@dashadmin/dash-boilerplate 1.3.25 → 1.3.28
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 +35 -0
- package/dist/index.cjs +1234 -0
- package/dist/index.js +871 -534
- package/package.json +55 -57
- package/dist/components/AppWrapperLight.js +0 -5
- package/dist/components/CustomErrorBoundary.js +0 -1
- package/dist/components/DefaultFallbacks.js +0 -1
- package/dist/components/GlobalSmallLoader.js +0 -55
- package/dist/components/index.js +0 -1
- package/dist/i18n/I18nBridgeProviderLight.js +0 -1
- package/dist/i18n/createSimpleI18nProvider.js +0 -1
- package/dist/i18n/index.js +0 -1
- package/dist/i18n/types.js +0 -0
- package/dist/theme/DashThemeProviderLight.js +0 -1
- package/dist/theme/index.js +0 -1
- package/dist/utils/DashBootstrapUtils.js +0 -1
- package/dist/utils/cssVariables.js +0 -1
- package/dist/utils/electronStore.js +0 -1
- package/dist/utils/index.js +0 -1
package/dist/index.js
CHANGED
|
@@ -1,127 +1,258 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
33
|
+
var __async = (__this, __arguments, generator) => {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
var fulfilled = (value) => {
|
|
36
|
+
try {
|
|
37
|
+
step(generator.next(value));
|
|
38
|
+
} catch (e) {
|
|
39
|
+
reject(e);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var rejected = (value) => {
|
|
43
|
+
try {
|
|
44
|
+
step(generator.throw(value));
|
|
45
|
+
} catch (e) {
|
|
46
|
+
reject(e);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
50
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
51
|
+
});
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/i18n/createSimpleI18nProvider.ts
|
|
55
|
+
var getNestedValue = (obj, path) => {
|
|
56
|
+
return path.split(".").reduce((prev, curr) => prev ? prev[curr] : null, obj);
|
|
57
|
+
};
|
|
58
|
+
var interpolate = (text, options) => {
|
|
59
|
+
if (!options || !text) return text;
|
|
60
|
+
return Object.keys(options).reduce((acc, key) => {
|
|
61
|
+
return acc.replace(new RegExp(`%\\{${key}\\}`, "g"), String(options[key]));
|
|
62
|
+
}, text);
|
|
63
|
+
};
|
|
64
|
+
var defaultLocales = [
|
|
13
65
|
{ locale: "en", name: "English" },
|
|
14
|
-
{ locale: "es", name: "
|
|
15
|
-
]
|
|
66
|
+
{ locale: "es", name: "Espa\xF1ol" }
|
|
67
|
+
];
|
|
68
|
+
var createSimpleI18nProvider = (options) => {
|
|
16
69
|
const {
|
|
17
|
-
translations
|
|
18
|
-
initialLocale
|
|
19
|
-
fallbackLocale
|
|
20
|
-
locales
|
|
21
|
-
onLocaleChange
|
|
22
|
-
} =
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
70
|
+
translations,
|
|
71
|
+
initialLocale = "es",
|
|
72
|
+
fallbackLocale = "en",
|
|
73
|
+
locales = defaultLocales,
|
|
74
|
+
onLocaleChange
|
|
75
|
+
} = options;
|
|
76
|
+
let currentLocale = initialLocale;
|
|
77
|
+
const translate = (key, interpolationOptions) => {
|
|
78
|
+
const messages = translations[currentLocale] || translations[fallbackLocale] || {};
|
|
79
|
+
const text = getNestedValue(messages, key);
|
|
80
|
+
if (typeof text === "string") {
|
|
81
|
+
return interpolate(text, interpolationOptions);
|
|
82
|
+
}
|
|
83
|
+
if (currentLocale !== fallbackLocale) {
|
|
84
|
+
const fallbackMessages = translations[fallbackLocale] || {};
|
|
85
|
+
const fallbackText = getNestedValue(fallbackMessages, key);
|
|
86
|
+
if (typeof fallbackText === "string") {
|
|
87
|
+
return interpolate(fallbackText, interpolationOptions);
|
|
33
88
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
89
|
+
}
|
|
90
|
+
return key;
|
|
91
|
+
};
|
|
92
|
+
const changeLocale = (newLocale) => __async(null, null, function* () {
|
|
93
|
+
if (translations[newLocale]) {
|
|
94
|
+
currentLocale = newLocale;
|
|
95
|
+
localStorage.setItem("dash-user-locale", newLocale);
|
|
96
|
+
onLocaleChange == null ? void 0 : onLocaleChange(newLocale);
|
|
97
|
+
return Promise.resolve();
|
|
98
|
+
}
|
|
99
|
+
return Promise.reject(new Error(`Locale '${newLocale}' not found`));
|
|
100
|
+
});
|
|
101
|
+
const getLocale = () => currentLocale;
|
|
102
|
+
const getLocales = () => locales;
|
|
103
|
+
const getMessages = (locale) => {
|
|
104
|
+
return translations[locale] || {};
|
|
105
|
+
};
|
|
106
|
+
return {
|
|
107
|
+
translate,
|
|
108
|
+
changeLocale,
|
|
109
|
+
getLocale,
|
|
110
|
+
getLocales,
|
|
111
|
+
getMessages
|
|
40
112
|
};
|
|
41
|
-
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/i18n/I18nBridgeProviderLight.tsx
|
|
116
|
+
import { createContext, useContext, useState, useCallback, useMemo, useEffect } from "react";
|
|
117
|
+
import { jsx } from "react/jsx-runtime";
|
|
118
|
+
var LOCALE_CHANGE_EVENT = "dash:locale-change";
|
|
119
|
+
var defaultContextValue = {
|
|
42
120
|
i18nProvider: null,
|
|
43
121
|
locale: "es",
|
|
44
122
|
setI18nProvider: () => {
|
|
45
123
|
},
|
|
46
124
|
setLocale: () => {
|
|
47
125
|
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
126
|
+
};
|
|
127
|
+
var I18nBridgeContext = createContext(defaultContextValue);
|
|
128
|
+
var I18nBridgeProviderLight = ({
|
|
129
|
+
children,
|
|
130
|
+
defaultLocale = "es"
|
|
51
131
|
}) => {
|
|
52
|
-
const [
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
132
|
+
const [i18nProvider, setI18nProviderState] = useState(null);
|
|
133
|
+
const [locale, setLocale] = useState(() => {
|
|
134
|
+
if (typeof window !== "undefined") {
|
|
135
|
+
return localStorage.getItem("dash-user-locale") || defaultLocale;
|
|
136
|
+
}
|
|
137
|
+
return defaultLocale;
|
|
138
|
+
});
|
|
139
|
+
const setI18nProvider = useCallback((provider) => __async(null, null, function* () {
|
|
140
|
+
var _a, _b;
|
|
141
|
+
console.log("\u{1F310} I18nBridgeProviderLight: Setting bridged i18nProvider", {
|
|
142
|
+
providerLocale: (_a = provider == null ? void 0 : provider.getLocale) == null ? void 0 : _a.call(provider),
|
|
143
|
+
desiredLocale: locale
|
|
144
|
+
});
|
|
145
|
+
setI18nProviderState(provider);
|
|
146
|
+
const providerLocale = (_b = provider == null ? void 0 : provider.getLocale) == null ? void 0 : _b.call(provider);
|
|
147
|
+
if (providerLocale && providerLocale !== locale && (provider == null ? void 0 : provider.changeLocale)) {
|
|
148
|
+
console.log(`\u{1F310} I18nBridgeProviderLight: Provider locale (${providerLocale}) differs from desired (${locale}), switching...`);
|
|
60
149
|
try {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
150
|
+
yield provider.changeLocale(locale);
|
|
151
|
+
console.log(`\u{1F310} I18nBridgeProviderLight: Successfully switched provider to ${locale}`);
|
|
152
|
+
} catch (e) {
|
|
153
|
+
console.warn("\u{1F310} I18nBridgeProviderLight: Failed to switch provider locale:", e);
|
|
64
154
|
}
|
|
65
|
-
} else
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
155
|
+
} else if (provider == null ? void 0 : provider.getLocale) {
|
|
156
|
+
setLocale(provider.getLocale());
|
|
157
|
+
}
|
|
158
|
+
}), [locale]);
|
|
159
|
+
useEffect(() => {
|
|
160
|
+
const handleLocaleChange = (event) => __async(null, null, function* () {
|
|
161
|
+
var _a;
|
|
162
|
+
const customEvent = event;
|
|
163
|
+
const newLocale = (_a = customEvent.detail) == null ? void 0 : _a.locale;
|
|
164
|
+
if (newLocale && newLocale !== locale) {
|
|
165
|
+
console.log("\u{1F310} I18nBridgeProviderLight: Received locale change event:", newLocale);
|
|
166
|
+
if (i18nProvider == null ? void 0 : i18nProvider.changeLocale) {
|
|
72
167
|
try {
|
|
73
|
-
|
|
74
|
-
} catch (
|
|
75
|
-
console.warn("Failed to change provider locale:",
|
|
168
|
+
yield i18nProvider.changeLocale(newLocale);
|
|
169
|
+
} catch (e) {
|
|
170
|
+
console.warn("Failed to change provider locale:", e);
|
|
76
171
|
}
|
|
77
|
-
|
|
172
|
+
}
|
|
173
|
+
setLocale(newLocale);
|
|
78
174
|
}
|
|
175
|
+
});
|
|
176
|
+
window.addEventListener(LOCALE_CHANGE_EVENT, handleLocaleChange);
|
|
177
|
+
return () => {
|
|
178
|
+
window.removeEventListener(LOCALE_CHANGE_EVENT, handleLocaleChange);
|
|
79
179
|
};
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
return
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
180
|
+
}, [i18nProvider, locale]);
|
|
181
|
+
const contextValue = useMemo(() => ({
|
|
182
|
+
i18nProvider,
|
|
183
|
+
locale,
|
|
184
|
+
setI18nProvider,
|
|
185
|
+
setLocale
|
|
186
|
+
}), [i18nProvider, locale, setI18nProvider]);
|
|
187
|
+
return /* @__PURE__ */ jsx(I18nBridgeContext.Provider, { value: contextValue, children });
|
|
188
|
+
};
|
|
189
|
+
var useI18nBridgeLight = () => {
|
|
190
|
+
const context = useContext(I18nBridgeContext);
|
|
191
|
+
return context;
|
|
192
|
+
};
|
|
193
|
+
var useBridgedLocalesLight = () => {
|
|
194
|
+
const { i18nProvider } = useI18nBridgeLight();
|
|
195
|
+
const locales = useMemo(() => {
|
|
196
|
+
if (!(i18nProvider == null ? void 0 : i18nProvider.getLocales)) {
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
return i18nProvider.getLocales();
|
|
200
|
+
}, [i18nProvider]);
|
|
201
|
+
return locales;
|
|
202
|
+
};
|
|
203
|
+
var useBridgedChangeLocaleLight = () => {
|
|
204
|
+
const { i18nProvider, setLocale } = useI18nBridgeLight();
|
|
205
|
+
const changeLocale = useCallback((locale) => __async(null, null, function* () {
|
|
206
|
+
if (i18nProvider == null ? void 0 : i18nProvider.changeLocale) {
|
|
207
|
+
yield i18nProvider.changeLocale(locale);
|
|
208
|
+
setLocale(locale);
|
|
209
|
+
}
|
|
210
|
+
}), [i18nProvider, setLocale]);
|
|
211
|
+
return changeLocale;
|
|
212
|
+
};
|
|
213
|
+
var useBridgedLocaleLight = () => {
|
|
214
|
+
const { locale } = useI18nBridgeLight();
|
|
215
|
+
return locale;
|
|
216
|
+
};
|
|
217
|
+
var useTranslateLight = () => {
|
|
218
|
+
const { i18nProvider } = useI18nBridgeLight();
|
|
219
|
+
const translate = useCallback((key, options) => {
|
|
220
|
+
if (i18nProvider == null ? void 0 : i18nProvider.translate) {
|
|
221
|
+
return i18nProvider.translate(key, options);
|
|
222
|
+
}
|
|
223
|
+
return key;
|
|
224
|
+
}, [i18nProvider]);
|
|
225
|
+
return translate;
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
// src/components/GlobalSmallLoader.tsx
|
|
229
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
230
|
+
var loaderSvgMarkup = `<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="32px" height="32px" style="shape-rendering:geometricPrecision; text-rendering:geometricPrecision; image-rendering:optimizeQuality; fill-rule:evenodd; clip-rule:evenodd" viewBox="0 0 16 16"><g><path style="opacity:1" fill="#FFFFFF" d="M11.506 12.388q0.306 0.011 0.617 0.008v1.281h-0.89a2 2 0 0 1 -0.898 -0.215 1.24 1.24 0 0 1 -0.629 -0.761 2.5 2.5 0 0 1 -0.094 -0.554q-0.006 -1.082 -0.004 -2.163h-0.609q0.002 -0.398 -0.004 -0.796a616 616 0 0 0 -1.676 2.023 657 657 0 0 0 2.069 2.46q-0.935 0.012 -1.874 0.008L6.003 11.61q-0.006 1.035 -0.004 2.069H4.485q0.004 -2.983 -0.008 -5.966 -0.661 -0.21 -0.863 -0.875a2 2 0 0 1 -0.039 -0.258q-0.008 -2.108 0 -4.217 0.12 -0.356 0.48 -0.246 0.153 0.079 0.191 0.246l0.008 3.272q0.05 0.116 0.168 0.066 0.035 -0.027 0.051 -0.066l0.008 -3.264q0.095 -0.329 0.433 -0.269 0.191 0.059 0.238 0.254l0.008 3.272q0.065 0.14 0.195 0.055l0.023 -0.039 0.008 -3.264q0.086 -0.321 0.418 -0.285 0.197 0.057 0.254 0.254a352 352 0 0 1 0.016 3.295q0.062 0.109 0.176 0.051 0.029 -0.028 0.043 -0.066l0.008 -3.28q0.045 -0.17 0.207 -0.238 0.25 -0.074 0.41 0.129a0.5 0.5 0 0 1 0.047 0.109q0.014 1.063 0.012 2.128 0.002 1.088 -0.012 2.175 -0.137 0.844 -0.96 1.078a301 301 0 0 0 0 3.006q0.753 -1.005 1.503 -2.011 1.05 -0.006 2.101 -0.004 0.002 -0.519 -0.004 -1.039a1.82 1.82 0 0 1 -1.281 -1.101q-0.197 -0.504 -0.211 -1.046a4.7 4.7 0 0 1 0.383 -2.03q0.242 -0.547 0.668 -0.964 0.395 -0.364 0.929 -0.445 0.695 -0.056 1.218 0.398 0.476 0.438 0.73 1.035 0.513 1.212 0.32 2.514a2.26 2.26 0 0 1 -0.484 1.07 1.75 1.75 0 0 1 -0.754 0.5v1.109h0.992v1.265h-0.992q-0.002 1.042 0.004 2.085 0.05 0.323 0.379 0.32"/></g></svg>`;
|
|
231
|
+
var KTIcon = () => /* @__PURE__ */ jsx2("span", { dangerouslySetInnerHTML: { __html: loaderSvgMarkup } });
|
|
232
|
+
var GlobalSmallLoader = ({
|
|
233
|
+
message,
|
|
234
|
+
showMessage = false
|
|
235
|
+
}) => /* @__PURE__ */ jsxs("div", { children: [
|
|
236
|
+
/* @__PURE__ */ jsxs("div", { className: "initial-loader", children: [
|
|
237
|
+
/* @__PURE__ */ jsx2("div", { className: "initial-loader-spinner" }),
|
|
238
|
+
/* @__PURE__ */ jsx2("span", { className: "initial-loader-icon", children: /* @__PURE__ */ jsx2(KTIcon, {}) })
|
|
112
239
|
] }),
|
|
113
|
-
|
|
114
|
-
] })
|
|
240
|
+
showMessage && message && /* @__PURE__ */ jsx2("div", { className: "initial-loader-text", children: message })
|
|
241
|
+
] });
|
|
242
|
+
var GlobalLoaderHtmlMarkup = `<div class="initial-loader">
|
|
115
243
|
<div class="initial-loader-spinner">
|
|
116
244
|
<span class="initial-loader-icon">
|
|
117
|
-
${
|
|
245
|
+
${loaderSvgMarkup}
|
|
118
246
|
</span>
|
|
119
247
|
</div>
|
|
120
248
|
<div class="initial-loader-text"></div>
|
|
121
|
-
</div
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
249
|
+
</div>`;
|
|
250
|
+
var injectCriticalStyles = () => {
|
|
251
|
+
if (typeof document === "undefined") return;
|
|
252
|
+
if (document.getElementById("critical-loading-styles")) return;
|
|
253
|
+
const style = document.createElement("style");
|
|
254
|
+
style.id = "critical-loading-styles";
|
|
255
|
+
style.textContent = `
|
|
125
256
|
.initial-loader {
|
|
126
257
|
position: fixed;
|
|
127
258
|
top: 0;
|
|
@@ -168,61 +299,81 @@ const M = (t, e) => e.split(".").reduce((o, r) => o ? o[r] : null, t), N = (t, e
|
|
|
168
299
|
@keyframes spin {
|
|
169
300
|
to { transform: rotate(360deg); }
|
|
170
301
|
}
|
|
171
|
-
|
|
302
|
+
`;
|
|
303
|
+
document.head.appendChild(style);
|
|
172
304
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
305
|
+
|
|
306
|
+
// src/components/CustomErrorBoundary.tsx
|
|
307
|
+
import React2 from "react";
|
|
308
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
309
|
+
var CustomErrorBoundary = class extends React2.Component {
|
|
310
|
+
constructor(props) {
|
|
311
|
+
super(props);
|
|
312
|
+
__publicField(this, "handleReload", () => {
|
|
313
|
+
window.location.reload();
|
|
314
|
+
});
|
|
315
|
+
this.state = { hasError: false };
|
|
176
316
|
}
|
|
177
|
-
static getDerivedStateFromError(
|
|
178
|
-
return { hasError:
|
|
317
|
+
static getDerivedStateFromError(error) {
|
|
318
|
+
return { hasError: true, error };
|
|
179
319
|
}
|
|
180
|
-
componentDidCatch(
|
|
181
|
-
|
|
320
|
+
componentDidCatch(error, errorInfo) {
|
|
321
|
+
var _a, _b;
|
|
322
|
+
console.error("CustomErrorBoundary caught error:", error, errorInfo);
|
|
323
|
+
(_b = (_a = this.props).onError) == null ? void 0 : _b.call(_a, error, errorInfo);
|
|
182
324
|
}
|
|
183
|
-
handleReload = () => {
|
|
184
|
-
window.location.reload();
|
|
185
|
-
};
|
|
186
325
|
render() {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
{
|
|
190
|
-
|
|
191
|
-
display: "flex",
|
|
192
|
-
justifyContent: "center",
|
|
193
|
-
alignItems: "center",
|
|
194
|
-
height: "100vh",
|
|
195
|
-
backgroundColor: "var(--bodybg-primary, #121212)",
|
|
196
|
-
color: "var(--text-color, #ffffff)",
|
|
197
|
-
flexDirection: "column",
|
|
198
|
-
gap: "20px"
|
|
199
|
-
},
|
|
200
|
-
children: [
|
|
201
|
-
/* @__PURE__ */ c("h2", { children: "Something went wrong" }),
|
|
202
|
-
/* @__PURE__ */ c("p", { style: { opacity: 0.8 }, children: this.state.error?.message }),
|
|
203
|
-
/* @__PURE__ */ c(
|
|
204
|
-
"button",
|
|
205
|
-
{
|
|
206
|
-
onClick: this.handleReload,
|
|
207
|
-
style: {
|
|
208
|
-
padding: "10px 20px",
|
|
209
|
-
backgroundColor: "var(--primary-color, #007bff)",
|
|
210
|
-
color: "white",
|
|
211
|
-
border: "none",
|
|
212
|
-
borderRadius: "4px",
|
|
213
|
-
cursor: "pointer",
|
|
214
|
-
fontSize: "14px",
|
|
215
|
-
fontWeight: 500
|
|
216
|
-
},
|
|
217
|
-
children: "Reload Page"
|
|
218
|
-
}
|
|
219
|
-
)
|
|
220
|
-
]
|
|
326
|
+
var _a;
|
|
327
|
+
if (this.state.hasError) {
|
|
328
|
+
if (this.props.fallback) {
|
|
329
|
+
return this.props.fallback;
|
|
221
330
|
}
|
|
222
|
-
|
|
331
|
+
return /* @__PURE__ */ jsxs2(
|
|
332
|
+
"div",
|
|
333
|
+
{
|
|
334
|
+
style: {
|
|
335
|
+
display: "flex",
|
|
336
|
+
justifyContent: "center",
|
|
337
|
+
alignItems: "center",
|
|
338
|
+
height: "100vh",
|
|
339
|
+
backgroundColor: "var(--bodybg-primary, #121212)",
|
|
340
|
+
color: "var(--text-color, #ffffff)",
|
|
341
|
+
flexDirection: "column",
|
|
342
|
+
gap: "20px"
|
|
343
|
+
},
|
|
344
|
+
children: [
|
|
345
|
+
/* @__PURE__ */ jsx3("h2", { children: "Something went wrong" }),
|
|
346
|
+
/* @__PURE__ */ jsx3("p", { style: { opacity: 0.8 }, children: (_a = this.state.error) == null ? void 0 : _a.message }),
|
|
347
|
+
/* @__PURE__ */ jsx3(
|
|
348
|
+
"button",
|
|
349
|
+
{
|
|
350
|
+
onClick: this.handleReload,
|
|
351
|
+
style: {
|
|
352
|
+
padding: "10px 20px",
|
|
353
|
+
backgroundColor: "var(--primary-color, #007bff)",
|
|
354
|
+
color: "white",
|
|
355
|
+
border: "none",
|
|
356
|
+
borderRadius: "4px",
|
|
357
|
+
cursor: "pointer",
|
|
358
|
+
fontSize: "14px",
|
|
359
|
+
fontWeight: 500
|
|
360
|
+
},
|
|
361
|
+
children: "Reload Page"
|
|
362
|
+
}
|
|
363
|
+
)
|
|
364
|
+
]
|
|
365
|
+
}
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
return this.props.children;
|
|
223
369
|
}
|
|
224
|
-
}
|
|
225
|
-
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
// src/components/AppWrapperLight.tsx
|
|
373
|
+
import React3, { Suspense, useState as useState2, useTransition } from "react";
|
|
374
|
+
import { ErrorBoundary } from "react-error-boundary";
|
|
375
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
376
|
+
var ErrorFallback = ({ error, resetErrorBoundary }) => /* @__PURE__ */ jsxs3(
|
|
226
377
|
"div",
|
|
227
378
|
{
|
|
228
379
|
style: {
|
|
@@ -236,12 +387,12 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
|
|
|
236
387
|
backgroundColor: "var(--bodybg-primary)"
|
|
237
388
|
},
|
|
238
389
|
children: [
|
|
239
|
-
/* @__PURE__ */
|
|
240
|
-
/* @__PURE__ */
|
|
241
|
-
/* @__PURE__ */
|
|
390
|
+
/* @__PURE__ */ jsx4("h1", { style: { margin: 0, fontSize: "1.5rem" }, children: "Something went wrong" }),
|
|
391
|
+
/* @__PURE__ */ jsx4("p", { style: { margin: 0, opacity: 0.8 }, children: (error == null ? void 0 : error.message) || "Unknown error" }),
|
|
392
|
+
/* @__PURE__ */ jsx4(
|
|
242
393
|
"button",
|
|
243
394
|
{
|
|
244
|
-
onClick:
|
|
395
|
+
onClick: resetErrorBoundary,
|
|
245
396
|
style: {
|
|
246
397
|
padding: "8px 24px",
|
|
247
398
|
backgroundColor: "var(--primary-color)",
|
|
@@ -257,7 +408,8 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
|
|
|
257
408
|
)
|
|
258
409
|
]
|
|
259
410
|
}
|
|
260
|
-
)
|
|
411
|
+
);
|
|
412
|
+
var SimpleLoader = () => /* @__PURE__ */ jsxs3(
|
|
261
413
|
"div",
|
|
262
414
|
{
|
|
263
415
|
style: {
|
|
@@ -268,7 +420,7 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
|
|
|
268
420
|
backgroundColor: "var(--bodybg-primary)"
|
|
269
421
|
},
|
|
270
422
|
children: [
|
|
271
|
-
/* @__PURE__ */
|
|
423
|
+
/* @__PURE__ */ jsx4(
|
|
272
424
|
"div",
|
|
273
425
|
{
|
|
274
426
|
className: "loading-spinner",
|
|
@@ -282,30 +434,43 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
|
|
|
282
434
|
}
|
|
283
435
|
}
|
|
284
436
|
),
|
|
285
|
-
/* @__PURE__ */
|
|
437
|
+
/* @__PURE__ */ jsx4("style", { children: `
|
|
286
438
|
@keyframes spin {
|
|
287
439
|
to { transform: rotate(360deg); }
|
|
288
440
|
}
|
|
289
441
|
` })
|
|
290
442
|
]
|
|
291
443
|
}
|
|
292
|
-
)
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
444
|
+
);
|
|
445
|
+
var AppWrapperLight = ({
|
|
446
|
+
children,
|
|
447
|
+
onReset,
|
|
448
|
+
showSplash = true
|
|
296
449
|
}) => {
|
|
297
|
-
const [
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
450
|
+
const [isPending, startTransition] = useTransition();
|
|
451
|
+
const [isInitialRender, setIsInitialRender] = useState2(true);
|
|
452
|
+
React3.useEffect(() => {
|
|
453
|
+
startTransition(() => {
|
|
454
|
+
setIsInitialRender(false);
|
|
301
455
|
});
|
|
302
|
-
}, [])
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
456
|
+
}, []);
|
|
457
|
+
const handleReset = () => {
|
|
458
|
+
if (onReset) {
|
|
459
|
+
onReset();
|
|
460
|
+
} else {
|
|
461
|
+
window.location.reload();
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
return /* @__PURE__ */ jsxs3(Fragment, { children: [
|
|
465
|
+
/* @__PURE__ */ jsx4(ErrorBoundary, { FallbackComponent: ErrorFallback, onReset: handleReset, children: /* @__PURE__ */ jsx4(Suspense, { fallback: /* @__PURE__ */ jsx4(SimpleLoader, {}), children }) }),
|
|
466
|
+
showSplash && /* @__PURE__ */ jsx4("div", { className: !isPending && !isInitialRender ? "dash-splash fade-out" : "dash-splash" })
|
|
307
467
|
] });
|
|
308
|
-
}
|
|
468
|
+
};
|
|
469
|
+
|
|
470
|
+
// src/components/DefaultFallbacks.tsx
|
|
471
|
+
import React4 from "react";
|
|
472
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
473
|
+
var defaultContainerStyle = {
|
|
309
474
|
display: "flex",
|
|
310
475
|
flexDirection: "column",
|
|
311
476
|
justifyContent: "center",
|
|
@@ -314,12 +479,14 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
|
|
|
314
479
|
gap: "16px",
|
|
315
480
|
color: "var(--text-color, #333)",
|
|
316
481
|
backgroundColor: "var(--background-color, #fff)"
|
|
317
|
-
}
|
|
482
|
+
};
|
|
483
|
+
var defaultErrorMessageStyle = {
|
|
318
484
|
margin: 0,
|
|
319
485
|
fontSize: "1.25rem",
|
|
320
486
|
fontWeight: 500,
|
|
321
487
|
color: "#f44336"
|
|
322
|
-
}
|
|
488
|
+
};
|
|
489
|
+
var defaultButtonStyle = {
|
|
323
490
|
marginTop: "16px",
|
|
324
491
|
padding: "8px 16px",
|
|
325
492
|
backgroundColor: "#1976d2",
|
|
@@ -329,36 +496,38 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
|
|
|
329
496
|
cursor: "pointer",
|
|
330
497
|
fontSize: "14px",
|
|
331
498
|
fontWeight: 500
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
499
|
+
};
|
|
500
|
+
var DefaultInitializationErrorFallback = ({
|
|
501
|
+
error,
|
|
502
|
+
message = "Failed to initialize application",
|
|
503
|
+
onRetry = () => window.location.reload(),
|
|
504
|
+
retryLabel = "Retry",
|
|
505
|
+
containerStyle,
|
|
506
|
+
messageStyle,
|
|
507
|
+
buttonStyle
|
|
340
508
|
}) => {
|
|
341
|
-
const
|
|
342
|
-
return /* @__PURE__ */
|
|
343
|
-
/* @__PURE__ */
|
|
344
|
-
/* @__PURE__ */
|
|
509
|
+
const errorMessage = error instanceof Error ? error.message : error || message;
|
|
510
|
+
return /* @__PURE__ */ jsxs4("div", { style: __spreadValues(__spreadValues({}, defaultContainerStyle), containerStyle), children: [
|
|
511
|
+
/* @__PURE__ */ jsx5("h6", { style: __spreadValues(__spreadValues({}, defaultErrorMessageStyle), messageStyle), children: errorMessage }),
|
|
512
|
+
/* @__PURE__ */ jsx5(
|
|
345
513
|
"button",
|
|
346
514
|
{
|
|
347
|
-
onClick:
|
|
348
|
-
style: {
|
|
349
|
-
children:
|
|
515
|
+
onClick: onRetry,
|
|
516
|
+
style: __spreadValues(__spreadValues({}, defaultButtonStyle), buttonStyle),
|
|
517
|
+
children: retryLabel
|
|
350
518
|
}
|
|
351
519
|
)
|
|
352
520
|
] });
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
521
|
+
};
|
|
522
|
+
var DefaultAppLoadErrorFallback = ({
|
|
523
|
+
message = "Failed to load application",
|
|
524
|
+
onRetry = () => window.location.reload(),
|
|
525
|
+
retryLabel = "Retry",
|
|
526
|
+
containerStyle,
|
|
527
|
+
messageStyle,
|
|
528
|
+
buttonStyle
|
|
360
529
|
}) => {
|
|
361
|
-
const
|
|
530
|
+
const appLoadContainerStyle = {
|
|
362
531
|
display: "flex",
|
|
363
532
|
flexDirection: "column",
|
|
364
533
|
justifyContent: "center",
|
|
@@ -366,7 +535,8 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
|
|
|
366
535
|
height: "100vh",
|
|
367
536
|
color: "#000000",
|
|
368
537
|
gap: "12px"
|
|
369
|
-
}
|
|
538
|
+
};
|
|
539
|
+
const appLoadButtonStyle = {
|
|
370
540
|
padding: "8px 24px",
|
|
371
541
|
backgroundColor: "#57005aff",
|
|
372
542
|
color: "#fff",
|
|
@@ -374,97 +544,125 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
|
|
|
374
544
|
borderRadius: "4px",
|
|
375
545
|
cursor: "pointer"
|
|
376
546
|
};
|
|
377
|
-
return /* @__PURE__ */
|
|
378
|
-
/* @__PURE__ */
|
|
379
|
-
/* @__PURE__ */
|
|
547
|
+
return /* @__PURE__ */ jsxs4("div", { style: __spreadValues(__spreadValues({}, appLoadContainerStyle), containerStyle), children: [
|
|
548
|
+
/* @__PURE__ */ jsx5("h1", { style: messageStyle, children: message }),
|
|
549
|
+
/* @__PURE__ */ jsx5(
|
|
380
550
|
"button",
|
|
381
551
|
{
|
|
382
|
-
onClick:
|
|
383
|
-
style: {
|
|
384
|
-
children:
|
|
552
|
+
onClick: onRetry,
|
|
553
|
+
style: __spreadValues(__spreadValues({}, appLoadButtonStyle), buttonStyle),
|
|
554
|
+
children: retryLabel
|
|
385
555
|
}
|
|
386
556
|
)
|
|
387
557
|
] });
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
558
|
+
};
|
|
559
|
+
var createLazyAppLoader = ({
|
|
560
|
+
importFn,
|
|
561
|
+
delay = 100,
|
|
562
|
+
ErrorFallback: ErrorFallback2 = DefaultAppLoadErrorFallback,
|
|
563
|
+
errorMessage = "Failed to load application"
|
|
564
|
+
}) => {
|
|
565
|
+
return React4.lazy(() => {
|
|
566
|
+
return new Promise((resolve) => {
|
|
567
|
+
setTimeout(() => {
|
|
568
|
+
importFn().then((mod) => {
|
|
569
|
+
resolve({ default: mod.default });
|
|
570
|
+
}).catch((error) => {
|
|
571
|
+
console.error("Failed to load application:", error);
|
|
572
|
+
resolve({
|
|
573
|
+
default: () => /* @__PURE__ */ jsx5(
|
|
574
|
+
ErrorFallback2,
|
|
575
|
+
{
|
|
576
|
+
error,
|
|
577
|
+
message: errorMessage
|
|
578
|
+
}
|
|
579
|
+
)
|
|
580
|
+
});
|
|
581
|
+
});
|
|
582
|
+
}, delay);
|
|
407
583
|
});
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
const
|
|
438
|
-
|
|
584
|
+
});
|
|
585
|
+
};
|
|
586
|
+
|
|
587
|
+
// src/theme/DashThemeProviderLight.tsx
|
|
588
|
+
import { createContext as createContext2, useContext as useContext2, useState as useState3, useEffect as useEffect2, useMemo as useMemo2 } from "react";
|
|
589
|
+
import CssBaseline from "@mui/material/CssBaseline";
|
|
590
|
+
import { createTheme, ThemeProvider } from "@mui/material";
|
|
591
|
+
import { updateDomCssVariables } from "dash-utils";
|
|
592
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
593
|
+
var getCssVariableNumber = (varName, defaultValue) => {
|
|
594
|
+
if (typeof document === "undefined") return defaultValue;
|
|
595
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
596
|
+
const parsed = parseInt(value, 10);
|
|
597
|
+
return isNaN(parsed) ? defaultValue : parsed;
|
|
598
|
+
};
|
|
599
|
+
var getCssVariable = (varName) => {
|
|
600
|
+
if (typeof document === "undefined") return null;
|
|
601
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
602
|
+
return value || null;
|
|
603
|
+
};
|
|
604
|
+
var getThemeColors = (mode) => {
|
|
605
|
+
const colors = {};
|
|
606
|
+
const suffix = `--${mode}`;
|
|
607
|
+
const primaryColor = getCssVariable(`--primary-color${suffix}`);
|
|
608
|
+
if (primaryColor) colors.primaryColor = primaryColor;
|
|
609
|
+
const primaryContrast = getCssVariable(`--primary-contrast${suffix}`);
|
|
610
|
+
if (primaryContrast) colors.primaryContrast = primaryContrast;
|
|
611
|
+
const secondaryColor = getCssVariable(`--secondary-color${suffix}`);
|
|
612
|
+
if (secondaryColor) colors.secondaryColor = secondaryColor;
|
|
613
|
+
const bodyBgPrimary = getCssVariable(`--bodybg-primary${suffix}`);
|
|
614
|
+
if (bodyBgPrimary) colors.bodyBgPrimary = bodyBgPrimary;
|
|
615
|
+
const bodyBgSecondary = getCssVariable(`--bodybg-secondary${suffix}`);
|
|
616
|
+
if (bodyBgSecondary) colors.bodyBgSecondary = bodyBgSecondary;
|
|
617
|
+
const componentBg = getCssVariable(`--component-bg${suffix}`);
|
|
618
|
+
if (componentBg) colors.componentBg = componentBg;
|
|
619
|
+
const textColor = getCssVariable(`--text-color${suffix}`);
|
|
620
|
+
if (textColor) colors.textColor = textColor;
|
|
621
|
+
const textContrast = getCssVariable(`--text-contrast${suffix}`);
|
|
622
|
+
if (textContrast) colors.textContrast = textContrast;
|
|
623
|
+
const headingColor = getCssVariable(`--heading-color${suffix}`);
|
|
624
|
+
if (headingColor) colors.headingColor = headingColor;
|
|
625
|
+
const linkColor = getCssVariable(`--link-color${suffix}`);
|
|
626
|
+
if (linkColor) colors.linkColor = linkColor;
|
|
627
|
+
const borderColor = getCssVariable(`--border-color${suffix}`);
|
|
628
|
+
if (borderColor) colors.borderColor = borderColor;
|
|
629
|
+
return colors;
|
|
630
|
+
};
|
|
631
|
+
var createMinimalTheme = (mode, extendedOptions) => {
|
|
632
|
+
const colors = getThemeColors(mode);
|
|
633
|
+
const fontSizeBase = getCssVariableNumber("--font-size-base", 14);
|
|
634
|
+
const borderRadiusBase = getCssVariableNumber("--border-radius-base", 6);
|
|
635
|
+
const _a = extendedOptions || {}, { palette: _p, colorSchemes: _cs, defaultColorScheme: _dcs } = _a, safeExtendedOptions = __objRest(_a, ["palette", "colorSchemes", "defaultColorScheme"]);
|
|
636
|
+
return createTheme(__spreadValues({
|
|
439
637
|
breakpoints: {
|
|
440
638
|
keys: ["xs", "sm", "md", "lg", "xl"],
|
|
441
639
|
values: { xs: 0, sm: 600, md: 900, lg: 1200, xl: 1536 }
|
|
442
640
|
},
|
|
443
641
|
palette: {
|
|
444
|
-
mode
|
|
642
|
+
mode,
|
|
445
643
|
primary: {
|
|
446
|
-
main:
|
|
447
|
-
contrastText:
|
|
644
|
+
main: colors.primaryColor,
|
|
645
|
+
contrastText: colors.primaryContrast
|
|
448
646
|
},
|
|
449
647
|
secondary: {
|
|
450
|
-
main:
|
|
648
|
+
main: colors.secondaryColor
|
|
451
649
|
},
|
|
452
650
|
background: {
|
|
453
|
-
default:
|
|
454
|
-
paper:
|
|
651
|
+
default: colors.bodyBgPrimary,
|
|
652
|
+
paper: colors.componentBg
|
|
455
653
|
},
|
|
456
654
|
text: {
|
|
457
|
-
primary:
|
|
458
|
-
secondary:
|
|
655
|
+
primary: colors.textColor,
|
|
656
|
+
secondary: colors.textContrast
|
|
459
657
|
},
|
|
460
|
-
divider:
|
|
658
|
+
divider: colors.borderColor
|
|
461
659
|
},
|
|
462
660
|
typography: {
|
|
463
661
|
fontFamily: '"Montserrat", "Roboto", "Helvetica", "Arial", sans-serif',
|
|
464
|
-
fontSize:
|
|
662
|
+
fontSize: fontSizeBase
|
|
465
663
|
},
|
|
466
664
|
shape: {
|
|
467
|
-
borderRadius:
|
|
665
|
+
borderRadius: borderRadiusBase
|
|
468
666
|
},
|
|
469
667
|
components: {
|
|
470
668
|
MuiButton: {
|
|
@@ -478,8 +676,8 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
|
|
|
478
676
|
MuiCssBaseline: {
|
|
479
677
|
styleOverrides: {
|
|
480
678
|
body: {
|
|
481
|
-
backgroundColor:
|
|
482
|
-
color:
|
|
679
|
+
backgroundColor: colors.bodyBgPrimary,
|
|
680
|
+
color: colors.textColor
|
|
483
681
|
}
|
|
484
682
|
}
|
|
485
683
|
},
|
|
@@ -490,269 +688,408 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
|
|
|
490
688
|
}
|
|
491
689
|
}
|
|
492
690
|
}
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
691
|
+
}
|
|
692
|
+
}, safeExtendedOptions));
|
|
693
|
+
};
|
|
694
|
+
var DashThemeContext = createContext2(null);
|
|
695
|
+
var useDashThemeContextLight = () => {
|
|
696
|
+
const context = useContext2(DashThemeContext);
|
|
697
|
+
if (!context) {
|
|
499
698
|
throw new Error("useDashThemeContextLight must be used within a DashThemeProviderLight");
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
699
|
+
}
|
|
700
|
+
return context;
|
|
701
|
+
};
|
|
702
|
+
var DashThemeProviderLight = ({
|
|
703
|
+
children,
|
|
704
|
+
extendedOptions,
|
|
705
|
+
defaultMode
|
|
505
706
|
}) => {
|
|
506
|
-
const [
|
|
507
|
-
if (typeof document
|
|
508
|
-
const
|
|
509
|
-
return
|
|
510
|
-
})
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
},
|
|
515
|
-
|
|
707
|
+
const [currentMode, setCurrentMode] = useState3(() => {
|
|
708
|
+
if (typeof document === "undefined") return defaultMode || "dark";
|
|
709
|
+
const stored = document.documentElement.getAttribute("data-theme");
|
|
710
|
+
return stored === "light" || stored === "dark" ? stored : defaultMode || "dark";
|
|
711
|
+
});
|
|
712
|
+
const [themeVersion, setThemeVersion] = useState3(0);
|
|
713
|
+
const theme = useMemo2(() => {
|
|
714
|
+
return createMinimalTheme(currentMode, extendedOptions);
|
|
715
|
+
}, [currentMode, extendedOptions, themeVersion]);
|
|
716
|
+
const setMode = (mode) => {
|
|
717
|
+
setCurrentMode(mode);
|
|
718
|
+
if (typeof document !== "undefined") {
|
|
719
|
+
document.documentElement.setAttribute("data-theme", mode);
|
|
720
|
+
localStorage.setItem("theme", mode);
|
|
721
|
+
updateDomCssVariables(mode);
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
const toggleMode = () => {
|
|
725
|
+
setMode(currentMode === "dark" ? "light" : "dark");
|
|
516
726
|
};
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
727
|
+
const refreshTheme = () => {
|
|
728
|
+
setThemeVersion((v) => v + 1);
|
|
729
|
+
};
|
|
730
|
+
useEffect2(() => {
|
|
731
|
+
if (typeof document === "undefined") return;
|
|
732
|
+
const observer = new MutationObserver((mutations) => {
|
|
733
|
+
mutations.forEach((mutation) => {
|
|
734
|
+
if (mutation.type === "attributes" && mutation.attributeName === "data-theme") {
|
|
735
|
+
const newMode = document.documentElement.getAttribute("data-theme");
|
|
736
|
+
if (newMode === "light" || newMode === "dark") {
|
|
737
|
+
if (newMode !== currentMode) {
|
|
738
|
+
setCurrentMode(newMode);
|
|
739
|
+
}
|
|
740
|
+
}
|
|
524
741
|
}
|
|
525
742
|
});
|
|
526
743
|
});
|
|
527
|
-
|
|
528
|
-
attributes:
|
|
744
|
+
observer.observe(document.documentElement, {
|
|
745
|
+
attributes: true,
|
|
529
746
|
attributeFilter: ["data-theme"]
|
|
530
|
-
})
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
if (typeof
|
|
535
|
-
|
|
536
|
-
|
|
747
|
+
});
|
|
748
|
+
return () => observer.disconnect();
|
|
749
|
+
}, [currentMode]);
|
|
750
|
+
useEffect2(() => {
|
|
751
|
+
if (typeof document === "undefined") return;
|
|
752
|
+
updateDomCssVariables(currentMode);
|
|
753
|
+
}, [currentMode]);
|
|
754
|
+
useEffect2(() => {
|
|
755
|
+
if (typeof window === "undefined") return;
|
|
756
|
+
const handler = () => {
|
|
757
|
+
console.log("DashThemeProviderLight: Refreshing theme from CSS variables");
|
|
758
|
+
refreshTheme();
|
|
537
759
|
};
|
|
538
|
-
|
|
760
|
+
window.addEventListener("DASHTRefreshTheme", handler);
|
|
761
|
+
return () => window.removeEventListener("DASHTRefreshTheme", handler);
|
|
539
762
|
}, []);
|
|
540
|
-
const
|
|
763
|
+
const contextValue = useMemo2(
|
|
541
764
|
() => ({
|
|
542
|
-
theme
|
|
543
|
-
currentMode
|
|
544
|
-
setMode
|
|
545
|
-
toggleMode
|
|
546
|
-
refreshTheme
|
|
765
|
+
theme,
|
|
766
|
+
currentMode,
|
|
767
|
+
setMode,
|
|
768
|
+
toggleMode,
|
|
769
|
+
refreshTheme
|
|
547
770
|
}),
|
|
548
|
-
[
|
|
771
|
+
[theme, currentMode]
|
|
549
772
|
);
|
|
550
|
-
return /* @__PURE__ */
|
|
551
|
-
/* @__PURE__ */
|
|
552
|
-
/* @__PURE__ */
|
|
773
|
+
return /* @__PURE__ */ jsxs5(ThemeProvider, { theme, children: [
|
|
774
|
+
/* @__PURE__ */ jsx6(CssBaseline, {}),
|
|
775
|
+
/* @__PURE__ */ jsx6(DashThemeContext.Provider, { value: contextValue, children })
|
|
553
776
|
] });
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
777
|
+
};
|
|
778
|
+
|
|
779
|
+
// src/utils/DashBootstrapUtils.ts
|
|
780
|
+
import { useEffect as useEffect3, useState as useState4 } from "react";
|
|
781
|
+
import { useDispatch } from "react-redux";
|
|
782
|
+
import { AuthPersistenceService, syncDeviceStoreToLocalStorage, syncLocalStorageToDeviceStore } from "dash-auth";
|
|
783
|
+
import { DASH_REDUX_ACTIONS } from "dash-admin-state";
|
|
784
|
+
import { ACTION_UPDATE_AUTH } from "dash-admin-state/src/redux/reducers/Auth";
|
|
785
|
+
import DASHAuthenticationService from "dash-admin/src/contexts/auth/DASHAuthenticationService";
|
|
786
|
+
import { dashStorage, updateDomCssVariables as updateDomCssVariables2 } from "dash-utils";
|
|
787
|
+
var useInitializeReduxFromPersisted = (currentAuthState) => {
|
|
788
|
+
const dispatch = useDispatch();
|
|
789
|
+
useEffect3(() => {
|
|
790
|
+
const initializeReduxFromPersisted = () => {
|
|
791
|
+
console.log("\u{1F50D} Bootstrap: Checking for persisted auth data...");
|
|
792
|
+
const storedUser = AuthPersistenceService.getUser();
|
|
793
|
+
const storedToken = AuthPersistenceService.getToken();
|
|
794
|
+
const isAuthenticated = JSON.parse(dashStorage.getItem("authenticated") || "false");
|
|
795
|
+
const persistedAuth = AuthPersistenceService.getAuth();
|
|
796
|
+
console.log("\u{1F50D} Bootstrap: Persisted data check:", {
|
|
797
|
+
hasStoredUser: !!storedUser,
|
|
798
|
+
hasStoredToken: !!storedToken,
|
|
799
|
+
isAuthenticated,
|
|
800
|
+
hasPersistedAuth: !!persistedAuth,
|
|
801
|
+
currentReduxAuth: currentAuthState
|
|
802
|
+
});
|
|
803
|
+
if (isAuthenticated && storedUser && storedToken && !currentAuthState) {
|
|
804
|
+
console.log("\u{1F504} Bootstrap: Restoring auth session to Redux from localStorage");
|
|
805
|
+
let userObject = storedUser;
|
|
806
|
+
if (typeof storedUser === "string") {
|
|
807
|
+
console.error("\u274C Bootstrap: Stored user is string, this should not happen");
|
|
571
808
|
try {
|
|
572
|
-
|
|
573
|
-
} catch {
|
|
574
|
-
console.error("
|
|
809
|
+
userObject = JSON.parse(storedUser);
|
|
810
|
+
} catch (e) {
|
|
811
|
+
console.error("\u274C Bootstrap: Cannot parse user string, clearing auth data");
|
|
812
|
+
AuthPersistenceService.clearAuth();
|
|
575
813
|
return;
|
|
576
814
|
}
|
|
577
815
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
user:
|
|
581
|
-
authenticated:
|
|
582
|
-
auth:
|
|
816
|
+
dispatch(
|
|
817
|
+
DASH_REDUX_ACTIONS.updateAuth(ACTION_UPDATE_AUTH, {
|
|
818
|
+
user: userObject,
|
|
819
|
+
authenticated: true,
|
|
820
|
+
auth: (persistedAuth == null ? void 0 : persistedAuth.auth) || null
|
|
583
821
|
})
|
|
584
|
-
)
|
|
822
|
+
);
|
|
823
|
+
console.log("\u2705 Bootstrap: Redux state restored from persisted data");
|
|
585
824
|
}
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
},
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
825
|
+
};
|
|
826
|
+
initializeReduxFromPersisted();
|
|
827
|
+
}, [dispatch, currentAuthState]);
|
|
828
|
+
};
|
|
829
|
+
var useLogoutEventListener = () => {
|
|
830
|
+
const dispatch = useDispatch();
|
|
831
|
+
useEffect3(() => {
|
|
832
|
+
const handleLogoutEvent = (event) => {
|
|
833
|
+
console.log("\u{1F510} Bootstrap: Received logout event", event.detail);
|
|
834
|
+
dispatch(
|
|
835
|
+
DASH_REDUX_ACTIONS.updateAuth(ACTION_UPDATE_AUTH, {
|
|
594
836
|
user: null,
|
|
595
|
-
authenticated:
|
|
837
|
+
authenticated: false,
|
|
596
838
|
auth: null
|
|
597
839
|
})
|
|
598
|
-
)
|
|
840
|
+
);
|
|
841
|
+
AuthPersistenceService.clearAuth();
|
|
842
|
+
localStorage.clear();
|
|
599
843
|
};
|
|
600
|
-
|
|
601
|
-
|
|
844
|
+
window.addEventListener("auth:logout", handleLogoutEvent);
|
|
845
|
+
return () => {
|
|
846
|
+
window.removeEventListener("auth:logout", handleLogoutEvent);
|
|
602
847
|
};
|
|
603
|
-
}, [
|
|
604
|
-
}
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
848
|
+
}, [dispatch]);
|
|
849
|
+
};
|
|
850
|
+
var useAppInitialization = () => {
|
|
851
|
+
const [isLoading, setIsLoading] = useState4(true);
|
|
852
|
+
const [initializationError, setInitializationError] = useState4(null);
|
|
853
|
+
const dispatch = useDispatch();
|
|
854
|
+
useEffect3(() => {
|
|
855
|
+
const initializeApp = () => __async(null, null, function* () {
|
|
856
|
+
var _a, _b;
|
|
608
857
|
try {
|
|
609
|
-
console.log("
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
858
|
+
console.log("\u{1F680} Bootstrap: Starting app initialization...");
|
|
859
|
+
yield syncDeviceStoreToLocalStorage();
|
|
860
|
+
const initResult = yield DASHAuthenticationService.initializeApp(true);
|
|
861
|
+
console.log("\u{1F50D} Bootstrap: Initialization result:", initResult);
|
|
862
|
+
if (initResult.success) {
|
|
863
|
+
console.log("\u2705 Bootstrap: Auto-login successful");
|
|
864
|
+
dispatch(
|
|
865
|
+
DASH_REDUX_ACTIONS.updateAuth(ACTION_UPDATE_AUTH, {
|
|
866
|
+
user: initResult.user,
|
|
867
|
+
authenticated: true,
|
|
868
|
+
auth: initResult.auth || null
|
|
617
869
|
})
|
|
618
|
-
)
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
870
|
+
);
|
|
871
|
+
(_b = window.DashIPCService) == null ? void 0 : _b.speak(`${(_a = initResult.user) == null ? void 0 : _a.name}, Bienvenido!`);
|
|
872
|
+
yield syncLocalStorageToDeviceStore();
|
|
873
|
+
setInitializationError(null);
|
|
874
|
+
if (initResult.redirectAfterLogin) {
|
|
875
|
+
console.log("\u{1F504} Bootstrap: Emitting auth:redirect event", initResult.redirectAfterLogin);
|
|
876
|
+
const event = new CustomEvent("auth:redirect", {
|
|
877
|
+
detail: { to: initResult.redirectAfterLogin }
|
|
622
878
|
});
|
|
623
|
-
window.dispatchEvent(
|
|
879
|
+
window.dispatchEvent(event);
|
|
624
880
|
}
|
|
625
881
|
} else {
|
|
626
|
-
console.log("
|
|
627
|
-
const
|
|
628
|
-
if (
|
|
629
|
-
console.log("
|
|
882
|
+
console.log("\u2139\uFE0F Bootstrap: No valid authentication found");
|
|
883
|
+
const authData = AuthPersistenceService.getAuth();
|
|
884
|
+
if (authData && authData.auth) {
|
|
885
|
+
console.log("\u{1F504} Bootstrap: Found persisted auth data, attempting token initialization...");
|
|
630
886
|
try {
|
|
631
|
-
const
|
|
632
|
-
if (
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
887
|
+
const tokenInitResult = yield DASHAuthenticationService.initializeFromToken();
|
|
888
|
+
if (tokenInitResult.success) {
|
|
889
|
+
console.log("\u2705 Bootstrap: Token initialization successful");
|
|
890
|
+
dispatch(
|
|
891
|
+
DASH_REDUX_ACTIONS.updateAuth(ACTION_UPDATE_AUTH, {
|
|
892
|
+
user: tokenInitResult.user,
|
|
893
|
+
authenticated: true,
|
|
894
|
+
auth: tokenInitResult.auth || null
|
|
638
895
|
})
|
|
639
|
-
)
|
|
896
|
+
);
|
|
897
|
+
yield syncLocalStorageToDeviceStore();
|
|
898
|
+
setInitializationError(null);
|
|
899
|
+
if (tokenInitResult.redirectAfterLogin) {
|
|
640
900
|
console.log(
|
|
641
|
-
"
|
|
642
|
-
|
|
901
|
+
"\u{1F504} Bootstrap: Emitting auth:redirect event",
|
|
902
|
+
tokenInitResult.redirectAfterLogin
|
|
643
903
|
);
|
|
644
|
-
const
|
|
645
|
-
detail: { to:
|
|
904
|
+
const event = new CustomEvent("auth:redirect", {
|
|
905
|
+
detail: { to: tokenInitResult.redirectAfterLogin }
|
|
646
906
|
});
|
|
647
|
-
window.dispatchEvent(
|
|
907
|
+
window.dispatchEvent(event);
|
|
648
908
|
}
|
|
649
|
-
} else
|
|
650
|
-
console.log("
|
|
651
|
-
|
|
652
|
-
|
|
909
|
+
} else {
|
|
910
|
+
console.log("\u274C Bootstrap: Token initialization failed:", tokenInitResult.error);
|
|
911
|
+
setInitializationError(null);
|
|
912
|
+
AuthPersistenceService.clearAuth();
|
|
913
|
+
}
|
|
914
|
+
} catch (error) {
|
|
915
|
+
console.error("\u274C Bootstrap: Token initialization error:", error);
|
|
916
|
+
setInitializationError(null);
|
|
917
|
+
AuthPersistenceService.clearAuth();
|
|
653
918
|
}
|
|
654
|
-
} else
|
|
655
|
-
console.log("
|
|
919
|
+
} else {
|
|
920
|
+
console.log("\u2139\uFE0F Bootstrap: No persisted auth data found");
|
|
921
|
+
AuthPersistenceService.clearAuth();
|
|
922
|
+
}
|
|
656
923
|
}
|
|
657
|
-
} catch (
|
|
658
|
-
console.error("
|
|
924
|
+
} catch (error) {
|
|
925
|
+
console.error("\u274C Bootstrap: App initialization failed:", error);
|
|
926
|
+
setInitializationError("Failed to initialize application");
|
|
659
927
|
} finally {
|
|
660
|
-
|
|
928
|
+
setIsLoading(false);
|
|
661
929
|
}
|
|
662
|
-
})
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
930
|
+
});
|
|
931
|
+
if (isLoading) {
|
|
932
|
+
initializeApp();
|
|
933
|
+
}
|
|
934
|
+
}, [dispatch, isLoading]);
|
|
935
|
+
return { isLoading, initializationError };
|
|
936
|
+
};
|
|
937
|
+
var usePendingRedirect = () => {
|
|
938
|
+
useEffect3(() => {
|
|
939
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
940
|
+
const redirectTo = searchParams.get("redirect");
|
|
941
|
+
if (redirectTo && redirectTo !== "/login") {
|
|
942
|
+
console.log("\u2139\uFE0F RedirectTO: Setting redirect to by searchParams to:", redirectTo);
|
|
943
|
+
DASHAuthenticationService.setPendingRedirect(redirectTo);
|
|
944
|
+
}
|
|
668
945
|
}, []);
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
946
|
+
};
|
|
947
|
+
var LOCALE_CHANGE_EVENT2 = "dash:locale-change";
|
|
948
|
+
var useUrlLocaleDetection = (availableLocales = ["es", "en"], defaultLocale = "es") => {
|
|
949
|
+
const dispatch = useDispatch();
|
|
950
|
+
useEffect3(() => {
|
|
951
|
+
if (typeof window === "undefined") return;
|
|
952
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
953
|
+
const langParam = searchParams.get("lang");
|
|
954
|
+
const storedLocale = localStorage.getItem("dash-user-locale");
|
|
955
|
+
let targetLocale = defaultLocale;
|
|
956
|
+
if (langParam && availableLocales.includes(langParam)) {
|
|
957
|
+
targetLocale = langParam;
|
|
958
|
+
} else if (storedLocale && availableLocales.includes(storedLocale)) {
|
|
959
|
+
targetLocale = storedLocale;
|
|
960
|
+
}
|
|
961
|
+
const isNewLocale = storedLocale !== targetLocale;
|
|
962
|
+
if (isNewLocale) {
|
|
963
|
+
console.log(`\u{1F310} Bootstrap: Locale change detected: ${storedLocale} -> ${targetLocale}`);
|
|
964
|
+
localStorage.setItem("dash-user-locale", targetLocale);
|
|
965
|
+
} else {
|
|
966
|
+
console.log(`\u{1F310} Bootstrap: Initializing locale from storage: ${targetLocale}`);
|
|
967
|
+
}
|
|
968
|
+
console.log(`\u{1F310} Bootstrap: Dispatching locale to Redux: ${targetLocale}`);
|
|
969
|
+
dispatch(DASH_REDUX_ACTIONS.switchLanguage(targetLocale));
|
|
970
|
+
console.log(`\u{1F310} Bootstrap: Emitting locale change event: ${targetLocale}`);
|
|
971
|
+
window.dispatchEvent(new CustomEvent(LOCALE_CHANGE_EVENT2, {
|
|
972
|
+
detail: { locale: targetLocale }
|
|
677
973
|
}));
|
|
678
|
-
}, [
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
|
|
974
|
+
}, [dispatch, availableLocales, defaultLocale]);
|
|
975
|
+
};
|
|
976
|
+
var usePathnameTracker = () => {
|
|
977
|
+
const [pathname, setPathname] = useState4(
|
|
978
|
+
typeof window !== "undefined" ? window.location.pathname : "/"
|
|
682
979
|
);
|
|
683
|
-
|
|
684
|
-
if (typeof window
|
|
685
|
-
const
|
|
686
|
-
const
|
|
687
|
-
|
|
980
|
+
useEffect3(() => {
|
|
981
|
+
if (typeof window === "undefined") return;
|
|
982
|
+
const handleUrlChange = () => {
|
|
983
|
+
const newPathname = window.location.pathname;
|
|
984
|
+
if (newPathname !== pathname) {
|
|
985
|
+
console.log("\u{1F50D} Bootstrap: URL changed from", pathname, "to", newPathname);
|
|
986
|
+
setPathname(newPathname);
|
|
987
|
+
}
|
|
688
988
|
};
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
},
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
989
|
+
window.addEventListener("popstate", handleUrlChange);
|
|
990
|
+
return () => window.removeEventListener("popstate", handleUrlChange);
|
|
991
|
+
}, [pathname]);
|
|
992
|
+
return pathname;
|
|
993
|
+
};
|
|
994
|
+
var useEarlyThemeInit = (defaultTheme = "dark") => {
|
|
995
|
+
useEffect3(() => {
|
|
996
|
+
if (typeof document === "undefined") return;
|
|
997
|
+
const stored = localStorage.getItem("theme");
|
|
998
|
+
const theme = stored === "light" || stored === "dark" ? stored : defaultTheme;
|
|
999
|
+
document.documentElement.setAttribute("data-theme", theme);
|
|
1000
|
+
if (!stored) {
|
|
1001
|
+
localStorage.setItem("theme", theme);
|
|
1002
|
+
}
|
|
1003
|
+
}, [defaultTheme]);
|
|
1004
|
+
};
|
|
1005
|
+
var initializeThemeEarly = (defaultTheme) => {
|
|
1006
|
+
if (typeof document === "undefined" || typeof localStorage === "undefined") return;
|
|
1007
|
+
const stored = localStorage.getItem("theme");
|
|
1008
|
+
const theme = stored === "light" || stored === "dark" ? stored : defaultTheme;
|
|
1009
|
+
document.documentElement.setAttribute("data-theme", theme);
|
|
1010
|
+
if (!stored) {
|
|
1011
|
+
localStorage.setItem("theme", theme);
|
|
1012
|
+
}
|
|
701
1013
|
try {
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
1014
|
+
updateDomCssVariables2(theme);
|
|
1015
|
+
console.log("\u{1F3A8} Bootstrap: Initialized theme variables for:", theme);
|
|
1016
|
+
} catch (error) {
|
|
1017
|
+
console.warn("Failed to initialize theme variables:", error);
|
|
705
1018
|
}
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
1019
|
+
};
|
|
1020
|
+
var syncElectronStore = () => __async(null, null, function* () {
|
|
1021
|
+
if (typeof window === "undefined") return;
|
|
1022
|
+
const electronStore = window.electronStore;
|
|
1023
|
+
if (electronStore) {
|
|
1024
|
+
const all = yield electronStore.syncToLocalStorage();
|
|
1025
|
+
Object.entries(all).forEach(([key, value]) => {
|
|
1026
|
+
window.localStorage.setItem(key, JSON.stringify(value));
|
|
713
1027
|
});
|
|
714
1028
|
}
|
|
715
|
-
}
|
|
716
|
-
|
|
1029
|
+
});
|
|
1030
|
+
|
|
1031
|
+
// src/utils/electronStore.ts
|
|
1032
|
+
var syncElectronStoreToLocalStorage = () => __async(null, null, function* () {
|
|
1033
|
+
if (typeof window === "undefined") return;
|
|
1034
|
+
if (window.electronStore) {
|
|
1035
|
+
try {
|
|
1036
|
+
const all = yield window.electronStore.syncToLocalStorage();
|
|
1037
|
+
Object.entries(all).forEach(([key, value]) => {
|
|
1038
|
+
window.localStorage.setItem(key, JSON.stringify(value));
|
|
1039
|
+
});
|
|
1040
|
+
console.log("\u2705 Electron store synced to localStorage");
|
|
1041
|
+
} catch (error) {
|
|
1042
|
+
console.error("\u274C Failed to sync Electron store:", error);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
var isElectron = () => {
|
|
1047
|
+
return typeof window !== "undefined" && !!window.electronStore;
|
|
1048
|
+
};
|
|
1049
|
+
var getElectronStoreValue = (key, defaultValue) => __async(null, null, function* () {
|
|
1050
|
+
if (typeof window === "undefined") return defaultValue;
|
|
1051
|
+
if (window.electronStore) {
|
|
717
1052
|
try {
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
}), console.log("✅ Electron store synced to localStorage");
|
|
722
|
-
} catch (t) {
|
|
723
|
-
console.error("❌ Failed to sync Electron store:", t);
|
|
1053
|
+
return yield window.electronStore.get(key);
|
|
1054
|
+
} catch (e) {
|
|
1055
|
+
return defaultValue;
|
|
724
1056
|
}
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
if (
|
|
1057
|
+
}
|
|
1058
|
+
const stored = localStorage.getItem(key);
|
|
1059
|
+
if (stored) {
|
|
728
1060
|
try {
|
|
729
|
-
return
|
|
730
|
-
} catch {
|
|
731
|
-
return
|
|
1061
|
+
return JSON.parse(stored);
|
|
1062
|
+
} catch (e) {
|
|
1063
|
+
return stored;
|
|
732
1064
|
}
|
|
733
|
-
|
|
734
|
-
|
|
1065
|
+
}
|
|
1066
|
+
return defaultValue;
|
|
1067
|
+
});
|
|
1068
|
+
var setElectronStoreValue = (key, value) => __async(null, null, function* () {
|
|
1069
|
+
if (typeof window === "undefined") return;
|
|
1070
|
+
if (window.electronStore) {
|
|
735
1071
|
try {
|
|
736
|
-
|
|
737
|
-
} catch {
|
|
738
|
-
|
|
1072
|
+
yield window.electronStore.set(key, value);
|
|
1073
|
+
} catch (error) {
|
|
1074
|
+
console.error("Failed to set Electron store value:", error);
|
|
739
1075
|
}
|
|
740
|
-
return e;
|
|
741
|
-
}, Xe = async (t, e) => {
|
|
742
|
-
if (!(typeof window > "u")) {
|
|
743
|
-
if (window.electronStore)
|
|
744
|
-
try {
|
|
745
|
-
await window.electronStore.set(t, e);
|
|
746
|
-
} catch (o) {
|
|
747
|
-
console.error("Failed to set Electron store value:", o);
|
|
748
|
-
}
|
|
749
|
-
localStorage.setItem(t, JSON.stringify(e));
|
|
750
1076
|
}
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
1077
|
+
localStorage.setItem(key, JSON.stringify(value));
|
|
1078
|
+
});
|
|
1079
|
+
|
|
1080
|
+
// src/utils/cssVariables.ts
|
|
1081
|
+
var getCssVariableNumber2 = (varName, defaultValue) => {
|
|
1082
|
+
if (typeof document === "undefined") return defaultValue;
|
|
1083
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
1084
|
+
const parsed = parseInt(value, 10);
|
|
1085
|
+
return isNaN(parsed) ? defaultValue : parsed;
|
|
1086
|
+
};
|
|
1087
|
+
var getCssVariableString = (varName, defaultValue = "") => {
|
|
1088
|
+
if (typeof document === "undefined") return defaultValue;
|
|
1089
|
+
const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
1090
|
+
return value || defaultValue;
|
|
1091
|
+
};
|
|
1092
|
+
var DEFAULT_LAYOUT_DIMENSIONS = {
|
|
756
1093
|
sidebarLargeWidth: 255,
|
|
757
1094
|
sidebarSmallWidth: 64,
|
|
758
1095
|
sidebarHorizontalHeight: 120,
|
|
@@ -760,68 +1097,68 @@ const re = ({ error: t, resetErrorBoundary: e }) => /* @__PURE__ */ y(
|
|
|
760
1097
|
logoVerticalMaxHeight: 130,
|
|
761
1098
|
logoHorizontalMaxWidth: 200,
|
|
762
1099
|
logoHorizontalMaxHeight: 60
|
|
763
|
-
}
|
|
764
|
-
|
|
765
|
-
sidebarSmallWidth: L("--sidebar-small-width", w.sidebarSmallWidth),
|
|
766
|
-
sidebarHorizontalHeight: L("--sidebar-horizontal-height", w.sidebarHorizontalHeight),
|
|
767
|
-
logoVerticalMaxWidth: L("--logo-vertical-max-width", w.logoVerticalMaxWidth),
|
|
768
|
-
logoVerticalMaxHeight: L("--logo-vertical-max-height", w.logoVerticalMaxHeight),
|
|
769
|
-
logoHorizontalMaxWidth: L("--logo-horizontal-max-width", w.logoHorizontalMaxWidth),
|
|
770
|
-
logoHorizontalMaxHeight: L("--logo-horizontal-max-height", w.logoHorizontalMaxHeight)
|
|
771
|
-
}), Ze = (t = {}) => {
|
|
772
|
-
const e = {
|
|
773
|
-
...w,
|
|
774
|
-
...ge(),
|
|
775
|
-
...t.layoutDimensions
|
|
776
|
-
};
|
|
1100
|
+
};
|
|
1101
|
+
var getLayoutDimensionsFromCss = () => {
|
|
777
1102
|
return {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
paddingHorizontal: e.sidebarLargeWidth,
|
|
786
|
-
paddingVertical: e.sidebarHorizontalHeight
|
|
1103
|
+
sidebarLargeWidth: getCssVariableNumber2("--sidebar-large-width", DEFAULT_LAYOUT_DIMENSIONS.sidebarLargeWidth),
|
|
1104
|
+
sidebarSmallWidth: getCssVariableNumber2("--sidebar-small-width", DEFAULT_LAYOUT_DIMENSIONS.sidebarSmallWidth),
|
|
1105
|
+
sidebarHorizontalHeight: getCssVariableNumber2("--sidebar-horizontal-height", DEFAULT_LAYOUT_DIMENSIONS.sidebarHorizontalHeight),
|
|
1106
|
+
logoVerticalMaxWidth: getCssVariableNumber2("--logo-vertical-max-width", DEFAULT_LAYOUT_DIMENSIONS.logoVerticalMaxWidth),
|
|
1107
|
+
logoVerticalMaxHeight: getCssVariableNumber2("--logo-vertical-max-height", DEFAULT_LAYOUT_DIMENSIONS.logoVerticalMaxHeight),
|
|
1108
|
+
logoHorizontalMaxWidth: getCssVariableNumber2("--logo-horizontal-max-width", DEFAULT_LAYOUT_DIMENSIONS.logoHorizontalMaxWidth),
|
|
1109
|
+
logoHorizontalMaxHeight: getCssVariableNumber2("--logo-horizontal-max-height", DEFAULT_LAYOUT_DIMENSIONS.logoHorizontalMaxHeight)
|
|
787
1110
|
};
|
|
788
1111
|
};
|
|
1112
|
+
var createDefaultPanelSettings = (options = {}) => {
|
|
1113
|
+
const dimensions = __spreadValues(__spreadValues(__spreadValues({}, DEFAULT_LAYOUT_DIMENSIONS), getLayoutDimensionsFromCss()), options.layoutDimensions);
|
|
1114
|
+
return __spreadProps(__spreadValues({
|
|
1115
|
+
appName: options.appName || "Dash App",
|
|
1116
|
+
horizontalLogo: options.horizontalLogo,
|
|
1117
|
+
squaredLogo: options.squaredLogo,
|
|
1118
|
+
loginBackground: options.loginBackground,
|
|
1119
|
+
sidebarPosition: options.sidebarPosition || "left"
|
|
1120
|
+
}, dimensions), {
|
|
1121
|
+
// Padding configuration (derived from sidebar sizes)
|
|
1122
|
+
paddingHorizontal: dimensions.sidebarLargeWidth,
|
|
1123
|
+
paddingVertical: dimensions.sidebarHorizontalHeight
|
|
1124
|
+
});
|
|
1125
|
+
};
|
|
789
1126
|
export {
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
1127
|
+
AppWrapperLight,
|
|
1128
|
+
CustomErrorBoundary,
|
|
1129
|
+
DEFAULT_LAYOUT_DIMENSIONS,
|
|
1130
|
+
DashThemeContext,
|
|
1131
|
+
DashThemeProviderLight,
|
|
1132
|
+
DefaultAppLoadErrorFallback,
|
|
1133
|
+
DefaultInitializationErrorFallback,
|
|
1134
|
+
GlobalLoaderHtmlMarkup,
|
|
1135
|
+
GlobalSmallLoader,
|
|
1136
|
+
I18nBridgeContext,
|
|
1137
|
+
I18nBridgeProviderLight,
|
|
1138
|
+
createDefaultPanelSettings,
|
|
1139
|
+
createLazyAppLoader,
|
|
1140
|
+
createSimpleI18nProvider,
|
|
1141
|
+
getCssVariableNumber2 as getCssVariableNumber,
|
|
1142
|
+
getCssVariableString,
|
|
1143
|
+
getElectronStoreValue,
|
|
1144
|
+
getLayoutDimensionsFromCss,
|
|
1145
|
+
initializeThemeEarly,
|
|
1146
|
+
injectCriticalStyles,
|
|
1147
|
+
isElectron,
|
|
1148
|
+
setElectronStoreValue,
|
|
1149
|
+
syncElectronStore,
|
|
1150
|
+
syncElectronStoreToLocalStorage,
|
|
1151
|
+
useAppInitialization,
|
|
1152
|
+
useBridgedChangeLocaleLight,
|
|
1153
|
+
useBridgedLocaleLight,
|
|
1154
|
+
useBridgedLocalesLight,
|
|
1155
|
+
useDashThemeContextLight,
|
|
1156
|
+
useEarlyThemeInit,
|
|
1157
|
+
useI18nBridgeLight,
|
|
1158
|
+
useInitializeReduxFromPersisted,
|
|
1159
|
+
useLogoutEventListener,
|
|
1160
|
+
usePathnameTracker,
|
|
1161
|
+
usePendingRedirect,
|
|
1162
|
+
useTranslateLight,
|
|
1163
|
+
useUrlLocaleDetection
|
|
827
1164
|
};
|