@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.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  import { clsx } from 'clsx';
2
2
  import { twMerge } from 'tailwind-merge';
3
3
  import * as React2 from 'react';
4
- import { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1 } from 'next-themes';
5
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
5
  import { IconCheck, IconPointFilled, IconChevronRight, IconX, IconSearch, IconSun, IconMoon } from '@tabler/icons-react';
7
6
  import { Slot } from '@radix-ui/react-slot';
@@ -57,11 +56,19 @@ function ThemeProvider({
57
56
  children,
58
57
  ...props
59
58
  }) {
60
- if (typeof window === "undefined") {
59
+ const [NextThemesProvider, setNextThemesProvider] = React2.useState(null);
60
+ const [mounted, setMounted] = React2.useState(false);
61
+ React2.useEffect(() => {
62
+ import('next-themes').then(({ ThemeProvider: Provider }) => {
63
+ setNextThemesProvider(() => Provider);
64
+ setMounted(true);
65
+ });
66
+ }, []);
67
+ if (!mounted || !NextThemesProvider) {
61
68
  return /* @__PURE__ */ jsx(Fragment, { children });
62
69
  }
63
70
  return /* @__PURE__ */ jsx(
64
- ThemeProvider$1,
71
+ NextThemesProvider,
65
72
  {
66
73
  attribute: "class",
67
74
  defaultTheme: "system",
@@ -153,28 +160,42 @@ var init_theme_utils = __esm({
153
160
  }
154
161
  });
155
162
  function useTheme() {
156
- if (typeof window === "undefined") {
163
+ const [themeData, setThemeData] = React2.useState({
164
+ theme: "system",
165
+ setTheme: (theme) => {
166
+ },
167
+ resolvedTheme: "light",
168
+ isDark: false
169
+ });
170
+ const [mounted, setMounted] = React2.useState(false);
171
+ React2.useEffect(() => {
172
+ import('next-themes').then(({ useTheme: useNextTheme }) => {
173
+ const { theme, setTheme, resolvedTheme, systemTheme } = useNextTheme();
174
+ const isDark = isDarkTheme(theme, systemTheme);
175
+ setThemeData({
176
+ theme: theme || "system",
177
+ setTheme,
178
+ resolvedTheme: resolvedTheme || "light",
179
+ isDark
180
+ });
181
+ setMounted(true);
182
+ });
183
+ }, []);
184
+ if (!mounted) {
157
185
  return {
158
186
  theme: "system",
159
- setTheme: () => {
187
+ setTheme: (theme) => {
160
188
  },
161
189
  resolvedTheme: "light",
162
190
  isDark: false
163
191
  };
164
192
  }
165
- const { theme, setTheme, resolvedTheme, systemTheme } = useTheme$1();
166
- const isDark = isDarkTheme(theme, systemTheme);
167
- return {
168
- theme: theme || "system",
169
- setTheme,
170
- resolvedTheme: resolvedTheme || "light",
171
- isDark
172
- };
193
+ return themeData;
173
194
  }
174
195
  function useThemeServer() {
175
196
  return {
176
197
  theme: "system",
177
- setTheme: () => {
198
+ setTheme: (theme) => {
178
199
  },
179
200
  resolvedTheme: "light",
180
201
  isDark: false