@xleddyl/443-components-vue 0.2.0 → 0.2.3

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 CHANGED
@@ -49,10 +49,10 @@ Every component is registered with the prefix (`Button.vue` becomes `<KButton>`)
49
49
  | `messages` | `{}` | Overrides per locale code, for example `{ it: { common: { cancel: 'Indietro' } } }`. |
50
50
  | `composables` | `true` | Auto-imports the composables. |
51
51
  | `global` | `false` | Puts `k-root` and `data-theme` on `<html>` for apps that are dashboard only. |
52
- | `theme.cookie` | `'k-theme'` | Cookie that stores the theme preference (SSR safe, no flash). |
52
+ | `theme.cookie` | `'k-theme'` | Cookie that stores the theme preference (SSR safe, no flash). `false` sets no cookie and always renders `theme.default`. |
53
53
  | `theme.default` | `'system'` | `'light'`, `'dark'` or `'system'`. |
54
54
  | `preset.default` | `'default'` | Built-in preset: `'default'`, `'suedtirol'` or `'spotfish'`. |
55
- | `preset.cookie` | `'k-preset'` | Cookie that stores the preset preference (SSR safe, no flash). |
55
+ | `preset.cookie` | `'k-preset'` | Cookie that stores the preset preference (SSR safe, no flash). `false` sets no cookie and always renders `preset.default`. |
56
56
  | `fonts` | `true` | Injects the self-hosted fonts of `preset.default` (`true`), of a list of presets (`['default', 'suedtirol']`) or none (`false`). Install the `@fontsource-variable/*` packages they need. |
57
57
  | `icons.dir` | none | Folder of `.svg` files registered as icons by file name (watched in dev). |
58
58
  | `icons.collections` | `[]` | Iconify collections usable as `prefix:name`, for example `['lucide', { prefix: 'heroicons', exclude: ['*-solid', '*-20-*', '*-16-*'] }]`. See [Icons](#icons). |
@@ -30,12 +30,12 @@ export interface ModuleOptions {
30
30
  aliases?: Record<string, string>;
31
31
  };
32
32
  theme: {
33
- cookie: string;
34
- default: ThemePreference;
33
+ cookie?: string | false;
34
+ default?: ThemePreference;
35
35
  };
36
36
  preset: {
37
- cookie: string;
38
- default: ThemePreset;
37
+ cookie?: string | false;
38
+ default?: ThemePreset;
39
39
  };
40
40
  fonts: boolean | ThemePreset[];
41
41
  locale: string;
@@ -43,9 +43,9 @@ export interface ModuleOptions {
43
43
  }
44
44
  export interface KRuntimeConfig {
45
45
  global: boolean;
46
- themeCookie: string;
46
+ themeCookie: string | false;
47
47
  themeDefault: ThemePreference;
48
- presetCookie: string;
48
+ presetCookie: string | false;
49
49
  presetDefault: ThemePreset;
50
50
  locale: string;
51
51
  messages: Record<string, DeepPartial<KMessages>>;
@@ -107,15 +107,16 @@ export default defineNuxtModule({
107
107
  const viteBuild = nuxt.options.vite.build ??= {};
108
108
  if (options.cssTarget && viteBuild.cssTarget === void 0)
109
109
  viteBuild.cssTarget = options.cssTarget;
110
- nuxt.options.runtimeConfig.public.k = {
110
+ const runtimeConfig = {
111
111
  global: options.global,
112
- themeCookie: options.theme.cookie,
113
- themeDefault: options.theme.default,
114
- presetCookie: options.preset.cookie,
112
+ themeCookie: options.theme.cookie ?? "k-theme",
113
+ themeDefault: options.theme.default ?? "system",
114
+ presetCookie: options.preset.cookie ?? "k-preset",
115
115
  presetDefault,
116
116
  locale: options.locale,
117
117
  messages: options.messages
118
118
  };
119
+ Object.assign(nuxt.options.runtimeConfig.public, { k: runtimeConfig });
119
120
  addPlugin(resolver.resolve("./runtime/theme"));
120
121
  addPlugin(resolver.resolve("./runtime/storage"));
121
122
  addPlugin(resolver.resolve("./runtime/locale"));
@@ -1,4 +1,4 @@
1
- import { defineNuxtPlugin, useCookie, useHead, useRuntimeConfig } from "nuxt/app";
1
+ import { defineNuxtPlugin, useCookie, useHead, useRuntimeConfig, useState } from "nuxt/app";
2
2
  import { computed } from "vue";
3
3
  import { isThemePreference, THEME_STORAGE_KEY } from "../../composables/useTheme.mjs";
4
4
  import { isThemePreset, PRESET_STORAGE_KEY } from "../../internal/core/preset-data.mjs";
@@ -9,13 +9,13 @@ export default defineNuxtPlugin({
9
9
  setup(nuxtApp) {
10
10
  const config = useRuntimeConfig().public.k ?? {};
11
11
  const fallback = isThemePreference(config.themeDefault) ? config.themeDefault : "system";
12
- const cookie = useCookie(config.themeCookie ?? THEME_STORAGE_KEY, {
12
+ const cookie = config.themeCookie === false ? useState("k-theme", () => fallback) : useCookie(config.themeCookie ?? THEME_STORAGE_KEY, {
13
13
  ...persistentCookieOptions,
14
14
  default: () => fallback
15
15
  });
16
16
  if (!isThemePreference(cookie.value)) cookie.value = fallback;
17
17
  const presetFallback = isThemePreset(config.presetDefault) ? config.presetDefault : "default";
18
- const presetCookie = useCookie(config.presetCookie ?? PRESET_STORAGE_KEY, {
18
+ const presetCookie = config.presetCookie === false ? useState("k-preset", () => presetFallback) : useCookie(config.presetCookie ?? PRESET_STORAGE_KEY, {
19
19
  ...persistentCookieOptions,
20
20
  default: () => presetFallback
21
21
  });
@@ -26,6 +26,11 @@ html.k-root > body {
26
26
  color: var(--k-text);
27
27
  }
28
28
 
29
+ :where(.k-root) :where(a) {
30
+ color: inherit;
31
+ text-decoration: inherit;
32
+ }
33
+
29
34
  :where(.k-root) :where(button, input, select, textarea, optgroup) {
30
35
  font: inherit;
31
36
  font-feature-settings: inherit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xleddyl/443-components-vue",
3
- "version": "0.2.0",
3
+ "version": "0.2.3",
4
4
  "description": "Compact, scoped dashboard components for Vue and Nuxt",
5
5
  "license": "MIT",
6
6
  "author": "Edoardo Alberti (https://github.com/xleddyl)",