@prefabs.tech/vue3-i18n 0.14.0 → 0.15.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,23 +1,23 @@
|
|
|
1
|
-
import { useI18n as
|
|
2
|
-
import { useI18n as
|
|
3
|
-
import { watch as
|
|
4
|
-
import { useConfig as
|
|
5
|
-
function
|
|
6
|
-
return
|
|
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, createElementBlock as L, openBlock as _, createTextVNode as N, createCommentVNode as V, toDisplayString as I, 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
7
|
}
|
|
8
|
-
const
|
|
8
|
+
const j = typeof window < "u" && typeof document < "u";
|
|
9
9
|
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
|
|
10
|
-
const
|
|
11
|
-
},
|
|
12
|
-
function
|
|
10
|
+
const Y = Object.prototype.toString, ee = (e) => Y.call(e) === "[object Object]", y = () => {
|
|
11
|
+
}, te = /* @__PURE__ */ ne();
|
|
12
|
+
function ne() {
|
|
13
13
|
var e, t;
|
|
14
|
-
return
|
|
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));
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function $(e) {
|
|
17
17
|
return Array.isArray(e) ? e : [e];
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function oe(e, t, n) {
|
|
20
|
+
return z(
|
|
21
21
|
e,
|
|
22
22
|
t,
|
|
23
23
|
{
|
|
@@ -26,36 +26,36 @@ function le(e, t, n) {
|
|
|
26
26
|
}
|
|
27
27
|
);
|
|
28
28
|
}
|
|
29
|
-
const
|
|
30
|
-
function
|
|
29
|
+
const W = j ? window : void 0;
|
|
30
|
+
function S(e) {
|
|
31
31
|
var t;
|
|
32
32
|
const n = v(e);
|
|
33
33
|
return (t = n?.$el) != null ? t : n;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function b(...e) {
|
|
36
36
|
const t = [], n = () => {
|
|
37
37
|
t.forEach((a) => a()), t.length = 0;
|
|
38
|
-
}, o = (a,
|
|
39
|
-
const a =
|
|
40
|
-
return a.every((
|
|
41
|
-
}),
|
|
38
|
+
}, o = (a, c, u, p) => (a.addEventListener(c, u, p), () => a.removeEventListener(c, u, p)), l = C(() => {
|
|
39
|
+
const a = $(v(e[0])).filter((c) => c != null);
|
|
40
|
+
return a.every((c) => typeof c != "string") ? a : void 0;
|
|
41
|
+
}), r = oe(
|
|
42
42
|
() => {
|
|
43
|
-
var a,
|
|
43
|
+
var a, c;
|
|
44
44
|
return [
|
|
45
|
-
(
|
|
46
|
-
|
|
47
|
-
|
|
45
|
+
(c = (a = l.value) == null ? void 0 : a.map((u) => S(u))) != null ? c : [W].filter((u) => u != null),
|
|
46
|
+
$(v(l.value ? e[1] : e[0])),
|
|
47
|
+
$(M(l.value ? e[2] : e[1])),
|
|
48
48
|
// @ts-expect-error - TypeScript gets the correct types, but somehow still complains
|
|
49
49
|
v(l.value ? e[3] : e[2])
|
|
50
50
|
];
|
|
51
51
|
},
|
|
52
|
-
([a,
|
|
53
|
-
if (n(), !a?.length || !
|
|
52
|
+
([a, c, u, p]) => {
|
|
53
|
+
if (n(), !a?.length || !c?.length || !u?.length)
|
|
54
54
|
return;
|
|
55
|
-
const g =
|
|
55
|
+
const g = ee(p) ? { ...p } : p;
|
|
56
56
|
t.push(
|
|
57
57
|
...a.flatMap(
|
|
58
|
-
(h) =>
|
|
58
|
+
(h) => c.flatMap(
|
|
59
59
|
(m) => u.map((k) => o(h, m, k, g))
|
|
60
60
|
)
|
|
61
61
|
)
|
|
@@ -63,26 +63,26 @@ function S(...e) {
|
|
|
63
63
|
},
|
|
64
64
|
{ flush: "post" }
|
|
65
65
|
), f = () => {
|
|
66
|
-
|
|
66
|
+
r(), n();
|
|
67
67
|
};
|
|
68
|
-
return
|
|
68
|
+
return X(n), f;
|
|
69
69
|
}
|
|
70
|
-
let
|
|
71
|
-
function
|
|
72
|
-
const { window: o =
|
|
70
|
+
let T = !1;
|
|
71
|
+
function le(e, t, n = {}) {
|
|
72
|
+
const { window: o = W, ignore: l = [], capture: r = !0, detectIframe: f = !1, controls: a = !1 } = n;
|
|
73
73
|
if (!o)
|
|
74
74
|
return a ? { stop: y, cancel: y, trigger: y } : y;
|
|
75
|
-
if (
|
|
76
|
-
|
|
75
|
+
if (te && !T) {
|
|
76
|
+
T = !0;
|
|
77
77
|
const s = { passive: !0 };
|
|
78
|
-
Array.from(o.document.body.children).forEach((i) =>
|
|
78
|
+
Array.from(o.document.body.children).forEach((i) => b(i, "click", y, s)), b(o.document.documentElement, "click", y, s);
|
|
79
79
|
}
|
|
80
|
-
let
|
|
80
|
+
let c = !0;
|
|
81
81
|
const u = (s) => v(l).some((i) => {
|
|
82
82
|
if (typeof i == "string")
|
|
83
83
|
return Array.from(o.document.querySelectorAll(i)).some((d) => d === s.target || s.composedPath().includes(d));
|
|
84
84
|
{
|
|
85
|
-
const d =
|
|
85
|
+
const d = S(i);
|
|
86
86
|
return d && (s.target === d || s.composedPath().includes(d));
|
|
87
87
|
}
|
|
88
88
|
});
|
|
@@ -91,14 +91,14 @@ function se(e, t, n = {}) {
|
|
|
91
91
|
return i && i.$.subTree.shapeFlag === 16;
|
|
92
92
|
}
|
|
93
93
|
function g(s, i) {
|
|
94
|
-
const d = v(s),
|
|
95
|
-
return
|
|
94
|
+
const d = v(s), 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
96
|
}
|
|
97
97
|
const h = (s) => {
|
|
98
|
-
const i =
|
|
98
|
+
const i = S(e);
|
|
99
99
|
if (s.target != null && !(!(i instanceof Element) && p(e) && g(e, s)) && !(!i || i === s.target || s.composedPath().includes(i))) {
|
|
100
|
-
if ("detail" in s && s.detail === 0 && (
|
|
101
|
-
|
|
100
|
+
if ("detail" in s && s.detail === 0 && (c = !u(s)), !c) {
|
|
101
|
+
c = !0;
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
t(s);
|
|
@@ -106,40 +106,40 @@ function se(e, t, n = {}) {
|
|
|
106
106
|
};
|
|
107
107
|
let m = !1;
|
|
108
108
|
const k = [
|
|
109
|
-
|
|
109
|
+
b(o, "click", (s) => {
|
|
110
110
|
m || (m = !0, setTimeout(() => {
|
|
111
111
|
m = !1;
|
|
112
112
|
}, 0), h(s));
|
|
113
|
-
}, { passive: !0, capture:
|
|
114
|
-
|
|
115
|
-
const i =
|
|
116
|
-
|
|
113
|
+
}, { passive: !0, capture: r }),
|
|
114
|
+
b(o, "pointerdown", (s) => {
|
|
115
|
+
const i = S(e);
|
|
116
|
+
c = !u(s) && !!(i && !s.composedPath().includes(i));
|
|
117
117
|
}, { passive: !0 }),
|
|
118
|
-
f &&
|
|
118
|
+
f && b(o, "blur", (s) => {
|
|
119
119
|
setTimeout(() => {
|
|
120
120
|
var i;
|
|
121
|
-
const d =
|
|
121
|
+
const d = S(e);
|
|
122
122
|
((i = o.document.activeElement) == null ? void 0 : i.tagName) === "IFRAME" && !d?.contains(o.document.activeElement) && t(s);
|
|
123
123
|
}, 0);
|
|
124
124
|
}, { passive: !0 })
|
|
125
|
-
].filter(Boolean),
|
|
125
|
+
].filter(Boolean), A = () => k.forEach((s) => s());
|
|
126
126
|
return a ? {
|
|
127
|
-
stop:
|
|
127
|
+
stop: A,
|
|
128
128
|
cancel: () => {
|
|
129
|
-
|
|
129
|
+
c = !1;
|
|
130
130
|
},
|
|
131
131
|
trigger: (s) => {
|
|
132
|
-
|
|
132
|
+
c = !0, h(s), c = !1;
|
|
133
133
|
}
|
|
134
|
-
} :
|
|
134
|
+
} : A;
|
|
135
135
|
}
|
|
136
|
-
const
|
|
136
|
+
const se = { class: "badge" }, re = {
|
|
137
137
|
key: 0,
|
|
138
138
|
class: "country"
|
|
139
|
-
},
|
|
139
|
+
}, ce = {
|
|
140
140
|
name: "LocaleBadge"
|
|
141
|
-
},
|
|
142
|
-
...
|
|
141
|
+
}, ae = /* @__PURE__ */ B({
|
|
142
|
+
...ce,
|
|
143
143
|
props: {
|
|
144
144
|
locale: {
|
|
145
145
|
required: !0,
|
|
@@ -147,24 +147,24 @@ const ce = { class: "badge" }, re = {
|
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
149
|
setup(e) {
|
|
150
|
-
const t = e, n =
|
|
150
|
+
const t = e, n = C(() => t.locale.substring(0, 2)), o = C(() => {
|
|
151
151
|
const l = t.locale.split("-");
|
|
152
152
|
if (l.length > 1)
|
|
153
153
|
return l[1];
|
|
154
154
|
});
|
|
155
|
-
return (l,
|
|
156
|
-
|
|
157
|
-
o.value ? (_(), L("span", re,
|
|
155
|
+
return (l, r) => (_(), L("span", se, [
|
|
156
|
+
N(I(n.value) + " ", 1),
|
|
157
|
+
o.value ? (_(), L("span", re, I(o.value), 1)) : V("", !0)
|
|
158
158
|
]));
|
|
159
159
|
}
|
|
160
|
-
}),
|
|
160
|
+
}), ie = (e, t) => {
|
|
161
161
|
const n = e.__vccOpts || e;
|
|
162
162
|
for (const [o, l] of t)
|
|
163
163
|
n[o] = l;
|
|
164
164
|
return n;
|
|
165
|
-
}, ue = /* @__PURE__ */
|
|
165
|
+
}, ue = /* @__PURE__ */ ie(ae, [["__scopeId", "data-v-c1291edf"]]), de = { class: "locale" }, fe = {
|
|
166
166
|
name: "LocaleOption"
|
|
167
|
-
}, pe = /* @__PURE__ */
|
|
167
|
+
}, pe = /* @__PURE__ */ B({
|
|
168
168
|
...fe,
|
|
169
169
|
props: {
|
|
170
170
|
locale: {
|
|
@@ -182,14 +182,14 @@ const ce = { class: "badge" }, re = {
|
|
|
182
182
|
},
|
|
183
183
|
setup(e) {
|
|
184
184
|
return (t, n) => (_(), L("div", de, [
|
|
185
|
-
e.showBadges ? (_(),
|
|
185
|
+
e.showBadges ? (_(), U(ue, {
|
|
186
186
|
key: 0,
|
|
187
187
|
locale: e.locale
|
|
188
|
-
}, null, 8, ["locale"])) :
|
|
189
|
-
|
|
188
|
+
}, null, 8, ["locale"])) : V("", !0),
|
|
189
|
+
N(" " + I(e.name), 1)
|
|
190
190
|
]));
|
|
191
191
|
}
|
|
192
|
-
}),
|
|
192
|
+
}), q = (e) => {
|
|
193
193
|
const t = `${e}.locale`;
|
|
194
194
|
return { getLocale: () => {
|
|
195
195
|
const l = localStorage.getItem(t);
|
|
@@ -197,10 +197,10 @@ const ce = { class: "badge" }, re = {
|
|
|
197
197
|
}, setLocale: (l) => {
|
|
198
198
|
l ? localStorage.setItem(t, l) : localStorage.removeItem(t);
|
|
199
199
|
} };
|
|
200
|
-
},
|
|
200
|
+
}, ge = { class: "locale truncated" }, me = { class: "truncated" }, he = { class: "dropdown" }, ve = ["onClick"], _e = {
|
|
201
201
|
name: "LocaleSwitcher"
|
|
202
|
-
},
|
|
203
|
-
...
|
|
202
|
+
}, Ee = /* @__PURE__ */ B({
|
|
203
|
+
..._e,
|
|
204
204
|
props: {
|
|
205
205
|
showBadges: {
|
|
206
206
|
default: !0,
|
|
@@ -208,134 +208,136 @@ const ce = { class: "badge" }, re = {
|
|
|
208
208
|
}
|
|
209
209
|
},
|
|
210
210
|
setup(e) {
|
|
211
|
-
const { availableLocales: t, locale: n, t: o } =
|
|
212
|
-
n.value = g,
|
|
213
|
-
const { setLocale: h } =
|
|
211
|
+
const { availableLocales: t, locale: n, t: o } = F(), l = Q(), r = x(!1), f = (g) => {
|
|
212
|
+
n.value = g, r.value = !1;
|
|
213
|
+
const { setLocale: h } = q(l.slug);
|
|
214
214
|
h(g);
|
|
215
|
-
}, a =
|
|
215
|
+
}, a = C(() => ({
|
|
216
216
|
locale: n.value,
|
|
217
217
|
name: u(n.value)
|
|
218
|
-
})),
|
|
219
|
-
|
|
220
|
-
}, u = (g) => o(`locales.${g}`), p =
|
|
221
|
-
return
|
|
222
|
-
|
|
218
|
+
})), c = () => {
|
|
219
|
+
r.value = !r.value;
|
|
220
|
+
}, u = (g) => o(`locales.${g}`), p = x(null);
|
|
221
|
+
return le(p, (g) => {
|
|
222
|
+
r.value = !1;
|
|
223
223
|
}), (g, h) => (_(), L("nav", {
|
|
224
224
|
ref_key: "dzangolabVueI18nLocaleSwitcher",
|
|
225
225
|
ref: p,
|
|
226
|
-
class:
|
|
226
|
+
class: P(["locale-switcher", { expanded: r.value }])
|
|
227
227
|
}, [
|
|
228
228
|
w("div", {
|
|
229
229
|
class: "locale-trigger",
|
|
230
|
-
onClick:
|
|
230
|
+
onClick: c
|
|
231
231
|
}, [
|
|
232
|
-
w("div",
|
|
233
|
-
w("span",
|
|
234
|
-
|
|
232
|
+
w("div", ge, I(a.value.name), 1),
|
|
233
|
+
w("span", me, [
|
|
234
|
+
Z(g.$slots, "icon", {}, () => [
|
|
235
235
|
h[0] || (h[0] = w("svg", {
|
|
236
|
-
|
|
236
|
+
"aria-label": "open user menu",
|
|
237
|
+
fill: "none",
|
|
237
238
|
viewBox: "0 0 24 24",
|
|
238
|
-
width: "24",
|
|
239
239
|
xmlns: "http://www.w3.org/2000/svg"
|
|
240
240
|
}, [
|
|
241
241
|
w("path", {
|
|
242
|
-
|
|
242
|
+
"clip-rule": "evenodd",
|
|
243
|
+
"fill-rule": "evenodd",
|
|
244
|
+
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",
|
|
243
245
|
fill: "currentColor"
|
|
244
246
|
})
|
|
245
247
|
], -1))
|
|
246
|
-
]
|
|
248
|
+
])
|
|
247
249
|
])
|
|
248
250
|
]),
|
|
249
|
-
w("ul",
|
|
250
|
-
(_(!0), L(
|
|
251
|
+
w("ul", he, [
|
|
252
|
+
(_(!0), L(H, null, J(M(t), (m) => (_(), L("li", {
|
|
251
253
|
key: m,
|
|
252
|
-
class:
|
|
254
|
+
class: P([{ current: m === a.value.locale }, "truncated"]),
|
|
253
255
|
onClick: (k) => f(m)
|
|
254
256
|
}, [
|
|
255
|
-
|
|
257
|
+
K(pe, {
|
|
256
258
|
locale: m,
|
|
257
259
|
name: u(m),
|
|
258
260
|
"show-badges": e.showBadges
|
|
259
261
|
}, null, 8, ["locale", "name", "show-badges"])
|
|
260
|
-
], 10,
|
|
262
|
+
], 10, ve))), 128))
|
|
261
263
|
])
|
|
262
264
|
], 2));
|
|
263
265
|
}
|
|
264
|
-
}),
|
|
266
|
+
}), we = {
|
|
265
267
|
en: "English",
|
|
266
268
|
"en-GB": "English (GB)",
|
|
267
269
|
"en-US": "English (US)",
|
|
268
270
|
fr: "Français",
|
|
269
271
|
th: "ไทย"
|
|
270
|
-
},
|
|
272
|
+
}, ye = (e) => {
|
|
271
273
|
const t = {};
|
|
272
274
|
for (const n of e)
|
|
273
275
|
t[n] = {
|
|
274
|
-
locales:
|
|
276
|
+
locales: we
|
|
275
277
|
};
|
|
276
278
|
return t;
|
|
277
|
-
},
|
|
279
|
+
}, Le = (e, t) => {
|
|
278
280
|
let n;
|
|
279
281
|
return e.some((o) => {
|
|
280
282
|
const l = o.split("-");
|
|
281
|
-
let
|
|
283
|
+
let r = [];
|
|
282
284
|
for (let f = 1; f <= l.length; f++)
|
|
283
|
-
if (
|
|
284
|
-
return n =
|
|
285
|
+
if (r = (r.length === 0 ? t : r).filter((a) => a.startsWith(l.slice(0, f).join("-"))), r.length === 1)
|
|
286
|
+
return n = r[0], !0;
|
|
285
287
|
}), n;
|
|
286
|
-
},
|
|
288
|
+
}, be = (e, t) => {
|
|
287
289
|
if (!t)
|
|
288
290
|
return e;
|
|
289
291
|
const n = {};
|
|
290
292
|
for (const o in t) {
|
|
291
|
-
const l = t[o],
|
|
292
|
-
n[o] =
|
|
293
|
-
...
|
|
293
|
+
const l = t[o], r = e[o];
|
|
294
|
+
n[o] = r ? {
|
|
295
|
+
...r,
|
|
294
296
|
...l
|
|
295
297
|
} : l;
|
|
296
298
|
}
|
|
297
299
|
for (const o in e) {
|
|
298
300
|
if (n[o])
|
|
299
301
|
continue;
|
|
300
|
-
const l = t[o],
|
|
302
|
+
const l = t[o], r = e[o];
|
|
301
303
|
n[o] = l ? {
|
|
302
|
-
...
|
|
304
|
+
...r,
|
|
303
305
|
...l
|
|
304
|
-
} :
|
|
306
|
+
} : r;
|
|
305
307
|
}
|
|
306
308
|
return n;
|
|
307
|
-
},
|
|
308
|
-
const t = e.config.i18n, n = e.config.slug, { getLocale: o, setLocale: l } =
|
|
309
|
-
if (!
|
|
310
|
-
const
|
|
309
|
+
}, Se = (e) => {
|
|
310
|
+
const t = e.config.i18n, n = e.config.slug, { getLocale: o, setLocale: l } = q(n), r = o();
|
|
311
|
+
if (!r) {
|
|
312
|
+
const c = Le(
|
|
311
313
|
navigator.languages,
|
|
312
314
|
t.supportedLocales
|
|
313
315
|
);
|
|
314
|
-
l(
|
|
316
|
+
l(c);
|
|
315
317
|
}
|
|
316
|
-
const f =
|
|
317
|
-
|
|
318
|
+
const f = be(
|
|
319
|
+
ye(t.supportedLocales),
|
|
318
320
|
t?.messages
|
|
319
321
|
);
|
|
320
|
-
return
|
|
322
|
+
return G({
|
|
321
323
|
...t,
|
|
322
324
|
globalInjection: !0,
|
|
323
325
|
legacy: !1,
|
|
324
|
-
locale:
|
|
326
|
+
locale: r,
|
|
325
327
|
messages: f
|
|
326
328
|
});
|
|
327
|
-
},
|
|
329
|
+
}, $e = {
|
|
328
330
|
install: (e, t) => {
|
|
329
|
-
const n =
|
|
331
|
+
const n = Se(t);
|
|
330
332
|
e.use(n);
|
|
331
333
|
}
|
|
332
334
|
};
|
|
333
335
|
export {
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
336
|
+
Ee as LocaleSwitcher,
|
|
337
|
+
Se as createI18n,
|
|
338
|
+
$e as default,
|
|
339
|
+
Le as getPreferredLocale,
|
|
340
|
+
be as prependMessages,
|
|
341
|
+
Oe as useI18n,
|
|
342
|
+
q as useLocaleStore
|
|
341
343
|
};
|
|
@@ -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,
|
|
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(i=>i()),n.length=0},l=(i,a,d,g)=>(i.addEventListener(a,d,g),()=>i.removeEventListener(a,d,g)),c=e.computed(()=>{const i=E(e.toValue(t[0])).filter(a=>a!=null);return i.every(a=>typeof a!="string")?i:void 0}),s=W(()=>{var i,a;return[(a=(i=c.value)==null?void 0:i.map(d=>w(d)))!=null?a:[I].filter(d=>d!=null),E(e.toValue(c.value?t[1]:t[0])),E(e.unref(c.value?t[2]:t[1])),e.toValue(c.value?t[3]:t[2])]},([i,a,d,g])=>{if(o(),!i?.length||!a?.length||!d?.length)return;const h=q(g)?{...g}:g;n.push(...i.flatMap(y=>a.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:c=[],capture:s=!0,detectIframe:m=!1,controls:i=!1}=o;if(!l)return i?{stop:b,cancel:b,trigger:b}:b;if(x&&!P){P=!0;const r={passive:!0};Array.from(l.document.body.children).forEach(u=>L(u,"click",b,r)),L(l.document.documentElement,"click",b,r)}let a=!0;const d=r=>e.toValue(c).some(u=>{if(typeof u=="string")return Array.from(l.document.querySelectorAll(u)).some(p=>p===r.target||r.composedPath().includes(p));{const p=w(u);return p&&(r.target===p||r.composedPath().includes(p))}});function g(r){const u=e.toValue(r);return u&&u.$.subTree.shapeFlag===16}function h(r,u){const p=e.toValue(r),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=r=>{const u=w(t);if(r.target!=null&&!(!(u instanceof Element)&&g(t)&&h(t,r))&&!(!u||u===r.target||r.composedPath().includes(u))){if("detail"in r&&r.detail===0&&(a=!d(r)),!a){a=!0;return}n(r)}};let _=!1;const S=[L(l,"click",r=>{_||(_=!0,setTimeout(()=>{_=!1},0),y(r))},{passive:!0,capture:s}),L(l,"pointerdown",r=>{const u=w(t);a=!d(r)&&!!(u&&!r.composedPath().includes(u))},{passive:!0}),m&&L(l,"blur",r=>{setTimeout(()=>{var u;const p=w(t);((u=l.document.activeElement)==null?void 0:u.tagName)==="IFRAME"&&!p?.contains(l.document.activeElement)&&n(r)},0)},{passive:!0})].filter(Boolean),O=()=>S.forEach(r=>r());return i?{stop:O,cancel:()=>{a=!1},trigger:r=>{a=!0,y(r),a=!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.substring(0,2)),l=e.computed(()=>{const c=n.locale.split("-");if(c.length>1)return c[1]});return(c,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,c]of n)o[l]=c;return o})(U,[["__scopeId","data-v-c1291edf"]]),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:()=>{const c=localStorage.getItem(n);return c||void 0},setLocale:c=>{c?localStorage.setItem(n,c):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(),c=M.useConfig(),s=e.ref(!1),m=h=>{o.value=h,s.value=!1;const{setLocale:y}=B(c.slug);y(h)},i=e.computed(()=>({locale:o.value,name:d(o.value)})),a=()=>{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:a},[e.createElementVNode("div",Q,e.toDisplayString(i.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:_===i.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 c=l.split("-");let s=[];for(let m=1;m<=c.length;m++)if(s=(s.length===0?n:s).filter(i=>i.startsWith(c.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 c=n[l],s=t[l];o[l]=s?{...s,...c}:c}for(const l in t){if(o[l])continue;const c=n[l],s=t[l];o[l]=c?{...s,...c}:s}return o},N=t=>{const n=t.config.i18n,o=t.config.slug,{getLocale:l,setLocale:c}=B(o),s=l();if(!s){const a=T(navigator.languages,n.supportedLocales);c(a)}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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Index.vue.d.ts","sourceRoot":"","sources":["../../../src/locale-switcher/Index.vue.ts"],"names":[],"mappings":";;;;;;;;;;;;;
|
|
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 +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,
|
|
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"}
|
package/dist/vue3-i18n.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.country[data-v-c1291edf]{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-c1291edf]{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
|
|
1
|
+
.country[data-v-c1291edf]{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-c1291edf]{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{align-self:start;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);--_border: var(--locale-switcher-border, 1px solid #e5e5e5);--_min-width: var(--locale-switcher-width, 10rem);background-color:var(--_bg-color);border:var(--_border);border-radius:.325rem;box-shadow:0 2px 5px #0000001a;display:none;list-style:none;min-width:var(--_min-width);padding-inline-start:0;padding:.15rem 0;position:absolute;right:0;top:120%;z-index:1000}nav.locale-switcher.expanded ul{display:block}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)}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prefabs.tech/vue3-i18n",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.0",
|
|
4
4
|
"description": "Vue3 I18n Plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@prefabs.tech/eslint-config": "0.2.0",
|
|
24
24
|
"@prefabs.tech/tsconfig": "0.2.0",
|
|
25
|
-
"@prefabs.tech/vue3-config": "0.
|
|
25
|
+
"@prefabs.tech/vue3-config": "0.15.0",
|
|
26
26
|
"@types/node": "22.13.5",
|
|
27
27
|
"@typescript-eslint/eslint-plugin": "8.24.1",
|
|
28
28
|
"@typescript-eslint/parser": "8.24.1",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"vue-tsc": "1.2.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
|
-
"@prefabs.tech/vue3-config": "0.
|
|
52
|
+
"@prefabs.tech/vue3-config": "0.15.0",
|
|
53
53
|
"@vueuse/core": ">=9.4.0",
|
|
54
54
|
"pinia": ">=2.0",
|
|
55
55
|
"vue": ">=3.2"
|