@codefast/theme 0.3.10

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.
Files changed (46) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/LICENSE +21 -0
  3. package/README.md +102 -0
  4. package/dist/adapters/tanstack-start/index.cjs +42 -0
  5. package/dist/adapters/tanstack-start/index.d.ts +39 -0
  6. package/dist/adapters/tanstack-start/index.js +2 -0
  7. package/dist/adapters/tanstack-start/server.cjs +70 -0
  8. package/dist/adapters/tanstack-start/server.d.ts +37 -0
  9. package/dist/adapters/tanstack-start/server.js +30 -0
  10. package/dist/constants.cjs +52 -0
  11. package/dist/constants.d.ts +31 -0
  12. package/dist/constants.js +6 -0
  13. package/dist/core/context.cjs +37 -0
  14. package/dist/core/context.d.ts +13 -0
  15. package/dist/core/context.js +3 -0
  16. package/dist/core/index.cjs +44 -0
  17. package/dist/core/index.d.ts +3 -0
  18. package/dist/core/index.js +4 -0
  19. package/dist/core/provider.cjs +123 -0
  20. package/dist/core/provider.d.ts +47 -0
  21. package/dist/core/provider.js +89 -0
  22. package/dist/core/use-theme.cjs +42 -0
  23. package/dist/core/use-theme.d.ts +28 -0
  24. package/dist/core/use-theme.js +8 -0
  25. package/dist/index.cjs +76 -0
  26. package/dist/index.d.ts +16 -0
  27. package/dist/index.js +6 -0
  28. package/dist/script/index.cjs +36 -0
  29. package/dist/script/index.d.ts +1 -0
  30. package/dist/script/index.js +2 -0
  31. package/dist/script/theme-script.cjs +44 -0
  32. package/dist/script/theme-script.d.ts +32 -0
  33. package/dist/script/theme-script.js +10 -0
  34. package/dist/types.cjs +45 -0
  35. package/dist/types.d.ts +46 -0
  36. package/dist/types.js +8 -0
  37. package/dist/utils/dom.cjs +61 -0
  38. package/dist/utils/dom.d.ts +28 -0
  39. package/dist/utils/dom.js +24 -0
  40. package/dist/utils/index.cjs +46 -0
  41. package/dist/utils/index.d.ts +2 -0
  42. package/dist/utils/index.js +3 -0
  43. package/dist/utils/system.cjs +46 -0
  44. package/dist/utils/system.d.ts +21 -0
  45. package/dist/utils/system.js +9 -0
  46. package/package.json +164 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # @codefast/theme
2
+
3
+ ## 0.3.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [`6737b93`](https://github.com/codefastlabs/codefast/commit/6737b932ed045e2ab1b6da54e3d4c857f77eb436) Thanks [@thevuong](https://github.com/thevuong)! - chore(release): bump package versions
8
+
9
+ - [`b8aef8a`](https://github.com/codefastlabs/codefast/commit/b8aef8a14a885f146de99be5496fc179c6fb49b3) Thanks [@thevuong](https://github.com/thevuong)! - chore: remove deployment workflows and related scripts
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 CodeFast Labs
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,102 @@
1
+ # @codefast/theme
2
+
3
+ Theme management with React 19 features - optimistic updates, cross-tab sync, and SSR support.
4
+
5
+ ## Features
6
+
7
+ - 🚀 **React 19 Optimized** - Uses `useOptimistic`, `useSyncExternalStore`, `useEffectEvent`
8
+ - 🌗 **System Theme Detection** - Automatically detects and follows OS preference
9
+ - 🔄 **Cross-tab Sync** - Theme changes sync across all open tabs
10
+ - âš¡ **Optimistic Updates** - Immediate UI feedback during theme changes
11
+ - 🎯 **SSR Ready** - FOUC prevention with inline script
12
+ - 🔌 **Framework Adapters** - Built-in TanStack Start adapter, extensible for others
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pnpm add @codefast/theme
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ### TanStack Start
23
+
24
+ ```tsx
25
+ // routes/__root.tsx
26
+ import { ThemeProvider, ThemeScript, resolveTheme } from '@codefast/theme';
27
+ import { getThemeServerFn, setThemeServerFn } from '@codefast/theme/tanstack-start';
28
+
29
+ export const Route = createRootRoute({
30
+ loader: async () => {
31
+ const theme = await getThemeServerFn();
32
+ return { theme };
33
+ },
34
+ component: RootComponent,
35
+ head: ({ loaderData }) => ({
36
+ scripts: [
37
+ { tag: ThemeScript, props: { theme: loaderData?.theme ?? 'system' } },
38
+ ],
39
+ }),
40
+ });
41
+
42
+ function RootComponent() {
43
+ const { theme } = Route.useLoaderData();
44
+
45
+ return (
46
+ <ThemeProvider
47
+ theme={theme}
48
+ persistTheme={(value) => setThemeServerFn({ data: value })}
49
+ >
50
+ <Outlet />
51
+ </ThemeProvider>
52
+ );
53
+ }
54
+ ```
55
+
56
+ ### In Components
57
+
58
+ ```tsx
59
+ import { useTheme, themes } from '@codefast/theme';
60
+
61
+ function ThemeToggle() {
62
+ const { theme, setTheme, isPending } = useTheme();
63
+
64
+ return (
65
+ <select
66
+ value={theme}
67
+ onChange={(e) => setTheme(e.target.value)}
68
+ disabled={isPending}
69
+ >
70
+ {themes.map((t) => (
71
+ <option key={t} value={t}>{t}</option>
72
+ ))}
73
+ </select>
74
+ );
75
+ }
76
+ ```
77
+
78
+ ## API
79
+
80
+ ### ThemeProvider
81
+
82
+ | Prop | Type | Description |
83
+ |------|------|-------------|
84
+ | `theme` | `Theme` | Initial theme value |
85
+ | `persistTheme` | `(value: Theme) => Promise<void>` | Callback to persist theme |
86
+ | `disableTransitionOnChange` | `boolean` | Disable CSS transitions during theme change |
87
+ | `nonce` | `string` | CSP nonce for inline styles |
88
+
89
+ ### useTheme
90
+
91
+ Returns `ThemeContextType`:
92
+
93
+ | Property | Type | Description |
94
+ |----------|------|-------------|
95
+ | `theme` | `Theme` | Current theme preference |
96
+ | `resolvedTheme` | `ResolvedTheme` | Resolved theme ('light' or 'dark') |
97
+ | `setTheme` | `(value: Theme) => Promise<void>` | Set theme function |
98
+ | `isPending` | `boolean` | Whether theme change is in progress |
99
+
100
+ ## License
101
+
102
+ MIT
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ createPersistTheme: ()=>external_server_cjs_namespaceObject.createPersistTheme,
28
+ getThemeServerFn: ()=>external_server_cjs_namespaceObject.getThemeServerFn,
29
+ setThemeServerFn: ()=>external_server_cjs_namespaceObject.setThemeServerFn
30
+ });
31
+ const external_server_cjs_namespaceObject = require("./server.cjs");
32
+ exports.createPersistTheme = __webpack_exports__.createPersistTheme;
33
+ exports.getThemeServerFn = __webpack_exports__.getThemeServerFn;
34
+ exports.setThemeServerFn = __webpack_exports__.setThemeServerFn;
35
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
36
+ "createPersistTheme",
37
+ "getThemeServerFn",
38
+ "setThemeServerFn"
39
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
40
+ Object.defineProperty(exports, '__esModule', {
41
+ value: true
42
+ });
@@ -0,0 +1,39 @@
1
+ /**
2
+ * TanStack Start adapter for theme persistence via HTTP-only cookies.
3
+ *
4
+ * @example
5
+ * ```tsx
6
+ * // __root.tsx
7
+ * import { getThemeServerFn, setThemeServerFn } from '@codefast/theme/adapters/tanstack-start';
8
+ * import { ThemeProvider, ThemeScript, resolveTheme } from '@codefast/theme';
9
+ *
10
+ * export const Route = createRootRouteWithContext<RootRouterContext>()({
11
+ * loader: async () => {
12
+ * const theme = await getThemeServerFn();
13
+ * return { theme, resolvedTheme: resolveTheme(theme) };
14
+ * },
15
+ * shellComponent: RootShellComponent,
16
+ * });
17
+ *
18
+ * function RootShellComponent({ children }: PropsWithChildren) {
19
+ * const { theme, resolvedTheme } = Route.useLoaderData();
20
+ *
21
+ * return (
22
+ * <html className={resolvedTheme} style={{ colorScheme: resolvedTheme }}>
23
+ * <head>
24
+ * <ThemeScript theme={theme} />
25
+ * </head>
26
+ * <body>
27
+ * <ThemeProvider
28
+ * theme={theme}
29
+ * persistTheme={(value) => setThemeServerFn({ data: value })}
30
+ * >
31
+ * {children}
32
+ * </ThemeProvider>
33
+ * </body>
34
+ * </html>
35
+ * );
36
+ * }
37
+ * ```
38
+ */
39
+ export { createPersistTheme, getThemeServerFn, setThemeServerFn } from './server';
@@ -0,0 +1,2 @@
1
+ import { createPersistTheme, getThemeServerFn, setThemeServerFn } from "./server.js";
2
+ export { createPersistTheme, getThemeServerFn, setThemeServerFn };
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ createPersistTheme: ()=>createPersistTheme,
28
+ getThemeServerFn: ()=>getThemeServerFn,
29
+ setThemeServerFn: ()=>setThemeServerFn
30
+ });
31
+ const react_start_namespaceObject = require("@tanstack/react-start");
32
+ const server_namespaceObject = require("@tanstack/react-start/server");
33
+ const external_constants_cjs_namespaceObject = require("../../constants.cjs");
34
+ const external_types_cjs_namespaceObject = require("../../types.cjs");
35
+ const getThemeServerFn = (0, react_start_namespaceObject.createServerFn)().handler(()=>{
36
+ const cookieTheme = (0, server_namespaceObject.getCookie)(external_constants_cjs_namespaceObject.THEME_STORAGE_KEY);
37
+ const validationResult = external_types_cjs_namespaceObject.themeSchema.safeParse(cookieTheme);
38
+ if (validationResult.success) return validationResult.data;
39
+ return external_constants_cjs_namespaceObject.DEFAULT_THEME;
40
+ });
41
+ const setThemeServerFn = (0, react_start_namespaceObject.createServerFn)({
42
+ method: 'POST'
43
+ }).inputValidator(external_types_cjs_namespaceObject.themeSchema).handler(({ data })=>{
44
+ (0, server_namespaceObject.setCookie)(external_constants_cjs_namespaceObject.THEME_STORAGE_KEY, data, {
45
+ httpOnly: true,
46
+ maxAge: 31536000,
47
+ path: '/',
48
+ sameSite: 'lax',
49
+ secure: 'production' === process.env.NODE_ENV
50
+ });
51
+ });
52
+ const persistThemeHandler = async (value)=>{
53
+ await setThemeServerFn({
54
+ data: value
55
+ });
56
+ };
57
+ function createPersistTheme() {
58
+ return persistThemeHandler;
59
+ }
60
+ exports.createPersistTheme = __webpack_exports__.createPersistTheme;
61
+ exports.getThemeServerFn = __webpack_exports__.getThemeServerFn;
62
+ exports.setThemeServerFn = __webpack_exports__.setThemeServerFn;
63
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
64
+ "createPersistTheme",
65
+ "getThemeServerFn",
66
+ "setThemeServerFn"
67
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
68
+ Object.defineProperty(exports, '__esModule', {
69
+ value: true
70
+ });
@@ -0,0 +1,37 @@
1
+ import type { Theme } from '../../types';
2
+ /**
3
+ * Read the user's theme preference from cookies.
4
+ *
5
+ * Validates the cookie value using Zod schema for type safety.
6
+ * Returns {@link DEFAULT_THEME} if cookie is missing or invalid.
7
+ *
8
+ * @returns User's stored theme preference or default
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * const theme = await getThemeServerFn();
13
+ * ```
14
+ */
15
+ export declare const getThemeServerFn: import("@tanstack/react-start").OptionalFetcher<undefined, undefined, "light" | "dark" | "system">;
16
+ /**
17
+ * Persist theme preference to an HTTP-only cookie.
18
+ *
19
+ * **Security:**
20
+ * - `httpOnly: true` - Cookie cannot be accessed from JavaScript (XSS protection)
21
+ * - `secure: true` in production - Cookie only sent over HTTPS
22
+ * - `sameSite: 'lax'` - Prevents CSRF while allowing navigation
23
+ *
24
+ * **Cookie Settings:**
25
+ * - `maxAge: 1 year` - Preference persists across sessions
26
+ * - `path: '/'` - Available to all routes
27
+ *
28
+ * @param data - Theme to persist ('light', 'dark', or 'system')
29
+ *
30
+ * @see [TanStack Start Server Functions](https://tanstack.com/start/latest/docs/framework/react/server-functions)
31
+ */
32
+ export declare const setThemeServerFn: import("@tanstack/react-start").RequiredFetcher<undefined, import("zod").ZodEnum<{
33
+ light: "light";
34
+ dark: "dark";
35
+ system: "system";
36
+ }>, void>;
37
+ export declare function createPersistTheme(): (value: Theme) => Promise<void>;
@@ -0,0 +1,30 @@
1
+ import { createServerFn } from "@tanstack/react-start";
2
+ import { getCookie, setCookie } from "@tanstack/react-start/server";
3
+ import { DEFAULT_THEME, THEME_STORAGE_KEY } from "../../constants.js";
4
+ import { themeSchema } from "../../types.js";
5
+ const getThemeServerFn = createServerFn().handler(()=>{
6
+ const cookieTheme = getCookie(THEME_STORAGE_KEY);
7
+ const validationResult = themeSchema.safeParse(cookieTheme);
8
+ if (validationResult.success) return validationResult.data;
9
+ return DEFAULT_THEME;
10
+ });
11
+ const setThemeServerFn = createServerFn({
12
+ method: 'POST'
13
+ }).inputValidator(themeSchema).handler(({ data })=>{
14
+ setCookie(THEME_STORAGE_KEY, data, {
15
+ httpOnly: true,
16
+ maxAge: 31536000,
17
+ path: '/',
18
+ sameSite: 'lax',
19
+ secure: 'production' === process.env.NODE_ENV
20
+ });
21
+ });
22
+ const persistThemeHandler = async (value)=>{
23
+ await setThemeServerFn({
24
+ data: value
25
+ });
26
+ };
27
+ function createPersistTheme() {
28
+ return persistThemeHandler;
29
+ }
30
+ export { createPersistTheme, getThemeServerFn, setThemeServerFn };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ DEFAULT_RESOLVED_THEME: ()=>DEFAULT_RESOLVED_THEME,
28
+ DEFAULT_THEME: ()=>DEFAULT_THEME,
29
+ MEDIA: ()=>MEDIA,
30
+ THEME_CHANNEL: ()=>THEME_CHANNEL,
31
+ THEME_STORAGE_KEY: ()=>THEME_STORAGE_KEY
32
+ });
33
+ const DEFAULT_THEME = 'system';
34
+ const DEFAULT_RESOLVED_THEME = 'dark';
35
+ const THEME_STORAGE_KEY = 'ui-theme';
36
+ const MEDIA = '(prefers-color-scheme: dark)';
37
+ const THEME_CHANNEL = 'theme-sync';
38
+ exports.DEFAULT_RESOLVED_THEME = __webpack_exports__.DEFAULT_RESOLVED_THEME;
39
+ exports.DEFAULT_THEME = __webpack_exports__.DEFAULT_THEME;
40
+ exports.MEDIA = __webpack_exports__.MEDIA;
41
+ exports.THEME_CHANNEL = __webpack_exports__.THEME_CHANNEL;
42
+ exports.THEME_STORAGE_KEY = __webpack_exports__.THEME_STORAGE_KEY;
43
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
44
+ "DEFAULT_RESOLVED_THEME",
45
+ "DEFAULT_THEME",
46
+ "MEDIA",
47
+ "THEME_CHANNEL",
48
+ "THEME_STORAGE_KEY"
49
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
50
+ Object.defineProperty(exports, '__esModule', {
51
+ value: true
52
+ });
@@ -0,0 +1,31 @@
1
+ import type { ResolvedTheme, Theme } from './types';
2
+ /**
3
+ * Default theme when no user preference exists.
4
+ *
5
+ * Set to 'system' to respect OS preference by default.
6
+ */
7
+ export declare const DEFAULT_THEME: Theme;
8
+ /**
9
+ * Fallback theme for SSR when system preference cannot be detected.
10
+ *
11
+ * Used during server-side rendering since `window.matchMedia()` is unavailable.
12
+ */
13
+ export declare const DEFAULT_RESOLVED_THEME: ResolvedTheme;
14
+ /**
15
+ * Cookie key for persisting user's theme preference.
16
+ *
17
+ * The cookie is httpOnly for security (only server can read it).
18
+ */
19
+ export declare const THEME_STORAGE_KEY = "ui-theme";
20
+ /**
21
+ * CSS media query for detecting dark mode preference.
22
+ * @internal
23
+ */
24
+ export declare const MEDIA = "(prefers-color-scheme: dark)";
25
+ /**
26
+ * BroadcastChannel name for cross-tab theme synchronization.
27
+ *
28
+ * Enables instant theme updates across all open browser tabs.
29
+ * @internal
30
+ */
31
+ export declare const THEME_CHANNEL = "theme-sync";
@@ -0,0 +1,6 @@
1
+ const DEFAULT_THEME = 'system';
2
+ const DEFAULT_RESOLVED_THEME = 'dark';
3
+ const THEME_STORAGE_KEY = 'ui-theme';
4
+ const MEDIA = '(prefers-color-scheme: dark)';
5
+ const THEME_CHANNEL = 'theme-sync';
6
+ export { DEFAULT_RESOLVED_THEME, DEFAULT_THEME, MEDIA, THEME_CHANNEL, THEME_STORAGE_KEY };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ ThemeContext: ()=>ThemeContext
28
+ });
29
+ const external_react_namespaceObject = require("react");
30
+ const ThemeContext = /*#__PURE__*/ (0, external_react_namespaceObject.createContext)(null);
31
+ exports.ThemeContext = __webpack_exports__.ThemeContext;
32
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
33
+ "ThemeContext"
34
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
35
+ Object.defineProperty(exports, '__esModule', {
36
+ value: true
37
+ });
@@ -0,0 +1,13 @@
1
+ import type { ThemeContextType } from '../types';
2
+ type ThemeContextValue = null | ThemeContextType;
3
+ /**
4
+ * React context for theme state management.
5
+ *
6
+ * Provides access to current theme, resolved theme, setter function, and pending state.
7
+ * Use {@link useTheme} hook instead of consuming this context directly.
8
+ *
9
+ * @see {@link ThemeProvider} - Provider component
10
+ * @see {@link useTheme} - Consumer hook
11
+ */
12
+ export declare const ThemeContext: import("react").Context<ThemeContextValue>;
13
+ export {};
@@ -0,0 +1,3 @@
1
+ import { createContext } from "react";
2
+ const ThemeContext = /*#__PURE__*/ createContext(null);
3
+ export { ThemeContext };
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __webpack_require__ = {};
3
+ (()=>{
4
+ __webpack_require__.d = (exports1, definition)=>{
5
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
6
+ enumerable: true,
7
+ get: definition[key]
8
+ });
9
+ };
10
+ })();
11
+ (()=>{
12
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
13
+ })();
14
+ (()=>{
15
+ __webpack_require__.r = (exports1)=>{
16
+ if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
17
+ value: 'Module'
18
+ });
19
+ Object.defineProperty(exports1, '__esModule', {
20
+ value: true
21
+ });
22
+ };
23
+ })();
24
+ var __webpack_exports__ = {};
25
+ __webpack_require__.r(__webpack_exports__);
26
+ __webpack_require__.d(__webpack_exports__, {
27
+ ThemeProvider: ()=>external_provider_cjs_namespaceObject.ThemeProvider,
28
+ ThemeContext: ()=>external_context_cjs_namespaceObject.ThemeContext,
29
+ useTheme: ()=>external_use_theme_cjs_namespaceObject.useTheme
30
+ });
31
+ const external_context_cjs_namespaceObject = require("./context.cjs");
32
+ const external_provider_cjs_namespaceObject = require("./provider.cjs");
33
+ const external_use_theme_cjs_namespaceObject = require("./use-theme.cjs");
34
+ exports.ThemeContext = __webpack_exports__.ThemeContext;
35
+ exports.ThemeProvider = __webpack_exports__.ThemeProvider;
36
+ exports.useTheme = __webpack_exports__.useTheme;
37
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
38
+ "ThemeContext",
39
+ "ThemeProvider",
40
+ "useTheme"
41
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
42
+ Object.defineProperty(exports, '__esModule', {
43
+ value: true
44
+ });
@@ -0,0 +1,3 @@
1
+ export { ThemeContext } from './context';
2
+ export { ThemeProvider } from './provider';
3
+ export { useTheme } from './use-theme';
@@ -0,0 +1,4 @@
1
+ import { ThemeContext } from "./context.js";
2
+ import { ThemeProvider } from "./provider.js";
3
+ import { useTheme } from "./use-theme.js";
4
+ export { ThemeContext, ThemeProvider, useTheme };