@i18n-micro/preact 1.2.17 → 2.0.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/LICENSE +1 -1
- package/README.md +17 -57
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +123 -114
- package/dist/index.d.ts +123 -114
- package/dist/index.mjs +270 -319
- package/dist/index.mjs.map +1 -1
- package/dist/router.cjs +2 -0
- package/dist/router.cjs.map +1 -0
- package/dist/router.d.cts +70 -0
- package/dist/router.d.ts +70 -0
- package/dist/router.mjs +33 -0
- package/dist/router.mjs.map +1 -0
- package/package.json +31 -14
package/dist/index.mjs
CHANGED
|
@@ -1,348 +1,299 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { I18n as e, createI18n as t, createI18n as n } from "@i18n-micro/runtime";
|
|
2
|
+
import { FormatService as r, defaultPlural as i, externalLinkHref as a, interpolate as o, isActiveLink as s, isPlainClick as c, localeIsoMap as l, ownValue as u } from "@i18n-micro/core";
|
|
3
|
+
import { Fragment as d, createContext as f, h as p } from "preact";
|
|
4
|
+
import { useContext as m, useEffect as h, useLayoutEffect as g, useMemo as _, useRef as v, useState as y } from "preact/hooks";
|
|
5
|
+
import { SWITCHER_STYLES as b, renderI18nT as x } from "@i18n-micro/core/render";
|
|
6
|
+
// src/host.ts
|
|
7
|
+
var S = {
|
|
8
|
+
h: p,
|
|
9
|
+
Fragment: d,
|
|
10
|
+
markup: (e) => ({ dangerouslySetInnerHTML: { __html: e } }),
|
|
11
|
+
dated: {}
|
|
12
|
+
};
|
|
13
|
+
function C(e, t) {
|
|
14
|
+
let n = t(), [, r] = y(0), i = v({
|
|
15
|
+
read: t,
|
|
16
|
+
value: n
|
|
17
|
+
});
|
|
18
|
+
return i.current = {
|
|
19
|
+
read: t,
|
|
20
|
+
value: n
|
|
21
|
+
}, g(() => {
|
|
22
|
+
let t = () => {
|
|
23
|
+
i.current.read() !== i.current.value && r((e) => e + 1);
|
|
24
|
+
};
|
|
25
|
+
return t(), e(t);
|
|
26
|
+
}, [e]), n;
|
|
27
|
+
}
|
|
28
|
+
var w = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, T = ([e, t]) => e === "cssText" ? String(t) : e[0] === "-" ? `${e}:${t}` : `${e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`)}:${typeof t == "number" && !w.test(e) ? `${t}px` : t}`, E = (e) => typeof e == "string" ? e : Object.entries(e).filter(([, e]) => e != null).map(T).join(";");
|
|
29
|
+
function D(...e) {
|
|
30
|
+
let t = e.filter((e) => e != null);
|
|
31
|
+
return t.some((e) => typeof e == "string") ? t.map(E).filter(Boolean).join(";") : Object.assign({}, ...t);
|
|
32
|
+
}
|
|
33
|
+
// ../react/src/injection.ts
|
|
34
|
+
var O = f(null), k = f(null), A = () => {
|
|
35
|
+
let e = m(O);
|
|
8
36
|
if (!e) throw Error("[i18n-micro] I18nContext not found. Make sure I18nProvider is used.");
|
|
9
37
|
return e;
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
38
|
+
}, j = () => m(k)?.locales ?? null, M = () => m(k)?.defaultLocale ?? null, N = () => m(k)?.router ?? null;
|
|
39
|
+
// ../react/src/context.tsx
|
|
40
|
+
function P(e) {
|
|
41
|
+
if (!e.locale) throw Error("[i18n-micro] I18nProvider needs an `i18n` instance, an outer provider, or a `locale`.");
|
|
42
|
+
return n(e);
|
|
15
43
|
}
|
|
16
|
-
|
|
17
|
-
let
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
let
|
|
44
|
+
function F({ i18n: e, locales: t, defaultLocale: n, routingStrategy: r, children: i, ...a }) {
|
|
45
|
+
let o = m(O), s = m(k), c = e ?? o, u = _(() => c ?? P(a), [c, a.locale]), d = v(null), f = v(null);
|
|
46
|
+
t && f.current !== u && u.addLocaleIso(l(t), !1), h(() => {
|
|
47
|
+
f.current = u, t && u.addLocaleIso(l(t));
|
|
48
|
+
}, [u, t]);
|
|
49
|
+
let g = _(() => ({
|
|
50
|
+
locales: t ?? s?.locales ?? null,
|
|
51
|
+
defaultLocale: n ?? s?.defaultLocale ?? null,
|
|
52
|
+
router: r ?? s?.router ?? null,
|
|
53
|
+
api: null,
|
|
54
|
+
methods: d
|
|
55
|
+
}), [
|
|
56
|
+
t,
|
|
57
|
+
n,
|
|
58
|
+
r,
|
|
59
|
+
s
|
|
60
|
+
]);
|
|
61
|
+
return p(O.Provider, { value: u }, p(k.Provider, { value: g }, i));
|
|
62
|
+
}
|
|
63
|
+
var I = (e) => typeof e == "string" ? e : e.path || "/", L = (e) => ({
|
|
64
|
+
addTranslations: e.addTranslations.bind(e),
|
|
65
|
+
addRouteTranslations: e.addRouteTranslations.bind(e),
|
|
66
|
+
clearCache: e.clearCache.bind(e)
|
|
67
|
+
});
|
|
68
|
+
function R(e, t, n) {
|
|
69
|
+
let r = n?.current;
|
|
70
|
+
if (r && r.i18n === e && r.snapshot === t) return r;
|
|
71
|
+
let i = {
|
|
72
|
+
...r?.i18n === e ? r : L(e),
|
|
73
|
+
i18n: e,
|
|
74
|
+
snapshot: t,
|
|
75
|
+
t: e.t.bind(e),
|
|
76
|
+
ts: e.ts.bind(e),
|
|
77
|
+
tc: e.tc.bind(e),
|
|
78
|
+
tn: e.tn.bind(e),
|
|
79
|
+
td: e.td.bind(e),
|
|
80
|
+
tdr: e.tdr.bind(e),
|
|
81
|
+
has: e.has.bind(e)
|
|
82
|
+
};
|
|
83
|
+
return n && (n.current = i), i;
|
|
84
|
+
}
|
|
85
|
+
function z(e, { locales: t, defaultLocale: n, router: r }, i) {
|
|
86
|
+
let a = t ?? [], o = (t, n) => r?.resolvePath ? r.resolvePath(t, n || e.locale) : t, { t: s, ts: c, tc: l, tn: u, td: d, tdr: f, has: p, addTranslations: m, addRouteTranslations: h, clearCache: g } = i;
|
|
22
87
|
return {
|
|
23
|
-
t:
|
|
24
|
-
ts:
|
|
25
|
-
tc:
|
|
26
|
-
tn:
|
|
27
|
-
td:
|
|
28
|
-
tdr:
|
|
29
|
-
has:
|
|
88
|
+
t: s,
|
|
89
|
+
ts: c,
|
|
90
|
+
tc: l,
|
|
91
|
+
tn: u,
|
|
92
|
+
td: d,
|
|
93
|
+
tdr: f,
|
|
94
|
+
has: p,
|
|
30
95
|
get locale() {
|
|
31
|
-
return
|
|
96
|
+
return e.locale;
|
|
32
97
|
},
|
|
33
98
|
get fallbackLocale() {
|
|
34
|
-
return
|
|
99
|
+
return e.fallbackLocale;
|
|
35
100
|
},
|
|
36
101
|
get currentRoute() {
|
|
37
|
-
return
|
|
102
|
+
return e.currentRoute;
|
|
38
103
|
},
|
|
39
|
-
setLocale: (
|
|
40
|
-
|
|
104
|
+
setLocale: (t) => {
|
|
105
|
+
e.locale = t;
|
|
41
106
|
},
|
|
42
|
-
setRoute:
|
|
43
|
-
getRoute:
|
|
44
|
-
getLocales: () =>
|
|
45
|
-
defaultLocale: () =>
|
|
46
|
-
getLocaleName: () =>
|
|
47
|
-
switchLocale: (
|
|
48
|
-
|
|
49
|
-
let t = n.getCurrentPath(), r = u(t, e);
|
|
50
|
-
n.push(typeof r == "string" ? { path: r } : { path: r.path || "/" });
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
localeRoute: u,
|
|
54
|
-
localePath: (e, t) => {
|
|
55
|
-
let n = u(e, t);
|
|
56
|
-
return typeof n == "string" ? n : n.path || "/";
|
|
107
|
+
setRoute: e.setRoute.bind(e),
|
|
108
|
+
getRoute: e.getRoute.bind(e),
|
|
109
|
+
getLocales: () => a,
|
|
110
|
+
defaultLocale: () => n ?? e.fallbackLocale,
|
|
111
|
+
getLocaleName: () => a.find((t) => t.code === e.locale)?.displayName || null,
|
|
112
|
+
switchLocale: (t) => {
|
|
113
|
+
e.locale = t, r && r.push({ path: I(o(r.getCurrentPath(), t)) });
|
|
57
114
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
115
|
+
localeRoute: o,
|
|
116
|
+
localePath: (e, t) => I(o(e, t)),
|
|
117
|
+
addTranslations: m,
|
|
118
|
+
addRouteTranslations: h,
|
|
119
|
+
clearCache: g
|
|
61
120
|
};
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
let e = l(r);
|
|
81
|
-
return typeof e == "string" ? e : e.path || "/";
|
|
82
|
-
}
|
|
83
|
-
if (!n?.resolvePath) return typeof r == "string" ? r : r.path || "/";
|
|
84
|
-
let e = n.resolvePath(r, t.locale);
|
|
85
|
-
return typeof e == "string" ? e : e.path || "/";
|
|
86
|
-
}, p = (() => {
|
|
87
|
-
if (u() || !n) return !1;
|
|
88
|
-
let e = n.getCurrentPath(), t = f(), r = e.replace(/\/$/, ""), i = t.replace(/\/$/, "");
|
|
89
|
-
return !!(r === i || r.startsWith(`${i}/`));
|
|
90
|
-
})() && i || {}, m = f(), h = (t) => {
|
|
91
|
-
e.onClick && e.onClick(t), !t.defaultPrevented && !t.button && !t.metaKey && !t.ctrlKey && n && !u() && (t.preventDefault(), n.push({ path: m }));
|
|
92
|
-
};
|
|
93
|
-
if (u()) return a("a", {
|
|
94
|
-
...c,
|
|
95
|
-
href: d(),
|
|
96
|
-
style: p,
|
|
97
|
-
target: "_blank",
|
|
98
|
-
rel: "noopener noreferrer"
|
|
99
|
-
}, s);
|
|
100
|
-
if (n?.linkComponent) {
|
|
101
|
-
let e = n.linkComponent;
|
|
102
|
-
if (typeof e == "string") return a(e, {
|
|
103
|
-
...c,
|
|
104
|
-
href: m,
|
|
105
|
-
style: p
|
|
106
|
-
}, s);
|
|
107
|
-
let t = e, r = {
|
|
108
|
-
...c,
|
|
109
|
-
href: m,
|
|
110
|
-
style: p
|
|
111
|
-
};
|
|
112
|
-
return a(t, r, s);
|
|
113
|
-
}
|
|
114
|
-
return a("a", {
|
|
115
|
-
...c,
|
|
116
|
-
href: m,
|
|
117
|
-
style: p,
|
|
118
|
-
onClick: h
|
|
119
|
-
}, s);
|
|
121
|
+
}
|
|
122
|
+
var B = (e) => {
|
|
123
|
+
let t = A(), n = m(k), r = C(t.subscribe, t.getSnapshot), i = e?.locales ?? n?.locales ?? null, a = e?.defaultLocale ?? n?.defaultLocale ?? null, o = n?.router ?? null, s = n && !e?.locales && !e?.defaultLocale ? n : null, c = _(() => s ? null : z(t, {
|
|
124
|
+
locales: i,
|
|
125
|
+
defaultLocale: a,
|
|
126
|
+
router: o
|
|
127
|
+
}, R(t, r, n?.methods)), [
|
|
128
|
+
s,
|
|
129
|
+
t,
|
|
130
|
+
r,
|
|
131
|
+
i,
|
|
132
|
+
a,
|
|
133
|
+
o
|
|
134
|
+
]);
|
|
135
|
+
return c || !s ? c : (s.api?.snapshot !== r && (s.api = {
|
|
136
|
+
snapshot: r,
|
|
137
|
+
value: z(t, s, R(t, r, s.methods))
|
|
138
|
+
}), s.api.value);
|
|
120
139
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
return typeof e == "function" ? e() : typeof e == "string" ? e : t;
|
|
140
|
+
function V(e, t, n, r) {
|
|
141
|
+
let i = A();
|
|
142
|
+
return C(i.subscribe, () => i.ts(e, t, n, r));
|
|
125
143
|
}
|
|
126
|
-
|
|
127
|
-
let {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
i(
|
|
135
|
-
return;
|
|
144
|
+
function H(e) {
|
|
145
|
+
let { switchLocale: t } = B(), [n, r] = y(!1), i = v(0), a = v(t);
|
|
146
|
+
return a.current = t, [async (t) => {
|
|
147
|
+
let n = ++i.current;
|
|
148
|
+
r(!0);
|
|
149
|
+
try {
|
|
150
|
+
await e(t), n === i.current && a.current(t);
|
|
151
|
+
} finally {
|
|
152
|
+
n === i.current && r(!1);
|
|
136
153
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
},
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
transition: "transform 0.3s ease"
|
|
190
|
-
}, J = { transform: "rotate(180deg)" };
|
|
191
|
-
s(() => {
|
|
192
|
-
if (!k) return;
|
|
154
|
+
}, n];
|
|
155
|
+
}
|
|
156
|
+
// ../react/src/components/I18nGroup.tsx
|
|
157
|
+
var U = (e) => {
|
|
158
|
+
let { prefix: t, groupClass: n, children: r, className: i, class: a, ...o } = e, { ts: s } = B(), c = (e, n) => s(`${t}.${e}`, n);
|
|
159
|
+
return p("div", {
|
|
160
|
+
...o,
|
|
161
|
+
className: [
|
|
162
|
+
"i18n-group",
|
|
163
|
+
n,
|
|
164
|
+
i,
|
|
165
|
+
a
|
|
166
|
+
].filter(Boolean).join(" ")
|
|
167
|
+
}, typeof r == "function" ? r({
|
|
168
|
+
prefix: t,
|
|
169
|
+
t: c
|
|
170
|
+
}) : r);
|
|
171
|
+
}, W = (e) => {
|
|
172
|
+
let t = B(), n = N(), { to: r, activeStyle: i, localeRoute: o = t.localeRoute, style: l, onClick: u, children: d, ...f } = e, m = a(r);
|
|
173
|
+
if (m !== void 0) return p("a", {
|
|
174
|
+
target: "_blank",
|
|
175
|
+
rel: "noopener noreferrer",
|
|
176
|
+
...f,
|
|
177
|
+
onClick: u,
|
|
178
|
+
style: l,
|
|
179
|
+
href: m
|
|
180
|
+
}, d);
|
|
181
|
+
let h = I(o(r)), g = i && n && s(n.getCurrentPath(), h, [
|
|
182
|
+
t.locale,
|
|
183
|
+
t.defaultLocale(),
|
|
184
|
+
t.fallbackLocale,
|
|
185
|
+
...t.getLocales().map((e) => e.code)
|
|
186
|
+
]), _ = {
|
|
187
|
+
...f,
|
|
188
|
+
href: h,
|
|
189
|
+
style: g ? D(l, i) : l
|
|
190
|
+
};
|
|
191
|
+
if (n?.linkComponent) return p(n.linkComponent, {
|
|
192
|
+
..._,
|
|
193
|
+
onClick: u
|
|
194
|
+
}, d);
|
|
195
|
+
let v = (e) => {
|
|
196
|
+
u?.(e), n && c(e) && (e.preventDefault(), n.push({ path: h }));
|
|
197
|
+
};
|
|
198
|
+
return p("a", {
|
|
199
|
+
..._,
|
|
200
|
+
onClick: v
|
|
201
|
+
}, d);
|
|
202
|
+
}, G = (e) => {
|
|
203
|
+
let { locales: t, currentLocale: n, getLocaleName: r, switchLocale: i, localeRoute: a, customLabels: o, customWrapperStyle: s, customButtonStyle: l, customDropdownStyle: d, customItemStyle: f, customLinkStyle: m, customActiveLinkStyle: g, customDisabledLinkStyle: _, customIconStyle: x, className: S, class: C, style: w, ...T } = e, E = B(), O = N(), k = j(), [A, M] = y(!1), P = v(null), F = t ?? k ?? E.getLocales(), L = typeof n == "function" ? n() : n ?? E.locale, R = F.find((e) => e.code === L);
|
|
204
|
+
h(() => {
|
|
205
|
+
if (!A) return;
|
|
193
206
|
let e = (e) => {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
let n = j.current.contains(t), r = t.closest(".i18n-switcher-button") !== null;
|
|
198
|
-
!n && !r && A(!1);
|
|
199
|
-
};
|
|
200
|
-
return document.addEventListener("click", e), () => {
|
|
201
|
-
document.removeEventListener("click", e);
|
|
207
|
+
P.current?.contains(e.target) || M(!1);
|
|
208
|
+
}, t = (e) => {
|
|
209
|
+
e.key === "Escape" && M(!1);
|
|
202
210
|
};
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
...V,
|
|
206
|
-
...d
|
|
207
|
-
}, X = {
|
|
208
|
-
...H,
|
|
209
|
-
...f,
|
|
210
|
-
...F ? x : {}
|
|
211
|
-
}, Z = {
|
|
212
|
-
...U,
|
|
213
|
-
...p
|
|
214
|
-
}, Q = {
|
|
215
|
-
...W,
|
|
216
|
-
...m
|
|
217
|
-
}, $ = {
|
|
218
|
-
...q,
|
|
219
|
-
...k ? J : {},
|
|
220
|
-
...S
|
|
221
|
-
}, ee = N.map((e) => {
|
|
222
|
-
let t = e.code === P, n = {
|
|
223
|
-
...G,
|
|
224
|
-
...t ? K : {},
|
|
225
|
-
..._,
|
|
226
|
-
...t ? y : {},
|
|
227
|
-
width: "100%",
|
|
228
|
-
textAlign: "left",
|
|
229
|
-
border: "none",
|
|
230
|
-
background: "transparent"
|
|
211
|
+
return document.addEventListener("click", e), document.addEventListener("keydown", t), () => {
|
|
212
|
+
document.removeEventListener("click", e), document.removeEventListener("keydown", t);
|
|
231
213
|
};
|
|
232
|
-
|
|
214
|
+
}, [A]);
|
|
215
|
+
let z = (e) => o && u(o, e.code) || e.displayName || e.code, V = (e) => {
|
|
216
|
+
let t = O?.getCurrentPath() ?? (typeof window > "u" ? "/" : window.location.pathname + window.location.search + window.location.hash);
|
|
217
|
+
return a ? I(a(t, e)) : O ? I(O.resolvePath ? O.resolvePath(t, e) : t) : "#";
|
|
218
|
+
}, H = (e, t) => {
|
|
219
|
+
if (c(e)) {
|
|
220
|
+
if ((i || O || !a) && e.preventDefault(), M(!1), i) return i(t);
|
|
221
|
+
if (!a) return E.switchLocale(t);
|
|
222
|
+
E.setLocale(t), O?.push({ path: V(t) });
|
|
223
|
+
}
|
|
224
|
+
}, U = (e) => {
|
|
225
|
+
let t = e.code === L, n = e.iso || e.code;
|
|
226
|
+
return p("li", {
|
|
233
227
|
key: e.code,
|
|
234
|
-
style:
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
className: `switcher-locale-${e.code}`,
|
|
238
|
-
style: n,
|
|
239
|
-
onClick: (t) => {
|
|
240
|
-
t.preventDefault(), t.stopPropagation(), B(e.code);
|
|
228
|
+
style: {
|
|
229
|
+
...b.item,
|
|
230
|
+
...f
|
|
241
231
|
}
|
|
242
|
-
},
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
232
|
+
}, p("a", {
|
|
233
|
+
className: `switcher-locale-${e.code}`,
|
|
234
|
+
href: V(e.code),
|
|
235
|
+
hrefLang: n,
|
|
236
|
+
lang: n,
|
|
237
|
+
dir: e.dir,
|
|
238
|
+
"aria-current": t ? "page" : void 0,
|
|
239
|
+
style: {
|
|
240
|
+
...b.link,
|
|
241
|
+
...t ? b.activeLink : null,
|
|
242
|
+
...m,
|
|
243
|
+
...t ? g : null
|
|
244
|
+
},
|
|
245
|
+
onClick: (t) => H(t, e.code)
|
|
246
|
+
}, z(e)));
|
|
247
|
+
};
|
|
248
|
+
return p("div", {
|
|
249
|
+
...T,
|
|
250
|
+
ref: P,
|
|
251
|
+
className: [
|
|
252
|
+
"i18n-switcher-wrapper",
|
|
253
|
+
S,
|
|
254
|
+
C
|
|
255
|
+
].filter(Boolean).join(" "),
|
|
256
|
+
style: D(b.wrapper, s, w)
|
|
257
|
+
}, p("button", {
|
|
250
258
|
type: "button",
|
|
251
|
-
className: "i18n-switcher-button",
|
|
252
|
-
style:
|
|
253
|
-
|
|
254
|
-
|
|
259
|
+
className: "i18n-switcher-button language-switcher",
|
|
260
|
+
style: {
|
|
261
|
+
...b.button,
|
|
262
|
+
...l,
|
|
263
|
+
...R?.disabled ? _ : null
|
|
255
264
|
},
|
|
256
|
-
"aria-
|
|
257
|
-
|
|
258
|
-
},
|
|
265
|
+
"aria-expanded": A,
|
|
266
|
+
onClick: () => M(!A)
|
|
267
|
+
}, p("span", null, r?.() || z(R ?? { code: L })), " ", p("span", { style: {
|
|
268
|
+
...b.icon,
|
|
269
|
+
...A ? b.openIcon : null,
|
|
270
|
+
...x
|
|
271
|
+
} }, "▾")), A ? p("ul", {
|
|
259
272
|
className: "i18n-switcher-dropdown",
|
|
260
|
-
style:
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}, void 0) : w(f, S, n);
|
|
273
|
-
}
|
|
274
|
-
if (y !== void 0) {
|
|
275
|
-
let e = t(u, {
|
|
276
|
-
date: o(y),
|
|
277
|
-
...d || {}
|
|
278
|
-
}, void 0, C), n = typeof e == "string" ? e : String(e);
|
|
279
|
-
return h ? w(f, {
|
|
280
|
-
...S,
|
|
281
|
-
dangerouslySetInnerHTML: { __html: n }
|
|
282
|
-
}, void 0) : w(f, S, n);
|
|
283
|
-
}
|
|
284
|
-
if (x !== void 0) {
|
|
285
|
-
let e = t(u, {
|
|
286
|
-
relativeDate: s(x),
|
|
287
|
-
...d || {}
|
|
288
|
-
}, void 0, C), n = typeof e == "string" ? e : String(e);
|
|
289
|
-
return h ? w(f, {
|
|
290
|
-
...S,
|
|
291
|
-
dangerouslySetInnerHTML: { __html: n }
|
|
292
|
-
}, void 0) : w(f, S, n);
|
|
293
|
-
}
|
|
294
|
-
if (p !== void 0) {
|
|
295
|
-
let e = Number.parseInt(p.toString(), 10), r;
|
|
296
|
-
return r = _ ? _(u, e, d || {}, c, (e, n, r) => {
|
|
297
|
-
let i = t(e, n, r, C);
|
|
298
|
-
return typeof i == "string" ? i : String(i);
|
|
299
|
-
}) || "" : n(u, {
|
|
300
|
-
count: e,
|
|
301
|
-
...d || {}
|
|
302
|
-
}, m), h ? w(f, {
|
|
303
|
-
...S,
|
|
304
|
-
dangerouslySetInnerHTML: { __html: r }
|
|
305
|
-
}, void 0) : w(f, S, r);
|
|
273
|
+
style: {
|
|
274
|
+
...b.dropdown,
|
|
275
|
+
...d
|
|
276
|
+
}
|
|
277
|
+
}, F.filter((e) => !e.disabled).map(U)) : null);
|
|
278
|
+
}, K = {}, q = (e) => e == null || typeof e == "boolean", J = ({ render: e }) => e();
|
|
279
|
+
function Y({ h: e }, t, n) {
|
|
280
|
+
if (!t && q(n)) return K;
|
|
281
|
+
let r = Object.create(null);
|
|
282
|
+
for (let n of Object.keys(t ?? {})) {
|
|
283
|
+
let i = t[n];
|
|
284
|
+
i !== void 0 && (r[n] = typeof i == "function" ? () => e(J, { render: i }) : () => i);
|
|
306
285
|
}
|
|
307
|
-
|
|
308
|
-
return g && !E.trim() ? m ? a(r, null, m) : null : h ? w(f, {
|
|
309
|
-
...S,
|
|
310
|
-
dangerouslySetInnerHTML: { __html: E }
|
|
311
|
-
}, void 0) : w(f, S, E);
|
|
312
|
-
}, E = class extends u {};
|
|
313
|
-
function D(e) {
|
|
314
|
-
return new E(e);
|
|
286
|
+
return q(n) || (r.default = typeof n == "function" ? n : () => n), r;
|
|
315
287
|
}
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
let n = e.map((e) => e.code), r = (e, r) => {
|
|
320
|
-
let i = (typeof e == "string" ? e : e.path || "/").split("/").filter(Boolean), a = i[0];
|
|
321
|
-
a !== void 0 && n.includes(a) && i.shift();
|
|
322
|
-
let o = `/${i.join("/")}`;
|
|
323
|
-
return r === t ? o : `/${r}${o === "/" ? "" : o}`;
|
|
324
|
-
};
|
|
325
|
-
return {
|
|
326
|
-
linkComponent: void 0,
|
|
327
|
-
getCurrentPath: () => typeof window < "u" ? window.location.pathname : "/",
|
|
328
|
-
push: (e) => {
|
|
329
|
-
typeof window < "u" && (window.history.pushState({}, "", e.path), window.dispatchEvent(new Event("popstate")));
|
|
330
|
-
},
|
|
331
|
-
replace: (e) => {
|
|
332
|
-
typeof window < "u" && (window.history.replaceState({}, "", e.path), window.dispatchEvent(new Event("popstate")));
|
|
333
|
-
},
|
|
334
|
-
resolvePath: (e, t) => r(e, t),
|
|
335
|
-
getRoute: () => typeof window < "u" ? {
|
|
336
|
-
fullPath: window.location.pathname + window.location.search,
|
|
337
|
-
query: Object.fromEntries(new URLSearchParams(window.location.search))
|
|
338
|
-
} : {
|
|
339
|
-
fullPath: "/",
|
|
340
|
-
query: {}
|
|
341
|
-
}
|
|
342
|
-
};
|
|
288
|
+
function X(e, t, n) {
|
|
289
|
+
let { keypath: r, params: i, tag: a, plural: o, defaultValue: s, html: c, hideIfEmpty: l, customPluralRule: u, number: d, date: f, relativeDate: p, components: m, children: h, ...g } = n;
|
|
290
|
+
return x(e, t, n, Y(e, m, h), g);
|
|
343
291
|
}
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
292
|
+
// ../react/src/components/I18nT.tsx
|
|
293
|
+
var Z = (e) => {
|
|
294
|
+
let t = A();
|
|
295
|
+
return C(t.subscribe, t.getSnapshot), X(S, t, e);
|
|
296
|
+
};
|
|
297
|
+
export { r as FormatService, k as I18nConfigContext, O as I18nContext, U as I18nGroup, W as I18nLink, F as I18nProvider, G as I18nSwitcher, Z as I18nT, e as PreactI18n, t as createI18n, i as defaultPlural, o as interpolate, B as useI18n, A as useI18nContext, M as useI18nDefaultLocale, j as useI18nLocales, N as useI18nRouter, H as useLocaleSwitch, V as useT };
|
|
347
298
|
|
|
348
299
|
//# sourceMappingURL=index.mjs.map
|