@burdenoff/microfe-i18n 2026.1126.1 → 2026.1129.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.
Files changed (92) hide show
  1. package/dist/generated/global-operations.d.ts +299 -0
  2. package/dist/generated/global-operations.js +135 -0
  3. package/dist/generated/global-types.d.ts +34021 -0
  4. package/dist/generated/global-types.js +11 -0
  5. package/dist/i18n/I18nRoutes.d.ts +11 -0
  6. package/dist/i18n/I18nRoutes.js +54 -41
  7. package/dist/i18n/v2/LanguagesPage.d.ts +3 -0
  8. package/dist/i18n/v2/LanguagesPage.js +82 -0
  9. package/dist/i18n/v2/LanguagesTab.d.ts +8 -0
  10. package/dist/i18n/v2/LanguagesTab.js +102 -0
  11. package/dist/i18n/v2/ProductsTab.d.ts +4 -0
  12. package/dist/i18n/v2/ProductsTab.js +60 -0
  13. package/dist/i18n/v2/ReviewRows.d.ts +9 -0
  14. package/dist/i18n/v2/ReviewRows.js +71 -0
  15. package/dist/i18n/v2/ReviewTab.d.ts +6 -0
  16. package/dist/i18n/v2/ReviewTab.js +121 -0
  17. package/dist/i18n/v2/ShareBar.d.ts +5 -0
  18. package/dist/i18n/v2/ShareBar.js +28 -0
  19. package/dist/i18n/v2/TabRedirect.d.ts +4 -0
  20. package/dist/i18n/v2/TabRedirect.js +14 -0
  21. package/dist/i18n/v2/__tests__/routeShapes.d.ts +7 -0
  22. package/dist/i18n/v2/formats.d.ts +3 -0
  23. package/dist/i18n/v2/formats.js +6 -0
  24. package/dist/i18n/v2/links.d.ts +13 -0
  25. package/dist/i18n/v2/links.js +16 -0
  26. package/dist/i18n/v2/model.d.ts +76 -0
  27. package/dist/i18n/v2/model.js +87 -0
  28. package/dist/i18n/v2/reviewMessages.d.ts +9 -0
  29. package/dist/i18n/v2/reviewMessages.js +40 -0
  30. package/dist/i18n/v2/useLanguagesData.d.ts +35 -0
  31. package/dist/i18n/v2/useLanguagesData.js +62 -0
  32. package/dist/i18n/v2/useReviewActions.d.ts +9 -0
  33. package/dist/i18n/v2/useReviewActions.js +56 -0
  34. package/dist/i18n/v2/useReviewQueue.d.ts +44 -0
  35. package/dist/i18n/v2/useReviewQueue.js +60 -0
  36. package/dist/node_modules/@apollo/client/react/context/ApolloContext.js +15 -0
  37. package/dist/node_modules/@apollo/client/react/hooks/constants.js +3 -0
  38. package/dist/node_modules/@apollo/client/react/hooks/internal/useDeepMemo.js +11 -0
  39. package/dist/node_modules/@apollo/client/react/hooks/internal/useIsomorphicLayoutEffect.js +5 -0
  40. package/dist/node_modules/@apollo/client/react/hooks/internal/wrapHook.js +13 -0
  41. package/dist/node_modules/@apollo/client/react/hooks/useApolloClient.js +9 -0
  42. package/dist/node_modules/@apollo/client/react/hooks/useMutation.js +96 -0
  43. package/dist/node_modules/@apollo/client/react/hooks/useQuery.js +125 -0
  44. package/dist/node_modules/@apollo/client/react/hooks/useSyncExternalStore.js +34 -0
  45. package/dist/node_modules/@apollo/client/react/internal/index.js +3 -0
  46. package/dist/node_modules/@apollo/client/utilities/internal/canUseDOM.js +4 -0
  47. package/dist/node_modules/@apollo/client/utilities/internal/compact.js +11 -0
  48. package/dist/node_modules/@apollo/client/utilities/internal/constants.js +3 -0
  49. package/dist/node_modules/@apollo/client/utilities/internal/deepFreeze.js +14 -0
  50. package/dist/node_modules/@apollo/client/utilities/internal/globals/global.js +6 -0
  51. package/dist/node_modules/@apollo/client/utilities/internal/globals/maybe.js +7 -0
  52. package/dist/node_modules/@apollo/client/utilities/internal/isNonNullObject.js +5 -0
  53. package/dist/node_modules/@apollo/client/utilities/internal/makeUniqueId.js +7 -0
  54. package/dist/node_modules/@apollo/client/utilities/internal/maybeDeepFreeze.js +6 -0
  55. package/dist/node_modules/@apollo/client/utilities/internal/mergeOptions.js +9 -0
  56. package/dist/node_modules/@apollo/client/utilities/internal/preventUnhandledRejection.js +5 -0
  57. package/dist/node_modules/@apollo/client/utilities/internal/stringifyForDisplay.js +7 -0
  58. package/dist/node_modules/@apollo/client/utilities/invariant/index.js +54 -0
  59. package/dist/node_modules/@apollo/client/version.js +3 -0
  60. package/dist/node_modules/@wry/equality/lib/index.js +86 -0
  61. package/dist/node_modules/lucide-react/dist/esm/icons/check-check.js +10 -0
  62. package/dist/node_modules/lucide-react/dist/esm/icons/check.js +7 -0
  63. package/dist/node_modules/lucide-react/dist/esm/icons/pencil.js +10 -0
  64. package/dist/node_modules/rxjs/dist/esm5/internal/NotificationFactories.js +18 -0
  65. package/dist/node_modules/rxjs/dist/esm5/internal/Scheduler.js +11 -0
  66. package/dist/node_modules/rxjs/dist/esm5/internal/Subscriber.js +114 -0
  67. package/dist/node_modules/rxjs/dist/esm5/internal/Subscription.js +94 -0
  68. package/dist/node_modules/rxjs/dist/esm5/internal/config.js +9 -0
  69. package/dist/node_modules/rxjs/dist/esm5/internal/operators/OperatorSubscriber.js +43 -0
  70. package/dist/node_modules/rxjs/dist/esm5/internal/operators/observeOn.js +22 -0
  71. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/Action.js +13 -0
  72. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/AsapAction.js +19 -0
  73. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/AsapScheduler.js +24 -0
  74. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/AsyncAction.js +43 -0
  75. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/AsyncScheduler.js +27 -0
  76. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/asap.js +5 -0
  77. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/dateTimestampProvider.js +8 -0
  78. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/immediateProvider.js +14 -0
  79. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/intervalProvider.js +13 -0
  80. package/dist/node_modules/rxjs/dist/esm5/internal/scheduler/timeoutProvider.js +13 -0
  81. package/dist/node_modules/rxjs/dist/esm5/internal/util/Immediate.js +17 -0
  82. package/dist/node_modules/rxjs/dist/esm5/internal/util/UnsubscriptionError.js +10 -0
  83. package/dist/node_modules/rxjs/dist/esm5/internal/util/arrRemove.js +8 -0
  84. package/dist/node_modules/rxjs/dist/esm5/internal/util/createErrorClass.js +8 -0
  85. package/dist/node_modules/rxjs/dist/esm5/internal/util/errorContext.js +5 -0
  86. package/dist/node_modules/rxjs/dist/esm5/internal/util/executeSchedule.js +9 -0
  87. package/dist/node_modules/rxjs/dist/esm5/internal/util/isFunction.js +5 -0
  88. package/dist/node_modules/rxjs/dist/esm5/internal/util/lift.js +18 -0
  89. package/dist/node_modules/rxjs/dist/esm5/internal/util/noop.js +3 -0
  90. package/dist/node_modules/rxjs/dist/esm5/internal/util/reportUnhandledError.js +11 -0
  91. package/dist/node_modules/tslib/tslib.es6.js +49 -0
  92. package/package.json +12 -5
@@ -0,0 +1,28 @@
1
+ import { SHARE as e } from "./formats.js";
2
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
+ import { Skeleton as r } from "@burdenoff/fe-libs/ui";
4
+ // src/i18n/v2/ShareBar.tsx
5
+ function i({ share: i, loading: a }) {
6
+ if (a) return /* @__PURE__ */ t(r, { className: "h-4 w-36 rounded" });
7
+ if (i === null) return /* @__PURE__ */ t("span", {
8
+ className: "text-sm text-text-secondary",
9
+ children: "—"
10
+ });
11
+ let o = Math.floor(i * 100);
12
+ return /* @__PURE__ */ n("span", {
13
+ className: "inline-flex items-center gap-2",
14
+ "data-share-bar": "",
15
+ children: [/* @__PURE__ */ t("span", {
16
+ "aria-hidden": "true",
17
+ className: "h-1.5 w-28 shrink-0 overflow-hidden rounded-full bg-bg-sunken",
18
+ children: /* @__PURE__ */ t("span", {
19
+ className: "block h-full rounded-full bg-action-primary-bg",
20
+ style: { width: `${o}%` }
21
+ })
22
+ }), /* @__PURE__ */ t("span", {
23
+ className: "text-sm tabular-nums text-text-primary",
24
+ children: e.format(o / 100)
25
+ })]
26
+ });
27
+ }
28
+ export { i as ShareBar };
@@ -0,0 +1,4 @@
1
+ export declare function TabRedirect({ basePath, tab, }: {
2
+ basePath: string;
3
+ tab: string;
4
+ }): import('react').JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { joinPath as e } from "../utils/paths.js";
2
+ import { Navigate as t, useSearchParams as n } from "react-router";
3
+ import { jsx as r } from "react/jsx-runtime";
4
+ // src/i18n/v2/TabRedirect.tsx
5
+ function i({ basePath: i, tab: a }) {
6
+ let [o] = n(), s = new URLSearchParams(o);
7
+ a === "languages" ? s.delete("tab") : s.set("tab", a);
8
+ let c = s.toString(), l = e(i, "languages");
9
+ return /* @__PURE__ */ r(t, {
10
+ to: c ? `${l}?${c}` : l,
11
+ replace: !0
12
+ });
13
+ }
14
+ export { i as TabRedirect };
@@ -0,0 +1,7 @@
1
+ import { ReactNode } from 'react';
2
+ export interface RouteEntry {
3
+ path: string;
4
+ element: unknown;
5
+ }
6
+ export declare function shape(node: ReactNode): unknown;
7
+ export declare function collectRoutes(node: ReactNode, out?: RouteEntry[]): RouteEntry[];
@@ -0,0 +1,3 @@
1
+ /** Counts and shares on the Languages page (BOFF-16785, C5). */
2
+ export declare const COUNT: Intl.NumberFormat;
3
+ export declare const SHARE: Intl.NumberFormat;
@@ -0,0 +1,6 @@
1
+ // src/i18n/v2/formats.ts
2
+ var e = new Intl.NumberFormat(), t = new Intl.NumberFormat(void 0, {
3
+ style: "percent",
4
+ maximumFractionDigits: 0
5
+ });
6
+ export { e as COUNT, t as SHARE };
@@ -0,0 +1,13 @@
1
+ import { LanguagesTab } from './model';
2
+ export declare function languagesLinks(basePath: string): {
3
+ page: string;
4
+ tab: (tab: LanguagesTab) => string;
5
+ /** The review queue, showing one language. */
6
+ review: (languageCode: string) => string;
7
+ /** One language: today's language settings until C5b. */
8
+ language: (code: string) => string;
9
+ addLanguage: string;
10
+ importWords: string;
11
+ exportWords: string;
12
+ };
13
+ export type LanguagesLinks = ReturnType<typeof languagesLinks>;
@@ -0,0 +1,16 @@
1
+ import { joinPath as e } from "../utils/paths.js";
2
+ import { LANGUAGE_PARAM as t } from "./model.js";
3
+ // src/i18n/v2/links.ts
4
+ function n(n) {
5
+ let r = e(n, "languages");
6
+ return {
7
+ page: r,
8
+ tab: (e) => e === "languages" ? r : `${r}?tab=${e}`,
9
+ review: (e) => `${r}?tab=review&${t}=${encodeURIComponent(e)}`,
10
+ language: (t) => e(n, `languages/${encodeURIComponent(t)}`),
11
+ addLanguage: e(n, "languages/new"),
12
+ importWords: e(n, "import"),
13
+ exportWords: e(n, "export")
14
+ };
15
+ }
16
+ export { n as languagesLinks };
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The Languages page's numbers (BOFF-16785, C5; the mockup's `languages`): how
3
+ * much of each language is translated across every product, how much of each
4
+ * product is translated, and what waits for review. Pure, so it is tested
5
+ * without a page.
6
+ */
7
+ export declare const LANGUAGES_TABS: readonly ["languages", "products", "review"];
8
+ export type LanguagesTab = (typeof LANGUAGES_TABS)[number];
9
+ /** `?tab=`; anything else is the Languages tab. */
10
+ export declare function readLanguagesTab(value: string | null): LanguagesTab;
11
+ /** The review queue's language filter (`?language=`). */
12
+ export declare const LANGUAGE_PARAM = "language";
13
+ /** One language's line of `translationCoverage` for one product. */
14
+ export interface CoverageLine {
15
+ languageCode: string;
16
+ totalKeys: number;
17
+ translatedKeys: number;
18
+ missingCount: number;
19
+ pendingReviewKeys: number;
20
+ }
21
+ /** How far along something is: what's translated out of how much. */
22
+ export interface Progress {
23
+ translated: number;
24
+ total: number;
25
+ /** What waits for review. */
26
+ waiting: number;
27
+ /** What nobody has translated yet. */
28
+ missing: number;
29
+ /** `translated / total`, 0 to 1; null when there is nothing to translate. */
30
+ share: number | null;
31
+ }
32
+ /**
33
+ * Each language across every product: the products' lines for that language
34
+ * added up. A language with no line (not active, so not counted) is missing
35
+ * from the map.
36
+ */
37
+ export declare function languageProgress(byProduct: ReadonlyMap<string, readonly CoverageLine[]>): Map<string, Progress>;
38
+ /** One product: how much text it has, and how much of it is translated. */
39
+ export interface ProductProgress extends Progress {
40
+ /** The product's texts (each is translated once per language). */
41
+ texts: number;
42
+ }
43
+ /**
44
+ * One product across the languages it is translated into. The source language
45
+ * (`sourceCode`) is left out: it is where the words come from, so counting it
46
+ * would make every product look further along. With only the source language,
47
+ * that one counts.
48
+ */
49
+ export declare function productProgress(lines: readonly CoverageLine[], sourceCode: string | null): ProductProgress;
50
+ /** A translation's text: where it appears, and the product. */
51
+ export interface TranslationPlace {
52
+ product: {
53
+ displayName: string;
54
+ };
55
+ namespace: {
56
+ displayName: string;
57
+ } | null;
58
+ }
59
+ /** Where a text appears, in words: its section, or the product when it has none. */
60
+ export declare function whereItAppears(key: TranslationPlace): string;
61
+ /** The languages, the source language first, then by name. */
62
+ export declare function sortLanguages<T extends {
63
+ isDefault: boolean;
64
+ name: string;
65
+ }>(languages: readonly T[]): T[];
66
+ /**
67
+ * `run` for every item, at most `limit` at a time, keeping the order. A failed
68
+ * item is reported in `failed` and doesn't stop the others.
69
+ */
70
+ export declare function eachLimited<T, R>(items: readonly T[], limit: number, run: (item: T) => Promise<R>): Promise<{
71
+ done: Array<{
72
+ item: T;
73
+ result: R;
74
+ }>;
75
+ failed: T[];
76
+ }>;
@@ -0,0 +1,87 @@
1
+ // src/i18n/v2/model.ts
2
+ var e = [
3
+ "languages",
4
+ "products",
5
+ "review"
6
+ ];
7
+ function t(t) {
8
+ return e.find((e) => e === t) ?? "languages";
9
+ }
10
+ var n = "language", r = {
11
+ translated: 0,
12
+ total: 0,
13
+ waiting: 0,
14
+ missing: 0,
15
+ share: null
16
+ };
17
+ function i(e) {
18
+ return {
19
+ ...e,
20
+ share: e.total > 0 ? e.translated / e.total : null
21
+ };
22
+ }
23
+ function a(e) {
24
+ let t = /* @__PURE__ */ new Map();
25
+ for (let n of e.values()) for (let e of n) {
26
+ let n = t.get(e.languageCode) ?? { ...r };
27
+ t.set(e.languageCode, {
28
+ translated: n.translated + e.translatedKeys,
29
+ total: n.total + e.totalKeys,
30
+ waiting: n.waiting + e.pendingReviewKeys,
31
+ missing: n.missing + e.missingCount
32
+ });
33
+ }
34
+ let n = /* @__PURE__ */ new Map();
35
+ for (let [e, r] of t) n.set(e, i(r));
36
+ return n;
37
+ }
38
+ function o(e, t) {
39
+ let n = e.reduce((e, t) => Math.max(e, t.totalKeys), 0), a = e.filter((e) => e.languageCode !== t);
40
+ return {
41
+ ...i((a.length > 0 ? a : e).reduce((e, t) => ({
42
+ translated: e.translated + t.translatedKeys,
43
+ total: e.total + t.totalKeys,
44
+ waiting: e.waiting + t.pendingReviewKeys,
45
+ missing: e.missing + t.missingCount
46
+ }), { ...r })),
47
+ texts: n
48
+ };
49
+ }
50
+ function s(e) {
51
+ return e.namespace?.displayName || e.product.displayName;
52
+ }
53
+ function c(e) {
54
+ return [...e].sort((e, t) => e.isDefault === t.isDefault ? e.name.localeCompare(t.name) : e.isDefault ? -1 : 1);
55
+ }
56
+ async function l(e, t, n) {
57
+ let r = Array(e.length), i = 0;
58
+ await Promise.all(Array.from({ length: Math.max(1, Math.min(t, e.length)) }, async () => {
59
+ for (; i < e.length;) {
60
+ let t = i;
61
+ i += 1;
62
+ let a = e[t];
63
+ try {
64
+ r[t] = {
65
+ ok: !0,
66
+ item: a,
67
+ result: await n(a)
68
+ };
69
+ } catch {
70
+ r[t] = {
71
+ ok: !1,
72
+ item: a
73
+ };
74
+ }
75
+ }
76
+ }));
77
+ let a = [], o = [];
78
+ for (let e of r) e && (e.ok ? a.push({
79
+ item: e.item,
80
+ result: e.result
81
+ }) : o.push(e.item));
82
+ return {
83
+ done: a,
84
+ failed: o
85
+ };
86
+ }
87
+ export { e as LANGUAGES_TABS, n as LANGUAGE_PARAM, l as eachLimited, a as languageProgress, o as productProgress, t as readLanguagesTab, c as sortLanguages, s as whereItAppears };
@@ -0,0 +1,9 @@
1
+ import { NotifyOptions } from '@burdenoff/fe-libs/ui';
2
+ import { ApproveOutcome } from './useReviewQueue';
3
+ export type Tr = (key: string, fallback: string, params?: Record<string, string | number>) => string;
4
+ /** After one Approve. */
5
+ export declare function approvedMessage(tr: Tr, outcome: ApproveOutcome): NotifyOptions;
6
+ /** After Approve all shown: how many were approved, and what went wrong. */
7
+ export declare function approvedManyMessage(tr: Tr, outcomes: readonly ApproveOutcome[], failed: number): NotifyOptions;
8
+ /** After Put them live. */
9
+ export declare function liveMessage(tr: Tr, done: number, failed: number): NotifyOptions;
@@ -0,0 +1,40 @@
1
+ import { COUNT as e } from "./formats.js";
2
+ // src/i18n/v2/reviewMessages.ts
3
+ function t(e, t) {
4
+ return t === "live" ? {
5
+ title: e("i18n.v3.approved", "Approved. It’s live now."),
6
+ tone: "success"
7
+ } : {
8
+ title: e("i18n.v3.approvedNotLive", "Approved, but it isn’t live yet."),
9
+ description: e("i18n.v3.approvedNotLiveBody", "Put it live from the note above the queue."),
10
+ tone: "warning"
11
+ };
12
+ }
13
+ function n(t, n, r) {
14
+ let i = n.filter((e) => e !== "live").length;
15
+ return r === 0 && i === 0 ? {
16
+ title: t("i18n.v3.approvedCount", "Approved {{count}}. They’re live now.", { count: e.format(n.length) }),
17
+ tone: "success"
18
+ } : {
19
+ title: t("i18n.v3.approvedSome", "Approved {{done}} of {{count}}.", {
20
+ done: e.format(n.length),
21
+ count: e.format(n.length + r)
22
+ }),
23
+ description: r > 0 ? t("i18n.v3.approvedSomeFailed", "The rest couldn’t be approved. Try again.") : t("i18n.v3.approvedSomeNotLive", "Some aren’t live yet: put them live from the note above the queue."),
24
+ tone: "warning"
25
+ };
26
+ }
27
+ function r(t, n, r) {
28
+ return r === 0 ? {
29
+ title: t("i18n.v3.liveCount", "{{count}} translations are live now.", { count: e.format(n) }),
30
+ tone: "success"
31
+ } : {
32
+ title: t("i18n.v3.liveSome", "Put {{done}} of {{count}} live.", {
33
+ done: e.format(n),
34
+ count: e.format(n + r)
35
+ }),
36
+ description: t("i18n.v3.liveSomeFailed", "The rest couldn’t be put live. Try again."),
37
+ tone: "warning"
38
+ };
39
+ }
40
+ export { n as approvedManyMessage, t as approvedMessage, r as liveMessage };
@@ -0,0 +1,35 @@
1
+ import { LanguageDirection, LanguageStatus } from '../../generated/global-types';
2
+ import { CoverageLine } from './model';
3
+ export interface LanguageRow {
4
+ id: string;
5
+ code: string;
6
+ name: string;
7
+ nativeName: string;
8
+ direction: LanguageDirection;
9
+ status: LanguageStatus;
10
+ isDefault: boolean;
11
+ region: string | null;
12
+ }
13
+ export interface ProductRow {
14
+ id: string;
15
+ displayName: string;
16
+ description: string | null;
17
+ }
18
+ export declare function useLanguagesData(): {
19
+ languages: LanguageRow[];
20
+ products: ProductRow[];
21
+ sourceCode: string | null;
22
+ coverage: {
23
+ byProduct: Map<string, CoverageLine[]>;
24
+ failed: string[];
25
+ /** The first load only. */
26
+ loading: boolean;
27
+ reload: () => void;
28
+ };
29
+ languagesLoading: boolean;
30
+ productsLoading: boolean;
31
+ languagesError: import('@apollo/client').ErrorLike | undefined;
32
+ productsError: import('@apollo/client').ErrorLike | undefined;
33
+ retry: () => void;
34
+ };
35
+ export type LanguagesData = ReturnType<typeof useLanguagesData>;
@@ -0,0 +1,62 @@
1
+ import { useApolloClient as e } from "../../node_modules/@apollo/client/react/hooks/useApolloClient.js";
2
+ import { GetI18nCoverageDocument as t, useGetI18nLanguagesQuery as n, useGetI18nProductsQuery as r } from "../../generated/global-operations.js";
3
+ import { I18nProductStatus as i } from "../../generated/global-types.js";
4
+ import { eachLimited as a } from "./model.js";
5
+ import { useCallback as o, useEffect as s, useMemo as c, useState as l } from "react";
6
+ // src/i18n/v2/useLanguagesData.ts
7
+ var u = 4, d = {
8
+ for: "",
9
+ byProduct: /* @__PURE__ */ new Map(),
10
+ failed: []
11
+ };
12
+ function f(n) {
13
+ let r = e(), i = n.join(","), [c, f] = l(0), [p, m] = l(d);
14
+ s(() => {
15
+ if (!i) return;
16
+ let e = !0;
17
+ return a(i.split(","), u, async (e) => (await r.query({
18
+ query: t,
19
+ variables: { productId: e },
20
+ fetchPolicy: c > 0 ? "network-only" : "cache-first"
21
+ })).data?.translationCoverage ?? []).then(({ done: t, failed: n }) => {
22
+ e && m({
23
+ for: `${i}#${c}`,
24
+ byProduct: new Map(t.map(({ item: e, result: t }) => [e, t])),
25
+ failed: n
26
+ });
27
+ }), () => {
28
+ e = !1;
29
+ };
30
+ }, [
31
+ r,
32
+ i,
33
+ c
34
+ ]);
35
+ let h = o(() => f((e) => e + 1), []);
36
+ return {
37
+ byProduct: p.byProduct,
38
+ failed: p.failed,
39
+ loading: !!i && p.for === "",
40
+ reload: h
41
+ };
42
+ }
43
+ function p() {
44
+ let e = n({ variables: { limit: 100 } }), t = r({ variables: {
45
+ filter: { status: i.Active },
46
+ limit: 100
47
+ } }), a = c(() => e.data?.languages.items ?? [], [e.data]), s = c(() => t.data?.i18nProducts.items ?? [], [t.data]), l = f(c(() => s.map((e) => e.id), [s])), u = a.find((e) => e.isDefault)?.code ?? null, { refetch: d } = e, { refetch: p } = t, m = o(() => {
48
+ d(), p();
49
+ }, [d, p]);
50
+ return {
51
+ languages: a,
52
+ products: s,
53
+ sourceCode: u,
54
+ coverage: l,
55
+ languagesLoading: e.loading && a.length === 0,
56
+ productsLoading: t.loading && s.length === 0,
57
+ languagesError: e.error,
58
+ productsError: t.error,
59
+ retry: m
60
+ };
61
+ }
62
+ export { p as useLanguagesData };
@@ -0,0 +1,9 @@
1
+ import { ReviewQueue, ReviewRow } from './useReviewQueue';
2
+ export declare function useReviewActions(queue: ReviewQueue, onReviewed: () => void): {
3
+ busy: ReadonlySet<string>;
4
+ bulk: boolean;
5
+ approveOne: (row: ReviewRow) => Promise<void>;
6
+ approveShown: () => Promise<void>;
7
+ putLive: () => Promise<void>;
8
+ };
9
+ export type ReviewActions = ReturnType<typeof useReviewActions>;
@@ -0,0 +1,56 @@
1
+ import { useTr as e } from "../hooks/useTr.js";
2
+ import { COUNT as t } from "./formats.js";
3
+ import { eachLimited as n } from "./model.js";
4
+ import { approvedManyMessage as r, approvedMessage as i, liveMessage as a } from "./reviewMessages.js";
5
+ import { useState as o } from "react";
6
+ import { useConfirm as s, useNotify as c } from "@burdenoff/fe-libs/ui";
7
+ // src/i18n/v2/useReviewActions.ts
8
+ var l = 4;
9
+ function u(u, d) {
10
+ let f = e(), p = c(), m = s(), [h, g] = o(/* @__PURE__ */ new Set()), [_, v] = o(!1), y = () => {
11
+ u.refresh(), d();
12
+ };
13
+ return {
14
+ busy: h,
15
+ bulk: _,
16
+ approveOne: async (e) => {
17
+ g((t) => new Set(t).add(e.id));
18
+ try {
19
+ p(i(f, await u.approve(e.id))), y();
20
+ } catch {
21
+ p({
22
+ title: f("i18n.v3.approveFailed", "Couldn’t approve it. Try again."),
23
+ tone: "error"
24
+ });
25
+ } finally {
26
+ g((t) => {
27
+ let n = new Set(t);
28
+ return n.delete(e.id), n;
29
+ });
30
+ }
31
+ },
32
+ approveShown: async () => {
33
+ let e = u.rows;
34
+ if (!await m({
35
+ title: f("i18n.v3.approveAllTitle", "Approve {{count}} translations?", { count: t.format(e.length) }),
36
+ description: f("i18n.v3.approveAllBody", "They go live in every product straight away."),
37
+ confirmLabel: f("i18n.v3.approveAll", "Approve all shown")
38
+ })) return;
39
+ v(!0);
40
+ let { done: i, failed: a } = await n(e, l, (e) => u.approve(e.id));
41
+ v(!1), p(r(f, i.map(({ result: e }) => e), a.length)), y();
42
+ },
43
+ putLive: async () => {
44
+ let e = u.notLive;
45
+ if (!await m({
46
+ title: f("i18n.v3.putLiveTitle", "Put {{count}} translations live?", { count: t.format(e.length) }),
47
+ description: f("i18n.v3.putLiveBody", "They’re approved already. Every product shows them straight away."),
48
+ confirmLabel: f("i18n.v3.putLive", "Put them live")
49
+ })) return;
50
+ v(!0);
51
+ let { done: r, failed: i } = await n(e, l, (e) => u.publish(e.id));
52
+ v(!1), p(a(f, r.length, i.length)), y();
53
+ }
54
+ };
55
+ }
56
+ export { u as useReviewActions };
@@ -0,0 +1,44 @@
1
+ export interface ReviewRow {
2
+ id: string;
3
+ value: string;
4
+ languageCode: string;
5
+ updatedAt: string;
6
+ key: {
7
+ id: string;
8
+ defaultValue: string | null;
9
+ description: string | null;
10
+ product: {
11
+ id: string;
12
+ displayName: string;
13
+ };
14
+ namespace: {
15
+ id: string;
16
+ displayName: string;
17
+ } | null;
18
+ };
19
+ }
20
+ /** How many rows a page of the queue shows; Show more adds as many again. */
21
+ export declare const REVIEW_PAGE = 50;
22
+ /** What one approval ended as. */
23
+ export type ApproveOutcome = "live" | "approvedOnly";
24
+ /** How many translations wait for review, in every language (the tab's count). */
25
+ export declare function useWaitingCount(): number | undefined;
26
+ export declare function useReviewQueue(languageCode: string | null): {
27
+ rows: ReviewRow[];
28
+ total: any;
29
+ hasMore: any;
30
+ loading: boolean;
31
+ loadingMore: boolean;
32
+ error: import('@apollo/client').ErrorLike | undefined;
33
+ retry: () => undefined;
34
+ showMore: () => void;
35
+ notLive: ReviewRow[];
36
+ notLiveTotal: any;
37
+ approve: (id: string) => Promise<ApproveOutcome>;
38
+ publish: (id: string) => Promise<void>;
39
+ refresh: () => import('@apollo/client').ApolloClient.RefetchQueriesResult<Promise<{
40
+ data: any;
41
+ error?: import('@apollo/client').ErrorLike;
42
+ }>>;
43
+ };
44
+ export type ReviewQueue = ReturnType<typeof useReviewQueue>;
@@ -0,0 +1,60 @@
1
+ import { useApolloClient as e } from "../../node_modules/@apollo/client/react/hooks/useApolloClient.js";
2
+ import { useApproveI18nTranslationMutation as t, useGetI18nTranslationsByStatusQuery as n, usePublishI18nTranslationMutation as r } from "../../generated/global-operations.js";
3
+ import { TranslationStatus as i } from "../../generated/global-types.js";
4
+ import { useCallback as a, useState as o } from "react";
5
+ var s = ["GetI18nTranslationsByStatus"];
6
+ function c(e) {
7
+ return e ? { languageCode: e } : {};
8
+ }
9
+ function l() {
10
+ let { data: e } = n({ variables: {
11
+ filter: { status: i.PendingReview },
12
+ limit: 1
13
+ } });
14
+ return e?.translations.total;
15
+ }
16
+ function u(l) {
17
+ let u = e(), [d, f] = o(50), p = n({
18
+ variables: {
19
+ filter: {
20
+ status: i.PendingReview,
21
+ ...c(l)
22
+ },
23
+ limit: d
24
+ },
25
+ notifyOnNetworkStatusChange: !0
26
+ }), m = n({ variables: {
27
+ filter: {
28
+ status: i.Approved,
29
+ ...c(l)
30
+ },
31
+ limit: 50
32
+ } }), [h] = t(), [g] = r(), _ = p.data?.translations.items ?? [], v = m.data?.translations.items ?? [], y = a(async (e) => {
33
+ let t = await g({ variables: { id: e } });
34
+ if (t.error) throw t.error;
35
+ }, [g]), b = a(async (e) => {
36
+ let t = await h({ variables: { id: e } });
37
+ if (t.error) throw t.error;
38
+ try {
39
+ return await y(e), "live";
40
+ } catch {
41
+ return "approvedOnly";
42
+ }
43
+ }, [h, y]), x = a(() => u.refetchQueries({ include: s }), [u]);
44
+ return {
45
+ rows: _,
46
+ total: p.data?.translations.total ?? 0,
47
+ hasMore: p.data?.translations.hasMore ?? !1,
48
+ loading: p.loading && _.length === 0,
49
+ loadingMore: p.loading && _.length > 0,
50
+ error: p.error,
51
+ retry: () => void p.refetch(),
52
+ showMore: () => f((e) => e + 50),
53
+ notLive: v,
54
+ notLiveTotal: m.data?.translations.total ?? 0,
55
+ approve: b,
56
+ publish: y,
57
+ refresh: x
58
+ };
59
+ }
60
+ export { u as useReviewQueue, l as useWaitingCount };
@@ -0,0 +1,15 @@
1
+ import { invariant as e } from "../../utilities/invariant/index.js";
2
+ import * as t from "react";
3
+ // node_modules/@apollo/client/react/context/ApolloContext.js
4
+ var n = Symbol.for("__APOLLO_CONTEXT__");
5
+ function r() {
6
+ e("createContext" in t, 39);
7
+ let r = t.createContext[n];
8
+ return r || (Object.defineProperty(t.createContext, n, {
9
+ value: r = t.createContext({}),
10
+ enumerable: !1,
11
+ writable: !1,
12
+ configurable: !0
13
+ }), r.displayName = "ApolloContext"), r;
14
+ }
15
+ export { r as getApolloContext };
@@ -0,0 +1,3 @@
1
+ // node_modules/@apollo/client/react/hooks/constants.js
2
+ var e = Symbol.for("apollo.skipToken");
3
+ export { e as skipToken };
@@ -0,0 +1,11 @@
1
+ import e from "../../../../../@wry/equality/lib/index.js";
2
+ import * as t from "react";
3
+ // node_modules/@apollo/client/react/hooks/internal/useDeepMemo.js
4
+ function n(n, r) {
5
+ let i = t.useRef(void 0);
6
+ return i.current && e(i.current.deps, r) || (i.current = {
7
+ value: n(),
8
+ deps: r
9
+ }), i.current.value;
10
+ }
11
+ export { n as useDeepMemo };
@@ -0,0 +1,5 @@
1
+ import { canUseDOM as e } from "../../../utilities/internal/canUseDOM.js";
2
+ import * as t from "react";
3
+ // node_modules/@apollo/client/react/hooks/internal/useIsomorphicLayoutEffect.js
4
+ var n = e ? t.useLayoutEffect : t.useEffect;
5
+ export { n as useIsomorphicLayoutEffect };
@@ -0,0 +1,13 @@
1
+ import { wrapperSymbol as e } from "../../internal/index.js";
2
+ import { getApolloContext as t } from "../../context/ApolloContext.js";
3
+ import * as n from "react";
4
+ // node_modules/@apollo/client/react/hooks/internal/wrapHook.js
5
+ function r(r, i, a) {
6
+ let o = [a.queryManager, r.startsWith("use") ? n.useContext(t()) : void 0], s = i;
7
+ for (let t of o) {
8
+ let n = t?.[e]?.[r];
9
+ n && (s = n(s));
10
+ }
11
+ return s;
12
+ }
13
+ export { r as wrapHook };
@@ -0,0 +1,9 @@
1
+ import { invariant as e } from "../../utilities/invariant/index.js";
2
+ import { getApolloContext as t } from "../context/ApolloContext.js";
3
+ import * as n from "react";
4
+ // node_modules/@apollo/client/react/hooks/useApolloClient.js
5
+ function r(r) {
6
+ let i = n.useContext(t()), a = r || i.client;
7
+ return e(!!a, 30), a;
8
+ }
9
+ export { r as useApolloClient };