@i18n-micro/solid 1.0.0 → 1.1.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.
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -11
- package/dist/index.mjs +280 -306
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -1,44 +1,31 @@
|
|
|
1
|
-
import { createSignal as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
class be extends ge {
|
|
8
|
-
// Реактивные примитивы Solid
|
|
1
|
+
import { createSignal as A, createContext as E, useContext as j, createMemo as P, splitProps as V, onMount as dt, onCleanup as ft, createEffect as ht } from "solid-js";
|
|
2
|
+
import { BaseI18n as pt } from "@i18n-micro/core";
|
|
3
|
+
import { FormatService as Ot, defaultPlural as Wt, interpolate as Ht } from "@i18n-micro/core";
|
|
4
|
+
import { createComponent as k, memo as v, Dynamic as W, mergeProps as R, spread as T, insert as x, template as C, delegateEvents as gt, use as mt, setAttribute as K, effect as H, style as $, className as yt } from "solid-js/web";
|
|
5
|
+
import { A as vt } from "@solidjs/router";
|
|
6
|
+
class Lt extends pt {
|
|
9
7
|
_locale;
|
|
10
8
|
_setLocale;
|
|
11
9
|
_fallbackLocale;
|
|
12
10
|
_currentRoute;
|
|
13
11
|
_setRoute;
|
|
14
|
-
|
|
15
|
-
// Мы используем createStore для глубокой реактивности, чтобы при подгрузке
|
|
16
|
-
// частичных переводов (mergeTranslation) интерфейс обновлялся.
|
|
17
|
-
cacheStore;
|
|
18
|
-
setCacheStore;
|
|
19
|
-
// Слушатели для DevTools (аналог subscribe в React версии)
|
|
12
|
+
storage;
|
|
20
13
|
listeners = /* @__PURE__ */ new Set();
|
|
21
|
-
constructor(
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
route: {}
|
|
25
|
-
}), s = {
|
|
26
|
-
// Solid Store Proxy is compatible with reading objects
|
|
27
|
-
generalLocaleCache: { value: l.general },
|
|
28
|
-
routeLocaleCache: { value: l.route },
|
|
29
|
-
dynamicTranslationsCaches: { value: [] },
|
|
30
|
-
serverTranslationCache: { value: {} }
|
|
14
|
+
constructor(t) {
|
|
15
|
+
const e = {
|
|
16
|
+
translations: /* @__PURE__ */ new Map()
|
|
31
17
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
plural:
|
|
35
|
-
missingWarn:
|
|
36
|
-
missingHandler:
|
|
37
|
-
}), this.
|
|
38
|
-
|
|
39
|
-
|
|
18
|
+
super({
|
|
19
|
+
storage: e,
|
|
20
|
+
plural: t.plural,
|
|
21
|
+
missingWarn: t.missingWarn,
|
|
22
|
+
missingHandler: t.missingHandler
|
|
23
|
+
}), this.storage = e;
|
|
24
|
+
const [o, n] = A(t.locale), [f] = A(t.fallbackLocale || t.locale), [h, c] = A("general");
|
|
25
|
+
if (this._locale = o, this._setLocale = n, this._fallbackLocale = f, this._currentRoute = h, this._setRoute = c, t.messages)
|
|
26
|
+
for (const [a, s] of Object.entries(t.messages))
|
|
27
|
+
this.addTranslations(a, s);
|
|
40
28
|
}
|
|
41
|
-
// --- Abstract Implementation ---
|
|
42
29
|
getLocale() {
|
|
43
30
|
return this._locale();
|
|
44
31
|
}
|
|
@@ -48,14 +35,12 @@ class be extends ge {
|
|
|
48
35
|
getRoute() {
|
|
49
36
|
return this._currentRoute();
|
|
50
37
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
this._setLocale(e), this.notifyListeners();
|
|
38
|
+
set locale(t) {
|
|
39
|
+
this._setLocale(t), this.notifyListeners();
|
|
54
40
|
}
|
|
55
41
|
get locale() {
|
|
56
42
|
return this._locale();
|
|
57
43
|
}
|
|
58
|
-
// Публичный accessor для реактивности
|
|
59
44
|
get localeAccessor() {
|
|
60
45
|
return this._locale;
|
|
61
46
|
}
|
|
@@ -65,249 +50,238 @@ class be extends ge {
|
|
|
65
50
|
get currentRoute() {
|
|
66
51
|
return this._currentRoute();
|
|
67
52
|
}
|
|
68
|
-
// Публичный accessor для реактивности
|
|
69
53
|
get routeAccessor() {
|
|
70
54
|
return this._currentRoute;
|
|
71
55
|
}
|
|
72
|
-
setRoute(
|
|
73
|
-
this._setRoute(
|
|
56
|
+
setRoute(t) {
|
|
57
|
+
this._setRoute(t), this.notifyListeners();
|
|
74
58
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
o ? this.setCacheStore("general", e, (r) => ({
|
|
78
|
-
...r || {},
|
|
79
|
-
...t
|
|
80
|
-
})) : this.setCacheStore("general", e, t), this.notifyListeners();
|
|
59
|
+
addTranslations(t, e, o = !0) {
|
|
60
|
+
super.loadTranslationsCore(t, e, o), this.notifyListeners();
|
|
81
61
|
}
|
|
82
|
-
addRouteTranslations(
|
|
83
|
-
|
|
84
|
-
r ? this.setCacheStore("route", d, (f) => ({
|
|
85
|
-
...f || {},
|
|
86
|
-
...o
|
|
87
|
-
})) : this.setCacheStore("route", d, o), this.notifyListeners();
|
|
62
|
+
addRouteTranslations(t, e, o, n = !0) {
|
|
63
|
+
super.loadRouteTranslationsCore(t, e, o, n), this.notifyListeners();
|
|
88
64
|
}
|
|
89
65
|
clearCache() {
|
|
90
|
-
|
|
66
|
+
super.clearCache(), this.notifyListeners();
|
|
91
67
|
}
|
|
92
|
-
subscribe(
|
|
93
|
-
return this.listeners.add(
|
|
68
|
+
subscribe(t) {
|
|
69
|
+
return this.listeners.add(t), () => this.listeners.delete(t);
|
|
94
70
|
}
|
|
95
71
|
notifyListeners() {
|
|
96
|
-
this.listeners.forEach((
|
|
97
|
-
e();
|
|
98
|
-
});
|
|
72
|
+
this.listeners.forEach((t) => t());
|
|
99
73
|
}
|
|
100
74
|
}
|
|
101
|
-
function
|
|
102
|
-
return new
|
|
75
|
+
function At(r) {
|
|
76
|
+
return new Lt(r);
|
|
103
77
|
}
|
|
104
78
|
const Q = E(), U = E(), X = E(), Y = E(), D = () => {
|
|
105
|
-
const
|
|
106
|
-
if (!
|
|
79
|
+
const r = j(Q);
|
|
80
|
+
if (!r)
|
|
107
81
|
throw new Error("[i18n-micro] I18nContext not found. Make sure I18nProvider is used.");
|
|
108
|
-
return
|
|
109
|
-
},
|
|
110
|
-
const
|
|
111
|
-
if (!
|
|
82
|
+
return r;
|
|
83
|
+
}, tt = () => {
|
|
84
|
+
const r = j(U);
|
|
85
|
+
if (!r)
|
|
112
86
|
throw new Error("[i18n-micro] I18nLocalesContext not found. Make sure I18nLocalesContext is provided.");
|
|
113
|
-
return
|
|
114
|
-
},
|
|
115
|
-
const
|
|
116
|
-
if (!
|
|
87
|
+
return r;
|
|
88
|
+
}, bt = () => {
|
|
89
|
+
const r = j(X);
|
|
90
|
+
if (!r)
|
|
117
91
|
throw new Error("[i18n-micro] I18nDefaultLocaleContext not found. Make sure I18nDefaultLocaleContext is provided.");
|
|
118
|
-
return
|
|
119
|
-
}, F = () => j(Y),
|
|
120
|
-
const
|
|
92
|
+
return r;
|
|
93
|
+
}, F = () => j(Y), Dt = (r) => {
|
|
94
|
+
const t = r.children;
|
|
121
95
|
return (
|
|
122
96
|
// @ts-expect-error - Provider components type conflict with Vue JSX
|
|
123
|
-
|
|
97
|
+
k(Q.Provider, {
|
|
124
98
|
get value() {
|
|
125
|
-
return
|
|
99
|
+
return r.i18n;
|
|
126
100
|
},
|
|
127
101
|
get children() {
|
|
128
|
-
return [v(() => v(() => !!
|
|
129
|
-
|
|
102
|
+
return [v(() => v(() => !!r.locales)() && // @ts-expect-error - Provider components type conflict with Vue JSX
|
|
103
|
+
k(U.Provider, {
|
|
130
104
|
get value() {
|
|
131
|
-
return
|
|
105
|
+
return r.locales;
|
|
132
106
|
},
|
|
133
107
|
get children() {
|
|
134
|
-
return [v(() => v(() => !!
|
|
135
|
-
|
|
108
|
+
return [v(() => v(() => !!r.defaultLocale)() && // @ts-expect-error - Provider components type conflict with Vue JSX
|
|
109
|
+
k(X.Provider, {
|
|
136
110
|
get value() {
|
|
137
|
-
return
|
|
111
|
+
return r.defaultLocale;
|
|
138
112
|
},
|
|
139
113
|
get children() {
|
|
140
|
-
return [v(() => v(() => !!
|
|
141
|
-
|
|
114
|
+
return [v(() => v(() => !!r.routingStrategy)() && // @ts-expect-error - Provider components type conflict with Vue JSX
|
|
115
|
+
k(Y.Provider, {
|
|
142
116
|
get value() {
|
|
143
|
-
return
|
|
117
|
+
return r.routingStrategy;
|
|
144
118
|
},
|
|
145
|
-
children:
|
|
146
|
-
})), v(() => !
|
|
119
|
+
children: t
|
|
120
|
+
})), v(() => !r.routingStrategy && t)];
|
|
147
121
|
}
|
|
148
|
-
})), v(() => !
|
|
122
|
+
})), v(() => !r.defaultLocale && t)];
|
|
149
123
|
}
|
|
150
|
-
})), v(() => !
|
|
124
|
+
})), v(() => !r.locales && t)];
|
|
151
125
|
}
|
|
152
126
|
})
|
|
153
127
|
);
|
|
154
128
|
};
|
|
155
|
-
function
|
|
156
|
-
const
|
|
129
|
+
function Nt(r) {
|
|
130
|
+
const t = D(), e = F(), o = tt(), n = bt(), f = r?.locales || o, h = r?.defaultLocale || n, c = (a, s) => e?.resolvePath ? e.resolvePath(a, s || t.getLocale()) : a;
|
|
157
131
|
return {
|
|
158
132
|
// Direct access to instance
|
|
159
|
-
instance:
|
|
133
|
+
instance: t,
|
|
160
134
|
// Locale (reactive) - используем accessor для отслеживания изменений
|
|
161
|
-
locale:
|
|
135
|
+
locale: P(() => t.localeAccessor()),
|
|
162
136
|
// Locale helpers
|
|
163
|
-
getLocales: () =>
|
|
164
|
-
defaultLocale: () =>
|
|
165
|
-
getLocaleName: () =>
|
|
137
|
+
getLocales: () => f,
|
|
138
|
+
defaultLocale: () => h,
|
|
139
|
+
getLocaleName: () => f.find((s) => s.code === t.localeAccessor())?.displayName || null,
|
|
166
140
|
// Routing helpers
|
|
167
|
-
localeRoute:
|
|
141
|
+
localeRoute: c,
|
|
168
142
|
localePath: (a, s) => {
|
|
169
|
-
const
|
|
170
|
-
return typeof
|
|
143
|
+
const l = c(a, s);
|
|
144
|
+
return typeof l == "string" ? l : l.path || "/";
|
|
171
145
|
},
|
|
172
146
|
switchLocale: (a) => {
|
|
173
|
-
if (
|
|
174
|
-
const s =
|
|
175
|
-
|
|
147
|
+
if (t.locale = a, e) {
|
|
148
|
+
const s = e.getCurrentPath(), l = c(s, a);
|
|
149
|
+
e.push(typeof l == "string" ? { path: l } : { path: l.path || "/" });
|
|
176
150
|
}
|
|
177
151
|
},
|
|
178
152
|
// Translation methods (delegate to instance)
|
|
179
|
-
t:
|
|
180
|
-
ts:
|
|
181
|
-
tc:
|
|
182
|
-
tn:
|
|
183
|
-
td:
|
|
184
|
-
tdr:
|
|
185
|
-
has:
|
|
153
|
+
t: t.t.bind(t),
|
|
154
|
+
ts: t.ts.bind(t),
|
|
155
|
+
tc: t.tc.bind(t),
|
|
156
|
+
tn: t.tn.bind(t),
|
|
157
|
+
td: t.td.bind(t),
|
|
158
|
+
tdr: t.tdr.bind(t),
|
|
159
|
+
has: t.has.bind(t),
|
|
186
160
|
// Route management
|
|
187
|
-
setRoute:
|
|
188
|
-
getRoute:
|
|
189
|
-
getLocale: () =>
|
|
161
|
+
setRoute: t.setRoute.bind(t),
|
|
162
|
+
getRoute: t.getRoute.bind(t),
|
|
163
|
+
getLocale: () => t.getLocale(),
|
|
190
164
|
// Translation management
|
|
191
|
-
addTranslations:
|
|
192
|
-
addRouteTranslations:
|
|
193
|
-
clearCache:
|
|
165
|
+
addTranslations: t.addTranslations.bind(t),
|
|
166
|
+
addRouteTranslations: t.addRouteTranslations.bind(t),
|
|
167
|
+
clearCache: t.clearCache.bind(t)
|
|
194
168
|
};
|
|
195
169
|
}
|
|
196
|
-
const
|
|
197
|
-
const
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
200
|
-
const s = Number(
|
|
201
|
-
number:
|
|
202
|
-
...
|
|
203
|
-
}, void 0,
|
|
204
|
-
return typeof
|
|
170
|
+
const Tt = (r) => {
|
|
171
|
+
const t = D(), [e, o] = V(r, ["keypath", "params", "tag", "plural", "defaultValue", "html", "hideIfEmpty", "customPluralRule", "number", "date", "relativeDate"]), n = P(() => {
|
|
172
|
+
const h = t.localeAccessor(), c = t.routeAccessor();
|
|
173
|
+
if (e.number !== void 0) {
|
|
174
|
+
const s = Number(e.number), l = t.tn(s), g = t.t(e.keypath, {
|
|
175
|
+
number: l,
|
|
176
|
+
...e.params || {}
|
|
177
|
+
}, void 0, c);
|
|
178
|
+
return typeof g == "string" ? g : String(g);
|
|
205
179
|
}
|
|
206
|
-
if (
|
|
207
|
-
const s =
|
|
180
|
+
if (e.date !== void 0) {
|
|
181
|
+
const s = t.td(e.date), l = t.t(e.keypath, {
|
|
208
182
|
date: s,
|
|
209
|
-
...
|
|
210
|
-
}, void 0,
|
|
211
|
-
return typeof
|
|
183
|
+
...e.params || {}
|
|
184
|
+
}, void 0, c);
|
|
185
|
+
return typeof l == "string" ? l : String(l);
|
|
212
186
|
}
|
|
213
|
-
if (
|
|
214
|
-
const s =
|
|
187
|
+
if (e.relativeDate !== void 0) {
|
|
188
|
+
const s = t.tdr(e.relativeDate), l = t.t(e.keypath, {
|
|
215
189
|
relativeDate: s,
|
|
216
|
-
...
|
|
217
|
-
}, void 0,
|
|
218
|
-
return typeof
|
|
190
|
+
...e.params || {}
|
|
191
|
+
}, void 0, c);
|
|
192
|
+
return typeof l == "string" ? l : String(l);
|
|
219
193
|
}
|
|
220
|
-
if (
|
|
221
|
-
const s = Number.parseInt(
|
|
222
|
-
return
|
|
194
|
+
if (e.plural !== void 0) {
|
|
195
|
+
const s = Number.parseInt(e.plural.toString());
|
|
196
|
+
return e.customPluralRule ? e.customPluralRule(e.keypath, s, e.params || {}, h, (g, i, p) => t.t(g, i, p, c)) || "" : t.tc(e.keypath, {
|
|
223
197
|
count: s,
|
|
224
|
-
...
|
|
225
|
-
},
|
|
198
|
+
...e.params || {}
|
|
199
|
+
}, e.defaultValue);
|
|
226
200
|
}
|
|
227
|
-
const a = (
|
|
228
|
-
return
|
|
201
|
+
const a = (t.t(e.keypath, e.params, e.defaultValue, c) ?? "").toString();
|
|
202
|
+
return e.hideIfEmpty && !a.trim() ? e.defaultValue || "" : a;
|
|
229
203
|
});
|
|
230
|
-
if (
|
|
204
|
+
if (e.html)
|
|
231
205
|
return (
|
|
232
206
|
// @ts-expect-error - Dynamic component type conflict with Vue JSX
|
|
233
|
-
|
|
207
|
+
k(W, R({
|
|
234
208
|
get component() {
|
|
235
|
-
return
|
|
209
|
+
return e.tag || "span";
|
|
236
210
|
}
|
|
237
211
|
}, o, {
|
|
238
212
|
get innerHTML() {
|
|
239
|
-
return
|
|
213
|
+
return n();
|
|
240
214
|
}
|
|
241
215
|
}))
|
|
242
216
|
);
|
|
243
|
-
const
|
|
244
|
-
return
|
|
217
|
+
const f = n();
|
|
218
|
+
return e.hideIfEmpty && !f.trim() ? e.defaultValue ? k(W, R({
|
|
245
219
|
get component() {
|
|
246
|
-
return
|
|
220
|
+
return e.tag || "span";
|
|
247
221
|
}
|
|
248
222
|
}, o, {
|
|
249
223
|
get children() {
|
|
250
|
-
return
|
|
224
|
+
return e.defaultValue;
|
|
251
225
|
}
|
|
252
226
|
})) : null : (
|
|
253
227
|
// @ts-expect-error - Dynamic component type conflict with Vue JSX
|
|
254
|
-
|
|
228
|
+
k(W, R({
|
|
255
229
|
get component() {
|
|
256
|
-
return
|
|
230
|
+
return e.tag || "span";
|
|
257
231
|
}
|
|
258
232
|
}, o, {
|
|
259
|
-
children:
|
|
233
|
+
children: f
|
|
260
234
|
}))
|
|
261
235
|
);
|
|
262
236
|
};
|
|
263
|
-
var
|
|
264
|
-
const
|
|
265
|
-
const
|
|
266
|
-
const i =
|
|
267
|
-
let
|
|
237
|
+
var Pt = /* @__PURE__ */ C('<a target=_blank rel="noopener noreferrer">'), kt = /* @__PURE__ */ C("<a>");
|
|
238
|
+
const Et = (r) => {
|
|
239
|
+
const t = F(), e = D(), [o, n] = V(r, ["to", "localeRoute", "activeStyle", "style", "children"]), h = t?.getCurrentPathAccessor, c = P(() => {
|
|
240
|
+
const i = e.localeAccessor();
|
|
241
|
+
let p;
|
|
268
242
|
if (o.localeRoute) {
|
|
269
243
|
const y = o.localeRoute(o.to, i);
|
|
270
|
-
|
|
271
|
-
} else if (
|
|
272
|
-
const y =
|
|
273
|
-
|
|
274
|
-
} else typeof o.to == "string" ?
|
|
275
|
-
return
|
|
276
|
-
}), a =
|
|
244
|
+
p = typeof y == "string" ? y : y?.path || "/";
|
|
245
|
+
} else if (t?.resolvePath) {
|
|
246
|
+
const y = t.resolvePath(o.to, i);
|
|
247
|
+
p = typeof y == "string" ? y : y?.path || "/";
|
|
248
|
+
} else typeof o.to == "string" ? p = o.to : p = o.to?.path || "/";
|
|
249
|
+
return p;
|
|
250
|
+
}), a = P(() => typeof o.to == "string" ? /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(o.to) : !1), s = P(() => {
|
|
277
251
|
if (a())
|
|
278
252
|
return !1;
|
|
279
|
-
const i =
|
|
280
|
-
return y ===
|
|
281
|
-
}),
|
|
253
|
+
const i = h ? h() : t ? t.getCurrentPath() : typeof window < "u" ? window.location.pathname : "/", p = c(), y = i === "/" ? "/" : i.replace(/\/$/, ""), M = p === "/" ? "/" : p.replace(/\/$/, "");
|
|
254
|
+
return y === M;
|
|
255
|
+
}), l = P(() => {
|
|
282
256
|
const i = o.style || {}, y = s() ? o.activeStyle || {} : {};
|
|
283
257
|
return {
|
|
284
258
|
...typeof i == "object" ? i : {},
|
|
285
259
|
...typeof y == "object" ? y : {}
|
|
286
260
|
};
|
|
287
|
-
}),
|
|
261
|
+
}), g = t?.linkComponent;
|
|
288
262
|
return a() ? (
|
|
289
263
|
// @ts-expect-error - Type conflict with Vue JSX
|
|
290
264
|
(() => {
|
|
291
|
-
var i =
|
|
292
|
-
return T(i,
|
|
265
|
+
var i = Pt();
|
|
266
|
+
return T(i, R({
|
|
293
267
|
get href() {
|
|
294
268
|
return v(() => typeof o.to == "string")() ? o.to : "";
|
|
295
269
|
},
|
|
296
270
|
get style() {
|
|
297
|
-
return
|
|
271
|
+
return l();
|
|
298
272
|
}
|
|
299
|
-
},
|
|
273
|
+
}, n), !1, !0), x(i, () => o.children), i;
|
|
300
274
|
})()
|
|
301
|
-
) :
|
|
275
|
+
) : g ? (
|
|
302
276
|
// @ts-expect-error - Type conflict with router component types
|
|
303
|
-
|
|
277
|
+
k(g, R({
|
|
304
278
|
get href() {
|
|
305
|
-
return
|
|
279
|
+
return c();
|
|
306
280
|
},
|
|
307
281
|
get style() {
|
|
308
|
-
return
|
|
282
|
+
return l();
|
|
309
283
|
}
|
|
310
|
-
},
|
|
284
|
+
}, n, {
|
|
311
285
|
get children() {
|
|
312
286
|
return o.children;
|
|
313
287
|
}
|
|
@@ -315,55 +289,55 @@ const Ve = (n) => {
|
|
|
315
289
|
) : (
|
|
316
290
|
// @ts-expect-error - Type conflict with Vue JSX
|
|
317
291
|
(() => {
|
|
318
|
-
var i =
|
|
319
|
-
return T(i,
|
|
292
|
+
var i = kt();
|
|
293
|
+
return T(i, R({
|
|
320
294
|
get href() {
|
|
321
|
-
return
|
|
295
|
+
return c();
|
|
322
296
|
},
|
|
323
297
|
get style() {
|
|
324
|
-
return
|
|
298
|
+
return l();
|
|
325
299
|
}
|
|
326
|
-
},
|
|
327
|
-
onClick: (
|
|
328
|
-
|
|
329
|
-
path:
|
|
300
|
+
}, n, {
|
|
301
|
+
onClick: (p) => {
|
|
302
|
+
t && !a() && (p.preventDefault(), t.push({
|
|
303
|
+
path: c()
|
|
330
304
|
}));
|
|
331
305
|
}
|
|
332
306
|
}), !1, !0), x(i, () => o.children), i;
|
|
333
307
|
})()
|
|
334
308
|
);
|
|
335
309
|
};
|
|
336
|
-
var
|
|
337
|
-
const
|
|
338
|
-
const
|
|
310
|
+
var Rt = /* @__PURE__ */ C("<div class=i18n-switcher-wrapper><button type=button class=i18n-switcher-button aria-haspopup=true><span></span><span>▼"), St = /* @__PURE__ */ C("<ul class=i18n-switcher-dropdown>"), xt = /* @__PURE__ */ C("<li><a>");
|
|
311
|
+
const jt = (r) => {
|
|
312
|
+
const t = D(), e = F(), o = tt(), [n, f] = V(r, ["locales", "currentLocale", "getLocaleName", "switchLocale", "localeRoute", "customLabels", "customWrapperStyle", "customButtonStyle", "customDropdownStyle", "customItemStyle", "customLinkStyle", "customActiveLinkStyle", "customDisabledLinkStyle", "customIconStyle"]), [h, c] = A(!1);
|
|
339
313
|
let a;
|
|
340
|
-
const s =
|
|
341
|
-
u && (u.stopPropagation(), u.preventDefault()),
|
|
342
|
-
},
|
|
343
|
-
const u = s().find((m) => m.code ===
|
|
344
|
-
return u ?
|
|
345
|
-
}),
|
|
346
|
-
if (
|
|
347
|
-
|
|
314
|
+
const s = P(() => n.locales || o || []), l = P(() => n.currentLocale !== void 0 ? typeof n.currentLocale == "function" ? n.currentLocale() : n.currentLocale : t.localeAccessor()), g = P(() => n.getLocaleName ? n.getLocaleName() || null : s().find((m) => m.code === t.localeAccessor())?.displayName || null), i = (u) => {
|
|
315
|
+
u && (u.stopPropagation(), u.preventDefault()), c(!h());
|
|
316
|
+
}, p = (u) => n.customLabels?.[u.code] || u.displayName || u.code, y = P(() => {
|
|
317
|
+
const u = s().find((m) => m.code === l());
|
|
318
|
+
return u ? p(u) : g() || l();
|
|
319
|
+
}), M = async (u) => {
|
|
320
|
+
if (c(!1), n.switchLocale) {
|
|
321
|
+
n.switchLocale(u);
|
|
348
322
|
return;
|
|
349
323
|
}
|
|
350
|
-
if (
|
|
324
|
+
if (t.locale = u, !e)
|
|
351
325
|
return;
|
|
352
|
-
const m =
|
|
353
|
-
const
|
|
354
|
-
return typeof
|
|
355
|
-
})() :
|
|
356
|
-
const
|
|
357
|
-
return typeof
|
|
358
|
-
})() :
|
|
359
|
-
|
|
326
|
+
const m = e, S = m.getCurrentPathAccessor ? m.getCurrentPathAccessor() : e.getCurrentPath(), w = n.localeRoute ? (() => {
|
|
327
|
+
const d = n.localeRoute(S, u);
|
|
328
|
+
return typeof d == "string" ? d : d.path || "/";
|
|
329
|
+
})() : e?.resolvePath ? (() => {
|
|
330
|
+
const d = e.resolvePath(S, u);
|
|
331
|
+
return typeof d == "string" ? d : d.path || "/";
|
|
332
|
+
})() : S;
|
|
333
|
+
e.push({
|
|
360
334
|
path: w
|
|
361
335
|
});
|
|
362
|
-
},
|
|
336
|
+
}, et = {
|
|
363
337
|
position: "relative",
|
|
364
338
|
display: "inline-block",
|
|
365
339
|
"vertical-align": "middle"
|
|
366
|
-
},
|
|
340
|
+
}, rt = {
|
|
367
341
|
padding: "4px 12px",
|
|
368
342
|
"font-size": "16px",
|
|
369
343
|
cursor: "pointer",
|
|
@@ -373,7 +347,7 @@ const Be = (n) => {
|
|
|
373
347
|
display: "flex",
|
|
374
348
|
"align-items": "center",
|
|
375
349
|
"justify-content": "space-between"
|
|
376
|
-
},
|
|
350
|
+
}, nt = {
|
|
377
351
|
position: "absolute",
|
|
378
352
|
top: "100%",
|
|
379
353
|
left: "0",
|
|
@@ -385,91 +359,91 @@ const Be = (n) => {
|
|
|
385
359
|
margin: "4px 0 0 0",
|
|
386
360
|
"min-width": "150px",
|
|
387
361
|
"box-shadow": "0 2px 8px rgba(0,0,0,0.15)"
|
|
388
|
-
},
|
|
362
|
+
}, ot = {
|
|
389
363
|
margin: "0",
|
|
390
364
|
padding: "0"
|
|
391
|
-
},
|
|
365
|
+
}, at = {
|
|
392
366
|
display: "block",
|
|
393
367
|
padding: "8px 12px",
|
|
394
368
|
color: "#333",
|
|
395
369
|
"text-decoration": "none",
|
|
396
370
|
transition: "background-color 0.3s ease",
|
|
397
371
|
cursor: "pointer"
|
|
398
|
-
},
|
|
372
|
+
}, st = {
|
|
399
373
|
"font-weight": "bold",
|
|
400
374
|
color: "#007bff"
|
|
401
|
-
},
|
|
375
|
+
}, lt = {
|
|
402
376
|
"margin-left": "8px",
|
|
403
377
|
display: "inline-block",
|
|
404
378
|
transition: "transform 0.3s ease"
|
|
405
|
-
},
|
|
379
|
+
}, ct = {
|
|
406
380
|
transform: "rotate(180deg)"
|
|
407
381
|
}, Z = (u) => {
|
|
408
|
-
if (!
|
|
382
|
+
if (!h()) return;
|
|
409
383
|
const m = u.target;
|
|
410
384
|
if (!m || !a) return;
|
|
411
|
-
const
|
|
412
|
-
!
|
|
385
|
+
const S = a.contains(m), w = m.closest(".i18n-switcher-button") !== null;
|
|
386
|
+
!S && !w && c(!1);
|
|
413
387
|
};
|
|
414
|
-
return
|
|
388
|
+
return dt(() => {
|
|
415
389
|
document.addEventListener("click", Z);
|
|
416
|
-
}),
|
|
390
|
+
}), ft(() => {
|
|
417
391
|
document.removeEventListener("click", Z);
|
|
418
392
|
}), (() => {
|
|
419
|
-
var u =
|
|
420
|
-
return
|
|
421
|
-
a =
|
|
422
|
-
}, u), T(u,
|
|
393
|
+
var u = Rt(), m = u.firstChild, S = m.firstChild, w = S.nextSibling;
|
|
394
|
+
return mt((d) => {
|
|
395
|
+
a = d;
|
|
396
|
+
}, u), T(u, R({
|
|
423
397
|
get style() {
|
|
424
398
|
return {
|
|
425
|
-
...
|
|
426
|
-
...
|
|
399
|
+
...et,
|
|
400
|
+
...n.customWrapperStyle
|
|
427
401
|
};
|
|
428
402
|
}
|
|
429
|
-
},
|
|
430
|
-
|
|
431
|
-
}, x(
|
|
432
|
-
var
|
|
433
|
-
return () =>
|
|
434
|
-
var _ =
|
|
403
|
+
}, f), !1, !0), m.$$click = (d) => {
|
|
404
|
+
d.preventDefault(), d.stopPropagation(), i(d);
|
|
405
|
+
}, x(S, y), x(u, (() => {
|
|
406
|
+
var d = v(() => !!h());
|
|
407
|
+
return () => d() && (() => {
|
|
408
|
+
var _ = St();
|
|
435
409
|
return x(_, () => s().map((L) => {
|
|
436
|
-
const N = L.code ===
|
|
410
|
+
const N = L.code === l(), q = e, B = q?.getCurrentPathAccessor ? q.getCurrentPathAccessor() : e?.getCurrentPath() || (typeof window < "u" ? window.location.pathname : "/"), z = n.localeRoute ? n.localeRoute(B, L.code) : e?.resolvePath ? e.resolvePath(B, L.code) : B, G = typeof z == "string" ? z : z?.path || "#";
|
|
437
411
|
return (() => {
|
|
438
|
-
var O =
|
|
439
|
-
return
|
|
440
|
-
b.preventDefault(), b.stopPropagation(),
|
|
441
|
-
}, K(
|
|
442
|
-
var
|
|
443
|
-
...
|
|
444
|
-
...
|
|
445
|
-
}, J = `switcher-locale-${L.code}`,
|
|
446
|
-
...
|
|
447
|
-
...N ?
|
|
448
|
-
...
|
|
449
|
-
...N ?
|
|
412
|
+
var O = xt(), I = O.firstChild;
|
|
413
|
+
return I.$$click = (b) => {
|
|
414
|
+
b.preventDefault(), b.stopPropagation(), M(L.code);
|
|
415
|
+
}, K(I, "href", typeof G == "string" ? G : "#"), x(I, () => p(L)), H((b) => {
|
|
416
|
+
var it = {
|
|
417
|
+
...ot,
|
|
418
|
+
...n.customItemStyle
|
|
419
|
+
}, J = `switcher-locale-${L.code}`, ut = {
|
|
420
|
+
...at,
|
|
421
|
+
...N ? st : {},
|
|
422
|
+
...n.customLinkStyle,
|
|
423
|
+
...N ? n.customActiveLinkStyle : {}
|
|
450
424
|
};
|
|
451
|
-
return b.e =
|
|
425
|
+
return b.e = $(O, it, b.e), J !== b.t && yt(I, b.t = J), b.a = $(I, ut, b.a), b;
|
|
452
426
|
}, {
|
|
453
427
|
e: void 0,
|
|
454
428
|
t: void 0,
|
|
455
429
|
a: void 0
|
|
456
430
|
}), O;
|
|
457
431
|
})();
|
|
458
|
-
})), H((L) =>
|
|
459
|
-
...
|
|
460
|
-
...
|
|
432
|
+
})), H((L) => $(_, {
|
|
433
|
+
...nt,
|
|
434
|
+
...n.customDropdownStyle
|
|
461
435
|
}, L)), _;
|
|
462
436
|
})();
|
|
463
|
-
})(), null), H((
|
|
437
|
+
})(), null), H((d) => {
|
|
464
438
|
var _ = {
|
|
465
|
-
...
|
|
466
|
-
...
|
|
467
|
-
}, L =
|
|
468
|
-
...
|
|
469
|
-
...
|
|
470
|
-
...
|
|
439
|
+
...rt,
|
|
440
|
+
...n.customButtonStyle
|
|
441
|
+
}, L = h(), N = {
|
|
442
|
+
...lt,
|
|
443
|
+
...h() ? ct : {},
|
|
444
|
+
...n.customIconStyle
|
|
471
445
|
};
|
|
472
|
-
return
|
|
446
|
+
return d.e = $(m, _, d.e), L !== d.t && K(m, "aria-expanded", d.t = L), d.a = $(w, N, d.a), d;
|
|
473
447
|
}, {
|
|
474
448
|
e: void 0,
|
|
475
449
|
t: void 0,
|
|
@@ -477,99 +451,99 @@ const Be = (n) => {
|
|
|
477
451
|
}), u;
|
|
478
452
|
})();
|
|
479
453
|
};
|
|
480
|
-
|
|
481
|
-
var
|
|
482
|
-
const
|
|
483
|
-
const
|
|
484
|
-
const
|
|
485
|
-
return typeof
|
|
454
|
+
gt(["click"]);
|
|
455
|
+
var Ct = /* @__PURE__ */ C("<div>");
|
|
456
|
+
const Vt = (r) => {
|
|
457
|
+
const t = D(), [e, o] = V(r, ["prefix", "groupClass"]), n = (f, h) => {
|
|
458
|
+
const c = t.t(`${e.prefix}.${f}`, h, void 0, t.getRoute());
|
|
459
|
+
return typeof c == "string" ? c : String(c);
|
|
486
460
|
};
|
|
487
461
|
return (
|
|
488
462
|
// @ts-expect-error - Type conflict with Vue JSX in monorepo
|
|
489
463
|
(() => {
|
|
490
|
-
var
|
|
491
|
-
return T(
|
|
464
|
+
var f = Ct();
|
|
465
|
+
return T(f, R({
|
|
492
466
|
get class() {
|
|
493
|
-
return ["i18n-group",
|
|
467
|
+
return ["i18n-group", e.groupClass].filter(Boolean).join(" ");
|
|
494
468
|
}
|
|
495
|
-
}, o), !1, !0), x(
|
|
496
|
-
var
|
|
497
|
-
return () =>
|
|
498
|
-
prefix:
|
|
499
|
-
t:
|
|
500
|
-
}) :
|
|
501
|
-
})()),
|
|
469
|
+
}, o), !1, !0), x(f, (() => {
|
|
470
|
+
var h = v(() => typeof r.children == "function");
|
|
471
|
+
return () => h() ? r.children({
|
|
472
|
+
prefix: e.prefix,
|
|
473
|
+
t: n
|
|
474
|
+
}) : r.children;
|
|
475
|
+
})()), f;
|
|
502
476
|
})()
|
|
503
477
|
);
|
|
504
478
|
};
|
|
505
|
-
function
|
|
506
|
-
const
|
|
507
|
-
|
|
508
|
-
|
|
479
|
+
function Mt(r, t, e, o) {
|
|
480
|
+
const n = r.map((a) => a.code), [f, h] = A(o.pathname);
|
|
481
|
+
ht(() => {
|
|
482
|
+
h(o.pathname);
|
|
509
483
|
});
|
|
510
|
-
const
|
|
511
|
-
const
|
|
512
|
-
|
|
513
|
-
const i = "/" +
|
|
514
|
-
return s ===
|
|
484
|
+
const c = (a, s) => {
|
|
485
|
+
const g = (typeof a == "string" ? a : a.path || "/").split("/").filter(Boolean);
|
|
486
|
+
g.length > 0 && n.includes(g[0]) && g.shift();
|
|
487
|
+
const i = "/" + g.join("/");
|
|
488
|
+
return s === t ? i : `/${s}${i === "/" ? "" : i}`;
|
|
515
489
|
};
|
|
516
490
|
return {
|
|
517
|
-
getCurrentPath: () =>
|
|
491
|
+
getCurrentPath: () => f(),
|
|
518
492
|
// Returns current value for compatibility
|
|
519
|
-
getCurrentPathAccessor:
|
|
493
|
+
getCurrentPathAccessor: f,
|
|
520
494
|
// Returns accessor for reactivity
|
|
521
495
|
push: (a) => {
|
|
522
|
-
|
|
496
|
+
e(a.path);
|
|
523
497
|
},
|
|
524
498
|
replace: (a) => {
|
|
525
|
-
|
|
499
|
+
e(a.path, {
|
|
526
500
|
replace: !0
|
|
527
501
|
});
|
|
528
502
|
},
|
|
529
|
-
resolvePath: (a, s) =>
|
|
503
|
+
resolvePath: (a, s) => c(a, s),
|
|
530
504
|
getRoute: () => ({
|
|
531
|
-
fullPath:
|
|
505
|
+
fullPath: f(),
|
|
532
506
|
query: {}
|
|
533
507
|
}),
|
|
534
508
|
// Use A component from @solidjs/router
|
|
535
509
|
linkComponent: ((a) => {
|
|
536
510
|
const {
|
|
537
511
|
href: s,
|
|
538
|
-
children:
|
|
539
|
-
class:
|
|
512
|
+
children: l,
|
|
513
|
+
class: g,
|
|
540
514
|
style: i,
|
|
541
|
-
...
|
|
515
|
+
...p
|
|
542
516
|
} = a;
|
|
543
|
-
return
|
|
517
|
+
return k(vt, R({
|
|
544
518
|
href: s,
|
|
545
|
-
class:
|
|
519
|
+
class: g,
|
|
546
520
|
style: i
|
|
547
|
-
},
|
|
548
|
-
children:
|
|
521
|
+
}, p, {
|
|
522
|
+
children: l
|
|
549
523
|
}));
|
|
550
524
|
})
|
|
551
525
|
};
|
|
552
526
|
}
|
|
553
527
|
export {
|
|
554
|
-
|
|
528
|
+
Ot as FormatService,
|
|
555
529
|
Q as I18nContext,
|
|
556
530
|
X as I18nDefaultLocaleContext,
|
|
557
|
-
|
|
558
|
-
|
|
531
|
+
Vt as I18nGroup,
|
|
532
|
+
Et as I18nLink,
|
|
559
533
|
U as I18nLocalesContext,
|
|
560
|
-
|
|
534
|
+
Dt as I18nProvider,
|
|
561
535
|
Y as I18nRouterContext,
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
536
|
+
jt as I18nSwitcher,
|
|
537
|
+
Tt as I18nT,
|
|
538
|
+
Lt as SolidI18n,
|
|
539
|
+
At as createI18n,
|
|
540
|
+
Mt as createSolidRouterAdapter,
|
|
541
|
+
Wt as defaultPlural,
|
|
542
|
+
Ht as interpolate,
|
|
543
|
+
Nt as useI18n,
|
|
570
544
|
D as useI18nContext,
|
|
571
|
-
|
|
572
|
-
|
|
545
|
+
bt as useI18nDefaultLocale,
|
|
546
|
+
tt as useI18nLocales,
|
|
573
547
|
F as useI18nRouter
|
|
574
548
|
};
|
|
575
549
|
//# sourceMappingURL=index.mjs.map
|