@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.
package/dist/providers.js CHANGED
@@ -1893,6 +1893,49 @@ function mergeCustomColorTokens(baseTokens2, customPalette) {
1893
1893
  ...customPalette.derivedTokens
1894
1894
  };
1895
1895
  }
1896
+ function validateThemeTokens(theme, mode) {
1897
+ if (typeof process !== "undefined" && process.env?.NODE_ENV === "production") return;
1898
+ const root = document.documentElement;
1899
+ const style = getComputedStyle(root);
1900
+ const requiredTokens = [
1901
+ "--color-background",
1902
+ "--color-foreground",
1903
+ "--color-primary",
1904
+ "--color-primary-foreground",
1905
+ "--color-border",
1906
+ "--color-ring",
1907
+ "--font-heading",
1908
+ "--font-body",
1909
+ "--font-mono"
1910
+ ];
1911
+ const missingTokens = [];
1912
+ const invalidTokens = [];
1913
+ requiredTokens.forEach((token) => {
1914
+ const value = style.getPropertyValue(token).trim();
1915
+ if (!value) {
1916
+ missingTokens.push(token);
1917
+ } else if (token.startsWith("--color-") && !value.match(/^(#|rgb|hsl|var\()/)) {
1918
+ invalidTokens.push(`${token} = "${value}"`);
1919
+ } else if (token.startsWith("--font-") && value === "") {
1920
+ invalidTokens.push(`${token} = empty`);
1921
+ }
1922
+ });
1923
+ if (missingTokens.length > 0) {
1924
+ console.warn(
1925
+ `[ThemeProvider] Missing CSS variables for theme "${theme}" (${mode} mode):`,
1926
+ missingTokens
1927
+ );
1928
+ }
1929
+ if (invalidTokens.length > 0) {
1930
+ console.warn(
1931
+ `[ThemeProvider] Invalid CSS variable values for theme "${theme}" (${mode} mode):`,
1932
+ invalidTokens
1933
+ );
1934
+ }
1935
+ if (missingTokens.length === 0 && invalidTokens.length === 0) {
1936
+ console.log(`[ThemeProvider] \u2713 Theme validation passed for "${theme}" (${mode} mode)`);
1937
+ }
1938
+ }
1896
1939
  function ThemeProvider({ children }) {
1897
1940
  const { theme, mode } = useThemeStore();
1898
1941
  const customPalette = useCustomizer((state) => state.customColors?.[theme]?.[mode]);
@@ -1926,6 +1969,7 @@ function ThemeProvider({ children }) {
1926
1969
  } else {
1927
1970
  root.classList.remove("dark");
1928
1971
  }
1972
+ validateThemeTokens(theme, mode);
1929
1973
  const timeout = setTimeout(() => {
1930
1974
  root.classList.remove("theme-transitioning");
1931
1975
  setIsTransitioning(false);