vuetify-nuxt-module 0.5.1 → 0.5.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 +2 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/plugins/i18n.mjs +23 -98
- package/package.json +14 -17
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<picture>
|
|
3
3
|
<source media="(prefers-color-scheme: dark)" srcset="https://github.com/userquin/vuetify-nuxt-module/raw/main/hero-dark.svg" />
|
|
4
|
-
<img alt="vuetify-nuxt-module - Zero-config Nuxt
|
|
4
|
+
<img alt="vuetify-nuxt-module - Zero-config Nuxt Module for Vuetify" src='https://github.com/userquin/vuetify-nuxt-module/raw/main/hero.svg' alt="vuetify-nuxt-module - Zero-config Nuxt Module for Vuetify"><br>
|
|
5
5
|
</picture>
|
|
6
|
-
<p>Zero-config Nuxt
|
|
6
|
+
<p>Zero-config Nuxt Module for Vuetify</p>
|
|
7
7
|
</div>
|
|
8
8
|
|
|
9
9
|
<p align='center'>
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -10,7 +10,7 @@ import { resolveVuetifyBase, normalizePath, writeStyles, cacheDir } from '@vueti
|
|
|
10
10
|
import { isAbsolute, join, relative } from 'pathe';
|
|
11
11
|
import { normalizePath as normalizePath$1 } from 'vite';
|
|
12
12
|
|
|
13
|
-
const version = "0.5.
|
|
13
|
+
const version = "0.5.3";
|
|
14
14
|
|
|
15
15
|
const VIRTUAL_VUETIFY_CONFIGURATION = "virtual:vuetify-configuration";
|
|
16
16
|
const RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION = `/@nuxt-vuetify-configuration/${VIRTUAL_VUETIFY_CONFIGURATION.slice("virtual:".length)}`;
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getCurrentInstance as _getCurrentInstance,
|
|
3
|
-
computed,
|
|
4
|
-
effectScope,
|
|
5
|
-
onScopeDispose,
|
|
6
|
-
ref,
|
|
7
|
-
toRaw,
|
|
8
|
-
watch
|
|
9
|
-
} from "vue";
|
|
1
|
+
import { ref, watch } from "vue";
|
|
10
2
|
import { useI18n } from "vue-i18n";
|
|
11
3
|
import { useNuxtApp } from "#app";
|
|
12
4
|
export function createAdapter(vuetifyOptions) {
|
|
@@ -16,120 +8,53 @@ export function createAdapter(vuetifyOptions) {
|
|
|
16
8
|
const current = i18n.locale;
|
|
17
9
|
const fallback = i18n.fallbackLocale;
|
|
18
10
|
const messages = i18n.messages;
|
|
11
|
+
const currentLocale = ref(current.value);
|
|
19
12
|
vuetifyOptions.locale.rtl = i18n.locales.value.reduce((acc, locale) => {
|
|
20
13
|
acc[locale.code] = locale.dir === "rtl";
|
|
21
14
|
return acc;
|
|
22
15
|
}, {});
|
|
16
|
+
watch(currentLocale, (val, oldVal) => {
|
|
17
|
+
if (oldVal)
|
|
18
|
+
i18n.setLocale(val);
|
|
19
|
+
}, { immediate: true, flush: "post" });
|
|
20
|
+
nuxtApp.hook("i18n:localeSwitched", ({ newLocale }) => {
|
|
21
|
+
currentLocale.value = newLocale;
|
|
22
|
+
});
|
|
23
23
|
vuetifyOptions.locale.adapter = {
|
|
24
24
|
name: "nuxt-vue-i18n",
|
|
25
|
-
current,
|
|
25
|
+
current: currentLocale,
|
|
26
26
|
fallback,
|
|
27
27
|
messages,
|
|
28
28
|
t: (key, ...params) => i18n.t(key, params),
|
|
29
29
|
n: i18n.n,
|
|
30
|
-
provide: createProvideFunction({ current, fallback, messages })
|
|
30
|
+
provide: createProvideFunction({ current: currentLocale, fallback, messages })
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
function getCurrentInstance(name, message) {
|
|
34
|
-
const vm = _getCurrentInstance();
|
|
35
|
-
if (!vm)
|
|
36
|
-
throw new Error(`[Vuetify] ${name} ${message || "must be called from inside a setup function"}`);
|
|
37
|
-
return vm;
|
|
38
|
-
}
|
|
39
|
-
function useToggleScope(source, fn) {
|
|
40
|
-
let scope;
|
|
41
|
-
function start() {
|
|
42
|
-
scope = effectScope();
|
|
43
|
-
scope.run(
|
|
44
|
-
() => fn.length ? fn(() => {
|
|
45
|
-
scope?.stop();
|
|
46
|
-
start();
|
|
47
|
-
}) : fn()
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
watch(source, (active) => {
|
|
51
|
-
if (active && !scope) {
|
|
52
|
-
start();
|
|
53
|
-
} else if (!active) {
|
|
54
|
-
scope?.stop();
|
|
55
|
-
scope = void 0;
|
|
56
|
-
}
|
|
57
|
-
}, { immediate: true });
|
|
58
|
-
onScopeDispose(() => {
|
|
59
|
-
scope?.stop();
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
function toKebabCase(str = "") {
|
|
63
|
-
return str.replace(/[^a-z]/gi, "-").replace(/\B([A-Z])/g, "-$1").toLowerCase();
|
|
64
|
-
}
|
|
65
|
-
function useProxiedModel(props, prop, defaultValue, transformIn = (v) => v, transformOut = (v) => v) {
|
|
66
|
-
const vm = getCurrentInstance("useProxiedModel");
|
|
67
|
-
const internal = ref(props[prop] !== void 0 ? props[prop] : defaultValue);
|
|
68
|
-
const kebabProp = toKebabCase(prop);
|
|
69
|
-
const checkKebab = kebabProp !== prop;
|
|
70
|
-
const isControlled = checkKebab ? computed(() => {
|
|
71
|
-
void props[prop];
|
|
72
|
-
return !!((vm.vnode.props?.hasOwnProperty(prop) || vm.vnode.props?.hasOwnProperty(kebabProp)) && (vm.vnode.props?.hasOwnProperty(`onUpdate:${prop}`) || vm.vnode.props?.hasOwnProperty(`onUpdate:${kebabProp}`)));
|
|
73
|
-
}) : computed(() => {
|
|
74
|
-
void props[prop];
|
|
75
|
-
return !!(vm.vnode.props?.hasOwnProperty(prop) && vm.vnode.props?.hasOwnProperty(`onUpdate:${prop}`));
|
|
76
|
-
});
|
|
77
|
-
useToggleScope(() => !isControlled.value, () => {
|
|
78
|
-
watch(() => props[prop], (val) => {
|
|
79
|
-
internal.value = val;
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
const model = computed({
|
|
83
|
-
get() {
|
|
84
|
-
const externalValue = props[prop];
|
|
85
|
-
return transformIn(isControlled.value ? externalValue : internal.value);
|
|
86
|
-
},
|
|
87
|
-
set(internalValue) {
|
|
88
|
-
const newValue = transformOut(internalValue);
|
|
89
|
-
const value = toRaw(isControlled.value ? props[prop] : internal.value);
|
|
90
|
-
if (value === newValue || transformIn(value) === internalValue)
|
|
91
|
-
return;
|
|
92
|
-
internal.value = newValue;
|
|
93
|
-
vm?.emit(`update:${prop}`, newValue);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
Object.defineProperty(model, "externalValue", {
|
|
97
|
-
get: () => isControlled.value ? props[prop] : internal.value
|
|
98
|
-
});
|
|
99
|
-
return model;
|
|
100
|
-
}
|
|
101
|
-
function useProvided(props, prop, provided) {
|
|
102
|
-
const internal = useProxiedModel(props, prop);
|
|
103
|
-
internal.value = props[prop] ?? provided.value;
|
|
104
|
-
watch(provided, (v) => {
|
|
105
|
-
if (props[prop] == null)
|
|
106
|
-
internal.value = v;
|
|
107
|
-
});
|
|
108
|
-
return internal;
|
|
109
|
-
}
|
|
110
33
|
function createProvideFunction(data) {
|
|
111
34
|
return (props) => {
|
|
112
|
-
const
|
|
113
|
-
const fallback = useProvided(props, "fallback", data.fallback);
|
|
114
|
-
const messages = useProvided(props, "messages", data.messages);
|
|
35
|
+
const currentLocale = ref(props.locale ?? data.current.value);
|
|
115
36
|
const i18n = useI18n({
|
|
116
|
-
locale:
|
|
117
|
-
fallbackLocale: fallback.value,
|
|
118
|
-
messages: messages.value,
|
|
37
|
+
locale: currentLocale.value,
|
|
38
|
+
fallbackLocale: data.fallback.value,
|
|
39
|
+
messages: data.messages.value,
|
|
119
40
|
useScope: "local",
|
|
120
41
|
legacy: false,
|
|
121
42
|
inheritLocale: false
|
|
122
43
|
});
|
|
44
|
+
watch(currentLocale, (val, oldVal) => {
|
|
45
|
+
if (oldVal)
|
|
46
|
+
i18n.setLocale(val);
|
|
47
|
+
}, { immediate: true, flush: "post" });
|
|
123
48
|
return {
|
|
124
49
|
name: "nuxt-vue-i18n",
|
|
125
|
-
current,
|
|
126
|
-
fallback,
|
|
127
|
-
messages,
|
|
50
|
+
current: currentLocale,
|
|
51
|
+
fallback: data.fallback,
|
|
52
|
+
messages: data.messages,
|
|
128
53
|
// todo: fix this, we should check the options
|
|
129
54
|
// @ts-expect-error Type instantiation is excessively deep and possibly infinite.ts(2589)
|
|
130
55
|
t: (key, ...params) => i18n.t(key, params),
|
|
131
56
|
n: i18n.n,
|
|
132
|
-
provide: createProvideFunction({ current, fallback, messages })
|
|
57
|
+
provide: createProvideFunction({ current: currentLocale, fallback: data.fallback, messages: data.messages })
|
|
133
58
|
};
|
|
134
59
|
};
|
|
135
60
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuetify-nuxt-module",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.3",
|
|
5
5
|
"packageManager": "pnpm@8.6.9",
|
|
6
6
|
"description": "Zero-Config Nuxt Module for Vuetify",
|
|
7
7
|
"author": "userquin <userquin@gmail.com>",
|
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
"vuetify": "^3.3.9"
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@nuxt/kit": "^3.6.
|
|
74
|
+
"@nuxt/kit": "^3.6.5",
|
|
75
75
|
"defu": "^6.1.2",
|
|
76
76
|
"perfect-debounce": "^1.0.0",
|
|
77
77
|
"unconfig": "^0.3.9",
|
|
@@ -79,27 +79,27 @@
|
|
|
79
79
|
"vuetify": "^3.3.9"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@antfu/eslint-config": "^0.39.
|
|
83
|
-
"@antfu/ni": "^0.21.
|
|
84
|
-
"@date-io/luxon": "^2.
|
|
82
|
+
"@antfu/eslint-config": "^0.39.8",
|
|
83
|
+
"@antfu/ni": "^0.21.5",
|
|
84
|
+
"@date-io/luxon": "^2.17.0",
|
|
85
85
|
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
|
86
86
|
"@fortawesome/free-solid-svg-icons": "^6.4.0",
|
|
87
87
|
"@fortawesome/vue-fontawesome": "^3.0.3",
|
|
88
88
|
"@iconify-json/carbon": "^1.1.18",
|
|
89
89
|
"@iconify-json/mdi": "^1.1.53",
|
|
90
90
|
"@mdi/js": "^7.2.96",
|
|
91
|
-
"@nuxt/devtools": "^0.
|
|
91
|
+
"@nuxt/devtools": "^0.7.0",
|
|
92
92
|
"@nuxt/module-builder": "^0.4.0",
|
|
93
|
-
"@nuxt/schema": "^3.6.
|
|
94
|
-
"@nuxt/test-utils": "^3.6.
|
|
95
|
-
"@nuxtjs/i18n": "
|
|
96
|
-
"@parcel/watcher": "^2.
|
|
93
|
+
"@nuxt/schema": "^3.6.5",
|
|
94
|
+
"@nuxt/test-utils": "^3.6.5",
|
|
95
|
+
"@nuxtjs/i18n": "npm:@nuxtjs/i18n-edge",
|
|
96
|
+
"@parcel/watcher": "^2.2.0",
|
|
97
97
|
"@types/node": "^18",
|
|
98
|
-
"@unocss/nuxt": "^0.53.
|
|
98
|
+
"@unocss/nuxt": "^0.53.6",
|
|
99
99
|
"bumpp": "^9.1.1",
|
|
100
|
-
"eslint": "^8.
|
|
100
|
+
"eslint": "^8.45.0",
|
|
101
101
|
"luxon": "^3.3.0",
|
|
102
|
-
"nuxt": "^3.6.
|
|
102
|
+
"nuxt": "^3.6.5",
|
|
103
103
|
"sass": "^1.63.6",
|
|
104
104
|
"typescript": "^5.1.6",
|
|
105
105
|
"vite": "^4.3.9",
|
|
@@ -125,9 +125,6 @@
|
|
|
125
125
|
]
|
|
126
126
|
},
|
|
127
127
|
"pnpm": {
|
|
128
|
-
"patchedDependencies": {
|
|
129
|
-
"@nuxtjs/i18n@8.0.0-beta.13": "patches/@nuxtjs__i18n@8.0.0-beta.13.patch"
|
|
130
|
-
},
|
|
131
128
|
"peerDependencyRules": {
|
|
132
129
|
"ignoreMissing": [
|
|
133
130
|
"@algolia/client-search"
|
|
@@ -138,4 +135,4 @@
|
|
|
138
135
|
"installDependencies": false,
|
|
139
136
|
"startCommand": "node .stackblitz.js && pnpm install && pnpm run dev"
|
|
140
137
|
}
|
|
141
|
-
}
|
|
138
|
+
}
|