@eintrek/erp-shell 0.1.44 → 0.1.45
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/dist/index.esm.js +18 -5
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +18 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1650,27 +1650,40 @@ function writeThemeCookie(value) {
|
|
|
1650
1650
|
/**
|
|
1651
1651
|
* Bridges next-themes (per-origin localStorage) with a cookie scoped to the
|
|
1652
1652
|
* parent domain, so the light/dark/system choice is shared across the
|
|
1653
|
-
* accounting / HR / platform subdomains.
|
|
1654
|
-
*
|
|
1653
|
+
* accounting / HR / platform subdomains.
|
|
1654
|
+
*
|
|
1655
|
+
* Local storage wins when it already has a value (H57): adopting the shared
|
|
1656
|
+
* cookie first used to overwrite an explicit choice — including one set via
|
|
1657
|
+
* DevTools — and write `theme=light` back on every load whenever the cookie
|
|
1658
|
+
* still said light. Push the local value into the cookie instead so sibling
|
|
1659
|
+
* apps catch up.
|
|
1655
1660
|
*/
|
|
1656
1661
|
function ThemeCookieSync() {
|
|
1657
1662
|
const { theme, setTheme } = useTheme();
|
|
1658
1663
|
const skipFirstWrite = React.useRef(true);
|
|
1659
1664
|
React.useEffect(() => {
|
|
1665
|
+
const local = typeof window !== "undefined"
|
|
1666
|
+
? window.localStorage.getItem("theme")
|
|
1667
|
+
: null;
|
|
1660
1668
|
const cookie = readThemeCookie();
|
|
1661
|
-
if (
|
|
1669
|
+
if (local) {
|
|
1670
|
+
if (local !== theme)
|
|
1671
|
+
setTheme(local);
|
|
1672
|
+
writeThemeCookie(local);
|
|
1673
|
+
}
|
|
1674
|
+
else if (cookie) {
|
|
1662
1675
|
if (cookie !== theme)
|
|
1663
1676
|
setTheme(cookie);
|
|
1664
1677
|
}
|
|
1665
1678
|
else if (theme) {
|
|
1666
|
-
writeThemeCookie(theme);
|
|
1679
|
+
writeThemeCookie(theme);
|
|
1667
1680
|
}
|
|
1668
1681
|
// Run once on mount — `theme` is intentionally not a dependency here.
|
|
1669
1682
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1670
1683
|
}, []);
|
|
1671
1684
|
React.useEffect(() => {
|
|
1672
1685
|
// Skip the initial render; only persist genuine changes (incl. the
|
|
1673
|
-
// setTheme() triggered by adopting
|
|
1686
|
+
// setTheme() triggered by adopting storage above — harmless re-write).
|
|
1674
1687
|
if (skipFirstWrite.current) {
|
|
1675
1688
|
skipFirstWrite.current = false;
|
|
1676
1689
|
return;
|