@dashadmin/dash-boilerplate 1.3.47 → 1.3.48

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.cjs CHANGED
@@ -736,6 +736,35 @@ var DashThemeProviderLight = ({
736
736
  window.addEventListener("DASHTRefreshTheme", handler);
737
737
  return () => window.removeEventListener("DASHTRefreshTheme", handler);
738
738
  }, []);
739
+ const currentModeRef = (0, import_react4.useRef)(currentMode);
740
+ currentModeRef.current = currentMode;
741
+ (0, import_react4.useEffect)(() => {
742
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") return;
743
+ let pending = false;
744
+ const rerun = () => {
745
+ if (pending) return;
746
+ pending = true;
747
+ queueMicrotask(() => {
748
+ pending = false;
749
+ (0, import_dash_utils.updateDomCssVariables)(currentModeRef.current);
750
+ refreshTheme();
751
+ });
752
+ };
753
+ const observer = new MutationObserver((mutations) => {
754
+ for (const mutation of mutations) {
755
+ for (const node of Array.from(mutation.addedNodes)) {
756
+ if (!(node instanceof HTMLElement)) continue;
757
+ const isStylesheet = node.tagName === "STYLE" || node.tagName === "LINK" && node.rel === "stylesheet";
758
+ if (isStylesheet && node.id !== "dash-theme-variables") {
759
+ rerun();
760
+ return;
761
+ }
762
+ }
763
+ }
764
+ });
765
+ observer.observe(document.head, { childList: true });
766
+ return () => observer.disconnect();
767
+ }, []);
739
768
  const contextValue = (0, import_react4.useMemo)(
740
769
  () => ({
741
770
  theme,
package/dist/index.js CHANGED
@@ -484,7 +484,7 @@ import { DASH_REDUX_ACTIONS } from "dash-admin-state";
484
484
  import { Avatar } from "@mui/material";
485
485
 
486
486
  // src/theme/DashThemeProviderLight.tsx
487
- import { createContext as createContext2, useContext as useContext2, useState as useState3, useEffect as useEffect2, useMemo as useMemo2 } from "react";
487
+ import { createContext as createContext2, useContext as useContext2, useState as useState3, useEffect as useEffect2, useMemo as useMemo2, useRef } from "react";
488
488
  import CssBaseline from "@mui/material/CssBaseline";
489
489
  import { createTheme, ThemeProvider } from "@mui/material";
490
490
  import { updateDomCssVariables } from "dash-utils";
@@ -665,6 +665,35 @@ var DashThemeProviderLight = ({
665
665
  window.addEventListener("DASHTRefreshTheme", handler);
666
666
  return () => window.removeEventListener("DASHTRefreshTheme", handler);
667
667
  }, []);
668
+ const currentModeRef = useRef(currentMode);
669
+ currentModeRef.current = currentMode;
670
+ useEffect2(() => {
671
+ if (typeof document === "undefined" || typeof MutationObserver === "undefined") return;
672
+ let pending = false;
673
+ const rerun = () => {
674
+ if (pending) return;
675
+ pending = true;
676
+ queueMicrotask(() => {
677
+ pending = false;
678
+ updateDomCssVariables(currentModeRef.current);
679
+ refreshTheme();
680
+ });
681
+ };
682
+ const observer = new MutationObserver((mutations) => {
683
+ for (const mutation of mutations) {
684
+ for (const node of Array.from(mutation.addedNodes)) {
685
+ if (!(node instanceof HTMLElement)) continue;
686
+ const isStylesheet = node.tagName === "STYLE" || node.tagName === "LINK" && node.rel === "stylesheet";
687
+ if (isStylesheet && node.id !== "dash-theme-variables") {
688
+ rerun();
689
+ return;
690
+ }
691
+ }
692
+ }
693
+ });
694
+ observer.observe(document.head, { childList: true });
695
+ return () => observer.disconnect();
696
+ }, []);
668
697
  const contextValue = useMemo2(
669
698
  () => ({
670
699
  theme,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashadmin/dash-boilerplate",
3
- "version": "1.3.47",
3
+ "version": "1.3.48",
4
4
  "main": "dist/index.cjs",
5
5
  "type": "module",
6
6
  "scripts": {