@thesage/ui 0.0.12 → 0.0.13

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.
@@ -1868,6 +1868,49 @@ function mergeCustomColorTokens(baseTokens2, customPalette) {
1868
1868
  ...customPalette.derivedTokens
1869
1869
  };
1870
1870
  }
1871
+ function validateThemeTokens(theme, mode) {
1872
+ if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
1873
+ const root = document.documentElement;
1874
+ const style = getComputedStyle(root);
1875
+ const requiredTokens = [
1876
+ "--color-background",
1877
+ "--color-foreground",
1878
+ "--color-primary",
1879
+ "--color-primary-foreground",
1880
+ "--color-border",
1881
+ "--color-ring",
1882
+ "--font-heading",
1883
+ "--font-body",
1884
+ "--font-mono"
1885
+ ];
1886
+ const missingTokens = [];
1887
+ const invalidTokens = [];
1888
+ requiredTokens.forEach((token) => {
1889
+ const value = style.getPropertyValue(token).trim();
1890
+ if (!value) {
1891
+ missingTokens.push(token);
1892
+ } else if (token.startsWith("--color-") && !value.match(/^(#|rgb|hsl|var\()/)) {
1893
+ invalidTokens.push(`${token} = "${value}"`);
1894
+ } else if (token.startsWith("--font-") && value === "") {
1895
+ invalidTokens.push(`${token} = empty`);
1896
+ }
1897
+ });
1898
+ if (missingTokens.length > 0) {
1899
+ console.warn(
1900
+ `[ThemeProvider] Missing CSS variables for theme "${theme}" (${mode} mode):`,
1901
+ missingTokens
1902
+ );
1903
+ }
1904
+ if (invalidTokens.length > 0) {
1905
+ console.warn(
1906
+ `[ThemeProvider] Invalid CSS variable values for theme "${theme}" (${mode} mode):`,
1907
+ invalidTokens
1908
+ );
1909
+ }
1910
+ if (missingTokens.length === 0 && invalidTokens.length === 0) {
1911
+ console.log(`[ThemeProvider] \u2713 Theme validation passed for "${theme}" (${mode} mode)`);
1912
+ }
1913
+ }
1871
1914
  function ThemeProvider({ children }) {
1872
1915
  const { theme, mode } = useThemeStore();
1873
1916
  const customPalette = useCustomizer((state) => state.customColors?.[theme]?.[mode]);
@@ -1901,6 +1944,7 @@ function ThemeProvider({ children }) {
1901
1944
  } else {
1902
1945
  root.classList.remove("dark");
1903
1946
  }
1947
+ validateThemeTokens(theme, mode);
1904
1948
  const timeout = setTimeout(() => {
1905
1949
  root.classList.remove("theme-transitioning");
1906
1950
  setIsTransitioning(false);