@venix-sistemas/jade 1.3.0 → 1.4.1
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 +969 -789
- package/dist/module.d.mts +8 -1
- package/dist/module.json +4 -1
- package/dist/module.mjs +75 -7
- package/dist/runtime/components/VenixThemeSwitcher.d.vue.ts +5 -1
- package/dist/runtime/components/VenixThemeSwitcher.vue +455 -280
- package/dist/runtime/components/VenixThemeSwitcher.vue.d.ts +5 -1
- package/dist/runtime/composables/useThemeCookies.d.ts +7 -7
- package/dist/runtime/composables/useVenixTheme.d.ts +12 -0
- package/dist/runtime/composables/useVenixTheme.js +71 -1
- package/dist/runtime/plugins/overlay-scrollbars.client.d.ts +1 -1
- package/dist/runtime/plugins/theme-init.server.d.ts +1 -1
- package/dist/runtime/plugins/vuetify-theme.d.ts +1 -1
- package/dist/runtime/scripts/theme-init.d.ts +8 -0
- package/dist/runtime/scripts/theme-init.js +14 -1
- package/dist/shared/constants.d.ts +1 -1
- package/dist/shared/constants.js +3 -1
- package/dist/shared/css/colors.d.ts +2 -2
- package/dist/shared/css/colors.js +7 -2
- package/dist/shared/css/cursor.js +73 -9
- package/dist/shared/css/index.js +1 -1
- package/dist/shared/css/scrollbar.js +7 -1
- package/dist/shared/css/tokens.d.ts +40 -0
- package/dist/shared/css/tokens.js +119 -0
- package/dist/shared/theme.json +320 -308
- package/dist/shared/token-names.d.ts +37 -0
- package/dist/shared/token-names.js +53 -0
- package/dist/shared/types/color-options.d.ts +23 -2
- package/dist/shared/types/colors.d.ts +38 -0
- package/dist/shared/types/experimental.d.ts +19 -0
- package/dist/shared/types/experimental.js +0 -0
- package/dist/shared/types/index.d.ts +3 -1
- package/dist/shared/types/runtime-config.d.ts +39 -25
- package/dist/shared/unocss-preset.d.ts +27 -1
- package/dist/shared/unocss-preset.js +20 -2
- package/dist/shared/utils/contrast.d.ts +11 -0
- package/dist/shared/utils/contrast.js +24 -0
- package/dist/shared/utils/index.d.ts +3 -2
- package/dist/shared/utils/index.js +3 -2
- package/dist/shared/utils/load.d.ts +1 -1
- package/dist/shared/utils/load.js +1 -1
- package/dist/shared/utils/merge-themes.d.ts +18 -0
- package/dist/shared/utils/merge-themes.js +80 -3
- package/dist/shared/utils/oklab.d.ts +21 -0
- package/dist/shared/utils/oklab.js +74 -0
- package/dist/shared/utils/scale.d.ts +53 -0
- package/dist/shared/utils/scale.js +164 -0
- package/dist/shared/utils/theme-config.d.ts +8 -0
- package/dist/shared/utils/theme-config.js +10 -1
- package/package.json +18 -13
package/dist/module.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
-
import { TranslationConfig, ColorOptions, ScrollbarConfig, CursorConfig, TypographyConfig, VuetifyOptions, IconOptions } from '../dist/shared/types/index.js';
|
|
2
|
+
import { TranslationConfig, ColorOptions, ScrollbarConfig, CursorConfig, TypographyConfig, VuetifyOptions, IconOptions, ExperimentalConfig } from '../dist/shared/types/index.js';
|
|
3
3
|
|
|
4
4
|
interface ModuleOptions {
|
|
5
5
|
translation?: boolean | Partial<TranslationConfig>;
|
|
@@ -19,6 +19,13 @@ interface ModuleOptions {
|
|
|
19
19
|
* or an inline SVG from a single value. Installs `@nuxt/icon` automatically.
|
|
20
20
|
*/
|
|
21
21
|
icon?: boolean | Partial<IconOptions>;
|
|
22
|
+
/**
|
|
23
|
+
* Experimental features, to try them on a project. Off by default; a
|
|
24
|
+
* build-time choice, with nothing for the visitor to switch. Today: the
|
|
25
|
+
* semantic color tokens for every theme, built-in ones included (see
|
|
26
|
+
* `ExperimentalConfig`).
|
|
27
|
+
*/
|
|
28
|
+
experimental?: boolean | Partial<ExperimentalConfig>;
|
|
22
29
|
}
|
|
23
30
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
|
|
24
31
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -2,11 +2,13 @@ import { addComponent, addPlugin, addServerPlugin, addTemplate, useLogger, insta
|
|
|
2
2
|
import { loadTheme } from '../dist/shared/utils/load.js';
|
|
3
3
|
import { SWITCHER_ICONS, DEFAULT_THEME, DEFAULT_LOCALE_COOKIE_NAME, DEFAULT_LOCALE } from '../dist/shared/constants.js';
|
|
4
4
|
import { resolveFeatureOption } from '../dist/shared/utils/options.js';
|
|
5
|
-
import { findDeprecatedThemeEntries } from '../dist/shared/utils/merge-themes.js';
|
|
6
|
-
import { buildResolvedTheme, getBaseThemeEntries } from '../dist/shared/utils/theme-config.js';
|
|
5
|
+
import { findDeprecatedThemeEntries, findThemeConfigIssues, overridesBrandColors } from '../dist/shared/utils/merge-themes.js';
|
|
6
|
+
import { buildResolvedTheme, getBaseThemeEntries, findInvalidDefaultColor } from '../dist/shared/utils/theme-config.js';
|
|
7
|
+
import { generateTokens, findTokenOverrideIssues, findTokenContrastIssues, collectTokens } from '../dist/shared/css/tokens.js';
|
|
8
|
+
import { tokensEnabled, TOKEN_ROLES } from '../dist/shared/token-names.js';
|
|
9
|
+
import { isColorTheme, getThemeHexColors } from '../dist/shared/utils/theme-resolve.js';
|
|
7
10
|
import { processTheme } from '../dist/shared/css/index.js';
|
|
8
11
|
import { createRequire } from 'node:module';
|
|
9
|
-
import { isColorTheme, getThemeHexColors } from '../dist/shared/utils/theme-resolve.js';
|
|
10
12
|
import { realpathSync } from 'node:fs';
|
|
11
13
|
import { fileURLToPath } from 'node:url';
|
|
12
14
|
import { join } from 'node:path';
|
|
@@ -39,6 +41,22 @@ function customizeTheme(baseTheme, options) {
|
|
|
39
41
|
seasonal: colorOption.seasonal
|
|
40
42
|
});
|
|
41
43
|
customized.colors = { ...resolved.colors, enabled: customized.colors.enabled };
|
|
44
|
+
if (colorOption.contrast !== void 0) customized.colors.contrast = colorOption.contrast;
|
|
45
|
+
}
|
|
46
|
+
const experimental = resolveFeatureOption(options.experimental, { enabled: false }).enabled;
|
|
47
|
+
if (experimental && customized.colors.enabled !== false) {
|
|
48
|
+
for (const variant of Object.values(customized.colors.themes)) {
|
|
49
|
+
if (isColorTheme(variant) && variant.tokens === void 0) variant.tokens = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (!experimental && customized.colors.enabled !== false) {
|
|
53
|
+
const projectThemes = typeof colorOption === "object" && colorOption !== null ? colorOption.themes ?? {} : {};
|
|
54
|
+
const defaults = [];
|
|
55
|
+
for (const [name, entry] of Object.entries(getBaseThemeEntries())) {
|
|
56
|
+
if (!tokensEnabled(entry) || projectThemes[name]?.tokens !== void 0) continue;
|
|
57
|
+
defaults.push(...Object.values(customized.colors.groups[name]?.variants ?? {}));
|
|
58
|
+
}
|
|
59
|
+
if (defaults.length) customized.colors.defaultTokens = defaults;
|
|
42
60
|
}
|
|
43
61
|
return customized;
|
|
44
62
|
}
|
|
@@ -128,6 +146,20 @@ function registerOverlayScrollbars(nuxt, resolver, theme, resolveCSS = resolveOv
|
|
|
128
146
|
addPlugin({ src: resolver.resolve("./runtime/plugins/overlay-scrollbars.client"), mode: "client" });
|
|
129
147
|
}
|
|
130
148
|
|
|
149
|
+
function tokenColorsForVuetify(themeColors, level, hasBackground2) {
|
|
150
|
+
const tokens = Object.fromEntries(generateTokens(themeColors, level));
|
|
151
|
+
const colors = {};
|
|
152
|
+
for (const role of TOKEN_ROLES) {
|
|
153
|
+
const on = tokens[`on-${role}`];
|
|
154
|
+
if (on) colors[`on-${role}`] = on;
|
|
155
|
+
}
|
|
156
|
+
if (tokens["bg-subtle"] && !hasBackground2) colors.surface = tokens["bg-subtle"];
|
|
157
|
+
if (tokens.text) {
|
|
158
|
+
colors["on-background"] = tokens.text;
|
|
159
|
+
colors["on-surface"] = tokens.text;
|
|
160
|
+
}
|
|
161
|
+
return colors;
|
|
162
|
+
}
|
|
131
163
|
function buildVuetifyThemes(colors) {
|
|
132
164
|
const themes = {};
|
|
133
165
|
for (const [name, themeColors] of Object.entries(colors.themes)) {
|
|
@@ -136,6 +168,7 @@ function buildVuetifyThemes(colors) {
|
|
|
136
168
|
const vuetifyColors = Object.fromEntries(getThemeHexColors(themeColors));
|
|
137
169
|
if (themeColors.background2) vuetifyColors.surface = themeColors.background2;
|
|
138
170
|
vuetifyColors.inverse = isDark ? "#FFFFFF" : "#000000";
|
|
171
|
+
if (tokensEnabled(themeColors) && !colors.defaultTokens?.includes(name)) Object.assign(vuetifyColors, tokenColorsForVuetify(themeColors, colors.contrast || "AA", !!themeColors.background2));
|
|
139
172
|
themes[name] = { dark: isDark, colors: vuetifyColors };
|
|
140
173
|
}
|
|
141
174
|
return themes;
|
|
@@ -217,7 +250,10 @@ async function registerThemeIcon(nuxt, resolver, options, colors) {
|
|
|
217
250
|
const module$1 = defineNuxtModule({
|
|
218
251
|
meta: {
|
|
219
252
|
name: "@venix-sistemas/jade",
|
|
220
|
-
configKey: "venixTheme"
|
|
253
|
+
configKey: "venixTheme",
|
|
254
|
+
// The module is built and tested on Nuxt 4 (`@nuxt/kit` ^4). Older
|
|
255
|
+
// versions get a clear message, not the first error that comes up.
|
|
256
|
+
compatibility: { nuxt: ">=4.0.0" }
|
|
221
257
|
},
|
|
222
258
|
defaults: {
|
|
223
259
|
translation: true,
|
|
@@ -226,7 +262,8 @@ const module$1 = defineNuxtModule({
|
|
|
226
262
|
cursor: true,
|
|
227
263
|
typography: true,
|
|
228
264
|
vuetify: false,
|
|
229
|
-
icon: true
|
|
265
|
+
icon: true,
|
|
266
|
+
experimental: false
|
|
230
267
|
},
|
|
231
268
|
async setup(options, nuxt) {
|
|
232
269
|
const resolver = createResolver(import.meta.url);
|
|
@@ -245,11 +282,39 @@ const module$1 = defineNuxtModule({
|
|
|
245
282
|
themes: {},
|
|
246
283
|
iconFormat: "svg",
|
|
247
284
|
requireConsent: true,
|
|
248
|
-
seasonal: true
|
|
285
|
+
seasonal: true,
|
|
286
|
+
allowVenixOverride: false,
|
|
287
|
+
contrast: "AA"
|
|
249
288
|
});
|
|
250
289
|
for (const message of findDeprecatedThemeEntries(getBaseThemeEntries(), colorOptions.themes)) {
|
|
251
290
|
useLogger("jade").warn(message);
|
|
252
291
|
}
|
|
292
|
+
if (colorOptions.enabled) {
|
|
293
|
+
for (const message of findThemeConfigIssues(getBaseThemeEntries(), colorOptions.themes)) {
|
|
294
|
+
useLogger("jade").warn(message);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
if (colorOptions.enabled && !colorOptions.allowVenixOverride && overridesBrandColors(getBaseThemeEntries(), colorOptions.themes)) {
|
|
298
|
+
useLogger("jade").warn("`color.themes` changes the colors of `venix`, the Venix Sistemas brand theme. For another identity, add a theme of your own (e.g. `color.themes.myBrand`) and set `color.defaultColor` to its name; Venix stays in the switcher next to it. Set `color.allowVenixOverride: true` if changing Venix is intended.");
|
|
299
|
+
}
|
|
300
|
+
if (colorOptions.enabled) {
|
|
301
|
+
const resolvedColors = buildResolvedTheme({
|
|
302
|
+
defaultTheme: colorOptions.defaultColor,
|
|
303
|
+
colorThemes: colorOptions.themes,
|
|
304
|
+
seasonal: colorOptions.seasonal
|
|
305
|
+
}).colors;
|
|
306
|
+
const defaultColorMessage = findInvalidDefaultColor(resolvedColors);
|
|
307
|
+
if (defaultColorMessage) useLogger("jade").warn(defaultColorMessage);
|
|
308
|
+
for (const message of findTokenOverrideIssues(theme.colors.themes)) {
|
|
309
|
+
useLogger("jade").warn(message);
|
|
310
|
+
}
|
|
311
|
+
if (colorOptions.contrast) {
|
|
312
|
+
const projectThemes = Object.fromEntries(Object.entries(theme.colors.themes).filter(([id]) => !theme.colors.defaultTokens?.includes(id)));
|
|
313
|
+
for (const message of findTokenContrastIssues(projectThemes, colorOptions.contrast)) {
|
|
314
|
+
useLogger("jade").warn(message);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
253
318
|
if (typeof options.cursor === "object" && options.cursor?.cursors) {
|
|
254
319
|
useLogger("jade").warn("`cursor.cursors` is deprecated and stops working in 2.0. Use `cursor.defaultCursors` instead.");
|
|
255
320
|
}
|
|
@@ -275,7 +340,8 @@ const module$1 = defineNuxtModule({
|
|
|
275
340
|
aliases: {}
|
|
276
341
|
});
|
|
277
342
|
await registerThemeIcon(nuxt, resolver, iconOptions, theme.colors);
|
|
278
|
-
|
|
343
|
+
const tokens = colorOptions.enabled ? collectTokens(theme.colors.themes, colorOptions.contrast || "AA") : {};
|
|
344
|
+
const runtimeConfig = {
|
|
279
345
|
defaultTheme: theme.colors?.defaultColor || DEFAULT_THEME,
|
|
280
346
|
colorThemes: colorOptions.themes,
|
|
281
347
|
applyColors: shouldApplyColors,
|
|
@@ -286,6 +352,7 @@ const module$1 = defineNuxtModule({
|
|
|
286
352
|
iconFormat: iconOptions.enabled ? colorOptions.iconFormat : "emote",
|
|
287
353
|
requireConsent: colorOptions.requireConsent,
|
|
288
354
|
seasonal: colorOptions.seasonal,
|
|
355
|
+
tokens,
|
|
289
356
|
icon: {
|
|
290
357
|
aliases: iconOptions.aliases
|
|
291
358
|
},
|
|
@@ -302,6 +369,7 @@ const module$1 = defineNuxtModule({
|
|
|
302
369
|
icon: iconOptions.enabled
|
|
303
370
|
}
|
|
304
371
|
};
|
|
372
|
+
Object.assign(nuxt.options.runtimeConfig.public, { venixTheme: runtimeConfig });
|
|
305
373
|
}
|
|
306
374
|
});
|
|
307
375
|
|
|
@@ -6,6 +6,10 @@ type __VLS_Props = {
|
|
|
6
6
|
/** Hides "Save changes" in the settings, for a site whose own cookie banner already records consent. */
|
|
7
7
|
hideConsent?: boolean;
|
|
8
8
|
};
|
|
9
|
-
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
10
|
+
"consent-needed": () => any;
|
|
11
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
12
|
+
"onConsent-needed"?: (() => any) | undefined;
|
|
13
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
14
|
declare const _default: typeof __VLS_export;
|
|
11
15
|
export default _default;
|