@eifi1/ui-kit 0.38.0 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +6 -5
  2. package/dist/auth/auth-errors.d.ts +8 -3
  3. package/dist/auth/auth-errors.js +3 -1
  4. package/dist/auth/auth-errors.js.map +1 -1
  5. package/dist/billing/billing-labels.d.ts +25 -2
  6. package/dist/billing/billing-labels.js +11 -2
  7. package/dist/billing/billing-labels.js.map +1 -1
  8. package/dist/billing/billing-overview.d.ts +50 -1
  9. package/dist/billing/checkout-processing.d.ts +15 -3
  10. package/dist/billing/checkout-processing.js +3 -1
  11. package/dist/billing/checkout-processing.js.map +1 -1
  12. package/dist/billing/pay-page.d.ts +55 -18
  13. package/dist/billing/pay-page.js +44 -10
  14. package/dist/billing/pay-page.js.map +1 -1
  15. package/dist/billing/plan-switch.d.ts +79 -0
  16. package/dist/billing/plan-switch.js +93 -0
  17. package/dist/billing/plan-switch.js.map +1 -0
  18. package/dist/bin/eifi1-pay-page.mjs +109 -21
  19. package/dist/eslint/index.js +1 -1
  20. package/dist/feedback/feedback-comment-thread.d.ts +13 -6
  21. package/dist/feedback/feedback-comment-thread.js +10 -2
  22. package/dist/feedback/feedback-comment-thread.js.map +1 -1
  23. package/dist/feedback/feedback-labels.d.ts +11 -0
  24. package/dist/feedback/feedback-labels.js +4 -1
  25. package/dist/feedback/feedback-labels.js.map +1 -1
  26. package/dist/feedback/feedback-public-labels.d.ts +3 -0
  27. package/dist/feedback/feedback-public-labels.js +2 -1
  28. package/dist/feedback/feedback-public-labels.js.map +1 -1
  29. package/dist/feedback/feedback-public-list.d.ts +25 -4
  30. package/dist/feedback/feedback-public-list.js +54 -3
  31. package/dist/feedback/feedback-public-list.js.map +1 -1
  32. package/dist/feedback/feedback-public-switch.js +3 -3
  33. package/dist/feedback/feedback-public-switch.js.map +1 -1
  34. package/dist/feedback/feedback-record.d.ts +7 -7
  35. package/dist/feedback/feedback-record.js.map +1 -1
  36. package/dist/feedback/feedback-replies-context.d.ts +7 -0
  37. package/dist/feedback/feedback-replies-context.js +7 -0
  38. package/dist/feedback/feedback-replies-context.js.map +1 -0
  39. package/dist/feedback/feedback-row-detail.d.ts +12 -3
  40. package/dist/feedback/feedback-row-detail.js +2 -1
  41. package/dist/feedback/feedback-row-detail.js.map +1 -1
  42. package/dist/feedback/feedback-table.js +2 -2
  43. package/dist/feedback/feedback-table.js.map +1 -1
  44. package/dist/feedback/feedback-vote-button.d.ts +2 -1
  45. package/dist/feedback/feedback-vote-button.js.map +1 -1
  46. package/dist/i18n/german.js +19 -4
  47. package/dist/i18n/german.js.map +1 -1
  48. package/dist/i18n/locales/en.js +22 -6
  49. package/dist/i18n/locales/en.js.map +2 -2
  50. package/dist/i18n/locales/es.js +19 -4
  51. package/dist/i18n/locales/es.js.map +1 -1
  52. package/dist/i18n/locales/fr.js +19 -4
  53. package/dist/i18n/locales/fr.js.map +1 -1
  54. package/dist/i18n/locales/hu.js +19 -4
  55. package/dist/i18n/locales/hu.js.map +1 -1
  56. package/dist/i18n/locales/it.js +19 -4
  57. package/dist/i18n/locales/it.js.map +1 -1
  58. package/dist/i18n/locales/zh.js +19 -4
  59. package/dist/i18n/locales/zh.js.map +1 -1
  60. package/dist/i18n/review.js +4 -0
  61. package/dist/i18n/review.js.map +1 -1
  62. package/dist/index.d.ts +6 -1
  63. package/dist/index.js +4 -0
  64. package/dist/index.js.map +1 -1
  65. package/dist/lib/translation-review.d.ts +11 -0
  66. package/dist/lib/translation-review.js.map +1 -1
  67. package/dist/pay/pay.js +102 -40
  68. package/package.json +1 -1
  69. package/src/auth/auth-errors.ts +12 -3
  70. package/src/billing/billing-labels.ts +38 -3
  71. package/src/billing/billing-overview.ts +53 -1
  72. package/src/billing/checkout-processing.ts +17 -3
  73. package/src/billing/pay-page.ts +111 -27
  74. package/src/billing/plan-switch.tsx +201 -0
  75. package/src/feedback/feedback-comment-thread.tsx +29 -7
  76. package/src/feedback/feedback-labels.ts +14 -0
  77. package/src/feedback/feedback-public-labels.ts +4 -0
  78. package/src/feedback/feedback-public-list.tsx +88 -5
  79. package/src/feedback/feedback-public-switch.tsx +3 -3
  80. package/src/feedback/feedback-record.ts +7 -7
  81. package/src/feedback/feedback-replies-context.ts +9 -0
  82. package/src/feedback/feedback-row-detail.tsx +16 -4
  83. package/src/feedback/feedback-table.tsx +2 -2
  84. package/src/feedback/feedback-vote-button.tsx +2 -1
  85. package/src/i18n/german.ts +17 -1
  86. package/src/i18n/locales/en.ts +1 -0
  87. package/src/i18n/locales/es.ts +16 -1
  88. package/src/i18n/locales/fr.ts +16 -2
  89. package/src/i18n/locales/hu.ts +16 -1
  90. package/src/i18n/locales/it.ts +16 -1
  91. package/src/i18n/locales/zh.ts +16 -1
  92. package/src/i18n/review.ts +4 -0
  93. package/src/index.ts +8 -0
  94. package/src/lib/translation-review.ts +12 -0
@@ -5,14 +5,23 @@ import process from "process";
5
5
  import { fileURLToPath } from "url";
6
6
 
7
7
  // pay-page/cli.ts
8
- import { copyFileSync, existsSync, mkdirSync, writeFileSync } from "fs";
8
+ import { copyFileSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
9
9
  import { dirname, join } from "path";
10
10
  import { parseArgs } from "util";
11
11
 
12
12
  // src/billing/pay-page.ts
13
13
  var PAY_CONFIG_FILE = "pay-config.json";
14
+ var APP_TAG = /^[a-z][a-z0-9_-]{0,63}$/;
15
+ function appAt(name, site, returnPath) {
16
+ return { name, returnUrl: `${site}${returnPath}`, termsUrl: `${site}/terms`, privacyUrl: `${site}/privacy` };
17
+ }
18
+ var PAY_PAGE_APPS = Object.freeze({
19
+ keksdose: Object.freeze(appAt("Keksdose", "https://keksdose.app", "/settings/subscription")),
20
+ kastlan: Object.freeze(appAt("kastlan", "https://kastlan.app", "/admin/billing")),
21
+ kurvenschmiede: Object.freeze(appAt("Kurvenschmiede", "https://kurvenschmiede.app", "/settings/subscription"))
22
+ });
14
23
  var TOKEN_PREFIX = { sandbox: "test_", live: "live_" };
15
- function isPageUrl(value) {
24
+ function isPayPageUrl(value) {
16
25
  if (typeof value !== "string") return false;
17
26
  let url;
18
27
  try {
@@ -23,6 +32,19 @@ function isPageUrl(value) {
23
32
  if (url.protocol === "https:") return true;
24
33
  return url.protocol === "http:" && ["localhost", "127.0.0.1", "[::1]"].includes(url.hostname);
25
34
  }
35
+ function hasApp(apps, tag) {
36
+ return typeof tag === "string" && APP_TAG.test(tag) && typeof apps === "object" && apps !== null && Object.prototype.hasOwnProperty.call(apps, tag);
37
+ }
38
+ function appProblems(tag, app) {
39
+ if (typeof app !== "object" || app === null) return [`apps.${tag} is not an object`];
40
+ const a = app;
41
+ const problems = [];
42
+ if (typeof a.name !== "string" || a.name.trim() === "") problems.push(`apps.${tag}.name is missing`);
43
+ for (const key of ["returnUrl", "termsUrl", "privacyUrl"]) {
44
+ if (!isPayPageUrl(a[key])) problems.push(`apps.${tag}.${key} must be an https:// URL (http:// for localhost only)`);
45
+ }
46
+ return problems;
47
+ }
26
48
  function payPageConfigProblems(config) {
27
49
  if (typeof config !== "object" || config === null) return ["the configuration is not an object"];
28
50
  const c = config;
@@ -43,10 +65,20 @@ function payPageConfigProblems(config) {
43
65
  );
44
66
  }
45
67
  }
46
- for (const key of ["returnUrl", "termsUrl", "privacyUrl"]) {
47
- if (!isPageUrl(c[key])) problems.push(`${key} must be an https:// URL (http:// for localhost only)`);
68
+ const { apps, app } = c;
69
+ if (typeof apps !== "object" || apps === null || Array.isArray(apps) || Object.keys(apps).length === 0) {
70
+ problems.push("apps must map each app's tag to its name and URLs");
71
+ } else {
72
+ for (const [tag, entry] of Object.entries(apps)) {
73
+ if (!APP_TAG.test(tag)) problems.push(`apps: ${JSON.stringify(tag)} is not an app tag (a-z, 0-9, _ and -)`);
74
+ else problems.push(...appProblems(tag, entry));
75
+ }
76
+ }
77
+ if (typeof app !== "string" || app === "") problems.push("app is missing: the host's own app tag");
78
+ else if (!hasApp(apps, app)) {
79
+ const known = typeof apps === "object" && apps !== null ? Object.keys(apps).join(", ") : "";
80
+ problems.push(`app ${JSON.stringify(app)} is not in apps${known ? ` (${known})` : ""}`);
48
81
  }
49
- if (typeof c.appName !== "string" || c.appName.trim() === "") problems.push("appName is missing");
50
82
  return problems;
51
83
  }
52
84
 
@@ -69,16 +101,60 @@ var given = (value) => {
69
101
  const trimmed = (value ?? "").trim();
70
102
  return trimmed === "" ? null : trimmed;
71
103
  };
104
+ function moved(url, site) {
105
+ let parsed;
106
+ try {
107
+ parsed = new URL(url);
108
+ } catch {
109
+ return url;
110
+ }
111
+ return `${site.replace(/\/+$/, "")}${parsed.pathname}${parsed.search}${parsed.hash}`;
112
+ }
113
+ function mergedApps(over) {
114
+ const apps = {};
115
+ for (const [tag, app] of Object.entries(PAY_PAGE_APPS)) apps[tag] = { ...app };
116
+ for (const [tag, app] of Object.entries(over ?? {})) {
117
+ const base = Object.prototype.hasOwnProperty.call(apps, tag) ? apps[tag] : {};
118
+ Object.defineProperty(apps, tag, { value: { ...base, ...app }, enumerable: true, writable: true, configurable: true });
119
+ }
120
+ return apps;
121
+ }
72
122
  function payPageConfig(options) {
123
+ const app = (options.app ?? "").trim();
124
+ const apps = mergedApps(options.apps);
125
+ const problems = [];
126
+ const site = given(options.appUrl);
127
+ if (site !== null) {
128
+ if (!isPayPageUrl(site)) problems.push("--app-url must be an https:// URL (http:// for localhost only)");
129
+ else if (Object.prototype.hasOwnProperty.call(apps, app)) {
130
+ const own = apps[app];
131
+ apps[app] = {
132
+ ...own,
133
+ returnUrl: moved(own.returnUrl, site),
134
+ termsUrl: moved(own.termsUrl, site),
135
+ privacyUrl: moved(own.privacyUrl, site)
136
+ };
137
+ }
138
+ }
73
139
  const config = {
74
140
  token: given(options.token),
75
141
  environment: given(options.environment),
76
- returnUrl: (options.returnUrl ?? "").trim(),
77
- appName: (options.appName ?? "").trim(),
78
- termsUrl: (options.termsUrl ?? "").trim(),
79
- privacyUrl: (options.privacyUrl ?? "").trim()
142
+ app,
143
+ apps
80
144
  };
81
- return { config, problems: payPageConfigProblems(config) };
145
+ return { config, problems: [...problems, ...payPageConfigProblems(config)] };
146
+ }
147
+ function readAppsFile(path) {
148
+ let parsed;
149
+ try {
150
+ parsed = JSON.parse(readFileSync(path, "utf8"));
151
+ } catch (err) {
152
+ throw new PayPageError([`--apps ${path} can't be read as JSON: ${err.message}`]);
153
+ }
154
+ if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
155
+ throw new PayPageError([`--apps ${path} must hold a JSON object of apps by tag`]);
156
+ }
157
+ return parsed;
82
158
  }
83
159
  function writePayPage(options, bundleDir) {
84
160
  const { config, problems } = payPageConfig(options);
@@ -99,10 +175,15 @@ function writePayPage(options, bundleDir) {
99
175
  return config;
100
176
  }
101
177
  var USAGE = `Usage: eifi1-pay-page --out <dir> [--token <test_\u2026|live_\u2026> --environment <sandbox|live>]
102
- --return-url <https://\u2026> --app-name <name> --terms-url <https://\u2026> --privacy-url <https://\u2026>
178
+ --app <tag> [--app-url <https://\u2026>] [--apps <file>]
103
179
 
104
- Copies @eifi1/ui-kit's pay page into <dir> and writes its ${PAY_CONFIG_FILE}.
180
+ Copies @eifi1/ui-kit's pay page into <dir> and writes its ${PAY_CONFIG_FILE}: the
181
+ token, the host's app (--app: ${Object.keys(PAY_PAGE_APPS).join(", ")}) and the kit's
182
+ map of apps, which the page reads each transaction's app from. --app-url moves the
183
+ host's app to another site; --apps merges a JSON map of apps by tag over the kit's.
105
184
  Without a token (billing off) the page says there is nothing to pay.`;
185
+ var OLD_FLAGS = ["return-url", "app-name", "terms-url", "privacy-url"];
186
+ var OLD_FLAGS_REFUSED = "eifi1-pay-page: --return-url, --app-name, --terms-url and --privacy-url are gone (ui-kit 0.39): every pay page serves every app, from the kit's map. Pass --app <tag> instead, with --app-url <https://\u2026> for another site (your PAY_APP_URL) and --apps <file> to merge your own map.";
106
187
  function runPayPageCli(argv, io) {
107
188
  let values;
108
189
  try {
@@ -114,10 +195,11 @@ function runPayPageCli(argv, io) {
114
195
  out: { type: "string" },
115
196
  token: { type: "string" },
116
197
  environment: { type: "string" },
117
- "return-url": { type: "string" },
118
- "app-name": { type: "string" },
119
- "terms-url": { type: "string" },
120
- "privacy-url": { type: "string" },
198
+ app: { type: "string" },
199
+ "app-url": { type: "string" },
200
+ apps: { type: "string" },
201
+ // Parsed only to be refused with a line that names the new flags.
202
+ ...Object.fromEntries(OLD_FLAGS.map((flag) => [flag, { type: "string" }])),
121
203
  help: { type: "boolean", short: "h" }
122
204
  }
123
205
  }));
@@ -131,22 +213,28 @@ ${USAGE}`);
131
213
  io.log(USAGE);
132
214
  return 0;
133
215
  }
216
+ if (OLD_FLAGS.some((flag) => values[flag] !== void 0)) {
217
+ io.error(`${OLD_FLAGS_REFUSED}
218
+
219
+ ${USAGE}`);
220
+ return 2;
221
+ }
134
222
  const text = (key) => typeof values[key] === "string" ? values[key] : "";
135
223
  try {
224
+ const appsFile = given(text("apps"));
136
225
  const config = writePayPage(
137
226
  {
138
227
  out: text("out"),
139
228
  token: text("token"),
140
229
  environment: text("environment"),
141
- returnUrl: text("return-url"),
142
- appName: text("app-name"),
143
- termsUrl: text("terms-url"),
144
- privacyUrl: text("privacy-url")
230
+ app: text("app"),
231
+ appUrl: text("app-url"),
232
+ apps: appsFile === null ? void 0 : readAppsFile(appsFile)
145
233
  },
146
234
  io.bundleDir
147
235
  );
148
236
  io.log(
149
- `eifi1-pay-page: wrote the pay page to ${text("out").trim()} ` + (config.token ? `(${config.environment})` : "(no token: billing off, the page says there is nothing to pay)")
237
+ `eifi1-pay-page: wrote ${config.app}'s pay page (serving ${Object.keys(config.apps).join(", ")}) to ${text("out").trim()} ` + (config.token ? `(${config.environment})` : "(no token: billing off, the page says there is nothing to pay)")
150
238
  );
151
239
  return 0;
152
240
  } catch (err) {
@@ -47,7 +47,7 @@ const roleUtilities = {
47
47
  };
48
48
  }
49
49
  };
50
- const VERSION = true ? "0.38.0" : "0.0.0-source";
50
+ const VERSION = true ? "0.39.0" : "0.0.0-source";
51
51
  const recommended = {
52
52
  name: "@eifi1/ui-kit/recommended",
53
53
  // Not the tests, as check:tokens skips the kit's: a test names the old class to assert it
@@ -51,17 +51,24 @@ export interface FeedbackCommentsLabels {
51
51
  }
52
52
  export { DEFAULT_FEEDBACK_COMMENTS_LABELS };
53
53
  export interface FeedbackCommentThreadProps {
54
- /** The report's replies (§9.7), oldest first. `[]` when it has none. */
55
- replies: readonly FeedbackReply[];
54
+ /** The report's replies (§9.7), oldest first. Left out or `[]`: none.
55
+ *
56
+ * Inside `FeedbackRowDetail`'s `comments` they are dropped (0.38.1): the detail's
57
+ * Replies section draws them already, and the thread there is the comments alone —
58
+ * so passing them there cannot draw them twice. */
59
+ replies?: readonly FeedbackReply[];
56
60
  /** `GET /feedback/{id}/comments`, oldest first. */
57
61
  comments: readonly FeedbackComment[];
58
62
  /** The viewer is the app's admin: Hide / Unhide, the hidden text struck through. */
59
63
  isAdmin: boolean;
60
64
  /** `POST /feedback/{id}/comments`. Return the promise: the box clears when it
61
- * resolves. Left out, no composer. */
65
+ * resolves, and keeps the draft when it rejects. A failure is the app's to toast —
66
+ * the server's `detail`, else `feedbackToast.commentFailed` (0.38.1). Left out, no
67
+ * composer. */
62
68
  onComment?: (body: string) => void | Promise<unknown>;
63
- /** `PATCH /feedback/{id}/comments/{comment_id} {hidden}` — the admin's. Left out, no
64
- * Hide / Unhide. */
69
+ /** `PATCH /feedback/{id}/comments/{comment_id} {hidden}` — the admin's. A rejection
70
+ * is caught (0.38.1) and is the app's to toast (`feedbackToast.updateFailed`). Left
71
+ * out, no Hide / Unhide. */
65
72
  onHide?: (comment: FeedbackComment, hidden: boolean) => void | Promise<unknown>;
66
73
  /** `DELETE /feedback/{id}/comments/{comment_id}` — the writer's own, after the
67
74
  * confirm. Left out, no Delete. */
@@ -77,4 +84,4 @@ export interface FeedbackCommentThreadProps {
77
84
  labels?: LabelOverride<FeedbackCommentsLabels>;
78
85
  className?: string;
79
86
  }
80
- export declare function FeedbackCommentThread({ replies, comments, isAdmin, onComment, onHide, onDelete, pending, loading, commit, now, labels: labelsProp, className, }: FeedbackCommentThreadProps): import("react").JSX.Element;
87
+ export declare function FeedbackCommentThread({ replies: repliesProp, comments, isAdmin, onComment, onHide, onDelete, pending, loading, commit, now, labels: labelsProp, className, }: FeedbackCommentThreadProps): import("react").JSX.Element;
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
+ import { useContext } from "react";
3
4
  import { EyeOff } from "lucide-react";
4
5
  import { Button } from "../components/button.js";
5
6
  import { useConfirm } from "../components/confirm-dialog.js";
@@ -8,14 +9,18 @@ import { FeedbackStatusBadge } from "./feedback-inbox.js";
8
9
  import { DEFAULT_FEEDBACK_PUBLIC_LABELS } from "./feedback-public-labels.js";
9
10
  import { FEEDBACK_COMMENT_MAX } from "./feedback-record.js";
10
11
  import { useFeedbackRepliesLabels } from "./feedback-replies.js";
12
+ import { FeedbackRepliesDrawnAboveContext } from "./feedback-replies-context.js";
11
13
  import { ChatComposer, FeedbackThread } from "./feedback-thread.js";
12
14
  import { DEFAULT_FEEDBACK_COMMENTS_LABELS } from "./feedback-thread-parts-labels.js";
15
+ const hideComment = async (onHide, comment) => {
16
+ await onHide(comment, !comment.hidden);
17
+ };
13
18
  const instant = (iso) => {
14
19
  const ms = Date.parse(iso);
15
20
  return Number.isNaN(ms) ? 0 : ms;
16
21
  };
17
22
  function FeedbackCommentThread({
18
- replies,
23
+ replies: repliesProp = [],
19
24
  comments,
20
25
  isAdmin,
21
26
  onComment,
@@ -31,6 +36,8 @@ function FeedbackCommentThread({
31
36
  const labels = useKitLabels("feedbackComments", DEFAULT_FEEDBACK_COMMENTS_LABELS, labelsProp);
32
37
  const anonymous = useKitLabels("feedbackPublic", DEFAULT_FEEDBACK_PUBLIC_LABELS).anonymous;
33
38
  const replyLabels = useFeedbackRepliesLabels();
39
+ const repliesDrawnAbove = useContext(FeedbackRepliesDrawnAboveContext);
40
+ const replies = repliesDrawnAbove ? [] : repliesProp;
34
41
  const entries = [];
35
42
  replies.forEach((reply, order) => {
36
43
  entries.push({
@@ -71,7 +78,8 @@ function FeedbackCommentThread({
71
78
  tone: "muted",
72
79
  size: "sm",
73
80
  commit,
74
- onClick: () => void onHide(comment, !comment.hidden),
81
+ onClick: () => void hideComment(onHide, comment).catch(() => {
82
+ }),
75
83
  children: comment.hidden ? labels.unhide : labels.hide
76
84
  },
77
85
  "hide"
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/feedback/feedback-comment-thread.tsx"],"sourcesContent":["import type { ReactNode } from \"react\";\nimport { EyeOff } from \"lucide-react\";\nimport { Button } from \"../components/button\";\nimport { useConfirm } from \"../components/confirm-dialog\";\nimport type { CommitScope } from \"../components/write-lock\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { FeedbackStatusBadge } from \"./feedback-inbox\";\nimport type { FeedbackComment, FeedbackReply } from \"./feedback-public-types\";\nimport { DEFAULT_FEEDBACK_PUBLIC_LABELS } from \"./feedback-public-labels\";\nimport { FEEDBACK_COMMENT_MAX } from \"./feedback-record\";\nimport { useFeedbackRepliesLabels } from \"./feedback-replies\";\nimport { ChatComposer, FeedbackThread } from \"./feedback-thread\";\nimport type { FeedbackThreadMessage } from \"./feedback-thread\";\nimport { DEFAULT_FEEDBACK_COMMENTS_LABELS } from \"./feedback-thread-parts-labels\";\n\n/**\n * A report's conversation as everyone who may read it sees it\n * (docs/feedback-harmonization.md §9.8): the admin's replies and other people's\n * comments, each its own row, oldest first — merged by time, on the\n * {@link FeedbackThread} look — and the box to add one.\n *\n * - **Replies** are drawn as staff posts with the status they set (\"→ Done\"); a reply\n * without an author is \"Admin\" (§9.7).\n * - **Comments**: the viewer's own at the reading end (\"You\"); someone else's under the\n * first name the server sent, `null` as \"A user\" (§9.5, `feedbackPublic.anonymous`).\n * - **Hidden** (§9.8): others see \"Hidden by an admin\" and no name, no text; the writer\n * sees their text with that line; the admin sees it struck through, with **Unhide**.\n * An admin has **Hide** on every visible comment; the writer **Delete** on their own,\n * after a confirm (it is a hard delete). Nobody edits a comment.\n * - **The composer** (1–4 000 characters, no files) only with `onComment`: left out for\n * a reader who may not write (a demo, a CRASH report — the app knows).\n *\n * Delete asks through `useConfirm`, so a thread with `onDelete` and a comment of the\n * viewer's needs the app's `ConfirmProvider` (each app mounts one already).\n */\n\n/* ── Labels ───────────────────────────────────────────────────────────────── */\n\n/** The `feedbackComments` namespace of `<UiKitProvider labels>`. A `null` name is\n * `feedbackPublic.anonymous`, the public pages' word, so the two say the same. */\nexport interface FeedbackCommentsLabels {\n /** The thread's accessible name. de-CH: \"Kommentare\" */\n comments: string;\n /** Nothing yet. de-CH: \"Noch keine Kommentare\" */\n empty: string;\n /** In place of a hidden comment. de-CH: \"Von einem Admin ausgeblendet\" */\n hidden: string;\n /** The admin's button. de-CH: \"Ausblenden\" */\n hide: string;\n /** The admin's button on a hidden comment. de-CH: \"Einblenden\" */\n unhide: string;\n /** The writer's button. de-CH: \"Löschen\" */\n delete: string;\n /** The confirm's question. de-CH: \"Diesen Kommentar löschen?\" */\n deleteTitle: string;\n /** The confirm's line. de-CH: \"Er wird für alle entfernt. Das kann nicht rückgängig\n * gemacht werden.\" */\n deleteBody: string;\n /** The box's accessible name. de-CH: \"Kommentar schreiben\" */\n field: string;\n /** de-CH: \"Kommentar schreiben…\" */\n placeholder: string;\n /** The send button. de-CH: \"Kommentieren\" */\n send: string;\n}\n\nexport { DEFAULT_FEEDBACK_COMMENTS_LABELS };\n\n/* ── The thread ───────────────────────────────────────────────────────────── */\n\nexport interface FeedbackCommentThreadProps {\n /** The report's replies (§9.7), oldest first. `[]` when it has none. */\n replies: readonly FeedbackReply[];\n /** `GET /feedback/{id}/comments`, oldest first. */\n comments: readonly FeedbackComment[];\n /** The viewer is the app's admin: Hide / Unhide, the hidden text struck through. */\n isAdmin: boolean;\n /** `POST /feedback/{id}/comments`. Return the promise: the box clears when it\n * resolves. Left out, no composer. */\n onComment?: (body: string) => void | Promise<unknown>;\n /** `PATCH /feedback/{id}/comments/{comment_id} {hidden}` — the admin's. Left out, no\n * Hide / Unhide. */\n onHide?: (comment: FeedbackComment, hidden: boolean) => void | Promise<unknown>;\n /** `DELETE /feedback/{id}/comments/{comment_id}` — the writer's own, after the\n * confirm. Left out, no Delete. */\n onDelete?: (comment: FeedbackComment) => void | Promise<unknown>;\n /** A comment is being sent. */\n pending?: boolean;\n /** The comments are loading. */\n loading?: boolean;\n /** Comment, Hide and Delete COMMIT — see Button's `commit`. */\n commit?: CommitScope;\n /** \"Now\" for the relative times — pin it in tests and stories. */\n now?: Date | number;\n labels?: LabelOverride<FeedbackCommentsLabels>;\n className?: string;\n}\n\ntype Entry = { at: number; order: number; message: FeedbackThreadMessage };\n\nconst instant = (iso: string) => {\n const ms = Date.parse(iso);\n return Number.isNaN(ms) ? 0 : ms;\n};\n\nexport function FeedbackCommentThread({\n replies,\n comments,\n isAdmin,\n onComment,\n onHide,\n onDelete,\n pending = false,\n loading = false,\n commit,\n now,\n labels: labelsProp,\n className,\n}: FeedbackCommentThreadProps) {\n const labels = useKitLabels(\"feedbackComments\", DEFAULT_FEEDBACK_COMMENTS_LABELS, labelsProp);\n const anonymous = useKitLabels(\"feedbackPublic\", DEFAULT_FEEDBACK_PUBLIC_LABELS).anonymous;\n const replyLabels = useFeedbackRepliesLabels();\n\n const entries: Entry[] = [];\n replies.forEach((reply, order) => {\n entries.push({\n at: instant(reply.created_at),\n order,\n message: {\n id: `reply-${reply.id}`,\n author: reply.author_name ?? replyLabels.admin,\n createdAt: reply.created_at,\n body: reply.body,\n staff: true,\n badge: reply.status_to ? (\n <span className=\"inline-flex min-w-0 max-w-full flex-wrap items-center gap-1\" data-feedback-reply-status={reply.status_to}>\n <span className=\"sr-only\">{replyLabels.statusChanged}</span>\n <span aria-hidden>→</span>\n <FeedbackStatusBadge status={reply.status_to} />\n </span>\n ) : undefined,\n },\n });\n });\n comments.forEach((comment, index) => {\n // Shown as hidden — no name, no text — to anyone but its writer and an admin.\n const veiled = comment.hidden && !comment.mine && !isAdmin;\n const actions: ReactNode[] = [];\n if (comment.hidden) {\n actions.push(\n <span key=\"hidden\" className=\"inline-flex items-center gap-1\" data-feedback-comment-hidden=\"\">\n <EyeOff className=\"size-3\" aria-hidden />\n {labels.hidden}\n </span>,\n );\n }\n if (isAdmin && onHide) {\n actions.push(\n <Button\n key=\"hide\"\n type=\"button\"\n variant=\"link\"\n tone=\"muted\"\n size=\"sm\"\n commit={commit}\n onClick={() => void onHide(comment, !comment.hidden)}\n >\n {comment.hidden ? labels.unhide : labels.hide}\n </Button>,\n );\n }\n if (comment.mine && onDelete) {\n actions.push(\n <DeleteCommentButton key=\"delete\" comment={comment} onDelete={onDelete} commit={commit} labels={labels} />,\n );\n }\n entries.push({\n at: instant(comment.created_at),\n // Replies first on a tie, then the comments in their order.\n order: replies.length + index,\n message: {\n id: `comment-${comment.id}`,\n own: comment.mine,\n author: veiled ? undefined : comment.mine ? undefined : (comment.author_name ?? anonymous),\n createdAt: comment.created_at,\n body: veiled ? \"\" : (comment.body ?? \"\"),\n staff: !veiled && comment.staff,\n struck: comment.hidden && isAdmin && !veiled,\n footer: actions.length > 0 ? actions : undefined,\n },\n });\n });\n entries.sort((a, b) => a.at - b.at || a.order - b.order);\n\n return (\n <div className={className} data-feedback-comment-thread=\"\">\n <FeedbackThread\n messages={entries.map((entry) => entry.message)}\n loading={loading}\n now={now}\n labels={{ thread: labels.comments, empty: labels.empty }}\n />\n {onComment && (\n <ChatComposer\n className=\"mt-3\"\n onSend={(body) => onComment(body)}\n pending={pending}\n commit={commit}\n maxLength={FEEDBACK_COMMENT_MAX}\n showCount\n labels={{ field: labels.field, placeholder: labels.placeholder, send: labels.send }}\n />\n )}\n </div>\n );\n}\n\n/** The writer's Delete: a confirm (danger tone, focus on Cancel), then `onDelete`. Its\n * own component, so `useConfirm` — which needs a `ConfirmProvider` — is only called\n * where there is something to delete. */\nfunction DeleteCommentButton({\n comment,\n onDelete,\n commit,\n labels,\n}: {\n comment: FeedbackComment;\n onDelete: (comment: FeedbackComment) => void | Promise<unknown>;\n commit?: CommitScope;\n labels: FeedbackCommentsLabels;\n}) {\n const confirm = useConfirm();\n const remove = async () => {\n const ok = await confirm({\n title: labels.deleteTitle,\n body: labels.deleteBody,\n confirmLabel: labels.delete,\n tone: \"danger\",\n commit,\n });\n if (ok) await onDelete(comment);\n };\n return (\n <Button\n type=\"button\"\n variant=\"link\"\n tone=\"danger\"\n size=\"sm\"\n commit={commit}\n onClick={() => void remove().catch(() => {})}\n >\n {labels.delete}\n </Button>\n );\n}\n"],"mappings":";AAuIU,SACE,KADF;AAtIV,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAE3B,SAAS,oBAAwC;AACjD,SAAS,2BAA2B;AAEpC,SAAS,sCAAsC;AAC/C,SAAS,4BAA4B;AACrC,SAAS,gCAAgC;AACzC,SAAS,cAAc,sBAAsB;AAE7C,SAAS,wCAAwC;AAuFjD,MAAM,UAAU,CAAC,QAAgB;AAC/B,QAAM,KAAK,KAAK,MAAM,GAAG;AACzB,SAAO,OAAO,MAAM,EAAE,IAAI,IAAI;AAChC;AAEO,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV,UAAU;AAAA,EACV;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AACF,GAA+B;AAC7B,QAAM,SAAS,aAAa,oBAAoB,kCAAkC,UAAU;AAC5F,QAAM,YAAY,aAAa,kBAAkB,8BAA8B,EAAE;AACjF,QAAM,cAAc,yBAAyB;AAE7C,QAAM,UAAmB,CAAC;AAC1B,UAAQ,QAAQ,CAAC,OAAO,UAAU;AAChC,YAAQ,KAAK;AAAA,MACX,IAAI,QAAQ,MAAM,UAAU;AAAA,MAC5B;AAAA,MACA,SAAS;AAAA,QACP,IAAI,S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,IACF,CAAC;AACD,QAAI,GAAI,OAAM,SAAS,OAAO;AAAA,EAChC;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,MAAK;AAAA,MACL;AAAA,MACA,SAAS,MAAM,KAAK,OAAO,EAAE,MAAM,MAAM;AAAA,MAAC,CAAC;AAAA,MAE1C,iBAAO;AAAA;AAAA,EACV;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/feedback/feedback-comment-thread.tsx"],"sourcesContent":["import { useContext } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { EyeOff } from \"lucide-react\";\nimport { Button } from \"../components/button\";\nimport { useConfirm } from \"../components/confirm-dialog\";\nimport type { CommitScope } from \"../components/write-lock\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { FeedbackStatusBadge } from \"./feedback-inbox\";\nimport type { FeedbackComment, FeedbackReply } from \"./feedback-public-types\";\nimport { DEFAULT_FEEDBACK_PUBLIC_LABELS } from \"./feedback-public-labels\";\nimport { FEEDBACK_COMMENT_MAX } from \"./feedback-record\";\nimport { useFeedbackRepliesLabels } from \"./feedback-replies\";\nimport { FeedbackRepliesDrawnAboveContext } from \"./feedback-replies-context\";\nimport { ChatComposer, FeedbackThread } from \"./feedback-thread\";\nimport type { FeedbackThreadMessage } from \"./feedback-thread\";\nimport { DEFAULT_FEEDBACK_COMMENTS_LABELS } from \"./feedback-thread-parts-labels\";\n\n/**\n * A report's conversation as everyone who may read it sees it\n * (docs/feedback-harmonization.md §9.8): the admin's replies and other people's\n * comments, each its own row, oldest first — merged by time, on the\n * {@link FeedbackThread} look — and the box to add one.\n *\n * - **Replies** are drawn as staff posts with the status they set (\"→ Done\"); a reply\n * without an author is \"Admin\" (§9.7).\n * - **Comments**: the viewer's own at the reading end (\"You\"); someone else's under the\n * first name the server sent, `null` as \"A user\" (§9.5, `feedbackPublic.anonymous`).\n * - **Hidden** (§9.8): others see \"Hidden by an admin\" and no name, no text; the writer\n * sees their text with that line; the admin sees it struck through, with **Unhide**.\n * An admin has **Hide** on every visible comment; the writer **Delete** on their own,\n * after a confirm (it is a hard delete). Nobody edits a comment.\n * - **The composer** (1–4 000 characters, no files) only with `onComment`: left out for\n * a reader who may not write (a demo, a CRASH report — the app knows).\n *\n * Delete asks through `useConfirm`, so a thread with `onDelete` and a comment of the\n * viewer's needs the app's `ConfirmProvider` (each app mounts one already).\n */\n\n/* ── Labels ───────────────────────────────────────────────────────────────── */\n\n/** The `feedbackComments` namespace of `<UiKitProvider labels>`. A `null` name is\n * `feedbackPublic.anonymous`, the public pages' word, so the two say the same. */\nexport interface FeedbackCommentsLabels {\n /** The thread's accessible name. de-CH: \"Kommentare\" */\n comments: string;\n /** Nothing yet. de-CH: \"Noch keine Kommentare\" */\n empty: string;\n /** In place of a hidden comment. de-CH: \"Von einem Admin ausgeblendet\" */\n hidden: string;\n /** The admin's button. de-CH: \"Ausblenden\" */\n hide: string;\n /** The admin's button on a hidden comment. de-CH: \"Einblenden\" */\n unhide: string;\n /** The writer's button. de-CH: \"Löschen\" */\n delete: string;\n /** The confirm's question. de-CH: \"Diesen Kommentar löschen?\" */\n deleteTitle: string;\n /** The confirm's line. de-CH: \"Er wird für alle entfernt. Das kann nicht rückgängig\n * gemacht werden.\" */\n deleteBody: string;\n /** The box's accessible name. de-CH: \"Kommentar schreiben\" */\n field: string;\n /** de-CH: \"Kommentar schreiben…\" */\n placeholder: string;\n /** The send button. de-CH: \"Kommentieren\" */\n send: string;\n}\n\nexport { DEFAULT_FEEDBACK_COMMENTS_LABELS };\n\n/* ── The thread ───────────────────────────────────────────────────────────── */\n\nexport interface FeedbackCommentThreadProps {\n /** The report's replies (§9.7), oldest first. Left out or `[]`: none.\n *\n * Inside `FeedbackRowDetail`'s `comments` they are dropped (0.38.1): the detail's\n * Replies section draws them already, and the thread there is the comments alone —\n * so passing them there cannot draw them twice. */\n replies?: readonly FeedbackReply[];\n /** `GET /feedback/{id}/comments`, oldest first. */\n comments: readonly FeedbackComment[];\n /** The viewer is the app's admin: Hide / Unhide, the hidden text struck through. */\n isAdmin: boolean;\n /** `POST /feedback/{id}/comments`. Return the promise: the box clears when it\n * resolves, and keeps the draft when it rejects. A failure is the app's to toast —\n * the server's `detail`, else `feedbackToast.commentFailed` (0.38.1). Left out, no\n * composer. */\n onComment?: (body: string) => void | Promise<unknown>;\n /** `PATCH /feedback/{id}/comments/{comment_id} {hidden}` — the admin's. A rejection\n * is caught (0.38.1) and is the app's to toast (`feedbackToast.updateFailed`). Left\n * out, no Hide / Unhide. */\n onHide?: (comment: FeedbackComment, hidden: boolean) => void | Promise<unknown>;\n /** `DELETE /feedback/{id}/comments/{comment_id}` — the writer's own, after the\n * confirm. Left out, no Delete. */\n onDelete?: (comment: FeedbackComment) => void | Promise<unknown>;\n /** A comment is being sent. */\n pending?: boolean;\n /** The comments are loading. */\n loading?: boolean;\n /** Comment, Hide and Delete COMMIT — see Button's `commit`. */\n commit?: CommitScope;\n /** \"Now\" for the relative times — pin it in tests and stories. */\n now?: Date | number;\n labels?: LabelOverride<FeedbackCommentsLabels>;\n className?: string;\n}\n\ntype Entry = { at: number; order: number; message: FeedbackThreadMessage };\n\n/** The admin's Hide / Unhide as a promise — a sync throw or a `void` return included —\n * so the click can catch it as Delete's does. */\nconst hideComment = async (\n onHide: NonNullable<FeedbackCommentThreadProps[\"onHide\"]>,\n comment: FeedbackComment,\n) => {\n await onHide(comment, !comment.hidden);\n};\n\nconst instant = (iso: string) => {\n const ms = Date.parse(iso);\n return Number.isNaN(ms) ? 0 : ms;\n};\n\nexport function FeedbackCommentThread({\n replies: repliesProp = [],\n comments,\n isAdmin,\n onComment,\n onHide,\n onDelete,\n pending = false,\n loading = false,\n commit,\n now,\n labels: labelsProp,\n className,\n}: FeedbackCommentThreadProps) {\n const labels = useKitLabels(\"feedbackComments\", DEFAULT_FEEDBACK_COMMENTS_LABELS, labelsProp);\n const anonymous = useKitLabels(\"feedbackPublic\", DEFAULT_FEEDBACK_PUBLIC_LABELS).anonymous;\n const replyLabels = useFeedbackRepliesLabels();\n const repliesDrawnAbove = useContext(FeedbackRepliesDrawnAboveContext);\n const replies = repliesDrawnAbove ? [] : repliesProp;\n\n const entries: Entry[] = [];\n replies.forEach((reply, order) => {\n entries.push({\n at: instant(reply.created_at),\n order,\n message: {\n id: `reply-${reply.id}`,\n author: reply.author_name ?? replyLabels.admin,\n createdAt: reply.created_at,\n body: reply.body,\n staff: true,\n badge: reply.status_to ? (\n <span className=\"inline-flex min-w-0 max-w-full flex-wrap items-center gap-1\" data-feedback-reply-status={reply.status_to}>\n <span className=\"sr-only\">{replyLabels.statusChanged}</span>\n <span aria-hidden>→</span>\n <FeedbackStatusBadge status={reply.status_to} />\n </span>\n ) : undefined,\n },\n });\n });\n comments.forEach((comment, index) => {\n // Shown as hidden — no name, no text — to anyone but its writer and an admin.\n const veiled = comment.hidden && !comment.mine && !isAdmin;\n const actions: ReactNode[] = [];\n if (comment.hidden) {\n actions.push(\n <span key=\"hidden\" className=\"inline-flex items-center gap-1\" data-feedback-comment-hidden=\"\">\n <EyeOff className=\"size-3\" aria-hidden />\n {labels.hidden}\n </span>,\n );\n }\n if (isAdmin && onHide) {\n actions.push(\n <Button\n key=\"hide\"\n type=\"button\"\n variant=\"link\"\n tone=\"muted\"\n size=\"sm\"\n commit={commit}\n // Caught as Delete's is (0.38.1): a rejection is the app's to toast — its\n // mutation's `onError` — and must not surface as an unhandled one.\n onClick={() => void hideComment(onHide, comment).catch(() => {})}\n >\n {comment.hidden ? labels.unhide : labels.hide}\n </Button>,\n );\n }\n if (comment.mine && onDelete) {\n actions.push(\n <DeleteCommentButton key=\"delete\" comment={comment} onDelete={onDelete} commit={commit} labels={labels} />,\n );\n }\n entries.push({\n at: instant(comment.created_at),\n // Replies first on a tie, then the comments in their order.\n order: replies.length + index,\n message: {\n id: `comment-${comment.id}`,\n own: comment.mine,\n author: veiled ? undefined : comment.mine ? undefined : (comment.author_name ?? anonymous),\n createdAt: comment.created_at,\n body: veiled ? \"\" : (comment.body ?? \"\"),\n staff: !veiled && comment.staff,\n struck: comment.hidden && isAdmin && !veiled,\n footer: actions.length > 0 ? actions : undefined,\n },\n });\n });\n entries.sort((a, b) => a.at - b.at || a.order - b.order);\n\n return (\n <div className={className} data-feedback-comment-thread=\"\">\n <FeedbackThread\n messages={entries.map((entry) => entry.message)}\n loading={loading}\n now={now}\n labels={{ thread: labels.comments, empty: labels.empty }}\n />\n {onComment && (\n <ChatComposer\n className=\"mt-3\"\n onSend={(body) => onComment(body)}\n pending={pending}\n commit={commit}\n maxLength={FEEDBACK_COMMENT_MAX}\n showCount\n labels={{ field: labels.field, placeholder: labels.placeholder, send: labels.send }}\n />\n )}\n </div>\n );\n}\n\n/** The writer's Delete: a confirm (danger tone, focus on Cancel), then `onDelete`. Its\n * own component, so `useConfirm` — which needs a `ConfirmProvider` — is only called\n * where there is something to delete. */\nfunction DeleteCommentButton({\n comment,\n onDelete,\n commit,\n labels,\n}: {\n comment: FeedbackComment;\n onDelete: (comment: FeedbackComment) => void | Promise<unknown>;\n commit?: CommitScope;\n labels: FeedbackCommentsLabels;\n}) {\n const confirm = useConfirm();\n const remove = async () => {\n const ok = await confirm({\n title: labels.deleteTitle,\n body: labels.deleteBody,\n confirmLabel: labels.delete,\n tone: \"danger\",\n commit,\n });\n if (ok) await onDelete(comment);\n };\n return (\n <Button\n type=\"button\"\n variant=\"link\"\n tone=\"danger\"\n size=\"sm\"\n commit={commit}\n onClick={() => void remove().catch(() => {})}\n >\n {labels.delete}\n </Button>\n );\n}\n"],"mappings":";AA2JU,SACE,KADF;AA3JV,SAAS,kBAAkB;AAE3B,SAAS,cAAc;AACvB,SAAS,cAAc;AACvB,SAAS,kBAAkB;AAE3B,SAAS,oBAAwC;AACjD,SAAS,2BAA2B;AAEpC,SAAS,sCAAsC;AAC/C,SAAS,4BAA4B;AACrC,SAAS,gCAAgC;AACzC,SAAS,wCAAwC;AACjD,SAA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D,UAAQ,KAAK,CAAC,GAAG,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK;AAEvD,SACE,qBAAC,SAAI,WAAsB,gCAA6B,IACtD;AAAA;AAAA,MAAC;AAAA;AAAA,QACC,UAAU,QAAQ,IAAI,CAAC,UAAU,MAAM,OAAO;AAAA,QAC9C;AAAA,QACA;AAAA,QACA,QAAQ,EAAE,QAAQ,OAAO,UAAU,OAAO,OAAO,MAAM;AAAA;AAAA,IACzD;AAAA,IACC,aACC;AAAA,MAAC;AAAA;AAAA,QACC,WAAU;AAAA,QACV,QAAQ,CAAC,SAAS,UAAU,IAAI;AAAA,QAChC;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,WAAS;AAAA,QACT,QAAQ,EAAE,OAAO,OAAO,OAAO,aAAa,OAAO,aAAa,MAAM,OAAO,KAAK;AAAA;AAAA,IACpF;AAAA,KAEJ;AAEJ;AAKA,SAAS,oBAAoB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAKG;AACD,QAAM,UAAU,WAAW;AAC3B,QAAM,SAAS,YAAY;AACzB,UAAM,KAAK,MAAM,QAAQ;AAAA,MACvB,OAAO,OAAO;AAAA,MACd,MAAM,OAAO;AAAA,MACb,cAAc,OAAO;AAAA,MACrB,MAAM;AAAA,MACN;AAAA,IACF,CAAC;AACD,QAAI,GAAI,OAAM,SAAS,OAAO;AAAA,EAChC;AACA,SACE;AAAA,IAAC;AAAA;AAAA,MACC,MAAK;AAAA,MACL,SAAQ;AAAA,MACR,MAAK;AAAA,MACL,MAAK;AAAA,MACL;AAAA,MACA,SAAS,MAAM,KAAK,OAAO,EAAE,MAAM,MAAM;AAAA,MAAC,CAAC;AAAA,MAE1C,iBAAO;AAAA;AAAA,EACV;AAEJ;","names":[]}
@@ -71,6 +71,17 @@ export interface FeedbackToastLabels {
71
71
  /** The Undo landed — `status` is the RESTORED status's label.
72
72
  * de-CH: "Zurück auf „{{status}}“: {{title}}" */
73
73
  statusRestored: (status: string, title: string) => string;
74
+ /** 0.38.1: `POST /feedback/{id}/comments` failed with no `detail` of its own — for
75
+ * `FeedbackCommentThread`'s `onComment`. de-CH: "Kommentar konnte nicht gesendet
76
+ * werden." */
77
+ commentFailed: string;
78
+ /** 0.38.1: `PUT` / `DELETE /feedback/{id}/vote` failed with no `detail` of its own —
79
+ * for `FeedbackVoteButton`'s `onVote` (the button rolls back; the app toasts).
80
+ * de-CH: "Stimme konnte nicht gespeichert werden." */
81
+ voteFailed: string;
82
+ /** 0.38.1: `POST /feedback/{id}/replies` failed with no `detail` of its own — for
83
+ * `FeedbackRowDetail`'s `onReply`. de-CH: "Antwort konnte nicht gesendet werden." */
84
+ replyFailed: string;
74
85
  }
75
86
  export declare const DEFAULT_FEEDBACK_TOAST_LABELS: FeedbackToastLabels;
76
87
  /** `feedbackStatus` resolved: English, then `<UiKitProvider labels>`, then `labels`. For
@@ -27,7 +27,10 @@ const DEFAULT_FEEDBACK_TOAST_LABELS = {
27
27
  updateFailed: "Could not save that change.",
28
28
  statusChanged: (status, title) => `Set to \u201C${status}\u201D: ${title}`,
29
29
  statusUndo: "Undo",
30
- statusRestored: (status, title) => `Back to \u201C${status}\u201D: ${title}`
30
+ statusRestored: (status, title) => `Back to \u201C${status}\u201D: ${title}`,
31
+ commentFailed: "Could not post the comment.",
32
+ voteFailed: "Could not save your vote.",
33
+ replyFailed: "Could not send the reply."
31
34
  };
32
35
  function useFeedbackStatusLabels(labels) {
33
36
  return useKitLabels("feedbackStatus", DEFAULT_FEEDBACK_STATUS_LABELS, labels);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/feedback/feedback-labels.ts"],"sourcesContent":["import { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport type { FeedbackCategory, FeedbackStatus } from \"./feedback-vocabulary\";\n\n/**\n * The words of a report's status and category, and the toasts a feedback page shows —\n * three `<UiKitProvider labels>` namespaces (0.27.0).\n *\n * Until 0.27 every app kept its own map from the enum to a translation key (keksdose\n * `STATUS_LABEL` and `categoryLabelKey`, \"the package has no translations\"), and the\n * three German maps had drifted apart: Kurvenschmiede said \"In Arbeit\", \"In Prüfung\",\n * \"Test auf der Live-Umgebung\" where keksdose and kastlan said \"In Bearbeitung\",\n * \"Zur Prüfung\", \"Live testen\". Marcel's feedback round (2026-10-04,\n * docs/feedback-harmonization.md §2.4) made keksdose's wording the canon and the kit its\n * owner, in all seven languages. The English defaults below are keksdose's\n * `frontend/src/shared/i18n/locales/en.json` (`feedback.*`); the de-CH canon for the\n * catalogues is noted on each key (keksdose `de-CH.json` — ss, never ß).\n *\n * `FeedbackStatusBadge`, `FeedbackCategoryBadge` and `FeedbackStatusTransitions` read\n * the first two by default, so an app drops its own maps; a `label` passed to them still\n * wins.\n */\n\n/**\n * `feedbackStatus` — one word per status, keyed by the enum value so\n * `labels[row.status]` is the whole lookup.\n *\n * de-CH canon: OPEN \"Offen\" · READY \"Bereit zur Umsetzung\" · IN_PROGRESS \"In Bearbeitung\" · IN_EVALUATION \"Zur Prüfung\"\n * · NEEDS_LIVE_TEST \"Live testen\" · POSTPONED \"Zurückgestellt\" · DONE \"Erledigt\" ·\n * WONT_DO \"Wird nicht umgesetzt\".\n */\nexport type FeedbackStatusLabels = Record<FeedbackStatus, string>;\n\nexport const DEFAULT_FEEDBACK_STATUS_LABELS: FeedbackStatusLabels = {\n OPEN: \"Open\",\n READY: \"Ready to implement\",\n IN_PROGRESS: \"In progress\",\n IN_EVALUATION: \"In evaluation\",\n NEEDS_LIVE_TEST: \"Test when live\",\n POSTPONED: \"Postponed\",\n DONE: \"Done\",\n WONT_DO: \"Won't do\",\n};\n\n/**\n * `feedbackCategory` — one word per category, keyed by the enum value. `CRASH` is never\n * pickable, but it is shown: on the badge, in the filter, in a row's detail.\n *\n * de-CH canon: CRASH \"Absturz\" · BUG \"Fehler\" · IDEA \"Idee\" · QUESTION \"Frage\" ·\n * OTHER \"Sonstiges\".\n */\nexport type FeedbackCategoryLabels = Record<FeedbackCategory, string>;\n\nexport const DEFAULT_FEEDBACK_CATEGORY_LABELS: FeedbackCategoryLabels = {\n CRASH: \"Crash\",\n BUG: \"Bug\",\n IDEA: \"Idea\",\n QUESTION: \"Question\",\n OTHER: \"Other\",\n};\n\n/**\n * `feedbackToast` — what the submit dialog, a failed save and a status change say in a\n * toast (§4.2, §4.4, §4.5 of the contract). A server's `detail` sentence, when it sent\n * one, wins over `submitFailed` and `updateFailed` (§3.7); that choice is the caller's.\n */\nexport interface FeedbackToastLabels {\n /** A report was filed. de-CH: \"Danke für Ihr Feedback!\" */\n submitted: string;\n /** `POST /feedback` failed with no `detail` of its own.\n * de-CH: \"Feedback konnte nicht gesendet werden\" */\n submitFailed: string;\n /** A picked file is not an image, a PDF or a text file (§3.5).\n * de-CH: \"Nur Bilder, PDF- oder Textdateien sind erlaubt\" */\n attachmentUnsupported: string;\n /** A picked file is over the 10 MB the contract allows (§3.5).\n * de-CH: \"Datei ist grösser als 10 MB\" */\n attachmentTooLarge: string;\n /** More files were picked than fit; `count` is how many fit.\n * de-CH: \"Es passen nur {{count}} Anhänge – die übrigen wurden weggelassen.\" */\n attachmentTooMany: (count: number) => string;\n /** The screenshot capture failed (or its optional peer is not installed).\n * de-CH: \"Screenshot konnte nicht aufgenommen werden\" */\n captureFailed: string;\n /** A `PATCH /feedback/{id}` failed with no `detail` of its own (§4.4).\n * de-CH: \"Änderung konnte nicht gespeichert werden.\" */\n updateFailed: string;\n /** A status change landed — the 8 s Undo toast (§4.5). `status` is the NEW status's\n * label, `title` the report's title. de-CH: \"Auf „{{status}}“ gesetzt: {{title}}\" */\n statusChanged: (status: string, title: string) => string;\n /** That toast's action. de-CH: \"Rückgängig\" */\n statusUndo: string;\n /** The Undo landed — `status` is the RESTORED status's label.\n * de-CH: \"Zurück auf „{{status}}“: {{title}}\" */\n statusRestored: (status: string, title: string) => string;\n}\n\nexport const DEFAULT_FEEDBACK_TOAST_LABELS: FeedbackToastLabels = {\n submitted: \"Thanks for the feedback!\",\n submitFailed: \"Could not submit feedback\",\n attachmentUnsupported: \"Only images, PDF or text files are allowed\",\n attachmentTooLarge: \"File is larger than 10 MB\",\n attachmentTooMany: (count) =>\n count === 1\n ? \"Only 1 attachment fits — the rest were left out.\"\n : `Only ${count} attachments fit — the rest were left out.`,\n captureFailed: \"Could not capture a screenshot\",\n updateFailed: \"Could not save that change.\",\n statusChanged: (status, title) => `Set to “${status}”: ${title}`,\n statusUndo: \"Undo\",\n statusRestored: (status, title) => `Back to “${status}”: ${title}`,\n};\n\n/** `feedbackStatus` resolved: English, then `<UiKitProvider labels>`, then `labels`. For\n * the places that need a status's name outside the kit's own parts — a filter's options,\n * `feedbackSwipePlan`'s panels, an app's overview tile. */\nexport function useFeedbackStatusLabels(labels?: LabelOverride<FeedbackStatusLabels>): FeedbackStatusLabels {\n return useKitLabels(\"feedbackStatus\", DEFAULT_FEEDBACK_STATUS_LABELS, labels);\n}\n\n/** `feedbackCategory` resolved: English, then the provider, then `labels`. */\nexport function useFeedbackCategoryLabels(labels?: LabelOverride<FeedbackCategoryLabels>): FeedbackCategoryLabels {\n return useKitLabels(\"feedbackCategory\", DEFAULT_FEEDBACK_CATEGORY_LABELS, labels);\n}\n\n/** `feedbackToast` resolved: English, then the provider, then `labels`. */\nexport function useFeedbackToastLabels(labels?: LabelOverride<FeedbackToastLabels>): FeedbackToastLabels {\n return useKitLabels(\"feedbackToast\", DEFAULT_FEEDBACK_TOAST_LABELS, labels);\n}\n"],"mappings":";AAAA,SAAS,oBAAwC;AAgC1C,MAAM,iCAAuD;AAAA,EAClE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,MAAM;AAAA,EACN,SAAS;AACX;AAWO,MAAM,mCAA2D;AAAA,EACtE,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,UAAU;AAAA,EACV,OAAO;AACT;AAsCO,MAAM,gCAAqD;AAAA,EAChE,WAAW;AAAA,EACX,cAAc;AAAA,EACd,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,mBAAmB,CAAC,UAClB,UAAU,IACN,0DACA,QAAQ,KAAK;AAAA,EACnB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe,CAAC,QAAQ,UAAU,gBAAW,MAAM,WAAM,KAAK;AAAA,EAC9D,YAAY;AAAA,EACZ,gBAAgB,CAAC,QAAQ,UAAU,iBAAY,MAAM,WAAM,KAAK;AAClE;AAKO,SAAS,wBAAwB,QAAoE;AAC1G,SAAO,aAAa,kBAAkB,gCAAgC,MAAM;AAC9E;AAGO,SAAS,0BAA0B,QAAwE;AAChH,SAAO,aAAa,oBAAoB,kCAAkC,MAAM;AAClF;AAGO,SAAS,uBAAuB,QAAkE;AACvG,SAAO,aAAa,iBAAiB,+BAA+B,MAAM;AAC5E;","names":[]}
1
+ {"version":3,"sources":["../../src/feedback/feedback-labels.ts"],"sourcesContent":["import { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport type { FeedbackCategory, FeedbackStatus } from \"./feedback-vocabulary\";\n\n/**\n * The words of a report's status and category, and the toasts a feedback page shows —\n * three `<UiKitProvider labels>` namespaces (0.27.0).\n *\n * Until 0.27 every app kept its own map from the enum to a translation key (keksdose\n * `STATUS_LABEL` and `categoryLabelKey`, \"the package has no translations\"), and the\n * three German maps had drifted apart: Kurvenschmiede said \"In Arbeit\", \"In Prüfung\",\n * \"Test auf der Live-Umgebung\" where keksdose and kastlan said \"In Bearbeitung\",\n * \"Zur Prüfung\", \"Live testen\". Marcel's feedback round (2026-10-04,\n * docs/feedback-harmonization.md §2.4) made keksdose's wording the canon and the kit its\n * owner, in all seven languages. The English defaults below are keksdose's\n * `frontend/src/shared/i18n/locales/en.json` (`feedback.*`); the de-CH canon for the\n * catalogues is noted on each key (keksdose `de-CH.json` — ss, never ß).\n *\n * `FeedbackStatusBadge`, `FeedbackCategoryBadge` and `FeedbackStatusTransitions` read\n * the first two by default, so an app drops its own maps; a `label` passed to them still\n * wins.\n */\n\n/**\n * `feedbackStatus` — one word per status, keyed by the enum value so\n * `labels[row.status]` is the whole lookup.\n *\n * de-CH canon: OPEN \"Offen\" · READY \"Bereit zur Umsetzung\" · IN_PROGRESS \"In Bearbeitung\" · IN_EVALUATION \"Zur Prüfung\"\n * · NEEDS_LIVE_TEST \"Live testen\" · POSTPONED \"Zurückgestellt\" · DONE \"Erledigt\" ·\n * WONT_DO \"Wird nicht umgesetzt\".\n */\nexport type FeedbackStatusLabels = Record<FeedbackStatus, string>;\n\nexport const DEFAULT_FEEDBACK_STATUS_LABELS: FeedbackStatusLabels = {\n OPEN: \"Open\",\n READY: \"Ready to implement\",\n IN_PROGRESS: \"In progress\",\n IN_EVALUATION: \"In evaluation\",\n NEEDS_LIVE_TEST: \"Test when live\",\n POSTPONED: \"Postponed\",\n DONE: \"Done\",\n WONT_DO: \"Won't do\",\n};\n\n/**\n * `feedbackCategory` — one word per category, keyed by the enum value. `CRASH` is never\n * pickable, but it is shown: on the badge, in the filter, in a row's detail.\n *\n * de-CH canon: CRASH \"Absturz\" · BUG \"Fehler\" · IDEA \"Idee\" · QUESTION \"Frage\" ·\n * OTHER \"Sonstiges\".\n */\nexport type FeedbackCategoryLabels = Record<FeedbackCategory, string>;\n\nexport const DEFAULT_FEEDBACK_CATEGORY_LABELS: FeedbackCategoryLabels = {\n CRASH: \"Crash\",\n BUG: \"Bug\",\n IDEA: \"Idea\",\n QUESTION: \"Question\",\n OTHER: \"Other\",\n};\n\n/**\n * `feedbackToast` — what the submit dialog, a failed save and a status change say in a\n * toast (§4.2, §4.4, §4.5 of the contract). A server's `detail` sentence, when it sent\n * one, wins over `submitFailed` and `updateFailed` (§3.7); that choice is the caller's.\n */\nexport interface FeedbackToastLabels {\n /** A report was filed. de-CH: \"Danke für Ihr Feedback!\" */\n submitted: string;\n /** `POST /feedback` failed with no `detail` of its own.\n * de-CH: \"Feedback konnte nicht gesendet werden\" */\n submitFailed: string;\n /** A picked file is not an image, a PDF or a text file (§3.5).\n * de-CH: \"Nur Bilder, PDF- oder Textdateien sind erlaubt\" */\n attachmentUnsupported: string;\n /** A picked file is over the 10 MB the contract allows (§3.5).\n * de-CH: \"Datei ist grösser als 10 MB\" */\n attachmentTooLarge: string;\n /** More files were picked than fit; `count` is how many fit.\n * de-CH: \"Es passen nur {{count}} Anhänge – die übrigen wurden weggelassen.\" */\n attachmentTooMany: (count: number) => string;\n /** The screenshot capture failed (or its optional peer is not installed).\n * de-CH: \"Screenshot konnte nicht aufgenommen werden\" */\n captureFailed: string;\n /** A `PATCH /feedback/{id}` failed with no `detail` of its own (§4.4).\n * de-CH: \"Änderung konnte nicht gespeichert werden.\" */\n updateFailed: string;\n /** A status change landed — the 8 s Undo toast (§4.5). `status` is the NEW status's\n * label, `title` the report's title. de-CH: \"Auf „{{status}}“ gesetzt: {{title}}\" */\n statusChanged: (status: string, title: string) => string;\n /** That toast's action. de-CH: \"Rückgängig\" */\n statusUndo: string;\n /** The Undo landed — `status` is the RESTORED status's label.\n * de-CH: \"Zurück auf „{{status}}“: {{title}}\" */\n statusRestored: (status: string, title: string) => string;\n /** 0.38.1: `POST /feedback/{id}/comments` failed with no `detail` of its own — for\n * `FeedbackCommentThread`'s `onComment`. de-CH: \"Kommentar konnte nicht gesendet\n * werden.\" */\n commentFailed: string;\n /** 0.38.1: `PUT` / `DELETE /feedback/{id}/vote` failed with no `detail` of its own —\n * for `FeedbackVoteButton`'s `onVote` (the button rolls back; the app toasts).\n * de-CH: \"Stimme konnte nicht gespeichert werden.\" */\n voteFailed: string;\n /** 0.38.1: `POST /feedback/{id}/replies` failed with no `detail` of its own — for\n * `FeedbackRowDetail`'s `onReply`. de-CH: \"Antwort konnte nicht gesendet werden.\" */\n replyFailed: string;\n}\n\nexport const DEFAULT_FEEDBACK_TOAST_LABELS: FeedbackToastLabels = {\n submitted: \"Thanks for the feedback!\",\n submitFailed: \"Could not submit feedback\",\n attachmentUnsupported: \"Only images, PDF or text files are allowed\",\n attachmentTooLarge: \"File is larger than 10 MB\",\n attachmentTooMany: (count) =>\n count === 1\n ? \"Only 1 attachment fits — the rest were left out.\"\n : `Only ${count} attachments fit — the rest were left out.`,\n captureFailed: \"Could not capture a screenshot\",\n updateFailed: \"Could not save that change.\",\n statusChanged: (status, title) => `Set to “${status}”: ${title}`,\n statusUndo: \"Undo\",\n statusRestored: (status, title) => `Back to “${status}”: ${title}`,\n commentFailed: \"Could not post the comment.\",\n voteFailed: \"Could not save your vote.\",\n replyFailed: \"Could not send the reply.\",\n};\n\n/** `feedbackStatus` resolved: English, then `<UiKitProvider labels>`, then `labels`. For\n * the places that need a status's name outside the kit's own parts — a filter's options,\n * `feedbackSwipePlan`'s panels, an app's overview tile. */\nexport function useFeedbackStatusLabels(labels?: LabelOverride<FeedbackStatusLabels>): FeedbackStatusLabels {\n return useKitLabels(\"feedbackStatus\", DEFAULT_FEEDBACK_STATUS_LABELS, labels);\n}\n\n/** `feedbackCategory` resolved: English, then the provider, then `labels`. */\nexport function useFeedbackCategoryLabels(labels?: LabelOverride<FeedbackCategoryLabels>): FeedbackCategoryLabels {\n return useKitLabels(\"feedbackCategory\", DEFAULT_FEEDBACK_CATEGORY_LABELS, labels);\n}\n\n/** `feedbackToast` resolved: English, then the provider, then `labels`. */\nexport function useFeedbackToastLabels(labels?: LabelOverride<FeedbackToastLabels>): FeedbackToastLabels {\n return useKitLabels(\"feedbackToast\", DEFAULT_FEEDBACK_TOAST_LABELS, labels);\n}\n"],"mappings":";AAAA,SAAS,oBAAwC;AAgC1C,MAAM,iCAAuD;AAAA,EAClE,MAAM;AAAA,EACN,OAAO;AAAA,EACP,aAAa;AAAA,EACb,eAAe;AAAA,EACf,iBAAiB;AAAA,EACjB,WAAW;AAAA,EACX,MAAM;AAAA,EACN,SAAS;AACX;AAWO,MAAM,mCAA2D;AAAA,EACtE,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MAAM;AAAA,EACN,UAAU;AAAA,EACV,OAAO;AACT;AAiDO,MAAM,gCAAqD;AAAA,EAChE,WAAW;AAAA,EACX,cAAc;AAAA,EACd,uBAAuB;AAAA,EACvB,oBAAoB;AAAA,EACpB,mBAAmB,CAAC,UAClB,UAAU,IACN,0DACA,QAAQ,KAAK;AAAA,EACnB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe,CAAC,QAAQ,UAAU,gBAAW,MAAM,WAAM,KAAK;AAAA,EAC9D,YAAY;AAAA,EACZ,gBAAgB,CAAC,QAAQ,UAAU,iBAAY,MAAM,WAAM,KAAK;AAAA,EAChE,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,aAAa;AACf;AAKO,SAAS,wBAAwB,QAAoE;AAC1G,SAAO,aAAa,kBAAkB,gCAAgC,MAAM;AAC9E;AAGO,SAAS,0BAA0B,QAAwE;AAChH,SAAO,aAAa,oBAAoB,kCAAkC,MAAM;AAClF;AAGO,SAAS,uBAAuB,QAAkE;AACvG,SAAO,aAAa,iBAAiB,+BAA+B,MAAM;AAC5E;","names":[]}
@@ -46,5 +46,8 @@ export interface FeedbackPublicLabels {
46
46
  visibleHint: string;
47
47
  /** Why the author cannot flip it now: the report is past its open window (§9.3). */
48
48
  visibleLocked: string;
49
+ /** 0.38.1: the pager's "where am I" — `page` counts from 1. The server answers no
50
+ * total, so there is no "of N". */
51
+ page: (page: number) => string;
49
52
  }
50
53
  export declare const DEFAULT_FEEDBACK_PUBLIC_LABELS: FeedbackPublicLabels;
@@ -18,7 +18,8 @@ const DEFAULT_FEEDBACK_PUBLIC_LABELS = {
18
18
  empty: "No reports yet",
19
19
  visibleToOthers: "Visible to others",
20
20
  visibleHint: "Other users see the title and text, never your screenshots or files.",
21
- visibleLocked: "Only while the report is still open."
21
+ visibleLocked: "Only while the report is still open.",
22
+ page: (page) => `Page ${page}`
22
23
  };
23
24
  export {
24
25
  DEFAULT_FEEDBACK_PUBLIC_LABELS
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/feedback/feedback-public-labels.ts"],"sourcesContent":["// The English words of the public feedback pages (round 0.38, docs/feedback-harmonization.md\n// §9.15) — `FeedbackPublicList`, `FeedbackPublicDetail` and `FeedbackPublicSwitch` — in a\n// module with no component code: the English catalogue (src/i18n/defaults.ts) imports\n// them without the components, as every `*-labels.ts` (0.34, KS U8).\n\n/**\n * `feedbackPublic` — the words of the pages every user reads (§9.3, §9.9): the list's\n * sort, search and count, the detail's sections and the \"Visible to others\" switch. The\n * table's column names that the inbox already has (#, Date, Category, Subject, Status)\n * stay `feedbackPage`'s, so the two lists cannot disagree; the vote button's words are\n * `feedbackVote`'s, the thread's `feedbackComments`'.\n *\n * de-CH canon (§9.2, §9.5): `title` \"Alle Rückmeldungen\", `anonymous` \"Eine Person\".\n */\nexport interface FeedbackPublicLabels {\n /** The page's heading — keksdose's `/all-feedback`, the menu's \"All feedback\". */\n title: string;\n /** The sort toggle's accessible name. */\n sort: string;\n /** `sort=newest`, the server's default. */\n sortNewest: string;\n /** `sort=votes`: most votes, then newest. */\n sortVotes: string;\n /** `sort=updated`. */\n sortUpdated: string;\n /** The search box's accessible name: it searches titles only (§9.9). */\n search: string;\n /** The Votes column's header. */\n columnVotes: string;\n /** How many reports the server has for this query (`total`). */\n total: (count: number) => string;\n /** A row's visible comments, the chip beside its title. */\n comments: (count: number) => string;\n /** A row's votes, the count on a phone card (the button is in the opened report). */\n votes: (count: number) => string;\n /** A `null` name (§9.5): an incomplete or erased account. */\n anonymous: string;\n /** Who filed it, with the server's first name (or {@link anonymous}). */\n filedBy: (name: string) => string;\n /** The detail's public body section. */\n body: string;\n /** The detail's merged replies and comments (§9.8, \"Order\"). */\n conversation: string;\n /** While the list or the comments load. */\n loading: string;\n /** No public report (yet, or for this search). */\n empty: string;\n /** `FeedbackPublicSwitch`'s label (§9.3, decision 6). */\n visibleToOthers: string;\n /** The line under it: what others see, and what never. */\n visibleHint: string;\n /** Why the author cannot flip it now: the report is past its open window (§9.3). */\n visibleLocked: string;\n}\n\nexport const DEFAULT_FEEDBACK_PUBLIC_LABELS: FeedbackPublicLabels = {\n title: \"All feedback\",\n sort: \"Sort\",\n sortNewest: \"Newest\",\n sortVotes: \"Most wanted\",\n sortUpdated: \"Recently updated\",\n search: \"Search titles\",\n columnVotes: \"Votes\",\n total: (count) => (count === 1 ? \"1 report\" : `${count} reports`),\n comments: (count) => (count === 1 ? \"1 comment\" : `${count} comments`),\n votes: (count) => (count === 1 ? \"1 vote\" : `${count} votes`),\n anonymous: \"A user\",\n filedBy: (name) => `From ${name}`,\n body: \"Description\",\n conversation: \"Answers and comments\",\n loading: \"Loading…\",\n empty: \"No reports yet\",\n visibleToOthers: \"Visible to others\",\n visibleHint: \"Other users see the title and text, never your screenshots or files.\",\n visibleLocked: \"Only while the report is still open.\",\n};\n"],"mappings":";AAuDO,MAAM,iCAAuD;AAAA,EAClE,OAAO;AAAA,EACP,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,OAAO,CAAC,UAAW,UAAU,IAAI,aAAa,GAAG,KAAK;AAAA,EACtD,UAAU,CAAC,UAAW,UAAU,IAAI,cAAc,GAAG,KAAK;AAAA,EAC1D,OAAO,CAAC,UAAW,UAAU,IAAI,WAAW,GAAG,KAAK;AAAA,EACpD,WAAW;AAAA,EACX,SAAS,CAAC,SAAS,QAAQ,IAAI;AAAA,EAC/B,MAAM;AAAA,EACN,cAAc;AAAA,EACd,SAAS;AAAA,EACT,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,eAAe;AACjB;","names":[]}
1
+ {"version":3,"sources":["../../src/feedback/feedback-public-labels.ts"],"sourcesContent":["// The English words of the public feedback pages (round 0.38, docs/feedback-harmonization.md\n// §9.15) — `FeedbackPublicList`, `FeedbackPublicDetail` and `FeedbackPublicSwitch` — in a\n// module with no component code: the English catalogue (src/i18n/defaults.ts) imports\n// them without the components, as every `*-labels.ts` (0.34, KS U8).\n\n/**\n * `feedbackPublic` — the words of the pages every user reads (§9.3, §9.9): the list's\n * sort, search and count, the detail's sections and the \"Visible to others\" switch. The\n * table's column names that the inbox already has (#, Date, Category, Subject, Status)\n * stay `feedbackPage`'s, so the two lists cannot disagree; the vote button's words are\n * `feedbackVote`'s, the thread's `feedbackComments`'.\n *\n * de-CH canon (§9.2, §9.5): `title` \"Alle Rückmeldungen\", `anonymous` \"Eine Person\".\n */\nexport interface FeedbackPublicLabels {\n /** The page's heading — keksdose's `/all-feedback`, the menu's \"All feedback\". */\n title: string;\n /** The sort toggle's accessible name. */\n sort: string;\n /** `sort=newest`, the server's default. */\n sortNewest: string;\n /** `sort=votes`: most votes, then newest. */\n sortVotes: string;\n /** `sort=updated`. */\n sortUpdated: string;\n /** The search box's accessible name: it searches titles only (§9.9). */\n search: string;\n /** The Votes column's header. */\n columnVotes: string;\n /** How many reports the server has for this query (`total`). */\n total: (count: number) => string;\n /** A row's visible comments, the chip beside its title. */\n comments: (count: number) => string;\n /** A row's votes, the count on a phone card (the button is in the opened report). */\n votes: (count: number) => string;\n /** A `null` name (§9.5): an incomplete or erased account. */\n anonymous: string;\n /** Who filed it, with the server's first name (or {@link anonymous}). */\n filedBy: (name: string) => string;\n /** The detail's public body section. */\n body: string;\n /** The detail's merged replies and comments (§9.8, \"Order\"). */\n conversation: string;\n /** While the list or the comments load. */\n loading: string;\n /** No public report (yet, or for this search). */\n empty: string;\n /** `FeedbackPublicSwitch`'s label (§9.3, decision 6). */\n visibleToOthers: string;\n /** The line under it: what others see, and what never. */\n visibleHint: string;\n /** Why the author cannot flip it now: the report is past its open window (§9.3). */\n visibleLocked: string;\n /** 0.38.1: the pager's \"where am I\" — `page` counts from 1. The server answers no\n * total, so there is no \"of N\". */\n page: (page: number) => string;\n}\n\nexport const DEFAULT_FEEDBACK_PUBLIC_LABELS: FeedbackPublicLabels = {\n title: \"All feedback\",\n sort: \"Sort\",\n sortNewest: \"Newest\",\n sortVotes: \"Most wanted\",\n sortUpdated: \"Recently updated\",\n search: \"Search titles\",\n columnVotes: \"Votes\",\n total: (count) => (count === 1 ? \"1 report\" : `${count} reports`),\n comments: (count) => (count === 1 ? \"1 comment\" : `${count} comments`),\n votes: (count) => (count === 1 ? \"1 vote\" : `${count} votes`),\n anonymous: \"A user\",\n filedBy: (name) => `From ${name}`,\n body: \"Description\",\n conversation: \"Answers and comments\",\n loading: \"Loading…\",\n empty: \"No reports yet\",\n visibleToOthers: \"Visible to others\",\n visibleHint: \"Other users see the title and text, never your screenshots or files.\",\n visibleLocked: \"Only while the report is still open.\",\n page: (page) => `Page ${page}`,\n};\n"],"mappings":";AA0DO,MAAM,iCAAuD;AAAA,EAClE,OAAO;AAAA,EACP,MAAM;AAAA,EACN,YAAY;AAAA,EACZ,WAAW;AAAA,EACX,aAAa;AAAA,EACb,QAAQ;AAAA,EACR,aAAa;AAAA,EACb,OAAO,CAAC,UAAW,UAAU,IAAI,aAAa,GAAG,KAAK;AAAA,EACtD,UAAU,CAAC,UAAW,UAAU,IAAI,cAAc,GAAG,KAAK;AAAA,EAC1D,OAAO,CAAC,UAAW,UAAU,IAAI,WAAW,GAAG,KAAK;AAAA,EACpD,WAAW;AAAA,EACX,SAAS,CAAC,SAAS,QAAQ,IAAI;AAAA,EAC/B,MAAM;AAAA,EACN,cAAc;AAAA,EACd,SAAS;AAAA,EACT,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,eAAe;AAAA,EACf,MAAM,CAAC,SAAS,QAAQ,IAAI;AAC9B;","names":[]}
@@ -37,6 +37,26 @@ export interface FeedbackPublicListProps<T extends FeedbackPublicListItem = Feed
37
37
  * keeps it itself. */
38
38
  openId?: number | null;
39
39
  onOpenChange?: (id: number | null) => void;
40
+ /**
41
+ * 0.38.1: the opened report when it is NOT on this page — a `?row=` link to an older
42
+ * one (Kurvenschmiede). The app fetches it (`GET /feedback/public/{id}`, a list item's
43
+ * fields and more) and passes it with `openId`; while `openId` is its id it is drawn
44
+ * first, above the page's rows, and opened with `renderDetail` (on the phone, in the
45
+ * full-screen dialog). Closed, it is gone. A row the page has already is never drawn
46
+ * twice: the page's own is opened instead.
47
+ */
48
+ openRow?: T | null;
49
+ /**
50
+ * 0.38.1: the server's page, from 0 — for a pager where `/feedback/public` answers no
51
+ * total (Kurvenschmiede). With {@link onPageChange} a **Previous / Page n / Next**
52
+ * strip stands under the table; Next is off without {@link hasMore}. Left out, no
53
+ * pager: the server's `limit` is all there is.
54
+ */
55
+ page?: number;
56
+ /** 0.38.1: there is a page after this one (e.g. the page came back full). */
57
+ hasMore?: boolean;
58
+ /** 0.38.1: go to another page (`page ± 1`); the app fetches it. Draws the pager. */
59
+ onPageChange?: (page: number) => void;
40
60
  /** A vote COMMITS — see Button's `commit`. */
41
61
  commit?: CommitScope;
42
62
  /** See {@link FeedbackRenderDate}. Default: the kit's, with the weekday. */
@@ -66,11 +86,12 @@ export interface FeedbackPublicListProps<T extends FeedbackPublicListItem = Feed
66
86
  * counts; the vote itself is in the opened report (a button inside the card, which is
67
87
  * the row's own button, would be two controls in one).
68
88
  *
69
- * No paging of its own: the server's `limit` is the page, and `total` says how many
70
- * there are (an app with more than one page adds its pager below). Needs a router, as
71
- * every `DataTable` does.
89
+ * No client paging: the server's `limit` is the page, and `total` says how many there
90
+ * are. For more than one page, `page` / `hasMore` / `onPageChange` draw a previous /
91
+ * next strip that needs no total (0.38.1); `openRow` shows a `?row=` report from
92
+ * another page. Needs a router, as every `DataTable` does.
72
93
  */
73
- export declare function FeedbackPublicList<T extends FeedbackPublicListItem = FeedbackPublicListItem>({ rows, total, sort, onSortChange, search, onSearchChange, renderDetail, onVote, loading, openId: openIdProp, onOpenChange, commit, renderDate: renderDateProp, labels: labelsProp, pageLabels: pageLabelsProp, className, }: FeedbackPublicListProps<T>): import("react").JSX.Element;
94
+ export declare function FeedbackPublicList<T extends FeedbackPublicListItem = FeedbackPublicListItem>({ rows, total, sort, onSortChange, search, onSearchChange, renderDetail, onVote, loading, openId: openIdProp, onOpenChange, openRow, page: pageIndex, hasMore, onPageChange, commit, renderDate: renderDateProp, labels: labelsProp, pageLabels: pageLabelsProp, className, }: FeedbackPublicListProps<T>): import("react").JSX.Element;
74
95
  export interface FeedbackPublicDetailProps {
75
96
  /** `GET /feedback/public/{id}`: the public body (attachment URLs already stripped by
76
97
  * the server, §9.4) and the replies. */
@@ -1,8 +1,10 @@
1
1
  "use client";
2
2
  import { jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useMemo, useState } from "react";
4
- import { MessageSquare, ThumbsUp } from "lucide-react";
4
+ import { ChevronLeft, ChevronRight, MessageSquare, ThumbsUp } from "lucide-react";
5
5
  import { DataTable } from "../components/data-table.js";
6
+ import { DEFAULT_DATA_TABLE_LABELS } from "../components/data-table-labels.js";
7
+ import { IconButton } from "../components/icon-button.js";
6
8
  import { SearchField } from "../components/search-field.js";
7
9
  import { ToggleGroup } from "../components/toggle-group.js";
8
10
  import { useKitLabels } from "../i18n/kit-labels.js";
@@ -47,6 +49,49 @@ function VoteCount({ count, voted, labels }) {
47
49
  }
48
50
  );
49
51
  }
52
+ function PublicPager({
53
+ page,
54
+ hasMore,
55
+ onPageChange,
56
+ labels
57
+ }) {
58
+ const tableLabels = useKitLabels("dataTable", DEFAULT_DATA_TABLE_LABELS);
59
+ const name = labels.page(page + 1);
60
+ return /* @__PURE__ */ jsxs(
61
+ "div",
62
+ {
63
+ role: "group",
64
+ "aria-label": name,
65
+ className: "flex items-center justify-end gap-2 text-sm text-secondary",
66
+ "data-feedback-public-pager": page,
67
+ children: [
68
+ /* @__PURE__ */ jsx(
69
+ IconButton,
70
+ {
71
+ size: "sm",
72
+ variant: "secondary",
73
+ label: tableLabels.prevPage,
74
+ disabled: page <= 0,
75
+ onClick: () => onPageChange(page - 1),
76
+ children: /* @__PURE__ */ jsx(ChevronLeft, { className: "rtl:-scale-x-100" })
77
+ }
78
+ ),
79
+ /* @__PURE__ */ jsx("span", { className: "tabular-nums", "aria-hidden": true, children: name }),
80
+ /* @__PURE__ */ jsx(
81
+ IconButton,
82
+ {
83
+ size: "sm",
84
+ variant: "secondary",
85
+ label: tableLabels.nextPage,
86
+ disabled: !hasMore,
87
+ onClick: () => onPageChange(page + 1),
88
+ children: /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:-scale-x-100" })
89
+ }
90
+ )
91
+ ]
92
+ }
93
+ );
94
+ }
50
95
  function FeedbackPublicList({
51
96
  rows,
52
97
  total,
@@ -59,6 +104,10 @@ function FeedbackPublicList({
59
104
  loading = false,
60
105
  openId: openIdProp,
61
106
  onOpenChange,
107
+ openRow,
108
+ page: pageIndex = 0,
109
+ hasMore = false,
110
+ onPageChange,
62
111
  commit,
63
112
  renderDate: renderDateProp,
64
113
  labels: labelsProp,
@@ -75,6 +124,7 @@ function FeedbackPublicList({
75
124
  if (openIdProp === void 0) setOwnOpenId(id);
76
125
  onOpenChange?.(id);
77
126
  };
127
+ const shownRows = openRow && openId === openRow.id && !rows.some((row) => row.id === openRow.id) ? [openRow, ...rows] : rows;
78
128
  const columns = useMemo(
79
129
  () => [
80
130
  {
@@ -158,7 +208,7 @@ function FeedbackPublicList({
158
208
  /* @__PURE__ */ jsx(
159
209
  DataTable,
160
210
  {
161
- rows,
211
+ rows: shownRows,
162
212
  columns,
163
213
  rowKey: (row) => row.id,
164
214
  rowName: (row) => row.title,
@@ -181,7 +231,8 @@ function FeedbackPublicList({
181
231
  ] })
182
232
  ] })
183
233
  }
184
- )
234
+ ),
235
+ onPageChange && (pageIndex > 0 || hasMore) && /* @__PURE__ */ jsx(PublicPager, { page: pageIndex, hasMore, onPageChange, labels })
185
236
  ] });
186
237
  }
187
238
  function FeedbackPublicDetail({