@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/dist/index.mjs CHANGED
@@ -1,348 +1,299 @@
1
- import { FormatService as e, defaultPlural as t, interpolate as n } from "@i18n-micro/core";
2
- import { Fragment as r, createContext as i, h as a } from "preact";
3
- import { useContext as o, useEffect as s, useRef as c, useState as l } from "preact/hooks";
4
- import { I18n as u } from "@i18n-micro/runtime";
5
- //#region src/injection.ts
6
- var d = i(null), f = i(null), p = i(null), m = i(null), h = () => {
7
- let e = o(d);
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
- }, g = () => o(f), _ = () => o(p), v = () => o(m);
11
- //#endregion
12
- //#region src/context.tsx
13
- function y({ i18n: e, locales: t, defaultLocale: n, routingStrategy: r, children: i }) {
14
- return a(d.Provider, { value: e }, t ? a(f.Provider, { value: t }, n ? a(p.Provider, { value: n }, r ? a(m.Provider, { value: r }, i) : i) : i) : i);
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
- var b = (e) => {
17
- let t = h(), n = v(), r = g(), i = _(), [, a] = l(0);
18
- s(() => t.subscribe(() => {
19
- a((e) => e + 1);
20
- }), [t]);
21
- let o = e?.locales || r || [], c = e?.defaultLocale || i || t.locale, u = (e, r) => n?.resolvePath ? n.resolvePath(e, r || t.locale) : e;
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: t.t.bind(t),
24
- ts: t.ts.bind(t),
25
- tc: t.tc.bind(t),
26
- tn: t.tn.bind(t),
27
- td: t.td.bind(t),
28
- tdr: t.tdr.bind(t),
29
- has: t.has.bind(t),
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 t.locale;
96
+ return e.locale;
32
97
  },
33
98
  get fallbackLocale() {
34
- return t.fallbackLocale;
99
+ return e.fallbackLocale;
35
100
  },
36
101
  get currentRoute() {
37
- return t.currentRoute;
102
+ return e.currentRoute;
38
103
  },
39
- setLocale: (e) => {
40
- t.locale = e;
104
+ setLocale: (t) => {
105
+ e.locale = t;
41
106
  },
42
- setRoute: t.setRoute.bind(t),
43
- getRoute: t.getRoute.bind(t),
44
- getLocales: () => o,
45
- defaultLocale: () => c,
46
- getLocaleName: () => o.find((e) => e.code === t.locale)?.displayName || null,
47
- switchLocale: (e) => {
48
- if (t.locale = e, n) {
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
- addTranslations: t.addTranslations.bind(t),
59
- addRouteTranslations: t.addRouteTranslations.bind(t),
60
- clearCache: t.clearCache.bind(t)
115
+ localeRoute: o,
116
+ localePath: (e, t) => I(o(e, t)),
117
+ addTranslations: m,
118
+ addRouteTranslations: h,
119
+ clearCache: g
61
120
  };
62
- }, x = (e) => {
63
- let { prefix: t, groupClass: n, children: r, ...i } = e, { t: o, getRoute: s } = b(), c = (e, n) => {
64
- let r = o(`${t}.${e}`, n, void 0, s());
65
- return typeof r == "string" ? r : String(r);
66
- }, l = ["i18n-group", n].filter(Boolean).join(" "), u = typeof r == "function" ? r({
67
- prefix: t,
68
- t: c
69
- }) : r;
70
- return a("div", {
71
- ...i,
72
- className: l
73
- }, u);
74
- }, S = (e) => {
75
- let t = b(), n = v(), { to: r, activeStyle: i, localeRoute: o, children: s, ...c } = e, l = o || t.localeRoute, u = () => typeof r == "string" && /^(?:https?:\/\/|\/\/|[a-zA-Z0-9-]+\.[a-zA-Z]{2,})|tel:|mailto:/.test(r), d = () => {
76
- if (u() && typeof r == "string") return /^https?:\/\//.test(r) ? r : `https://${r}`;
77
- }, f = () => {
78
- if (u()) return typeof r == "string" ? r : r?.path || "/";
79
- if (l) {
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
- //#endregion
122
- //#region src/components/I18nSwitcher.tsx
123
- function C(e, t) {
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
- var w = (e) => {
127
- let { locales: t, currentLocale: n, getLocaleName: r, switchLocale: i, localeRoute: o, customLabels: u = {}, customWrapperStyle: d, customButtonStyle: f, customDropdownStyle: p, customItemStyle: m, customLinkStyle: _, customActiveLinkStyle: y, customDisabledLinkStyle: x = {}, customIconStyle: S, ...w } = e, T = b(), E = h(), D = v(), O = g(), [k, A] = l(!1), j = c(null), M = t || O || T.getLocales() || [], N = M.filter((e) => !e.disabled), P = C(n, T.locale), F = M.some((e) => e.code === P && e.disabled), I = r ? r() : T.getLocaleName(), L = (e) => {
128
- e && (e.stopPropagation(), e.preventDefault()), A(!k);
129
- }, R = (e) => u[e.code] || e.displayName || e.code, z = () => {
130
- let e = N.find((e) => e.code === P);
131
- return e ? R(e) : I || P;
132
- }, B = (t) => {
133
- if (A(!1), i) {
134
- i(t);
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
- if (E.locale = t, !D) return;
138
- let n = D.getCurrentPath(), r = e.localeRoute ? (() => {
139
- let r = e.localeRoute(n, t);
140
- return typeof r == "string" ? r : r.path || "/";
141
- })() : D?.resolvePath ? (() => {
142
- let e = D.resolvePath(n, t);
143
- return typeof e == "string" ? e : e.path || "/";
144
- })() : n;
145
- D.push({ path: r });
146
- }, V = {
147
- position: "relative",
148
- display: "inline-block",
149
- verticalAlign: "middle"
150
- }, H = {
151
- padding: "4px 12px",
152
- fontSize: "16px",
153
- cursor: "pointer",
154
- backgroundColor: "#fff",
155
- border: "1px solid #333",
156
- transition: "background-color 0.3s ease",
157
- display: "flex",
158
- alignItems: "center",
159
- justifyContent: "space-between"
160
- }, U = {
161
- position: "absolute",
162
- top: "100%",
163
- left: "0",
164
- zIndex: 1e3,
165
- backgroundColor: "#fff",
166
- border: "1px solid #333",
167
- listStyle: "none",
168
- padding: "0",
169
- margin: "4px 0 0 0",
170
- minWidth: "150px",
171
- boxShadow: "0 2px 8px rgba(0,0,0,0.15)"
172
- }, W = {
173
- margin: "0",
174
- padding: "0"
175
- }, G = {
176
- display: "block",
177
- padding: "8px 12px",
178
- color: "#333",
179
- textDecoration: "none",
180
- transition: "background-color 0.3s ease",
181
- cursor: "pointer"
182
- }, K = {
183
- fontWeight: "bold",
184
- color: "#007bff",
185
- cursor: "not-allowed"
186
- }, q = {
187
- marginLeft: "8px",
188
- display: "inline-block",
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
- if (!k) return;
195
- let t = e.target;
196
- if (!t || !j.current) return;
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
- }, [k]);
204
- let Y = {
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
- return a("li", {
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: Q
235
- }, a("button", {
236
- type: "button",
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
- }, R(e)));
243
- });
244
- return a("div", {
245
- ref: j,
246
- className: "i18n-switcher-wrapper",
247
- style: Y,
248
- ...w
249
- }, a("button", {
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: X,
253
- onClick: (e) => {
254
- e.preventDefault(), e.stopPropagation(), L(e);
259
+ className: "i18n-switcher-button language-switcher",
260
+ style: {
261
+ ...b.button,
262
+ ...l,
263
+ ...R?.disabled ? _ : null
255
264
  },
256
- "aria-haspopup": "true",
257
- "aria-expanded": k
258
- }, a("span", null, z()), a("span", { style: $ }, "▼")), k ? a("ul", {
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: Z
261
- }, ...ee) : null);
262
- }, T = (e) => {
263
- let { t, tc: n, tn: i, td: o, tdr: s, locale: c, getRoute: l } = b(), { keypath: u, params: d, tag: f = "span", plural: p, defaultValue: m, html: h = !1, hideIfEmpty: g = !1, customPluralRule: _, number: v, date: y, relativeDate: x, ...S } = e, C = l(), w = (e, t, n) => a(e, t, n);
264
- if (v !== void 0) {
265
- let e = t(u, {
266
- number: i(Number(v)),
267
- ...d || {}
268
- }, void 0, C), n = typeof e == "string" ? e : String(e);
269
- return h ? w(f, {
270
- ...S,
271
- dangerouslySetInnerHTML: { __html: n }
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
- let T = t(u, d, m, C), E = typeof T == "string" ? T : String(T);
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
- //#endregion
317
- //#region src/router/adapter.tsx
318
- function O(e, t) {
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
- var k = O;
345
- //#endregion
346
- export { e as FormatService, d as I18nContext, p as I18nDefaultLocaleContext, x as I18nGroup, S as I18nLink, f as I18nLocalesContext, y as I18nProvider, m as I18nRouterContext, w as I18nSwitcher, T as I18nT, E as PreactI18n, O as createBrowserHistoryAdapter, D as createI18n, k as createPreactRouterAdapter, t as defaultPlural, n as interpolate, b as useI18n, h as useI18nContext, _ as useI18nDefaultLocale, g as useI18nLocales, v as useI18nRouter };
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