@tydavidson/design-system 1.1.8 → 1.1.9

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.js CHANGED
@@ -3,7 +3,6 @@
3
3
  var clsx = require('clsx');
4
4
  var tailwindMerge = require('tailwind-merge');
5
5
  var React2 = require('react');
6
- var nextThemes = require('next-themes');
7
6
  var jsxRuntime = require('react/jsx-runtime');
8
7
  var iconsReact = require('@tabler/icons-react');
9
8
  var reactSlot = require('@radix-ui/react-slot');
@@ -91,11 +90,19 @@ function ThemeProvider({
91
90
  children,
92
91
  ...props
93
92
  }) {
94
- if (typeof window === "undefined") {
93
+ const [NextThemesProvider, setNextThemesProvider] = React2__namespace.useState(null);
94
+ const [mounted, setMounted] = React2__namespace.useState(false);
95
+ React2__namespace.useEffect(() => {
96
+ import('next-themes').then(({ ThemeProvider: Provider }) => {
97
+ setNextThemesProvider(() => Provider);
98
+ setMounted(true);
99
+ });
100
+ }, []);
101
+ if (!mounted || !NextThemesProvider) {
95
102
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
96
103
  }
97
104
  return /* @__PURE__ */ jsxRuntime.jsx(
98
- nextThemes.ThemeProvider,
105
+ NextThemesProvider,
99
106
  {
100
107
  attribute: "class",
101
108
  defaultTheme: "system",
@@ -187,28 +194,42 @@ var init_theme_utils = __esm({
187
194
  }
188
195
  });
189
196
  function useTheme() {
190
- if (typeof window === "undefined") {
197
+ const [themeData, setThemeData] = React2__namespace.useState({
198
+ theme: "system",
199
+ setTheme: (theme) => {
200
+ },
201
+ resolvedTheme: "light",
202
+ isDark: false
203
+ });
204
+ const [mounted, setMounted] = React2__namespace.useState(false);
205
+ React2__namespace.useEffect(() => {
206
+ import('next-themes').then(({ useTheme: useNextTheme }) => {
207
+ const { theme, setTheme, resolvedTheme, systemTheme } = useNextTheme();
208
+ const isDark = exports.isDarkTheme(theme, systemTheme);
209
+ setThemeData({
210
+ theme: theme || "system",
211
+ setTheme,
212
+ resolvedTheme: resolvedTheme || "light",
213
+ isDark
214
+ });
215
+ setMounted(true);
216
+ });
217
+ }, []);
218
+ if (!mounted) {
191
219
  return {
192
220
  theme: "system",
193
- setTheme: () => {
221
+ setTheme: (theme) => {
194
222
  },
195
223
  resolvedTheme: "light",
196
224
  isDark: false
197
225
  };
198
226
  }
199
- const { theme, setTheme, resolvedTheme, systemTheme } = nextThemes.useTheme();
200
- const isDark = exports.isDarkTheme(theme, systemTheme);
201
- return {
202
- theme: theme || "system",
203
- setTheme,
204
- resolvedTheme: resolvedTheme || "light",
205
- isDark
206
- };
227
+ return themeData;
207
228
  }
208
229
  function useThemeServer() {
209
230
  return {
210
231
  theme: "system",
211
- setTheme: () => {
232
+ setTheme: (theme) => {
212
233
  },
213
234
  resolvedTheme: "light",
214
235
  isDark: false