@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.mjs CHANGED
@@ -1,44 +1,31 @@
1
- import { createSignal as I, createContext as E, useContext as j, createMemo as S, splitProps as V, onMount as de, onCleanup as he, createEffect as fe } from "solid-js";
2
- import { createStore as pe } from "solid-js/store";
3
- import { BaseI18n as ge } from "@i18n-micro/core";
4
- import { FormatService as He, defaultPlural as Fe, interpolate as Ze } from "@i18n-micro/core";
5
- import { createComponent as C, memo as v, Dynamic as W, mergeProps as P, template as R, spread as T, insert as x, delegateEvents as me, use as ye, setAttribute as K, effect as H, style as A, className as ve } from "solid-js/web";
6
- import { A as Le } from "@solidjs/router";
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
- // Store для кэша.
15
- // Мы используем createStore для глубокой реактивности, чтобы при подгрузке
16
- // частичных переводов (mergeTranslation) интерфейс обновлялся.
17
- cacheStore;
18
- setCacheStore;
19
- // Слушатели для DevTools (аналог subscribe в React версии)
12
+ storage;
20
13
  listeners = /* @__PURE__ */ new Set();
21
- constructor(e) {
22
- const [t, o] = I(e.locale), [r] = I(e.fallbackLocale || e.locale), [d, f] = I("general"), [l, a] = pe({
23
- general: {},
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
- if (super({
33
- cache: s,
34
- plural: e.plural,
35
- missingWarn: e.missingWarn,
36
- missingHandler: e.missingHandler
37
- }), this._locale = t, this._setLocale = o, this._fallbackLocale = r, this._currentRoute = d, this._setRoute = f, this.cacheStore = l, this.setCacheStore = a, e.messages)
38
- for (const [c, p] of Object.entries(e.messages))
39
- this.addTranslations(c, p);
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
- // --- Setters ---
52
- set locale(e) {
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(e) {
73
- this._setRoute(e), this.notifyListeners();
56
+ setRoute(t) {
57
+ this._setRoute(t), this.notifyListeners();
74
58
  }
75
- // --- Overrides for Reactivity ---
76
- addTranslations(e, t, o = !0) {
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(e, t, o, r = !0) {
83
- const d = `${e}:${t}`;
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
- this.setCacheStore("general", {}), this.setCacheStore("route", {}), super.clearCache(), this.notifyListeners();
66
+ super.clearCache(), this.notifyListeners();
91
67
  }
92
- subscribe(e) {
93
- return this.listeners.add(e), () => this.listeners.delete(e);
68
+ subscribe(t) {
69
+ return this.listeners.add(t), () => this.listeners.delete(t);
94
70
  }
95
71
  notifyListeners() {
96
- this.listeners.forEach((e) => {
97
- e();
98
- });
72
+ this.listeners.forEach((t) => t());
99
73
  }
100
74
  }
101
- function Ne(n) {
102
- return new be(n);
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 n = j(Q);
106
- if (!n)
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 n;
109
- }, ee = () => {
110
- const n = j(U);
111
- if (!n)
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 n;
114
- }, Se = () => {
115
- const n = j(X);
116
- if (!n)
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 n;
119
- }, F = () => j(Y), Te = (n) => {
120
- const e = n.children;
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
- C(Q.Provider, {
97
+ k(Q.Provider, {
124
98
  get value() {
125
- return n.i18n;
99
+ return r.i18n;
126
100
  },
127
101
  get children() {
128
- return [v(() => v(() => !!n.locales)() && // @ts-expect-error - Provider components type conflict with Vue JSX
129
- C(U.Provider, {
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 n.locales;
105
+ return r.locales;
132
106
  },
133
107
  get children() {
134
- return [v(() => v(() => !!n.defaultLocale)() && // @ts-expect-error - Provider components type conflict with Vue JSX
135
- C(X.Provider, {
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 n.defaultLocale;
111
+ return r.defaultLocale;
138
112
  },
139
113
  get children() {
140
- return [v(() => v(() => !!n.routingStrategy)() && // @ts-expect-error - Provider components type conflict with Vue JSX
141
- C(Y.Provider, {
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 n.routingStrategy;
117
+ return r.routingStrategy;
144
118
  },
145
- children: e
146
- })), v(() => !n.routingStrategy && e)];
119
+ children: t
120
+ })), v(() => !r.routingStrategy && t)];
147
121
  }
148
- })), v(() => !n.defaultLocale && e)];
122
+ })), v(() => !r.defaultLocale && t)];
149
123
  }
150
- })), v(() => !n.locales && e)];
124
+ })), v(() => !r.locales && t)];
151
125
  }
152
126
  })
153
127
  );
154
128
  };
155
- function Ee(n) {
156
- const e = D(), t = F(), o = ee(), r = Se(), d = n?.locales || o, f = n?.defaultLocale || r, l = (a, s) => t?.resolvePath ? t.resolvePath(a, s || e.getLocale()) : a;
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: e,
133
+ instance: t,
160
134
  // Locale (reactive) - используем accessor для отслеживания изменений
161
- locale: S(() => e.localeAccessor()),
135
+ locale: P(() => t.localeAccessor()),
162
136
  // Locale helpers
163
- getLocales: () => d,
164
- defaultLocale: () => f,
165
- getLocaleName: () => d.find((s) => s.code === e.localeAccessor())?.displayName || null,
137
+ getLocales: () => f,
138
+ defaultLocale: () => h,
139
+ getLocaleName: () => f.find((s) => s.code === t.localeAccessor())?.displayName || null,
166
140
  // Routing helpers
167
- localeRoute: l,
141
+ localeRoute: c,
168
142
  localePath: (a, s) => {
169
- const c = l(a, s);
170
- return typeof c == "string" ? c : c.path || "/";
143
+ const l = c(a, s);
144
+ return typeof l == "string" ? l : l.path || "/";
171
145
  },
172
146
  switchLocale: (a) => {
173
- if (e.locale = a, t) {
174
- const s = t.getCurrentPath(), c = l(s, a);
175
- t.push(typeof c == "string" ? { path: c } : { path: c.path || "/" });
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: e.t.bind(e),
180
- ts: e.ts.bind(e),
181
- tc: e.tc.bind(e),
182
- tn: e.tn.bind(e),
183
- td: e.td.bind(e),
184
- tdr: e.tdr.bind(e),
185
- has: e.has.bind(e),
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: e.setRoute.bind(e),
188
- getRoute: e.getRoute.bind(e),
189
- getLocale: () => e.getLocale(),
161
+ setRoute: t.setRoute.bind(t),
162
+ getRoute: t.getRoute.bind(t),
163
+ getLocale: () => t.getLocale(),
190
164
  // Translation management
191
- addTranslations: e.addTranslations.bind(e),
192
- addRouteTranslations: e.addRouteTranslations.bind(e),
193
- clearCache: e.clearCache.bind(e)
165
+ addTranslations: t.addTranslations.bind(t),
166
+ addRouteTranslations: t.addRouteTranslations.bind(t),
167
+ clearCache: t.clearCache.bind(t)
194
168
  };
195
169
  }
196
- const je = (n) => {
197
- const e = D(), [t, o] = V(n, ["keypath", "params", "tag", "plural", "defaultValue", "html", "hideIfEmpty", "customPluralRule", "number", "date", "relativeDate"]), r = S(() => {
198
- const f = e.localeAccessor(), l = e.routeAccessor();
199
- if (t.number !== void 0) {
200
- const s = Number(t.number), c = e.tn(s), p = e.t(t.keypath, {
201
- number: c,
202
- ...t.params || {}
203
- }, void 0, l);
204
- return typeof p == "string" ? p : String(p);
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 (t.date !== void 0) {
207
- const s = e.td(t.date), c = e.t(t.keypath, {
180
+ if (e.date !== void 0) {
181
+ const s = t.td(e.date), l = t.t(e.keypath, {
208
182
  date: s,
209
- ...t.params || {}
210
- }, void 0, l);
211
- return typeof c == "string" ? c : String(c);
183
+ ...e.params || {}
184
+ }, void 0, c);
185
+ return typeof l == "string" ? l : String(l);
212
186
  }
213
- if (t.relativeDate !== void 0) {
214
- const s = e.tdr(t.relativeDate), c = e.t(t.keypath, {
187
+ if (e.relativeDate !== void 0) {
188
+ const s = t.tdr(e.relativeDate), l = t.t(e.keypath, {
215
189
  relativeDate: s,
216
- ...t.params || {}
217
- }, void 0, l);
218
- return typeof c == "string" ? c : String(c);
190
+ ...e.params || {}
191
+ }, void 0, c);
192
+ return typeof l == "string" ? l : String(l);
219
193
  }
220
- if (t.plural !== void 0) {
221
- const s = Number.parseInt(t.plural.toString());
222
- return t.customPluralRule ? t.customPluralRule(t.keypath, s, t.params || {}, f, (p, i, g) => e.t(p, i, g, l)) || "" : e.tc(t.keypath, {
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
- ...t.params || {}
225
- }, t.defaultValue);
198
+ ...e.params || {}
199
+ }, e.defaultValue);
226
200
  }
227
- const a = (e.t(t.keypath, t.params, t.defaultValue, l) ?? "").toString();
228
- return t.hideIfEmpty && !a.trim() ? t.defaultValue || "" : a;
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 (t.html)
204
+ if (e.html)
231
205
  return (
232
206
  // @ts-expect-error - Dynamic component type conflict with Vue JSX
233
- C(W, P({
207
+ k(W, R({
234
208
  get component() {
235
- return t.tag || "span";
209
+ return e.tag || "span";
236
210
  }
237
211
  }, o, {
238
212
  get innerHTML() {
239
- return r();
213
+ return n();
240
214
  }
241
215
  }))
242
216
  );
243
- const d = r();
244
- return t.hideIfEmpty && !d.trim() ? t.defaultValue ? C(W, P({
217
+ const f = n();
218
+ return e.hideIfEmpty && !f.trim() ? e.defaultValue ? k(W, R({
245
219
  get component() {
246
- return t.tag || "span";
220
+ return e.tag || "span";
247
221
  }
248
222
  }, o, {
249
223
  get children() {
250
- return t.defaultValue;
224
+ return e.defaultValue;
251
225
  }
252
226
  })) : null : (
253
227
  // @ts-expect-error - Dynamic component type conflict with Vue JSX
254
- C(W, P({
228
+ k(W, R({
255
229
  get component() {
256
- return t.tag || "span";
230
+ return e.tag || "span";
257
231
  }
258
232
  }, o, {
259
- children: d
233
+ children: f
260
234
  }))
261
235
  );
262
236
  };
263
- var Ce = /* @__PURE__ */ R('<a target=_blank rel="noopener noreferrer">'), Pe = /* @__PURE__ */ R("<a>");
264
- const Ve = (n) => {
265
- const e = F(), t = D(), [o, r] = V(n, ["to", "localeRoute", "activeStyle", "style", "children"]), f = e?.getCurrentPathAccessor, l = S(() => {
266
- const i = t.localeAccessor();
267
- let g;
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
- g = typeof y == "string" ? y : y?.path || "/";
271
- } else if (e?.resolvePath) {
272
- const y = e.resolvePath(o.to, i);
273
- g = typeof y == "string" ? y : y?.path || "/";
274
- } else typeof o.to == "string" ? g = o.to : g = o.to?.path || "/";
275
- return g;
276
- }), a = S(() => typeof o.to == "string" ? /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(o.to) : !1), s = S(() => {
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 = f ? f() : e ? e.getCurrentPath() : typeof window < "u" ? window.location.pathname : "/", g = l(), y = i === "/" ? "/" : i.replace(/\/$/, ""), B = g === "/" ? "/" : g.replace(/\/$/, "");
280
- return y === B;
281
- }), c = S(() => {
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
- }), p = e?.linkComponent;
261
+ }), g = t?.linkComponent;
288
262
  return a() ? (
289
263
  // @ts-expect-error - Type conflict with Vue JSX
290
264
  (() => {
291
- var i = Ce();
292
- return T(i, P({
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 c();
271
+ return l();
298
272
  }
299
- }, r), !1, !0), x(i, () => o.children), i;
273
+ }, n), !1, !0), x(i, () => o.children), i;
300
274
  })()
301
- ) : p ? (
275
+ ) : g ? (
302
276
  // @ts-expect-error - Type conflict with router component types
303
- C(p, P({
277
+ k(g, R({
304
278
  get href() {
305
- return l();
279
+ return c();
306
280
  },
307
281
  get style() {
308
- return c();
282
+ return l();
309
283
  }
310
- }, r, {
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 = Pe();
319
- return T(i, P({
292
+ var i = kt();
293
+ return T(i, R({
320
294
  get href() {
321
- return l();
295
+ return c();
322
296
  },
323
297
  get style() {
324
- return c();
298
+ return l();
325
299
  }
326
- }, r, {
327
- onClick: (g) => {
328
- e && !a() && (g.preventDefault(), e.push({
329
- path: l()
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 ke = /* @__PURE__ */ R("<div class=i18n-switcher-wrapper><button type=button class=i18n-switcher-button aria-haspopup=true><span></span><span>▼"), xe = /* @__PURE__ */ R("<ul class=i18n-switcher-dropdown>"), Re = /* @__PURE__ */ R("<li><a>");
337
- const Be = (n) => {
338
- const e = D(), t = F(), o = ee(), [r, d] = V(n, ["locales", "currentLocale", "getLocaleName", "switchLocale", "localeRoute", "customLabels", "customWrapperStyle", "customButtonStyle", "customDropdownStyle", "customItemStyle", "customLinkStyle", "customActiveLinkStyle", "customDisabledLinkStyle", "customIconStyle"]), [f, l] = I(!1);
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 = S(() => r.locales || o || []), c = S(() => r.currentLocale !== void 0 ? typeof r.currentLocale == "function" ? r.currentLocale() : r.currentLocale : e.localeAccessor()), p = S(() => r.getLocaleName ? r.getLocaleName() || null : s().find((m) => m.code === e.localeAccessor())?.displayName || null), i = (u) => {
341
- u && (u.stopPropagation(), u.preventDefault()), l(!f());
342
- }, g = (u) => r.customLabels?.[u.code] || u.displayName || u.code, y = S(() => {
343
- const u = s().find((m) => m.code === c());
344
- return u ? g(u) : p() || c();
345
- }), B = async (u) => {
346
- if (l(!1), r.switchLocale) {
347
- r.switchLocale(u);
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 (e.locale = u, !t)
324
+ if (t.locale = u, !e)
351
325
  return;
352
- const m = t, k = m.getCurrentPathAccessor ? m.getCurrentPathAccessor() : t.getCurrentPath(), w = r.localeRoute ? (() => {
353
- const h = r.localeRoute(k, u);
354
- return typeof h == "string" ? h : h.path || "/";
355
- })() : t?.resolvePath ? (() => {
356
- const h = t.resolvePath(k, u);
357
- return typeof h == "string" ? h : h.path || "/";
358
- })() : k;
359
- t.push({
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
- }, te = {
336
+ }, et = {
363
337
  position: "relative",
364
338
  display: "inline-block",
365
339
  "vertical-align": "middle"
366
- }, re = {
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
- }, ne = {
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
- }, oe = {
362
+ }, ot = {
389
363
  margin: "0",
390
364
  padding: "0"
391
- }, ae = {
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
- }, se = {
372
+ }, st = {
399
373
  "font-weight": "bold",
400
374
  color: "#007bff"
401
- }, ce = {
375
+ }, lt = {
402
376
  "margin-left": "8px",
403
377
  display: "inline-block",
404
378
  transition: "transform 0.3s ease"
405
- }, le = {
379
+ }, ct = {
406
380
  transform: "rotate(180deg)"
407
381
  }, Z = (u) => {
408
- if (!f()) return;
382
+ if (!h()) return;
409
383
  const m = u.target;
410
384
  if (!m || !a) return;
411
- const k = a.contains(m), w = m.closest(".i18n-switcher-button") !== null;
412
- !k && !w && l(!1);
385
+ const S = a.contains(m), w = m.closest(".i18n-switcher-button") !== null;
386
+ !S && !w && c(!1);
413
387
  };
414
- return de(() => {
388
+ return dt(() => {
415
389
  document.addEventListener("click", Z);
416
- }), he(() => {
390
+ }), ft(() => {
417
391
  document.removeEventListener("click", Z);
418
392
  }), (() => {
419
- var u = ke(), m = u.firstChild, k = m.firstChild, w = k.nextSibling;
420
- return ye((h) => {
421
- a = h;
422
- }, u), T(u, P({
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
- ...te,
426
- ...r.customWrapperStyle
399
+ ...et,
400
+ ...n.customWrapperStyle
427
401
  };
428
402
  }
429
- }, d), !1, !0), m.$$click = (h) => {
430
- h.preventDefault(), h.stopPropagation(), i(h);
431
- }, x(k, y), x(u, (() => {
432
- var h = v(() => !!f());
433
- return () => h() && (() => {
434
- var _ = xe();
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 === c(), q = t, M = q?.getCurrentPathAccessor ? q.getCurrentPathAccessor() : t?.getCurrentPath() || (typeof window < "u" ? window.location.pathname : "/"), z = r.localeRoute ? r.localeRoute(M, L.code) : t?.resolvePath ? t.resolvePath(M, L.code) : M, G = typeof z == "string" ? z : z?.path || "#";
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 = Re(), $ = O.firstChild;
439
- return $.$$click = (b) => {
440
- b.preventDefault(), b.stopPropagation(), B(L.code);
441
- }, K($, "href", typeof G == "string" ? G : "#"), x($, () => g(L)), H((b) => {
442
- var ie = {
443
- ...oe,
444
- ...r.customItemStyle
445
- }, J = `switcher-locale-${L.code}`, ue = {
446
- ...ae,
447
- ...N ? se : {},
448
- ...r.customLinkStyle,
449
- ...N ? r.customActiveLinkStyle : {}
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 = A(O, ie, b.e), J !== b.t && ve($, b.t = J), b.a = A($, ue, b.a), b;
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) => A(_, {
459
- ...ne,
460
- ...r.customDropdownStyle
432
+ })), H((L) => $(_, {
433
+ ...nt,
434
+ ...n.customDropdownStyle
461
435
  }, L)), _;
462
436
  })();
463
- })(), null), H((h) => {
437
+ })(), null), H((d) => {
464
438
  var _ = {
465
- ...re,
466
- ...r.customButtonStyle
467
- }, L = f(), N = {
468
- ...ce,
469
- ...f() ? le : {},
470
- ...r.customIconStyle
439
+ ...rt,
440
+ ...n.customButtonStyle
441
+ }, L = h(), N = {
442
+ ...lt,
443
+ ...h() ? ct : {},
444
+ ...n.customIconStyle
471
445
  };
472
- return h.e = A(m, _, h.e), L !== h.t && K(m, "aria-expanded", h.t = L), h.a = A(w, N, h.a), h;
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
- me(["click"]);
481
- var we = /* @__PURE__ */ R("<div>");
482
- const Me = (n) => {
483
- const e = D(), [t, o] = V(n, ["prefix", "groupClass"]), r = (d, f) => {
484
- const l = e.t(`${t.prefix}.${d}`, f, void 0, e.getRoute());
485
- return typeof l == "string" ? l : String(l);
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 d = we();
491
- return T(d, P({
464
+ var f = Ct();
465
+ return T(f, R({
492
466
  get class() {
493
- return ["i18n-group", t.groupClass].filter(Boolean).join(" ");
467
+ return ["i18n-group", e.groupClass].filter(Boolean).join(" ");
494
468
  }
495
- }, o), !1, !0), x(d, (() => {
496
- var f = v(() => typeof n.children == "function");
497
- return () => f() ? n.children({
498
- prefix: t.prefix,
499
- t: r
500
- }) : n.children;
501
- })()), d;
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 ze(n, e, t, o) {
506
- const r = n.map((a) => a.code), [d, f] = I(o.pathname);
507
- fe(() => {
508
- f(o.pathname);
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 l = (a, s) => {
511
- const p = (typeof a == "string" ? a : a.path || "/").split("/").filter(Boolean);
512
- p.length > 0 && r.includes(p[0]) && p.shift();
513
- const i = "/" + p.join("/");
514
- return s === e ? i : `/${s}${i === "/" ? "" : i}`;
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: () => d(),
491
+ getCurrentPath: () => f(),
518
492
  // Returns current value for compatibility
519
- getCurrentPathAccessor: d,
493
+ getCurrentPathAccessor: f,
520
494
  // Returns accessor for reactivity
521
495
  push: (a) => {
522
- t(a.path);
496
+ e(a.path);
523
497
  },
524
498
  replace: (a) => {
525
- t(a.path, {
499
+ e(a.path, {
526
500
  replace: !0
527
501
  });
528
502
  },
529
- resolvePath: (a, s) => l(a, s),
503
+ resolvePath: (a, s) => c(a, s),
530
504
  getRoute: () => ({
531
- fullPath: d(),
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: c,
539
- class: p,
512
+ children: l,
513
+ class: g,
540
514
  style: i,
541
- ...g
515
+ ...p
542
516
  } = a;
543
- return C(Le, P({
517
+ return k(vt, R({
544
518
  href: s,
545
- class: p,
519
+ class: g,
546
520
  style: i
547
- }, g, {
548
- children: c
521
+ }, p, {
522
+ children: l
549
523
  }));
550
524
  })
551
525
  };
552
526
  }
553
527
  export {
554
- He as FormatService,
528
+ Ot as FormatService,
555
529
  Q as I18nContext,
556
530
  X as I18nDefaultLocaleContext,
557
- Me as I18nGroup,
558
- Ve as I18nLink,
531
+ Vt as I18nGroup,
532
+ Et as I18nLink,
559
533
  U as I18nLocalesContext,
560
- Te as I18nProvider,
534
+ Dt as I18nProvider,
561
535
  Y as I18nRouterContext,
562
- Be as I18nSwitcher,
563
- je as I18nT,
564
- be as SolidI18n,
565
- Ne as createI18n,
566
- ze as createSolidRouterAdapter,
567
- Fe as defaultPlural,
568
- Ze as interpolate,
569
- Ee as useI18n,
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
- Se as useI18nDefaultLocale,
572
- ee as useI18nLocales,
545
+ bt as useI18nDefaultLocale,
546
+ tt as useI18nLocales,
573
547
  F as useI18nRouter
574
548
  };
575
549
  //# sourceMappingURL=index.mjs.map