@stackwright/themes 0.4.0 → 0.5.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Per Aspera Sapientia LLC
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.
@@ -0,0 +1,331 @@
1
+ import { z } from 'zod';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import React, { ReactNode } from 'react';
4
+
5
+ declare const componentStyleSchema: z.ZodObject<{
6
+ base: z.ZodOptional<z.ZodString>;
7
+ primary: z.ZodOptional<z.ZodString>;
8
+ secondary: z.ZodOptional<z.ZodString>;
9
+ outline: z.ZodOptional<z.ZodString>;
10
+ shadow: z.ZodOptional<z.ZodString>;
11
+ nav: z.ZodOptional<z.ZodString>;
12
+ text: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>;
14
+ declare const colorsSchema: z.ZodObject<{
15
+ primary: z.ZodString;
16
+ secondary: z.ZodString;
17
+ accent: z.ZodString;
18
+ background: z.ZodString;
19
+ surface: z.ZodString;
20
+ text: z.ZodString;
21
+ textSecondary: z.ZodString;
22
+ }, z.core.$strip>;
23
+ type ThemeColors = z.infer<typeof colorsSchema>;
24
+ type ColorMode = 'light' | 'dark' | 'system';
25
+ declare const themeConfigSchema: z.ZodObject<{
26
+ id: z.ZodString;
27
+ name: z.ZodString;
28
+ description: z.ZodString;
29
+ colors: z.ZodObject<{
30
+ primary: z.ZodString;
31
+ secondary: z.ZodString;
32
+ accent: z.ZodString;
33
+ background: z.ZodString;
34
+ surface: z.ZodString;
35
+ text: z.ZodString;
36
+ textSecondary: z.ZodString;
37
+ }, z.core.$strip>;
38
+ darkColors: z.ZodOptional<z.ZodObject<{
39
+ primary: z.ZodString;
40
+ secondary: z.ZodString;
41
+ accent: z.ZodString;
42
+ background: z.ZodString;
43
+ surface: z.ZodString;
44
+ text: z.ZodString;
45
+ textSecondary: z.ZodString;
46
+ }, z.core.$strip>>;
47
+ backgroundImage: z.ZodOptional<z.ZodObject<{
48
+ url: z.ZodString;
49
+ repeat: z.ZodOptional<z.ZodEnum<{
50
+ repeat: "repeat";
51
+ "repeat-x": "repeat-x";
52
+ "repeat-y": "repeat-y";
53
+ "no-repeat": "no-repeat";
54
+ }>>;
55
+ size: z.ZodOptional<z.ZodString>;
56
+ position: z.ZodOptional<z.ZodString>;
57
+ attachment: z.ZodOptional<z.ZodEnum<{
58
+ scroll: "scroll";
59
+ fixed: "fixed";
60
+ local: "local";
61
+ }>>;
62
+ scale: z.ZodOptional<z.ZodNumber>;
63
+ animation: z.ZodOptional<z.ZodEnum<{
64
+ drift: "drift";
65
+ float: "float";
66
+ shimmer: "shimmer";
67
+ "shimmer-float": "shimmer-float";
68
+ none: "none";
69
+ }>>;
70
+ customAnimation: z.ZodOptional<z.ZodString>;
71
+ }, z.core.$strip>>;
72
+ typography: z.ZodObject<{
73
+ fontFamily: z.ZodObject<{
74
+ primary: z.ZodString;
75
+ secondary: z.ZodString;
76
+ }, z.core.$strip>;
77
+ scale: z.ZodObject<{
78
+ xs: z.ZodString;
79
+ sm: z.ZodString;
80
+ base: z.ZodString;
81
+ lg: z.ZodString;
82
+ xl: z.ZodString;
83
+ '2xl': z.ZodString;
84
+ '3xl': z.ZodString;
85
+ }, z.core.$strip>;
86
+ }, z.core.$strip>;
87
+ spacing: z.ZodObject<{
88
+ xs: z.ZodString;
89
+ sm: z.ZodString;
90
+ md: z.ZodString;
91
+ lg: z.ZodString;
92
+ xl: z.ZodString;
93
+ '2xl': z.ZodString;
94
+ }, z.core.$strip>;
95
+ components: z.ZodOptional<z.ZodObject<{
96
+ button: z.ZodOptional<z.ZodObject<{
97
+ base: z.ZodOptional<z.ZodString>;
98
+ primary: z.ZodOptional<z.ZodString>;
99
+ secondary: z.ZodOptional<z.ZodString>;
100
+ outline: z.ZodOptional<z.ZodString>;
101
+ shadow: z.ZodOptional<z.ZodString>;
102
+ nav: z.ZodOptional<z.ZodString>;
103
+ text: z.ZodOptional<z.ZodString>;
104
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
105
+ card: z.ZodOptional<z.ZodObject<{
106
+ base: z.ZodOptional<z.ZodString>;
107
+ primary: z.ZodOptional<z.ZodString>;
108
+ secondary: z.ZodOptional<z.ZodString>;
109
+ outline: z.ZodOptional<z.ZodString>;
110
+ shadow: z.ZodOptional<z.ZodString>;
111
+ nav: z.ZodOptional<z.ZodString>;
112
+ text: z.ZodOptional<z.ZodString>;
113
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
114
+ header: z.ZodOptional<z.ZodObject<{
115
+ base: z.ZodOptional<z.ZodString>;
116
+ primary: z.ZodOptional<z.ZodString>;
117
+ secondary: z.ZodOptional<z.ZodString>;
118
+ outline: z.ZodOptional<z.ZodString>;
119
+ shadow: z.ZodOptional<z.ZodString>;
120
+ nav: z.ZodOptional<z.ZodString>;
121
+ text: z.ZodOptional<z.ZodString>;
122
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
123
+ footer: z.ZodOptional<z.ZodObject<{
124
+ base: z.ZodOptional<z.ZodString>;
125
+ primary: z.ZodOptional<z.ZodString>;
126
+ secondary: z.ZodOptional<z.ZodString>;
127
+ outline: z.ZodOptional<z.ZodString>;
128
+ shadow: z.ZodOptional<z.ZodString>;
129
+ nav: z.ZodOptional<z.ZodString>;
130
+ text: z.ZodOptional<z.ZodString>;
131
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
132
+ }, z.core.$strip>>;
133
+ }, z.core.$strip>;
134
+ declare const themeSchema: z.ZodObject<{
135
+ id: z.ZodString;
136
+ name: z.ZodString;
137
+ description: z.ZodString;
138
+ colors: z.ZodObject<{
139
+ primary: z.ZodString;
140
+ secondary: z.ZodString;
141
+ accent: z.ZodString;
142
+ background: z.ZodString;
143
+ surface: z.ZodString;
144
+ text: z.ZodString;
145
+ textSecondary: z.ZodString;
146
+ }, z.core.$strip>;
147
+ darkColors: z.ZodOptional<z.ZodObject<{
148
+ primary: z.ZodString;
149
+ secondary: z.ZodString;
150
+ accent: z.ZodString;
151
+ background: z.ZodString;
152
+ surface: z.ZodString;
153
+ text: z.ZodString;
154
+ textSecondary: z.ZodString;
155
+ }, z.core.$strip>>;
156
+ backgroundImage: z.ZodOptional<z.ZodObject<{
157
+ url: z.ZodString;
158
+ repeat: z.ZodOptional<z.ZodEnum<{
159
+ repeat: "repeat";
160
+ "repeat-x": "repeat-x";
161
+ "repeat-y": "repeat-y";
162
+ "no-repeat": "no-repeat";
163
+ }>>;
164
+ size: z.ZodOptional<z.ZodString>;
165
+ position: z.ZodOptional<z.ZodString>;
166
+ attachment: z.ZodOptional<z.ZodEnum<{
167
+ scroll: "scroll";
168
+ fixed: "fixed";
169
+ local: "local";
170
+ }>>;
171
+ scale: z.ZodOptional<z.ZodNumber>;
172
+ animation: z.ZodOptional<z.ZodEnum<{
173
+ drift: "drift";
174
+ float: "float";
175
+ shimmer: "shimmer";
176
+ "shimmer-float": "shimmer-float";
177
+ none: "none";
178
+ }>>;
179
+ customAnimation: z.ZodOptional<z.ZodString>;
180
+ }, z.core.$strip>>;
181
+ typography: z.ZodObject<{
182
+ fontFamily: z.ZodObject<{
183
+ primary: z.ZodString;
184
+ secondary: z.ZodString;
185
+ }, z.core.$strip>;
186
+ scale: z.ZodObject<{
187
+ xs: z.ZodString;
188
+ sm: z.ZodString;
189
+ base: z.ZodString;
190
+ lg: z.ZodString;
191
+ xl: z.ZodString;
192
+ '2xl': z.ZodString;
193
+ '3xl': z.ZodString;
194
+ }, z.core.$strip>;
195
+ }, z.core.$strip>;
196
+ spacing: z.ZodObject<{
197
+ xs: z.ZodString;
198
+ sm: z.ZodString;
199
+ md: z.ZodString;
200
+ lg: z.ZodString;
201
+ xl: z.ZodString;
202
+ '2xl': z.ZodString;
203
+ }, z.core.$strip>;
204
+ components: z.ZodOptional<z.ZodObject<{
205
+ button: z.ZodOptional<z.ZodObject<{
206
+ base: z.ZodOptional<z.ZodString>;
207
+ primary: z.ZodOptional<z.ZodString>;
208
+ secondary: z.ZodOptional<z.ZodString>;
209
+ outline: z.ZodOptional<z.ZodString>;
210
+ shadow: z.ZodOptional<z.ZodString>;
211
+ nav: z.ZodOptional<z.ZodString>;
212
+ text: z.ZodOptional<z.ZodString>;
213
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
214
+ card: z.ZodOptional<z.ZodObject<{
215
+ base: z.ZodOptional<z.ZodString>;
216
+ primary: z.ZodOptional<z.ZodString>;
217
+ secondary: z.ZodOptional<z.ZodString>;
218
+ outline: z.ZodOptional<z.ZodString>;
219
+ shadow: z.ZodOptional<z.ZodString>;
220
+ nav: z.ZodOptional<z.ZodString>;
221
+ text: z.ZodOptional<z.ZodString>;
222
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
223
+ header: z.ZodOptional<z.ZodObject<{
224
+ base: z.ZodOptional<z.ZodString>;
225
+ primary: z.ZodOptional<z.ZodString>;
226
+ secondary: z.ZodOptional<z.ZodString>;
227
+ outline: z.ZodOptional<z.ZodString>;
228
+ shadow: z.ZodOptional<z.ZodString>;
229
+ nav: z.ZodOptional<z.ZodString>;
230
+ text: z.ZodOptional<z.ZodString>;
231
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
232
+ footer: z.ZodOptional<z.ZodObject<{
233
+ base: z.ZodOptional<z.ZodString>;
234
+ primary: z.ZodOptional<z.ZodString>;
235
+ secondary: z.ZodOptional<z.ZodString>;
236
+ outline: z.ZodOptional<z.ZodString>;
237
+ shadow: z.ZodOptional<z.ZodString>;
238
+ nav: z.ZodOptional<z.ZodString>;
239
+ text: z.ZodOptional<z.ZodString>;
240
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
241
+ }, z.core.$strip>>;
242
+ }, z.core.$strip>;
243
+ type ThemeConfig = z.infer<typeof themeConfigSchema>;
244
+ type ComponentStyle = z.infer<typeof componentStyleSchema>;
245
+ interface Theme extends ThemeConfig {
246
+ }
247
+
248
+ interface ThemeContextType {
249
+ /** The resolved theme — `colors` reflects the active color mode. */
250
+ theme: Theme;
251
+ /** The original theme with both `colors` and `darkColors` intact. */
252
+ rawTheme: Theme;
253
+ setTheme: (theme: Theme) => void;
254
+ /** Current color mode setting (`'light'`, `'dark'`, or `'system'`). */
255
+ colorMode: ColorMode;
256
+ /** Switch the color mode. */
257
+ setColorMode: (mode: ColorMode) => void;
258
+ /** The actually active mode after resolving `'system'`. */
259
+ resolvedColorMode: 'light' | 'dark';
260
+ }
261
+ interface ThemeProviderProps {
262
+ theme: Theme;
263
+ children: ReactNode;
264
+ /** Initial color mode. Defaults to `'system'`. */
265
+ initialColorMode?: ColorMode;
266
+ }
267
+ declare const ThemeProvider: React.FC<ThemeProviderProps>;
268
+ /**
269
+ * Access the current theme and color mode controls.
270
+ * Must be called inside a `<ThemeProvider>`.
271
+ */
272
+ declare const useTheme: () => ThemeContextType;
273
+ /**
274
+ * Like `useTheme`, but returns `undefined` instead of throwing when
275
+ * no `ThemeProvider` is present. Useful for optional-context components
276
+ * like `ThemeStyleInjector`.
277
+ */
278
+ declare const useThemeOptional: () => ThemeContextType | undefined;
279
+ /**
280
+ * Converts a Stackwright Theme to CSS custom properties.
281
+ * Inject these via ThemeStyleInjector or a `<style>` tag.
282
+ */
283
+ declare function themeToCSSVars(theme: Theme): Record<string, string>;
284
+ interface ThemeStyleInjectorProps {
285
+ /**
286
+ * Explicit theme override. When omitted the resolved theme from the
287
+ * nearest `ThemeProvider` is used automatically — this is the
288
+ * recommended approach so CSS vars stay in sync with color mode changes.
289
+ */
290
+ theme?: Theme;
291
+ children: ReactNode;
292
+ className?: string;
293
+ }
294
+ /**
295
+ * Wraps children in a div that injects Stackwright CSS custom properties.
296
+ * Place this inside a `<ThemeProvider>` and it will track color mode
297
+ * changes automatically.
298
+ */
299
+ declare function ThemeStyleInjector({ theme: themeProp, children, className, }: ThemeStyleInjectorProps): react_jsx_runtime.JSX.Element;
300
+
301
+ declare class ThemeLoader {
302
+ private static themes;
303
+ static loadThemeFromYaml(yamlContent: string): Theme;
304
+ static loadThemeFromFile(themeName: string): Theme;
305
+ static getTheme(name: string): Theme | undefined;
306
+ static getAllThemes(): Theme[];
307
+ static registerCustomTheme(theme: Theme): void;
308
+ static loadCustomTheme(theme: Theme): Theme;
309
+ private static getEmbeddedTheme;
310
+ }
311
+
312
+ /**
313
+ * Blocking script that reads the `sw-color-mode` cookie and applies the
314
+ * correct color mode attribute to `<html>` before React hydrates.
315
+ *
316
+ * Place this in `_document.tsx` `<Head>` (Pages Router) or in a `<script>`
317
+ * tag in `layout.tsx` (App Router). It must execute before the body is
318
+ * painted — intentionally render-blocking.
319
+ *
320
+ * The `data-sw-color-mode` attribute set by this script is read by
321
+ * `ThemeProvider`'s `systemPreference` initialiser, ensuring the first
322
+ * React render matches the visible state — no hydration mismatch.
323
+ *
324
+ * For return visitors (cookie exists): correct theme on first paint, zero flash.
325
+ * For first-time visitors with OS dark mode: one-frame flash (same as next-themes v0.2).
326
+ */
327
+ declare function ColorModeScript({ fallback }: {
328
+ fallback?: ColorMode;
329
+ }): react_jsx_runtime.JSX.Element;
330
+
331
+ export { type ColorMode, ColorModeScript, type ComponentStyle, type Theme, type ThemeColors, type ThemeColors as ThemeColorsType, type ThemeConfig, ThemeLoader, ThemeProvider, ThemeStyleInjector, colorsSchema, componentStyleSchema, themeConfigSchema, themeSchema, themeToCSSVars, useTheme, useThemeOptional };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,331 @@
1
- export * from './types';
2
- export * from './ThemeProvider';
3
- export * from './themeLoader';
4
- export type { ThemeConfig, Theme, ComponentStyle } from './types';
5
- //# sourceMappingURL=index.d.ts.map
1
+ import { z } from 'zod';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import React, { ReactNode } from 'react';
4
+
5
+ declare const componentStyleSchema: z.ZodObject<{
6
+ base: z.ZodOptional<z.ZodString>;
7
+ primary: z.ZodOptional<z.ZodString>;
8
+ secondary: z.ZodOptional<z.ZodString>;
9
+ outline: z.ZodOptional<z.ZodString>;
10
+ shadow: z.ZodOptional<z.ZodString>;
11
+ nav: z.ZodOptional<z.ZodString>;
12
+ text: z.ZodOptional<z.ZodString>;
13
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>;
14
+ declare const colorsSchema: z.ZodObject<{
15
+ primary: z.ZodString;
16
+ secondary: z.ZodString;
17
+ accent: z.ZodString;
18
+ background: z.ZodString;
19
+ surface: z.ZodString;
20
+ text: z.ZodString;
21
+ textSecondary: z.ZodString;
22
+ }, z.core.$strip>;
23
+ type ThemeColors = z.infer<typeof colorsSchema>;
24
+ type ColorMode = 'light' | 'dark' | 'system';
25
+ declare const themeConfigSchema: z.ZodObject<{
26
+ id: z.ZodString;
27
+ name: z.ZodString;
28
+ description: z.ZodString;
29
+ colors: z.ZodObject<{
30
+ primary: z.ZodString;
31
+ secondary: z.ZodString;
32
+ accent: z.ZodString;
33
+ background: z.ZodString;
34
+ surface: z.ZodString;
35
+ text: z.ZodString;
36
+ textSecondary: z.ZodString;
37
+ }, z.core.$strip>;
38
+ darkColors: z.ZodOptional<z.ZodObject<{
39
+ primary: z.ZodString;
40
+ secondary: z.ZodString;
41
+ accent: z.ZodString;
42
+ background: z.ZodString;
43
+ surface: z.ZodString;
44
+ text: z.ZodString;
45
+ textSecondary: z.ZodString;
46
+ }, z.core.$strip>>;
47
+ backgroundImage: z.ZodOptional<z.ZodObject<{
48
+ url: z.ZodString;
49
+ repeat: z.ZodOptional<z.ZodEnum<{
50
+ repeat: "repeat";
51
+ "repeat-x": "repeat-x";
52
+ "repeat-y": "repeat-y";
53
+ "no-repeat": "no-repeat";
54
+ }>>;
55
+ size: z.ZodOptional<z.ZodString>;
56
+ position: z.ZodOptional<z.ZodString>;
57
+ attachment: z.ZodOptional<z.ZodEnum<{
58
+ scroll: "scroll";
59
+ fixed: "fixed";
60
+ local: "local";
61
+ }>>;
62
+ scale: z.ZodOptional<z.ZodNumber>;
63
+ animation: z.ZodOptional<z.ZodEnum<{
64
+ drift: "drift";
65
+ float: "float";
66
+ shimmer: "shimmer";
67
+ "shimmer-float": "shimmer-float";
68
+ none: "none";
69
+ }>>;
70
+ customAnimation: z.ZodOptional<z.ZodString>;
71
+ }, z.core.$strip>>;
72
+ typography: z.ZodObject<{
73
+ fontFamily: z.ZodObject<{
74
+ primary: z.ZodString;
75
+ secondary: z.ZodString;
76
+ }, z.core.$strip>;
77
+ scale: z.ZodObject<{
78
+ xs: z.ZodString;
79
+ sm: z.ZodString;
80
+ base: z.ZodString;
81
+ lg: z.ZodString;
82
+ xl: z.ZodString;
83
+ '2xl': z.ZodString;
84
+ '3xl': z.ZodString;
85
+ }, z.core.$strip>;
86
+ }, z.core.$strip>;
87
+ spacing: z.ZodObject<{
88
+ xs: z.ZodString;
89
+ sm: z.ZodString;
90
+ md: z.ZodString;
91
+ lg: z.ZodString;
92
+ xl: z.ZodString;
93
+ '2xl': z.ZodString;
94
+ }, z.core.$strip>;
95
+ components: z.ZodOptional<z.ZodObject<{
96
+ button: z.ZodOptional<z.ZodObject<{
97
+ base: z.ZodOptional<z.ZodString>;
98
+ primary: z.ZodOptional<z.ZodString>;
99
+ secondary: z.ZodOptional<z.ZodString>;
100
+ outline: z.ZodOptional<z.ZodString>;
101
+ shadow: z.ZodOptional<z.ZodString>;
102
+ nav: z.ZodOptional<z.ZodString>;
103
+ text: z.ZodOptional<z.ZodString>;
104
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
105
+ card: z.ZodOptional<z.ZodObject<{
106
+ base: z.ZodOptional<z.ZodString>;
107
+ primary: z.ZodOptional<z.ZodString>;
108
+ secondary: z.ZodOptional<z.ZodString>;
109
+ outline: z.ZodOptional<z.ZodString>;
110
+ shadow: z.ZodOptional<z.ZodString>;
111
+ nav: z.ZodOptional<z.ZodString>;
112
+ text: z.ZodOptional<z.ZodString>;
113
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
114
+ header: z.ZodOptional<z.ZodObject<{
115
+ base: z.ZodOptional<z.ZodString>;
116
+ primary: z.ZodOptional<z.ZodString>;
117
+ secondary: z.ZodOptional<z.ZodString>;
118
+ outline: z.ZodOptional<z.ZodString>;
119
+ shadow: z.ZodOptional<z.ZodString>;
120
+ nav: z.ZodOptional<z.ZodString>;
121
+ text: z.ZodOptional<z.ZodString>;
122
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
123
+ footer: z.ZodOptional<z.ZodObject<{
124
+ base: z.ZodOptional<z.ZodString>;
125
+ primary: z.ZodOptional<z.ZodString>;
126
+ secondary: z.ZodOptional<z.ZodString>;
127
+ outline: z.ZodOptional<z.ZodString>;
128
+ shadow: z.ZodOptional<z.ZodString>;
129
+ nav: z.ZodOptional<z.ZodString>;
130
+ text: z.ZodOptional<z.ZodString>;
131
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
132
+ }, z.core.$strip>>;
133
+ }, z.core.$strip>;
134
+ declare const themeSchema: z.ZodObject<{
135
+ id: z.ZodString;
136
+ name: z.ZodString;
137
+ description: z.ZodString;
138
+ colors: z.ZodObject<{
139
+ primary: z.ZodString;
140
+ secondary: z.ZodString;
141
+ accent: z.ZodString;
142
+ background: z.ZodString;
143
+ surface: z.ZodString;
144
+ text: z.ZodString;
145
+ textSecondary: z.ZodString;
146
+ }, z.core.$strip>;
147
+ darkColors: z.ZodOptional<z.ZodObject<{
148
+ primary: z.ZodString;
149
+ secondary: z.ZodString;
150
+ accent: z.ZodString;
151
+ background: z.ZodString;
152
+ surface: z.ZodString;
153
+ text: z.ZodString;
154
+ textSecondary: z.ZodString;
155
+ }, z.core.$strip>>;
156
+ backgroundImage: z.ZodOptional<z.ZodObject<{
157
+ url: z.ZodString;
158
+ repeat: z.ZodOptional<z.ZodEnum<{
159
+ repeat: "repeat";
160
+ "repeat-x": "repeat-x";
161
+ "repeat-y": "repeat-y";
162
+ "no-repeat": "no-repeat";
163
+ }>>;
164
+ size: z.ZodOptional<z.ZodString>;
165
+ position: z.ZodOptional<z.ZodString>;
166
+ attachment: z.ZodOptional<z.ZodEnum<{
167
+ scroll: "scroll";
168
+ fixed: "fixed";
169
+ local: "local";
170
+ }>>;
171
+ scale: z.ZodOptional<z.ZodNumber>;
172
+ animation: z.ZodOptional<z.ZodEnum<{
173
+ drift: "drift";
174
+ float: "float";
175
+ shimmer: "shimmer";
176
+ "shimmer-float": "shimmer-float";
177
+ none: "none";
178
+ }>>;
179
+ customAnimation: z.ZodOptional<z.ZodString>;
180
+ }, z.core.$strip>>;
181
+ typography: z.ZodObject<{
182
+ fontFamily: z.ZodObject<{
183
+ primary: z.ZodString;
184
+ secondary: z.ZodString;
185
+ }, z.core.$strip>;
186
+ scale: z.ZodObject<{
187
+ xs: z.ZodString;
188
+ sm: z.ZodString;
189
+ base: z.ZodString;
190
+ lg: z.ZodString;
191
+ xl: z.ZodString;
192
+ '2xl': z.ZodString;
193
+ '3xl': z.ZodString;
194
+ }, z.core.$strip>;
195
+ }, z.core.$strip>;
196
+ spacing: z.ZodObject<{
197
+ xs: z.ZodString;
198
+ sm: z.ZodString;
199
+ md: z.ZodString;
200
+ lg: z.ZodString;
201
+ xl: z.ZodString;
202
+ '2xl': z.ZodString;
203
+ }, z.core.$strip>;
204
+ components: z.ZodOptional<z.ZodObject<{
205
+ button: z.ZodOptional<z.ZodObject<{
206
+ base: z.ZodOptional<z.ZodString>;
207
+ primary: z.ZodOptional<z.ZodString>;
208
+ secondary: z.ZodOptional<z.ZodString>;
209
+ outline: z.ZodOptional<z.ZodString>;
210
+ shadow: z.ZodOptional<z.ZodString>;
211
+ nav: z.ZodOptional<z.ZodString>;
212
+ text: z.ZodOptional<z.ZodString>;
213
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
214
+ card: z.ZodOptional<z.ZodObject<{
215
+ base: z.ZodOptional<z.ZodString>;
216
+ primary: z.ZodOptional<z.ZodString>;
217
+ secondary: z.ZodOptional<z.ZodString>;
218
+ outline: z.ZodOptional<z.ZodString>;
219
+ shadow: z.ZodOptional<z.ZodString>;
220
+ nav: z.ZodOptional<z.ZodString>;
221
+ text: z.ZodOptional<z.ZodString>;
222
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
223
+ header: z.ZodOptional<z.ZodObject<{
224
+ base: z.ZodOptional<z.ZodString>;
225
+ primary: z.ZodOptional<z.ZodString>;
226
+ secondary: z.ZodOptional<z.ZodString>;
227
+ outline: z.ZodOptional<z.ZodString>;
228
+ shadow: z.ZodOptional<z.ZodString>;
229
+ nav: z.ZodOptional<z.ZodString>;
230
+ text: z.ZodOptional<z.ZodString>;
231
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
232
+ footer: z.ZodOptional<z.ZodObject<{
233
+ base: z.ZodOptional<z.ZodString>;
234
+ primary: z.ZodOptional<z.ZodString>;
235
+ secondary: z.ZodOptional<z.ZodString>;
236
+ outline: z.ZodOptional<z.ZodString>;
237
+ shadow: z.ZodOptional<z.ZodString>;
238
+ nav: z.ZodOptional<z.ZodString>;
239
+ text: z.ZodOptional<z.ZodString>;
240
+ }, z.core.$catchall<z.ZodOptional<z.ZodString>>>>;
241
+ }, z.core.$strip>>;
242
+ }, z.core.$strip>;
243
+ type ThemeConfig = z.infer<typeof themeConfigSchema>;
244
+ type ComponentStyle = z.infer<typeof componentStyleSchema>;
245
+ interface Theme extends ThemeConfig {
246
+ }
247
+
248
+ interface ThemeContextType {
249
+ /** The resolved theme — `colors` reflects the active color mode. */
250
+ theme: Theme;
251
+ /** The original theme with both `colors` and `darkColors` intact. */
252
+ rawTheme: Theme;
253
+ setTheme: (theme: Theme) => void;
254
+ /** Current color mode setting (`'light'`, `'dark'`, or `'system'`). */
255
+ colorMode: ColorMode;
256
+ /** Switch the color mode. */
257
+ setColorMode: (mode: ColorMode) => void;
258
+ /** The actually active mode after resolving `'system'`. */
259
+ resolvedColorMode: 'light' | 'dark';
260
+ }
261
+ interface ThemeProviderProps {
262
+ theme: Theme;
263
+ children: ReactNode;
264
+ /** Initial color mode. Defaults to `'system'`. */
265
+ initialColorMode?: ColorMode;
266
+ }
267
+ declare const ThemeProvider: React.FC<ThemeProviderProps>;
268
+ /**
269
+ * Access the current theme and color mode controls.
270
+ * Must be called inside a `<ThemeProvider>`.
271
+ */
272
+ declare const useTheme: () => ThemeContextType;
273
+ /**
274
+ * Like `useTheme`, but returns `undefined` instead of throwing when
275
+ * no `ThemeProvider` is present. Useful for optional-context components
276
+ * like `ThemeStyleInjector`.
277
+ */
278
+ declare const useThemeOptional: () => ThemeContextType | undefined;
279
+ /**
280
+ * Converts a Stackwright Theme to CSS custom properties.
281
+ * Inject these via ThemeStyleInjector or a `<style>` tag.
282
+ */
283
+ declare function themeToCSSVars(theme: Theme): Record<string, string>;
284
+ interface ThemeStyleInjectorProps {
285
+ /**
286
+ * Explicit theme override. When omitted the resolved theme from the
287
+ * nearest `ThemeProvider` is used automatically — this is the
288
+ * recommended approach so CSS vars stay in sync with color mode changes.
289
+ */
290
+ theme?: Theme;
291
+ children: ReactNode;
292
+ className?: string;
293
+ }
294
+ /**
295
+ * Wraps children in a div that injects Stackwright CSS custom properties.
296
+ * Place this inside a `<ThemeProvider>` and it will track color mode
297
+ * changes automatically.
298
+ */
299
+ declare function ThemeStyleInjector({ theme: themeProp, children, className, }: ThemeStyleInjectorProps): react_jsx_runtime.JSX.Element;
300
+
301
+ declare class ThemeLoader {
302
+ private static themes;
303
+ static loadThemeFromYaml(yamlContent: string): Theme;
304
+ static loadThemeFromFile(themeName: string): Theme;
305
+ static getTheme(name: string): Theme | undefined;
306
+ static getAllThemes(): Theme[];
307
+ static registerCustomTheme(theme: Theme): void;
308
+ static loadCustomTheme(theme: Theme): Theme;
309
+ private static getEmbeddedTheme;
310
+ }
311
+
312
+ /**
313
+ * Blocking script that reads the `sw-color-mode` cookie and applies the
314
+ * correct color mode attribute to `<html>` before React hydrates.
315
+ *
316
+ * Place this in `_document.tsx` `<Head>` (Pages Router) or in a `<script>`
317
+ * tag in `layout.tsx` (App Router). It must execute before the body is
318
+ * painted — intentionally render-blocking.
319
+ *
320
+ * The `data-sw-color-mode` attribute set by this script is read by
321
+ * `ThemeProvider`'s `systemPreference` initialiser, ensuring the first
322
+ * React render matches the visible state — no hydration mismatch.
323
+ *
324
+ * For return visitors (cookie exists): correct theme on first paint, zero flash.
325
+ * For first-time visitors with OS dark mode: one-frame flash (same as next-themes v0.2).
326
+ */
327
+ declare function ColorModeScript({ fallback }: {
328
+ fallback?: ColorMode;
329
+ }): react_jsx_runtime.JSX.Element;
330
+
331
+ export { type ColorMode, ColorModeScript, type ComponentStyle, type Theme, type ThemeColors, type ThemeColors as ThemeColorsType, type ThemeConfig, ThemeLoader, ThemeProvider, ThemeStyleInjector, colorsSchema, componentStyleSchema, themeConfigSchema, themeSchema, themeToCSSVars, useTheme, useThemeOptional };