@burdenoff/microfe-i18n 2026.1129.2 → 2026.1129.4

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.
Files changed (43) hide show
  1. package/dist/generated/global-operations.d.ts +337 -0
  2. package/dist/generated/global-operations.js +155 -15
  3. package/dist/generated/global-types.js +7 -3
  4. package/dist/i18n/I18nRoutes.d.ts +4 -2
  5. package/dist/i18n/I18nRoutes.js +55 -47
  6. package/dist/i18n/v2/ExportDialog.d.ts +9 -0
  7. package/dist/i18n/v2/ExportDialog.js +107 -0
  8. package/dist/i18n/v2/LanguageDialog.d.ts +17 -0
  9. package/dist/i18n/v2/LanguageDialog.js +193 -0
  10. package/dist/i18n/v2/LanguagesDialogs.d.ts +7 -0
  11. package/dist/i18n/v2/LanguagesDialogs.js +43 -0
  12. package/dist/i18n/v2/LanguagesPage.js +62 -53
  13. package/dist/i18n/v2/LanguagesTab.js +1 -1
  14. package/dist/i18n/v2/ReviewTab.d.ts +3 -1
  15. package/dist/i18n/v2/ReviewTab.js +28 -27
  16. package/dist/i18n/v2/TabRedirect.d.ts +12 -0
  17. package/dist/i18n/v2/TabRedirect.js +25 -9
  18. package/dist/i18n/v2/language/FormatsTab.d.ts +6 -0
  19. package/dist/i18n/v2/language/FormatsTab.js +93 -0
  20. package/dist/i18n/v2/language/LanguagePage.d.ts +3 -0
  21. package/dist/i18n/v2/language/LanguagePage.js +256 -0
  22. package/dist/i18n/v2/language/TranslateDialog.d.ts +18 -0
  23. package/dist/i18n/v2/language/TranslateDialog.js +101 -0
  24. package/dist/i18n/v2/language/WordsTab.d.ts +11 -0
  25. package/dist/i18n/v2/language/WordsTab.js +190 -0
  26. package/dist/i18n/v2/language/useLanguage.d.ts +23 -0
  27. package/dist/i18n/v2/language/useLanguage.js +22 -0
  28. package/dist/i18n/v2/language/useWords.d.ts +31 -0
  29. package/dist/i18n/v2/language/useWords.js +51 -0
  30. package/dist/i18n/v2/languageModel.d.ts +66 -0
  31. package/dist/i18n/v2/languageModel.js +124 -0
  32. package/dist/i18n/v2/links.d.ts +10 -2
  33. package/dist/i18n/v2/links.js +11 -10
  34. package/dist/i18n/v2/useAddLanguage.d.ts +10 -0
  35. package/dist/i18n/v2/useAddLanguage.js +30 -0
  36. package/dist/i18n/v2/useDebouncedValue.d.ts +1 -0
  37. package/dist/i18n/v2/useDebouncedValue.js +10 -0
  38. package/dist/i18n/v2/useExportTranslations.d.ts +8 -0
  39. package/dist/i18n/v2/useExportTranslations.js +26 -0
  40. package/dist/node_modules/lucide-react/dist/esm/icons/calendar-days.js +49 -0
  41. package/dist/node_modules/lucide-react/dist/esm/icons/eye-off.js +21 -0
  42. package/dist/node_modules/lucide-react/dist/esm/icons/eye.js +12 -0
  43. package/package.json +1 -1
@@ -0,0 +1,256 @@
1
+ import e from "../../../node_modules/lucide-react/dist/esm/icons/download.js";
2
+ import t from "../../../node_modules/lucide-react/dist/esm/icons/eye.js";
3
+ import n from "../../../node_modules/lucide-react/dist/esm/icons/eye-off.js";
4
+ import r from "../../../node_modules/lucide-react/dist/esm/icons/languages.js";
5
+ import i from "../../../node_modules/lucide-react/dist/esm/icons/pencil.js";
6
+ import { useTr as a } from "../../hooks/useTr.js";
7
+ import { LanguageDirection as o, LanguageStatus as s } from "../../../generated/global-types.js";
8
+ import { COUNT as c, SHARE as l } from "../formats.js";
9
+ import { ExportDialog as u } from "../ExportDialog.js";
10
+ import { LanguageDialog as d } from "../LanguageDialog.js";
11
+ import { readLanguageTab as ee, shownLanguageTabs as f } from "../languageModel.js";
12
+ import { EXPORT_DIALOG as p, languagesLinks as m } from "../links.js";
13
+ import { languageProgress as h } from "../model.js";
14
+ import { ReviewTab as g } from "../ReviewTab.js";
15
+ import { useLanguagesData as _ } from "../useLanguagesData.js";
16
+ import { FormatsTab as v } from "./FormatsTab.js";
17
+ import { useLanguage as y } from "./useLanguage.js";
18
+ import { WordsTab as b } from "./WordsTab.js";
19
+ import { useMemo as x, useState as S } from "react";
20
+ import { Link as C, useParams as w, useSearchParams as T } from "react-router";
21
+ import { jsx as E, jsxs as D } from "react/jsx-runtime";
22
+ import { EmptyState as O, IconTile as k, LoadError as A, PageTabs as j, Skeleton as M, StatusChip as N, SummaryCard as P, SummaryStrip as F, useConfirm as I, useNotify as L } from "@burdenoff/fe-libs/ui";
23
+ import { PageHeader as R } from "@burdenoff/fe-libs/chrome";
24
+ // src/i18n/v2/language/LanguagePage.tsx
25
+ function z({ language: e, progress: t }) {
26
+ let n = a();
27
+ return e.status === s.Draft ? /* @__PURE__ */ E(N, {
28
+ status: "waiting",
29
+ children: n("i18n.v3.status.draft", "Draft")
30
+ }) : e.status === s.Deprecated ? /* @__PURE__ */ E(N, {
31
+ status: "paused",
32
+ children: n("i18n.v3.status.off", "Turned off")
33
+ }) : t ? t.total > 0 && t.missing === 0 ? /* @__PURE__ */ E(N, {
34
+ status: "ok",
35
+ children: n("i18n.v3.lang.complete", "Complete")
36
+ }) : t.waiting > 0 ? /* @__PURE__ */ E(N, {
37
+ status: "waiting",
38
+ children: n("i18n.v3.lang.waiting", "{{count}} waiting for review", { count: c.format(t.waiting) })
39
+ }) : null : null;
40
+ }
41
+ function B({ progress: e, loading: t }) {
42
+ let n = a();
43
+ if (t) return /* @__PURE__ */ E("div", {
44
+ className: "grid grid-cols-[repeat(auto-fill,minmax(13rem,1fr))] gap-3",
45
+ children: Array.from({ length: 3 }, (e, t) => /* @__PURE__ */ E(M, { className: "h-24 rounded-xl" }, t))
46
+ });
47
+ let r = e?.share ?? null;
48
+ return /* @__PURE__ */ D(F, {
49
+ "aria-label": n("i18n.v3.lang.summary", "Summary"),
50
+ children: [
51
+ /* @__PURE__ */ E(P, {
52
+ label: n("i18n.v3.col.translated", "Translated"),
53
+ value: r === null ? "—" : l.format(Math.floor(r * 100) / 100),
54
+ detail: e ? n("i18n.v3.lang.ofTexts", "{{translated}} of {{total}} texts", {
55
+ translated: c.format(e.translated),
56
+ total: c.format(e.total)
57
+ }) : void 0
58
+ }),
59
+ /* @__PURE__ */ E(P, {
60
+ label: n("i18n.v3.col.waiting", "Waiting for review"),
61
+ value: c.format(e?.waiting ?? 0)
62
+ }),
63
+ /* @__PURE__ */ E(P, {
64
+ label: n("i18n.v3.lang.missing", "Missing"),
65
+ value: c.format(e?.missing ?? 0),
66
+ tone: (e?.missing ?? 0) > 0 ? "warn" : void 0
67
+ })
68
+ ]
69
+ });
70
+ }
71
+ function V({ basePath: c, language: y, update: C }) {
72
+ let w = a(), O = L(), A = I(), [M, N] = T(), [P, F] = S(!1), V = M.get("dialog") === p, H = (e) => {
73
+ let t = new URLSearchParams(M);
74
+ e ? t.set("dialog", p) : t.delete("dialog"), N(t, { replace: !e });
75
+ }, U = m(c), W = _(), G = x(() => h(W.coverage.byProduct).get(y.code), [W.coverage.byProduct, y.code]), K = ee(M.get("tab"), !1), q = y.direction === o.Rtl, J = W.languages.find((e) => e.isDefault)?.name ?? w("i18n.v3.sourceText", "Source text"), Y = W.productsLoading || W.coverage.loading, X = y.status === s.Active, Z = [
76
+ y.nativeName === y.name ? "" : y.nativeName,
77
+ y.code,
78
+ G && G.share !== null ? w("i18n.v3.lang.shareLine", "{{share}} of every product is translated", { share: l.format(Math.floor(G.share * 100) / 100) }) : "",
79
+ q ? w("i18n.v3.lang.readsRtl", "reads right to left") : ""
80
+ ].filter(Boolean), Q = async (e) => {
81
+ if (e || await A({
82
+ title: w("i18n.v3.lang.offTitle", "Turn off {{name}}?", { name: y.name }),
83
+ description: w("i18n.v3.lang.offBody", "It stops being offered as a language. Its translations are kept, and you can turn it back on."),
84
+ confirmLabel: w("i18n.v3.lang.off", "Turn off"),
85
+ tone: "danger"
86
+ })) try {
87
+ await C({ status: e ? s.Active : s.Deprecated }), O({
88
+ title: e ? w("i18n.v3.lang.onDone", "{{name}} is offered again", { name: y.name }) : w("i18n.v3.lang.offDone", "{{name}} is turned off", { name: y.name }),
89
+ tone: "success"
90
+ }), W.retry();
91
+ } catch {
92
+ O({
93
+ title: w("i18n.v3.lang.saveFailed", "Couldn’t save it. Try again."),
94
+ tone: "error"
95
+ });
96
+ }
97
+ }, te = [
98
+ {
99
+ id: "names",
100
+ label: w("i18n.v3.lang.editNames", "Change the names…"),
101
+ icon: i,
102
+ onSelect: () => F(!0)
103
+ },
104
+ {
105
+ id: "export",
106
+ label: w("i18n.v3.exportWords", "Export translations"),
107
+ icon: e,
108
+ onSelect: () => H(!0)
109
+ },
110
+ X ? {
111
+ id: "off",
112
+ label: w("i18n.v3.lang.offMenu", "Turn off…"),
113
+ icon: n,
114
+ danger: !0,
115
+ separatorBefore: !0,
116
+ onSelect: () => void Q(!1)
117
+ } : {
118
+ id: "on",
119
+ label: w("i18n.v3.lang.on", "Turn on"),
120
+ icon: t,
121
+ separatorBefore: !0,
122
+ onSelect: () => void Q(!0)
123
+ }
124
+ ], ne = {
125
+ words: w("i18n.v3.lang.words", "Words"),
126
+ review: w("i18n.v3.col.waiting", "Waiting for review"),
127
+ formats: w("i18n.v3.lang.formats", "Dates and numbers")
128
+ }, re = (e) => {
129
+ let t = new URLSearchParams(M);
130
+ e === "words" ? t.delete("tab") : t.set("tab", e);
131
+ let n = t.toString();
132
+ return n ? `${U.language(y.code)}?${n}` : U.language(y.code);
133
+ }, $;
134
+ return $ = K === "formats" ? /* @__PURE__ */ E(v, {
135
+ language: y,
136
+ onUpdate: C
137
+ }) : K === "review" ? /* @__PURE__ */ E(g, {
138
+ languages: W.languages,
139
+ sourceName: J,
140
+ onReviewed: W.coverage.reload,
141
+ fixedLanguage: y.code
142
+ }) : /* @__PURE__ */ E(b, {
143
+ products: W.products,
144
+ productsLoading: W.productsLoading,
145
+ languageCode: y.code,
146
+ languageName: y.name,
147
+ sourceName: J,
148
+ rtl: q,
149
+ onSaved: W.coverage.reload
150
+ }), /* @__PURE__ */ D("div", {
151
+ "data-account-pages-v2": "language",
152
+ className: "flex w-full min-w-0 flex-col gap-4",
153
+ children: [
154
+ /* @__PURE__ */ E(R, {
155
+ variant: "compact",
156
+ title: y.name,
157
+ description: Z.join(" · "),
158
+ back: {
159
+ label: w("i18n.v3.title", "Languages"),
160
+ to: U.page
161
+ },
162
+ icon: /* @__PURE__ */ E(k, {
163
+ size: "lg",
164
+ children: /* @__PURE__ */ E(r, { "aria-hidden": "true" })
165
+ }),
166
+ meta: /* @__PURE__ */ E(z, {
167
+ language: y,
168
+ progress: G
169
+ }),
170
+ more: te,
171
+ moreLabel: w("i18n.v3.lang.moreFor", "More for {{name}}", { name: y.name })
172
+ }),
173
+ /* @__PURE__ */ E(B, {
174
+ progress: G,
175
+ loading: Y
176
+ }),
177
+ /* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E(j, {
178
+ ariaLabel: y.name,
179
+ activeId: K,
180
+ tabs: f(!1).map((e) => ({
181
+ id: e,
182
+ label: ne[e],
183
+ href: re(e),
184
+ badge: e === "review" ? G?.waiting : void 0
185
+ }))
186
+ }), /* @__PURE__ */ E("div", {
187
+ className: "pt-4",
188
+ children: $
189
+ })] }),
190
+ /* @__PURE__ */ E(u, {
191
+ open: V,
192
+ products: W.products,
193
+ languages: W.languages,
194
+ startLanguage: y.code,
195
+ onClose: () => H(!1)
196
+ }),
197
+ /* @__PURE__ */ E(d, {
198
+ open: P,
199
+ editing: {
200
+ code: y.code,
201
+ name: y.name,
202
+ nativeName: y.nativeName,
203
+ direction: y.direction
204
+ },
205
+ onClose: () => F(!1),
206
+ onSave: async (e) => {
207
+ try {
208
+ return await C({
209
+ name: e.name,
210
+ nativeName: e.nativeName
211
+ }), O({
212
+ title: w("i18n.v3.lang.saved", "Saved"),
213
+ tone: "success"
214
+ }), W.retry(), "saved";
215
+ } catch {
216
+ return O({
217
+ title: w("i18n.v3.lang.saveFailed", "Couldn’t save it. Try again."),
218
+ tone: "error"
219
+ }), "failed";
220
+ }
221
+ }
222
+ })
223
+ ]
224
+ });
225
+ }
226
+ function H({ basePath: e }) {
227
+ let t = a(), { code: n = "" } = w(), i = y(n), o = m(e);
228
+ return i.language ? /* @__PURE__ */ E(V, {
229
+ basePath: e,
230
+ language: i.language,
231
+ update: i.update
232
+ }) : i.error ? /* @__PURE__ */ E(A, {
233
+ what: t("i18n.v3.lang.what", "this language"),
234
+ error: i.error,
235
+ onRetry: i.retry
236
+ }) : i.missing ? /* @__PURE__ */ E(O, {
237
+ kind: "not-found",
238
+ icon: /* @__PURE__ */ E(r, { "aria-hidden": "true" }),
239
+ title: t("i18n.v3.lang.notFound", "We can’t find that language"),
240
+ description: t("i18n.v3.lang.notFoundBody", "It may have a different code. Every language is on Languages."),
241
+ action: /* @__PURE__ */ E(C, {
242
+ to: o.page,
243
+ className: "text-sm font-semibold text-action-primary-bg hover:underline",
244
+ children: t("i18n.v3.lang.toLanguages", "Go to Languages")
245
+ })
246
+ }) : /* @__PURE__ */ D("div", {
247
+ className: "flex flex-col gap-4",
248
+ "aria-busy": "true",
249
+ children: [
250
+ /* @__PURE__ */ E(M, { className: "h-12 w-72 rounded-lg" }),
251
+ /* @__PURE__ */ E(M, { className: "h-24 rounded-xl" }),
252
+ /* @__PURE__ */ E(M, { className: "h-64 rounded-xl" })
253
+ ]
254
+ });
255
+ }
256
+ export { H as LanguagePage };
@@ -0,0 +1,18 @@
1
+ import { Word } from './useWords';
2
+ export interface TranslateTarget {
3
+ word: Word;
4
+ /** The live translation being changed, or null for a new one. */
5
+ translation: {
6
+ id: string;
7
+ value: string;
8
+ } | null;
9
+ }
10
+ export declare function TranslateDialog({ target, sourceName, languageName, languageCode, rtl, onSave, onClose, }: {
11
+ target: TranslateTarget | null;
12
+ sourceName: string;
13
+ languageName: string;
14
+ languageCode: string;
15
+ rtl: boolean;
16
+ onSave: (target: TranslateTarget, value: string) => Promise<boolean>;
17
+ onClose: () => void;
18
+ }): import('react').JSX.Element;
@@ -0,0 +1,101 @@
1
+ import { useTr as e } from "../../hooks/useTr.js";
2
+ import { COUNT as t } from "../formats.js";
3
+ import { useId as n, useState as r } from "react";
4
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
5
+ import { Button as o, Label as s, ResponsiveDialog as c, ResponsiveDialogContent as l, ResponsiveDialogDescription as u, ResponsiveDialogFooter as d, ResponsiveDialogHeader as f, ResponsiveDialogTitle as p, Textarea as m } from "@burdenoff/fe-libs/ui";
6
+ // src/i18n/v2/language/TranslateDialog.tsx
7
+ function h({ target: c, sourceName: h, languageName: g, languageCode: _, rtl: v, onSave: y, onClose: b }) {
8
+ let x = e(), S = n(), [C, w] = r(c.translation?.value ?? ""), [T, E] = r(!1), D = c.word.characterLimit, O = D !== null && C.length > D, k = C.trim(), A = k === (c.translation?.value ?? "").trim(), j = async () => {
9
+ E(!0);
10
+ let e = !1;
11
+ try {
12
+ e = await y(k);
13
+ } finally {
14
+ E(!1);
15
+ }
16
+ e && b();
17
+ };
18
+ return /* @__PURE__ */ a(l, {
19
+ "data-testid": "translate-dialog",
20
+ children: [
21
+ /* @__PURE__ */ a(f, { children: [/* @__PURE__ */ i(p, { children: c.translation ? x("i18n.v3.word.editTitle", "Change the {{language}}", { language: g }) : x("i18n.v3.word.newTitle", "Translate into {{language}}", { language: g }) }), /* @__PURE__ */ i(u, { children: x("i18n.v3.word.liveNote", "It goes live straight away for everyone using {{language}}.", { language: g }) })] }),
22
+ /* @__PURE__ */ a("div", {
23
+ className: "flex flex-col gap-4",
24
+ children: [/* @__PURE__ */ a("div", {
25
+ className: "flex flex-col gap-1",
26
+ children: [
27
+ /* @__PURE__ */ i("span", {
28
+ className: "text-xs font-medium text-text-secondary",
29
+ children: c.word.namespace?.displayName ? x("i18n.v3.word.sourceIn", "{{source}} · {{where}}", {
30
+ source: h,
31
+ where: c.word.namespace.displayName
32
+ }) : h
33
+ }),
34
+ /* @__PURE__ */ i("p", {
35
+ className: "m-0 text-sm text-text-primary",
36
+ children: c.word.defaultValue ?? "—"
37
+ }),
38
+ c.word.description ? /* @__PURE__ */ i("p", {
39
+ className: "m-0 text-xs text-text-secondary",
40
+ children: c.word.description
41
+ }) : null
42
+ ]
43
+ }), /* @__PURE__ */ a("div", {
44
+ className: "flex flex-col gap-1.5",
45
+ children: [
46
+ /* @__PURE__ */ i(s, {
47
+ htmlFor: `${S}-value`,
48
+ children: g
49
+ }),
50
+ /* @__PURE__ */ i(m, {
51
+ id: `${S}-value`,
52
+ rows: 3,
53
+ value: C,
54
+ lang: _,
55
+ dir: v ? "rtl" : void 0,
56
+ onChange: (e) => w(e.target.value),
57
+ "aria-describedby": D === null ? void 0 : `${S}-limit`,
58
+ "aria-invalid": O || void 0,
59
+ "data-testid": "translate-value"
60
+ }),
61
+ D === null ? null : /* @__PURE__ */ i("p", {
62
+ id: `${S}-limit`,
63
+ className: O ? "m-0 text-xs text-status-error-text" : "m-0 text-xs text-text-secondary",
64
+ children: x("i18n.v3.word.limit", "{{used}} of {{limit}} characters", {
65
+ used: t.format(C.length),
66
+ limit: t.format(D)
67
+ })
68
+ })
69
+ ]
70
+ })]
71
+ }),
72
+ /* @__PURE__ */ a(d, { children: [/* @__PURE__ */ i(o, {
73
+ variant: "ghost",
74
+ onClick: b,
75
+ children: x("i18n.v3.cancel", "Cancel")
76
+ }), /* @__PURE__ */ i(o, {
77
+ busy: T,
78
+ disabled: !k || O || A,
79
+ onClick: () => void j(),
80
+ "data-testid": "translate-save",
81
+ children: x("i18n.v3.word.save", "Save and put live")
82
+ })] })
83
+ ]
84
+ });
85
+ }
86
+ function g({ target: e, sourceName: t, languageName: n, languageCode: r, rtl: a, onSave: o, onClose: s }) {
87
+ return /* @__PURE__ */ i(c, {
88
+ open: e !== null,
89
+ onOpenChange: (e) => e ? void 0 : s(),
90
+ children: e ? /* @__PURE__ */ i(h, {
91
+ target: e,
92
+ sourceName: t,
93
+ languageName: n,
94
+ languageCode: r,
95
+ rtl: a,
96
+ onSave: (t) => o(e, t),
97
+ onClose: s
98
+ }, e.word.id) : null
99
+ });
100
+ }
101
+ export { g as TranslateDialog };
@@ -0,0 +1,11 @@
1
+ import { ProductRow } from '../useLanguagesData';
2
+ export declare function WordsTab({ products, productsLoading, languageCode, languageName, sourceName, rtl, onSaved, }: {
3
+ products: readonly ProductRow[];
4
+ productsLoading: boolean;
5
+ languageCode: string;
6
+ languageName: string;
7
+ sourceName: string;
8
+ rtl: boolean;
9
+ /** A translation was saved: the page's numbers ask again. */
10
+ onSaved: () => void;
11
+ }): import('react').JSX.Element;
@@ -0,0 +1,190 @@
1
+ import e from "../../../node_modules/lucide-react/dist/esm/icons/languages.js";
2
+ import t from "../../../node_modules/lucide-react/dist/esm/icons/pencil.js";
3
+ import n from "../../../node_modules/lucide-react/dist/esm/icons/search.js";
4
+ import { useTr as r } from "../../hooks/useTr.js";
5
+ import { PRODUCT_PARAM as i, pickProduct as a, translationIn as o } from "../languageModel.js";
6
+ import { useDebouncedValue as s } from "../useDebouncedValue.js";
7
+ import { TranslateDialog as c } from "./TranslateDialog.js";
8
+ import { useWords as l } from "./useWords.js";
9
+ import { useState as u } from "react";
10
+ import { useSearchParams as d } from "react-router";
11
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
12
+ import { ActionMenu as m, Button as h, DataRows as g, EmptyState as _, Input as v, LoadError as y, Notice as b, Select as x, SelectContent as S, SelectItem as C, SelectTrigger as w, SelectValue as T, StatusChip as E, useNotify as D } from "@burdenoff/fe-libs/ui";
13
+ import { useAppShell as O } from "@burdenoff/fe-libs/shared/providers/shell";
14
+ // src/i18n/v2/language/WordsTab.tsx
15
+ function k({ products: e, current: t }) {
16
+ let n = r(), [a, o] = d();
17
+ return /* @__PURE__ */ p(x, {
18
+ value: t?.id ?? "",
19
+ onValueChange: (e) => {
20
+ let t = new URLSearchParams(a);
21
+ t.set(i, e), o(t, { replace: !0 });
22
+ },
23
+ children: [/* @__PURE__ */ f(w, {
24
+ className: "w-auto min-w-44",
25
+ "aria-label": n("i18n.v3.word.product", "Product"),
26
+ "data-testid": "words-product",
27
+ children: /* @__PURE__ */ f(T, { placeholder: n("i18n.v3.word.product", "Product") })
28
+ }), /* @__PURE__ */ f(S, { children: e.map((e) => /* @__PURE__ */ f(C, {
29
+ value: e.id,
30
+ children: e.displayName
31
+ }, e.id)) })]
32
+ });
33
+ }
34
+ function A({ words: n, state: i, languageCode: a, languageName: s, sourceName: c, rtl: l, onTranslate: u }) {
35
+ let d = r();
36
+ return /* @__PURE__ */ f(g, {
37
+ items: n,
38
+ getId: (e) => e.id,
39
+ label: d("i18n.v3.word.list", "Words"),
40
+ loading: i.loading,
41
+ lead: {
42
+ header: c,
43
+ width: "minmax(0,1.5fr)",
44
+ title: (e) => e.defaultValue ?? "—",
45
+ subtitle: (e) => e.namespace?.displayName
46
+ },
47
+ tone: (e) => o(e, a) ? void 0 : "bad",
48
+ columns: [{
49
+ id: "translation",
50
+ header: s,
51
+ width: "minmax(0,1.5fr)",
52
+ cell: (e) => {
53
+ let t = o(e, a);
54
+ return t ? /* @__PURE__ */ f("span", {
55
+ className: "text-sm text-text-primary",
56
+ lang: a,
57
+ dir: l ? "rtl" : void 0,
58
+ children: t.value
59
+ }) : /* @__PURE__ */ f("span", {
60
+ className: "text-sm text-text-secondary",
61
+ children: d("i18n.v3.word.notYet", "Not translated yet")
62
+ });
63
+ }
64
+ }, {
65
+ id: "status",
66
+ header: d("i18n.v3.col.status", "Status"),
67
+ width: "150px",
68
+ phone: "bare",
69
+ cell: (e) => o(e, a) ? /* @__PURE__ */ f(E, {
70
+ status: "ok",
71
+ children: d("i18n.v3.word.translated", "Translated")
72
+ }) : /* @__PURE__ */ f(E, {
73
+ status: "bad",
74
+ children: d("i18n.v3.word.missing", "Missing")
75
+ })
76
+ }],
77
+ actions: (n) => {
78
+ let r = o(n, a);
79
+ return r ? /* @__PURE__ */ f(m, {
80
+ placement: "row",
81
+ label: d("i18n.v3.word.actionsFor", "Actions for {{text}}", { text: n.defaultValue ?? "" }),
82
+ items: [{
83
+ id: "edit",
84
+ label: d("i18n.v3.word.edit", "Change the translation"),
85
+ icon: t,
86
+ onSelect: () => u({
87
+ word: n,
88
+ translation: {
89
+ id: r.id,
90
+ value: r.value
91
+ }
92
+ })
93
+ }]
94
+ }) : /* @__PURE__ */ p(h, {
95
+ size: "sm",
96
+ variant: "outline",
97
+ onClick: () => u({
98
+ word: n,
99
+ translation: null
100
+ }),
101
+ "aria-label": d("i18n.v3.word.translateThis", "Translate: {{text}}", { text: n.defaultValue ?? "" }),
102
+ children: [/* @__PURE__ */ f(e, { "aria-hidden": "true" }), d("i18n.v3.word.translate", "Translate")]
103
+ });
104
+ },
105
+ footer: i.hasMore ? /* @__PURE__ */ f(h, {
106
+ variant: "outline",
107
+ size: "sm",
108
+ onClick: i.showMore,
109
+ disabled: i.loadingMore,
110
+ "aria-busy": i.loadingMore || void 0,
111
+ children: d("i18n.v3.showMore", "Show more")
112
+ }) : void 0
113
+ });
114
+ }
115
+ function j({ products: t, productsLoading: o, languageCode: m, languageName: h, sourceName: g, rtl: x, onSaved: S }) {
116
+ let C = r(), w = D(), { productName: T } = O(), [E] = d(), j = a(t, E.get(i), T), [M, N] = u(""), P = s(M.trim(), 300), F = l(j?.id ?? null, P), [I, L] = u(null), R = async (e, t) => {
117
+ try {
118
+ let n = await F.save(e.word, m, t, e.translation?.id ?? null);
119
+ return w(n === "live" ? {
120
+ title: C("i18n.v3.word.saved", "Saved. It’s live now."),
121
+ tone: "success"
122
+ } : {
123
+ title: C("i18n.v3.word.savedDraft", "Saved as a draft."),
124
+ description: C("i18n.v3.word.savedDraftBody", "It shows here once someone approves it."),
125
+ tone: "info"
126
+ }), S(), !0;
127
+ } catch {
128
+ return w({
129
+ title: C("i18n.v3.word.saveFailed", "Couldn’t save it. Try again."),
130
+ tone: "error"
131
+ }), !1;
132
+ }
133
+ }, z = /* @__PURE__ */ f(A, {
134
+ words: F.words,
135
+ state: F,
136
+ languageCode: m,
137
+ languageName: h,
138
+ sourceName: g,
139
+ rtl: x,
140
+ onTranslate: L
141
+ });
142
+ return F.error && F.words.length === 0 ? z = /* @__PURE__ */ f(y, {
143
+ what: C("i18n.v3.word.list", "Words"),
144
+ error: F.error,
145
+ onRetry: F.retry
146
+ }) : !o && !j ? z = /* @__PURE__ */ f(_, {
147
+ icon: /* @__PURE__ */ f(e, { "aria-hidden": "true" }),
148
+ title: C("i18n.v3.noProducts", "No products yet"),
149
+ description: C("i18n.v3.noProductsBody", "A product’s words show here once they are ready to translate.")
150
+ }) : !F.loading && j && F.words.length === 0 && (z = /* @__PURE__ */ f(_, {
151
+ kind: P ? "no-results" : "first-use",
152
+ icon: /* @__PURE__ */ f(n, { "aria-hidden": "true" }),
153
+ title: P ? C("i18n.v3.word.noMatch", "No words match") : C("i18n.v3.word.none", "No words yet"),
154
+ description: P ? C("i18n.v3.word.noMatchBody", "Try other words, or another product.") : C("i18n.v3.word.noneBody", "{{product}} has no words to translate yet.", { product: j.displayName })
155
+ })), /* @__PURE__ */ p("div", {
156
+ className: "flex flex-col gap-3",
157
+ children: [
158
+ /* @__PURE__ */ f(b, {
159
+ tone: "info",
160
+ children: C("i18n.v3.word.liveOnly", "Shows words that are live. Words waiting for review appear after they’re approved.")
161
+ }),
162
+ /* @__PURE__ */ p("div", {
163
+ className: "flex flex-wrap items-center gap-2",
164
+ children: [/* @__PURE__ */ f(k, {
165
+ products: t,
166
+ current: j
167
+ }), /* @__PURE__ */ f(v, {
168
+ type: "search",
169
+ value: M,
170
+ onChange: (e) => N(e.target.value),
171
+ placeholder: C("i18n.v3.word.search", "Search words"),
172
+ "aria-label": C("i18n.v3.word.search", "Search words"),
173
+ className: "w-full sm:w-64",
174
+ "data-testid": "words-search"
175
+ })]
176
+ }),
177
+ z,
178
+ /* @__PURE__ */ f(c, {
179
+ target: I,
180
+ sourceName: g,
181
+ languageName: h,
182
+ languageCode: m,
183
+ rtl: x,
184
+ onSave: R,
185
+ onClose: () => L(null)
186
+ })
187
+ ]
188
+ });
189
+ }
190
+ export { j as WordsTab };
@@ -0,0 +1,23 @@
1
+ import { LanguageDirection, LanguageStatus, UpdateLanguageInput } from '../../../generated/global-types';
2
+ export interface LanguageDetail {
3
+ id: string;
4
+ code: string;
5
+ name: string;
6
+ nativeName: string;
7
+ direction: LanguageDirection;
8
+ status: LanguageStatus;
9
+ isDefault: boolean;
10
+ region: string | null;
11
+ dateFormat: string;
12
+ timeFormat: string;
13
+ }
14
+ export declare function useLanguage(code: string): {
15
+ language: LanguageDetail | null;
16
+ loading: boolean;
17
+ error: import('@apollo/client').ErrorLike | undefined;
18
+ /** Asked and answered: no language has this code. */
19
+ missing: boolean;
20
+ retry: () => undefined;
21
+ update: (input: UpdateLanguageInput) => Promise<void>;
22
+ };
23
+ export type LanguageState = ReturnType<typeof useLanguage>;
@@ -0,0 +1,22 @@
1
+ import { useGetI18nLanguageQuery as e, useUpdateI18nLanguageMutation as t } from "../../../generated/global-operations.js";
2
+ import { useCallback as n } from "react";
3
+ // src/i18n/v2/language/useLanguage.ts
4
+ function r(r) {
5
+ let i = e({ variables: { code: r } }), [a] = t(), o = i.data?.languageByCode ?? null, s = o?.id, c = n(async (e) => {
6
+ if (!s) return;
7
+ let t = await a({ variables: {
8
+ id: s,
9
+ input: e
10
+ } });
11
+ if (t.error) throw t.error;
12
+ }, [s, a]);
13
+ return {
14
+ language: o,
15
+ loading: i.loading && !o,
16
+ error: i.error,
17
+ missing: !i.loading && !i.error && !o,
18
+ retry: () => void i.refetch(),
19
+ update: c
20
+ };
21
+ }
22
+ export { r as useLanguage };
@@ -0,0 +1,31 @@
1
+ export interface Word {
2
+ id: string;
3
+ defaultValue: string | null;
4
+ description: string | null;
5
+ characterLimit: number | null;
6
+ namespace: {
7
+ id: string;
8
+ displayName: string;
9
+ } | null;
10
+ translations: Array<{
11
+ id: string;
12
+ languageCode: string;
13
+ value: string;
14
+ }>;
15
+ }
16
+ /** How many words a page shows; Show more adds as many again. */
17
+ export declare const WORDS_PAGE = 50;
18
+ /** What a save ended as. */
19
+ export type SaveOutcome = "live" | "draft";
20
+ export declare function useWords(productId: string | null, search: string): {
21
+ words: Word[];
22
+ total: any;
23
+ hasMore: any;
24
+ loading: boolean;
25
+ loadingMore: boolean;
26
+ error: import('@apollo/client').ErrorLike | undefined;
27
+ retry: () => undefined;
28
+ showMore: () => void;
29
+ save: (word: Word, languageCode: string, value: string, translationId: string | null) => Promise<SaveOutcome>;
30
+ };
31
+ export type WordsState = ReturnType<typeof useWords>;