@microvac/plugin-wayfinder 0.2.0-rc.1 → 0.2.0-rc.3

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/lib/client.js CHANGED
@@ -1,7 +1,7 @@
1
1
  window.__ModuleLoader__.load({
2
2
  id: "@microvac/plugin-wayfinder",
3
3
  factory: (require) => {
4
- require("@microvac/ui").requireVersion("^1.4.0", "@microvac/plugin-wayfinder");
4
+ require("@microvac/ui").requireVersion("^1.5.0", "@microvac/plugin-wayfinder");
5
5
  const module = { exports: {} };
6
6
  const exports = module.exports;
7
7
  "use strict";
@@ -36,16 +36,59 @@ __export(client_exports, {
36
36
  module.exports = __toCommonJS(client_exports);
37
37
 
38
38
  // src/map.tsx
39
+ var import_ui2 = require("@microvac/ui");
40
+
41
+ // src/i18n.ts
39
42
  var import_ui = require("@microvac/ui");
40
43
 
44
+ // src/messages.ts
45
+ var NAMESPACE = "microvac-wayfinder";
46
+ var en = {
47
+ progress: "Progress",
48
+ done: "{{done}} / {{total}} done",
49
+ childrenDone: "Children done",
50
+ questions: "Open questions",
51
+ noQuestion: "No question waiting for an answer.",
52
+ plan: "Plan",
53
+ noPlan: "No plan yet.",
54
+ noPlanDocument: "No plan document",
55
+ noChild: "No sub-task yet: the Wayfinder task creates them as it maps the initiative.",
56
+ loading: "Loading the map\u2026",
57
+ loadError: "Could not load the map: {{error}}.",
58
+ unknownError: "unknown error",
59
+ group: { grilling: "Grilling", research: "Research", plan: "Plan", delivery: "Delivery", other: "Other" }
60
+ };
61
+ var fr = {
62
+ progress: "Avancement",
63
+ done: "{{done}} / {{total}} termin\xE9es",
64
+ childrenDone: "Sous-t\xE2ches termin\xE9es",
65
+ questions: "Questions ouvertes",
66
+ noQuestion: "Aucune question n'attend de r\xE9ponse.",
67
+ plan: "Plan",
68
+ noPlan: "Pas encore de plan.",
69
+ noPlanDocument: "Pas de document de plan",
70
+ noChild: "Pas encore de sous-t\xE2che : la t\xE2che Wayfinder les cr\xE9e en cartographiant l'initiative.",
71
+ loading: "Chargement de la carte\u2026",
72
+ loadError: "La carte n'a pas pu \xEAtre charg\xE9e : {{error}}.",
73
+ unknownError: "erreur inconnue",
74
+ group: { grilling: "Interrogatoire", research: "Recherche", plan: "Plan", delivery: "Livraison", other: "Autres" }
75
+ };
76
+ var messages = { en, fr };
77
+
78
+ // src/i18n.ts
79
+ var t = import_ui.i18n.register(NAMESPACE, messages);
80
+ function useT() {
81
+ return import_ui.i18n.useTranslation(NAMESPACE).t;
82
+ }
83
+
41
84
  // src/map-model.ts
42
85
  var MAP_GROUPS = [
43
- { mode: "wayfinder.grilling", label: "Grilling" },
44
- { mode: "wayfinder.research", label: "Research" },
45
- { mode: "planning", label: "Plan" },
46
- { mode: "wayfinder.delivery", label: "Delivery" }
86
+ { mode: "wayfinder.grilling", labelKey: "group.grilling" },
87
+ { mode: "wayfinder.research", labelKey: "group.research" },
88
+ { mode: "planning", labelKey: "group.plan" },
89
+ { mode: "wayfinder.delivery", labelKey: "group.delivery" }
47
90
  ];
48
- var OTHER = { mode: "other", label: "Other" };
91
+ var OTHER = { mode: "other", labelKey: "group.other" };
49
92
  var FINISHED = /* @__PURE__ */ new Set(["done", "cancelled"]);
50
93
  function toTask(child) {
51
94
  return {
@@ -78,7 +121,7 @@ function grillingChildren(children) {
78
121
  }
79
122
  function buildMap(children, interactionsByIssue, planDocuments) {
80
123
  const groups = /* @__PURE__ */ new Map();
81
- for (const { mode, label } of [...MAP_GROUPS, OTHER]) groups.set(mode, { mode, label, tasks: [] });
124
+ for (const { mode, labelKey } of [...MAP_GROUPS, OTHER]) groups.set(mode, { mode, labelKey, tasks: [] });
82
125
  for (const child of children) {
83
126
  const mode = child.workMode && groups.has(child.workMode) ? child.workMode : OTHER.mode;
84
127
  groups.get(mode).tasks.push(toTask(child));
@@ -88,7 +131,7 @@ function buildMap(children, interactionsByIssue, planDocuments) {
88
131
  for (const child of children) {
89
132
  const document = plansByIssue.get(child.id);
90
133
  if (document || child.workMode === "planning") {
91
- plans.push({ task: toTask(child), documentTitle: document ? document.title ?? "Plan" : null });
134
+ plans.push({ task: toTask(child), documentTitle: document ? document.title ?? "" : null });
92
135
  }
93
136
  }
94
137
  const counted = children.filter((child) => child.status !== "cancelled");
@@ -105,14 +148,14 @@ var import_jsx_runtime = require("react/jsx-runtime");
105
148
  var DOCUMENT_BATCH_MAX = 200;
106
149
  async function loadMap(context) {
107
150
  const company = encodeURIComponent(context.companyId);
108
- const children = await import_ui.api.get(`/companies/${company}/issues?parentId=${encodeURIComponent(context.issueId)}`);
151
+ const children = await import_ui2.api.get(`/companies/${company}/issues?parentId=${encodeURIComponent(context.issueId)}`);
109
152
  const ids = children.map((child) => child.id).slice(0, DOCUMENT_BATCH_MAX);
110
153
  const [plans, interactions] = await Promise.all([
111
- ids.length ? import_ui.api.get(`/companies/${company}/issue-documents?key=plan&includeBody=false&issueIds=${ids.join(",")}`).then((batch) => batch.items) : Promise.resolve([]),
154
+ ids.length ? import_ui2.api.get(`/companies/${company}/issue-documents?key=plan&includeBody=false&issueIds=${ids.join(",")}`).then((batch) => batch.items) : Promise.resolve([]),
112
155
  Promise.all(
113
156
  grillingChildren(children).map(async (child) => [
114
157
  child.id,
115
- await import_ui.api.get(`/issues/${encodeURIComponent(child.id)}/interactions`)
158
+ await import_ui2.api.get(`/issues/${encodeURIComponent(child.id)}/interactions`)
116
159
  ])
117
160
  )
118
161
  ]);
@@ -126,7 +169,7 @@ function TaskLink({ task, context }) {
126
169
  };
127
170
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("a", { href: context.taskHref(task.ref), onClick: open, className: "min-w-0 break-words hover:underline", children: [
128
171
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "mr-1.5 font-mono text-xs text-muted-foreground", children: task.ref }),
129
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_ui.cn)(task.finished && "text-muted-foreground line-through"), children: task.title })
172
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: (0, import_ui2.cn)(task.finished && "text-muted-foreground line-through"), children: task.title })
130
173
  ] });
131
174
  }
132
175
  function Section({ title, aside, children }) {
@@ -139,15 +182,11 @@ function Section({ title, aside, children }) {
139
182
  ] });
140
183
  }
141
184
  function MapView({ map, context }) {
185
+ const t2 = useT();
142
186
  const { done, total } = map.progress;
143
187
  const percent = total ? Math.round(done / total * 100) : 0;
144
188
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-6", "data-testid": "wayfinder-map", children: [
145
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: "Progress", aside: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "text-xs text-muted-foreground", children: [
146
- done,
147
- " / ",
148
- total,
149
- " done"
150
- ] }), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
189
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: t2("progress"), aside: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "text-xs text-muted-foreground", children: t2("done", { done, total }) }), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
151
190
  "div",
152
191
  {
153
192
  className: "h-2 w-full overflow-hidden rounded-full bg-muted",
@@ -155,23 +194,23 @@ function MapView({ map, context }) {
155
194
  "aria-valuemin": 0,
156
195
  "aria-valuemax": total,
157
196
  "aria-valuenow": done,
158
- "aria-label": "Children done",
197
+ "aria-label": t2("childrenDone"),
159
198
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-full rounded-full bg-primary", style: { width: `${percent}%` } })
160
199
  }
161
200
  ) }),
162
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: "Open questions", aside: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Badge, { variant: "outline", children: map.questions.length }), children: map.questions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: "No question waiting for an answer." }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "space-y-2", children: map.questions.map((question) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "rounded-md border border-border p-3 text-sm", children: [
201
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: t2("questions"), aside: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui2.Badge, { variant: "outline", children: map.questions.length }), children: map.questions.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: t2("noQuestion") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "space-y-2", children: map.questions.map((question) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "rounded-md border border-border p-3 text-sm", children: [
163
202
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "font-medium", children: question.title }),
164
203
  question.prompts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "mt-1 list-disc space-y-0.5 pl-5 text-muted-foreground", children: question.prompts.map((prompt, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: prompt }, index)) }) : null,
165
204
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TaskLink, { task: question.task, context }) })
166
205
  ] }, question.interactionId)) }) }),
167
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: "Plan", children: map.plans.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: "No plan yet." }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "space-y-1 text-sm", children: map.plans.map((plan) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "flex flex-wrap items-center gap-2", children: [
206
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, { title: t2("plan"), children: map.plans.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: t2("noPlan") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "space-y-1 text-sm", children: map.plans.map((plan) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "flex flex-wrap items-center gap-2", children: [
168
207
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TaskLink, { task: plan.task, context }),
169
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Badge, { variant: "outline", children: plan.documentTitle ?? "No plan document" })
208
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui2.Badge, { variant: "outline", children: plan.documentTitle === null ? t2("noPlanDocument") : plan.documentTitle || t2("plan") })
170
209
  ] }, plan.task.id)) }) }),
171
- map.groups.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: "No sub-task yet: the Wayfinder task creates them as it maps the initiative." }) : map.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
210
+ map.groups.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: t2("noChild") }) : map.groups.map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
172
211
  Section,
173
212
  {
174
- title: group.label,
213
+ title: t2(group.labelKey),
175
214
  aside: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "text-xs text-muted-foreground", children: [
176
215
  group.tasks.filter((task) => task.status === "done").length,
177
216
  " / ",
@@ -179,7 +218,7 @@ function MapView({ map, context }) {
179
218
  ] }),
180
219
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", { className: "divide-y divide-border rounded-md border border-border text-sm", children: group.tasks.map((task) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", { className: "flex items-center justify-between gap-3 px-3 py-2", children: [
181
220
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TaskLink, { task, context }),
182
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Badge, { variant: "secondary", className: "shrink-0", children: task.status.replace(/_/g, " ") })
221
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui2.Badge, { variant: "secondary", className: "shrink-0", children: task.status.replace(/_/g, " ") })
183
222
  ] }, task.id)) })
184
223
  },
185
224
  group.mode
@@ -187,17 +226,14 @@ function MapView({ map, context }) {
187
226
  ] });
188
227
  }
189
228
  function MapTab({ context }) {
190
- const query = (0, import_ui.useQuery)({
229
+ const t2 = useT();
230
+ const query = (0, import_ui2.useQuery)({
191
231
  queryKey: ["microvac", "wayfinder", "map", context.issueId],
192
232
  queryFn: () => loadMap(context)
193
233
  });
194
- if (query.isPending) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: "Loading the map\u2026" });
234
+ if (query.isPending) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-muted-foreground", children: t2("loading") });
195
235
  if (query.error || !query.data) {
196
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "text-sm text-destructive", role: "alert", children: [
197
- "Could not load the map: ",
198
- query.error instanceof Error ? query.error.message : "unknown error",
199
- "."
200
- ] });
236
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "text-sm text-destructive", role: "alert", children: t2("loadError", { error: query.error instanceof Error ? query.error.message : t2("unknownError") }) });
201
237
  }
202
238
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MapView, { map: query.data, context });
203
239
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microvac/plugin-wayfinder",
3
- "version": "0.2.0-rc.1",
3
+ "version": "0.2.0-rc.3",
4
4
  "license": "MIT",
5
5
  "description": "Microvac plugin: Wayfinder, Grilling, Research and Delivery task modes, off by default.",
6
6
  "type": "module",
@@ -14,7 +14,7 @@
14
14
  "lib"
15
15
  ],
16
16
  "microvac": {
17
- "ui": "^1.4.0"
17
+ "ui": "^1.5.0"
18
18
  },
19
19
  "dsh": {
20
20
  "client": {
package/src/i18n.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { i18n } from "@microvac/ui";
2
+ import { messages, NAMESPACE } from "./messages.js";
3
+
4
+ /** The plugin's `t`, for code outside components (labels, toasts). */
5
+ export const t = i18n.register(NAMESPACE, messages);
6
+
7
+ /** The plugin's `t` in a component, which renders again when the UI language changes. */
8
+ export function useT() {
9
+ return i18n.useTranslation(NAMESPACE).t;
10
+ }
package/src/map-model.ts CHANGED
@@ -34,7 +34,8 @@ export interface MapTask {
34
34
 
35
35
  export interface MapGroup {
36
36
  mode: string;
37
- label: string;
37
+ /** Message key of the group's label (`group.*` in `messages.ts`). */
38
+ labelKey: string;
38
39
  tasks: MapTask[];
39
40
  }
40
41
 
@@ -47,7 +48,7 @@ export interface MapQuestion {
47
48
 
48
49
  export interface MapPlan {
49
50
  task: MapTask;
50
- /** Title of the plan document, or null when the task is a Plan task without one yet. */
51
+ /** Title of the plan document (empty when untitled), or null when the task is a Plan task without one yet. */
51
52
  documentTitle: string | null;
52
53
  }
53
54
 
@@ -58,15 +59,15 @@ export interface WayfinderMap {
58
59
  progress: { done: number; total: number };
59
60
  }
60
61
 
61
- /** Mode order on the Map, with labels; anything else goes under "Other". */
62
- export const MAP_GROUPS: readonly { mode: string; label: string }[] = [
63
- { mode: "wayfinder.grilling", label: "Grilling" },
64
- { mode: "wayfinder.research", label: "Research" },
65
- { mode: "planning", label: "Plan" },
66
- { mode: "wayfinder.delivery", label: "Delivery" },
62
+ /** Mode order on the Map, with message keys of the labels (`group.*`); anything else goes under "Other". */
63
+ export const MAP_GROUPS: readonly { mode: string; labelKey: string }[] = [
64
+ { mode: "wayfinder.grilling", labelKey: "group.grilling" },
65
+ { mode: "wayfinder.research", labelKey: "group.research" },
66
+ { mode: "planning", labelKey: "group.plan" },
67
+ { mode: "wayfinder.delivery", labelKey: "group.delivery" },
67
68
  ];
68
69
 
69
- const OTHER = { mode: "other", label: "Other" };
70
+ const OTHER = { mode: "other", labelKey: "group.other" };
70
71
 
71
72
  const FINISHED = new Set(["done", "cancelled"]);
72
73
 
@@ -113,7 +114,7 @@ export function buildMap(
113
114
  planDocuments: readonly MapPlanDocument[],
114
115
  ): WayfinderMap {
115
116
  const groups = new Map<string, MapGroup>();
116
- for (const { mode, label } of [...MAP_GROUPS, OTHER]) groups.set(mode, { mode, label, tasks: [] });
117
+ for (const { mode, labelKey } of [...MAP_GROUPS, OTHER]) groups.set(mode, { mode, labelKey, tasks: [] });
117
118
  for (const child of children) {
118
119
  const mode = child.workMode && groups.has(child.workMode) ? child.workMode : OTHER.mode;
119
120
  groups.get(mode)!.tasks.push(toTask(child));
@@ -124,7 +125,7 @@ export function buildMap(
124
125
  for (const child of children) {
125
126
  const document = plansByIssue.get(child.id);
126
127
  if (document || child.workMode === "planning") {
127
- plans.push({ task: toTask(child), documentTitle: document ? document.title ?? "Plan" : null });
128
+ plans.push({ task: toTask(child), documentTitle: document ? document.title ?? "" : null });
128
129
  }
129
130
  }
130
131
 
package/src/map.tsx CHANGED
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import type { MouseEvent, ReactNode } from "react";
6
6
  import { api, Badge, cn, useQuery } from "@microvac/ui";
7
+ import { useT } from "./i18n.js";
7
8
  import {
8
9
  buildMap,
9
10
  grillingChildren,
@@ -73,26 +74,27 @@ function Section({ title, aside, children }: { title: string; aside?: ReactNode;
73
74
  }
74
75
 
75
76
  export function MapView({ map, context }: { map: WayfinderMap; context: MapTabContext }) {
77
+ const t = useT();
76
78
  const { done, total } = map.progress;
77
79
  const percent = total ? Math.round((done / total) * 100) : 0;
78
80
  return (
79
81
  <div className="space-y-6" data-testid="wayfinder-map">
80
- <Section title="Progress" aside={<span className="text-xs text-muted-foreground">{done} / {total} done</span>}>
82
+ <Section title={t("progress")} aside={<span className="text-xs text-muted-foreground">{t("done", { done, total })}</span>}>
81
83
  <div
82
84
  className="h-2 w-full overflow-hidden rounded-full bg-muted"
83
85
  role="progressbar"
84
86
  aria-valuemin={0}
85
87
  aria-valuemax={total}
86
88
  aria-valuenow={done}
87
- aria-label="Children done"
89
+ aria-label={t("childrenDone")}
88
90
  >
89
91
  <div className="h-full rounded-full bg-primary" style={{ width: `${percent}%` }} />
90
92
  </div>
91
93
  </Section>
92
94
 
93
- <Section title="Open questions" aside={<Badge variant="outline">{map.questions.length}</Badge>}>
95
+ <Section title={t("questions")} aside={<Badge variant="outline">{map.questions.length}</Badge>}>
94
96
  {map.questions.length === 0 ? (
95
- <p className="text-sm text-muted-foreground">No question waiting for an answer.</p>
97
+ <p className="text-sm text-muted-foreground">{t("noQuestion")}</p>
96
98
  ) : (
97
99
  <ul className="space-y-2">
98
100
  {map.questions.map((question) => (
@@ -114,15 +116,15 @@ export function MapView({ map, context }: { map: WayfinderMap; context: MapTabCo
114
116
  )}
115
117
  </Section>
116
118
 
117
- <Section title="Plan">
119
+ <Section title={t("plan")}>
118
120
  {map.plans.length === 0 ? (
119
- <p className="text-sm text-muted-foreground">No plan yet.</p>
121
+ <p className="text-sm text-muted-foreground">{t("noPlan")}</p>
120
122
  ) : (
121
123
  <ul className="space-y-1 text-sm">
122
124
  {map.plans.map((plan) => (
123
125
  <li key={plan.task.id} className="flex flex-wrap items-center gap-2">
124
126
  <TaskLink task={plan.task} context={context} />
125
- <Badge variant="outline">{plan.documentTitle ?? "No plan document"}</Badge>
127
+ <Badge variant="outline">{plan.documentTitle === null ? t("noPlanDocument") : plan.documentTitle || t("plan")}</Badge>
126
128
  </li>
127
129
  ))}
128
130
  </ul>
@@ -130,12 +132,12 @@ export function MapView({ map, context }: { map: WayfinderMap; context: MapTabCo
130
132
  </Section>
131
133
 
132
134
  {map.groups.length === 0 ? (
133
- <p className="text-sm text-muted-foreground">No sub-task yet: the Wayfinder task creates them as it maps the initiative.</p>
135
+ <p className="text-sm text-muted-foreground">{t("noChild")}</p>
134
136
  ) : (
135
137
  map.groups.map((group) => (
136
138
  <Section
137
139
  key={group.mode}
138
- title={group.label}
140
+ title={t(group.labelKey)}
139
141
  aside={
140
142
  <span className="text-xs text-muted-foreground">
141
143
  {group.tasks.filter((task) => task.status === "done").length} / {group.tasks.length}
@@ -158,15 +160,16 @@ export function MapView({ map, context }: { map: WayfinderMap; context: MapTabCo
158
160
  }
159
161
 
160
162
  export function MapTab({ context }: { context: MapTabContext }) {
163
+ const t = useT();
161
164
  const query = useQuery({
162
165
  queryKey: ["microvac", "wayfinder", "map", context.issueId],
163
166
  queryFn: () => loadMap(context),
164
167
  });
165
- if (query.isPending) return <p className="text-sm text-muted-foreground">Loading the map…</p>;
168
+ if (query.isPending) return <p className="text-sm text-muted-foreground">{t("loading")}</p>;
166
169
  if (query.error || !query.data) {
167
170
  return (
168
171
  <p className="text-sm text-destructive" role="alert">
169
- Could not load the map: {query.error instanceof Error ? query.error.message : "unknown error"}.
172
+ {t("loadError", { error: query.error instanceof Error ? query.error.message : t("unknownError") })}
170
173
  </p>
171
174
  );
172
175
  }
@@ -0,0 +1,36 @@
1
+ /** The Wayfinder Map's text (Microvac UI 1.5 translation, ADR 0020): English and French. */
2
+ export const NAMESPACE = "microvac-wayfinder";
3
+
4
+ const en = {
5
+ progress: "Progress",
6
+ done: "{{done}} / {{total}} done",
7
+ childrenDone: "Children done",
8
+ questions: "Open questions",
9
+ noQuestion: "No question waiting for an answer.",
10
+ plan: "Plan",
11
+ noPlan: "No plan yet.",
12
+ noPlanDocument: "No plan document",
13
+ noChild: "No sub-task yet: the Wayfinder task creates them as it maps the initiative.",
14
+ loading: "Loading the map…",
15
+ loadError: "Could not load the map: {{error}}.",
16
+ unknownError: "unknown error",
17
+ group: { grilling: "Grilling", research: "Research", plan: "Plan", delivery: "Delivery", other: "Other" },
18
+ };
19
+
20
+ const fr: typeof en = {
21
+ progress: "Avancement",
22
+ done: "{{done}} / {{total}} terminées",
23
+ childrenDone: "Sous-tâches terminées",
24
+ questions: "Questions ouvertes",
25
+ noQuestion: "Aucune question n'attend de réponse.",
26
+ plan: "Plan",
27
+ noPlan: "Pas encore de plan.",
28
+ noPlanDocument: "Pas de document de plan",
29
+ noChild: "Pas encore de sous-tâche : la tâche Wayfinder les crée en cartographiant l'initiative.",
30
+ loading: "Chargement de la carte…",
31
+ loadError: "La carte n'a pas pu être chargée : {{error}}.",
32
+ unknownError: "erreur inconnue",
33
+ group: { grilling: "Interrogatoire", research: "Recherche", plan: "Plan", delivery: "Livraison", other: "Autres" },
34
+ };
35
+
36
+ export const messages = { en, fr };
@@ -8,6 +8,15 @@ import type { ComponentType } from "react";
8
8
  type AnyComponent = ComponentType<any>;
9
9
 
10
10
  export declare const version: string;
11
+
12
+ export type PluginMessages = { [key: string]: string | PluginMessages };
13
+ export type PluginTranslate = (key: string, values?: Record<string, unknown>) => string;
14
+ export declare const i18n: {
15
+ register(namespace: string, messages: Record<string, PluginMessages>): PluginTranslate;
16
+ useTranslation(namespace: string): { t: PluginTranslate; language: string };
17
+ language(): string;
18
+ };
19
+
11
20
  export declare function requireVersion(range: string, plugin?: string): void;
12
21
 
13
22
  export declare function useQuery<T>(options: {
package/src/modes.js CHANGED
@@ -18,7 +18,8 @@
18
18
  * planReview?(task: Task): boolean,
19
19
  * childAssignee?(child: Child): { assigneeAgentId: string | null } | undefined,
20
20
  * }} ModeHooks
21
- * @typedef {{ id: string, label: string, baseMode: BaseMode, description?: string, skill?: string, tab?: { label: string }, hooks?: ModeHooks }} ModeDefinition
21
+ * @typedef {{ label?: string, description?: string, tabLabel?: string }} ModeTranslation
22
+ * @typedef {{ id: string, label: string, baseMode: BaseMode, description?: string, skill?: string, tab?: { label: string }, translations?: Record<string, ModeTranslation>, hooks?: ModeHooks }} ModeDefinition
22
23
  */
23
24
 
24
25
  /** The modes a Wayfinder task's children take; the Plan child is the core Plan mode. */
@@ -34,6 +35,7 @@ export const MODES = [
34
35
  description: "Maps an initiative and creates its children: Grilling, Research, Plan, Delivery.",
35
36
  // The Map tab; the client face fills it (`src/client.tsx`).
36
37
  tab: { label: "Map" },
38
+ translations: { fr: { description: "Cartographie une initiative et crée ses sous-tâches : Interrogatoire, Recherche, Plan, Livraison.", tabLabel: "Carte" } },
37
39
  hooks: {
38
40
  promptSection: () => [
39
41
  "Wayfinder mode directive:",
@@ -50,6 +52,7 @@ export const MODES = [
50
52
  baseMode: "ask",
51
53
  skill: "grill-with-docs",
52
54
  description: "Asks the human in batches of question cards, writes the decisions down, ends with a plan.",
55
+ translations: { fr: { label: "Interrogatoire", description: "Interroge l'humain par lots de cartes de questions, consigne les décisions, finit par un plan." } },
53
56
  hooks: {
54
57
  promptSection: () => [
55
58
  "Grilling mode directive:",
@@ -68,6 +71,7 @@ export const MODES = [
68
71
  label: "Research",
69
72
  baseMode: "standard",
70
73
  description: "Spike or investigation; the result is a document on the task.",
74
+ translations: { fr: { label: "Recherche", description: "Prototype jetable ou enquête ; le résultat est un document sur la tâche." } },
71
75
  hooks: {
72
76
  promptSection: () => [
73
77
  "Research mode directive:",
@@ -81,6 +85,7 @@ export const MODES = [
81
85
  label: "Delivery",
82
86
  baseMode: "standard",
83
87
  description: "Implementation of a planned piece of the initiative.",
88
+ translations: { fr: { label: "Livraison", description: "Réalisation d'une partie planifiée de l'initiative." } },
84
89
  },
85
90
  ];
86
91