@venix-sistemas/jade 1.2.0 → 1.4.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.
Files changed (66) hide show
  1. package/README.md +969 -579
  2. package/dist/module.d.mts +8 -1
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +131 -9
  5. package/dist/runtime/components/VenixThemeSwitcher.d.vue.ts +7 -1
  6. package/dist/runtime/components/VenixThemeSwitcher.vue +679 -161
  7. package/dist/runtime/components/VenixThemeSwitcher.vue.d.ts +7 -1
  8. package/dist/runtime/composables/useThemeColors.d.ts +2 -2
  9. package/dist/runtime/composables/useThemeCookies.d.ts +12 -4
  10. package/dist/runtime/composables/useThemeCookies.js +20 -1
  11. package/dist/runtime/composables/useThemeLocale.d.ts +2 -2
  12. package/dist/runtime/composables/useThemeSeasonal.d.ts +2 -2
  13. package/dist/runtime/composables/useVenixTheme.d.ts +32 -0
  14. package/dist/runtime/composables/useVenixTheme.js +153 -9
  15. package/dist/runtime/plugins/overlay-scrollbars.client.d.ts +2 -0
  16. package/dist/runtime/plugins/overlay-scrollbars.client.js +89 -0
  17. package/dist/runtime/plugins/theme-init.server.d.ts +1 -1
  18. package/dist/runtime/plugins/vuetify-theme.d.ts +1 -1
  19. package/dist/runtime/scripts/theme-init.d.ts +12 -3
  20. package/dist/runtime/scripts/theme-init.js +21 -4
  21. package/dist/shared/constants.d.ts +55 -1
  22. package/dist/shared/constants.js +23 -1
  23. package/dist/shared/css/colors.d.ts +2 -2
  24. package/dist/shared/css/colors.js +7 -2
  25. package/dist/shared/css/cursor-svg.d.ts +10 -0
  26. package/dist/shared/css/cursor-svg.js +28 -0
  27. package/dist/shared/css/cursor.js +146 -37
  28. package/dist/shared/css/index.js +1 -1
  29. package/dist/shared/css/scrollbar.js +68 -8
  30. package/dist/shared/css/tokens.d.ts +40 -0
  31. package/dist/shared/css/tokens.js +119 -0
  32. package/dist/shared/css/typography.js +13 -0
  33. package/dist/shared/theme.json +320 -302
  34. package/dist/shared/token-names.d.ts +37 -0
  35. package/dist/shared/token-names.js +53 -0
  36. package/dist/shared/types/color-options.d.ts +23 -2
  37. package/dist/shared/types/colors.d.ts +38 -0
  38. package/dist/shared/types/cursor.d.ts +34 -4
  39. package/dist/shared/types/experimental.d.ts +19 -0
  40. package/dist/shared/types/experimental.js +0 -0
  41. package/dist/shared/types/index.d.ts +5 -3
  42. package/dist/shared/types/runtime-config.d.ts +39 -24
  43. package/dist/shared/types/scrollbar.d.ts +11 -0
  44. package/dist/shared/types/theme.d.ts +7 -0
  45. package/dist/shared/types/typography.d.ts +2 -1
  46. package/dist/shared/unocss-preset.d.ts +27 -1
  47. package/dist/shared/unocss-preset.js +20 -2
  48. package/dist/shared/utils/contrast.d.ts +11 -0
  49. package/dist/shared/utils/contrast.js +24 -0
  50. package/dist/shared/utils/index.d.ts +3 -2
  51. package/dist/shared/utils/index.js +3 -2
  52. package/dist/shared/utils/load.d.ts +2 -2
  53. package/dist/shared/utils/load.js +2 -1
  54. package/dist/shared/utils/merge-themes.d.ts +8 -0
  55. package/dist/shared/utils/merge-themes.js +25 -3
  56. package/dist/shared/utils/oklab.d.ts +21 -0
  57. package/dist/shared/utils/oklab.js +74 -0
  58. package/dist/shared/utils/scale.d.ts +53 -0
  59. package/dist/shared/utils/scale.js +164 -0
  60. package/dist/shared/utils/theme-config.d.ts +11 -3
  61. package/dist/shared/utils/theme-config.js +10 -2
  62. package/dist/shared/utils/theme-resolve.d.ts +11 -2
  63. package/dist/shared/utils/theme-resolve.js +18 -0
  64. package/dist/shared/utils/theme-resolver.d.ts +1 -0
  65. package/dist/shared/utils/theme-resolver.js +1 -0
  66. package/package.json +24 -9
@@ -0,0 +1,21 @@
1
+ /** `#RRGGBB`, uppercase. Accepts `#RGB` too. */
2
+ export declare function normalizeHex(hex: string): string;
3
+ export declare function hexToOklab(hex: string): [number, number, number];
4
+ /** The hex for an OKLab color, or `null` when it falls outside the sRGB gamut. */
5
+ export declare function oklabToHex(L: number, a: number, b: number): string | null;
6
+ /** CIELAB lightness (L*, 0–100) of a hex color. */
7
+ export declare function lightnessOf(hex: string): number;
8
+ /** OKLab chroma of a color: how far it is from a gray of the same lightness (about 0–0.4). */
9
+ export declare function chromaOf(hex: string): number;
10
+ /**
11
+ * The color at OKLab lightness `L` that has the hue of `hueOf` and, as far as
12
+ * the sRGB gamut allows, `chroma`: a chroma that doesn't fit is lowered until
13
+ * it does. `null` when `hueOf` has no hue (a gray).
14
+ */
15
+ export declare function colorWithHue(L: number, hueOf: string, chroma: number): string | null;
16
+ /**
17
+ * The background nudged toward the hue of `hueSeed`: the strongest tint that
18
+ * stays inside the sRGB gamut and within `MAX_TINT_DRIFT` of the background.
19
+ * Returns the background itself when no tint fits (e.g. pure white or black).
20
+ */
21
+ export declare function tintToward(background: string, hueSeed: string): string;
@@ -0,0 +1,74 @@
1
+ import { contrastRatio, relativeLuminance } from "./contrast.js";
2
+ function parseHex(hex) {
3
+ let digits = hex.trim().replace(/^#/, "");
4
+ if (digits.length === 3) digits = digits.replace(/./g, "$&$&");
5
+ if (!/^[\da-f]{6}$/i.test(digits)) throw new Error(`[jade] Invalid hex color: "${hex}"`);
6
+ return [0, 2, 4].map((i) => Number.parseInt(digits.slice(i, i + 2), 16));
7
+ }
8
+ function toLinear(channel) {
9
+ const c = channel / 255;
10
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
11
+ }
12
+ function fromLinear(linear) {
13
+ const c = linear <= 31308e-7 ? linear * 12.92 : 1.055 * linear ** (1 / 2.4) - 0.055;
14
+ return Math.round(Math.min(1, Math.max(0, c)) * 255);
15
+ }
16
+ export function normalizeHex(hex) {
17
+ return `#${parseHex(hex).map((c) => c.toString(16).padStart(2, "0")).join("").toUpperCase()}`;
18
+ }
19
+ export function hexToOklab(hex) {
20
+ const [r, g, b] = parseHex(hex).map(toLinear);
21
+ const l = Math.cbrt(0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b);
22
+ const m = Math.cbrt(0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b);
23
+ const s = Math.cbrt(0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b);
24
+ return [
25
+ 0.2104542553 * l + 0.793617785 * m - 0.0040720468 * s,
26
+ 1.9779984951 * l - 2.428592205 * m + 0.4505937099 * s,
27
+ 0.0259040371 * l + 0.7827717662 * m - 0.808675766 * s
28
+ ];
29
+ }
30
+ export function oklabToHex(L, a, b) {
31
+ const l = (L + 0.3963377774 * a + 0.2158037573 * b) ** 3;
32
+ const m = (L - 0.1055613458 * a - 0.0638541728 * b) ** 3;
33
+ const s = (L - 0.0894841775 * a - 1.291485548 * b) ** 3;
34
+ const linear = [
35
+ 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
36
+ -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
37
+ -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s
38
+ ];
39
+ if (linear.some((c) => c < -5e-4 || c > 1.0005)) return null;
40
+ return `#${linear.map((c) => fromLinear(c).toString(16).padStart(2, "0")).join("").toUpperCase()}`;
41
+ }
42
+ export function lightnessOf(hex) {
43
+ const y = relativeLuminance(hex);
44
+ const f = y > 216 / 24389 ? Math.cbrt(y) : (24389 / 27 * y + 16) / 116;
45
+ return 116 * f - 16;
46
+ }
47
+ export function chromaOf(hex) {
48
+ const [, a, b] = hexToOklab(hex);
49
+ return Math.hypot(a, b);
50
+ }
51
+ export function colorWithHue(L, hueOf, chroma) {
52
+ const [, a, b] = hexToOklab(hueOf);
53
+ const own = Math.hypot(a, b);
54
+ if (own < 1e-4) return null;
55
+ for (let c = chroma; c > 5e-4; c *= 0.9) {
56
+ const candidate = oklabToHex(L, a / own * c, b / own * c);
57
+ if (candidate) return candidate;
58
+ }
59
+ return oklabToHex(L, 0, 0);
60
+ }
61
+ const TINT_CHROMAS = [0.012, 0.01, 8e-3, 6e-3, 4e-3, 3e-3, 2e-3, 1e-3];
62
+ const MAX_TINT_DRIFT = 1.02;
63
+ export function tintToward(background, hueSeed) {
64
+ const base = normalizeHex(background);
65
+ const [L] = hexToOklab(base);
66
+ const [, a, b] = hexToOklab(hueSeed);
67
+ const chroma = Math.hypot(a, b);
68
+ if (chroma < 1e-4) return base;
69
+ for (const c of TINT_CHROMAS) {
70
+ const candidate = oklabToHex(L, a / chroma * c, b / chroma * c);
71
+ if (candidate && contrastRatio(candidate, base) <= MAX_TINT_DRIFT) return candidate;
72
+ }
73
+ return base;
74
+ }
@@ -0,0 +1,53 @@
1
+ import type { ContrastLevel, ThemeMode } from '../types/index.js';
2
+ /**
3
+ * Build-time color scales for the semantic tokens (v1.4.0, experimental).
4
+ *
5
+ * A scale has 12 steps, defined by their contrast ratio against the theme's
6
+ * background (not by fixed lightness), so the same ratios work in light and
7
+ * dark mode. Importing this file pulls in the color engine: use it only at
8
+ * build time (module setup), never from `src/runtime/`.
9
+ */
10
+ export type { ContrastLevel };
11
+ export interface RoleScale {
12
+ /** The 12 steps, light to strong, as `#RRGGBB`. Step 9 (index 8) is the seed. */
13
+ steps: string[];
14
+ /** Text and icon color on steps 9 and 10: white or black, whichever contrasts more. */
15
+ on: '#FFFFFF' | '#000000';
16
+ }
17
+ export interface GeneratedScales {
18
+ /** The neutral scale; step 1 (index 0) is exactly the background. */
19
+ neutral: string[];
20
+ roles: Record<string, RoleScale>;
21
+ }
22
+ /**
23
+ * The neutral scale: the theme's background and 11 steps leaning toward the
24
+ * hue of `tintSeed` (usually the primary), or plain grays when it is `null`.
25
+ * Step 1 is exactly `background`.
26
+ * A background that has a color of its own (a peach `#FFF8F0`) is not pulled
27
+ * toward the seed: its own hue is kept, and the surfaces and borders (steps
28
+ * 2–8) get more of it the farther they sit from the page, as a hand-made
29
+ * palette would, so a card doesn't look grayer than the page behind it.
30
+ * Step 9 (outline) reaches 3:1 on steps 1–2 and step 11 (muted text) reaches
31
+ * the level on steps 1–3; step 12 is main text.
32
+ */
33
+ export declare function generateNeutralScale(background: string, tintSeed: string | null, mode: ThemeMode, level?: ContrastLevel): string[];
34
+ /**
35
+ * A role's 12 steps, generated against the neutral scale it sits on.
36
+ *
37
+ * - Step 9 is the seed itself (the engine only gets close to it).
38
+ * - `on` is white or black, whichever contrasts more with the seed.
39
+ * - Step 10 (hover) moves away from `on`: lighter when `on` is black, darker
40
+ * when it's white, so the text on it never loses contrast.
41
+ * - Steps 11 and 12 (colored and strong colored text) reach the level over
42
+ * the surfaces they sit on: neutral steps 1–3 and this role's step 3 for 11,
43
+ * this role's steps 4–5 for 12.
44
+ */
45
+ export declare function generateScale(seed: string, neutral: string[], mode: ThemeMode, level?: ContrastLevel): RoleScale;
46
+ /**
47
+ * The neutral scale and one scale per role, for one theme variant.
48
+ * `seeds` maps each role (`primary`, `secondary`…) to its seed color; the
49
+ * neutral scale leans toward the first one unless `options.tint` is `false`.
50
+ */
51
+ export declare function generateScales(background: string, seeds: Record<string, string>, mode: ThemeMode, level?: ContrastLevel, options?: {
52
+ tint?: boolean;
53
+ }): GeneratedScales;
@@ -0,0 +1,164 @@
1
+ import { BackgroundColor, Color, Theme } from "@adobe/leonardo-contrast-colors";
2
+ import { contrastRatio, relativeLuminance } from "./contrast.js";
3
+ import { chromaOf, colorWithHue, hexToOklab, lightnessOf, normalizeHex, tintToward } from "./oklab.js";
4
+ const NEUTRAL_RATIOS = [1, 1.05, 1.12, 1.2, 1.3, 1.5, 1.8, 2.3, 3, 3.5, 4.5, 12];
5
+ const ROLE_RATIOS = [1.05, 1.12, 1.2, 1.3, 1.5, 1.8, 2.3, 3];
6
+ const STEP_GAP = 0.01;
7
+ const SEED_GAP = 0.1;
8
+ const HOVER_FACTOR = 1.12;
9
+ const TEXT_FACTOR = 1.15;
10
+ const STRONG_TEXT_FACTOR = 1.4;
11
+ const MAX_RATIO = 15;
12
+ const OUTLINE_TARGET = 3;
13
+ const NUDGE = 1.01;
14
+ const MAX_NUDGES = 8;
15
+ const TARGETS = {
16
+ AA: { text: 4.5, strongText: 7 },
17
+ AAA: { text: 7, strongText: 10 }
18
+ };
19
+ const ENGINE_NOISE = "`colorspace` is deprecated";
20
+ function withoutEngineNoise(run) {
21
+ const warn = console.warn;
22
+ console.warn = (...args) => {
23
+ if (typeof args[0] === "string" && args[0].includes(ENGINE_NOISE)) return;
24
+ warn(...args);
25
+ };
26
+ try {
27
+ return run();
28
+ } finally {
29
+ console.warn = warn;
30
+ }
31
+ }
32
+ function generateSteps(key, background, mode, ratios) {
33
+ const generated = withoutEngineNoise(() => runEngine(key, background, ratios));
34
+ const steps = generated.map(normalizeHex);
35
+ if (steps.length !== ratios.length) {
36
+ throw new Error(`[jade] The color engine returned ${steps.length} steps for ${ratios.length} ratios (${mode} mode, key ${key}).`);
37
+ }
38
+ return steps;
39
+ }
40
+ function runEngine(key, background, ratios) {
41
+ const bg = new BackgroundColor({ name: "background", colorKeys: [background], ratios: [1], colorSpace: "OKLCH" });
42
+ const color = new Color({ name: "scale", colorKeys: [key], ratios, colorSpace: "OKLCH", smooth: true });
43
+ const theme = new Theme({
44
+ colors: [bg, color],
45
+ backgroundColor: bg,
46
+ lightness: Math.round(lightnessOf(background)),
47
+ contrast: 1,
48
+ output: "HEX"
49
+ });
50
+ const generated = theme.contrastColors.at(-1);
51
+ return generated.values.map((v) => v.value);
52
+ }
53
+ function isGray(hex) {
54
+ return hex.slice(1, 3) === hex.slice(3, 5) && hex.slice(3, 5) === hex.slice(5, 7);
55
+ }
56
+ function grayWithLuminanceOf(hex) {
57
+ const y = relativeLuminance(hex);
58
+ const encoded = y <= 31308e-7 ? y * 12.92 : 1.055 * y ** (1 / 2.4) - 0.055;
59
+ const channel = Math.round(Math.min(1, Math.max(0, encoded)) * 255).toString(16).padStart(2, "0").toUpperCase();
60
+ return `#${channel}${channel}${channel}`;
61
+ }
62
+ function worstContrast(text, surfaces) {
63
+ return Math.min(...surfaces.map((surface) => contrastRatio(text, surface)));
64
+ }
65
+ function reachTarget(ratio, target, surfaces, place) {
66
+ let current = Math.min(ratio, MAX_RATIO);
67
+ let color = place(current);
68
+ for (let i = 0; i < MAX_NUDGES && current < MAX_RATIO; i++) {
69
+ const worst = worstContrast(color, surfaces);
70
+ if (worst >= target) break;
71
+ current = Math.min(MAX_RATIO, current * (target / worst) * NUDGE);
72
+ color = place(current);
73
+ }
74
+ return { ratio: current, color };
75
+ }
76
+ const THEMED_BACKGROUND_CHROMA = 4e-3;
77
+ const SURFACE_CHROMA_GROWTH = 6;
78
+ const SURFACE_MAX_GROWTH = 3;
79
+ const SURFACE_MAX_CHROMA = 0.04;
80
+ const SURFACE_LIGHTNESS_RANGE = 0.03;
81
+ function enrichSurface(step, background, ratio, ownChroma) {
82
+ const growth = Math.min(SURFACE_MAX_GROWTH, 1 + SURFACE_CHROMA_GROWTH * (ratio - 1));
83
+ const chroma = Math.min(SURFACE_MAX_CHROMA, ownChroma * growth);
84
+ const L = hexToOklab(step)[0];
85
+ let best = step;
86
+ let bestOff = Number.POSITIVE_INFINITY;
87
+ for (let i = -30; i <= 30; i++) {
88
+ const candidate = colorWithHue(L + i / 30 * SURFACE_LIGHTNESS_RANGE, background, chroma);
89
+ if (!candidate) continue;
90
+ const off = Math.abs(contrastRatio(candidate, background) - ratio);
91
+ if (off < bestOff) {
92
+ best = candidate;
93
+ bestOff = off;
94
+ }
95
+ }
96
+ return best;
97
+ }
98
+ export function generateNeutralScale(background, tintSeed, mode, level = "AA") {
99
+ const exact = normalizeHex(background);
100
+ const ownChroma = chromaOf(exact);
101
+ const themed = tintSeed !== null && ownChroma >= THEMED_BACKGROUND_CHROMA;
102
+ const key = tintSeed && !themed ? tintToward(exact, tintSeed) : exact;
103
+ const keepGray = !tintSeed && isGray(exact);
104
+ const generate = (ratios2) => {
105
+ const steps2 = generateSteps(key, key, mode, ratios2);
106
+ return keepGray ? steps2.map(grayWithLuminanceOf) : steps2;
107
+ };
108
+ const ratios = [...NEUTRAL_RATIOS];
109
+ ratios[10] = TARGETS[level].text;
110
+ const steps = generate(ratios);
111
+ steps[0] = exact;
112
+ if (themed) {
113
+ for (let i = 1; i <= 7; i++) steps[i] = enrichSurface(steps[i], exact, ratios[i], ownChroma);
114
+ }
115
+ const withRatio = (index, ratio) => {
116
+ const attempt = [...ratios];
117
+ attempt[index] = ratio;
118
+ return generate(attempt)[index];
119
+ };
120
+ steps[8] = reachTarget(ratios[8], OUTLINE_TARGET, steps.slice(0, 2), (r) => withRatio(8, r)).color;
121
+ steps[10] = reachTarget(ratios[10], TARGETS[level].text, steps.slice(0, 3), (r) => withRatio(10, r)).color;
122
+ return steps;
123
+ }
124
+ function fitUnderSeed(seedRatio) {
125
+ const top = ROLE_RATIOS.at(-1);
126
+ const ceiling = seedRatio - SEED_GAP;
127
+ if (ceiling >= top) return [...ROLE_RATIOS];
128
+ const squeeze = Math.max(0, (ceiling - 1) / (top - 1));
129
+ return ROLE_RATIOS.map((ratio, i) => Math.max(1 + STEP_GAP * (i + 1), 1 + (ratio - 1) * squeeze));
130
+ }
131
+ export function generateScale(seed, neutral, mode, level = "AA") {
132
+ const background = neutral[0];
133
+ const exactSeed = normalizeHex(seed);
134
+ const seedRatio = contrastRatio(exactSeed, background);
135
+ const on = contrastRatio(exactSeed, "#000000") >= contrastRatio(exactSeed, "#FFFFFF") ? "#000000" : "#FFFFFF";
136
+ const darkBackground = contrastRatio(background, "#000000") < contrastRatio(background, "#FFFFFF");
137
+ const hoverFarther = on === "#000000" === darkBackground;
138
+ const hoverRatio = Math.min(MAX_RATIO, Math.max(1.05, hoverFarther ? seedRatio * HOVER_FACTOR : seedRatio / HOVER_FACTOR));
139
+ const targets = TARGETS[level];
140
+ const textRatio = Math.max(targets.text, seedRatio * TEXT_FACTOR);
141
+ const strongTextRatio = Math.max(targets.strongText, seedRatio * STRONG_TEXT_FACTOR, textRatio * TEXT_FACTOR);
142
+ const ratios = [...fitUnderSeed(seedRatio), seedRatio, hoverRatio, textRatio, strongTextRatio];
143
+ const steps = generateSteps(exactSeed, background, mode, ratios);
144
+ steps[8] = exactSeed;
145
+ const withRatio = (index, ratio) => {
146
+ const attempt = [...ratios];
147
+ attempt[index] = ratio;
148
+ return generateSteps(exactSeed, background, mode, attempt)[index];
149
+ };
150
+ const text = reachTarget(textRatio, targets.text, [neutral[0], neutral[1], neutral[2], steps[2]], (r) => withRatio(10, r));
151
+ steps[10] = text.color;
152
+ const strongStart = Math.max(strongTextRatio, text.ratio * TEXT_FACTOR);
153
+ const strong = reachTarget(strongStart, targets.text, [steps[3], steps[4]], (r) => withRatio(11, r));
154
+ steps[11] = strong.color;
155
+ return { steps, on };
156
+ }
157
+ export function generateScales(background, seeds, mode, level = "AA", options = {}) {
158
+ const entries = Object.entries(seeds);
159
+ const tintSeed = options.tint === false ? null : entries[0]?.[1] ?? background;
160
+ const neutral = generateNeutralScale(background, tintSeed, mode, level);
161
+ const roles = {};
162
+ for (const [role, seed] of entries) roles[role] = generateScale(seed, neutral, mode, level);
163
+ return { neutral, roles };
164
+ }
@@ -1,4 +1,5 @@
1
- import type { ThemeConfig, ThemeEntry } from '../types/index.js';
1
+ import type { ResolvedTheme, ThemeEntry } from '../types/index.js';
2
+ import type { ColorModel } from './theme-resolve.js';
2
3
  export interface VenixRuntimeThemeConfig {
3
4
  defaultTheme?: string;
4
5
  colorThemes?: Record<string, Partial<ThemeEntry>>;
@@ -8,7 +9,14 @@ export interface VenixRuntimeThemeConfig {
8
9
  /** The theme entries bundled with the module, in config format. */
9
10
  export declare function getBaseThemeEntries(): Record<string, ThemeEntry>;
10
11
  /**
11
- * Rebuilds the full `ThemeConfig` at runtime, layering `theme.json`
12
+ * The build-time message for a `defaultColor` that names no theme a visitor
13
+ * can get (a typo, a theme that isn't defined, a seasonal one with
14
+ * `seasonal: false`), or `null` when it's fine. The runtime then falls back
15
+ * to `'system'` (see `getDefaultSelection`), so this only makes that visible.
16
+ */
17
+ export declare function findInvalidDefaultColor(colors: ColorModel): string | null;
18
+ /**
19
+ * Rebuilds the color themes at runtime, layering `theme.json`
12
20
  * (bundled with the module, with the "base" themes) with the customizations
13
21
  * from `runtimeConfig.public.venixTheme` (resolved at build time from the
14
22
  * module options in `nuxt.config`, see `module.ts`). Single implementation —
@@ -20,4 +28,4 @@ export declare function getBaseThemeEntries(): Record<string, ThemeEntry>;
20
28
  * (merge + normalization of every theme) each time was wasted work. The
21
29
  * result is shared, so callers must treat it as read-only.
22
30
  */
23
- export declare function buildResolvedTheme(runtimeThemeConfig?: VenixRuntimeThemeConfig): ThemeConfig;
31
+ export declare function buildResolvedTheme(runtimeThemeConfig?: VenixRuntimeThemeConfig): ResolvedTheme;
@@ -1,9 +1,18 @@
1
1
  import themeData from "../theme.json" with { type: "json" };
2
- import { DEFAULT_THEME } from "../constants.js";
2
+ import { DEFAULT_THEME, SYSTEM_THEME } from "../constants.js";
3
3
  import { mergeColorThemes, normalizeColorThemes } from "./merge-themes.js";
4
+ import { findVariantOwner, isSelectableGroup } from "./theme-resolve.js";
4
5
  export function getBaseThemeEntries() {
5
6
  return themeData.colors?.themes ?? {};
6
7
  }
8
+ export function findInvalidDefaultColor(colors) {
9
+ const defaultColor = colors.defaultColor || DEFAULT_THEME;
10
+ if (defaultColor === SYSTEM_THEME || isSelectableGroup(colors, defaultColor)) return null;
11
+ const owner = findVariantOwner(colors, defaultColor);
12
+ if (owner && isSelectableGroup(colors, owner.theme)) return null;
13
+ const available = Object.keys(colors.groups).filter((name) => isSelectableGroup(colors, name));
14
+ return `\`color.defaultColor\` is \`'${defaultColor}'\`, which matches no available theme, so new visitors get \`'system'\` instead. Use a theme name (${available.map((name) => `\`'${name}'\``).join(", ")}), one of its variant ids or \`'system'\`.`;
15
+ }
7
16
  const resolvedThemeCache = /* @__PURE__ */ new WeakMap();
8
17
  export function buildResolvedTheme(runtimeThemeConfig) {
9
18
  if (!runtimeThemeConfig) return resolveTheme();
@@ -24,7 +33,6 @@ function resolveTheme(runtimeThemeConfig) {
24
33
  if (!(name in baseEntries)) group.custom = true;
25
34
  }
26
35
  return {
27
- ...themeData,
28
36
  colors: {
29
37
  enabled: rawColors.enabled ?? true,
30
38
  defaults: rawColors.defaults ?? true,
@@ -1,12 +1,21 @@
1
- import type { ThemeColors } from '../types/index.js';
1
+ import type { ThemeColors, ThemeMeta } from '../types/index.js';
2
2
  import type { ColorModel } from './theme-resolver.js';
3
3
  export type { ColorModel, ThemeSelection } from './theme-resolver.js';
4
- export declare const isColorTheme: (themeConfig: ThemeColors | undefined) => boolean, getEasterSunday: (year: number) => Date, isModePreference: (value: unknown) => value is import("../types/index.js").ThemeModePreference, isSelectableGroup: (colors: ColorModel, name: string) => boolean, findVariantOwner: (colors: ColorModel, id: string) => {
4
+ export declare const isColorTheme: (themeConfig: ThemeColors | undefined) => boolean, getEasterSunday: (year: number) => Date, parseDatePart: (value: string, year: number) => number | null, isModePreference: (value: unknown) => value is import("../types/index.js").ThemeModePreference, isSelectableGroup: (colors: ColorModel, name: string) => boolean, findVariantOwner: (colors: ColorModel, id: string) => {
5
5
  theme: string;
6
6
  mode: import("../types/index.js").ThemeMode;
7
7
  } | null, getDefaultSelection: (colors: ColorModel) => import("./theme-resolver.js").ThemeSelection & {
8
8
  fallbackTheme: string;
9
9
  }, normalizeThemeSelection: (themePreference: string | null | undefined, modePreference: string | null | undefined, colors: ColorModel) => import("./theme-resolver.js").ThemeSelection, getActiveSeasonalTheme: (groups: Record<string, import("../types/index.js").ResolvedThemeGroup>, mode?: import("../types/index.js").ThemeMode, now?: Date) => string | null, resolveMode: (mode: import("../types/index.js").ThemeModePreference, prefersDark: boolean) => import("../types/index.js").ThemeMode, resolveThemeSelection: (selection: import("./theme-resolver.js").ThemeSelection, colors: ColorModel, prefersDark: boolean, now?: Date) => string, resolveThemePreference: (themePreference: string | null | undefined, modePreference: string | null | undefined, colors: ColorModel, prefersDark: boolean, now?: Date) => string;
10
+ /**
11
+ * When a seasonal theme is on: the occurrence of its `dateRange` that's
12
+ * running or comes next from `now` (next year's once this year's is over,
13
+ * which moves for ranges relative to Easter). `null` without a valid range.
14
+ */
15
+ export declare function getSeasonDates(meta: ThemeMeta, now?: Date): {
16
+ start: Date;
17
+ end: Date;
18
+ } | null;
10
19
  /**
11
20
  * The theme's actual color entries (hex values only) — skips metadata like
12
21
  * `dark`/`translations`/`icon`. Shared by the CSS generator and the Vuetify
@@ -3,6 +3,7 @@ import { createThemeResolver } from "./theme-resolver.js";
3
3
  export const {
4
4
  isColorTheme,
5
5
  getEasterSunday,
6
+ parseDatePart,
6
7
  isModePreference,
7
8
  isSelectableGroup,
8
9
  findVariantOwner,
@@ -13,6 +14,23 @@ export const {
13
14
  resolveThemeSelection,
14
15
  resolveThemePreference
15
16
  } = createThemeResolver();
17
+ export function getSeasonDates(meta, now = /* @__PURE__ */ new Date()) {
18
+ if (meta.seasonal !== true || !meta.dateRange) return null;
19
+ const { start, end } = meta.dateRange;
20
+ const toDate = (bound, year2) => {
21
+ const value = parseDatePart(bound, year2);
22
+ return value === null ? null : new Date(year2, Math.floor(value / 100) - 1, value % 100);
23
+ };
24
+ const year = now.getFullYear();
25
+ const today = new Date(year, now.getMonth(), now.getDate());
26
+ const startThisYear = toDate(start, year);
27
+ const endThisYear = toDate(end, year);
28
+ if (!startThisYear || !endThisYear) return null;
29
+ if (startThisYear > endThisYear) {
30
+ return today <= endThisYear ? { start: toDate(start, year - 1), end: endThisYear } : { start: startThisYear, end: toDate(end, year + 1) };
31
+ }
32
+ return today <= endThisYear ? { start: startThisYear, end: endThisYear } : { start: toDate(start, year + 1), end: toDate(end, year + 1) };
33
+ }
16
34
  export function getThemeHexColors(themeConfig) {
17
35
  const result = [];
18
36
  for (const [key, value] of Object.entries(themeConfig)) {
@@ -28,6 +28,7 @@ export declare function createThemeResolver(): {
28
28
  DEFAULT_THEME: string;
29
29
  isColorTheme: (themeConfig: ThemeColors | undefined) => boolean;
30
30
  getEasterSunday: (year: number) => Date;
31
+ parseDatePart: (value: string, year: number) => number | null;
31
32
  isModePreference: (value: unknown) => value is ThemeModePreference;
32
33
  isSelectableGroup: (colors: ColorModel, name: string) => boolean;
33
34
  findVariantOwner: (colors: ColorModel, id: string) => {
@@ -126,6 +126,7 @@ export function createThemeResolver() {
126
126
  DEFAULT_THEME,
127
127
  isColorTheme,
128
128
  getEasterSunday,
129
+ parseDatePart,
129
130
  isModePreference,
130
131
  isSelectableGroup,
131
132
  findVariantOwner,
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@venix-sistemas/jade",
3
- "version": "1.2.0",
4
- "description": "UI foundation for Nuxt in a single module: color themes (seasonal, SSR, cookie consent), typography, scrollbar, cursor, icons, i18n, plus UnoCSS and Vuetify integrations.",
3
+ "version": "1.4.0",
4
+ "description": "UI foundation for Nuxt in one module: light/dark and seasonal color themes that switch by date or OS, with SSR and cookie consent; semantic color tokens built for WCAG contrast; plus typography, custom scrollbar and cursor, Iconify icons, i18n, and UnoCSS and Vuetify integrations.",
5
5
  "keywords": [
6
6
  "nuxt",
7
7
  "nuxt-module",
8
8
  "ui",
9
9
  "design-system",
10
+ "design-tokens",
10
11
  "nuxt-theme",
11
12
  "jade",
12
13
  "jade-theme",
@@ -14,7 +15,11 @@
14
15
  "theming",
15
16
  "colors",
16
17
  "dark-mode",
18
+ "accessibility",
19
+ "wcag",
17
20
  "seasonal-theme",
21
+ "ssr",
22
+ "cookie-consent",
18
23
  "typography",
19
24
  "scrollbar",
20
25
  "cursor",
@@ -65,25 +70,35 @@
65
70
  "playground"
66
71
  ],
67
72
  "dependencies": {
73
+ "@adobe/leonardo-contrast-colors": "^1.1.0",
68
74
  "@iconify-json/line-md": "^1.2.16",
69
75
  "@iconify-json/mdi": "^1.2.3",
70
76
  "@iconify/utils": "^3.1.7",
71
77
  "@nuxt/icon": "^2.5.1",
72
- "@nuxt/kit": "^4.6.1"
78
+ "@nuxt/kit": "^4.6.2"
79
+ },
80
+ "peerDependencies": {
81
+ "overlayscrollbars": "^2.17.0"
82
+ },
83
+ "peerDependenciesMeta": {
84
+ "overlayscrollbars": {
85
+ "optional": true
86
+ }
73
87
  },
74
88
  "devDependencies": {
75
- "@nuxt/devtools": "4.0.0-beta.5",
89
+ "@nuxt/devtools": "4.0.0-beta.7",
76
90
  "@nuxt/eslint-config": "^1.17.0",
77
91
  "@nuxt/module-builder": "^1.0.3",
78
- "@nuxt/schema": "^4.6.1",
79
- "@nuxt/test-utils": "^4.3.3",
92
+ "@nuxt/schema": "^4.6.2",
93
+ "@nuxt/test-utils": "^4.3.4",
80
94
  "@nuxtjs/i18n": "10.6.0",
81
95
  "@types/node": "latest",
82
96
  "changelogen": "^0.6.2",
83
- "eslint": "^10.12.0",
84
- "nuxt": "^4.6.1",
97
+ "eslint": "^10.13.0",
98
+ "nuxt": "^4.6.2",
99
+ "overlayscrollbars": "^2.17.0",
85
100
  "typescript": "7.0.2",
86
- "vitest": "5.0.4",
101
+ "vitest": "5.0.5",
87
102
  "vue-tsc": "^3.3.13"
88
103
  },
89
104
  "scripts": {