@shellui/core 0.0.4
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 +17 -0
- package/dist/ContentView-CZG-ro_B.js +146 -0
- package/dist/ContentView-CZG-ro_B.js.map +1 -0
- package/dist/CookiePreferencesView-MhO9FO-4.js +213 -0
- package/dist/CookiePreferencesView-MhO9FO-4.js.map +1 -0
- package/dist/DefaultLayout-Dbb3uJED.js +394 -0
- package/dist/DefaultLayout-Dbb3uJED.js.map +1 -0
- package/dist/FullscreenLayout-1SgPHWw-.js +30 -0
- package/dist/FullscreenLayout-1SgPHWw-.js.map +1 -0
- package/dist/HomeView-DYU-O_Il.js +21 -0
- package/dist/HomeView-DYU-O_Il.js.map +1 -0
- package/dist/NotFoundView-CeYjJNg0.js +52 -0
- package/dist/NotFoundView-CeYjJNg0.js.map +1 -0
- package/dist/OverlayShell-pzbqQW25.js +642 -0
- package/dist/OverlayShell-pzbqQW25.js.map +1 -0
- package/dist/SettingsView-Bndrta44.js +2207 -0
- package/dist/SettingsView-Bndrta44.js.map +1 -0
- package/dist/ViewRoute-ChSPabOy.js +32 -0
- package/dist/ViewRoute-ChSPabOy.js.map +1 -0
- package/dist/WindowsLayout-CXGNPKoY.js +633 -0
- package/dist/WindowsLayout-CXGNPKoY.js.map +1 -0
- package/dist/app.d.ts +3 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/components/ContentView.d.ts +10 -0
- package/dist/components/ContentView.d.ts.map +1 -0
- package/dist/components/HomeView.d.ts +2 -0
- package/dist/components/HomeView.d.ts.map +1 -0
- package/dist/components/LoadingOverlay.d.ts +2 -0
- package/dist/components/LoadingOverlay.d.ts.map +1 -0
- package/dist/components/NotFoundView.d.ts +2 -0
- package/dist/components/NotFoundView.d.ts.map +1 -0
- package/dist/components/RouteErrorBoundary.d.ts +2 -0
- package/dist/components/RouteErrorBoundary.d.ts.map +1 -0
- package/dist/components/ViewRoute.d.ts +7 -0
- package/dist/components/ViewRoute.d.ts.map +1 -0
- package/dist/components/ui/alert-dialog.d.ts +32 -0
- package/dist/components/ui/alert-dialog.d.ts.map +1 -0
- package/dist/components/ui/breadcrumb.d.ts +20 -0
- package/dist/components/ui/breadcrumb.d.ts.map +1 -0
- package/dist/components/ui/button-group.d.ts +7 -0
- package/dist/components/ui/button-group.d.ts.map +1 -0
- package/dist/components/ui/button.d.ts +12 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/dialog.d.ts +24 -0
- package/dist/components/ui/dialog.d.ts.map +1 -0
- package/dist/components/ui/drawer.d.ts +38 -0
- package/dist/components/ui/drawer.d.ts.map +1 -0
- package/dist/components/ui/select.d.ts +5 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/sidebar.d.ts +46 -0
- package/dist/components/ui/sidebar.d.ts.map +1 -0
- package/dist/components/ui/sonner.d.ts +6 -0
- package/dist/components/ui/sonner.d.ts.map +1 -0
- package/dist/components/ui/switch.d.ts +8 -0
- package/dist/components/ui/switch.d.ts.map +1 -0
- package/dist/constants/urls.d.ts +6 -0
- package/dist/constants/urls.d.ts.map +1 -0
- package/dist/constants/urls.js +8 -0
- package/dist/constants/urls.js.map +1 -0
- package/dist/features/alertDialog/DialogContext.d.ts +12 -0
- package/dist/features/alertDialog/DialogContext.d.ts.map +1 -0
- package/dist/features/config/ConfigProvider.d.ts +15 -0
- package/dist/features/config/ConfigProvider.d.ts.map +1 -0
- package/dist/features/config/types.d.ts +177 -0
- package/dist/features/config/types.d.ts.map +1 -0
- package/dist/features/config/useConfig.d.ts +8 -0
- package/dist/features/config/useConfig.d.ts.map +1 -0
- package/dist/features/cookieConsent/CookieConsentModal.d.ts +6 -0
- package/dist/features/cookieConsent/CookieConsentModal.d.ts.map +1 -0
- package/dist/features/cookieConsent/CookiePreferencesView.d.ts +2 -0
- package/dist/features/cookieConsent/CookiePreferencesView.d.ts.map +1 -0
- package/dist/features/cookieConsent/cookieConsent.d.ts +22 -0
- package/dist/features/cookieConsent/cookieConsent.d.ts.map +1 -0
- package/dist/features/cookieConsent/useCookieConsent.d.ts +15 -0
- package/dist/features/cookieConsent/useCookieConsent.d.ts.map +1 -0
- package/dist/features/drawer/DrawerContext.d.ts +24 -0
- package/dist/features/drawer/DrawerContext.d.ts.map +1 -0
- package/dist/features/layouts/AppLayout.d.ts +12 -0
- package/dist/features/layouts/AppLayout.d.ts.map +1 -0
- package/dist/features/layouts/DefaultLayout.d.ts +10 -0
- package/dist/features/layouts/DefaultLayout.d.ts.map +1 -0
- package/dist/features/layouts/FullscreenLayout.d.ts +9 -0
- package/dist/features/layouts/FullscreenLayout.d.ts.map +1 -0
- package/dist/features/layouts/LayoutProviders.d.ts +9 -0
- package/dist/features/layouts/LayoutProviders.d.ts.map +1 -0
- package/dist/features/layouts/OverlayShell.d.ts +10 -0
- package/dist/features/layouts/OverlayShell.d.ts.map +1 -0
- package/dist/features/layouts/WindowsLayout.d.ts +24 -0
- package/dist/features/layouts/WindowsLayout.d.ts.map +1 -0
- package/dist/features/layouts/utils.d.ts +16 -0
- package/dist/features/layouts/utils.d.ts.map +1 -0
- package/dist/features/modal/ModalContext.d.ts +20 -0
- package/dist/features/modal/ModalContext.d.ts.map +1 -0
- package/dist/features/sentry/initSentry.d.ts +14 -0
- package/dist/features/sentry/initSentry.d.ts.map +1 -0
- package/dist/features/settings/SettingsContext.d.ts +10 -0
- package/dist/features/settings/SettingsContext.d.ts.map +1 -0
- package/dist/features/settings/SettingsIcons.d.ts +22 -0
- package/dist/features/settings/SettingsIcons.d.ts.map +1 -0
- package/dist/features/settings/SettingsProvider.d.ts +5 -0
- package/dist/features/settings/SettingsProvider.d.ts.map +1 -0
- package/dist/features/settings/SettingsRoutes.d.ts +7 -0
- package/dist/features/settings/SettingsRoutes.d.ts.map +1 -0
- package/dist/features/settings/SettingsView.d.ts +2 -0
- package/dist/features/settings/SettingsView.d.ts.map +1 -0
- package/dist/features/settings/components/Advanced.d.ts +2 -0
- package/dist/features/settings/components/Advanced.d.ts.map +1 -0
- package/dist/features/settings/components/Appearance.d.ts +2 -0
- package/dist/features/settings/components/Appearance.d.ts.map +1 -0
- package/dist/features/settings/components/DataPrivacy.d.ts +2 -0
- package/dist/features/settings/components/DataPrivacy.d.ts.map +1 -0
- package/dist/features/settings/components/Develop.d.ts +2 -0
- package/dist/features/settings/components/Develop.d.ts.map +1 -0
- package/dist/features/settings/components/LanguageAndRegion.d.ts +2 -0
- package/dist/features/settings/components/LanguageAndRegion.d.ts.map +1 -0
- package/dist/features/settings/components/ServiceWorker.d.ts +2 -0
- package/dist/features/settings/components/ServiceWorker.d.ts.map +1 -0
- package/dist/features/settings/components/UpdateApp.d.ts +2 -0
- package/dist/features/settings/components/UpdateApp.d.ts.map +1 -0
- package/dist/features/settings/components/develop/DialogTestButtons.d.ts +2 -0
- package/dist/features/settings/components/develop/DialogTestButtons.d.ts.map +1 -0
- package/dist/features/settings/components/develop/DrawerTestButtons.d.ts +2 -0
- package/dist/features/settings/components/develop/DrawerTestButtons.d.ts.map +1 -0
- package/dist/features/settings/components/develop/ModalTestButtons.d.ts +2 -0
- package/dist/features/settings/components/develop/ModalTestButtons.d.ts.map +1 -0
- package/dist/features/settings/components/develop/ToastTestButtons.d.ts +2 -0
- package/dist/features/settings/components/develop/ToastTestButtons.d.ts.map +1 -0
- package/dist/features/settings/hooks/useSettings.d.ts +2 -0
- package/dist/features/settings/hooks/useSettings.d.ts.map +1 -0
- package/dist/features/sonner/SonnerContext.d.ts +29 -0
- package/dist/features/sonner/SonnerContext.d.ts.map +1 -0
- package/dist/features/theme/ThemeProvider.d.ts +11 -0
- package/dist/features/theme/ThemeProvider.d.ts.map +1 -0
- package/dist/features/theme/themes.d.ts +114 -0
- package/dist/features/theme/themes.d.ts.map +1 -0
- package/dist/features/theme/useTheme.d.ts +10 -0
- package/dist/features/theme/useTheme.d.ts.map +1 -0
- package/dist/i18n/I18nProvider.d.ts +9 -0
- package/dist/i18n/I18nProvider.d.ts.map +1 -0
- package/dist/i18n/config.d.ts +23 -0
- package/dist/i18n/config.d.ts.map +1 -0
- package/dist/i18n/translations/en/common.json.d.ts +19 -0
- package/dist/i18n/translations/en/cookieConsent.json.d.ts +53 -0
- package/dist/i18n/translations/en/settings.json.d.ts +358 -0
- package/dist/i18n/translations/fr/common.json.d.ts +19 -0
- package/dist/i18n/translations/fr/cookieConsent.json.d.ts +53 -0
- package/dist/i18n/translations/fr/settings.json.d.ts +358 -0
- package/dist/index-lmRk5L6z.js +2160 -0
- package/dist/index-lmRk5L6z.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/z-index.d.ts +29 -0
- package/dist/lib/z-index.d.ts.map +1 -0
- package/dist/router/router.d.ts +3 -0
- package/dist/router/router.d.ts.map +1 -0
- package/dist/router/routes.d.ts +4 -0
- package/dist/router/routes.d.ts.map +1 -0
- package/dist/sidebar-ClIeZ2zb.js +303 -0
- package/dist/sidebar-ClIeZ2zb.js.map +1 -0
- package/dist/style.css +1 -0
- package/dist/switch-8SzUJz7Q.js +44 -0
- package/dist/switch-8SzUJz7Q.js.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +93 -0
- package/postcss.config.js +6 -0
- package/src/app.tsx +119 -0
- package/src/components/ContentView.tsx +258 -0
- package/src/components/HomeView.tsx +19 -0
- package/src/components/LoadingOverlay.tsx +12 -0
- package/src/components/NotFoundView.tsx +84 -0
- package/src/components/RouteErrorBoundary.tsx +95 -0
- package/src/components/ViewRoute.tsx +47 -0
- package/src/components/ui/alert-dialog.tsx +181 -0
- package/src/components/ui/breadcrumb.tsx +155 -0
- package/src/components/ui/button-group.tsx +52 -0
- package/src/components/ui/button.tsx +51 -0
- package/src/components/ui/dialog.tsx +160 -0
- package/src/components/ui/drawer.tsx +200 -0
- package/src/components/ui/select.tsx +24 -0
- package/src/components/ui/sidebar.tsx +406 -0
- package/src/components/ui/sonner.tsx +36 -0
- package/src/components/ui/switch.tsx +45 -0
- package/src/constants/urls.ts +4 -0
- package/src/features/alertDialog/DialogContext.tsx +468 -0
- package/src/features/config/ConfigProvider.ts +96 -0
- package/src/features/config/types.ts +195 -0
- package/src/features/config/useConfig.ts +15 -0
- package/src/features/cookieConsent/CookieConsentModal.tsx +122 -0
- package/src/features/cookieConsent/CookiePreferencesView.tsx +328 -0
- package/src/features/cookieConsent/cookieConsent.ts +84 -0
- package/src/features/cookieConsent/useCookieConsent.ts +39 -0
- package/src/features/drawer/DrawerContext.tsx +116 -0
- package/src/features/layouts/AppLayout.tsx +63 -0
- package/src/features/layouts/DefaultLayout.tsx +625 -0
- package/src/features/layouts/FullscreenLayout.tsx +55 -0
- package/src/features/layouts/LayoutProviders.tsx +20 -0
- package/src/features/layouts/OverlayShell.tsx +171 -0
- package/src/features/layouts/WindowsLayout.tsx +860 -0
- package/src/features/layouts/utils.ts +99 -0
- package/src/features/modal/ModalContext.tsx +112 -0
- package/src/features/sentry/initSentry.ts +72 -0
- package/src/features/settings/SettingsContext.tsx +19 -0
- package/src/features/settings/SettingsIcons.tsx +452 -0
- package/src/features/settings/SettingsProvider.tsx +341 -0
- package/src/features/settings/SettingsRoutes.tsx +66 -0
- package/src/features/settings/SettingsView.tsx +327 -0
- package/src/features/settings/components/Advanced.tsx +128 -0
- package/src/features/settings/components/Appearance.tsx +306 -0
- package/src/features/settings/components/DataPrivacy.tsx +142 -0
- package/src/features/settings/components/Develop.tsx +174 -0
- package/src/features/settings/components/LanguageAndRegion.tsx +329 -0
- package/src/features/settings/components/ServiceWorker.tsx +363 -0
- package/src/features/settings/components/UpdateApp.tsx +206 -0
- package/src/features/settings/components/develop/DialogTestButtons.tsx +137 -0
- package/src/features/settings/components/develop/DrawerTestButtons.tsx +67 -0
- package/src/features/settings/components/develop/ModalTestButtons.tsx +30 -0
- package/src/features/settings/components/develop/ToastTestButtons.tsx +179 -0
- package/src/features/settings/hooks/useSettings.tsx +10 -0
- package/src/features/sonner/SonnerContext.tsx +286 -0
- package/src/features/theme/ThemeProvider.tsx +16 -0
- package/src/features/theme/themes.ts +561 -0
- package/src/features/theme/useTheme.tsx +71 -0
- package/src/i18n/I18nProvider.tsx +32 -0
- package/src/i18n/config.ts +107 -0
- package/src/i18n/translations/en/common.json +16 -0
- package/src/i18n/translations/en/cookieConsent.json +50 -0
- package/src/i18n/translations/en/settings.json +355 -0
- package/src/i18n/translations/fr/common.json +16 -0
- package/src/i18n/translations/fr/cookieConsent.json +50 -0
- package/src/i18n/translations/fr/settings.json +355 -0
- package/src/index.css +412 -0
- package/src/index.html +100 -0
- package/src/index.ts +31 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/z-index.ts +29 -0
- package/src/main.tsx +26 -0
- package/src/router/router.tsx +8 -0
- package/src/router/routes.tsx +115 -0
- package/src/service-worker/register.ts +1199 -0
- package/src/service-worker/sw-dev.ts +87 -0
- package/src/service-worker/sw.ts +105 -0
- package/tailwind.config.js +60 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { shellui, type ShellUIMessage } from '@shellui/sdk';
|
|
2
|
+
import { createContext, useContext, useCallback, useEffect, type ReactNode } from 'react';
|
|
3
|
+
import { toast as sonnerToast } from 'sonner';
|
|
4
|
+
|
|
5
|
+
interface ToastOptions {
|
|
6
|
+
id?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
description?: string;
|
|
9
|
+
type?: 'default' | 'success' | 'error' | 'warning' | 'info' | 'loading';
|
|
10
|
+
duration?: number;
|
|
11
|
+
position?:
|
|
12
|
+
| 'top-left'
|
|
13
|
+
| 'top-center'
|
|
14
|
+
| 'top-right'
|
|
15
|
+
| 'bottom-left'
|
|
16
|
+
| 'bottom-center'
|
|
17
|
+
| 'bottom-right';
|
|
18
|
+
action?: {
|
|
19
|
+
label: string;
|
|
20
|
+
onClick: () => void;
|
|
21
|
+
};
|
|
22
|
+
cancel?: {
|
|
23
|
+
label: string;
|
|
24
|
+
onClick: () => void;
|
|
25
|
+
};
|
|
26
|
+
onDismiss?: () => void;
|
|
27
|
+
onAutoClose?: () => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface SonnerContextValue {
|
|
31
|
+
toast: (options: ToastOptions) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const SonnerContext = createContext<SonnerContextValue | undefined>(undefined);
|
|
35
|
+
|
|
36
|
+
export function useSonner() {
|
|
37
|
+
const context = useContext(SonnerContext);
|
|
38
|
+
if (!context) {
|
|
39
|
+
throw new Error('useSonner must be used within a SonnerProvider');
|
|
40
|
+
}
|
|
41
|
+
return context;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
interface SonnerProviderProps {
|
|
45
|
+
children: ReactNode;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export const SonnerProvider = ({ children }: SonnerProviderProps) => {
|
|
49
|
+
const toast = useCallback((options: ToastOptions) => {
|
|
50
|
+
const {
|
|
51
|
+
id,
|
|
52
|
+
title,
|
|
53
|
+
description,
|
|
54
|
+
type = 'default',
|
|
55
|
+
duration,
|
|
56
|
+
position,
|
|
57
|
+
action,
|
|
58
|
+
cancel,
|
|
59
|
+
onDismiss,
|
|
60
|
+
onAutoClose,
|
|
61
|
+
} = options;
|
|
62
|
+
|
|
63
|
+
const toastOptions: Parameters<typeof sonnerToast>[1] = {
|
|
64
|
+
id,
|
|
65
|
+
duration,
|
|
66
|
+
position,
|
|
67
|
+
action: action
|
|
68
|
+
? {
|
|
69
|
+
label: action.label,
|
|
70
|
+
onClick: action.onClick,
|
|
71
|
+
}
|
|
72
|
+
: undefined,
|
|
73
|
+
cancel: cancel
|
|
74
|
+
? {
|
|
75
|
+
label: cancel.label,
|
|
76
|
+
onClick: cancel.onClick,
|
|
77
|
+
}
|
|
78
|
+
: undefined,
|
|
79
|
+
onDismiss: onDismiss,
|
|
80
|
+
onAutoClose: onAutoClose,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
// If ID is provided, this is an update operation
|
|
84
|
+
if (id) {
|
|
85
|
+
switch (type) {
|
|
86
|
+
case 'success':
|
|
87
|
+
sonnerToast.success(title || 'Success', {
|
|
88
|
+
id,
|
|
89
|
+
description,
|
|
90
|
+
...toastOptions,
|
|
91
|
+
});
|
|
92
|
+
break;
|
|
93
|
+
case 'error':
|
|
94
|
+
sonnerToast.error(title || 'Error', {
|
|
95
|
+
id,
|
|
96
|
+
description,
|
|
97
|
+
...toastOptions,
|
|
98
|
+
});
|
|
99
|
+
break;
|
|
100
|
+
case 'warning':
|
|
101
|
+
sonnerToast.warning(title || 'Warning', {
|
|
102
|
+
id,
|
|
103
|
+
description,
|
|
104
|
+
...toastOptions,
|
|
105
|
+
});
|
|
106
|
+
break;
|
|
107
|
+
case 'info':
|
|
108
|
+
sonnerToast.info(title || 'Info', {
|
|
109
|
+
id,
|
|
110
|
+
description,
|
|
111
|
+
...toastOptions,
|
|
112
|
+
});
|
|
113
|
+
break;
|
|
114
|
+
case 'loading':
|
|
115
|
+
sonnerToast.loading(title || 'Loading...', {
|
|
116
|
+
id,
|
|
117
|
+
description,
|
|
118
|
+
...toastOptions,
|
|
119
|
+
});
|
|
120
|
+
break;
|
|
121
|
+
default:
|
|
122
|
+
sonnerToast(title || 'Notification', {
|
|
123
|
+
id,
|
|
124
|
+
description,
|
|
125
|
+
...toastOptions,
|
|
126
|
+
});
|
|
127
|
+
break;
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// Create new toast
|
|
133
|
+
switch (type) {
|
|
134
|
+
case 'success':
|
|
135
|
+
sonnerToast.success(title || 'Success', {
|
|
136
|
+
description,
|
|
137
|
+
...toastOptions,
|
|
138
|
+
});
|
|
139
|
+
break;
|
|
140
|
+
case 'error':
|
|
141
|
+
sonnerToast.error(title || 'Error', {
|
|
142
|
+
description,
|
|
143
|
+
...toastOptions,
|
|
144
|
+
});
|
|
145
|
+
break;
|
|
146
|
+
case 'warning':
|
|
147
|
+
sonnerToast.warning(title || 'Warning', {
|
|
148
|
+
description,
|
|
149
|
+
...toastOptions,
|
|
150
|
+
});
|
|
151
|
+
break;
|
|
152
|
+
case 'info':
|
|
153
|
+
sonnerToast.info(title || 'Info', {
|
|
154
|
+
description,
|
|
155
|
+
...toastOptions,
|
|
156
|
+
});
|
|
157
|
+
break;
|
|
158
|
+
case 'loading':
|
|
159
|
+
sonnerToast.loading(title || 'Loading...', {
|
|
160
|
+
description,
|
|
161
|
+
...toastOptions,
|
|
162
|
+
});
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
sonnerToast(title || 'Notification', {
|
|
166
|
+
description,
|
|
167
|
+
...toastOptions,
|
|
168
|
+
});
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}, []);
|
|
172
|
+
|
|
173
|
+
// Listen for postMessage events from nested iframes
|
|
174
|
+
useEffect(() => {
|
|
175
|
+
const cleanupToast = shellui.addMessageListener('SHELLUI_TOAST', (data: ShellUIMessage) => {
|
|
176
|
+
const payload = data.payload as ToastOptions;
|
|
177
|
+
toast({
|
|
178
|
+
...payload,
|
|
179
|
+
onDismiss: () => {
|
|
180
|
+
shellui.sendMessage({
|
|
181
|
+
type: 'SHELLUI_TOAST_CLEAR',
|
|
182
|
+
payload: { id: payload.id },
|
|
183
|
+
to: data.from,
|
|
184
|
+
});
|
|
185
|
+
},
|
|
186
|
+
onAutoClose: () => {
|
|
187
|
+
shellui.sendMessage({
|
|
188
|
+
type: 'SHELLUI_TOAST_CLEAR',
|
|
189
|
+
payload: { id: payload.id },
|
|
190
|
+
to: data.from,
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
action:
|
|
194
|
+
payload.action &&
|
|
195
|
+
(() => {
|
|
196
|
+
let actionSent = false;
|
|
197
|
+
return {
|
|
198
|
+
label: payload.action?.label ?? undefined,
|
|
199
|
+
onClick: () => {
|
|
200
|
+
if (actionSent) return;
|
|
201
|
+
actionSent = true;
|
|
202
|
+
shellui.sendMessage({
|
|
203
|
+
type: 'SHELLUI_TOAST_ACTION',
|
|
204
|
+
payload: { id: payload.id },
|
|
205
|
+
to: data.from,
|
|
206
|
+
});
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
})(),
|
|
210
|
+
cancel:
|
|
211
|
+
payload.cancel &&
|
|
212
|
+
(() => {
|
|
213
|
+
let cancelSent = false;
|
|
214
|
+
return {
|
|
215
|
+
label: payload.cancel?.label ?? undefined,
|
|
216
|
+
onClick: () => {
|
|
217
|
+
if (cancelSent) return;
|
|
218
|
+
cancelSent = true;
|
|
219
|
+
shellui.sendMessage({
|
|
220
|
+
type: 'SHELLUI_TOAST_CANCEL',
|
|
221
|
+
payload: { id: payload.id },
|
|
222
|
+
to: data.from,
|
|
223
|
+
});
|
|
224
|
+
},
|
|
225
|
+
};
|
|
226
|
+
})(),
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const cleanupToastUpdate = shellui.addMessageListener(
|
|
231
|
+
'SHELLUI_TOAST_UPDATE',
|
|
232
|
+
(data: ShellUIMessage) => {
|
|
233
|
+
const payload = data.payload as ToastOptions;
|
|
234
|
+
// CRITICAL: When updating a toast, we MUST re-register action handlers
|
|
235
|
+
// The callbackRegistry still has the callbacks, but the toast button needs onClick handlers
|
|
236
|
+
// that trigger the callbackRegistry via SHELLUI_TOAST_ACTION messages
|
|
237
|
+
toast({
|
|
238
|
+
...payload,
|
|
239
|
+
// Re-register action handlers so the button works after update
|
|
240
|
+
// These handlers send messages that trigger the callbackRegistry
|
|
241
|
+
action:
|
|
242
|
+
payload.action &&
|
|
243
|
+
(() => {
|
|
244
|
+
let actionSent = false;
|
|
245
|
+
return {
|
|
246
|
+
label: payload.action?.label ?? undefined,
|
|
247
|
+
onClick: () => {
|
|
248
|
+
if (actionSent) return;
|
|
249
|
+
actionSent = true;
|
|
250
|
+
shellui.sendMessage({
|
|
251
|
+
type: 'SHELLUI_TOAST_ACTION',
|
|
252
|
+
payload: { id: payload.id },
|
|
253
|
+
to: data.from,
|
|
254
|
+
});
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
})(),
|
|
258
|
+
cancel:
|
|
259
|
+
payload.cancel &&
|
|
260
|
+
(() => {
|
|
261
|
+
let cancelSent = false;
|
|
262
|
+
return {
|
|
263
|
+
label: payload.cancel?.label ?? undefined,
|
|
264
|
+
onClick: () => {
|
|
265
|
+
if (cancelSent) return;
|
|
266
|
+
cancelSent = true;
|
|
267
|
+
shellui.sendMessage({
|
|
268
|
+
type: 'SHELLUI_TOAST_CANCEL',
|
|
269
|
+
payload: { id: payload.id },
|
|
270
|
+
to: data.from,
|
|
271
|
+
});
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
})(),
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
);
|
|
278
|
+
|
|
279
|
+
return () => {
|
|
280
|
+
cleanupToast();
|
|
281
|
+
cleanupToastUpdate();
|
|
282
|
+
};
|
|
283
|
+
}, [toast]);
|
|
284
|
+
|
|
285
|
+
return <SonnerContext.Provider value={{ toast }}>{children}</SonnerContext.Provider>;
|
|
286
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { useTheme } from './useTheme';
|
|
3
|
+
|
|
4
|
+
export interface ThemeProviderProps {
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Provider that applies theme (light/dark/system and theme colors) from settings.
|
|
10
|
+
* Must be rendered inside SettingsProvider so useTheme can read appearance settings.
|
|
11
|
+
* Applies theme to document.documentElement and listens to system preference changes.
|
|
12
|
+
*/
|
|
13
|
+
export function ThemeProvider({ children }: ThemeProviderProps) {
|
|
14
|
+
useTheme();
|
|
15
|
+
return <>{children}</>;
|
|
16
|
+
}
|