@kilivi/payloadcms-theme-management 0.5.6 → 0.5.8
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/README.md +34 -38
- package/dist/components/InitTheme.d.ts +3 -0
- package/dist/components/InitTheme.d.ts.map +1 -1
- package/dist/components/InitTheme.js +9 -7
- package/dist/components/InitTheme.js.map +1 -1
- package/dist/components/ServerThemeInjector.d.ts.map +1 -1
- package/dist/components/ServerThemeInjector.js +1 -11
- package/dist/components/ServerThemeInjector.js.map +1 -1
- package/dist/components/ThemePreview.d.ts.map +1 -1
- package/dist/components/ThemePreview.js +3 -3
- package/dist/components/ThemePreview.js.map +1 -1
- package/dist/fields/ThemePresetImportField.d.ts +4 -0
- package/dist/fields/ThemePresetImportField.d.ts.map +1 -0
- package/dist/fields/ThemePresetImportField.js +219 -0
- package/dist/fields/ThemePresetImportField.js.map +1 -0
- package/dist/fields/ThemePreviewField.d.ts.map +1 -1
- package/dist/fields/ThemePreviewField.js +32 -25
- package/dist/fields/ThemePreviewField.js.map +1 -1
- package/dist/fields/themeConfigurationField.d.ts.map +1 -1
- package/dist/fields/themeConfigurationField.js +44 -10
- package/dist/fields/themeConfigurationField.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -4
- package/dist/index.js.map +1 -1
- package/dist/providers/Theme/themeConfig.d.ts.map +1 -1
- package/dist/providers/Theme/themeConfig.js +256 -8
- package/dist/providers/Theme/themeConfig.js.map +1 -1
- package/dist/providers/Theme/types.d.ts +5 -3
- package/dist/providers/Theme/types.d.ts.map +1 -1
- package/dist/providers/Theme/types.js +34 -13
- package/dist/providers/Theme/types.js.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/utils/customThemePresets.d.ts +5 -0
- package/dist/utils/customThemePresets.d.ts.map +1 -0
- package/dist/utils/customThemePresets.js +82 -0
- package/dist/utils/customThemePresets.js.map +1 -0
- package/dist/utils/extendedThemeHelpers.d.ts +1 -1
- package/dist/utils/extendedThemeHelpers.d.ts.map +1 -1
- package/dist/utils/extendedThemeHelpers.js +16 -16
- package/dist/utils/extendedThemeHelpers.js.map +1 -1
- package/dist/utils/generateThemeCSS.d.ts +11 -0
- package/dist/utils/generateThemeCSS.d.ts.map +1 -0
- package/dist/utils/generateThemeCSS.js +309 -0
- package/dist/utils/generateThemeCSS.js.map +1 -0
- package/dist/utils/resolveThemeConfiguration.d.ts +1 -1
- package/dist/utils/resolveThemeConfiguration.d.ts.map +1 -1
- package/dist/utils/resolveThemeConfiguration.js +3 -3
- package/dist/utils/resolveThemeConfiguration.js.map +1 -1
- package/dist/utils/themeAssets.d.ts +7 -0
- package/dist/utils/themeAssets.d.ts.map +1 -1
- package/dist/utils/themeAssets.js +23 -35
- package/dist/utils/themeAssets.js.map +1 -1
- package/dist/utils/themeCSS.d.ts +11 -0
- package/dist/utils/themeCSS.d.ts.map +1 -0
- package/dist/utils/themeCSS.js +32 -0
- package/dist/utils/themeCSS.js.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
import { borderRadiusPresets } from '../providers/Theme/themeConfig.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generates complete CSS for a theme preset
|
|
4
|
+
* Creates both light and dark mode CSS variables
|
|
5
|
+
*/ export function generateThemeCSS(preset) {
|
|
6
|
+
const { name, label, borderRadius, typography, lightMode, darkMode } = preset;
|
|
7
|
+
const rootLines = [];
|
|
8
|
+
const darkLines = [];
|
|
9
|
+
// Typography
|
|
10
|
+
const typographyPreset = typography ?? getDefaultTypography();
|
|
11
|
+
pushTypography(rootLines, typographyPreset);
|
|
12
|
+
// Layout (shared across themes)
|
|
13
|
+
pushLayoutDefaults(rootLines);
|
|
14
|
+
// Border radius based on preset definition
|
|
15
|
+
pushBorderRadius(rootLines, borderRadius);
|
|
16
|
+
// Component system defaults derived from colors
|
|
17
|
+
pushComponentDefaults(rootLines, lightMode);
|
|
18
|
+
// Light mode colours
|
|
19
|
+
pushColorTokens(rootLines, lightMode, 'light');
|
|
20
|
+
// Shared status colors (can be overridden later)
|
|
21
|
+
pushStatusColors(rootLines, 'light');
|
|
22
|
+
// Dark mode colors
|
|
23
|
+
pushColorTokens(darkLines, darkMode, 'dark');
|
|
24
|
+
pushStatusColors(darkLines, 'dark');
|
|
25
|
+
pushDarkModeComponentOverrides(darkLines, darkMode);
|
|
26
|
+
const sections = [];
|
|
27
|
+
sections.push(`/* ${label} Theme */`);
|
|
28
|
+
sections.push(buildCssBlock(`[data-theme='${name}']`, rootLines));
|
|
29
|
+
sections.push(`
|
|
30
|
+
/* ${label} Theme - Dark Mode */`);
|
|
31
|
+
sections.push(buildCssBlock(`[data-theme='${name}'][data-theme-mode='dark']`, darkLines));
|
|
32
|
+
return sections.join('\n').trim();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Convert HEX color to HSL format
|
|
36
|
+
* Example: #3b82f6 -> hsl(221, 83%, 53%)
|
|
37
|
+
*/ function hexToHsl(hex) {
|
|
38
|
+
let normalized = hex.trim();
|
|
39
|
+
if (!normalized.startsWith('#')) {
|
|
40
|
+
normalized = `#${normalized}`;
|
|
41
|
+
}
|
|
42
|
+
if (normalized.length === 4) {
|
|
43
|
+
normalized = `#${normalized[1]}${normalized[1]}${normalized[2]}${normalized[2]}${normalized[3]}${normalized[3]}`;
|
|
44
|
+
}
|
|
45
|
+
const r = parseInt(normalized.substring(1, 3), 16) / 255;
|
|
46
|
+
const g = parseInt(normalized.substring(3, 5), 16) / 255;
|
|
47
|
+
const b = parseInt(normalized.substring(5, 7), 16) / 255;
|
|
48
|
+
const max = Math.max(r, g, b);
|
|
49
|
+
const min = Math.min(r, g, b);
|
|
50
|
+
let h = 0;
|
|
51
|
+
let s = 0;
|
|
52
|
+
const l = (max + min) / 2;
|
|
53
|
+
if (max !== min) {
|
|
54
|
+
const d = max - min;
|
|
55
|
+
s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
|
|
56
|
+
switch(max){
|
|
57
|
+
case r:
|
|
58
|
+
h = ((g - b) / d + (g < b ? 6 : 0)) / 6;
|
|
59
|
+
break;
|
|
60
|
+
case g:
|
|
61
|
+
h = ((b - r) / d + 2) / 6;
|
|
62
|
+
break;
|
|
63
|
+
case b:
|
|
64
|
+
h = ((r - g) / d + 4) / 6;
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const hDeg = Math.round(h * 360);
|
|
69
|
+
const sPercent = Math.round(s * 100);
|
|
70
|
+
const lPercent = Math.round(l * 100);
|
|
71
|
+
return `hsl(${hDeg}, ${sPercent}%, ${lPercent}%)`;
|
|
72
|
+
}
|
|
73
|
+
function toCssColor(color) {
|
|
74
|
+
if (!color) return null;
|
|
75
|
+
const trimmed = color.trim();
|
|
76
|
+
if (/^var\(/i.test(trimmed) || /^hsl\(/i.test(trimmed) || /^rgb(a)?\(/i.test(trimmed)) {
|
|
77
|
+
return trimmed;
|
|
78
|
+
}
|
|
79
|
+
if (/^#?[0-9a-f]{6}$/i.test(trimmed) || /^#?[0-9a-f]{3}$/i.test(trimmed)) {
|
|
80
|
+
return hexToHsl(trimmed);
|
|
81
|
+
}
|
|
82
|
+
return trimmed;
|
|
83
|
+
}
|
|
84
|
+
function buildCssBlock(selector, lines) {
|
|
85
|
+
if (!lines.length) {
|
|
86
|
+
return `${selector} {}`;
|
|
87
|
+
}
|
|
88
|
+
const body = lines.map((line)=>line.startsWith('--') ? ` ${line}` : line).join('\n');
|
|
89
|
+
return `${selector} {\n${body}\n}`;
|
|
90
|
+
}
|
|
91
|
+
function pushTypography(lines, typography) {
|
|
92
|
+
const { fontFamily, headingFamily, baseFontSize, lineHeight, fontWeights = {}, letterSpacing = {} } = typography;
|
|
93
|
+
if (fontFamily) lines.push(`--typography-fontFamily: ${fontFamily};`);
|
|
94
|
+
if (headingFamily) lines.push(`--typography-headingFamily: ${headingFamily};`);
|
|
95
|
+
if (baseFontSize) lines.push(`--typography-baseFontSize: ${baseFontSize};`);
|
|
96
|
+
if (lineHeight) lines.push(`--typography-lineHeight: ${lineHeight};`);
|
|
97
|
+
Object.entries(fontWeights).forEach(([token, weight])=>{
|
|
98
|
+
if (weight) {
|
|
99
|
+
lines.push(`--typography-fontWeights-${token}: ${weight};`);
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
Object.entries(letterSpacing).forEach(([token, value])=>{
|
|
103
|
+
if (value) {
|
|
104
|
+
lines.push(`--typography-letterSpacing-${token}: ${value};`);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function pushLayoutDefaults(lines) {
|
|
109
|
+
lines.push('--layout-containerWidth: 1440px;');
|
|
110
|
+
lines.push('--layout-containerPadding: 1.5rem;');
|
|
111
|
+
lines.push('--layout-containerPaddingTablet: 2.5rem;');
|
|
112
|
+
lines.push('--layout-containerPaddingDesktop: 3rem;');
|
|
113
|
+
lines.push('--layout-sectionSpacing: 5rem;');
|
|
114
|
+
lines.push('--layout-sectionSpacingTablet: 7rem;');
|
|
115
|
+
lines.push('--layout-sectionSpacingDesktop: 9rem;');
|
|
116
|
+
lines.push('--layout-gridGap: 2rem;');
|
|
117
|
+
lines.push('--layout-gridGapTablet: 2.5rem;');
|
|
118
|
+
lines.push('--layout-gridGapDesktop: 3rem;');
|
|
119
|
+
}
|
|
120
|
+
function pushBorderRadius(lines, borderRadius) {
|
|
121
|
+
const presetKey = borderRadius ?? 'medium';
|
|
122
|
+
const preset = borderRadiusPresets[presetKey];
|
|
123
|
+
if (preset?.css) {
|
|
124
|
+
Object.entries(preset.css).forEach(([token, value])=>{
|
|
125
|
+
lines.push(`${token}: ${value};`);
|
|
126
|
+
});
|
|
127
|
+
const defaultRadius = preset.css['--radius-default'] ?? preset.css['--radius-medium'] ?? preset.css['--radius-large'] ?? preset.css['--radius'];
|
|
128
|
+
if (defaultRadius) {
|
|
129
|
+
lines.push(`--radius: ${defaultRadius};`);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function pushComponentDefaults(lines, lightMode) {
|
|
134
|
+
lines.push('--components-button-padding: 1rem 2.5rem;');
|
|
135
|
+
lines.push('--components-button-padding-large: 1.25rem 3rem;');
|
|
136
|
+
lines.push('--components-button-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);');
|
|
137
|
+
lines.push('--components-button-hover-scale: 1.02;');
|
|
138
|
+
lines.push('--components-button-hover-opacity: 0.9;');
|
|
139
|
+
lines.push('--components-button-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);');
|
|
140
|
+
lines.push('--components-button-hover-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);');
|
|
141
|
+
lines.push('--components-card-padding: 2.5rem;');
|
|
142
|
+
lines.push('--components-card-padding-compact: 1.5rem;');
|
|
143
|
+
lines.push('--components-card-shadow: 0 4px 16px -4px rgba(34, 42, 69, 0.12), 0 2px 8px -2px rgba(34, 42, 69, 0.08);');
|
|
144
|
+
lines.push('--components-card-hover-shadow: 0 12px 48px -12px rgba(34, 42, 69, 0.2), 0 8px 32px -8px rgba(34, 42, 69, 0.12);');
|
|
145
|
+
lines.push('--components-card-hover-transform: translateY(-8px) scale(1.02);');
|
|
146
|
+
const borderColor = toCssColor(lightMode?.border);
|
|
147
|
+
if (borderColor) {
|
|
148
|
+
lines.push(`--components-card-border: 1px solid ${borderColor};`);
|
|
149
|
+
lines.push(`--components-input-border: 1.5px solid ${borderColor};`);
|
|
150
|
+
}
|
|
151
|
+
const primaryColor = toCssColor(lightMode?.primary);
|
|
152
|
+
if (primaryColor) {
|
|
153
|
+
lines.push(`--components-input-focus-border: 2px solid ${primaryColor};`);
|
|
154
|
+
}
|
|
155
|
+
lines.push('--components-input-height: 3.5rem;');
|
|
156
|
+
lines.push('--components-input-padding: 1.25rem 1.75rem;');
|
|
157
|
+
}
|
|
158
|
+
const COLOR_TOKENS = [
|
|
159
|
+
{
|
|
160
|
+
key: 'background'
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
key: 'foreground'
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
key: 'card'
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
key: 'cardForeground'
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
key: 'popover'
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
key: 'popoverForeground'
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
key: 'primary',
|
|
179
|
+
wrapWithVar: true
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
key: 'primaryForeground'
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
key: 'secondary'
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
key: 'secondaryForeground'
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
key: 'muted'
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
key: 'mutedForeground'
|
|
195
|
+
},
|
|
196
|
+
{
|
|
197
|
+
key: 'accent',
|
|
198
|
+
wrapWithVar: true
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
key: 'accentForeground'
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
key: 'destructive'
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
key: 'destructiveForeground'
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
key: 'border'
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
key: 'input'
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
key: 'ring'
|
|
217
|
+
}
|
|
218
|
+
];
|
|
219
|
+
function pushColorTokens(lines, colors, mode) {
|
|
220
|
+
if (!colors) return;
|
|
221
|
+
COLOR_TOKENS.forEach(({ key, wrapWithVar })=>{
|
|
222
|
+
const value = toCssColor(colors[key]);
|
|
223
|
+
if (!value) return;
|
|
224
|
+
if (key === 'ring') {
|
|
225
|
+
lines.push('--ring: var(--primary);');
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
if (wrapWithVar) {
|
|
229
|
+
const customVar = key === 'accent' ? '--accent-custom' : '--primary-custom';
|
|
230
|
+
lines.push(`--${toKebab(key)}: var(${customVar}, ${value});`);
|
|
231
|
+
} else {
|
|
232
|
+
lines.push(`--${toKebab(key)}: ${value};`);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
if (mode === 'light') {
|
|
236
|
+
lines.push('--primary-hover: color-mix(in hsl, var(--primary), black 10%);');
|
|
237
|
+
lines.push('--secondary-hover: color-mix(in hsl, var(--secondary), black 10%);');
|
|
238
|
+
lines.push('--accent-hover: color-mix(in hsl, var(--accent), white 10%);');
|
|
239
|
+
} else {
|
|
240
|
+
lines.push('--primary-hover: color-mix(in hsl, var(--primary), white 10%);');
|
|
241
|
+
lines.push('--secondary-hover: color-mix(in hsl, var(--secondary), white 10%);');
|
|
242
|
+
lines.push('--accent-hover: color-mix(in hsl, var(--accent), white 10%);');
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function pushStatusColors(lines, mode) {
|
|
246
|
+
if (mode === 'light') {
|
|
247
|
+
lines.push('--success: hsl(120, 60%, 40%);');
|
|
248
|
+
lines.push('--success-foreground: hsl(0, 0%, 100%);');
|
|
249
|
+
lines.push('--warning: hsl(42, 85%, 55%);');
|
|
250
|
+
lines.push('--warning-foreground: hsl(25, 15%, 15%);');
|
|
251
|
+
lines.push('--error: hsl(0, 85%, 52%);');
|
|
252
|
+
lines.push('--error-foreground: hsl(0, 0%, 100%);');
|
|
253
|
+
lines.push('--info: var(--primary);');
|
|
254
|
+
lines.push('--info-foreground: var(--primary-foreground);');
|
|
255
|
+
} else {
|
|
256
|
+
lines.push('--success: hsl(120, 60%, 50%);');
|
|
257
|
+
lines.push('--success-foreground: hsl(0, 0%, 10%);');
|
|
258
|
+
lines.push('--warning: hsl(42, 85%, 55%);');
|
|
259
|
+
lines.push('--warning-foreground: hsl(0, 0%, 10%);');
|
|
260
|
+
lines.push('--error: hsl(0, 85%, 52%);');
|
|
261
|
+
lines.push('--error-foreground: hsl(0, 0%, 100%);');
|
|
262
|
+
lines.push('--info: var(--primary);');
|
|
263
|
+
lines.push('--info-foreground: var(--primary-foreground);');
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function pushDarkModeComponentOverrides(lines, darkMode) {
|
|
267
|
+
lines.push('--components-card-shadow: 0 8px 32px -8px rgba(0, 0, 0, 0.6), 0 4px 16px -4px rgba(0, 0, 0, 0.4);');
|
|
268
|
+
lines.push('--components-card-hover-shadow: 0 16px 64px -16px rgba(0, 0, 0, 0.8), 0 12px 40px -12px rgba(0, 0, 0, 0.6);');
|
|
269
|
+
const borderColor = toCssColor(darkMode?.border);
|
|
270
|
+
if (borderColor) {
|
|
271
|
+
lines.push(`--components-card-border: 1px solid ${borderColor};`);
|
|
272
|
+
}
|
|
273
|
+
const primaryColor = toCssColor(darkMode?.primary);
|
|
274
|
+
if (primaryColor) {
|
|
275
|
+
lines.push(`--components-input-focus-border: 2px solid ${primaryColor};`);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
function toKebab(token) {
|
|
279
|
+
return token.replace(/[A-Z]/g, (match)=>`-${match.toLowerCase()}`);
|
|
280
|
+
}
|
|
281
|
+
function getDefaultTypography() {
|
|
282
|
+
return {
|
|
283
|
+
fontFamily: 'var(--font-geist-sans)',
|
|
284
|
+
headingFamily: 'var(--font-outfit)',
|
|
285
|
+
baseFontSize: '16px',
|
|
286
|
+
lineHeight: '1.75',
|
|
287
|
+
fontWeights: {
|
|
288
|
+
light: '300',
|
|
289
|
+
normal: '400',
|
|
290
|
+
medium: '500',
|
|
291
|
+
semibold: '600',
|
|
292
|
+
bold: '700',
|
|
293
|
+
black: '900'
|
|
294
|
+
},
|
|
295
|
+
letterSpacing: {
|
|
296
|
+
tight: '-0.02em',
|
|
297
|
+
normal: '0',
|
|
298
|
+
wide: '0.025em',
|
|
299
|
+
wider: '0.05em'
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Generate CSS for all themes
|
|
305
|
+
*/ export function generateAllThemesCSS(presets) {
|
|
306
|
+
return presets.map((preset)=>generateThemeCSS(preset)).join('\n\n');
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
//# sourceMappingURL=generateThemeCSS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/generateThemeCSS.ts"],"sourcesContent":["import type { ThemePreset } from '../presets.js'\nimport { borderRadiusPresets } from '../providers/Theme/themeConfig.js'\n\n/**\n * Generates complete CSS for a theme preset\n * Creates both light and dark mode CSS variables\n */\nexport function generateThemeCSS(preset: ThemePreset): string {\n const { name, label, borderRadius, typography, lightMode, darkMode } = preset\n\n const rootLines: string[] = []\n const darkLines: string[] = []\n\n // Typography\n const typographyPreset = typography ?? getDefaultTypography()\n pushTypography(rootLines, typographyPreset)\n\n // Layout (shared across themes)\n pushLayoutDefaults(rootLines)\n\n // Border radius based on preset definition\n pushBorderRadius(rootLines, borderRadius)\n\n // Component system defaults derived from colors\n pushComponentDefaults(rootLines, lightMode)\n\n // Light mode colours\n pushColorTokens(rootLines, lightMode, 'light')\n\n // Shared status colors (can be overridden later)\n pushStatusColors(rootLines, 'light')\n\n // Dark mode colors\n pushColorTokens(darkLines, darkMode, 'dark')\n pushStatusColors(darkLines, 'dark')\n pushDarkModeComponentOverrides(darkLines, darkMode)\n\n const sections: string[] = []\n sections.push(`/* ${label} Theme */`)\n sections.push(buildCssBlock(`[data-theme='${name}']`, rootLines))\n\n sections.push(`\n/* ${label} Theme - Dark Mode */`)\n sections.push(buildCssBlock(`[data-theme='${name}'][data-theme-mode='dark']`, darkLines))\n\n return sections.join('\\n').trim()\n}\n\n/**\n * Convert HEX color to HSL format\n * Example: #3b82f6 -> hsl(221, 83%, 53%)\n */\nfunction hexToHsl(hex: string): string {\n let normalized = hex.trim()\n if (!normalized.startsWith('#')) {\n normalized = `#${normalized}`\n }\n\n if (normalized.length === 4) {\n normalized = `#${normalized[1]}${normalized[1]}${normalized[2]}${normalized[2]}${normalized[3]}${normalized[3]}`\n }\n\n const r = parseInt(normalized.substring(1, 3), 16) / 255\n const g = parseInt(normalized.substring(3, 5), 16) / 255\n const b = parseInt(normalized.substring(5, 7), 16) / 255\n\n const max = Math.max(r, g, b)\n const min = Math.min(r, g, b)\n let h = 0\n let s = 0\n const l = (max + min) / 2\n\n if (max !== min) {\n const d = max - min\n s = l > 0.5 ? d / (2 - max - min) : d / (max + min)\n\n switch (max) {\n case r:\n h = ((g - b) / d + (g < b ? 6 : 0)) / 6\n break\n case g:\n h = ((b - r) / d + 2) / 6\n break\n case b:\n h = ((r - g) / d + 4) / 6\n break\n }\n }\n\n const hDeg = Math.round(h * 360)\n const sPercent = Math.round(s * 100)\n const lPercent = Math.round(l * 100)\n\n return `hsl(${hDeg}, ${sPercent}%, ${lPercent}%)`\n}\n\nfunction toCssColor(color?: string | null): string | null {\n if (!color) return null\n const trimmed = color.trim()\n if (/^var\\(/i.test(trimmed) || /^hsl\\(/i.test(trimmed) || /^rgb(a)?\\(/i.test(trimmed)) {\n return trimmed\n }\n if (/^#?[0-9a-f]{6}$/i.test(trimmed) || /^#?[0-9a-f]{3}$/i.test(trimmed)) {\n return hexToHsl(trimmed)\n }\n return trimmed\n}\n\nfunction buildCssBlock(selector: string, lines: string[]): string {\n if (!lines.length) {\n return `${selector} {}`\n }\n\n const body = lines.map((line) => (line.startsWith('--') ? ` ${line}` : line)).join('\\n')\n return `${selector} {\\n${body}\\n}`\n}\n\nfunction pushTypography(lines: string[], typography: NonNullable<ThemePreset['typography']>): void {\n const {\n fontFamily,\n headingFamily,\n baseFontSize,\n lineHeight,\n fontWeights = {},\n letterSpacing = {},\n } = typography\n\n if (fontFamily) lines.push(`--typography-fontFamily: ${fontFamily};`)\n if (headingFamily) lines.push(`--typography-headingFamily: ${headingFamily};`)\n if (baseFontSize) lines.push(`--typography-baseFontSize: ${baseFontSize};`)\n if (lineHeight) lines.push(`--typography-lineHeight: ${lineHeight};`)\n\n Object.entries(fontWeights).forEach(([token, weight]) => {\n if (weight) {\n lines.push(`--typography-fontWeights-${token}: ${weight};`)\n }\n })\n\n Object.entries(letterSpacing).forEach(([token, value]) => {\n if (value) {\n lines.push(`--typography-letterSpacing-${token}: ${value};`)\n }\n })\n}\n\nfunction pushLayoutDefaults(lines: string[]): void {\n lines.push('--layout-containerWidth: 1440px;')\n lines.push('--layout-containerPadding: 1.5rem;')\n lines.push('--layout-containerPaddingTablet: 2.5rem;')\n lines.push('--layout-containerPaddingDesktop: 3rem;')\n lines.push('--layout-sectionSpacing: 5rem;')\n lines.push('--layout-sectionSpacingTablet: 7rem;')\n lines.push('--layout-sectionSpacingDesktop: 9rem;')\n lines.push('--layout-gridGap: 2rem;')\n lines.push('--layout-gridGapTablet: 2.5rem;')\n lines.push('--layout-gridGapDesktop: 3rem;')\n}\n\nfunction pushBorderRadius(lines: string[], borderRadius?: ThemePreset['borderRadius']): void {\n const presetKey = borderRadius ?? 'medium'\n const preset = borderRadiusPresets[presetKey]\n\n if (preset?.css) {\n Object.entries(preset.css).forEach(([token, value]) => {\n lines.push(`${token}: ${value};`)\n })\n\n const defaultRadius =\n preset.css['--radius-default'] ??\n preset.css['--radius-medium'] ??\n preset.css['--radius-large'] ??\n preset.css['--radius']\n\n if (defaultRadius) {\n lines.push(`--radius: ${defaultRadius};`)\n }\n }\n}\n\nfunction pushComponentDefaults(lines: string[], lightMode?: ThemePreset['lightMode']): void {\n lines.push('--components-button-padding: 1rem 2.5rem;')\n lines.push('--components-button-padding-large: 1.25rem 3rem;')\n lines.push('--components-button-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);')\n lines.push('--components-button-hover-scale: 1.02;')\n lines.push('--components-button-hover-opacity: 0.9;')\n lines.push('--components-button-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);')\n lines.push('--components-button-hover-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);')\n\n lines.push('--components-card-padding: 2.5rem;')\n lines.push('--components-card-padding-compact: 1.5rem;')\n lines.push(\n '--components-card-shadow: 0 4px 16px -4px rgba(34, 42, 69, 0.12), 0 2px 8px -2px rgba(34, 42, 69, 0.08);',\n )\n lines.push(\n '--components-card-hover-shadow: 0 12px 48px -12px rgba(34, 42, 69, 0.2), 0 8px 32px -8px rgba(34, 42, 69, 0.12);',\n )\n lines.push('--components-card-hover-transform: translateY(-8px) scale(1.02);')\n\n const borderColor = toCssColor(lightMode?.border)\n if (borderColor) {\n lines.push(`--components-card-border: 1px solid ${borderColor};`)\n lines.push(`--components-input-border: 1.5px solid ${borderColor};`)\n }\n\n const primaryColor = toCssColor(lightMode?.primary)\n if (primaryColor) {\n lines.push(`--components-input-focus-border: 2px solid ${primaryColor};`)\n }\n\n lines.push('--components-input-height: 3.5rem;')\n lines.push('--components-input-padding: 1.25rem 1.75rem;')\n}\n\nconst COLOR_TOKENS: Array<{\n key: keyof NonNullable<ThemePreset['lightMode']>\n wrapWithVar?: boolean\n}> = [\n { key: 'background' },\n { key: 'foreground' },\n { key: 'card' },\n { key: 'cardForeground' },\n { key: 'popover' },\n { key: 'popoverForeground' },\n { key: 'primary', wrapWithVar: true },\n { key: 'primaryForeground' },\n { key: 'secondary' },\n { key: 'secondaryForeground' },\n { key: 'muted' },\n { key: 'mutedForeground' },\n { key: 'accent', wrapWithVar: true },\n { key: 'accentForeground' },\n { key: 'destructive' },\n { key: 'destructiveForeground' },\n { key: 'border' },\n { key: 'input' },\n { key: 'ring' },\n]\n\nfunction pushColorTokens(\n lines: string[],\n colors: ThemePreset['lightMode'] | ThemePreset['darkMode'],\n mode: 'light' | 'dark',\n): void {\n if (!colors) return\n\n COLOR_TOKENS.forEach(({ key, wrapWithVar }) => {\n const value = toCssColor(colors[key])\n if (!value) return\n\n if (key === 'ring') {\n lines.push('--ring: var(--primary);')\n return\n }\n\n if (wrapWithVar) {\n const customVar = key === 'accent' ? '--accent-custom' : '--primary-custom'\n lines.push(`--${toKebab(key)}: var(${customVar}, ${value});`)\n } else {\n lines.push(`--${toKebab(key)}: ${value};`)\n }\n })\n\n if (mode === 'light') {\n lines.push('--primary-hover: color-mix(in hsl, var(--primary), black 10%);')\n lines.push('--secondary-hover: color-mix(in hsl, var(--secondary), black 10%);')\n lines.push('--accent-hover: color-mix(in hsl, var(--accent), white 10%);')\n } else {\n lines.push('--primary-hover: color-mix(in hsl, var(--primary), white 10%);')\n lines.push('--secondary-hover: color-mix(in hsl, var(--secondary), white 10%);')\n lines.push('--accent-hover: color-mix(in hsl, var(--accent), white 10%);')\n }\n}\n\nfunction pushStatusColors(lines: string[], mode: 'light' | 'dark'): void {\n if (mode === 'light') {\n lines.push('--success: hsl(120, 60%, 40%);')\n lines.push('--success-foreground: hsl(0, 0%, 100%);')\n lines.push('--warning: hsl(42, 85%, 55%);')\n lines.push('--warning-foreground: hsl(25, 15%, 15%);')\n lines.push('--error: hsl(0, 85%, 52%);')\n lines.push('--error-foreground: hsl(0, 0%, 100%);')\n lines.push('--info: var(--primary);')\n lines.push('--info-foreground: var(--primary-foreground);')\n } else {\n lines.push('--success: hsl(120, 60%, 50%);')\n lines.push('--success-foreground: hsl(0, 0%, 10%);')\n lines.push('--warning: hsl(42, 85%, 55%);')\n lines.push('--warning-foreground: hsl(0, 0%, 10%);')\n lines.push('--error: hsl(0, 85%, 52%);')\n lines.push('--error-foreground: hsl(0, 0%, 100%);')\n lines.push('--info: var(--primary);')\n lines.push('--info-foreground: var(--primary-foreground);')\n }\n}\n\nfunction pushDarkModeComponentOverrides(lines: string[], darkMode?: ThemePreset['darkMode']): void {\n lines.push(\n '--components-card-shadow: 0 8px 32px -8px rgba(0, 0, 0, 0.6), 0 4px 16px -4px rgba(0, 0, 0, 0.4);',\n )\n lines.push(\n '--components-card-hover-shadow: 0 16px 64px -16px rgba(0, 0, 0, 0.8), 0 12px 40px -12px rgba(0, 0, 0, 0.6);',\n )\n\n const borderColor = toCssColor(darkMode?.border)\n if (borderColor) {\n lines.push(`--components-card-border: 1px solid ${borderColor};`)\n }\n\n const primaryColor = toCssColor(darkMode?.primary)\n if (primaryColor) {\n lines.push(`--components-input-focus-border: 2px solid ${primaryColor};`)\n }\n}\n\nfunction toKebab(token: string): string {\n return token.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`)\n}\n\nfunction getDefaultTypography(): NonNullable<ThemePreset['typography']> {\n return {\n fontFamily: 'var(--font-geist-sans)',\n headingFamily: 'var(--font-outfit)',\n baseFontSize: '16px',\n lineHeight: '1.75',\n fontWeights: {\n light: '300',\n normal: '400',\n medium: '500',\n semibold: '600',\n bold: '700',\n black: '900',\n },\n letterSpacing: {\n tight: '-0.02em',\n normal: '0',\n wide: '0.025em',\n wider: '0.05em',\n },\n }\n}\n\n/**\n * Generate CSS for all themes\n */\nexport function generateAllThemesCSS(presets: ThemePreset[]): string {\n return presets.map((preset) => generateThemeCSS(preset)).join('\\n\\n')\n}\n"],"names":["borderRadiusPresets","generateThemeCSS","preset","name","label","borderRadius","typography","lightMode","darkMode","rootLines","darkLines","typographyPreset","getDefaultTypography","pushTypography","pushLayoutDefaults","pushBorderRadius","pushComponentDefaults","pushColorTokens","pushStatusColors","pushDarkModeComponentOverrides","sections","push","buildCssBlock","join","trim","hexToHsl","hex","normalized","startsWith","length","r","parseInt","substring","g","b","max","Math","min","h","s","l","d","hDeg","round","sPercent","lPercent","toCssColor","color","trimmed","test","selector","lines","body","map","line","fontFamily","headingFamily","baseFontSize","lineHeight","fontWeights","letterSpacing","Object","entries","forEach","token","weight","value","presetKey","css","defaultRadius","borderColor","border","primaryColor","primary","COLOR_TOKENS","key","wrapWithVar","colors","mode","customVar","toKebab","replace","match","toLowerCase","light","normal","medium","semibold","bold","black","tight","wide","wider","generateAllThemesCSS","presets"],"mappings":"AACA,SAASA,mBAAmB,QAAQ,oCAAmC;AAEvE;;;CAG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M9B,IAAI,CAAC;QACX8B,MAAM9B,IAAI,CAAC;QACX8B,MAAM9B,IAAI,CAAC;QACX8B,MAAM9B,IAAI,CAAC;IACb;AACF;AAEA,SAASF,+BAA+BgC,KAAe,EAAE3C,QAAkC;IACzF2C,MAAM9B,IAAI,CACR;IAEF8B,MAAM9B,IAAI,CACR;IAGF,MAAMiD,cAAcxB,WAAWtC,UAAU+D;IACzC,IAAID,aAAa;QACfnB,MAAM9B,IAAI,CAAC,CAAC,oCAAoC,EAAEiD,YAAY,CAAC,CAAC;IAClE;IAEA,MAAME,eAAe1B,WAAWtC,UAAUiE;IAC1C,IAAID,cAAc;QAChBrB,MAAM9B,IAAI,CAAC,CAAC,2CAA2C,EAAEmD,aAAa,CAAC,CAAC;IAC1E;AACF;AAEA,SAASQ,QAAQhB,KAAa;IAC5B,OAAOA,MAAMiB,OAAO,CAAC,UAAU,CAACC,QAAU,CAAC,CAAC,EAAEA,MAAMC,WAAW,IAAI;AACrE;AAEA,SAASvE;IACP,OAAO;QACL2C,YAAY;QACZC,eAAe;QACfC,cAAc;QACdC,YAAY;QACZC,aAAa;YACXyB,OAAO;YACPC,QAAQ;YACRC,QAAQ;YACRC,UAAU;YACVC,MAAM;YACNC,OAAO;QACT;QACA7B,eAAe;YACb8B,OAAO;YACPL,QAAQ;YACRM,MAAM;YACNC,OAAO;QACT;IACF;AACF;AAEA;;CAEC,GACD,OAAO,SAASC,qBAAqBC,OAAsB;IACzD,OAAOA,QAAQzC,GAAG,CAAC,CAACnD,SAAWD,iBAAiBC,SAASqB,IAAI,CAAC;AAChE"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Mode, ThemeDefaults } from '../providers/Theme/types.js';
|
|
2
1
|
import type { ThemeTypographyPreset } from '../presets.js';
|
|
2
|
+
import type { Mode, ThemeDefaults } from '../providers/Theme/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* Generic theme configuration structure that matches Payload's generated types
|
|
5
5
|
* without depending on specific payload-types versions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveThemeConfiguration.d.ts","sourceRoot":"","sources":["../../src/utils/resolveThemeConfiguration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"resolveThemeConfiguration.d.ts","sourceRoot":"","sources":["../../src/utils/resolveThemeConfiguration.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAE1D,OAAO,KAAK,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAGtE;;;GAGG;AACH,UAAU,uBAAuB;IAC/B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACjC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B;AAED;;;GAGG;AACH,UAAU,yBAAyB;IACjC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,oBAAoB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;IACrC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,SAAS,CAAC,EAAE;QACV,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;QACvB,SAAS,CAAC,EAAE,MAA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AAG,CAAC,OAAO,sBAAsB,CAAC,CAAC,MAAM,CAAC,CAAA;AAInE,KAAK,uBAAuB,GAAG,WAAW,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAC,CAAA;AAKlF,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,aAAa,CAAA;IACpB,SAAS,EAAE,IAAI,CAAA;IACf,oBAAoB,EAAE,OAAO,CAAA;IAC7B,YAAY,EAAE,kBAAkB,CAAA;IAChC,SAAS,EAAE,eAAe,CAAA;IAC1B,OAAO,EAAE,aAAa,CAAA;IACtB,cAAc,EAAE,oBAAoB,CAAA;IACpC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,SAAS,CAAC,EAAE,uBAAuB,CAAA;IACnC,QAAQ,CAAC,EAAE,uBAAuB,CAAA;IAClC,UAAU,EAAE,qBAAqB,GAAG,IAAI,CAAA;CACzC;AAED,eAAO,MAAM,2BAA2B,EAAE,0BAYzC,CAAA;AA4CD,wBAAgB,yBAAyB,CACvC,kBAAkB,CAAC,EAAE,yBAAyB,GAAG,IAAI,GACpD,0BAA0B,CA0D5B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FONT_VALUE_TO_CSS } from '../constants/themeFonts.js';
|
|
2
|
+
import { allThemePresets } from '../presets.js';
|
|
2
3
|
import { themeIsValid } from '../providers/Theme/types.js';
|
|
3
|
-
import { defaultThemePresets } from '../presets.js';
|
|
4
4
|
const BORDER_RADIUS_VALUES = [
|
|
5
5
|
'none',
|
|
6
6
|
'small',
|
|
@@ -36,7 +36,7 @@ const MODE_VALUES = [
|
|
|
36
36
|
'dark'
|
|
37
37
|
];
|
|
38
38
|
const DEFAULT_THEME_NAME = 'cool';
|
|
39
|
-
const DEFAULT_THEME_PRESET =
|
|
39
|
+
const DEFAULT_THEME_PRESET = allThemePresets.find((preset)=>preset.name === DEFAULT_THEME_NAME);
|
|
40
40
|
export const DEFAULT_THEME_CONFIGURATION = {
|
|
41
41
|
theme: DEFAULT_THEME_NAME,
|
|
42
42
|
colorMode: 'auto',
|
|
@@ -96,7 +96,7 @@ export function resolveThemeConfiguration(themeConfiguration) {
|
|
|
96
96
|
const resolvedAnimationLevel = resolveAnimationLevel(animationLevel);
|
|
97
97
|
const resolvedAllowToggle = typeof allowColorModeToggle === 'boolean' ? allowColorModeToggle : DEFAULT_THEME_CONFIGURATION.allowColorModeToggle;
|
|
98
98
|
const resolvedCustomCSS = typeof customCSS === 'string' ? customCSS : null;
|
|
99
|
-
const preset =
|
|
99
|
+
const preset = allThemePresets.find((candidate)=>candidate.name === resolvedTheme);
|
|
100
100
|
const baseLightMode = preset?.lightMode ?? DEFAULT_THEME_CONFIGURATION.lightMode;
|
|
101
101
|
const baseDarkMode = preset?.darkMode ?? DEFAULT_THEME_CONFIGURATION.darkMode;
|
|
102
102
|
const resolvedLightMode = mergeColorModes(baseLightMode, lightMode);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/resolveThemeConfiguration.ts"],"sourcesContent":["import { FONT_VALUE_TO_CSS } from '../constants/themeFonts.js'\nimport type { Mode, ThemeDefaults } from '../providers/Theme/types.js'\nimport { themeIsValid } from '../providers/Theme/types.js'\nimport type { ThemeTypographyPreset } from '../presets.js'\nimport { defaultThemePresets } from '../presets.js'\n\n/**\n * Generic theme configuration structure that matches Payload's generated types\n * without depending on specific payload-types versions\n */\ninterface ThemeTypographyOverride {\n bodyFont?: string | null\n headingFont?: string | null\n bodyFontCustom?: string | null\n headingFontCustom?: string | null\n baseFontSize?: string | null\n lineHeight?: string | null\n}\n\n/**\n * Generic theme configuration interface that accepts any compatible structure\n * This avoids type conflicts between different versions of payload-types\n */\ninterface GenericThemeConfiguration {\n theme?: string | null\n colorMode?: string | null\n allowColorModeToggle?: boolean | null\n borderRadius?: string | null\n fontScale?: string | null\n spacing?: string | null\n animationLevel?: string | null\n customCSS?: string | null\n lightMode?: {\n primary?: string | null\n secondary?: string | null\n accent?: string | null\n neutral?: string | null\n success?: string | null\n warning?: string | null\n error?: string | null\n info?: string | null\n } | null\n darkMode?: {\n primary?: string | null\n secondary?: string | null\n accent?: string | null\n neutral?: string | null\n success?: string | null\n warning?: string | null\n error?: string | null\n info?: string | null\n } | null\n typography?: ThemeTypographyOverride | null\n}\n\nconst BORDER_RADIUS_VALUES = ['none', 'small', 'medium', 'large', 'xl'] as const\nconst LEGACY_BORDER_RADIUS_ALIASES: Record<string, (typeof BORDER_RADIUS_VALUES)[number]> = {\n full: 'xl',\n}\nconst FONT_SCALE_VALUES = ['small', 'medium', 'large'] as const\nconst SPACING_VALUES = ['compact', 'medium', 'spacious'] as const\nconst ANIMATION_LEVEL_VALUES = ['none', 'reduced', 'medium', 'high'] as const\nconst LEGACY_ANIMATION_ALIASES: Record<string, (typeof ANIMATION_LEVEL_VALUES)[number]> = {\n full: 'high',\n}\nconst MODE_VALUES = ['auto', 'light', 'dark'] as const\n\ntype BorderRadiusOption = (typeof BORDER_RADIUS_VALUES)[number]\ntype FontScaleOption = (typeof FONT_SCALE_VALUES)[number]\ntype SpacingOption = (typeof SPACING_VALUES)[number]\ntype AnimationLevelOption = (typeof ANIMATION_LEVEL_VALUES)[number]\n\ntype ThemeModeOption = (typeof MODE_VALUES)[number]\n\ntype ThemeColorConfiguration = NonNullable<GenericThemeConfiguration['lightMode']>\n\nconst DEFAULT_THEME_NAME: ThemeDefaults = 'cool'\nconst DEFAULT_THEME_PRESET = defaultThemePresets.find(\n (preset) => preset.name === DEFAULT_THEME_NAME,\n)\n\nexport interface ResolvedThemeConfiguration {\n theme: ThemeDefaults\n colorMode: Mode\n allowColorModeToggle: boolean\n borderRadius: BorderRadiusOption\n fontScale: FontScaleOption\n spacing: SpacingOption\n animationLevel: AnimationLevelOption\n customCSS: string | null\n lightMode?: ThemeColorConfiguration\n darkMode?: ThemeColorConfiguration\n typography: ThemeTypographyPreset | null\n}\n\nexport const DEFAULT_THEME_CONFIGURATION: ResolvedThemeConfiguration = {\n theme: DEFAULT_THEME_NAME,\n colorMode: 'auto',\n allowColorModeToggle: true,\n borderRadius: 'medium',\n fontScale: 'medium',\n spacing: 'medium',\n animationLevel: 'medium',\n customCSS: null,\n lightMode: DEFAULT_THEME_PRESET?.lightMode,\n darkMode: DEFAULT_THEME_PRESET?.darkMode,\n typography: DEFAULT_THEME_PRESET?.typography ?? null,\n}\n\nfunction resolveBorderRadius(value: unknown): BorderRadiusOption {\n if (typeof value === 'string') {\n if (BORDER_RADIUS_VALUES.includes(value as BorderRadiusOption)) {\n return value as BorderRadiusOption\n }\n\n const legacyMatch = LEGACY_BORDER_RADIUS_ALIASES[value]\n if (legacyMatch) {\n return legacyMatch\n }\n }\n\n return DEFAULT_THEME_CONFIGURATION.borderRadius\n}\n\nfunction isFontScale(value: unknown): value is FontScaleOption {\n return typeof value === 'string' && FONT_SCALE_VALUES.includes(value as FontScaleOption)\n}\n\nfunction isSpacing(value: unknown): value is SpacingOption {\n return typeof value === 'string' && SPACING_VALUES.includes(value as SpacingOption)\n}\n\nfunction resolveAnimationLevel(value: unknown): AnimationLevelOption {\n if (typeof value === 'string') {\n if (ANIMATION_LEVEL_VALUES.includes(value as AnimationLevelOption)) {\n return value as AnimationLevelOption\n }\n\n const legacyMatch = LEGACY_ANIMATION_ALIASES[value]\n if (legacyMatch) {\n return legacyMatch\n }\n }\n\n return DEFAULT_THEME_CONFIGURATION.animationLevel\n}\n\nfunction isMode(value: unknown): value is ThemeModeOption {\n return typeof value === 'string' && MODE_VALUES.includes(value as ThemeModeOption)\n}\n\nexport function resolveThemeConfiguration(\n themeConfiguration?: GenericThemeConfiguration | null,\n): ResolvedThemeConfiguration {\n if (!themeConfiguration) {\n return DEFAULT_THEME_CONFIGURATION\n }\n\n const {\n theme,\n colorMode,\n allowColorModeToggle,\n borderRadius,\n fontScale,\n spacing,\n animationLevel,\n customCSS,\n lightMode,\n darkMode,\n typography,\n } = themeConfiguration\n\n const resolvedTheme =\n typeof theme === 'string' && themeIsValid(theme)\n ? (theme as ThemeDefaults)\n : DEFAULT_THEME_CONFIGURATION.theme\n const resolvedMode = isMode(colorMode)\n ? (colorMode as Mode)\n : DEFAULT_THEME_CONFIGURATION.colorMode\n const resolvedBorderRadius = resolveBorderRadius(borderRadius)\n const resolvedFontScale = isFontScale(fontScale)\n ? fontScale\n : DEFAULT_THEME_CONFIGURATION.fontScale\n const resolvedSpacing = isSpacing(spacing) ? spacing : DEFAULT_THEME_CONFIGURATION.spacing\n const resolvedAnimationLevel = resolveAnimationLevel(animationLevel)\n const resolvedAllowToggle =\n typeof allowColorModeToggle === 'boolean'\n ? allowColorModeToggle\n : DEFAULT_THEME_CONFIGURATION.allowColorModeToggle\n const resolvedCustomCSS = typeof customCSS === 'string' ? customCSS : null\n const preset = defaultThemePresets.find((candidate) => candidate.name === resolvedTheme)\n const baseLightMode = preset?.lightMode ?? DEFAULT_THEME_CONFIGURATION.lightMode\n const baseDarkMode = preset?.darkMode ?? DEFAULT_THEME_CONFIGURATION.darkMode\n const resolvedLightMode = mergeColorModes(baseLightMode, lightMode)\n const resolvedDarkMode = mergeColorModes(baseDarkMode, darkMode)\n const resolvedTypography =\n mergeTypography(preset?.typography, typography) ?? preset?.typography ?? null\n\n return {\n theme: resolvedTheme,\n colorMode: resolvedMode,\n allowColorModeToggle: resolvedAllowToggle,\n borderRadius: resolvedBorderRadius,\n fontScale: resolvedFontScale,\n spacing: resolvedSpacing,\n animationLevel: resolvedAnimationLevel,\n customCSS: resolvedCustomCSS,\n lightMode: resolvedLightMode,\n darkMode: resolvedDarkMode,\n typography: resolvedTypography,\n }\n}\n\nfunction mergeColorModes(\n base?: ThemeColorConfiguration,\n overrides?: GenericThemeConfiguration['lightMode'],\n): ThemeColorConfiguration | undefined {\n const merged: Record<string, string> = {}\n\n if (base) {\n Object.entries(base).forEach(([key, value]) => {\n if (typeof value === 'string' && value.trim().length > 0) {\n merged[key] = value\n }\n })\n }\n\n if (overrides) {\n Object.entries(overrides).forEach(([key, value]) => {\n if (typeof value === 'string' && value.trim().length > 0) {\n merged[key] = value\n } else if (value === null) {\n delete merged[key]\n }\n })\n }\n\n return Object.keys(merged).length > 0 ? (merged as ThemeColorConfiguration) : undefined\n}\n\nfunction mergeTypography(\n base?: ThemeTypographyPreset | null,\n overrides?: ThemeTypographyOverride | null,\n): ThemeTypographyPreset | null {\n if (!base && !overrides) {\n return base ?? null\n }\n\n const result: ThemeTypographyPreset = {\n fontFamily: base?.fontFamily ?? 'var(--font-geist-sans)',\n headingFamily: base?.headingFamily ?? 'var(--font-geist-sans)',\n baseFontSize: base?.baseFontSize ?? '16px',\n lineHeight: base?.lineHeight ?? '1.6',\n fontWeights: { ...(base?.fontWeights ?? {}) },\n letterSpacing: { ...(base?.letterSpacing ?? {}) },\n }\n\n if (overrides) {\n const resolvedBodyFont = resolveFontSelection(\n overrides.bodyFont,\n overrides.bodyFontCustom,\n base?.fontFamily,\n )\n if (resolvedBodyFont) {\n result.fontFamily = resolvedBodyFont\n }\n\n const resolvedHeadingFont = resolveFontSelection(\n overrides.headingFont,\n overrides.headingFontCustom,\n base?.headingFamily,\n )\n if (resolvedHeadingFont) {\n result.headingFamily = resolvedHeadingFont\n }\n\n if (overrides.baseFontSize && overrides.baseFontSize !== 'preset') {\n result.baseFontSize = overrides.baseFontSize\n }\n\n if (overrides.lineHeight && overrides.lineHeight !== 'preset') {\n result.lineHeight = overrides.lineHeight\n }\n }\n\n return result\n}\n\nfunction resolveFontSelection(\n selection?: string | null,\n custom?: string | null,\n fallback?: string | null,\n): string | null {\n if (!selection || selection === 'preset') {\n return fallback ?? null\n }\n\n if (selection === 'custom') {\n const trimmed = custom?.trim()\n return trimmed && trimmed.length > 0 ? trimmed : (fallback ?? null)\n }\n\n const mapped = FONT_VALUE_TO_CSS[selection]\n return mapped ?? fallback ?? null\n}\n"],"names":["FONT_VALUE_TO_CSS","themeIsValid","defaultThemePresets","BORDER_RADIUS_VALUES","LEGACY_BORDER_RADIUS_ALIASES","full","FONT_SCALE_VALUES","SPACING_VALUES","ANIMATION_LEVEL_VALUES","LEGACY_ANIMATION_ALIASES","MODE_VALUES","DEFAULT_THEME_NAME","DEFAULT_THEME_PRESET","find","preset","name","DEFAULT_THEME_CONFIGURATION","theme","colorMode","allowColorModeToggle","borderRadius","fontScale","spacing","animationLevel","customCSS","lightMode","darkMode","typography","resolveBorderRadius","value","includes","legacyMatch","isFontScale","isSpacing","resolveAnimationLevel","isMode","resolveThemeConfiguration","themeConfiguration","resolvedTheme","resolvedMode","resolvedBorderRadius","resolvedFontScale","resolvedSpacing","resolvedAnimationLevel","resolvedAllowToggle","resolvedCustomCSS","candidate","baseLightMode","baseDarkMode","resolvedLightMode","mergeColorModes","resolvedDarkMode","resolvedTypography","mergeTypography","base","overrides","merged","Object","entries","forEach","key","trim","length","keys","undefined","result","fontFamily","headingFamily","baseFontSize","lineHeight","fontWeights","letterSpacing","resolvedBodyFont","resolveFontSelection","bodyFont","bodyFontCustom","resolvedHeadingFont","headingFont","headingFontCustom","selection","custom","fallback","trimmed","mapped"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,6BAA4B;AAE9D,SAASC,YAAY,QAAQ,8BAA6B;AAE1D,SAASC,mBAAmB,QAAQ,gBAAe;AAmDnD,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;IAAU;IAAS;CAAK;AACvE,MAAMC,+BAAsF;IAC1FC,MAAM;AACR;AACA,MAAMC,oBAAoB;IAAC;IAAS;IAAU;CAAQ;AACtD,MAAMC,iBAAiB;IAAC;IAAW;IAAU;CAAW;AACxD,MAAMC,yBAAyB;IAAC;IAAQ;IAAW;IAAU;CAAO;AACpE,MAAMC,2BAAoF;IACxFJ,MAAM;AACR;AACA,MAAMK,cAAc;IAAC;IAAQ;IAAS;CAAO;AAW7C,MAAMC,qBAAoC;AAC1C,MAAMC,uBAAuBV,oBAAoBW,IAAI,CACnD,CAACC,SAAWA,OAAOC,IAAI,KAAKJ;AAiB9B,OAAO,MAAMK,8BAA0D;IACrEC,OAAON;IACPO,WAAW;IACXC,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ACT;AAEA,SAASQ,qBACPM,SAAyB,EACzBC,MAAsB,EACtBC,QAAwB;IAExB,IAAI,CAACF,aAAaA,cAAc,UAAU;QACxC,OAAOE,YAAY;IACrB;IAEA,IAAIF,cAAc,UAAU;QAC1B,MAAMG,UAAUF,QAAQnB;QACxB,OAAOqB,WAAWA,QAAQpB,MAAM,GAAG,IAAIoB,UAAWD,YAAY;IAChE;IAEA,MAAME,SAASnF,iBAAiB,CAAC+E,UAAU;IAC3C,OAAOI,UAAUF,YAAY;AAC/B"}
|
|
1
|
+
{"version":3,"sources":["../../src/utils/resolveThemeConfiguration.ts"],"sourcesContent":["import { FONT_VALUE_TO_CSS } from '../constants/themeFonts.js'\nimport type { ThemeTypographyPreset } from '../presets.js'\nimport { allThemePresets } from '../presets.js'\nimport type { Mode, ThemeDefaults } from '../providers/Theme/types.js'\nimport { themeIsValid } from '../providers/Theme/types.js'\n\n/**\n * Generic theme configuration structure that matches Payload's generated types\n * without depending on specific payload-types versions\n */\ninterface ThemeTypographyOverride {\n bodyFont?: string | null\n headingFont?: string | null\n bodyFontCustom?: string | null\n headingFontCustom?: string | null\n baseFontSize?: string | null\n lineHeight?: string | null\n}\n\n/**\n * Generic theme configuration interface that accepts any compatible structure\n * This avoids type conflicts between different versions of payload-types\n */\ninterface GenericThemeConfiguration {\n theme?: string | null\n colorMode?: string | null\n allowColorModeToggle?: boolean | null\n borderRadius?: string | null\n fontScale?: string | null\n spacing?: string | null\n animationLevel?: string | null\n customCSS?: string | null\n lightMode?: {\n primary?: string | null\n secondary?: string | null\n accent?: string | null\n neutral?: string | null\n success?: string | null\n warning?: string | null\n error?: string | null\n info?: string | null\n } | null\n darkMode?: {\n primary?: string | null\n secondary?: string | null\n accent?: string | null\n neutral?: string | null\n success?: string | null\n warning?: string | null\n error?: string | null\n info?: string | null\n } | null\n typography?: ThemeTypographyOverride | null\n}\n\nconst BORDER_RADIUS_VALUES = ['none', 'small', 'medium', 'large', 'xl'] as const\nconst LEGACY_BORDER_RADIUS_ALIASES: Record<string, (typeof BORDER_RADIUS_VALUES)[number]> = {\n full: 'xl',\n}\nconst FONT_SCALE_VALUES = ['small', 'medium', 'large'] as const\nconst SPACING_VALUES = ['compact', 'medium', 'spacious'] as const\nconst ANIMATION_LEVEL_VALUES = ['none', 'reduced', 'medium', 'high'] as const\nconst LEGACY_ANIMATION_ALIASES: Record<string, (typeof ANIMATION_LEVEL_VALUES)[number]> = {\n full: 'high',\n}\nconst MODE_VALUES = ['auto', 'light', 'dark'] as const\n\ntype BorderRadiusOption = (typeof BORDER_RADIUS_VALUES)[number]\ntype FontScaleOption = (typeof FONT_SCALE_VALUES)[number]\ntype SpacingOption = (typeof SPACING_VALUES)[number]\ntype AnimationLevelOption = (typeof ANIMATION_LEVEL_VALUES)[number]\n\ntype ThemeModeOption = (typeof MODE_VALUES)[number]\n\ntype ThemeColorConfiguration = NonNullable<GenericThemeConfiguration['lightMode']>\n\nconst DEFAULT_THEME_NAME: ThemeDefaults = 'cool'\nconst DEFAULT_THEME_PRESET = allThemePresets.find((preset) => preset.name === DEFAULT_THEME_NAME)\n\nexport interface ResolvedThemeConfiguration {\n theme: ThemeDefaults\n colorMode: Mode\n allowColorModeToggle: boolean\n borderRadius: BorderRadiusOption\n fontScale: FontScaleOption\n spacing: SpacingOption\n animationLevel: AnimationLevelOption\n customCSS: string | null\n lightMode?: ThemeColorConfiguration\n darkMode?: ThemeColorConfiguration\n typography: ThemeTypographyPreset | null\n}\n\nexport const DEFAULT_THEME_CONFIGURATION: ResolvedThemeConfiguration = {\n theme: DEFAULT_THEME_NAME,\n colorMode: 'auto',\n allowColorModeToggle: true,\n borderRadius: 'medium',\n fontScale: 'medium',\n spacing: 'medium',\n animationLevel: 'medium',\n customCSS: null,\n lightMode: DEFAULT_THEME_PRESET?.lightMode,\n darkMode: DEFAULT_THEME_PRESET?.darkMode,\n typography: DEFAULT_THEME_PRESET?.typography ?? null,\n}\n\nfunction resolveBorderRadius(value: unknown): BorderRadiusOption {\n if (typeof value === 'string') {\n if (BORDER_RADIUS_VALUES.includes(value as BorderRadiusOption)) {\n return value as BorderRadiusOption\n }\n\n const legacyMatch = LEGACY_BORDER_RADIUS_ALIASES[value]\n if (legacyMatch) {\n return legacyMatch\n }\n }\n\n return DEFAULT_THEME_CONFIGURATION.borderRadius\n}\n\nfunction isFontScale(value: unknown): value is FontScaleOption {\n return typeof value === 'string' && FONT_SCALE_VALUES.includes(value as FontScaleOption)\n}\n\nfunction isSpacing(value: unknown): value is SpacingOption {\n return typeof value === 'string' && SPACING_VALUES.includes(value as SpacingOption)\n}\n\nfunction resolveAnimationLevel(value: unknown): AnimationLevelOption {\n if (typeof value === 'string') {\n if (ANIMATION_LEVEL_VALUES.includes(value as AnimationLevelOption)) {\n return value as AnimationLevelOption\n }\n\n const legacyMatch = LEGACY_ANIMATION_ALIASES[value]\n if (legacyMatch) {\n return legacyMatch\n }\n }\n\n return DEFAULT_THEME_CONFIGURATION.animationLevel\n}\n\nfunction isMode(value: unknown): value is ThemeModeOption {\n return typeof value === 'string' && MODE_VALUES.includes(value as ThemeModeOption)\n}\n\nexport function resolveThemeConfiguration(\n themeConfiguration?: GenericThemeConfiguration | null,\n): ResolvedThemeConfiguration {\n if (!themeConfiguration) {\n return DEFAULT_THEME_CONFIGURATION\n }\n\n const {\n theme,\n colorMode,\n allowColorModeToggle,\n borderRadius,\n fontScale,\n spacing,\n animationLevel,\n customCSS,\n lightMode,\n darkMode,\n typography,\n } = themeConfiguration\n\n const resolvedTheme =\n typeof theme === 'string' && themeIsValid(theme)\n ? (theme as ThemeDefaults)\n : DEFAULT_THEME_CONFIGURATION.theme\n const resolvedMode = isMode(colorMode)\n ? (colorMode as Mode)\n : DEFAULT_THEME_CONFIGURATION.colorMode\n const resolvedBorderRadius = resolveBorderRadius(borderRadius)\n const resolvedFontScale = isFontScale(fontScale)\n ? fontScale\n : DEFAULT_THEME_CONFIGURATION.fontScale\n const resolvedSpacing = isSpacing(spacing) ? spacing : DEFAULT_THEME_CONFIGURATION.spacing\n const resolvedAnimationLevel = resolveAnimationLevel(animationLevel)\n const resolvedAllowToggle =\n typeof allowColorModeToggle === 'boolean'\n ? allowColorModeToggle\n : DEFAULT_THEME_CONFIGURATION.allowColorModeToggle\n const resolvedCustomCSS = typeof customCSS === 'string' ? customCSS : null\n const preset = allThemePresets.find((candidate) => candidate.name === resolvedTheme)\n const baseLightMode = preset?.lightMode ?? DEFAULT_THEME_CONFIGURATION.lightMode\n const baseDarkMode = preset?.darkMode ?? DEFAULT_THEME_CONFIGURATION.darkMode\n const resolvedLightMode = mergeColorModes(baseLightMode, lightMode)\n const resolvedDarkMode = mergeColorModes(baseDarkMode, darkMode)\n const resolvedTypography =\n mergeTypography(preset?.typography, typography) ?? preset?.typography ?? null\n\n return {\n theme: resolvedTheme,\n colorMode: resolvedMode,\n allowColorModeToggle: resolvedAllowToggle,\n borderRadius: resolvedBorderRadius,\n fontScale: resolvedFontScale,\n spacing: resolvedSpacing,\n animationLevel: resolvedAnimationLevel,\n customCSS: resolvedCustomCSS,\n lightMode: resolvedLightMode,\n darkMode: resolvedDarkMode,\n typography: resolvedTypography,\n }\n}\n\nfunction mergeColorModes(\n base?: ThemeColorConfiguration,\n overrides?: GenericThemeConfiguration['lightMode'],\n): ThemeColorConfiguration | undefined {\n const merged: Record<string, string> = {}\n\n if (base) {\n Object.entries(base).forEach(([key, value]) => {\n if (typeof value === 'string' && value.trim().length > 0) {\n merged[key] = value\n }\n })\n }\n\n if (overrides) {\n Object.entries(overrides).forEach(([key, value]) => {\n if (typeof value === 'string' && value.trim().length > 0) {\n merged[key] = value\n } else if (value === null) {\n delete merged[key]\n }\n })\n }\n\n return Object.keys(merged).length > 0 ? (merged as ThemeColorConfiguration) : undefined\n}\n\nfunction mergeTypography(\n base?: ThemeTypographyPreset | null,\n overrides?: ThemeTypographyOverride | null,\n): ThemeTypographyPreset | null {\n if (!base && !overrides) {\n return base ?? null\n }\n\n const result: ThemeTypographyPreset = {\n fontFamily: base?.fontFamily ?? 'var(--font-geist-sans)',\n headingFamily: base?.headingFamily ?? 'var(--font-geist-sans)',\n baseFontSize: base?.baseFontSize ?? '16px',\n lineHeight: base?.lineHeight ?? '1.6',\n fontWeights: { ...(base?.fontWeights ?? {}) },\n letterSpacing: { ...(base?.letterSpacing ?? {}) },\n }\n\n if (overrides) {\n const resolvedBodyFont = resolveFontSelection(\n overrides.bodyFont,\n overrides.bodyFontCustom,\n base?.fontFamily,\n )\n if (resolvedBodyFont) {\n result.fontFamily = resolvedBodyFont\n }\n\n const resolvedHeadingFont = resolveFontSelection(\n overrides.headingFont,\n overrides.headingFontCustom,\n base?.headingFamily,\n )\n if (resolvedHeadingFont) {\n result.headingFamily = resolvedHeadingFont\n }\n\n if (overrides.baseFontSize && overrides.baseFontSize !== 'preset') {\n result.baseFontSize = overrides.baseFontSize\n }\n\n if (overrides.lineHeight && overrides.lineHeight !== 'preset') {\n result.lineHeight = overrides.lineHeight\n }\n }\n\n return result\n}\n\nfunction resolveFontSelection(\n selection?: string | null,\n custom?: string | null,\n fallback?: string | null,\n): string | null {\n if (!selection || selection === 'preset') {\n return fallback ?? null\n }\n\n if (selection === 'custom') {\n const trimmed = custom?.trim()\n return trimmed && trimmed.length > 0 ? trimmed : (fallback ?? null)\n }\n\n const mapped = FONT_VALUE_TO_CSS[selection]\n return mapped ?? fallback ?? null\n}\n"],"names":["FONT_VALUE_TO_CSS","allThemePresets","themeIsValid","BORDER_RADIUS_VALUES","LEGACY_BORDER_RADIUS_ALIASES","full","FONT_SCALE_VALUES","SPACING_VALUES","ANIMATION_LEVEL_VALUES","LEGACY_ANIMATION_ALIASES","MODE_VALUES","DEFAULT_THEME_NAME","DEFAULT_THEME_PRESET","find","preset","name","DEFAULT_THEME_CONFIGURATION","theme","colorMode","allowColorModeToggle","borderRadius","fontScale","spacing","animationLevel","customCSS","lightMode","darkMode","typography","resolveBorderRadius","value","includes","legacyMatch","isFontScale","isSpacing","resolveAnimationLevel","isMode","resolveThemeConfiguration","themeConfiguration","resolvedTheme","resolvedMode","resolvedBorderRadius","resolvedFontScale","resolvedSpacing","resolvedAnimationLevel","resolvedAllowToggle","resolvedCustomCSS","candidate","baseLightMode","baseDarkMode","resolvedLightMode","mergeColorModes","resolvedDarkMode","resolvedTypography","mergeTypography","base","overrides","merged","Object","entries","forEach","key","trim","length","keys","undefined","result","fontFamily","headingFamily","baseFontSize","lineHeight","fontWeights","letterSpacing","resolvedBodyFont","resolveFontSelection","bodyFont","bodyFontCustom","resolvedHeadingFont","headingFont","headingFontCustom","selection","custom","fallback","trimmed","mapped"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,6BAA4B;AAE9D,SAASC,eAAe,QAAQ,gBAAe;AAE/C,SAASC,YAAY,QAAQ,8BAA6B;AAmD1D,MAAMC,uBAAuB;IAAC;IAAQ;IAAS;IAAU;IAAS;CAAK;AACvE,MAAMC,+BAAsF;IAC1FC,MAAM;AACR;AACA,MAAMC,oBAAoB;IAAC;IAAS;IAAU;CAAQ;AACtD,MAAMC,iBAAiB;IAAC;IAAW;IAAU;CAAW;AACxD,MAAMC,yBAAyB;IAAC;IAAQ;IAAW;IAAU;CAAO;AACpE,MAAMC,2BAAoF;IACxFJ,MAAM;AACR;AACA,MAAMK,cAAc;IAAC;IAAQ;IAAS;CAAO;AAW7C,MAAMC,qBAAoC;AAC1C,MAAMC,uBAAuBX,gBAAgBY,IAAI,CAAC,CAACC,SAAWA,OAAOC,IAAI,KAAKJ;AAgB9E,OAAO,MAAMK,8BAA0D;IACrEC,OAAON;IACPO,WAAW;IACXC,sBAAsB;IACtBC,cAAc;IACdC,WAAW;IACXC,SAAS;IACTC,gBAAgB;IAChBC,WAAW;IACXC,WAAWb,sBAAsBa;IACjCC,UAAUd,sBAAsBc;IAChCC,YAAYf,sBAAsBe,cAAc;AAClD,EAAC;AAED,SAASC,oBAAoBC,KAAc;IACzC,IAAI,OAAOA,UAAU,UAAU;QAC7B,IAAI1B,qBAAqB2B,QAAQ,CAACD,QAA8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AAiB,CAAC+E,UAAU;IAC3C,OAAOI,UAAUF,YAAY;AAC/B"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { ThemeDefaults } from '../providers/Theme/types.js';
|
|
2
2
|
export declare function getThemeCriticalCSS(theme: ThemeDefaults): Promise<string | null>;
|
|
3
|
+
export declare function getThemeCSS(theme: ThemeDefaults): string | null;
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Static CSS files have been removed. This function now returns an empty string.
|
|
6
|
+
*/
|
|
3
7
|
export declare function getThemeCSSPath(theme: ThemeDefaults): string;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated Preload links are no longer required when CSS is inlined dynamically.
|
|
10
|
+
*/
|
|
4
11
|
export declare function generateThemePreloadLinks(theme: ThemeDefaults): string;
|
|
5
12
|
export declare function createFallbackCriticalCSS(theme: ThemeDefaults): string;
|
|
6
13
|
//# sourceMappingURL=themeAssets.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"themeAssets.d.ts","sourceRoot":"","sources":["../../src/utils/themeAssets.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"themeAssets.d.ts","sourceRoot":"","sources":["../../src/utils/themeAssets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAOhE,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAYtF;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAG/D;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAK5D;AAED;;GAEG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAKtE;AAED,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAmBtE"}
|
|
@@ -1,47 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
brutal: 'brutal-critical.css',
|
|
6
|
-
neon: 'neon-critical.css',
|
|
7
|
-
solar: 'solar-critical.css',
|
|
8
|
-
dealership: 'dealership-critical.css',
|
|
9
|
-
'real-estate': 'real-estate-critical.css',
|
|
10
|
-
'real-estate-gold': 'real-estate-gold-critical.css',
|
|
11
|
-
'real-estate-neutral': 'real-estate-neutral-critical.css'
|
|
12
|
-
};
|
|
13
|
-
const themeFullFiles = {
|
|
14
|
-
cool: 'cool.css',
|
|
15
|
-
brutal: 'brutal.css',
|
|
16
|
-
neon: 'neon.css',
|
|
17
|
-
solar: 'solar.css',
|
|
18
|
-
dealership: 'dealership.css',
|
|
19
|
-
'real-estate': 'real-estate.css',
|
|
20
|
-
'real-estate-gold': 'real-estate-gold.css',
|
|
21
|
-
'real-estate-neutral': 'real-estate-neutral.css'
|
|
22
|
-
};
|
|
1
|
+
import { getThemeDynamicCSS } from './themeCSS.js';
|
|
2
|
+
function normaliseCss(css) {
|
|
3
|
+
return css.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
4
|
+
}
|
|
23
5
|
export async function getThemeCriticalCSS(theme) {
|
|
24
6
|
try {
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
27
|
-
console.warn(`
|
|
7
|
+
const css = getThemeDynamicCSS(theme);
|
|
8
|
+
if (!css) {
|
|
9
|
+
console.warn(`Dynamic CSS could not be generated for theme: ${theme}`);
|
|
28
10
|
return null;
|
|
29
11
|
}
|
|
30
|
-
|
|
31
|
-
const css = await readFile(filePath, 'utf-8');
|
|
32
|
-
return css.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
12
|
+
return normaliseCss(css);
|
|
33
13
|
} catch (error) {
|
|
34
|
-
console.error(`Error
|
|
14
|
+
console.error(`Error generating critical CSS for theme ${theme}:`, error);
|
|
35
15
|
return null;
|
|
36
16
|
}
|
|
37
17
|
}
|
|
38
|
-
export function
|
|
39
|
-
const
|
|
40
|
-
return
|
|
18
|
+
export function getThemeCSS(theme) {
|
|
19
|
+
const css = getThemeDynamicCSS(theme);
|
|
20
|
+
return css ? normaliseCss(css) : null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Static CSS files have been removed. This function now returns an empty string.
|
|
24
|
+
*/ export function getThemeCSSPath(theme) {
|
|
25
|
+
console.warn(`[theme-management] getThemeCSSPath(${theme}) is deprecated. Dynamic CSS generation is used instead.`);
|
|
26
|
+
return '';
|
|
41
27
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
/**
|
|
29
|
+
* @deprecated Preload links are no longer required when CSS is inlined dynamically.
|
|
30
|
+
*/ export function generateThemePreloadLinks(theme) {
|
|
31
|
+
console.warn(`[theme-management] generateThemePreloadLinks(${theme}) is deprecated. Dynamic CSS generation is used instead.`);
|
|
32
|
+
return '';
|
|
45
33
|
}
|
|
46
34
|
export function createFallbackCriticalCSS(theme) {
|
|
47
35
|
return `
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils/themeAssets.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../src/utils/themeAssets.ts"],"sourcesContent":["import type { ThemeDefaults } from '../providers/Theme/types.js'\nimport { getThemeDynamicCSS } from './themeCSS.js'\n\nfunction normaliseCss(css: string): string {\n return css.replace(/\\r\\n/g, '\\n').replace(/\\r/g, '\\n')\n}\n\nexport async function getThemeCriticalCSS(theme: ThemeDefaults): Promise<string | null> {\n try {\n const css = getThemeDynamicCSS(theme)\n if (!css) {\n console.warn(`Dynamic CSS could not be generated for theme: ${theme}`)\n return null\n }\n return normaliseCss(css)\n } catch (error) {\n console.error(`Error generating critical CSS for theme ${theme}:`, error)\n return null\n }\n}\n\nexport function getThemeCSS(theme: ThemeDefaults): string | null {\n const css = getThemeDynamicCSS(theme)\n return css ? normaliseCss(css) : null\n}\n\n/**\n * @deprecated Static CSS files have been removed. This function now returns an empty string.\n */\nexport function getThemeCSSPath(theme: ThemeDefaults): string {\n console.warn(\n `[theme-management] getThemeCSSPath(${theme}) is deprecated. Dynamic CSS generation is used instead.`,\n )\n return ''\n}\n\n/**\n * @deprecated Preload links are no longer required when CSS is inlined dynamically.\n */\nexport function generateThemePreloadLinks(theme: ThemeDefaults): string {\n console.warn(\n `[theme-management] generateThemePreloadLinks(${theme}) is deprecated. Dynamic CSS generation is used instead.`,\n )\n return ''\n}\n\nexport function createFallbackCriticalCSS(theme: ThemeDefaults): string {\n return `\n/* Fallback critical CSS for ${theme} theme */\n[data-theme=\"${theme}\"] {\n --background: hsl(0 0% 100%);\n --foreground: hsl(222 47% 11%);\n --primary: hsl(221 83% 53%);\n --primary-foreground: hsl(210 40% 98%);\n color-scheme: light;\n}\n\n[data-theme=\"${theme}\"][data-theme-mode=\"dark\"] {\n --background: hsl(222 47% 11%);\n --foreground: hsl(210 40% 98%);\n --primary: hsl(217 91% 60%);\n --primary-foreground: hsl(222 47% 11%);\n color-scheme: dark;\n}\n`.trim()\n}\n"],"names":["getThemeDynamicCSS","normaliseCss","css","replace","getThemeCriticalCSS","theme","console","warn","error","getThemeCSS","getThemeCSSPath","generateThemePreloadLinks","createFallbackCriticalCSS","trim"],"mappings":"AACA,SAASA,kBAAkB,QAAQ,gBAAe;AAElD,SAASC,aAAaC,GAAW;IAC/B,OAAOA,IAAIC,OAAO,CAAC,SAAS,MAAMA,OAAO,CAAC,OAAO;AACnD;AAEA,OAAO,eAAeC,oBAAoBC,KAAoB;IAC5D,IAAI;QACF,MAAMH,MAAMF,mBAAmBK;QAC/B,IAAI,CAACH,KAAK;YACRI,QAAQC,IAAI,CAAC,CAAC,8CAA8C,EAAEF,OAAO;YACrE,OAAO;QACT;QACA,OAAOJ,aAAaC;IACtB,EAAE,OAAOM,OAAO;QACdF,QAAQE,KAAK,CAAC,CAAC,wCAAwC,EAAEH,MAAM,CAAC,CAAC,EAAEG;QACnE,OAAO;IACT;AACF;AAEA,OAAO,SAASC,YAAYJ,KAAoB;IAC9C,MAAMH,MAAMF,mBAAmBK;IAC/B,OAAOH,MAAMD,aAAaC,OAAO;AACnC;AAEA;;CAEC,GACD,OAAO,SAASQ,gBAAgBL,KAAoB;IAClDC,QAAQC,IAAI,CACV,CAAC,mCAAmC,EAAEF,MAAM,wDAAwD,CAAC;IAEvG,OAAO;AACT;AAEA;;CAEC,GACD,OAAO,SAASM,0BAA0BN,KAAoB;IAC5DC,QAAQC,IAAI,CACV,CAAC,6CAA6C,EAAEF,MAAM,wDAAwD,CAAC;IAEjH,OAAO;AACT;AAEA,OAAO,SAASO,0BAA0BP,KAAoB;IAC5D,OAAO,CAAC;6BACmB,EAAEA,MAAM;aACxB,EAAEA,MAAM;;;;;;;;aAQR,EAAEA,MAAM;;;;;;;AAOrB,CAAC,CAACQ,IAAI;AACN"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ThemeDefaults } from '../providers/Theme/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Get dynamically generated CSS for a theme
|
|
4
|
+
* Returns null if theme doesn't exist or doesn't use dynamic CSS
|
|
5
|
+
*/
|
|
6
|
+
export declare function getThemeDynamicCSS(themeName: ThemeDefaults): string | null;
|
|
7
|
+
/**
|
|
8
|
+
* Get CSS for all themes that use dynamic generation
|
|
9
|
+
*/
|
|
10
|
+
export declare function getAllDynamicThemesCSS(): string;
|
|
11
|
+
//# sourceMappingURL=themeCSS.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themeCSS.d.ts","sourceRoot":"","sources":["../../src/utils/themeCSS.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAA;AAGhE;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,aAAa,GAAG,MAAM,GAAG,IAAI,CAc1E;AAED;;GAEG;AACH,wBAAgB,sBAAsB,IAAI,MAAM,CAY/C"}
|