@burdenoff/fe-libs 2026.918.1 → 2026.919.1
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/shared/providers/shell/I18nProvider.d.ts.map +1 -1
- package/dist/shared/providers/shell/I18nProvider.js +33 -39
- package/dist/shared/providers/shell/resolveTranslation.d.ts +23 -0
- package/dist/shared/providers/shell/resolveTranslation.d.ts.map +1 -0
- package/dist/shared/providers/shell/resolveTranslation.js +11 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/I18nProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"I18nProvider.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/I18nProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAQL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAIf,MAAM,MAAM,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAWlF,MAAM,WAAW,qBAAqB;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,qBAAqB,CAAC;CAC/C;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,qBAAqB,CAAC;IACpC,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,CAAC,EAAE,CACD,GAAG,EAAE,MAAM,EACX,gBAAgB,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,EAC3D,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CA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
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { resolveTranslationValue as t } from "./resolveTranslation.js";
|
|
3
|
+
import { createContext as n, use as r, useCallback as i, useEffect as a, useMemo as o, useRef as s, useState as c } from "react";
|
|
4
|
+
import { Fragment as l, jsx as u } from "react/jsx-runtime";
|
|
4
5
|
//#region src/shared/providers/shell/I18nProvider.tsx
|
|
5
|
-
var
|
|
6
|
+
var d = n(null), f = {
|
|
6
7
|
en: {},
|
|
7
8
|
es: {},
|
|
8
9
|
fr: {},
|
|
@@ -12,7 +13,7 @@ var u = t(null), d = {
|
|
|
12
13
|
ta: {},
|
|
13
14
|
hi: {},
|
|
14
15
|
ar: {}
|
|
15
|
-
},
|
|
16
|
+
}, p = {
|
|
16
17
|
attempted: /* @__PURE__ */ new Set(),
|
|
17
18
|
translations: {},
|
|
18
19
|
version: 0,
|
|
@@ -20,7 +21,7 @@ var u = t(null), d = {
|
|
|
20
21
|
this.attempted.clear(), this.translations = {}, this.version++;
|
|
21
22
|
}
|
|
22
23
|
};
|
|
23
|
-
function
|
|
24
|
+
function m(e, t, n) {
|
|
24
25
|
if (typeof window > "u") return n;
|
|
25
26
|
if (e) {
|
|
26
27
|
let t = localStorage.getItem(`bf-p-${e}-locale`);
|
|
@@ -28,13 +29,6 @@ function p(e, t, n) {
|
|
|
28
29
|
}
|
|
29
30
|
return localStorage.getItem(t) || n;
|
|
30
31
|
}
|
|
31
|
-
function m(e, t) {
|
|
32
|
-
if (!e) return;
|
|
33
|
-
let n = t.split("."), r = e;
|
|
34
|
-
for (let e of n) if (typeof r == "object" && r && e in r) r = r[e];
|
|
35
|
-
else return;
|
|
36
|
-
return typeof r == "string" ? r : void 0;
|
|
37
|
-
}
|
|
38
32
|
function h(e) {
|
|
39
33
|
return typeof e == "object" && !!e;
|
|
40
34
|
}
|
|
@@ -53,18 +47,18 @@ function g(e, t) {
|
|
|
53
47
|
}
|
|
54
48
|
return n;
|
|
55
49
|
}
|
|
56
|
-
function _({ children:
|
|
57
|
-
let [S, C] =
|
|
50
|
+
function _({ children: n, defaultLocale: r = "en", translations: h = f, storageKey: _ = "burdenoff-locale", profileId: v, fetchTranslations: y, showChildrenWhileLoading: b = !0, loadingComponent: x }) {
|
|
51
|
+
let [S, C] = c(() => m(v, _, r)), [w, T] = c({}), [E, D] = c(!!y), [O, k] = c(null), A = s(/* @__PURE__ */ new Set()), j = s(p.version), M = o(() => {
|
|
58
52
|
let e = { ...h };
|
|
59
53
|
for (let [t, n] of Object.entries(w)) if (n && Object.keys(n).length > 0) {
|
|
60
54
|
let r = t;
|
|
61
55
|
e[r] = g(h[r], n);
|
|
62
56
|
}
|
|
63
57
|
return e;
|
|
64
|
-
}, [h, w]), N =
|
|
58
|
+
}, [h, w]), N = i(async (e) => {
|
|
65
59
|
if (y) {
|
|
66
|
-
if (j.current !==
|
|
67
|
-
let t =
|
|
60
|
+
if (j.current !== p.version && (A.current.clear(), j.current = p.version), p.attempted.has(e)) {
|
|
61
|
+
let t = p.translations[e];
|
|
68
62
|
t && Object.keys(t).length > 0 && T((n) => !n[e] || Object.keys(n[e]).length === 0 ? {
|
|
69
63
|
...n,
|
|
70
64
|
[e]: t
|
|
@@ -75,7 +69,7 @@ function _({ children: t, defaultLocale: n = "en", translations: h = d, storageK
|
|
|
75
69
|
A.current.add(e), D(!0), k(null);
|
|
76
70
|
try {
|
|
77
71
|
let t = await y(e);
|
|
78
|
-
t && Object.keys(t).length > 0 && (
|
|
72
|
+
t && Object.keys(t).length > 0 && (p.attempted.add(e), p.translations[e] = t), T((n) => ({
|
|
79
73
|
...n,
|
|
80
74
|
[e]: t
|
|
81
75
|
}));
|
|
@@ -87,36 +81,36 @@ function _({ children: t, defaultLocale: n = "en", translations: h = d, storageK
|
|
|
87
81
|
}
|
|
88
82
|
}
|
|
89
83
|
}, [y]);
|
|
90
|
-
|
|
91
|
-
y && (
|
|
84
|
+
a(() => {
|
|
85
|
+
y && (p.attempted.has(S) && p.translations[S] && Object.keys(p.translations[S]).length > 0 || N(S));
|
|
92
86
|
}, [
|
|
93
87
|
y,
|
|
94
88
|
S,
|
|
95
89
|
N
|
|
96
|
-
]),
|
|
97
|
-
let e =
|
|
90
|
+
]), a(() => {
|
|
91
|
+
let e = m(v, _, r);
|
|
98
92
|
C(e), document.documentElement.setAttribute("lang", e);
|
|
99
93
|
}, [
|
|
100
94
|
v,
|
|
101
95
|
_,
|
|
102
|
-
|
|
96
|
+
r
|
|
103
97
|
]);
|
|
104
|
-
let P =
|
|
98
|
+
let P = i((e) => {
|
|
105
99
|
C(e), localStorage.setItem(_, e), v && localStorage.setItem(`bf-p-${v}-locale`, e), document.documentElement.setAttribute("lang", e);
|
|
106
|
-
}, [_, v]), F =
|
|
107
|
-
let
|
|
108
|
-
if (typeof
|
|
109
|
-
else if (
|
|
110
|
-
let { defaultValue: e, ...t } =
|
|
111
|
-
typeof e == "string" ?
|
|
100
|
+
}, [_, v]), F = i((n, i, a) => {
|
|
101
|
+
let o, s;
|
|
102
|
+
if (typeof i == "string") o = i, s = a;
|
|
103
|
+
else if (i && typeof i == "object") {
|
|
104
|
+
let { defaultValue: e, ...t } = i;
|
|
105
|
+
typeof e == "string" ? o = e : typeof e == "number" && (o = String(e)), s = t;
|
|
112
106
|
}
|
|
113
|
-
let
|
|
114
|
-
return
|
|
107
|
+
let c = t(M[S], n) ?? (S === r ? void 0 : t(M[r], n)) ?? (r === "en" ? void 0 : t(M.en, n)) ?? o ?? n;
|
|
108
|
+
return s ? e(c, s) : c;
|
|
115
109
|
}, [
|
|
116
110
|
S,
|
|
117
111
|
M,
|
|
118
|
-
|
|
119
|
-
]), I =
|
|
112
|
+
r
|
|
113
|
+
]), I = o(() => ({
|
|
120
114
|
locale: S,
|
|
121
115
|
translations: M[S] || {},
|
|
122
116
|
setLocale: P,
|
|
@@ -131,21 +125,21 @@ function _({ children: t, defaultLocale: n = "en", translations: h = d, storageK
|
|
|
131
125
|
E,
|
|
132
126
|
O
|
|
133
127
|
]);
|
|
134
|
-
return E && !b && x ? /* @__PURE__ */ l
|
|
128
|
+
return E && !b && x ? /* @__PURE__ */ u(l, { children: x }) : /* @__PURE__ */ u(d.Provider, {
|
|
135
129
|
value: I,
|
|
136
|
-
children:
|
|
130
|
+
children: n
|
|
137
131
|
});
|
|
138
132
|
}
|
|
139
133
|
function v() {
|
|
140
|
-
let e =
|
|
134
|
+
let e = r(d);
|
|
141
135
|
if (!e) throw Error("useI18n must be used within an I18nProvider");
|
|
142
136
|
return e;
|
|
143
137
|
}
|
|
144
138
|
function y() {
|
|
145
|
-
|
|
139
|
+
p.clear();
|
|
146
140
|
}
|
|
147
141
|
function b(e) {
|
|
148
|
-
return
|
|
142
|
+
return p.attempted.has(e);
|
|
149
143
|
}
|
|
150
144
|
//#endregion
|
|
151
145
|
export { _ as I18nProvider, y as clearTranslationCache, b as isTranslationAttempted, g as mergeTranslationDictionaries, v as useI18n };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { TranslationDictionary } from './I18nProvider';
|
|
2
|
+
/**
|
|
3
|
+
* Where a nested dictionary keeps the value of a key that is ALSO a branch.
|
|
4
|
+
*
|
|
5
|
+
* `healthybowl.common.confirm` ("Confirm") and `healthybowl.common.confirm.title`
|
|
6
|
+
* ("Are you sure?") cannot both live at one path of a nested object, so the
|
|
7
|
+
* leaf is stored beside its children as `confirm._`. The product extractors
|
|
8
|
+
* write that slot, the seed stores such a key literally as `….confirm._`, and
|
|
9
|
+
* the i18n export serves it nested — so the translation already reaches the
|
|
10
|
+
* client. Nothing read it: `t('healthybowl.common.confirm')` walked to the
|
|
11
|
+
* object and returned undefined, and the call site's inline English rendered
|
|
12
|
+
* in every locale (13 HealthyBowl keys, BOFF-7438; BOFF-7459).
|
|
13
|
+
*/
|
|
14
|
+
export declare const LEAF_SLOT = "_";
|
|
15
|
+
/**
|
|
16
|
+
* Resolve a dot-notated translation key from a dictionary: the string at that
|
|
17
|
+
* path, or — when the path names a branch — the string in its `_` slot.
|
|
18
|
+
*
|
|
19
|
+
* A branch with no `_` string still resolves to undefined, so the caller's
|
|
20
|
+
* fallback renders rather than "[object Object]".
|
|
21
|
+
*/
|
|
22
|
+
export declare function resolveTranslationValue(dictionary: TranslationDictionary | undefined, key: string): string | undefined;
|
|
23
|
+
//# sourceMappingURL=resolveTranslation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveTranslation.d.ts","sourceRoot":"","sources":["../../../../src/shared/providers/shell/resolveTranslation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,SAAS,MAAM,CAAC;AAE7B;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,qBAAqB,GAAG,SAAS,EAC7C,GAAG,EAAE,MAAM,GACV,MAAM,GAAG,SAAS,CAgBpB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function e(e, t) {
|
|
2
|
+
if (!e) return;
|
|
3
|
+
let n = e;
|
|
4
|
+
for (let e of t.split(".")) if (typeof n == "object" && n && e in n) n = n[e];
|
|
5
|
+
else return;
|
|
6
|
+
if (typeof n == "string") return n;
|
|
7
|
+
let r = typeof n == "object" && n ? n._ : void 0;
|
|
8
|
+
return typeof r == "string" ? r : void 0;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { e as resolveTranslationValue };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/fe-libs",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.919.1",
|
|
4
4
|
"description": "Burdenoff frontend primitives and domain libraries",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -307,7 +307,7 @@
|
|
|
307
307
|
"format": "prettier --config shared/config/prettier.config.mjs --write \"src/**/*.{ts,tsx}\" \"!src/config/*.config.ts\"",
|
|
308
308
|
"type:check": "bash scripts/build-limits.sh tsc --noEmit",
|
|
309
309
|
"test:package-css-exports": "node scripts/validate-package-css-exports.mjs",
|
|
310
|
-
"test": "bun test scripts/graphql-schema-drift/__tests__ scripts/a11y-audit/__tests__ src/credentials src/storage src/shared/assistant src/shared/components src/shared/graphql/links/sse-link.test.ts src/shared/config/gatewayUrls.test.ts src/shared/config/authBridgeUrls.test.ts src/shared/config/gatewayFallback.test.ts src/shared/utils/gatewayFetchRewrite.test.ts src/shared/utils/authCookie.test.ts src/shared/providers/AppShellProvider.test.ts src/shared/providers/shell/interpolate.test.ts src/shared/events/sinks/RybbitSink.test.ts src/shell-native src/shared/native src/chrome/__tests__ src/ui/__tests__",
|
|
310
|
+
"test": "bun test scripts/graphql-schema-drift/__tests__ scripts/a11y-audit/__tests__ src/credentials src/storage src/shared/assistant src/shared/components src/shared/graphql/links/sse-link.test.ts src/shared/config/gatewayUrls.test.ts src/shared/config/authBridgeUrls.test.ts src/shared/config/gatewayFallback.test.ts src/shared/utils/gatewayFetchRewrite.test.ts src/shared/utils/authCookie.test.ts src/shared/providers/AppShellProvider.test.ts src/shared/providers/shell/interpolate.test.ts src/shared/providers/shell/resolveTranslation.test.ts src/shared/providers/shell/I18nProvider.render.test.tsx src/shared/events/sinks/RybbitSink.test.ts src/shell-native src/shared/native src/chrome/__tests__ src/ui/__tests__",
|
|
311
311
|
"sanity": "bash scripts/build-limits.sh --gate bash -c 'bun run lint:sanity && bun run format && bun run type:check && bun run test && bun run build'",
|
|
312
312
|
"switch:status": "bun scripts/deps-mode.ts status",
|
|
313
313
|
"switch:remote": "bun scripts/deps-mode.ts remote",
|