@prefabs.tech/vue3-i18n 0.31.0 → 0.33.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.
@@ -1,338 +1,268 @@
1
- import { useI18n as F, createI18n as G } from "vue-i18n";
2
- import { useI18n as Oe } from "vue-i18n";
3
- import { watch as z, getCurrentScope as D, onScopeDispose as R, computed as C, toValue as v, unref as M, defineComponent as B, openBlock as _, createElementBlock as L, createTextVNode as N, toDisplayString as I, createCommentVNode as V, createBlock as U, ref as x, normalizeClass as P, createElementVNode as w, renderSlot as Z, Fragment as H, renderList as J, createVNode as K } from "vue";
4
- import { useConfig as Q } from "@prefabs.tech/vue3-config";
5
- function X(e) {
6
- return D() ? (R(e), !0) : !1;
7
- }
8
- const j = typeof window < "u" && typeof document < "u";
1
+ import { createI18n as e, useI18n as t, useI18n as n } from "vue-i18n";
2
+ import { Fragment as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, normalizeClass as f, openBlock as p, ref as m, renderList as h, renderSlot as g, toDisplayString as _, toValue as v, unref as y, watch as b } from "vue";
3
+ import { useConfig as x } from "@prefabs.tech/vue3-config";
4
+ //#region ../../node_modules/.pnpm/@vueuse+shared@14.3.0_vue@3.5.40_typescript@6.0.3_/node_modules/@vueuse/shared/dist/index.js
5
+ var S = typeof window < "u" && typeof document < "u";
9
6
  typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
10
- const Y = Object.prototype.toString, ee = (e) => Y.call(e) === "[object Object]", y = () => {
11
- }, te = /* @__PURE__ */ ne();
12
- function ne() {
13
- var e, t;
14
- return j && ((e = window?.navigator) == null ? void 0 : e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window?.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent));
7
+ var C = Object.prototype.toString, w = (e) => C.call(e) === "[object Object]", T = () => {}, E = /* @__PURE__ */ D();
8
+ function D() {
9
+ var e, t;
10
+ return S && !!(!((e = window) == null || (e = e.navigator) == null) && e.userAgent) && (/iP(?:ad|hone|od)/.test(window.navigator.userAgent) || ((t = window) == null || (t = t.navigator) == null ? void 0 : t.maxTouchPoints) > 2 && /iPad|Macintosh/.test(window?.navigator.userAgent));
15
11
  }
16
- function $(e) {
17
- return Array.isArray(e) ? e : [e];
12
+ function O(e) {
13
+ return Array.isArray(e) ? e : [e];
18
14
  }
19
- function oe(e, t, n) {
20
- return z(
21
- e,
22
- t,
23
- {
24
- ...n,
25
- immediate: !0
26
- }
27
- );
15
+ function k(e, t, n) {
16
+ return b(e, t, {
17
+ ...n,
18
+ immediate: !0
19
+ });
28
20
  }
29
- const W = j ? window : void 0;
30
- function S(e) {
31
- var t;
32
- const n = v(e);
33
- return (t = n?.$el) != null ? t : n;
21
+ //#endregion
22
+ //#region ../../node_modules/.pnpm/@vueuse+core@14.3.0_vue@3.5.40_typescript@6.0.3_/node_modules/@vueuse/core/dist/index.js
23
+ var A = S ? window : void 0;
24
+ S && window.document, S && window.navigator, S && window.location;
25
+ function j(e) {
26
+ let t = v(e);
27
+ return t?.$el ?? t;
34
28
  }
35
- function b(...e) {
36
- const t = [], n = () => {
37
- t.forEach((r) => r()), t.length = 0;
38
- }, o = (r, a, u, p) => (r.addEventListener(a, u, p), () => r.removeEventListener(a, u, p)), s = C(() => {
39
- const r = $(v(e[0])).filter((a) => a != null);
40
- return r.every((a) => typeof a != "string") ? r : void 0;
41
- }), c = oe(
42
- () => {
43
- var r, a;
44
- return [
45
- (a = (r = s.value) == null ? void 0 : r.map((u) => S(u))) != null ? a : [W].filter((u) => u != null),
46
- $(v(s.value ? e[1] : e[0])),
47
- $(M(s.value ? e[2] : e[1])),
48
- // @ts-expect-error - TypeScript gets the correct types, but somehow still complains
49
- v(s.value ? e[3] : e[2])
50
- ];
51
- },
52
- ([r, a, u, p]) => {
53
- if (n(), !r?.length || !a?.length || !u?.length)
54
- return;
55
- const g = ee(p) ? { ...p } : p;
56
- t.push(
57
- ...r.flatMap(
58
- (h) => a.flatMap(
59
- (m) => u.map((k) => o(h, m, k, g))
60
- )
61
- )
62
- );
63
- },
64
- { flush: "post" }
65
- ), f = () => {
66
- c(), n();
67
- };
68
- return X(n), f;
29
+ function M(...e) {
30
+ let t = (e, t, n, r) => (e.addEventListener(t, n, r), () => e.removeEventListener(t, n, r)), n = i(() => {
31
+ let t = O(v(e[0])).filter((e) => e != null);
32
+ return t.every((e) => typeof e != "string") ? t : void 0;
33
+ });
34
+ return k(() => [
35
+ n.value?.map((e) => j(e)) ?? [A].filter((e) => e != null),
36
+ O(v(n.value ? e[1] : e[0])),
37
+ O(y(n.value ? e[2] : e[1])),
38
+ v(n.value ? e[3] : e[2])
39
+ ], ([e, n, r, i], a, o) => {
40
+ if (!e?.length || !n?.length || !r?.length) return;
41
+ let s = w(i) ? { ...i } : i, c = e.flatMap((e) => n.flatMap((n) => r.map((r) => t(e, n, r, s))));
42
+ o(() => {
43
+ c.forEach((e) => e());
44
+ });
45
+ }, { flush: "post" });
69
46
  }
70
- let T = !1;
71
- function le(e, t, n = {}) {
72
- const { window: o = W, ignore: s = [], capture: c = !0, detectIframe: f = !1, controls: r = !1 } = n;
73
- if (!o)
74
- return r ? { stop: y, cancel: y, trigger: y } : y;
75
- if (te && !T) {
76
- T = !0;
77
- const l = { passive: !0 };
78
- Array.from(o.document.body.children).forEach((i) => b(i, "click", y, l)), b(o.document.documentElement, "click", y, l);
79
- }
80
- let a = !0;
81
- const u = (l) => v(s).some((i) => {
82
- if (typeof i == "string")
83
- return Array.from(o.document.querySelectorAll(i)).some((d) => d === l.target || l.composedPath().includes(d));
84
- {
85
- const d = S(i);
86
- return d && (l.target === d || l.composedPath().includes(d));
87
- }
88
- });
89
- function p(l) {
90
- const i = v(l);
91
- return i && i.$.subTree.shapeFlag === 16;
92
- }
93
- function g(l, i) {
94
- const d = v(l), E = d.$.subTree && d.$.subTree.children;
95
- return E == null || !Array.isArray(E) ? !1 : E.some((O) => O.el === i.target || i.composedPath().includes(O.el));
96
- }
97
- const h = (l) => {
98
- const i = S(e);
99
- if (l.target != null && !(!(i instanceof Element) && p(e) && g(e, l)) && !(!i || i === l.target || l.composedPath().includes(i))) {
100
- if ("detail" in l && l.detail === 0 && (a = !u(l)), !a) {
101
- a = !0;
102
- return;
103
- }
104
- t(l);
105
- }
106
- };
107
- let m = !1;
108
- const k = [
109
- b(o, "click", (l) => {
110
- m || (m = !0, setTimeout(() => {
111
- m = !1;
112
- }, 0), h(l));
113
- }, { passive: !0, capture: c }),
114
- b(o, "pointerdown", (l) => {
115
- const i = S(e);
116
- a = !u(l) && !!(i && !l.composedPath().includes(i));
117
- }, { passive: !0 }),
118
- f && b(o, "blur", (l) => {
119
- setTimeout(() => {
120
- var i;
121
- const d = S(e);
122
- ((i = o.document.activeElement) == null ? void 0 : i.tagName) === "IFRAME" && !d?.contains(o.document.activeElement) && t(l);
123
- }, 0);
124
- }, { passive: !0 })
125
- ].filter(Boolean), A = () => k.forEach((l) => l());
126
- return r ? {
127
- stop: A,
128
- cancel: () => {
129
- a = !1;
130
- },
131
- trigger: (l) => {
132
- a = !0, h(l), a = !1;
133
- }
134
- } : A;
47
+ var N = !1;
48
+ function P(e, t, n = {}) {
49
+ let { window: r = A, ignore: i = [], capture: a = !0, detectIframe: o = !1, controls: s = !1 } = n;
50
+ if (!r) return s ? {
51
+ stop: T,
52
+ cancel: T,
53
+ trigger: T
54
+ } : T;
55
+ if (E && !N) {
56
+ N = !0;
57
+ let e = { passive: !0 };
58
+ Array.from(r.document.body.children).forEach((t) => t.addEventListener("click", T, e)), r.document.documentElement.addEventListener("click", T, e);
59
+ }
60
+ let c = !0, l = (e) => v(i).some((t) => {
61
+ if (typeof t == "string") return Array.from(r.document.querySelectorAll(t)).some((t) => t === e.target || e.composedPath().includes(t));
62
+ {
63
+ let n = j(t);
64
+ return n && (e.target === n || e.composedPath().includes(n));
65
+ }
66
+ });
67
+ function u(e) {
68
+ let t = v(e);
69
+ return t && t.$.subTree.shapeFlag === 16;
70
+ }
71
+ function d(e, t) {
72
+ let n = v(e), r = n.$.subTree && n.$.subTree.children;
73
+ return r == null || !Array.isArray(r) ? !1 : r.some((e) => e.el === t.target || t.composedPath().includes(e.el));
74
+ }
75
+ let f = (n) => {
76
+ let r = j(e);
77
+ if (n.target != null && !(!(r instanceof Element) && u(e) && d(e, n)) && !(!r || r === n.target || n.composedPath().includes(r))) {
78
+ if ("detail" in n && n.detail === 0 && (c = !l(n)), !c) {
79
+ c = !0;
80
+ return;
81
+ }
82
+ t(n);
83
+ }
84
+ }, p = !1, m = [
85
+ M(r, "click", (e) => {
86
+ p || (p = !0, setTimeout(() => {
87
+ p = !1;
88
+ }, 0), f(e));
89
+ }, {
90
+ passive: !0,
91
+ capture: a
92
+ }),
93
+ M(r, "pointerdown", (t) => {
94
+ let n = j(e);
95
+ c = !l(t) && !!(n && !t.composedPath().includes(n));
96
+ }, { passive: !0 }),
97
+ o && M(r, "blur", (n) => {
98
+ setTimeout(() => {
99
+ let i = j(e), a = r.document.activeElement;
100
+ for (; a?.shadowRoot;) a = a.shadowRoot.activeElement;
101
+ a?.tagName === "IFRAME" && !i?.contains(r.document.activeElement) && t(n);
102
+ }, 0);
103
+ }, { passive: !0 })
104
+ ].filter(Boolean), h = () => m.forEach((e) => e());
105
+ return s ? {
106
+ stop: h,
107
+ cancel: () => {
108
+ c = !1;
109
+ },
110
+ trigger: (e) => {
111
+ c = !0, f(e), c = !1;
112
+ }
113
+ } : h;
135
114
  }
136
- const se = { class: "badge" }, ce = {
137
- key: 0,
138
- class: "country"
139
- }, re = {
140
- name: "LocaleBadge"
141
- }, ae = /* @__PURE__ */ B({
142
- ...re,
143
- props: {
144
- locale: {
145
- required: !0,
146
- type: String
147
- }
148
- },
149
- setup(e) {
150
- const t = e, n = C(() => t.locale.slice(0, 2)), o = C(() => {
151
- const s = t.locale.split("-");
152
- if (s.length > 1)
153
- return s[1];
154
- });
155
- return (s, c) => (_(), L("span", se, [
156
- N(I(n.value) + " ", 1),
157
- o.value ? (_(), L("span", ce, I(o.value), 1)) : V("", !0)
158
- ]));
159
- }
160
- }), ie = (e, t) => {
161
- const n = e.__vccOpts || e;
162
- for (const [o, s] of t)
163
- n[o] = s;
164
- return n;
165
- }, ue = /* @__PURE__ */ ie(ae, [["__scopeId", "data-v-a48752bf"]]), de = { class: "locale" }, fe = {
166
- name: "LocaleOption"
167
- }, pe = /* @__PURE__ */ B({
168
- ...fe,
169
- props: {
170
- locale: {
171
- required: !0,
172
- type: String
173
- },
174
- name: {
175
- required: !0,
176
- type: String
177
- },
178
- showBadges: {
179
- default: !0,
180
- type: Boolean
181
- }
182
- },
183
- setup(e) {
184
- return (t, n) => (_(), L("div", de, [
185
- e.showBadges ? (_(), U(ue, {
186
- key: 0,
187
- locale: e.locale
188
- }, null, 8, ["locale"])) : V("", !0),
189
- N(" " + I(e.name), 1)
190
- ]));
191
- }
192
- }), q = (e) => {
193
- const t = `${e}.locale`;
194
- return { getLocale: () => localStorage.getItem(t) || void 0, setLocale: (s) => {
195
- s ? localStorage.setItem(t, s) : localStorage.removeItem(t);
196
- } };
197
- }, ge = { class: "locale truncated" }, me = { class: "truncated" }, he = { class: "dropdown" }, ve = ["onClick"], _e = {
198
- name: "LocaleSwitcher"
199
- }, Ee = /* @__PURE__ */ B({
200
- ..._e,
201
- props: {
202
- showBadges: {
203
- default: !0,
204
- type: Boolean
205
- }
206
- },
207
- setup(e) {
208
- const { availableLocales: t, locale: n, t: o } = F(), s = Q(), c = x(!1), f = (g) => {
209
- n.value = g, c.value = !1;
210
- const { setLocale: h } = q(s.slug);
211
- h(g);
212
- }, r = C(() => ({
213
- locale: n.value,
214
- name: u(n.value)
215
- })), a = () => {
216
- c.value = !c.value;
217
- }, u = (g) => o(`locales.${g}`), p = x(null);
218
- return le(p, (g) => {
219
- c.value = !1;
220
- }), (g, h) => (_(), L("nav", {
221
- ref_key: "dzangolabVueI18nLocaleSwitcher",
222
- ref: p,
223
- class: P(["locale-switcher", { expanded: c.value }])
224
- }, [
225
- w("div", {
226
- class: "locale-trigger",
227
- onClick: a
228
- }, [
229
- w("div", ge, I(r.value.name), 1),
230
- w("span", me, [
231
- Z(g.$slots, "icon", {}, () => [
232
- h[0] || (h[0] = w("svg", {
233
- "aria-label": "open user menu",
234
- fill: "none",
235
- viewBox: "0 0 24 24",
236
- xmlns: "http://www.w3.org/2000/svg"
237
- }, [
238
- w("path", {
239
- "clip-rule": "evenodd",
240
- "fill-rule": "evenodd",
241
- d: "M12 7C12.2652 7 12.5196 7.10536 12.7071 7.29289L19.7071 14.2929C20.0976 14.6834 20.0976 15.3166 19.7071 15.7071C19.3166 16.0976 18.6834 16.0976 18.2929 15.7071L12 9.41421L5.70711 15.7071C5.31658 16.0976 4.68342 16.0976 4.29289 15.7071C3.90237 15.3166 3.90237 14.6834 4.29289 14.2929L11.2929 7.29289C11.4804 7.10536 11.7348 7 12 7Z",
242
- fill: "currentColor"
243
- })
244
- ], -1))
245
- ])
246
- ])
247
- ]),
248
- w("ul", he, [
249
- (_(!0), L(H, null, J(M(t), (m) => (_(), L("li", {
250
- key: m,
251
- class: P([{ current: m === r.value.locale }, "truncated"]),
252
- onClick: (k) => f(m)
253
- }, [
254
- K(pe, {
255
- locale: m,
256
- name: u(m),
257
- "show-badges": e.showBadges
258
- }, null, 8, ["locale", "name", "show-badges"])
259
- ], 10, ve))), 128))
260
- ])
261
- ], 2));
262
- }
263
- }), we = {
264
- en: "English",
265
- "en-GB": "English (GB)",
266
- "en-US": "English (US)",
267
- fr: "Français",
268
- th: "ไทย"
269
- }, ye = (e) => {
270
- const t = {};
271
- for (const n of e)
272
- t[n] = {
273
- locales: we
274
- };
275
- return t;
276
- }, Le = (e, t) => {
277
- let n;
278
- return e.some((o) => {
279
- const s = o.split("-");
280
- let c = [];
281
- for (let f = 1; f <= s.length; f++)
282
- if (c = (c.length === 0 ? t : c).filter((r) => r.startsWith(s.slice(0, f).join("-"))), c.length === 1)
283
- return n = c[0], !0;
284
- }), n;
285
- }, be = (e, t) => {
286
- if (!t)
287
- return e;
288
- const n = {};
289
- for (const o in t) {
290
- const s = t[o], c = e[o];
291
- n[o] = c ? {
292
- ...c,
293
- ...s
294
- } : s;
295
- }
296
- for (const o in e) {
297
- if (n[o])
298
- continue;
299
- const s = t[o], c = e[o];
300
- n[o] = s ? {
301
- ...c,
302
- ...s
303
- } : c;
304
- }
305
- return n;
306
- }, Se = (e) => {
307
- const t = e.config.i18n, n = e.config.slug, { getLocale: o, setLocale: s } = q(n);
308
- let c = o();
309
- c || (c = Le(
310
- navigator.languages,
311
- t.supportedLocales
312
- ), s(c));
313
- const f = be(
314
- ye(t.supportedLocales),
315
- t?.messages
316
- );
317
- return G({
318
- ...t,
319
- globalInjection: !0,
320
- legacy: !1,
321
- locale: c,
322
- messages: f
323
- });
324
- }, $e = {
325
- install: (e, t) => {
326
- const n = Se(t);
327
- e.use(n);
328
- }
329
- };
330
- export {
331
- Ee as LocaleSwitcher,
332
- Se as createI18n,
333
- $e as default,
334
- Le as getPreferredLocale,
335
- be as prependMessages,
336
- Oe as useI18n,
337
- q as useLocaleStore
338
- };
115
+ //#endregion
116
+ //#region src/store.ts
117
+ var F = (e) => {
118
+ let t = `${e}.locale`;
119
+ return {
120
+ getLocale: () => localStorage.getItem(t) || void 0,
121
+ setLocale: (e) => {
122
+ e ? localStorage.setItem(t, e) : localStorage.removeItem(t);
123
+ }
124
+ };
125
+ }, I = { class: "badge" }, L = {
126
+ key: 0,
127
+ class: "country"
128
+ }, R = /*#__PURE__*/ ((e, t) => {
129
+ let n = e.__vccOpts || e;
130
+ for (let [e, r] of t) n[e] = r;
131
+ return n;
132
+ })(/* @__PURE__ */ d({
133
+ name: "LocaleBadge",
134
+ props: { locale: {
135
+ required: !0,
136
+ type: String
137
+ } },
138
+ setup(e) {
139
+ let t = e, n = i(() => t.locale.slice(0, 2)), r = i(() => {
140
+ let e = t.locale.split("-");
141
+ if (e.length > 1) return e[1];
142
+ });
143
+ return (e, t) => (p(), s("span", I, [l(_(n.value) + " ", 1), r.value ? (p(), s("span", L, _(r.value), 1)) : o("", !0)]));
144
+ }
145
+ }), [["__scopeId", "data-v-83bea1dd"]]), z = { class: "locale" }, B = /* @__PURE__ */ d({
146
+ name: "LocaleOption",
147
+ props: {
148
+ locale: {
149
+ required: !0,
150
+ type: String
151
+ },
152
+ name: {
153
+ required: !0,
154
+ type: String
155
+ },
156
+ showBadges: {
157
+ default: !0,
158
+ type: Boolean
159
+ }
160
+ },
161
+ setup(e) {
162
+ return (t, n) => (p(), s("div", z, [e.showBadges ? (p(), a(R, {
163
+ key: 0,
164
+ locale: e.locale
165
+ }, null, 8, ["locale"])) : o("", !0), l(" " + _(e.name), 1)]));
166
+ }
167
+ }), V = { class: "locale truncated" }, H = { class: "truncated" }, U = { class: "dropdown" }, W = ["onClick"], G = /* @__PURE__ */ d({
168
+ name: "LocaleSwitcher",
169
+ props: { showBadges: {
170
+ default: !0,
171
+ type: Boolean
172
+ } },
173
+ setup(e) {
174
+ let { availableLocales: t, locale: a, t: o } = n(), l = x(), d = m(!1), v = (e) => {
175
+ a.value = e, d.value = !1;
176
+ let { setLocale: t } = F(l.slug);
177
+ t(e);
178
+ }, b = i(() => ({
179
+ locale: a.value,
180
+ name: C(a.value)
181
+ })), S = () => {
182
+ d.value = !d.value;
183
+ }, C = (e) => o(`locales.${e}`), w = m(null);
184
+ return P(w, (e) => {
185
+ d.value = !1;
186
+ }), (n, i) => (p(), s("nav", {
187
+ ref_key: "dzangolabVueI18nLocaleSwitcher",
188
+ ref: w,
189
+ class: f(["locale-switcher", { expanded: d.value }])
190
+ }, [c("div", {
191
+ class: "locale-trigger",
192
+ onClick: S
193
+ }, [c("div", V, _(b.value.name), 1), c("span", H, [g(n.$slots, "icon", {}, () => [i[0] ||= c("svg", {
194
+ "aria-label": "open user menu",
195
+ fill: "none",
196
+ viewBox: "0 0 24 24",
197
+ xmlns: "http://www.w3.org/2000/svg"
198
+ }, [c("path", {
199
+ "clip-rule": "evenodd",
200
+ "fill-rule": "evenodd",
201
+ d: "M12 7C12.2652 7 12.5196 7.10536 12.7071 7.29289L19.7071 14.2929C20.0976 14.6834 20.0976 15.3166 19.7071 15.7071C19.3166 16.0976 18.6834 16.0976 18.2929 15.7071L12 9.41421L5.70711 15.7071C5.31658 16.0976 4.68342 16.0976 4.29289 15.7071C3.90237 15.3166 3.90237 14.6834 4.29289 14.2929L11.2929 7.29289C11.4804 7.10536 11.7348 7 12 7Z",
202
+ fill: "currentColor"
203
+ })], -1)])])]), c("ul", U, [(p(!0), s(r, null, h(y(t), (t) => (p(), s("li", {
204
+ key: t,
205
+ class: f([{ current: t === b.value.locale }, "truncated"]),
206
+ onClick: (e) => v(t)
207
+ }, [u(B, {
208
+ locale: t,
209
+ name: C(t),
210
+ "show-badges": e.showBadges
211
+ }, null, 8, [
212
+ "locale",
213
+ "name",
214
+ "show-badges"
215
+ ])], 10, W))), 128))])], 2));
216
+ }
217
+ }), K = {
218
+ en: "English",
219
+ "en-GB": "English (GB)",
220
+ "en-US": "English (US)",
221
+ fr: "Français",
222
+ th: "ไทย"
223
+ }, q = (e) => {
224
+ let t = {};
225
+ for (let n of e) t[n] = { locales: K };
226
+ return t;
227
+ }, J = (e, t) => {
228
+ let n;
229
+ return e.some((e) => {
230
+ let r = e.split("-"), i = [];
231
+ for (let e = 1; e <= r.length; e++) if (i = (i.length === 0 ? t : i).filter((t) => t.startsWith(r.slice(0, e).join("-"))), i.length === 1) return n = i[0], !0;
232
+ }), n;
233
+ }, Y = (e, t) => {
234
+ if (!t) return e;
235
+ let n = {};
236
+ for (let r in t) {
237
+ let i = t[r], a = e[r];
238
+ n[r] = a ? {
239
+ ...a,
240
+ ...i
241
+ } : i;
242
+ }
243
+ for (let r in e) {
244
+ if (n[r]) continue;
245
+ let i = t[r], a = e[r];
246
+ n[r] = i ? {
247
+ ...a,
248
+ ...i
249
+ } : a;
250
+ }
251
+ return n;
252
+ }, X = (t) => {
253
+ let n = t.config.i18n, r = t.config.slug, { getLocale: i, setLocale: a } = F(r), o = i();
254
+ o || (o = J(navigator.languages, n.supportedLocales), a(o));
255
+ let s = Y(q(n.supportedLocales), n?.messages);
256
+ return e({
257
+ ...n,
258
+ globalInjection: !0,
259
+ legacy: !1,
260
+ locale: o,
261
+ messages: s
262
+ });
263
+ }, Z = { install: (e, t) => {
264
+ let n = X(t);
265
+ e.use(n);
266
+ } };
267
+ //#endregion
268
+ export { G as LocaleSwitcher, X as createI18n, Z as default, J as getPreferredLocale, Y as prependMessages, t as useI18n, F as useLocaleStore };
@@ -1 +1 @@
1
- (function(f,k){typeof exports=="object"&&typeof module<"u"?k(exports,require("vue-i18n"),require("vue"),require("@prefabs.tech/vue3-config")):typeof define=="function"&&define.amd?define(["exports","vue-i18n","vue","@prefabs.tech/vue3-config"],k):(f=typeof globalThis<"u"?globalThis:f||self,k(f.PrefabsTechVue3I18n={},f.VueI18n,f.Vue,f.PrefabsTechVue3Config))})(this,(function(f,k,e,M){"use strict";function j(t){return e.getCurrentScope()?(e.onScopeDispose(t),!0):!1}const V=typeof window<"u"&&typeof document<"u";typeof WorkerGlobalScope<"u"&&globalThis instanceof WorkerGlobalScope;const v=Object.prototype.toString,q=t=>v.call(t)==="[object Object]",b=()=>{},x=D();function D(){var t,n;return V&&((t=window?.navigator)==null?void 0:t.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((n=window?.navigator)==null?void 0:n.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function E(t){return Array.isArray(t)?t:[t]}function W(t,n,o){return e.watch(t,n,{...o,immediate:!0})}const I=V?window:void 0;function w(t){var n;const o=e.toValue(t);return(n=o?.$el)!=null?n:o}function L(...t){const n=[],o=()=>{n.forEach(a=>a()),n.length=0},l=(a,i,d,g)=>(a.addEventListener(i,d,g),()=>a.removeEventListener(i,d,g)),r=e.computed(()=>{const a=E(e.toValue(t[0])).filter(i=>i!=null);return a.every(i=>typeof i!="string")?a:void 0}),s=W(()=>{var a,i;return[(i=(a=r.value)==null?void 0:a.map(d=>w(d)))!=null?i:[I].filter(d=>d!=null),E(e.toValue(r.value?t[1]:t[0])),E(e.unref(r.value?t[2]:t[1])),e.toValue(r.value?t[3]:t[2])]},([a,i,d,g])=>{if(o(),!a?.length||!i?.length||!d?.length)return;const h=q(g)?{...g}:g;n.push(...a.flatMap(y=>i.flatMap(_=>d.map(S=>l(y,_,S,h)))))},{flush:"post"}),m=()=>{s(),o()};return j(o),m}let P=!1;function z(t,n,o={}){const{window:l=I,ignore:r=[],capture:s=!0,detectIframe:m=!1,controls:a=!1}=o;if(!l)return a?{stop:b,cancel:b,trigger:b}:b;if(x&&!P){P=!0;const c={passive:!0};Array.from(l.document.body.children).forEach(u=>L(u,"click",b,c)),L(l.document.documentElement,"click",b,c)}let i=!0;const d=c=>e.toValue(r).some(u=>{if(typeof u=="string")return Array.from(l.document.querySelectorAll(u)).some(p=>p===c.target||c.composedPath().includes(p));{const p=w(u);return p&&(c.target===p||c.composedPath().includes(p))}});function g(c){const u=e.toValue(c);return u&&u.$.subTree.shapeFlag===16}function h(c,u){const p=e.toValue(c),C=p.$.subTree&&p.$.subTree.children;return C==null||!Array.isArray(C)?!1:C.some(A=>A.el===u.target||u.composedPath().includes(A.el))}const y=c=>{const u=w(t);if(c.target!=null&&!(!(u instanceof Element)&&g(t)&&h(t,c))&&!(!u||u===c.target||c.composedPath().includes(u))){if("detail"in c&&c.detail===0&&(i=!d(c)),!i){i=!0;return}n(c)}};let _=!1;const S=[L(l,"click",c=>{_||(_=!0,setTimeout(()=>{_=!1},0),y(c))},{passive:!0,capture:s}),L(l,"pointerdown",c=>{const u=w(t);i=!d(c)&&!!(u&&!c.composedPath().includes(u))},{passive:!0}),m&&L(l,"blur",c=>{setTimeout(()=>{var u;const p=w(t);((u=l.document.activeElement)==null?void 0:u.tagName)==="IFRAME"&&!p?.contains(l.document.activeElement)&&n(c)},0)},{passive:!0})].filter(Boolean),O=()=>S.forEach(c=>c());return a?{stop:O,cancel:()=>{i=!1},trigger:c=>{i=!0,y(c),i=!1}}:O}const F={class:"badge"},G={key:0,class:"country"},R={name:"LocaleBadge"},U=e.defineComponent({...R,props:{locale:{required:!0,type:String}},setup(t){const n=t,o=e.computed(()=>n.locale.slice(0,2)),l=e.computed(()=>{const r=n.locale.split("-");if(r.length>1)return r[1]});return(r,s)=>(e.openBlock(),e.createElementBlock("span",F,[e.createTextVNode(e.toDisplayString(o.value)+" ",1),l.value?(e.openBlock(),e.createElementBlock("span",G,e.toDisplayString(l.value),1)):e.createCommentVNode("",!0)]))}}),Z=((t,n)=>{const o=t.__vccOpts||t;for(const[l,r]of n)o[l]=r;return o})(U,[["__scopeId","data-v-a48752bf"]]),H={class:"locale"},J={name:"LocaleOption"},K=e.defineComponent({...J,props:{locale:{required:!0,type:String},name:{required:!0,type:String},showBadges:{default:!0,type:Boolean}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("div",H,[t.showBadges?(e.openBlock(),e.createBlock(Z,{key:0,locale:t.locale},null,8,["locale"])):e.createCommentVNode("",!0),e.createTextVNode(" "+e.toDisplayString(t.name),1)]))}}),B=t=>{const n=`${t}.locale`;return{getLocale:()=>localStorage.getItem(n)||void 0,setLocale:r=>{r?localStorage.setItem(n,r):localStorage.removeItem(n)}}},Q={class:"locale truncated"},X={class:"truncated"},Y={class:"dropdown"},ee=["onClick"],te={name:"LocaleSwitcher"},ne=e.defineComponent({...te,props:{showBadges:{default:!0,type:Boolean}},setup(t){const{availableLocales:n,locale:o,t:l}=k.useI18n(),r=M.useConfig(),s=e.ref(!1),m=h=>{o.value=h,s.value=!1;const{setLocale:y}=B(r.slug);y(h)},a=e.computed(()=>({locale:o.value,name:d(o.value)})),i=()=>{s.value=!s.value},d=h=>l(`locales.${h}`),g=e.ref(null);return z(g,h=>{s.value=!1}),(h,y)=>(e.openBlock(),e.createElementBlock("nav",{ref_key:"dzangolabVueI18nLocaleSwitcher",ref:g,class:e.normalizeClass(["locale-switcher",{expanded:s.value}])},[e.createElementVNode("div",{class:"locale-trigger",onClick:i},[e.createElementVNode("div",Q,e.toDisplayString(a.value.name),1),e.createElementVNode("span",X,[e.renderSlot(h.$slots,"icon",{},()=>[y[0]||(y[0]=e.createElementVNode("svg",{"aria-label":"open user menu",fill:"none",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},[e.createElementVNode("path",{"clip-rule":"evenodd","fill-rule":"evenodd",d:"M12 7C12.2652 7 12.5196 7.10536 12.7071 7.29289L19.7071 14.2929C20.0976 14.6834 20.0976 15.3166 19.7071 15.7071C19.3166 16.0976 18.6834 16.0976 18.2929 15.7071L12 9.41421L5.70711 15.7071C5.31658 16.0976 4.68342 16.0976 4.29289 15.7071C3.90237 15.3166 3.90237 14.6834 4.29289 14.2929L11.2929 7.29289C11.4804 7.10536 11.7348 7 12 7Z",fill:"currentColor"})],-1))])])]),e.createElementVNode("ul",Y,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n),_=>(e.openBlock(),e.createElementBlock("li",{key:_,class:e.normalizeClass([{current:_===a.value.locale},"truncated"]),onClick:S=>m(_)},[e.createVNode(K,{locale:_,name:d(_),"show-badges":t.showBadges},null,8,["locale","name","show-badges"])],10,ee))),128))])],2))}}),oe={en:"English","en-GB":"English (GB)","en-US":"English (US)",fr:"Français",th:"ไทย"},le=t=>{const n={};for(const o of t)n[o]={locales:oe};return n},T=(t,n)=>{let o;return t.some(l=>{const r=l.split("-");let s=[];for(let m=1;m<=r.length;m++)if(s=(s.length===0?n:s).filter(a=>a.startsWith(r.slice(0,m).join("-"))),s.length===1)return o=s[0],!0}),o},$=(t,n)=>{if(!n)return t;const o={};for(const l in n){const r=n[l],s=t[l];o[l]=s?{...s,...r}:r}for(const l in t){if(o[l])continue;const r=n[l],s=t[l];o[l]=r?{...s,...r}:s}return o},N=t=>{const n=t.config.i18n,o=t.config.slug,{getLocale:l,setLocale:r}=B(o);let s=l();s||(s=T(navigator.languages,n.supportedLocales),r(s));const m=$(le(n.supportedLocales),n?.messages);return k.createI18n({...n,globalInjection:!0,legacy:!1,locale:s,messages:m})},ce={install:(t,n)=>{const o=N(n);t.use(o)}};Object.defineProperty(f,"useI18n",{enumerable:!0,get:()=>k.useI18n}),f.LocaleSwitcher=ne,f.createI18n=N,f.default=ce,f.getPreferredLocale=T,f.prependMessages=$,f.useLocaleStore=B,Object.defineProperties(f,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("vue-i18n"),require("vue"),require("@prefabs.tech/vue3-config")):typeof define==`function`&&define.amd?define([`exports`,`vue-i18n`,`vue`,`@prefabs.tech/vue3-config`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.PrefabsTechVue3I18n={},e.VueI18n,e.Vue,e.PrefabsTechVue3Config))})(this,function(e,t,n,r){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var i=typeof window<`u`&&typeof document<`u`;typeof WorkerGlobalScope<`u`&&globalThis instanceof WorkerGlobalScope;var a=Object.prototype.toString,o=e=>a.call(e)===`[object Object]`,s=()=>{},c=l();function l(){var e,t;return i&&!!(!((e=window)==null||(e=e.navigator)==null)&&e.userAgent)&&(/iP(?:ad|hone|od)/.test(window.navigator.userAgent)||((t=window)==null||(t=t.navigator)==null?void 0:t.maxTouchPoints)>2&&/iPad|Macintosh/.test(window?.navigator.userAgent))}function u(e){return Array.isArray(e)?e:[e]}function d(e,t,r){return(0,n.watch)(e,t,{...r,immediate:!0})}var f=i?window:void 0;i&&window.document,i&&window.navigator,i&&window.location;function p(e){let t=(0,n.toValue)(e);return t?.$el??t}function m(...e){let t=(e,t,n,r)=>(e.addEventListener(t,n,r),()=>e.removeEventListener(t,n,r)),r=(0,n.computed)(()=>{let t=u((0,n.toValue)(e[0])).filter(e=>e!=null);return t.every(e=>typeof e!=`string`)?t:void 0});return d(()=>[r.value?.map(e=>p(e))??[f].filter(e=>e!=null),u((0,n.toValue)(r.value?e[1]:e[0])),u((0,n.unref)(r.value?e[2]:e[1])),(0,n.toValue)(r.value?e[3]:e[2])],([e,n,r,i],a,s)=>{if(!e?.length||!n?.length||!r?.length)return;let c=o(i)?{...i}:i,l=e.flatMap(e=>n.flatMap(n=>r.map(r=>t(e,n,r,c))));s(()=>{l.forEach(e=>e())})},{flush:`post`})}var h=!1;function g(e,t,r={}){let{window:i=f,ignore:a=[],capture:o=!0,detectIframe:l=!1,controls:u=!1}=r;if(!i)return u?{stop:s,cancel:s,trigger:s}:s;if(c&&!h){h=!0;let e={passive:!0};Array.from(i.document.body.children).forEach(t=>t.addEventListener(`click`,s,e)),i.document.documentElement.addEventListener(`click`,s,e)}let d=!0,g=e=>(0,n.toValue)(a).some(t=>{if(typeof t==`string`)return Array.from(i.document.querySelectorAll(t)).some(t=>t===e.target||e.composedPath().includes(t));{let n=p(t);return n&&(e.target===n||e.composedPath().includes(n))}});function _(e){let t=(0,n.toValue)(e);return t&&t.$.subTree.shapeFlag===16}function v(e,t){let r=(0,n.toValue)(e),i=r.$.subTree&&r.$.subTree.children;return i==null||!Array.isArray(i)?!1:i.some(e=>e.el===t.target||t.composedPath().includes(e.el))}let y=n=>{let r=p(e);if(n.target!=null&&!(!(r instanceof Element)&&_(e)&&v(e,n))&&!(!r||r===n.target||n.composedPath().includes(r))){if(`detail`in n&&n.detail===0&&(d=!g(n)),!d){d=!0;return}t(n)}},b=!1,x=[m(i,`click`,e=>{b||(b=!0,setTimeout(()=>{b=!1},0),y(e))},{passive:!0,capture:o}),m(i,`pointerdown`,t=>{let n=p(e);d=!g(t)&&!!(n&&!t.composedPath().includes(n))},{passive:!0}),l&&m(i,`blur`,n=>{setTimeout(()=>{let r=p(e),a=i.document.activeElement;for(;a?.shadowRoot;)a=a.shadowRoot.activeElement;a?.tagName===`IFRAME`&&!r?.contains(i.document.activeElement)&&t(n)},0)},{passive:!0})].filter(Boolean),S=()=>x.forEach(e=>e());return u?{stop:S,cancel:()=>{d=!1},trigger:e=>{d=!0,y(e),d=!1}}:S}var _=e=>{let t=`${e}.locale`;return{getLocale:()=>localStorage.getItem(t)||void 0,setLocale:e=>{e?localStorage.setItem(t,e):localStorage.removeItem(t)}}},v={class:`badge`},y={key:0,class:`country`},b=((e,t)=>{let n=e.__vccOpts||e;for(let[e,r]of t)n[e]=r;return n})((0,n.defineComponent)({name:`LocaleBadge`,props:{locale:{required:!0,type:String}},setup(e){let t=e,r=(0,n.computed)(()=>t.locale.slice(0,2)),i=(0,n.computed)(()=>{let e=t.locale.split(`-`);if(e.length>1)return e[1]});return(e,t)=>((0,n.openBlock)(),(0,n.createElementBlock)(`span`,v,[(0,n.createTextVNode)((0,n.toDisplayString)(r.value)+` `,1),i.value?((0,n.openBlock)(),(0,n.createElementBlock)(`span`,y,(0,n.toDisplayString)(i.value),1)):(0,n.createCommentVNode)(``,!0)]))}}),[[`__scopeId`,`data-v-83bea1dd`]]),x={class:`locale`},S=(0,n.defineComponent)({name:`LocaleOption`,props:{locale:{required:!0,type:String},name:{required:!0,type:String},showBadges:{default:!0,type:Boolean}},setup(e){return(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`div`,x,[e.showBadges?((0,n.openBlock)(),(0,n.createBlock)(b,{key:0,locale:e.locale},null,8,[`locale`])):(0,n.createCommentVNode)(``,!0),(0,n.createTextVNode)(` `+(0,n.toDisplayString)(e.name),1)]))}}),C={class:`locale truncated`},w={class:`truncated`},T={class:`dropdown`},E=[`onClick`],D=(0,n.defineComponent)({name:`LocaleSwitcher`,props:{showBadges:{default:!0,type:Boolean}},setup(e){let{availableLocales:i,locale:a,t:o}=(0,t.useI18n)(),s=(0,r.useConfig)(),c=(0,n.ref)(!1),l=e=>{a.value=e,c.value=!1;let{setLocale:t}=_(s.slug);t(e)},u=(0,n.computed)(()=>({locale:a.value,name:f(a.value)})),d=()=>{c.value=!c.value},f=e=>o(`locales.${e}`),p=(0,n.ref)(null);return g(p,e=>{c.value=!1}),(t,r)=>((0,n.openBlock)(),(0,n.createElementBlock)(`nav`,{ref_key:`dzangolabVueI18nLocaleSwitcher`,ref:p,class:(0,n.normalizeClass)([`locale-switcher`,{expanded:c.value}])},[(0,n.createElementVNode)(`div`,{class:`locale-trigger`,onClick:d},[(0,n.createElementVNode)(`div`,C,(0,n.toDisplayString)(u.value.name),1),(0,n.createElementVNode)(`span`,w,[(0,n.renderSlot)(t.$slots,`icon`,{},()=>[r[0]||=(0,n.createElementVNode)(`svg`,{"aria-label":`open user menu`,fill:`none`,viewBox:`0 0 24 24`,xmlns:`http://www.w3.org/2000/svg`},[(0,n.createElementVNode)(`path`,{"clip-rule":`evenodd`,"fill-rule":`evenodd`,d:`M12 7C12.2652 7 12.5196 7.10536 12.7071 7.29289L19.7071 14.2929C20.0976 14.6834 20.0976 15.3166 19.7071 15.7071C19.3166 16.0976 18.6834 16.0976 18.2929 15.7071L12 9.41421L5.70711 15.7071C5.31658 16.0976 4.68342 16.0976 4.29289 15.7071C3.90237 15.3166 3.90237 14.6834 4.29289 14.2929L11.2929 7.29289C11.4804 7.10536 11.7348 7 12 7Z`,fill:`currentColor`})],-1)])])]),(0,n.createElementVNode)(`ul`,T,[((0,n.openBlock)(!0),(0,n.createElementBlock)(n.Fragment,null,(0,n.renderList)((0,n.unref)(i),t=>((0,n.openBlock)(),(0,n.createElementBlock)(`li`,{key:t,class:(0,n.normalizeClass)([{current:t===u.value.locale},`truncated`]),onClick:e=>l(t)},[(0,n.createVNode)(S,{locale:t,name:f(t),"show-badges":e.showBadges},null,8,[`locale`,`name`,`show-badges`])],10,E))),128))])],2))}}),O={en:`English`,"en-GB":`English (GB)`,"en-US":`English (US)`,fr:`Français`,th:`ไทย`},k=e=>{let t={};for(let n of e)t[n]={locales:O};return t},A=(e,t)=>{let n;return e.some(e=>{let r=e.split(`-`),i=[];for(let e=1;e<=r.length;e++)if(i=(i.length===0?t:i).filter(t=>t.startsWith(r.slice(0,e).join(`-`))),i.length===1)return n=i[0],!0}),n},j=(e,t)=>{if(!t)return e;let n={};for(let r in t){let i=t[r],a=e[r];n[r]=a?{...a,...i}:i}for(let r in e){if(n[r])continue;let i=t[r],a=e[r];n[r]=i?{...a,...i}:a}return n},M=e=>{let n=e.config.i18n,r=e.config.slug,{getLocale:i,setLocale:a}=_(r),o=i();o||(o=A(navigator.languages,n.supportedLocales),a(o));let s=j(k(n.supportedLocales),n?.messages);return(0,t.createI18n)({...n,globalInjection:!0,legacy:!1,locale:o,messages:s})};e.LocaleSwitcher=D,e.createI18n=M,e.default={install:(e,t)=>{let n=M(t);e.use(n)}},e.getPreferredLocale=A,e.prependMessages=j,e.useI18n=t.useI18n,e.useLocaleStore=_});
@@ -1,10 +1,10 @@
1
+ import type { AppConfig } from "@prefabs.tech/vue3-config";
2
+ import type { App, Plugin } from "vue";
3
+ import type { I18nOptions, LocaleMessages, VueMessageType } from "vue-i18n";
1
4
  import { useI18n } from "vue-i18n";
2
5
  import LocaleSwitcher from "./locale-switcher/Index.vue";
3
6
  import useLocaleStore from "./store";
4
7
  import { getPreferredLocale, prependMessages } from "./utilities";
5
- import type { AppConfig } from "@prefabs.tech/vue3-config";
6
- import type { App, Plugin } from "vue";
7
- import type { I18nOptions, LocaleMessages, VueMessageType } from "vue-i18n";
8
8
  declare const createI18n: (options: DzangolabVueI18nPluginOptions) => Plugin;
9
9
  declare const plugin: {
10
10
  install: (app: App, options: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgC,OAAO,EAAE,MAAM,UAAU,CAAC;AAEjE,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,cAAc,MAAM,SAAS,CAAC;AACrC,OAAO,EAEL,kBAAkB,EAClB,eAAe,EAChB,MAAM,aAAa,CAAC;AAErB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE5E,QAAA,MAAM,UAAU,YAAa,6BAA6B,KAAG,MA+B5D,CAAC;AAEF,QAAA,MAAM,MAAM;mBACK,GAAG,WAAW;QAAE,MAAM,EAAE,SAAS,CAAA;KAAE,KAAG,IAAI;CAK1D,CAAC;AAEF,KAAK,oBAAoB,GAAG,WAAW,GAAG;IACxC,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,UAAU,6BAA6B;IACrC,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,OAAO,QAAQ,2BAA2B,CAAC;IACzC,UAAiB,SAAS;QACxB,IAAI,EAAE,oBAAoB,CAAC;KAC5B;CACF;AAED,eAAe,MAAM,CAAC;AAEtB,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,OAAO,EACP,cAAc,GACf,CAAC;AAEF,YAAY,EACV,oBAAoB,EACpB,6BAA6B,EAC7B,cAAc,EACd,cAAc,GACf,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE5E,OAAO,EAAgC,OAAO,EAAE,MAAM,UAAU,CAAC;AAEjE,OAAO,cAAc,MAAM,6BAA6B,CAAC;AACzD,OAAO,cAAc,MAAM,SAAS,CAAC;AACrC,OAAO,EAEL,kBAAkB,EAClB,eAAe,EAChB,MAAM,aAAa,CAAC;AAErB,QAAA,MAAM,UAAU,GAAI,SAAS,6BAA6B,KAAG,MA+B5D,CAAC;AAEF,QAAA,MAAM,MAAM;mBACK,GAAG,WAAW;QAAE,MAAM,EAAE,SAAS,CAAA;KAAE,KAAG,IAAI;CAK1D,CAAC;AAEF,KAAK,oBAAoB,GAAG,WAAW,GAAG;IACxC,gBAAgB,EAAE,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF,UAAU,6BAA6B;IACrC,MAAM,EAAE,SAAS,CAAC;CACnB;AAED,OAAO,QAAQ,2BAA2B,CAAC;IACzC,UAAiB,SAAS;QACxB,IAAI,EAAE,oBAAoB,CAAC;KAC5B;CACF;AAED,eAAe,MAAM,CAAC;AAEtB,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,eAAe,EACf,OAAO,EACP,cAAc,GACf,CAAC;AAEF,YAAY,EACV,oBAAoB,EACpB,6BAA6B,EAC7B,cAAc,EACd,cAAc,GACf,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import type { PropType } from "vue";
2
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
4
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
5
  locale: {
4
6
  required: true;
5
7
  type: PropType<string>;
@@ -10,5 +12,4 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
10
12
  type: PropType<string>;
11
13
  };
12
14
  }>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
13
- export default _default;
14
15
  //# sourceMappingURL=Badge.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Badge.vue.d.ts","sourceRoot":"","sources":["../../../src/locale-switcher/Badge.vue.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;;;;cA6BhB,QAAQ,CAAC,MAAM,CAAC;;;;;cAAhB,QAAQ,CAAC,MAAM,CAAC;;;AA1BpC,wBAiGc"}
1
+ {"version":3,"file":"Badge.vue.d.ts","sourceRoot":"","sources":["../../../src/locale-switcher/Badge.vue"],"names":[],"mappings":"AAoEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;wBAKf,OAAO,YAAY;AAAxC,wBAAyC;AAKzC,QAAA,MAAM,YAAY;;;cA8DE,QAAQ,CAAC,MAAM,CAAC;;;;;cAAhB,QAAQ,CAAC,MAAM,CAAC;;iGAIhC,CAAC"}
@@ -1,4 +1,6 @@
1
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
1
+ declare const _default: typeof __VLS_export;
2
+ export default _default;
3
+ declare const __VLS_export: __VLS_WithSlots<import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
4
  showBadges: {
3
5
  default: boolean;
4
6
  type: BooleanConstructor;
@@ -11,10 +13,9 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<im
11
13
  }>> & Readonly<{}>, {
12
14
  showBadges: boolean;
13
15
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>, {
14
- icon: (_: {}) => any;
16
+ icon?: (props: {}) => any;
15
17
  }>;
16
- export default _default;
17
- type __VLS_WithTemplateSlots<T, S> = T & {
18
+ type __VLS_WithSlots<T, S> = T & {
18
19
  new (): {
19
20
  $slots: S;
20
21
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Index.vue.d.ts","sourceRoot":"","sources":["../../../src/locale-switcher/Index.vue.ts"],"names":[],"mappings":";;;;;;;;;;;;;UA+KM,CAAC,CAAC,IAAgB,KAAK,GAAG;;AAlKhC,wBAuLc;AACd,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,QAAO;QAAE,MAAM,EAAE,CAAC,CAAA;KAAE,CAAA;CAAE,CAAC"}
1
+ {"version":3,"file":"Index.vue.d.ts","sourceRoot":"","sources":["../../../src/locale-switcher/Index.vue"],"names":[],"mappings":"wBA8HqB,OAAO,YAAY;AAAxC,wBAAyC;AAKzC,QAAA,MAAM,YAAY;;;;;;;;;;;;;WAwIP,CAAC,KAAK,IAAgB,KAAK,GAAG;EAgBrC,CAAC;AACL,KAAK,eAAe,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAChC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KACV,CAAA;CACD,CAAC"}
@@ -1,5 +1,7 @@
1
1
  import type { PropType } from "vue";
2
- declare const _default: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
2
+ declare const _default: typeof __VLS_export;
3
+ export default _default;
4
+ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
3
5
  locale: {
4
6
  required: true;
5
7
  type: PropType<string>;
@@ -28,5 +30,4 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
28
30
  }>> & Readonly<{}>, {
29
31
  showBadges: boolean;
30
32
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
31
- export default _default;
32
33
  //# sourceMappingURL=LocaleOption.vue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"LocaleOption.vue.d.ts","sourceRoot":"","sources":["../../../src/locale-switcher/LocaleOption.vue.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;;;;cAuBhB,QAAQ,CAAC,MAAM,CAAC;;;;cAIhB,QAAQ,CAAC,MAAM,CAAC;;;;;;;;;cAJhB,QAAQ,CAAC,MAAM,CAAC;;;;cAIhB,QAAQ,CAAC,MAAM,CAAC;;;;;;;;;AAxBpC,wBA+Fc"}
1
+ {"version":3,"file":"LocaleOption.vue.d.ts","sourceRoot":"","sources":["../../../src/locale-switcher/LocaleOption.vue"],"names":[],"mappings":"AA6CA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,KAAK,CAAC;wBAKf,OAAO,YAAY;AAAxC,wBAAyC;AAKzC,QAAA,MAAM,YAAY;;;cAmDE,QAAQ,CAAC,MAAM,CAAC;;;;cAIhB,QAAQ,CAAC,MAAM,CAAC;;;;;;;;;cAJhB,QAAQ,CAAC,MAAM,CAAC;;;;cAIhB,QAAQ,CAAC,MAAM,CAAC;;;;;;;;4EAQhC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,cAAc,SAAU,MAAM;qBAGZ,MAAM,GAAG,SAAS;wBAMb,MAAM,GAAG,SAAS,KAAG,IAAI;CASrD,CAAC;AAEF,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,cAAc,GAAI,MAAM,MAAM;qBAGZ,MAAM,GAAG,SAAS;wBAMb,MAAM,GAAG,SAAS,KAAG,IAAI;CASrD,CAAC;AAEF,eAAe,cAAc,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/utilities.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/D,QAAA,MAAM,cAAc,qBAAsB,MAAM,EAAE,mCAUjD,CAAC;AAEF,QAAA,MAAM,kBAAkB,cACX,SAAS,MAAM,EAAE,WACnB,MAAM,EAAE,KAChB,MAAM,GAAG,SAsBX,CAAC;AAEF,QAAA,MAAM,eAAe,aACT,cAAc,CAAC,cAAc,CAAC,YAC9B,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,KACnD,cAAc,CAAC,cAAc,CAoC/B,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"utilities.d.ts","sourceRoot":"","sources":["../../src/utilities.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAI/D,QAAA,MAAM,cAAc,GAAI,kBAAkB,MAAM,EAAE,mCAUjD,CAAC;AAEF,QAAA,MAAM,kBAAkB,GACtB,WAAW,SAAS,MAAM,EAAE,EAC5B,SAAS,MAAM,EAAE,KAChB,MAAM,GAAG,SAsBX,CAAC;AAEF,QAAA,MAAM,eAAe,GACnB,UAAU,cAAc,CAAC,cAAc,CAAC,EACxC,UAAU,cAAc,CAAC,cAAc,CAAC,GAAG,SAAS,KACnD,cAAc,CAAC,cAAc,CAoC/B,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,CAAC"}
@@ -1 +1,2 @@
1
- .country[data-v-a48752bf]{bottom:-.35rem;background:var(--locale-switcher-badge-country-bf-color, #007aff);color:var(--locale-switcher-badge-country-color, #fff);font-size:.5rem;font-weight:700;line-height:1.25;padding:1px 2px;position:absolute;right:-.25rem}.badge[data-v-a48752bf]{align-items:center;background-color:var(--locale-switcher-badge-bg-color, #007aff);border-radius:50%;display:flex;font-size:.9rem;height:2em;justify-content:center;position:relative;text-align:center;width:2em}.locale{align-items:center;display:flex;gap:.5rem;justify-content:flex-start}nav.locale-switcher{--_hover-bg: var(--nav-item-hover-bg, #f0f2f7ad);--_hover-color: var(--nav-item-hover-color, #2c2c2c);--_width: var(--locale-switcher-width, 10rem);border-radius:.325rem;cursor:pointer;padding:0;position:relative;width:var(--_width)}nav.locale-switcher.expanded,nav.locale-switcher:hover{background:var(--_hover-bg);color:var(--_hover-color)}nav.locale-switcher>.locale-trigger{--_padding-h: var(--locale-switcher-padding-h, 1rem);--_padding-v: var(--locale-switcher-padding-v, .625rem);align-items:center;display:flex;gap:0;justify-content:space-between;padding:var(--_padding-v) var(--_padding-h)}.locale{flex:1}nav.locale-switcher>.locale-trigger>span{font-size:1.5rem;line-height:1.25rem;text-align:center;width:1rem}nav.locale-switcher>ul.dropdown{--_bg-color: var(--locale-switcher-bg-color, #fff);--_min-width: var(--locale-switcher-width, 10rem);background-color:var(--_bg-color);border:var(--_border);border-radius:.325rem;max-height:0;inset:0 0 auto auto;list-style:none;min-width:var(--_min-width);overflow-y:hidden;padding-inline-start:0;position:absolute;transform:translate3d(0,56px,0);transition:max-height .3s ease-out;z-index:1000}nav.locale-switcher.expanded ul{--_border: var(--locale-switcher-border, 1px solid #e5e5e5);box-shadow:1px 1px 5px 1px #e5e5e5;height:auto;max-height:30rem;padding-block:.15rem}nav.locale-switcher>.dropdown>li{--_active-bg: var(--nav-item-active-bg, #eff6ff);--_active-color: var(--nav-item-active-color, #2c2c2c);--_hover-bg: var(--nav-item-hover-bg, #f0f2f7ad);--_hover-color: var(--nav-item-hover-color, #2c2c2c);cursor:pointer;list-style:none;padding:.7rem 1.25rem}nav.locale-switcher.expanded li:hover{background:var(--_hover-bg);color:var(--_hover-color)}nav.locale-switcher>.dropdown>li.current{background-color:var(--_active-bg);color:var(--_active-color)}.locale-switcher .truncated{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.locale-switcher .truncated>svg{transition:transform .3s ease}nav.locale-switcher.expanded .truncated>svg{transform:rotate(-180deg)}
1
+ .country[data-v-83bea1dd]{background:var(--locale-switcher-badge-country-bf-color,#007aff);color:var(--locale-switcher-badge-country-color,#fff);padding:1px 2px;font-size:.5rem;font-weight:700;line-height:1.25;position:absolute;bottom:-.35rem;right:-.25rem}.badge[data-v-83bea1dd]{background-color:var(--locale-switcher-badge-bg-color,#007aff);text-align:center;border-radius:50%;justify-content:center;align-items:center;width:2em;height:2em;font-size:.9rem;display:flex;position:relative}ul.dropdown .locale{justify-content:flex-start;align-items:center;gap:.5rem;display:flex}nav.locale-switcher{--_hover-bg:var(--nav-item-hover-bg,#f0f2f7ad);--_hover-color:var(--nav-item-hover-color,#2c2c2c);--_width:var(--locale-switcher-width,10rem);cursor:pointer;width:var(--_width);border-radius:.325rem;padding:0;position:relative}nav.locale-switcher.expanded>.locale-trigger,nav.locale-switcher>.locale-trigger:hover{background:var(--_hover-bg);color:var(--_hover-color)}nav.locale-switcher>.locale-trigger{--_padding-h:var(--locale-switcher-padding-h,1rem);--_padding-v:var(--locale-switcher-padding-v,.625rem);padding:var(--_padding-v) var(--_padding-h);justify-content:space-between;align-items:center;gap:0;display:flex}.locale{flex:1}nav.locale-switcher>.locale-trigger>span{text-align:center;width:1rem;font-size:1.5rem;line-height:1.25rem}nav.locale-switcher>ul.dropdown{--_bg-color:var(--locale-switcher-bg-color,#fff);--_min-width:var(--locale-switcher-width,10rem);background-color:var(--_bg-color);border:var(--_border);max-height:0;min-width:var(--_min-width);z-index:1000;border-radius:.325rem;padding-inline-start:0;list-style:none;transition:max-height .3s ease-out;position:absolute;inset:0 0 auto auto;overflow-y:hidden;transform:translateY(56px)}nav.locale-switcher.expanded ul{--_border:var(--locale-switcher-border,1px solid #e5e5e5);height:auto;max-height:30rem;padding-block:.15rem;box-shadow:1px 1px 5px 1px #e5e5e5}nav.locale-switcher>.dropdown>li{--_active-bg:var(--nav-item-active-bg,#eff6ff);--_active-color:var(--nav-item-active-color,#2c2c2c);--_hover-bg:var(--nav-item-hover-bg,#f0f2f7ad);--_hover-color:var(--nav-item-hover-color,#2c2c2c);cursor:pointer;padding:.7rem 1.25rem;list-style:none}nav.locale-switcher.expanded li:hover{background:var(--_hover-bg);color:var(--_hover-color)}nav.locale-switcher>.dropdown>li.current{background-color:var(--_active-bg);color:var(--_active-color)}.locale-switcher .truncated{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.locale-switcher .truncated>svg{transition:transform .3s}nav.locale-switcher.expanded .truncated>svg{transform:rotate(-180deg)}
2
+ /*$vite$:1*/
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prefabs.tech/vue3-i18n",
3
- "version": "0.31.0",
3
+ "version": "0.33.0",
4
4
  "description": "Vue3 I18n Plugin",
5
5
  "type": "module",
6
6
  "exports": {
@@ -21,29 +21,34 @@
21
21
  "vue-i18n": "9.1.10"
22
22
  },
23
23
  "devDependencies": {
24
- "@prefabs.tech/eslint-config": "0.4.0",
25
- "@prefabs.tech/tsconfig": "0.4.0",
26
- "@prefabs.tech/vue3-config": "0.31.0",
27
- "@types/node": "24.10.1",
28
- "@vitejs/plugin-vue": "6.0.4",
29
- "@vitejs/plugin-vue-jsx": "5.1.4",
30
- "@vitest/coverage-istanbul": "4.0.18",
31
- "@vueuse/core": "12.7.0",
32
- "eslint": "9.39.2",
33
- "prettier": "3.8.1",
34
- "jsdom": "27.0.1",
35
- "pinia": "3.0.4",
36
- "typescript": "5.5.4",
37
- "vite": "7.3.1",
38
- "vitest": "4.0.18",
39
- "vue": "3.5.27",
40
- "vue-tsc": "1.2.0"
24
+ "@prefabs.tech/eslint-config": "0.8.7",
25
+ "@prefabs.tech/stylelint-config": "0.8.7",
26
+ "@prefabs.tech/tsconfig": "0.8.7",
27
+ "@prefabs.tech/vue3-config": "0.33.0",
28
+ "@types/node": "26.1.1",
29
+ "@vitejs/plugin-vue": "6.0.8",
30
+ "@vitejs/plugin-vue-jsx": "5.1.6",
31
+ "@vitest/coverage-istanbul": "4.1.10",
32
+ "@vue/test-utils": "2.4.11",
33
+ "@vueuse/core": "14.3.0",
34
+ "eslint": "10.7.0",
35
+ "prettier": "3.9.5",
36
+ "jsdom": "29.1.1",
37
+ "pinia": "4.0.2",
38
+ "stylelint": "17.14.1",
39
+ "stylelint-config-recommended-vue": "1.6.1",
40
+ "stylelint-order": "8.1.1",
41
+ "typescript": "6.0.3",
42
+ "vite": "8.1.5",
43
+ "vitest": "4.1.10",
44
+ "vue": "3.5.40",
45
+ "vue-tsc": "3.3.7"
41
46
  },
42
47
  "peerDependencies": {
43
- "@prefabs.tech/vue3-config": "0.31.0",
44
- "@vueuse/core": ">=9.4.0",
45
- "pinia": ">=2.0",
46
- "vue": ">=3.2"
48
+ "@prefabs.tech/vue3-config": "0.33.0",
49
+ "@vueuse/core": ">=14.3.0",
50
+ "pinia": ">=4.0",
51
+ "vue": ">=3.5"
47
52
  },
48
53
  "engines": {
49
54
  "node": ">=18",
@@ -55,11 +60,13 @@
55
60
  "lint:fix": "eslint . --fix",
56
61
  "snapshot:update": "vitest --environment jsdom run --update",
57
62
  "sort-package": "npx sort-package-json",
63
+ "stylelint": "stylelint \"src/**/*.{css,vue}\" --allow-empty-input",
64
+ "stylelint:fix": "stylelint \"src/**/*.{css,vue}\" --fix --allow-empty-input",
58
65
  "test": "vitest --environment jsdom run --coverage --passWithNoTests",
59
66
  "test:component": "vitest --environment jsdom run component/ --passWithNoTests",
60
67
  "test:snapshot": "vitest --environment jsdom run snapshot/ --passWithNoTests",
61
68
  "test:unit": "vitest --environment jsdom run unit/ --passWithNoTests",
62
69
  "test:watch": "vitest",
63
- "typecheck": "vue-tsc --noEmit -p tsconfig.json --composite false"
70
+ "typecheck": "vue-tsc --noEmit -p tsconfig.vitest.json --composite false"
64
71
  }
65
72
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=LocaleNames.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LocaleNames.test.d.ts","sourceRoot":"","sources":["../../../../src/__test__/unit/LocaleNames.test.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=PreferredLocale.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PreferredLocale.spec.d.ts","sourceRoot":"","sources":["../../../../src/__test__/unit/PreferredLocale.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=PrependMessages.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PrependMessages.spec.d.ts","sourceRoot":"","sources":["../../../../src/__test__/unit/PrependMessages.spec.ts"],"names":[],"mappings":""}