@venix-sistemas/jade 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +555 -228
- package/dist/module.json +1 -1
- package/dist/module.mjs +89 -13
- package/dist/runtime/components/VenixThemeSwitcher.d.vue.ts +3 -1
- package/dist/runtime/components/VenixThemeSwitcher.vue +592 -106
- package/dist/runtime/components/VenixThemeSwitcher.vue.d.ts +3 -1
- package/dist/runtime/composables/useThemeColors.d.ts +8 -2
- package/dist/runtime/composables/useThemeColors.js +24 -9
- package/dist/runtime/composables/useThemeCookies.d.ts +17 -2
- package/dist/runtime/composables/useThemeCookies.js +44 -7
- package/dist/runtime/composables/useThemeLocale.d.ts +7 -2
- package/dist/runtime/composables/useThemeLocale.js +2 -2
- package/dist/runtime/composables/useThemeSeasonal.d.ts +3 -3
- package/dist/runtime/composables/useThemeSeasonal.js +1 -1
- package/dist/runtime/composables/useVenixTheme.d.ts +40 -0
- package/dist/runtime/composables/useVenixTheme.js +249 -112
- package/dist/runtime/nitro/theme-init.js +8 -5
- package/dist/runtime/plugins/overlay-scrollbars.client.js +89 -0
- package/dist/runtime/plugins/theme-init.server.js +7 -12
- package/dist/runtime/plugins/vuetify-theme.js +8 -11
- package/dist/runtime/scripts/theme-init.d.ts +33 -11
- package/dist/runtime/scripts/theme-init.js +59 -88
- package/dist/shared/constants.d.ts +72 -3
- package/dist/shared/constants.js +26 -1
- package/dist/shared/css/cursor-svg.d.ts +10 -0
- package/dist/shared/css/cursor-svg.js +28 -0
- package/dist/shared/css/cursor.js +86 -34
- package/dist/shared/css/index.d.ts +1 -7
- package/dist/shared/css/index.js +5 -5
- package/dist/shared/css/scrollbar.js +61 -7
- package/dist/shared/css/transition.d.ts +1 -1
- package/dist/shared/css/typography.js +13 -0
- package/dist/shared/theme.json +308 -192
- package/dist/shared/types/color-options.d.ts +26 -2
- package/dist/shared/types/colors.d.ts +64 -12
- package/dist/shared/types/cursor.d.ts +34 -4
- package/dist/shared/types/index.d.ts +3 -3
- package/dist/shared/types/runtime-config.d.ts +5 -2
- package/dist/shared/types/scrollbar.d.ts +11 -0
- package/dist/shared/types/theme.d.ts +7 -0
- package/dist/shared/types/typography.d.ts +2 -1
- package/dist/shared/utils/icon-refs.d.ts +7 -3
- package/dist/shared/utils/icon.d.ts +4 -2
- package/dist/shared/utils/icon.js +6 -2
- package/dist/shared/utils/index.d.ts +5 -4
- package/dist/shared/utils/index.js +12 -6
- package/dist/shared/utils/inline-script.d.ts +6 -0
- package/dist/shared/utils/inline-script.js +3 -0
- package/dist/shared/utils/load.d.ts +2 -3
- package/dist/shared/utils/load.js +6 -12
- package/dist/shared/utils/merge-themes.d.ts +39 -9
- package/dist/shared/utils/merge-themes.js +101 -5
- package/dist/shared/utils/normalize.d.ts +0 -11
- package/dist/shared/utils/normalize.js +0 -12
- package/dist/shared/utils/theme-config.d.ts +15 -6
- package/dist/shared/utils/theme-config.js +28 -16
- package/dist/shared/utils/theme-resolve.d.ts +23 -22
- package/dist/shared/utils/theme-resolve.js +35 -66
- package/dist/shared/utils/theme-resolver.d.ts +47 -0
- package/dist/shared/utils/theme-resolver.js +140 -0
- package/package.json +22 -10
- package/README-default.md +0 -84
- package/dist/runtime/plugin.js +0 -3
- /package/dist/runtime/{plugin.d.ts → plugins/overlay-scrollbars.client.d.ts} +0 -0
|
@@ -1,9 +1,19 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ThemeEntry } from './colors.js';
|
|
2
2
|
export interface ColorOptions {
|
|
3
3
|
enabled: boolean;
|
|
4
4
|
apply: boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Initial choice for new visitors: a theme name (mode follows the OS), a
|
|
7
|
+
* variant id like `'dark'` (that theme in that mode) or `'system'` (both
|
|
8
|
+
* automatic). Default: `'dark'`.
|
|
9
|
+
*/
|
|
5
10
|
defaultColor: string;
|
|
6
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Override or add themes. Use the grouped format
|
|
13
|
+
* (`{ translations, icon, light: {...}, dark: {...} }`); the flat format
|
|
14
|
+
* (`{ dark: true, primary, ... }`) still works but is deprecated.
|
|
15
|
+
*/
|
|
16
|
+
themes: Record<string, Partial<ThemeEntry>>;
|
|
7
17
|
/**
|
|
8
18
|
* Preferred variant for each theme's icon when `icon` is an object
|
|
9
19
|
* (`ThemeIconFormats`). Default: `'svg'`. Falls back to `'emote'` when the
|
|
@@ -11,4 +21,18 @@ export interface ColorOptions {
|
|
|
11
21
|
* (legacy format).
|
|
12
22
|
*/
|
|
13
23
|
iconFormat: 'emote' | 'css' | 'svg';
|
|
24
|
+
/**
|
|
25
|
+
* Only save the theme cookies (`venix-theme-preference`, `venix-theme-mode`,
|
|
26
|
+
* `venix-theme-resolved`) and the locale cookie after functional-cookie
|
|
27
|
+
* consent is recorded (see `persistence.grant()`).
|
|
28
|
+
* Default: `true`. Set `false` for apps without a consent banner (e.g. an
|
|
29
|
+
* internal tool) so the chosen theme always survives a reload.
|
|
30
|
+
*/
|
|
31
|
+
requireConsent: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Seasonal themes (Carnival, Easter, Halloween, Christmas and any custom
|
|
34
|
+
* one with `seasonal: true`). Default: `true`. With `false` they're
|
|
35
|
+
* removed entirely: not listed in pickers and never applied by date.
|
|
36
|
+
*/
|
|
37
|
+
seasonal: boolean;
|
|
14
38
|
}
|
|
@@ -9,18 +9,12 @@ export interface ThemeIconFormats {
|
|
|
9
9
|
/** Iconify icon name (e.g. 'line-md:sunny-filled-loop'), animated (@nuxt/icon in SVG mode). */
|
|
10
10
|
svg?: string;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* (`easter`, `easter-47`, `easter+1`).
|
|
19
|
-
*/
|
|
20
|
-
dateRange?: {
|
|
21
|
-
start: string;
|
|
22
|
-
end: string;
|
|
23
|
-
};
|
|
12
|
+
/** Light or dark — the two variants every theme can have. */
|
|
13
|
+
export type ThemeMode = 'light' | 'dark';
|
|
14
|
+
/** The user's mode choice: a fixed mode, or `'system'` to follow the OS. */
|
|
15
|
+
export type ThemeModePreference = ThemeMode | 'system';
|
|
16
|
+
/** The color slots of a theme variant — each becomes a `--color-<name>` CSS variable. */
|
|
17
|
+
export interface ThemePalette {
|
|
24
18
|
primary?: string;
|
|
25
19
|
secondary?: string;
|
|
26
20
|
accent?: string;
|
|
@@ -31,13 +25,71 @@ export interface ThemeColors {
|
|
|
31
25
|
background?: string;
|
|
32
26
|
background2?: string;
|
|
33
27
|
background3?: string;
|
|
28
|
+
}
|
|
29
|
+
/** One light/dark variant of a theme (`ThemeDefinition.light` / `.dark`). */
|
|
30
|
+
export interface ThemeVariant extends ThemePalette {
|
|
31
|
+
/**
|
|
32
|
+
* The value applied to `<html data-theme>` (and class) and used as the
|
|
33
|
+
* Vuetify theme name. Default: `<theme>-<mode>` (e.g. `carnaval-light`).
|
|
34
|
+
*/
|
|
35
|
+
id?: string;
|
|
36
|
+
}
|
|
37
|
+
/** What a theme is called, how it's drawn and when it's active — shared by both variants. */
|
|
38
|
+
export interface ThemeMeta {
|
|
39
|
+
seasonal?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Inclusive range, wrapping across year-end when `end` < `start`. Each bound
|
|
42
|
+
* is a fixed `MM-DD` date or a movable one relative to Easter Sunday
|
|
43
|
+
* (`easter`, `easter-47`, `easter+1`).
|
|
44
|
+
*/
|
|
45
|
+
dateRange?: {
|
|
46
|
+
start: string;
|
|
47
|
+
end: string;
|
|
48
|
+
};
|
|
34
49
|
translations?: ThemeTranslations;
|
|
35
50
|
/** A plain emoji ('🎨') or an object with per-format variants — see `ThemeIconFormats`. */
|
|
36
51
|
icon?: string | ThemeIconFormats;
|
|
37
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* A theme in the grouped format: shared metadata plus a `light` and/or a
|
|
55
|
+
* `dark` variant. The user picks the theme and the mode independently; the
|
|
56
|
+
* applied colors are the variant matching the mode.
|
|
57
|
+
*/
|
|
58
|
+
export interface ThemeDefinition extends ThemeMeta {
|
|
59
|
+
light?: ThemeVariant;
|
|
60
|
+
dark?: ThemeVariant;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* A single concrete set of colors, flagged light or dark. This is how
|
|
64
|
+
* resolved variants are stored (`ColorsConfig.themes`), and also the legacy
|
|
65
|
+
* flat config format — deprecated in `color.themes` in favor of
|
|
66
|
+
* `ThemeDefinition`.
|
|
67
|
+
*/
|
|
68
|
+
export interface ThemeColors extends ThemeMeta, ThemePalette {
|
|
69
|
+
dark?: boolean;
|
|
70
|
+
}
|
|
71
|
+
/** An entry of `color.themes`: the grouped format, or the deprecated flat one. */
|
|
72
|
+
export type ThemeEntry = ThemeDefinition | ThemeColors;
|
|
73
|
+
/** A selectable theme after resolution: its metadata and the ids of its variants. */
|
|
74
|
+
export interface ResolvedThemeGroup extends ThemeMeta {
|
|
75
|
+
variants: Partial<Record<ThemeMode, string>>;
|
|
76
|
+
/** Added by the project in `color.themes`, not shipped with the module. */
|
|
77
|
+
custom?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/** Label and icon of a mode option (`'system'`, `'light'`, `'dark'`). */
|
|
80
|
+
export interface ThemeModeLabel {
|
|
81
|
+
translations?: ThemeTranslations;
|
|
82
|
+
icon?: string | ThemeIconFormats;
|
|
83
|
+
}
|
|
38
84
|
export interface ColorsConfig {
|
|
39
85
|
enabled: boolean;
|
|
40
86
|
defaults: boolean;
|
|
87
|
+
/** Initial choice for new visitors: a theme name, a variant id (`'dark'`) or `'system'`. */
|
|
41
88
|
defaultColor: string;
|
|
89
|
+
/** Every concrete color variant, by id — what `data-theme` receives. */
|
|
42
90
|
themes: Record<string, ThemeColors>;
|
|
91
|
+
/** The selectable themes (plus the `'system'` placeholder), each pointing at its variants. */
|
|
92
|
+
groups: Record<string, ResolvedThemeGroup>;
|
|
93
|
+
/** Labels and icons for the mode picker. */
|
|
94
|
+
modes: Record<string, ThemeModeLabel>;
|
|
43
95
|
}
|
|
@@ -1,7 +1,37 @@
|
|
|
1
|
+
/** The cursors the module replaces. */
|
|
2
|
+
export type CursorType = 'default' | 'pointer' | 'text';
|
|
3
|
+
export interface CursorImage {
|
|
4
|
+
/** Image served from `public/`. */
|
|
5
|
+
path: string;
|
|
6
|
+
/** The click point ("x y"). */
|
|
7
|
+
hotspot?: string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* What a color theme shows as its cursor:
|
|
11
|
+
* - `'themed'`: drawn in the theme's `primary`
|
|
12
|
+
* - `'base'`: the `defaultCursors` images (the module's fire cursors, unless
|
|
13
|
+
* the project set its own)
|
|
14
|
+
* - `'none'`: no custom cursor, the operating system's own
|
|
15
|
+
* - an object: its own images; a cursor it leaves out is shown as if the
|
|
16
|
+
* theme had no entry
|
|
17
|
+
*/
|
|
18
|
+
export type ThemeCursor = 'themed' | 'base' | 'none' | Partial<Record<CursorType, CursorImage>>;
|
|
1
19
|
export interface CursorConfig {
|
|
2
20
|
enabled: boolean;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Draws each cursor as an SVG in the active color theme's `primary`, so it
|
|
23
|
+
* changes along with the theme. `false` shows the `defaultCursors` in
|
|
24
|
+
* every theme without an entry in `themeCursors`. Default: `true`.
|
|
25
|
+
*/
|
|
26
|
+
themed?: boolean;
|
|
27
|
+
/** The default cursors, and the fallback of the drawn ones. */
|
|
28
|
+
defaultCursors: Record<string, CursorImage>;
|
|
29
|
+
/**
|
|
30
|
+
* Cursor per color theme, by theme name (both its variants, e.g. `venix`)
|
|
31
|
+
* or variant id (just that one, e.g. `carnaval-light`), which wins over
|
|
32
|
+
* the theme name. Merged with the module's own (`venix: 'base'`).
|
|
33
|
+
*/
|
|
34
|
+
themeCursors?: Record<string, ThemeCursor>;
|
|
35
|
+
/** @deprecated Renamed to `defaultCursors`; removed in 2.0. */
|
|
36
|
+
cursors?: Record<string, CursorImage>;
|
|
7
37
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import './runtime-config.js';
|
|
2
2
|
export type { FontConfig, TypographyConfig } from './typography.js';
|
|
3
3
|
export type { ScrollbarConfig } from './scrollbar.js';
|
|
4
|
-
export type { CursorConfig } from './cursor.js';
|
|
5
|
-
export type { ThemeColors, ThemeTranslations, ColorsConfig, ThemeIconFormats } from './colors.js';
|
|
6
|
-
export type { ThemeConfig } from './theme.js';
|
|
4
|
+
export type { CursorConfig, CursorType, CursorImage, ThemeCursor } from './cursor.js';
|
|
5
|
+
export type { ThemeColors, ThemeTranslations, ColorsConfig, ThemeIconFormats, ThemeMode, ThemeModePreference, ThemePalette, ThemeVariant, ThemeMeta, ThemeDefinition, ThemeEntry, ResolvedThemeGroup, ThemeModeLabel, } from './colors.js';
|
|
6
|
+
export type { ThemeConfig, ResolvedTheme } from './theme.js';
|
|
7
7
|
export type { TranslationConfig } from './translation.js';
|
|
8
8
|
export type { ColorOptions } from './color-options.js';
|
|
9
9
|
export type { VuetifyOptions } from './vuetify.js';
|
|
@@ -1,19 +1,22 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ThemeEntry } from './colors.js';
|
|
2
2
|
declare module '@nuxt/schema' {
|
|
3
3
|
interface PublicRuntimeConfig {
|
|
4
4
|
venixTheme?: {
|
|
5
5
|
defaultTheme: string;
|
|
6
|
-
colorThemes: Record<string, Partial<
|
|
6
|
+
colorThemes: Record<string, Partial<ThemeEntry>>;
|
|
7
7
|
applyColors: boolean;
|
|
8
8
|
localeCookie: string;
|
|
9
9
|
defaultLocale: string;
|
|
10
10
|
locale: string;
|
|
11
11
|
iconFormat: 'emote' | 'css' | 'svg';
|
|
12
|
+
requireConsent: boolean;
|
|
13
|
+
seasonal: boolean;
|
|
12
14
|
icon: {
|
|
13
15
|
aliases: Record<string, string>;
|
|
14
16
|
};
|
|
15
17
|
enabled: {
|
|
16
18
|
typography: boolean;
|
|
19
|
+
customFont: boolean;
|
|
17
20
|
scrollbar: boolean;
|
|
18
21
|
cursor: boolean;
|
|
19
22
|
color: boolean;
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
export interface ScrollbarConfig {
|
|
2
2
|
enabled: boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Draws the scrollbars with OverlayScrollbars, as page elements: the
|
|
5
|
+
* browser's own scrollbar ignores CSS `cursor`, so hovering it shows the
|
|
6
|
+
* system cursor instead of the custom one. Covers the page, Vuetify's scroll
|
|
7
|
+
* containers and any element with `data-venix-scroll`; other elements keep
|
|
8
|
+
* the CSS-styled native scrollbar. Off, every scrollbar is the native one,
|
|
9
|
+
* styled with CSS. Default: `false`.
|
|
10
|
+
*/
|
|
11
|
+
overlay?: boolean;
|
|
3
12
|
width: string;
|
|
4
13
|
borderRadius: string;
|
|
14
|
+
/** Native scrollbar only: the overlay one has no border around the thumb. */
|
|
5
15
|
borderWidth: string;
|
|
6
16
|
colors: {
|
|
7
17
|
thumb: string;
|
|
8
18
|
thumbHover: string;
|
|
9
19
|
track: string;
|
|
20
|
+
/** Native scrollbar only, like `borderWidth`. */
|
|
10
21
|
border: string;
|
|
11
22
|
};
|
|
12
23
|
}
|
|
@@ -9,3 +9,10 @@ export interface ThemeConfig {
|
|
|
9
9
|
customCursor: CursorConfig;
|
|
10
10
|
colors: ColorsConfig;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* The theme as rebuilt at runtime (`buildResolvedTheme`): just the colors.
|
|
14
|
+
* The other parts of `ThemeConfig` are only known at build time, where the
|
|
15
|
+
* module options are applied to them; at runtime they'd be `theme.json`'s
|
|
16
|
+
* own values, ignoring `nuxt.config`.
|
|
17
|
+
*/
|
|
18
|
+
export type ResolvedTheme = Pick<ThemeConfig, 'colors'>;
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ThemeIconFormats } from '../types/colors.js';
|
|
2
2
|
/**
|
|
3
3
|
* Extracts the Iconify `collection:icon` references used in color themes
|
|
4
|
-
* (`icon.css` / `icon.svg`) and in the configured icon aliases, grouped by
|
|
4
|
+
* and modes (`icon.css` / `icon.svg`) and in the configured icon aliases, grouped by
|
|
5
5
|
* collection. Lets each collection be bundled with only the icons actually
|
|
6
6
|
* used (tree-shaking) instead of the whole collection — essential for large
|
|
7
7
|
* collections like `mdi` (thousands of icons) used for only a handful of
|
|
8
8
|
* icons in the default theme.
|
|
9
9
|
*/
|
|
10
|
-
export declare function extractIconRefs(themes: Record<string,
|
|
10
|
+
export declare function extractIconRefs(themes: Record<string, {
|
|
11
|
+
icon?: string | ThemeIconFormats;
|
|
12
|
+
}> | Array<{
|
|
13
|
+
icon?: string | ThemeIconFormats;
|
|
14
|
+
}>, aliases: Record<string, string>): Map<string, Set<string>>;
|
|
@@ -23,7 +23,9 @@ export interface ResolvedThemeIcon {
|
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Resolves a color theme's icon (a legacy string, always emote, or a
|
|
26
|
-
* `ThemeIconFormats` with variants) to the preferred format
|
|
27
|
-
*
|
|
26
|
+
* `ThemeIconFormats` with variants) to the preferred format. When the theme
|
|
27
|
+
* doesn't define it, tries the other Iconify variant before `emote`
|
|
28
|
+
* (`svg` → `css` → `emote`, or `css` → `svg` → `emote`), so a theme with only
|
|
29
|
+
* one Iconify variant still shows an icon instead of dropping to the emoji.
|
|
28
30
|
*/
|
|
29
31
|
export declare function resolveThemeIcon(icon: string | ThemeIconFormats | undefined, preferred: ThemeIconFormat): ResolvedThemeIcon | null;
|
|
@@ -14,8 +14,12 @@ export function resolveThemeIcon(icon, preferred) {
|
|
|
14
14
|
if (typeof icon === "string") {
|
|
15
15
|
return { format: "emote", value: icon };
|
|
16
16
|
}
|
|
17
|
-
if (preferred !== "emote"
|
|
18
|
-
|
|
17
|
+
if (preferred !== "emote") {
|
|
18
|
+
const order = preferred === "svg" ? ["svg", "css"] : ["css", "svg"];
|
|
19
|
+
for (const format of order) {
|
|
20
|
+
const value = icon[format];
|
|
21
|
+
if (value) return { format, value };
|
|
22
|
+
}
|
|
19
23
|
}
|
|
20
24
|
return { format: "emote", value: icon.emote };
|
|
21
25
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { normalizeLocale, extractFirstLocale,
|
|
1
|
+
export { normalizeLocale, extractFirstLocale, } from './normalize.js';
|
|
2
2
|
export { resolveFeatureOption } from './options.js';
|
|
3
3
|
export { resolveIcon, resolveThemeIcon } from './icon.js';
|
|
4
4
|
export type { IconKind, ResolvedIcon, ThemeIconFormat, ResolvedThemeIcon } from './icon.js';
|
|
5
5
|
export { extractIconRefs } from './icon-refs.js';
|
|
6
6
|
export { hasCookieConsent } from './consent.js';
|
|
7
|
-
export { isColorTheme, getActiveSeasonalTheme, getEasterSunday, resolveThemePreference } from './theme-resolve.js';
|
|
8
|
-
export {
|
|
9
|
-
export {
|
|
7
|
+
export { isColorTheme, getActiveSeasonalTheme, getEasterSunday, getDefaultSelection, normalizeThemeSelection, resolveThemeSelection, resolveThemePreference, } from './theme-resolve.js';
|
|
8
|
+
export type { ColorModel, ThemeSelection } from './theme-resolve.js';
|
|
9
|
+
export { mergeColorThemes, normalizeColorThemes, findDeprecatedThemeEntries } from './merge-themes.js';
|
|
10
|
+
export { buildResolvedTheme, getBaseThemeEntries } from './theme-config.js';
|
|
10
11
|
export type { VenixRuntimeThemeConfig } from './theme-config.js';
|
|
@@ -1,13 +1,19 @@
|
|
|
1
1
|
export {
|
|
2
2
|
normalizeLocale,
|
|
3
|
-
extractFirstLocale
|
|
4
|
-
normalizeColor,
|
|
5
|
-
normalizeThemeName
|
|
3
|
+
extractFirstLocale
|
|
6
4
|
} from "./normalize.js";
|
|
7
5
|
export { resolveFeatureOption } from "./options.js";
|
|
8
6
|
export { resolveIcon, resolveThemeIcon } from "./icon.js";
|
|
9
7
|
export { extractIconRefs } from "./icon-refs.js";
|
|
10
8
|
export { hasCookieConsent } from "./consent.js";
|
|
11
|
-
export {
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
export {
|
|
10
|
+
isColorTheme,
|
|
11
|
+
getActiveSeasonalTheme,
|
|
12
|
+
getEasterSunday,
|
|
13
|
+
getDefaultSelection,
|
|
14
|
+
normalizeThemeSelection,
|
|
15
|
+
resolveThemeSelection,
|
|
16
|
+
resolveThemePreference
|
|
17
|
+
} from "./theme-resolve.js";
|
|
18
|
+
export { mergeColorThemes, normalizeColorThemes, findDeprecatedThemeEntries } from "./merge-themes.js";
|
|
19
|
+
export { buildResolvedTheme, getBaseThemeEntries } from "./theme-config.js";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON is valid JS, but inside an inline `<script>` a `</script>` anywhere in
|
|
3
|
+
* the data (e.g. in a theme translation) would end the element early and
|
|
4
|
+
* break the page. `<` is the same character to the JS parser.
|
|
5
|
+
*/
|
|
6
|
+
export declare function toInlineScriptJson(value: unknown): string;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ThemeConfig } from '../types/index.js';
|
|
1
|
+
import type { ResolvedTheme, ThemeConfig } from '../types/index.js';
|
|
2
2
|
export declare function loadTheme(_path?: string): ThemeConfig;
|
|
3
|
-
export declare function extractLocales(theme:
|
|
4
|
-
export declare function getDefaultLocale(theme: ThemeConfig): string;
|
|
3
|
+
export declare function extractLocales(theme: ResolvedTheme): string[];
|
|
@@ -1,22 +1,16 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { DEFAULT_LOCALE } from "../constants.js";
|
|
1
|
+
import themeData from "../theme.json" with { type: "json" };
|
|
3
2
|
import { normalizeLocale } from "./normalize.js";
|
|
3
|
+
import { buildResolvedTheme } from "./theme-config.js";
|
|
4
4
|
export function loadTheme(_path) {
|
|
5
|
-
return
|
|
5
|
+
return { ...themeData, colors: buildResolvedTheme().colors };
|
|
6
6
|
}
|
|
7
7
|
export function extractLocales(theme) {
|
|
8
8
|
const locales = /* @__PURE__ */ new Set();
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const labelled = [...Object.values(theme.colors?.groups || {}), ...Object.values(theme.colors?.modes || {})];
|
|
10
|
+
for (const entry of labelled) {
|
|
11
|
+
for (const locale of Object.keys(entry.translations ?? {})) {
|
|
11
12
|
locales.add(normalizeLocale(locale));
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
15
|
return Array.from(locales);
|
|
15
16
|
}
|
|
16
|
-
export function getDefaultLocale(theme) {
|
|
17
|
-
const locales = extractLocales(theme);
|
|
18
|
-
if (locales.includes("en-US")) return "en-US";
|
|
19
|
-
const firstLocale = locales[0];
|
|
20
|
-
if (firstLocale) return firstLocale;
|
|
21
|
-
return DEFAULT_LOCALE;
|
|
22
|
-
}
|
|
@@ -1,11 +1,41 @@
|
|
|
1
|
-
import type { ThemeColors } from '../types/index.js';
|
|
1
|
+
import type { ThemeColors, ThemeDefinition, ThemeEntry, ResolvedThemeGroup } from '../types/index.js';
|
|
2
|
+
/** Grouped format: at least one `light`/`dark` variant object. */
|
|
3
|
+
export declare function isThemeDefinition(entry: Partial<ThemeEntry> | undefined): entry is ThemeDefinition;
|
|
4
|
+
/**
|
|
5
|
+
* Deprecated flat format: a boolean `dark` flag and/or colors at the top
|
|
6
|
+
* level. An entry with only metadata (`translations`, `icon`…) is neither —
|
|
7
|
+
* it's valid in both formats.
|
|
8
|
+
*/
|
|
9
|
+
export declare function isLegacyThemeEntry(entry: Partial<ThemeEntry> | undefined): entry is ThemeColors;
|
|
2
10
|
/**
|
|
3
11
|
* Layers the `color.themes` overrides from `nuxt.config` on top of the base
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
|
|
11
|
-
|
|
12
|
+
* entries (`theme.json`), still in config format:
|
|
13
|
+
*
|
|
14
|
+
* - an existing theme only gets the keys the override sets — metadata at the
|
|
15
|
+
* theme level, colors variant by variant;
|
|
16
|
+
* - a deprecated flat override named after a variant id (`dark: { primary }`)
|
|
17
|
+
* is merged into that variant (`venix.dark`);
|
|
18
|
+
* - anything else is added as a new theme (a flat one is dark unless it sets
|
|
19
|
+
* `dark: false`, as before).
|
|
20
|
+
*
|
|
21
|
+
* Single implementation — used both at build time (`customizeTheme`, which
|
|
22
|
+
* feeds the generated CSS and Vuetify) and at runtime (`buildResolvedTheme`),
|
|
23
|
+
* so the two can't diverge.
|
|
24
|
+
*/
|
|
25
|
+
export declare function mergeColorThemes(baseThemes: Record<string, ThemeEntry>, overrides?: Record<string, Partial<ThemeEntry>>): Record<string, ThemeEntry>;
|
|
26
|
+
/**
|
|
27
|
+
* Turns config entries (both formats) into what the runtime works with:
|
|
28
|
+
* `themes`, every concrete variant by id (feeds `data-theme`, the CSS and
|
|
29
|
+
* Vuetify), and `groups`, the selectable themes pointing at their variants.
|
|
30
|
+
* A deprecated flat entry becomes a single-variant theme whose id is its own
|
|
31
|
+
* name, so its `data-theme` value doesn't change.
|
|
32
|
+
*/
|
|
33
|
+
export declare function normalizeColorThemes(entries: Record<string, ThemeEntry>): {
|
|
34
|
+
themes: Record<string, ThemeColors>;
|
|
35
|
+
groups: Record<string, ResolvedThemeGroup>;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* Overrides still written in the deprecated flat format, with the message to
|
|
39
|
+
* show for each — logged once at build time by `module.ts`.
|
|
40
|
+
*/
|
|
41
|
+
export declare function findDeprecatedThemeEntries(baseThemes: Record<string, ThemeEntry>, overrides?: Record<string, Partial<ThemeEntry>>): string[];
|
|
@@ -1,10 +1,106 @@
|
|
|
1
|
+
import { COLOR_PROPERTIES, THEME_MODES } from "../constants.js";
|
|
2
|
+
const META_PROPERTIES = ["seasonal", "dateRange", "translations", "icon"];
|
|
3
|
+
export function isThemeDefinition(entry) {
|
|
4
|
+
if (!entry) return false;
|
|
5
|
+
return THEME_MODES.some((mode) => typeof entry[mode] === "object");
|
|
6
|
+
}
|
|
7
|
+
export function isLegacyThemeEntry(entry) {
|
|
8
|
+
if (!entry || isThemeDefinition(entry)) return false;
|
|
9
|
+
return typeof entry.dark === "boolean" || COLOR_PROPERTIES.some((key) => entry[key] !== void 0);
|
|
10
|
+
}
|
|
11
|
+
function pickMeta(entry) {
|
|
12
|
+
const meta = {};
|
|
13
|
+
for (const key of META_PROPERTIES) {
|
|
14
|
+
if (entry[key] !== void 0) meta[key] = entry[key];
|
|
15
|
+
}
|
|
16
|
+
return meta;
|
|
17
|
+
}
|
|
18
|
+
function pickPalette(entry) {
|
|
19
|
+
const palette = {};
|
|
20
|
+
for (const key of COLOR_PROPERTIES) {
|
|
21
|
+
const value = entry[key];
|
|
22
|
+
if (value !== void 0) palette[key] = value;
|
|
23
|
+
}
|
|
24
|
+
return palette;
|
|
25
|
+
}
|
|
26
|
+
const variantId = (themeName, mode, variant) => variant.id || `${themeName}-${mode}`;
|
|
27
|
+
function findVariantOwner(entries, id) {
|
|
28
|
+
for (const [themeName, entry] of Object.entries(entries)) {
|
|
29
|
+
if (!isThemeDefinition(entry)) continue;
|
|
30
|
+
for (const mode of THEME_MODES) {
|
|
31
|
+
const variant = entry[mode];
|
|
32
|
+
if (variant && variantId(themeName, mode, variant) === id) return { theme: themeName, mode };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
function legacyOverrideMode(group, themeName, override) {
|
|
38
|
+
const byId = THEME_MODES.find((mode) => group[mode] && variantId(themeName, mode, group[mode]) === themeName);
|
|
39
|
+
return byId ?? (override.dark === false ? "light" : "dark");
|
|
40
|
+
}
|
|
1
41
|
export function mergeColorThemes(baseThemes, overrides) {
|
|
2
42
|
const merged = { ...baseThemes };
|
|
3
|
-
for (const [themeName,
|
|
4
|
-
merged[themeName]
|
|
5
|
-
|
|
6
|
-
...
|
|
7
|
-
|
|
43
|
+
for (const [themeName, override] of Object.entries(overrides ?? {})) {
|
|
44
|
+
const existing = merged[themeName];
|
|
45
|
+
if (existing && isThemeDefinition(existing)) {
|
|
46
|
+
const next = { ...existing, ...pickMeta(override) };
|
|
47
|
+
if (isThemeDefinition(override)) {
|
|
48
|
+
for (const mode of THEME_MODES) {
|
|
49
|
+
if (override[mode]) next[mode] = { ...existing[mode], ...override[mode] };
|
|
50
|
+
}
|
|
51
|
+
} else if (isLegacyThemeEntry(override)) {
|
|
52
|
+
const mode = legacyOverrideMode(existing, themeName, override);
|
|
53
|
+
next[mode] = { ...existing[mode], ...pickPalette(override) };
|
|
54
|
+
}
|
|
55
|
+
merged[themeName] = next;
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
if (existing) {
|
|
59
|
+
merged[themeName] = { ...existing, ...override };
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
const owner = isLegacyThemeEntry(override) ? findVariantOwner(merged, themeName) : null;
|
|
63
|
+
if (owner) {
|
|
64
|
+
const group = merged[owner.theme];
|
|
65
|
+
merged[owner.theme] = {
|
|
66
|
+
...group,
|
|
67
|
+
[owner.mode]: { ...group[owner.mode], ...pickPalette(override) }
|
|
68
|
+
};
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
merged[themeName] = isThemeDefinition(override) ? override : { dark: true, ...override };
|
|
8
72
|
}
|
|
9
73
|
return merged;
|
|
10
74
|
}
|
|
75
|
+
export function normalizeColorThemes(entries) {
|
|
76
|
+
const themes = {};
|
|
77
|
+
const groups = {};
|
|
78
|
+
for (const [themeName, entry] of Object.entries(entries)) {
|
|
79
|
+
const group = { ...pickMeta(entry), variants: {} };
|
|
80
|
+
if (isThemeDefinition(entry)) {
|
|
81
|
+
for (const mode of THEME_MODES) {
|
|
82
|
+
const variant = entry[mode];
|
|
83
|
+
if (!variant) continue;
|
|
84
|
+
const id = variantId(themeName, mode, variant);
|
|
85
|
+
themes[id] = { dark: mode === "dark", ...pickPalette(variant) };
|
|
86
|
+
group.variants[mode] = id;
|
|
87
|
+
}
|
|
88
|
+
} else if (isLegacyThemeEntry(entry)) {
|
|
89
|
+
const mode = entry.dark === false ? "light" : "dark";
|
|
90
|
+
themes[themeName] = { dark: mode === "dark", ...pickPalette(entry) };
|
|
91
|
+
group.variants[mode] = themeName;
|
|
92
|
+
}
|
|
93
|
+
groups[themeName] = group;
|
|
94
|
+
}
|
|
95
|
+
return { themes, groups };
|
|
96
|
+
}
|
|
97
|
+
export function findDeprecatedThemeEntries(baseThemes, overrides) {
|
|
98
|
+
const messages = [];
|
|
99
|
+
for (const [themeName, override] of Object.entries(overrides ?? {})) {
|
|
100
|
+
if (!isLegacyThemeEntry(override)) continue;
|
|
101
|
+
const base = baseThemes[themeName];
|
|
102
|
+
const owner = base && isThemeDefinition(base) ? { theme: themeName, mode: legacyOverrideMode(base, themeName, override) } : base ? null : findVariantOwner(baseThemes, themeName);
|
|
103
|
+
messages.push(owner ? `\`color.themes.${themeName}\` overrides a theme variant in the deprecated flat format. Use \`${owner.theme}: { ${owner.mode}: { ... } }\` instead.` : `\`color.themes.${themeName}\` uses the deprecated flat format (\`dark: true/false\` plus colors). Use \`${themeName}: { light: { ... }, dark: { ... } }\` instead.`);
|
|
104
|
+
}
|
|
105
|
+
return messages;
|
|
106
|
+
}
|
|
@@ -8,14 +8,3 @@ export declare function normalizeLocale(locale: string): string;
|
|
|
8
8
|
* E.g.: "pt-BR,pt;q=0.9,en;q=0.8" -> "pt-BR"
|
|
9
9
|
*/
|
|
10
10
|
export declare function extractFirstLocale(acceptLanguage: string): string | null;
|
|
11
|
-
/**
|
|
12
|
-
* Normalizes a hex color: trims it and adds the leading `#` when missing
|
|
13
|
-
* (case is preserved).
|
|
14
|
-
* E.g.: "fff" -> "#fff", " #FFFFFF " -> "#FFFFFF"
|
|
15
|
-
*/
|
|
16
|
-
export declare function normalizeColor(color: string): string;
|
|
17
|
-
/**
|
|
18
|
-
* Normalizes a theme name.
|
|
19
|
-
* E.g.: "dark" -> "Dark", "DARK" -> "Dark"
|
|
20
|
-
*/
|
|
21
|
-
export declare function normalizeThemeName(name: string): string;
|
|
@@ -24,15 +24,3 @@ export function extractFirstLocale(acceptLanguage) {
|
|
|
24
24
|
const firstLocale = localeParts[0]?.trim();
|
|
25
25
|
return firstLocale || null;
|
|
26
26
|
}
|
|
27
|
-
export function normalizeColor(color) {
|
|
28
|
-
if (!color) return color;
|
|
29
|
-
color = color.trim();
|
|
30
|
-
if (!color.startsWith("#")) {
|
|
31
|
-
color = `#${color}`;
|
|
32
|
-
}
|
|
33
|
-
return color;
|
|
34
|
-
}
|
|
35
|
-
export function normalizeThemeName(name) {
|
|
36
|
-
if (!name) return name;
|
|
37
|
-
return name.charAt(0).toUpperCase() + name.slice(1).toLowerCase();
|
|
38
|
-
}
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ResolvedTheme, ThemeEntry } from '../types/index.js';
|
|
2
2
|
export interface VenixRuntimeThemeConfig {
|
|
3
3
|
defaultTheme?: string;
|
|
4
|
-
colorThemes?: Record<string, Partial<
|
|
4
|
+
colorThemes?: Record<string, Partial<ThemeEntry>>;
|
|
5
|
+
/** `false` drops every seasonal theme (built-in and custom). Default: `true`. */
|
|
6
|
+
seasonal?: boolean;
|
|
5
7
|
}
|
|
8
|
+
/** The theme entries bundled with the module, in config format. */
|
|
9
|
+
export declare function getBaseThemeEntries(): Record<string, ThemeEntry>;
|
|
6
10
|
/**
|
|
7
|
-
* Rebuilds the
|
|
11
|
+
* Rebuilds the color themes at runtime, layering `theme.json`
|
|
8
12
|
* (bundled with the module, with the "base" themes) with the customizations
|
|
9
13
|
* from `runtimeConfig.public.venixTheme` (resolved at build time from the
|
|
10
14
|
* module options in `nuxt.config`, see `module.ts`). Single implementation —
|
|
11
|
-
* used by the composable (`useVenixTheme`)
|
|
12
|
-
*
|
|
15
|
+
* used by the composable (`useVenixTheme`), the SSR/Vuetify plugins and, at
|
|
16
|
+
* build time, `customizeTheme`.
|
|
17
|
+
*
|
|
18
|
+
* Memoized per config object: every `useVenixTheme()` call and plugin asks
|
|
19
|
+
* for it with the same `runtimeConfig.public.venixTheme`, and rebuilding it
|
|
20
|
+
* (merge + normalization of every theme) each time was wasted work. The
|
|
21
|
+
* result is shared, so callers must treat it as read-only.
|
|
13
22
|
*/
|
|
14
|
-
export declare function buildResolvedTheme(runtimeThemeConfig?: VenixRuntimeThemeConfig):
|
|
23
|
+
export declare function buildResolvedTheme(runtimeThemeConfig?: VenixRuntimeThemeConfig): ResolvedTheme;
|