@eifi1/ui-kit 0.37.0 → 0.38.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.
- package/README.md +11 -4
- package/dist/eslint/index.js +1 -1
- package/dist/feedback/feedback-comment-thread.d.ts +80 -0
- package/dist/feedback/feedback-comment-thread.js +162 -0
- package/dist/feedback/feedback-comment-thread.js.map +1 -0
- package/dist/feedback/feedback-dialog-labels.js +2 -1
- package/dist/feedback/feedback-dialog-labels.js.map +1 -1
- package/dist/feedback/feedback-dialog.d.ts +13 -0
- package/dist/feedback/feedback-dialog.js +12 -4
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-menu-labels.js +2 -1
- package/dist/feedback/feedback-menu-labels.js.map +1 -1
- package/dist/feedback/feedback-menu.d.ts +17 -3
- package/dist/feedback/feedback-menu.js +11 -1
- package/dist/feedback/feedback-menu.js.map +1 -1
- package/dist/feedback/feedback-public-labels.d.ts +50 -0
- package/dist/feedback/feedback-public-labels.js +26 -0
- package/dist/feedback/feedback-public-labels.js.map +1 -0
- package/dist/feedback/feedback-public-list.d.ts +118 -0
- package/dist/feedback/feedback-public-list.js +248 -0
- package/dist/feedback/feedback-public-list.js.map +1 -0
- package/dist/feedback/feedback-public-switch.d.ts +51 -0
- package/dist/feedback/feedback-public-switch.js +50 -0
- package/dist/feedback/feedback-public-switch.js.map +1 -0
- package/dist/feedback/feedback-public-types.d.ts +75 -0
- package/dist/feedback/feedback-public-types.js +2 -0
- package/dist/feedback/feedback-public-types.js.map +1 -0
- package/dist/feedback/feedback-record.d.ts +32 -1
- package/dist/feedback/feedback-record.js +10 -0
- package/dist/feedback/feedback-record.js.map +1 -1
- package/dist/feedback/feedback-replies.d.ts +97 -0
- package/dist/feedback/feedback-replies.js +114 -0
- package/dist/feedback/feedback-replies.js.map +1 -0
- package/dist/feedback/feedback-row-detail-labels.js +1 -0
- package/dist/feedback/feedback-row-detail-labels.js.map +1 -1
- package/dist/feedback/feedback-row-detail.d.ts +38 -10
- package/dist/feedback/feedback-row-detail.js +50 -50
- package/dist/feedback/feedback-row-detail.js.map +1 -1
- package/dist/feedback/feedback-submit-dialog.d.ts +3 -1
- package/dist/feedback/feedback-submit-dialog.js +6 -1
- package/dist/feedback/feedback-submit-dialog.js.map +1 -1
- package/dist/feedback/feedback-submit.d.ts +8 -0
- package/dist/feedback/feedback-submit.js +3 -2
- package/dist/feedback/feedback-submit.js.map +1 -1
- package/dist/feedback/feedback-table.d.ts +15 -5
- package/dist/feedback/feedback-table.js +46 -5
- package/dist/feedback/feedback-table.js.map +1 -1
- package/dist/feedback/feedback-thread-parts-labels.d.ts +6 -0
- package/dist/feedback/feedback-thread-parts-labels.js +36 -0
- package/dist/feedback/feedback-thread-parts-labels.js.map +1 -0
- package/dist/feedback/feedback-thread.d.ts +8 -0
- package/dist/feedback/feedback-thread.js +7 -2
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/feedback/feedback-vote-button.d.ts +48 -0
- package/dist/feedback/feedback-vote-button.js +72 -0
- package/dist/feedback/feedback-vote-button.js.map +1 -0
- package/dist/feedback.d.ts +6 -0
- package/dist/feedback.js +6 -0
- package/dist/feedback.js.map +1 -1
- package/dist/i18n/defaults.js +12 -0
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +64 -2
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +16 -0
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +79 -2
- package/dist/i18n/locales/en.js.map +3 -3
- package/dist/i18n/locales/es.js +64 -2
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +64 -2
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +64 -2
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +64 -2
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +64 -2
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +4 -0
- package/dist/i18n/review.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/notifications/feedback-notification-types-labels.d.ts +15 -0
- package/dist/notifications/feedback-notification-types-labels.js +11 -0
- package/dist/notifications/feedback-notification-types-labels.js.map +1 -0
- package/dist/notifications/feedback-notification-types.d.ts +28 -0
- package/dist/notifications/feedback-notification-types.js +21 -0
- package/dist/notifications/feedback-notification-types.js.map +1 -0
- package/package.json +1 -1
- package/src/feedback/feedback-comment-thread.tsx +255 -0
- package/src/feedback/feedback-dialog-labels.ts +1 -0
- package/src/feedback/feedback-dialog.tsx +30 -2
- package/src/feedback/feedback-menu-labels.ts +1 -0
- package/src/feedback/feedback-menu.tsx +29 -3
- package/src/feedback/feedback-public-labels.ts +76 -0
- package/src/feedback/feedback-public-list.tsx +395 -0
- package/src/feedback/feedback-public-switch.tsx +102 -0
- package/src/feedback/feedback-public-types.ts +82 -0
- package/src/feedback/feedback-record.ts +39 -1
- package/src/feedback/feedback-replies.tsx +235 -0
- package/src/feedback/feedback-row-detail-labels.ts +1 -0
- package/src/feedback/feedback-row-detail.tsx +103 -74
- package/src/feedback/feedback-submit-dialog.tsx +9 -0
- package/src/feedback/feedback-submit.tsx +10 -1
- package/src/feedback/feedback-table.tsx +73 -6
- package/src/feedback/feedback-thread-parts-labels.ts +41 -0
- package/src/feedback/feedback-thread.tsx +18 -1
- package/src/feedback/feedback-vote-button.tsx +122 -0
- package/src/feedback.ts +10 -0
- package/src/i18n/defaults.ts +12 -0
- package/src/i18n/german.ts +62 -0
- package/src/i18n/kit-labels.tsx +16 -0
- package/src/i18n/locales/en.ts +7 -0
- package/src/i18n/locales/es.ts +62 -0
- package/src/i18n/locales/fr.ts +62 -0
- package/src/i18n/locales/hu.ts +62 -0
- package/src/i18n/locales/it.ts +62 -0
- package/src/i18n/locales/zh.ts +62 -0
- package/src/i18n/review.ts +4 -0
- package/src/index.ts +9 -0
- package/src/notifications/feedback-notification-types-labels.ts +24 -0
- package/src/notifications/feedback-notification-types.ts +46 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { Switch } from "../components/switch.js";
|
|
4
|
+
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
5
|
+
import { FEEDBACK_AUTHOR_EDITABLE_STATUSES } from "./feedback-record.js";
|
|
6
|
+
import { DEFAULT_FEEDBACK_PUBLIC_LABELS } from "./feedback-public-labels.js";
|
|
7
|
+
function isAuthorOf(row, viewerId) {
|
|
8
|
+
if (row.mine !== void 0) return row.mine;
|
|
9
|
+
return row.user_id !== null && viewerId !== void 0 && viewerId !== null && row.user_id === viewerId;
|
|
10
|
+
}
|
|
11
|
+
function feedbackPublicSwitchAllowed(row, { isAdmin, viewerId }) {
|
|
12
|
+
if (row.category === "CRASH") return false;
|
|
13
|
+
if (isAdmin) return true;
|
|
14
|
+
if (!isAuthorOf(row, viewerId)) return false;
|
|
15
|
+
return row.filed_private === true || FEEDBACK_AUTHOR_EDITABLE_STATUSES.includes(row.status);
|
|
16
|
+
}
|
|
17
|
+
function FeedbackPublicSwitch({
|
|
18
|
+
row,
|
|
19
|
+
isAdmin,
|
|
20
|
+
viewerId,
|
|
21
|
+
onChange,
|
|
22
|
+
pending = false,
|
|
23
|
+
commit,
|
|
24
|
+
labels: labelsProp,
|
|
25
|
+
className
|
|
26
|
+
}) {
|
|
27
|
+
const labels = useKitLabels("feedbackPublic", DEFAULT_FEEDBACK_PUBLIC_LABELS, labelsProp);
|
|
28
|
+
if (row.category === "CRASH" || row.public === void 0) return null;
|
|
29
|
+
if (!isAdmin && !isAuthorOf(row, viewerId)) return null;
|
|
30
|
+
const allowed = feedbackPublicSwitchAllowed(row, { isAdmin, viewerId });
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
Switch,
|
|
33
|
+
{
|
|
34
|
+
className,
|
|
35
|
+
label: labels.visibleToOthers,
|
|
36
|
+
description: labels.visibleHint,
|
|
37
|
+
checked: row.public,
|
|
38
|
+
disabled: pending,
|
|
39
|
+
disabledReason: allowed ? void 0 : labels.visibleLocked,
|
|
40
|
+
commit,
|
|
41
|
+
onCheckedChange: (next) => onChange(next),
|
|
42
|
+
"data-feedback-public": row.public ? "on" : "off"
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
FeedbackPublicSwitch,
|
|
48
|
+
feedbackPublicSwitchAllowed
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=feedback-public-switch.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/feedback-public-switch.tsx"],"sourcesContent":["import { Switch } from \"../components/switch\";\nimport type { CommitScope } from \"../components/write-lock\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { FEEDBACK_AUTHOR_EDITABLE_STATUSES, type FeedbackRecord } from \"./feedback-record\";\nimport { DEFAULT_FEEDBACK_PUBLIC_LABELS, type FeedbackPublicLabels } from \"./feedback-public-labels\";\n\n/** What the switch reads off a report: {@link FeedbackRecord}'s fields (§9.3). */\nexport type FeedbackPublicSwitchRow = Pick<\n FeedbackRecord,\n \"user_id\" | \"category\" | \"status\" | \"public\" | \"filed_private\" | \"mine\"\n>;\n\n/** Who is looking: the app's admin check, and the signed-in user's id. */\nexport interface FeedbackPublicSwitchViewer {\n isAdmin: boolean;\n viewerId?: number | null;\n}\n\n/** The viewer filed the row — `mine` when the server sent it, else the ids (never for an\n * erased author, `user_id: null`). */\nfunction isAuthorOf(row: FeedbackPublicSwitchRow, viewerId: number | null | undefined): boolean {\n if (row.mine !== undefined) return row.mine;\n return row.user_id !== null && viewerId !== undefined && viewerId !== null && row.user_id === viewerId;\n}\n\n/**\n * Whether the viewer may flip a report's `public` flag — the server's rule (§9.3), so the\n * switch never offers what the `PATCH {public}` would refuse with a 403:\n *\n * - never on a CRASH (decision 9: a crash is private whatever its flag);\n * - an admin, at any status;\n * - the author while the status is OPEN, READY or IN_PROGRESS\n * (`FEEDBACK_AUTHOR_EDITABLE_STATUSES`), and on a `filed_private` report — one the\n * 0.38 migration made public — at any status: that is the opt-out the notice offers.\n */\nexport function feedbackPublicSwitchAllowed(\n row: FeedbackPublicSwitchRow,\n { isAdmin, viewerId }: FeedbackPublicSwitchViewer,\n): boolean {\n if (row.category === \"CRASH\") return false;\n if (isAdmin) return true;\n if (!isAuthorOf(row, viewerId)) return false;\n return row.filed_private === true || FEEDBACK_AUTHOR_EDITABLE_STATUSES.includes(row.status);\n}\n\nexport interface FeedbackPublicSwitchProps extends FeedbackPublicSwitchViewer {\n row: FeedbackPublicSwitchRow;\n /** `PATCH /feedback/{id} {\"public\": next}` — the app's mutation. */\n onChange: (next: boolean) => void;\n /** The PATCH is in flight: the switch holds still. */\n pending?: boolean;\n /** Flipping it SAVES: pass `true` to put it under the page's `WriteLockProvider`\n * (Switch's `commit`). Off by default, as on the inbox's status buttons. */\n commit?: CommitScope;\n /** Over the `feedbackPublic` namespace (`visibleToOthers`, `visibleHint`,\n * `visibleLocked`). */\n labels?: LabelOverride<FeedbackPublicLabels>;\n className?: string;\n}\n\n/**\n * **Visible to others** — a report's `public` flag (round 0.38, docs/feedback-harmonization.md\n * §9.3, decision 6), for the row detail (`FeedbackRowDetail`'s `onPublicChange`) or an\n * app's own page.\n *\n * - Drawn for the admin and the author only: nobody else is sent `public` (§9.10). Not\n * drawn on a CRASH, and not when the row carries no `public` at all (a server before\n * 0.38, or an app without public parts — kastlan).\n * - The author past the open window sees it **locked with the reason** (\"Only while the\n * report is open\"), focusable, so the reason reaches a keyboard; a `filed_private`\n * report is never locked for its author ({@link feedbackPublicSwitchAllowed}).\n * - The line under it says what \"visible\" means: the title and the text, never the\n * screenshots or files (decision 1).\n */\nexport function FeedbackPublicSwitch({\n row,\n isAdmin,\n viewerId,\n onChange,\n pending = false,\n commit,\n labels: labelsProp,\n className,\n}: FeedbackPublicSwitchProps) {\n const labels = useKitLabels(\"feedbackPublic\", DEFAULT_FEEDBACK_PUBLIC_LABELS, labelsProp);\n if (row.category === \"CRASH\" || row.public === undefined) return null;\n if (!isAdmin && !isAuthorOf(row, viewerId)) return null;\n const allowed = feedbackPublicSwitchAllowed(row, { isAdmin, viewerId });\n return (\n <Switch\n className={className}\n label={labels.visibleToOthers}\n description={labels.visibleHint}\n checked={row.public}\n disabled={pending}\n disabledReason={allowed ? undefined : labels.visibleLocked}\n commit={commit}\n onCheckedChange={(next) => onChange(next)}\n data-feedback-public={row.public ? \"on\" : \"off\"}\n />\n );\n}\n"],"mappings":";AAyFI;AAzFJ,SAAS,cAAc;AAEvB,SAAS,oBAAwC;AACjD,SAAS,yCAA8D;AACvE,SAAS,sCAAiE;AAgB1E,SAAS,WAAW,KAA8B,UAA8C;AAC9F,MAAI,IAAI,SAAS,OAAW,QAAO,IAAI;AACvC,SAAO,IAAI,YAAY,QAAQ,aAAa,UAAa,aAAa,QAAQ,IAAI,YAAY;AAChG;AAYO,SAAS,4BACd,KACA,EAAE,SAAS,SAAS,GACX;AACT,MAAI,IAAI,aAAa,QAAS,QAAO;AACrC,MAAI,QAAS,QAAO;AACpB,MAAI,CAAC,WAAW,KAAK,QAAQ,EAAG,QAAO;AACvC,SAAO,IAAI,kBAAkB,QAAQ,kCAAkC,SAAS,IAAI,MAAM;AAC5F;AA+BO,SAAS,qBAAqB;AAAA,EACnC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU;AAAA,EACV;AAAA,EACA,QAAQ;AAAA,EACR;AACF,GAA8B;AAC5B,QAAM,SAAS,aAAa,kBAAkB,gCAAgC,UAAU;AACxF,MAAI,IAAI,aAAa,WAAW,IAAI,WAAW,OAAW,QAAO;AACjE,MAAI,CAAC,WAAW,CAAC,WAAW,KAAK,QAAQ,EAAG,QAAO;AACnD,QAAM,UAAU,4BAA4B,KAAK,EAAE,SAAS,SAAS,CAAC;AACtE,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,OAAO,OAAO;AAAA,MACd,aAAa,OAAO;AAAA,MACpB,SAAS,IAAI;AAAA,MACb,UAAU;AAAA,MACV,gBAAgB,UAAU,SAAY,OAAO;AAAA,MAC7C;AAAA,MACA,iBAAiB,CAAC,SAAS,SAAS,IAAI;AAAA,MACxC,wBAAsB,IAAI,SAAS,OAAO;AAAA;AAAA,EAC5C;AAEJ;","names":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { FeedbackCategory, FeedbackStatus } from "./feedback-vocabulary.js";
|
|
2
|
+
/**
|
|
3
|
+
* The shapes of round 0.38's public feedback (docs/feedback-harmonization.md §9): the
|
|
4
|
+
* admin's replies as a list (§9.7), other people's comments as rows (§9.8), the upvote
|
|
5
|
+
* (§9.6) and the two public views of a report (§9.3). Types only: what the server
|
|
6
|
+
* answers, as the three apps' clients receive it.
|
|
7
|
+
*
|
|
8
|
+
* A name is always the server's (§9.5): `author_name` is a first name for others, the
|
|
9
|
+
* full name for an admin, and `null` when there is none to show (an erased or incomplete
|
|
10
|
+
* account, a loop's reply). The client never builds one from an id.
|
|
11
|
+
*/
|
|
12
|
+
/** One answer of the admin's — `FeedbackReplyResponse`, §9.7. Oldest first. */
|
|
13
|
+
export interface FeedbackReply {
|
|
14
|
+
id: number;
|
|
15
|
+
/** `null`: a loop's reply, a migrated `outcome`, or an erased admin — drawn as the
|
|
16
|
+
* app's word for its admin ("Admin"). */
|
|
17
|
+
author_name: string | null;
|
|
18
|
+
body: string;
|
|
19
|
+
/** The status this reply moved the report to; `null` = no status change. */
|
|
20
|
+
status_to: FeedbackStatus | null;
|
|
21
|
+
/** Where it moved from — the admin view only. */
|
|
22
|
+
status_from?: FeedbackStatus | null;
|
|
23
|
+
/** ISO 8601. */
|
|
24
|
+
created_at: string;
|
|
25
|
+
}
|
|
26
|
+
/** One comment by someone who reads the report — `FeedbackCommentResponse`, §9.8. */
|
|
27
|
+
export interface FeedbackComment {
|
|
28
|
+
id: number;
|
|
29
|
+
/** First name for others, the full name for an admin; `null` → "A user". */
|
|
30
|
+
author_name: string | null;
|
|
31
|
+
/** The viewer wrote it (they may delete it). */
|
|
32
|
+
mine: boolean;
|
|
33
|
+
/** keksdose's migrated rows whose writer was an admin (K2): drawn as a staff post. */
|
|
34
|
+
staff: boolean;
|
|
35
|
+
/** `null` when hidden, but for its writer and an admin. */
|
|
36
|
+
body: string | null;
|
|
37
|
+
hidden: boolean;
|
|
38
|
+
/** ISO 8601. */
|
|
39
|
+
created_at: string;
|
|
40
|
+
}
|
|
41
|
+
/** What `PUT` / `DELETE /feedback/{id}/vote` answer — `FeedbackVoteResponse`, §9.6. */
|
|
42
|
+
export interface FeedbackVoteState {
|
|
43
|
+
votes: number;
|
|
44
|
+
voted: boolean;
|
|
45
|
+
}
|
|
46
|
+
/** The public list's server-side sort (§9.6): newest first (default), most votes (then
|
|
47
|
+
* newest), or most recently updated. */
|
|
48
|
+
export type FeedbackPublicSort = "newest" | "votes" | "updated";
|
|
49
|
+
/** One row of `GET /feedback/public` — `FeedbackPublicListItem`, §9.3, §9.9: titles
|
|
50
|
+
* only, no body, no files, no account. */
|
|
51
|
+
export interface FeedbackPublicListItem extends FeedbackVoteState {
|
|
52
|
+
id: number;
|
|
53
|
+
title: string;
|
|
54
|
+
category: FeedbackCategory;
|
|
55
|
+
status: FeedbackStatus;
|
|
56
|
+
/** First name, or `null` → "A user". */
|
|
57
|
+
author_name: string | null;
|
|
58
|
+
/** The viewer filed it. */
|
|
59
|
+
mine: boolean;
|
|
60
|
+
/** Visible comments. */
|
|
61
|
+
comment_count: number;
|
|
62
|
+
/** ISO 8601. */
|
|
63
|
+
created_at: string;
|
|
64
|
+
/** ISO 8601. */
|
|
65
|
+
updated_at: string;
|
|
66
|
+
/** ISO 8601, or `null`. */
|
|
67
|
+
resolved_at: string | null;
|
|
68
|
+
}
|
|
69
|
+
/** `GET /feedback/public/{id}` — `FeedbackPublicResponse`, §9.3: the list row plus the
|
|
70
|
+
* public body (every attachment URL stripped by the server, §9.4) and the replies. The
|
|
71
|
+
* comments are fetched beside it (`GET /feedback/{id}/comments`). */
|
|
72
|
+
export interface FeedbackPublicRecord extends FeedbackPublicListItem {
|
|
73
|
+
body: string;
|
|
74
|
+
replies: FeedbackReply[];
|
|
75
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FeedbackCategory, FeedbackStatus } from "./feedback-vocabulary.js";
|
|
2
|
+
import type { FeedbackReply } from "./feedback-public-types.js";
|
|
2
3
|
/**
|
|
3
4
|
* One feedback report as the three apps send it, and the facts the kit reads off it.
|
|
4
5
|
*
|
|
@@ -94,7 +95,9 @@ export interface FeedbackRecord {
|
|
|
94
95
|
/** Up to 5 other files; `null` = none. Optional because a server older than the
|
|
95
96
|
* column sends no key at all (keksdose dev #578 met exactly that). */
|
|
96
97
|
attachment_urls?: string[] | null;
|
|
97
|
-
/** The team's answer; `null` = none written.
|
|
98
|
+
/** The team's answer; `null` = none written. **Frozen since 0.38** (§9.7): answered
|
|
99
|
+
* as stored for one release, written by nothing, then dropped — the answer is
|
|
100
|
+
* {@link FeedbackRecord.replies} now. */
|
|
98
101
|
outcome: string | null;
|
|
99
102
|
/** Set on ENTERING `DONE` / `WONT_DO`, cleared on leaving them. ISO 8601. */
|
|
100
103
|
resolved_at: string | null;
|
|
@@ -102,6 +105,23 @@ export interface FeedbackRecord {
|
|
|
102
105
|
created_at: string;
|
|
103
106
|
/** ISO 8601. */
|
|
104
107
|
updated_at: string;
|
|
108
|
+
/** The admin: the full name; the author: their own; `null`: none to show. */
|
|
109
|
+
author_name?: string | null;
|
|
110
|
+
/** The viewer filed it. */
|
|
111
|
+
mine?: boolean;
|
|
112
|
+
/** Visible to the app's other users (§9.3); never on a CRASH. */
|
|
113
|
+
public?: boolean;
|
|
114
|
+
/** Made public by the 0.38 migration: the author may switch it off at any status. */
|
|
115
|
+
filed_private?: boolean;
|
|
116
|
+
/** People who want this (the author's own vote included, §9.6). */
|
|
117
|
+
votes?: number;
|
|
118
|
+
/** The viewer's vote. */
|
|
119
|
+
voted?: boolean;
|
|
120
|
+
/** Comments (an admin's count includes hidden ones). */
|
|
121
|
+
comment_count?: number;
|
|
122
|
+
/** The admin's answers, oldest first (§9.7). Absent: a server before 0.38 — read
|
|
123
|
+
* `outcome` instead. */
|
|
124
|
+
replies?: FeedbackReply[];
|
|
105
125
|
}
|
|
106
126
|
/** The image types `FeedbackAttachmentField` takes when `accept` is not given. */
|
|
107
127
|
export declare const DEFAULT_ATTACHMENT_ACCEPT: string[];
|
|
@@ -152,6 +172,17 @@ export declare const FEEDBACK_AUTHOR_EDITABLE_STATUSES: readonly FeedbackStatus[
|
|
|
152
172
|
* you" toggle narrows the inbox to exactly these (§4.3).
|
|
153
173
|
*/
|
|
154
174
|
export declare const FEEDBACK_AWAITING_STATUSES: readonly FeedbackStatus[];
|
|
175
|
+
/**
|
|
176
|
+
* The **decided** statuses (§9.7, decision 13): `DONE`, `WONT_DO`, `POSTPONED`. A
|
|
177
|
+
* status-only move into one tells the author nothing (a status alone sends no
|
|
178
|
+
* notification), so the row detail nudges the admin toward a reply until one with that
|
|
179
|
+
* `status_to` exists.
|
|
180
|
+
*/
|
|
181
|
+
export declare const FEEDBACK_DECIDED_STATUSES: readonly FeedbackStatus[];
|
|
182
|
+
/** A comment's longest body after trimming (§9.8). */
|
|
183
|
+
export declare const FEEDBACK_COMMENT_MAX = 4000;
|
|
184
|
+
/** A reply's longest body after trimming (§9.7). */
|
|
185
|
+
export declare const FEEDBACK_REPLY_MAX = 8000;
|
|
155
186
|
/** The body line for one uploaded attachment — what {@link appendRework} writes under
|
|
156
187
|
* the note. */
|
|
157
188
|
export declare function feedbackAttachmentLine(url: string): string;
|
|
@@ -28,6 +28,13 @@ const FEEDBACK_AWAITING_STATUSES = Object.freeze([
|
|
|
28
28
|
"IN_EVALUATION",
|
|
29
29
|
"NEEDS_LIVE_TEST"
|
|
30
30
|
]);
|
|
31
|
+
const FEEDBACK_DECIDED_STATUSES = Object.freeze([
|
|
32
|
+
"DONE",
|
|
33
|
+
"WONT_DO",
|
|
34
|
+
"POSTPONED"
|
|
35
|
+
]);
|
|
36
|
+
const FEEDBACK_COMMENT_MAX = 4e3;
|
|
37
|
+
const FEEDBACK_REPLY_MAX = 8e3;
|
|
31
38
|
const ATTACHMENT_URL = /^\/api\/v1\/feedback\/attachments\/[\w.-]+$/;
|
|
32
39
|
const ATTACHMENT_LINE = /^\[screenshot\]\s+(\/api\/v1\/feedback\/attachments\/[\w.-]+)\s*$/;
|
|
33
40
|
const REWORK_RULE = /^---\s*REWORK\b.*---$/;
|
|
@@ -97,7 +104,10 @@ export {
|
|
|
97
104
|
FEEDBACK_ATTACHMENT_ACCEPT,
|
|
98
105
|
FEEDBACK_AUTHOR_EDITABLE_STATUSES,
|
|
99
106
|
FEEDBACK_AWAITING_STATUSES,
|
|
107
|
+
FEEDBACK_COMMENT_MAX,
|
|
108
|
+
FEEDBACK_DECIDED_STATUSES,
|
|
100
109
|
FEEDBACK_PICKABLE_CATEGORIES,
|
|
110
|
+
FEEDBACK_REPLY_MAX,
|
|
101
111
|
FEEDBACK_REWORKABLE_STATUSES,
|
|
102
112
|
appendRework,
|
|
103
113
|
attachmentName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feedback/feedback-record.ts"],"sourcesContent":["import { FEEDBACK_CATEGORY_ORDER } from \"./feedback-vocabulary\";\nimport type { FeedbackCategory, FeedbackStatus } from \"./feedback-vocabulary\";\n\n/**\n * One feedback report as the three apps send it, and the facts the kit reads off it.\n *\n * Until 0.27 the inbox parts took no report at all (\"no `Feedback` type in this file\",\n * feedback-inbox.tsx): keksdose kept its reporter context in a JSON column, kastlan a\n * thinner copy of it, Kurvenschmiede a `page_path` and the bytes in the row. Marcel's\n * feedback round (2026-10-04, docs/feedback-harmonization.md) settled one API contract\n * for all three — keksdose's, read off its code — so the apps now share one shape and the\n * kit can take a row instead of a dozen loose values. This file is that shape (§3.1,\n * §3.2), the contract's constants (§3.4, §3.5, §4.3) and the readers and writers of the\n * one field whose format is itself contract: the body, which carries the rework rounds\n * (§3.4) — lifted from keksdose `frontend/src/features/feedback/body-attachments.ts`.\n *\n * Plain functions and data, no components: everything here is as usable from a loop\n * script's helper or a test as from a page.\n */\n\n/* ── The resource (§3.1, §3.2) ────────────────────────────────────────────── */\n\n/** Which copy of an app a report came from — keksdose `app/deploy-environment.ts`.\n * Any other string is read as \"not prod\" (the admin list shows it upper-cased as a\n * chip, §4.3), so an app with a `staging` loses nothing. */\nexport type FeedbackEnvironment = \"prod\" | \"dev\" | \"local\";\n\n/**\n * The reporter's context, written by the submit dialog (keksdose\n * `use-feedback-dialog.tsx:105`) — §3.2 of the contract.\n *\n * **Every key is optional on read**, and a reader treats a missing one as \"unknown\":\n * kastlan's client sends six of them (no email, no version), Kurvenschmiede's old rows are\n * backfilled from two columns with a path-only `url`, crash rows add their own (and\n * `origin` / `environment` from the crash payload, §3.6 — older crash rows have neither),\n * and an erased account's row keeps only an allow-list (§3.2: `environment` stays,\n * `origin` goes). Extra keys are allowed — a server may add its own — hence the index\n * signature.\n */\nexport interface FeedbackContext {\n /** The full `location.href` at open time; `\"\"` when \"Attach current page URL\" was off.\n * Readers also accept a path-only value (Kurvenschmiede's backfilled rows). */\n url?: string;\n /** Its pathname; `\"\"` when the URL was withheld. */\n route?: string;\n /** `location.origin` — which copy of the app, not personal; never withheld. */\n origin?: string;\n /** {@link FeedbackEnvironment}, or whatever the app calls its other copies. */\n environment?: FeedbackEnvironment | (string & {});\n /** The submitter, as a snapshot. The server should overwrite the three `user_*` keys\n * from the session (Kurvenschmiede does), so nobody files in someone else's name. */\n user_id?: number | null;\n user_email?: string | null;\n user_display_name?: string | null;\n /** `\"406x816\"`. */\n viewport?: string;\n /** `navigator.userAgent`. */\n ua?: string;\n /** The app build (`__APP_VERSION__`). */\n version?: string;\n // Crash rows (server-written, keksdose `feedback_service.py:346`).\n fingerprint?: string;\n /** Which error boundary caught it. */\n boundary?: \"app\" | \"page\" | (string & {});\n online?: boolean;\n occurrences?: number;\n first_seen_at?: string;\n last_seen_at?: string;\n auto_reported?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * One report — `FeedbackResponse`, keksdose `schemas/feedback.py:117`, §3.1 of the\n * contract. What `GET /feedback`, `GET /feedback/my`, `POST /feedback` and\n * `PATCH /feedback/{id}` answer in all three apps.\n *\n * Extra fields are allowed and ignored (kastlan's `company_id`, `user_name`): an app's\n * own row type with more fields is assignable to this one as it stands.\n *\n * There is **no rework counter field** — {@link reworkCount} reads it off the body, so\n * nothing can forget to set it.\n */\nexport interface FeedbackRecord {\n id: number;\n /** `null`: the author's account was erased (keksdose live #275). */\n user_id: number | null;\n /** The admin list only (joined); `null` — or absent — on `/my`, create and update. */\n user_email?: string | null;\n /** 1–255 characters, never blank. */\n title: string;\n /** `\"\"` when none. Rework rounds are appended here (§3.4) — read it with\n * {@link splitDescription} / {@link splitBodyAttachments}, write it with\n * {@link appendRework} / {@link replaceDescription}. */\n body: string;\n category: FeedbackCategory;\n status: FeedbackStatus;\n /** §3.2; `null` on rows that have none. */\n context: FeedbackContext | null;\n /** The ONE captured screenshot's attachment URL, or `null`. */\n screenshot_url: string | null;\n /** Up to 5 other files; `null` = none. Optional because a server older than the\n * column sends no key at all (keksdose dev #578 met exactly that). */\n attachment_urls?: string[] | null;\n /** The team's answer; `null` = none written. */\n outcome: string | null;\n /** Set on ENTERING `DONE` / `WONT_DO`, cleared on leaving them. ISO 8601. */\n resolved_at: string | null;\n /** ISO 8601. */\n created_at: string;\n /** ISO 8601. */\n updated_at: string;\n}\n\n/* ── Constants (§3.4, §3.5, §4.3) ─────────────────────────────────────────── */\n\n// The attachment field's three defaults live here, not in feedback-attachment.tsx\n// (which re-exports them), since 0.34 (MOD-1, refactor audit 2026-10). This module is in\n// every app's top bar (the menu's categories), and FEEDBACK_ATTACHMENT_ACCEPT below is\n// built on DEFAULT_ATTACHMENT_ACCEPT: imported from the field's module, it tied the top\n// bar to the field, the lazily loaded dialog's heaviest part, for three values.\n\n/** The image types `FeedbackAttachmentField` takes when `accept` is not given. */\nexport const DEFAULT_ATTACHMENT_ACCEPT = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"];\n/** 10 MB, the contract's size limit for one file (§3.5). */\nexport const DEFAULT_MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;\n/** How many files `<FeedbackAttachmentField multiple>` takes when `max` is not given\n * (0.15.5). Five photos of one problem is already a lot to look through; a report\n * that needs more is a conversation, which the thread is for. */\nexport const DEFAULT_MAX_ATTACHMENTS = 5;\n\n/**\n * What a report may carry (§3.5, keksdose `upload_guards.py:197` and its\n * `attachment-options.ts`): the kit's four image types plus a PDF and a plain-text log\n * (keksdose feedback #87). SVG and HTML stay out — both are script-carrying documents in\n * an image's clothing. For `FeedbackAttachmentField` / `FeedbackDialog`'s `accept`, with\n * `DEFAULT_MAX_ATTACHMENTS` (5) and `DEFAULT_MAX_ATTACHMENT_BYTES` (10 MB) above, which\n * already are the contract's limits.\n *\n * A plain array (not frozen) because `accept` takes `string[]`, as\n * `DEFAULT_ATTACHMENT_ACCEPT` does — copy it before changing it.\n */\nexport const FEEDBACK_ATTACHMENT_ACCEPT: string[] = [\n ...DEFAULT_ATTACHMENT_ACCEPT,\n \"application/pdf\",\n \"text/plain\",\n];\n\n/**\n * The categories a person can pick — every one but `CRASH`, in triage order (Bug, Idea,\n * Question, Other: the feedback menu's rows, §4.1). `CRASH` is filed by an error boundary\n * and the server refuses it by hand with a 422 (keksdose `_reject_manual_crash`), so no\n * picker may offer it.\n */\nexport const FEEDBACK_PICKABLE_CATEGORIES: readonly FeedbackCategory[] = Object.freeze(\n FEEDBACK_CATEGORY_ORDER.filter((category) => category !== \"CRASH\"),\n);\n\n/**\n * The statuses a report can be sent back for **rework** from (§3.4): everything the team\n * has answered — `IN_EVALUATION`, `NEEDS_LIVE_TEST`, `POSTPONED`, `DONE`, `WONT_DO`. On\n * these the server reopens the row when the body grows by a rework block; on `OPEN`,\n * `READY` and `IN_PROGRESS` there is nothing to send back yet.\n */\nexport const FEEDBACK_REWORKABLE_STATUSES: readonly FeedbackStatus[] = Object.freeze([\n \"IN_EVALUATION\",\n \"NEEDS_LIVE_TEST\",\n \"POSTPONED\",\n \"DONE\",\n \"WONT_DO\",\n] as const);\n\n/**\n * The statuses in which the AUTHOR may still edit title, body and category (§3.4,\n * keksdose `canAuthorEdit`, `feedback-page.tsx:398`): `OPEN`, `READY` and `IN_PROGRESS`.\n * Once the team has answered, the description is what they answered and stays as it\n * was; a correction goes in as a rework.\n */\nexport const FEEDBACK_AUTHOR_EDITABLE_STATUSES: readonly FeedbackStatus[] = Object.freeze([\n \"OPEN\",\n \"READY\",\n \"IN_PROGRESS\",\n] as const);\n\n/**\n * The statuses that wait on the person triaging: filed and not yet triaged (`OPEN`,\n * since READY took over \"released for implementation\" in 0.31, feedback contract §8.2),\n * answered and handed back for a verdict, or answered and only checkable on a deployed\n * build (keksdose `AWAITING_VERDICT`, live #330). The phone's \"Only what is waiting for\n * you\" toggle narrows the inbox to exactly these (§4.3).\n */\nexport const FEEDBACK_AWAITING_STATUSES: readonly FeedbackStatus[] = Object.freeze([\n \"OPEN\",\n \"IN_EVALUATION\",\n \"NEEDS_LIVE_TEST\",\n] as const);\n\n/* ── The body (§3.4) ──────────────────────────────────────────────────────── */\n\n/**\n * The path every app serves attachments under (§3.3), and a key after it. Keys are\n * OPAQUE (§3.5): keksdose and Kurvenschmiede content-address (`<sha12>.<ext>`), kastlan's\n * storage keys are `<uuid32>_<sha12>.<ext>` — so `[\\w.-]+`, never a fixed hex shape.\n */\nconst ATTACHMENT_URL = /^\\/api\\/v1\\/feedback\\/attachments\\/[\\w.-]+$/;\n\n/**\n * One file line in a body. The marker is deliberately narrow — this path and nothing\n * else, alone on its line — so no sentence a user writes can be mistaken for one\n * (keksdose live #291). It says `[screenshot]` for a PDF or a text log too: the name is\n * history, the format is contract.\n */\nconst ATTACHMENT_LINE = /^\\[screenshot\\]\\s+(\\/api\\/v1\\/feedback\\/attachments\\/[\\w.-]+)\\s*$/;\n\n/**\n * The `--- REWORK <stamp> ---` rule a rework opens with. Anchored and whole-line for the\n * same reason as the file marker: \"I did a REWORK --- honestly\" is a sentence, not a\n * round. kastlan's folded `--- COMMENT <stamp> · <name> ---` blocks (§7.7) never match.\n */\nconst REWORK_RULE = /^---\\s*REWORK\\b.*---$/;\n\n/** Any appended block's opening rule: a rework round, or a kastlan comment folded into\n * the body by its one-time migration (§7.7). */\nconst BLOCK_RULE = /^---\\s*(?:REWORK|COMMENT)\\b.*---$/;\n\n/** The body line for one uploaded attachment — what {@link appendRework} writes under\n * the note. */\nexport function feedbackAttachmentLine(url: string): string {\n return `[screenshot] ${url}`;\n}\n\n/**\n * A rework round appended to a body — the exact text `PATCH /feedback/{id}` takes as the\n * new `body` (§3.4; keksdose `submitRework`, `feedback-page.tsx:350`):\n *\n * ```text\n * <old body>\\n\\n--- REWORK 2026-10-04 09:12 ---\\n<note>\\n[screenshot] /api/v1/feedback/attachments/<key>\n * ```\n *\n * - The stamp is UTC, `YYYY-MM-DD HH:MM` (`toISOString().slice(0, 16)`), from `now`.\n * - The old body is kept byte for byte, so the result STRICTLY EXTENDS it — which is\n * how the server recognises an append and reopens an answered row (keksdose\n * `_is_rework_append`, live #331). `\\n\\n` is left out when the old body is `\"\"`.\n * - ONE file per round (`url`), uploaded first by the caller: a body appended without\n * it would be a rework whose evidence never arrived.\n *\n * **Returns `null` when the trimmed note is empty** — a file alone cannot be sent\n * (keksdose `:577`). Null rather than a throw because an empty note is something a\n * person does, not a bug, and the type then makes every caller decide what an empty\n * box means before anything can reach the PATCH.\n *\n * **Throws a `TypeError` when `url` is not an attachment URL** of the contract's shape\n * (`/api/v1/feedback/attachments/<key>`): that one IS a bug — the upload handed back\n * something foreign — and written anyway it would sit in the body as prose that no\n * reader recognises as a file.\n */\nexport function appendRework(\n body: string,\n note: string,\n url?: string | null,\n now: Date = new Date(),\n): string | null {\n const text = note.trim();\n if (!text) return null;\n if (url && !ATTACHMENT_URL.test(url)) {\n throw new TypeError(`appendRework: not a feedback attachment URL: ${url}`);\n }\n const stamp = now.toISOString().slice(0, 16).replace(\"T\", \" \");\n const block = `--- REWORK ${stamp} ---\\n${url ? `${text}\\n${feedbackAttachmentLine(url)}` : text}`;\n return body ? `${body}\\n\\n${block}` : block;\n}\n\n/**\n * How many times a report has been sent back — the count of `--- REWORK … ---` rule\n * lines in its body (keksdose live #331: the \"category for items in rework\", derived\n * rather than stored, so nothing can forget to set it or leave it set). Folded kastlan\n * comments do not count.\n */\nexport function reworkCount(body: string): number {\n let n = 0;\n for (const line of body.split(\"\\n\")) if (REWORK_RULE.test(line.trim())) n += 1;\n return n;\n}\n\n/**\n * A body split into the prose to render and the files to show beside it, in body order.\n *\n * The file lines are stripped from the text: they are a location, not something anybody\n * wrote, and left in they would put a raw URL in the middle of a sentence. Trailing blank\n * lines go (what a stripped marker leaves at the end of a note); every blank line between\n * paragraphs stays.\n */\nexport function splitBodyAttachments(body: string): { text: string; urls: string[] } {\n const urls: string[] = [];\n const kept: string[] = [];\n for (const line of body.split(\"\\n\")) {\n const match = ATTACHMENT_LINE.exec(line.trim());\n if (match) urls.push(match[1]);\n else kept.push(line);\n }\n return { text: kept.join(\"\\n\").replace(/\\n+$/, \"\"), urls };\n}\n\n/** A body cut where its first appended block begins. */\nfunction cutAtFirstBlock(body: string): { head: string; appended: string } {\n const lines = body.split(\"\\n\");\n const at = lines.findIndex((line) => BLOCK_RULE.test(line.trim()));\n if (at === -1) return { head: body, appended: \"\" };\n return { head: lines.slice(0, at).join(\"\\n\"), appended: lines.slice(at).join(\"\\n\") };\n}\n\n/**\n * The ORIGINAL description, apart from everything appended to it since (§4.4.1).\n *\n * - `description` — what the author wrote when filing, without its file lines and\n * trailing blank lines: the text the \"Edit description\" editor holds.\n * - `appended` — every `--- REWORK … ---` round and folded `--- COMMENT … ---` block,\n * from the first one's rule line to the end, verbatim (`\"\"` when there are none).\n *\n * keksdose's editor edits the raw body (`initial={fb.body}`, `feedback-page.tsx:420`), so\n * an author tidying a typo could delete the rework history and the file lines with it.\n * The kit's editor holds `description` only and saves through\n * {@link replaceDescription}, which puts the rest back unchanged.\n */\nexport function splitDescription(body: string): { description: string; appended: string } {\n const { head, appended } = cutAtFirstBlock(body);\n return { description: splitBodyAttachments(head).text, appended };\n}\n\n/**\n * The body with its original description replaced and everything else kept — the file\n * lines of the original part (after the new text, in their order) and the appended\n * blocks (verbatim, after a blank line). The new text is trimmed; clearing it saves the\n * rest alone (`\"\"` when there is no rest).\n *\n * `replaceDescription(body, splitDescription(body).description)` gives back a canonical\n * body unchanged — a trimmed description, then each block after one blank line, as the\n * dialog and {@link appendRework} write them.\n */\nexport function replaceDescription(body: string, description: string): string {\n const { head, appended } = cutAtFirstBlock(body);\n const files = splitBodyAttachments(head).urls.map(feedbackAttachmentLine);\n const text = description.trim();\n const top = [...(text ? [text] : []), ...files].join(\"\\n\");\n if (!appended) return top;\n return top ? `${top}\\n\\n${appended}` : appended;\n}\n\n/**\n * Whether an attachment URL is a picture (keksdose dev #578). The upload route takes\n * PDFs and text logs too and serves them as downloads, never inline, so an `<img>` on\n * one shows a broken icon. The key's extension is the server's own statement of the\n * type (minted from the sniffed content), so it is the thing to read.\n */\nexport function isImageAttachment(url: string): boolean {\n return /\\.(png|jpe?g|webp|gif)$/i.test(url);\n}\n\n/** The file name an attachment downloads as — its key, the last segment of the URL. */\nexport function attachmentName(url: string): string {\n return url.slice(url.lastIndexOf(\"/\") + 1);\n}\n"],"mappings":";AAAA,SAAS,+BAA+B;AA2HjC,MAAM,4BAA4B,CAAC,aAAa,cAAc,cAAc,WAAW;AAEvF,MAAM,+BAA+B,KAAK,OAAO;AAI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AAe,KAAqB;AAClD,SAAO,IAAI,MAAM,IAAI,YAAY,GAAG,IAAI,CAAC;AAC3C;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/feedback-record.ts"],"sourcesContent":["import { FEEDBACK_CATEGORY_ORDER } from \"./feedback-vocabulary\";\nimport type { FeedbackCategory, FeedbackStatus } from \"./feedback-vocabulary\";\nimport type { FeedbackReply } from \"./feedback-public-types\";\n\n/**\n * One feedback report as the three apps send it, and the facts the kit reads off it.\n *\n * Until 0.27 the inbox parts took no report at all (\"no `Feedback` type in this file\",\n * feedback-inbox.tsx): keksdose kept its reporter context in a JSON column, kastlan a\n * thinner copy of it, Kurvenschmiede a `page_path` and the bytes in the row. Marcel's\n * feedback round (2026-10-04, docs/feedback-harmonization.md) settled one API contract\n * for all three — keksdose's, read off its code — so the apps now share one shape and the\n * kit can take a row instead of a dozen loose values. This file is that shape (§3.1,\n * §3.2), the contract's constants (§3.4, §3.5, §4.3) and the readers and writers of the\n * one field whose format is itself contract: the body, which carries the rework rounds\n * (§3.4) — lifted from keksdose `frontend/src/features/feedback/body-attachments.ts`.\n *\n * Plain functions and data, no components: everything here is as usable from a loop\n * script's helper or a test as from a page.\n */\n\n/* ── The resource (§3.1, §3.2) ────────────────────────────────────────────── */\n\n/** Which copy of an app a report came from — keksdose `app/deploy-environment.ts`.\n * Any other string is read as \"not prod\" (the admin list shows it upper-cased as a\n * chip, §4.3), so an app with a `staging` loses nothing. */\nexport type FeedbackEnvironment = \"prod\" | \"dev\" | \"local\";\n\n/**\n * The reporter's context, written by the submit dialog (keksdose\n * `use-feedback-dialog.tsx:105`) — §3.2 of the contract.\n *\n * **Every key is optional on read**, and a reader treats a missing one as \"unknown\":\n * kastlan's client sends six of them (no email, no version), Kurvenschmiede's old rows are\n * backfilled from two columns with a path-only `url`, crash rows add their own (and\n * `origin` / `environment` from the crash payload, §3.6 — older crash rows have neither),\n * and an erased account's row keeps only an allow-list (§3.2: `environment` stays,\n * `origin` goes). Extra keys are allowed — a server may add its own — hence the index\n * signature.\n */\nexport interface FeedbackContext {\n /** The full `location.href` at open time; `\"\"` when \"Attach current page URL\" was off.\n * Readers also accept a path-only value (Kurvenschmiede's backfilled rows). */\n url?: string;\n /** Its pathname; `\"\"` when the URL was withheld. */\n route?: string;\n /** `location.origin` — which copy of the app, not personal; never withheld. */\n origin?: string;\n /** {@link FeedbackEnvironment}, or whatever the app calls its other copies. */\n environment?: FeedbackEnvironment | (string & {});\n /** The submitter, as a snapshot. The server should overwrite the three `user_*` keys\n * from the session (Kurvenschmiede does), so nobody files in someone else's name. */\n user_id?: number | null;\n user_email?: string | null;\n user_display_name?: string | null;\n /** `\"406x816\"`. */\n viewport?: string;\n /** `navigator.userAgent`. */\n ua?: string;\n /** The app build (`__APP_VERSION__`). */\n version?: string;\n // Crash rows (server-written, keksdose `feedback_service.py:346`).\n fingerprint?: string;\n /** Which error boundary caught it. */\n boundary?: \"app\" | \"page\" | (string & {});\n online?: boolean;\n occurrences?: number;\n first_seen_at?: string;\n last_seen_at?: string;\n auto_reported?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * One report — `FeedbackResponse`, keksdose `schemas/feedback.py:117`, §3.1 of the\n * contract. What `GET /feedback`, `GET /feedback/my`, `POST /feedback` and\n * `PATCH /feedback/{id}` answer in all three apps.\n *\n * Extra fields are allowed and ignored (kastlan's `company_id`, `user_name`): an app's\n * own row type with more fields is assignable to this one as it stands.\n *\n * There is **no rework counter field** — {@link reworkCount} reads it off the body, so\n * nothing can forget to set it.\n */\nexport interface FeedbackRecord {\n id: number;\n /** `null`: the author's account was erased (keksdose live #275). */\n user_id: number | null;\n /** The admin list only (joined); `null` — or absent — on `/my`, create and update. */\n user_email?: string | null;\n /** 1–255 characters, never blank. */\n title: string;\n /** `\"\"` when none. Rework rounds are appended here (§3.4) — read it with\n * {@link splitDescription} / {@link splitBodyAttachments}, write it with\n * {@link appendRework} / {@link replaceDescription}. */\n body: string;\n category: FeedbackCategory;\n status: FeedbackStatus;\n /** §3.2; `null` on rows that have none. */\n context: FeedbackContext | null;\n /** The ONE captured screenshot's attachment URL, or `null`. */\n screenshot_url: string | null;\n /** Up to 5 other files; `null` = none. Optional because a server older than the\n * column sends no key at all (keksdose dev #578 met exactly that). */\n attachment_urls?: string[] | null;\n /** The team's answer; `null` = none written. **Frozen since 0.38** (§9.7): answered\n * as stored for one release, written by nothing, then dropped — the answer is\n * {@link FeedbackRecord.replies} now. */\n outcome: string | null;\n /** Set on ENTERING `DONE` / `WONT_DO`, cleared on leaving them. ISO 8601. */\n resolved_at: string | null;\n /** ISO 8601. */\n created_at: string;\n /** ISO 8601. */\n updated_at: string;\n // ── Round 0.38 (§9.3): all optional, so an app without public parts sends none. ──\n /** The admin: the full name; the author: their own; `null`: none to show. */\n author_name?: string | null;\n /** The viewer filed it. */\n mine?: boolean;\n /** Visible to the app's other users (§9.3); never on a CRASH. */\n public?: boolean;\n /** Made public by the 0.38 migration: the author may switch it off at any status. */\n filed_private?: boolean;\n /** People who want this (the author's own vote included, §9.6). */\n votes?: number;\n /** The viewer's vote. */\n voted?: boolean;\n /** Comments (an admin's count includes hidden ones). */\n comment_count?: number;\n /** The admin's answers, oldest first (§9.7). Absent: a server before 0.38 — read\n * `outcome` instead. */\n replies?: FeedbackReply[];\n}\n\n/* ── Constants (§3.4, §3.5, §4.3) ─────────────────────────────────────────── */\n\n// The attachment field's three defaults live here, not in feedback-attachment.tsx\n// (which re-exports them), since 0.34 (MOD-1, refactor audit 2026-10). This module is in\n// every app's top bar (the menu's categories), and FEEDBACK_ATTACHMENT_ACCEPT below is\n// built on DEFAULT_ATTACHMENT_ACCEPT: imported from the field's module, it tied the top\n// bar to the field, the lazily loaded dialog's heaviest part, for three values.\n\n/** The image types `FeedbackAttachmentField` takes when `accept` is not given. */\nexport const DEFAULT_ATTACHMENT_ACCEPT = [\"image/png\", \"image/jpeg\", \"image/webp\", \"image/gif\"];\n/** 10 MB, the contract's size limit for one file (§3.5). */\nexport const DEFAULT_MAX_ATTACHMENT_BYTES = 10 * 1024 * 1024;\n/** How many files `<FeedbackAttachmentField multiple>` takes when `max` is not given\n * (0.15.5). Five photos of one problem is already a lot to look through; a report\n * that needs more is a conversation, which the thread is for. */\nexport const DEFAULT_MAX_ATTACHMENTS = 5;\n\n/**\n * What a report may carry (§3.5, keksdose `upload_guards.py:197` and its\n * `attachment-options.ts`): the kit's four image types plus a PDF and a plain-text log\n * (keksdose feedback #87). SVG and HTML stay out — both are script-carrying documents in\n * an image's clothing. For `FeedbackAttachmentField` / `FeedbackDialog`'s `accept`, with\n * `DEFAULT_MAX_ATTACHMENTS` (5) and `DEFAULT_MAX_ATTACHMENT_BYTES` (10 MB) above, which\n * already are the contract's limits.\n *\n * A plain array (not frozen) because `accept` takes `string[]`, as\n * `DEFAULT_ATTACHMENT_ACCEPT` does — copy it before changing it.\n */\nexport const FEEDBACK_ATTACHMENT_ACCEPT: string[] = [\n ...DEFAULT_ATTACHMENT_ACCEPT,\n \"application/pdf\",\n \"text/plain\",\n];\n\n/**\n * The categories a person can pick — every one but `CRASH`, in triage order (Bug, Idea,\n * Question, Other: the feedback menu's rows, §4.1). `CRASH` is filed by an error boundary\n * and the server refuses it by hand with a 422 (keksdose `_reject_manual_crash`), so no\n * picker may offer it.\n */\nexport const FEEDBACK_PICKABLE_CATEGORIES: readonly FeedbackCategory[] = Object.freeze(\n FEEDBACK_CATEGORY_ORDER.filter((category) => category !== \"CRASH\"),\n);\n\n/**\n * The statuses a report can be sent back for **rework** from (§3.4): everything the team\n * has answered — `IN_EVALUATION`, `NEEDS_LIVE_TEST`, `POSTPONED`, `DONE`, `WONT_DO`. On\n * these the server reopens the row when the body grows by a rework block; on `OPEN`,\n * `READY` and `IN_PROGRESS` there is nothing to send back yet.\n */\nexport const FEEDBACK_REWORKABLE_STATUSES: readonly FeedbackStatus[] = Object.freeze([\n \"IN_EVALUATION\",\n \"NEEDS_LIVE_TEST\",\n \"POSTPONED\",\n \"DONE\",\n \"WONT_DO\",\n] as const);\n\n/**\n * The statuses in which the AUTHOR may still edit title, body and category (§3.4,\n * keksdose `canAuthorEdit`, `feedback-page.tsx:398`): `OPEN`, `READY` and `IN_PROGRESS`.\n * Once the team has answered, the description is what they answered and stays as it\n * was; a correction goes in as a rework.\n */\nexport const FEEDBACK_AUTHOR_EDITABLE_STATUSES: readonly FeedbackStatus[] = Object.freeze([\n \"OPEN\",\n \"READY\",\n \"IN_PROGRESS\",\n] as const);\n\n/**\n * The statuses that wait on the person triaging: filed and not yet triaged (`OPEN`,\n * since READY took over \"released for implementation\" in 0.31, feedback contract §8.2),\n * answered and handed back for a verdict, or answered and only checkable on a deployed\n * build (keksdose `AWAITING_VERDICT`, live #330). The phone's \"Only what is waiting for\n * you\" toggle narrows the inbox to exactly these (§4.3).\n */\nexport const FEEDBACK_AWAITING_STATUSES: readonly FeedbackStatus[] = Object.freeze([\n \"OPEN\",\n \"IN_EVALUATION\",\n \"NEEDS_LIVE_TEST\",\n] as const);\n\n/**\n * The **decided** statuses (§9.7, decision 13): `DONE`, `WONT_DO`, `POSTPONED`. A\n * status-only move into one tells the author nothing (a status alone sends no\n * notification), so the row detail nudges the admin toward a reply until one with that\n * `status_to` exists.\n */\nexport const FEEDBACK_DECIDED_STATUSES: readonly FeedbackStatus[] = Object.freeze([\n \"DONE\",\n \"WONT_DO\",\n \"POSTPONED\",\n] as const);\n\n/** A comment's longest body after trimming (§9.8). */\nexport const FEEDBACK_COMMENT_MAX = 4000;\n/** A reply's longest body after trimming (§9.7). */\nexport const FEEDBACK_REPLY_MAX = 8000;\n\n/* ── The body (§3.4) ──────────────────────────────────────────────────────── */\n\n/**\n * The path every app serves attachments under (§3.3), and a key after it. Keys are\n * OPAQUE (§3.5): keksdose and Kurvenschmiede content-address (`<sha12>.<ext>`), kastlan's\n * storage keys are `<uuid32>_<sha12>.<ext>` — so `[\\w.-]+`, never a fixed hex shape.\n */\nconst ATTACHMENT_URL = /^\\/api\\/v1\\/feedback\\/attachments\\/[\\w.-]+$/;\n\n/**\n * One file line in a body. The marker is deliberately narrow — this path and nothing\n * else, alone on its line — so no sentence a user writes can be mistaken for one\n * (keksdose live #291). It says `[screenshot]` for a PDF or a text log too: the name is\n * history, the format is contract.\n */\nconst ATTACHMENT_LINE = /^\\[screenshot\\]\\s+(\\/api\\/v1\\/feedback\\/attachments\\/[\\w.-]+)\\s*$/;\n\n/**\n * The `--- REWORK <stamp> ---` rule a rework opens with. Anchored and whole-line for the\n * same reason as the file marker: \"I did a REWORK --- honestly\" is a sentence, not a\n * round. kastlan's folded `--- COMMENT <stamp> · <name> ---` blocks (§7.7) never match.\n */\nconst REWORK_RULE = /^---\\s*REWORK\\b.*---$/;\n\n/** Any appended block's opening rule: a rework round, or a kastlan comment folded into\n * the body by its one-time migration (§7.7). */\nconst BLOCK_RULE = /^---\\s*(?:REWORK|COMMENT)\\b.*---$/;\n\n/** The body line for one uploaded attachment — what {@link appendRework} writes under\n * the note. */\nexport function feedbackAttachmentLine(url: string): string {\n return `[screenshot] ${url}`;\n}\n\n/**\n * A rework round appended to a body — the exact text `PATCH /feedback/{id}` takes as the\n * new `body` (§3.4; keksdose `submitRework`, `feedback-page.tsx:350`):\n *\n * ```text\n * <old body>\\n\\n--- REWORK 2026-10-04 09:12 ---\\n<note>\\n[screenshot] /api/v1/feedback/attachments/<key>\n * ```\n *\n * - The stamp is UTC, `YYYY-MM-DD HH:MM` (`toISOString().slice(0, 16)`), from `now`.\n * - The old body is kept byte for byte, so the result STRICTLY EXTENDS it — which is\n * how the server recognises an append and reopens an answered row (keksdose\n * `_is_rework_append`, live #331). `\\n\\n` is left out when the old body is `\"\"`.\n * - ONE file per round (`url`), uploaded first by the caller: a body appended without\n * it would be a rework whose evidence never arrived.\n *\n * **Returns `null` when the trimmed note is empty** — a file alone cannot be sent\n * (keksdose `:577`). Null rather than a throw because an empty note is something a\n * person does, not a bug, and the type then makes every caller decide what an empty\n * box means before anything can reach the PATCH.\n *\n * **Throws a `TypeError` when `url` is not an attachment URL** of the contract's shape\n * (`/api/v1/feedback/attachments/<key>`): that one IS a bug — the upload handed back\n * something foreign — and written anyway it would sit in the body as prose that no\n * reader recognises as a file.\n */\nexport function appendRework(\n body: string,\n note: string,\n url?: string | null,\n now: Date = new Date(),\n): string | null {\n const text = note.trim();\n if (!text) return null;\n if (url && !ATTACHMENT_URL.test(url)) {\n throw new TypeError(`appendRework: not a feedback attachment URL: ${url}`);\n }\n const stamp = now.toISOString().slice(0, 16).replace(\"T\", \" \");\n const block = `--- REWORK ${stamp} ---\\n${url ? `${text}\\n${feedbackAttachmentLine(url)}` : text}`;\n return body ? `${body}\\n\\n${block}` : block;\n}\n\n/**\n * How many times a report has been sent back — the count of `--- REWORK … ---` rule\n * lines in its body (keksdose live #331: the \"category for items in rework\", derived\n * rather than stored, so nothing can forget to set it or leave it set). Folded kastlan\n * comments do not count.\n */\nexport function reworkCount(body: string): number {\n let n = 0;\n for (const line of body.split(\"\\n\")) if (REWORK_RULE.test(line.trim())) n += 1;\n return n;\n}\n\n/**\n * A body split into the prose to render and the files to show beside it, in body order.\n *\n * The file lines are stripped from the text: they are a location, not something anybody\n * wrote, and left in they would put a raw URL in the middle of a sentence. Trailing blank\n * lines go (what a stripped marker leaves at the end of a note); every blank line between\n * paragraphs stays.\n */\nexport function splitBodyAttachments(body: string): { text: string; urls: string[] } {\n const urls: string[] = [];\n const kept: string[] = [];\n for (const line of body.split(\"\\n\")) {\n const match = ATTACHMENT_LINE.exec(line.trim());\n if (match) urls.push(match[1]);\n else kept.push(line);\n }\n return { text: kept.join(\"\\n\").replace(/\\n+$/, \"\"), urls };\n}\n\n/** A body cut where its first appended block begins. */\nfunction cutAtFirstBlock(body: string): { head: string; appended: string } {\n const lines = body.split(\"\\n\");\n const at = lines.findIndex((line) => BLOCK_RULE.test(line.trim()));\n if (at === -1) return { head: body, appended: \"\" };\n return { head: lines.slice(0, at).join(\"\\n\"), appended: lines.slice(at).join(\"\\n\") };\n}\n\n/**\n * The ORIGINAL description, apart from everything appended to it since (§4.4.1).\n *\n * - `description` — what the author wrote when filing, without its file lines and\n * trailing blank lines: the text the \"Edit description\" editor holds.\n * - `appended` — every `--- REWORK … ---` round and folded `--- COMMENT … ---` block,\n * from the first one's rule line to the end, verbatim (`\"\"` when there are none).\n *\n * keksdose's editor edits the raw body (`initial={fb.body}`, `feedback-page.tsx:420`), so\n * an author tidying a typo could delete the rework history and the file lines with it.\n * The kit's editor holds `description` only and saves through\n * {@link replaceDescription}, which puts the rest back unchanged.\n */\nexport function splitDescription(body: string): { description: string; appended: string } {\n const { head, appended } = cutAtFirstBlock(body);\n return { description: splitBodyAttachments(head).text, appended };\n}\n\n/**\n * The body with its original description replaced and everything else kept — the file\n * lines of the original part (after the new text, in their order) and the appended\n * blocks (verbatim, after a blank line). The new text is trimmed; clearing it saves the\n * rest alone (`\"\"` when there is no rest).\n *\n * `replaceDescription(body, splitDescription(body).description)` gives back a canonical\n * body unchanged — a trimmed description, then each block after one blank line, as the\n * dialog and {@link appendRework} write them.\n */\nexport function replaceDescription(body: string, description: string): string {\n const { head, appended } = cutAtFirstBlock(body);\n const files = splitBodyAttachments(head).urls.map(feedbackAttachmentLine);\n const text = description.trim();\n const top = [...(text ? [text] : []), ...files].join(\"\\n\");\n if (!appended) return top;\n return top ? `${top}\\n\\n${appended}` : appended;\n}\n\n/**\n * Whether an attachment URL is a picture (keksdose dev #578). The upload route takes\n * PDFs and text logs too and serves them as downloads, never inline, so an `<img>` on\n * one shows a broken icon. The key's extension is the server's own statement of the\n * type (minted from the sniffed content), so it is the thing to read.\n */\nexport function isImageAttachment(url: string): boolean {\n return /\\.(png|jpe?g|webp|gif)$/i.test(url);\n}\n\n/** The file name an attachment downloads as — its key, the last segment of the URL. */\nexport function attachmentName(url: string): string {\n return url.slice(url.lastIndexOf(\"/\") + 1);\n}\n"],"mappings":";AAAA,SAAS,+BAA+B;AAgJjC,MAAM,4BAA4B,CAAC,aAAa,cAAc,cAAc,WAAW;AAEvF,MAAM,+BAA+B,KA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AM,GAAG,GAAG;AAAA;AAAA,EAAO,QAAQ,KAAK;AACzC;AAQO,SAAS,kBAAkB,KAAsB;AACtD,SAAO,2BAA2B,KAAK,GAAG;AAC5C;AAGO,SAAS,eAAe,KAAqB;AAClD,SAAO,IAAI,MAAM,IAAI,YAAY,GAAG,IAAI,CAAC;AAC3C;","names":[]}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { CommitScope } from "../components/write-lock.js";
|
|
2
|
+
import { type LabelOverride } from "../i18n/kit-labels.js";
|
|
3
|
+
import { type FeedbackStatus } from "./feedback-inbox.js";
|
|
4
|
+
import type { FeedbackReply } from "./feedback-public-types.js";
|
|
5
|
+
import { DEFAULT_FEEDBACK_REPLIES_LABELS } from "./feedback-thread-parts-labels.js";
|
|
6
|
+
/**
|
|
7
|
+
* The admin's answers as a list (docs/feedback-harmonization.md §9.7, decision 5): each
|
|
8
|
+
* reply its own row — who, when, what, and the status it moved the report to — where
|
|
9
|
+
* 0.37 had one `outcome` field that every answer overwrote. {@link FeedbackReplyTimeline}
|
|
10
|
+
* draws them; {@link FeedbackReplyComposer} writes the next one, with the status picker
|
|
11
|
+
* beside it (decision 13: a reply notifies the author, a status alone does not, so the
|
|
12
|
+
* status belongs with the words).
|
|
13
|
+
*/
|
|
14
|
+
/** The `feedbackReplies` namespace of `<UiKitProvider labels>`. */
|
|
15
|
+
export interface FeedbackRepliesLabels {
|
|
16
|
+
/** The timeline's accessible name. de-CH: "Antworten" */
|
|
17
|
+
replies: string;
|
|
18
|
+
/** No reply yet. de-CH: "Noch keine Antwort" */
|
|
19
|
+
empty: string;
|
|
20
|
+
/** A reply without an author — a loop's, a migrated outcome, an erased admin (§9.7).
|
|
21
|
+
* The app's word for its admin; never "the team". de-CH: "Admin" */
|
|
22
|
+
admin: string;
|
|
23
|
+
/** Read before a reply's status chip ("→ Done"). de-CH: "Status geändert auf" */
|
|
24
|
+
statusChanged: string;
|
|
25
|
+
/** The reply box's accessible name. de-CH: "Antwort schreiben" */
|
|
26
|
+
field: string;
|
|
27
|
+
/** de-CH: "Antwort schreiben…" */
|
|
28
|
+
placeholder: string;
|
|
29
|
+
/** The send button. de-CH: "Antworten" */
|
|
30
|
+
reply: string;
|
|
31
|
+
/** The status picker's accessible name. de-CH: "Status mit der Antwort" */
|
|
32
|
+
status: string;
|
|
33
|
+
/** The picker's first option: the reply changes no status. de-CH: "Keine Änderung" */
|
|
34
|
+
noChange: string;
|
|
35
|
+
/** Above the composer when a decided status was set without a reply (§9.7, B2).
|
|
36
|
+
* de-CH: "Die meldende Person wurde nicht benachrichtigt. Schreiben Sie eine Antwort." */
|
|
37
|
+
nudge: string;
|
|
38
|
+
}
|
|
39
|
+
export { DEFAULT_FEEDBACK_REPLIES_LABELS };
|
|
40
|
+
/** `feedbackReplies` resolved: English, then `<UiKitProvider labels>`, then `labels`. */
|
|
41
|
+
export declare function useFeedbackRepliesLabels(labels?: LabelOverride<FeedbackRepliesLabels>): FeedbackRepliesLabels;
|
|
42
|
+
/**
|
|
43
|
+
* The status a row detail should nudge toward (§9.7, B2), or `undefined`: the row's
|
|
44
|
+
* status when it is decided ({@link FEEDBACK_DECIDED_STATUSES}) and no reply carries it
|
|
45
|
+
* as its `status_to` — a status-only move from the table, a swipe or the pills told the
|
|
46
|
+
* author nothing. `undefined` too without `replies` (a server before 0.38).
|
|
47
|
+
*/
|
|
48
|
+
export declare function feedbackReplyNudge(row: {
|
|
49
|
+
status: FeedbackStatus;
|
|
50
|
+
replies?: readonly Pick<FeedbackReply, "status_to">[] | null;
|
|
51
|
+
}): FeedbackStatus | undefined;
|
|
52
|
+
export interface FeedbackReplyTimelineProps {
|
|
53
|
+
/** Oldest first, as the server sends them. */
|
|
54
|
+
replies: readonly FeedbackReply[];
|
|
55
|
+
/** How a reply's time reads. Default: the date and time in the provider's locale. */
|
|
56
|
+
renderDate?: (iso: string) => string;
|
|
57
|
+
/** Tag bodies and names `data-private` (a host's screen-share blur). Default true. */
|
|
58
|
+
redact?: boolean;
|
|
59
|
+
labels?: LabelOverride<FeedbackRepliesLabels>;
|
|
60
|
+
className?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The replies, oldest first, down a rule: each with its author (`null` → "Admin"), its
|
|
64
|
+
* time, the status it set ("→ Done"; the admin view adds where from) and its text. No
|
|
65
|
+
* edit and no delete (§9.7): a correction is a new reply.
|
|
66
|
+
*/
|
|
67
|
+
export declare function FeedbackReplyTimeline({ replies, renderDate, redact, labels: labelsProp, className, }: FeedbackReplyTimelineProps): import("react").JSX.Element;
|
|
68
|
+
export interface FeedbackReplyComposerProps {
|
|
69
|
+
/** The report's status now — what "No change" keeps. */
|
|
70
|
+
status: FeedbackStatus;
|
|
71
|
+
/**
|
|
72
|
+
* `POST /feedback/{id}/replies` — the body (1–{@link FEEDBACK_REPLY_MAX} after
|
|
73
|
+
* trimming) and the status picked, `undefined` for "No change". Return the promise:
|
|
74
|
+
* the box clears when it resolves, and keeps everything on a rejection.
|
|
75
|
+
*/
|
|
76
|
+
onReply: (body: string, status?: FeedbackStatus) => void | Promise<unknown>;
|
|
77
|
+
/** The reply is in flight. */
|
|
78
|
+
pending?: boolean;
|
|
79
|
+
/** Preselect this status and say the author has not been told (§9.7, the nudge) —
|
|
80
|
+
* {@link feedbackReplyNudge}. */
|
|
81
|
+
suggestedStatus?: FeedbackStatus;
|
|
82
|
+
/** Reply COMMITS — see ChatComposer's `commit`. */
|
|
83
|
+
commit?: CommitScope;
|
|
84
|
+
labels?: LabelOverride<FeedbackRepliesLabels>;
|
|
85
|
+
className?: string;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The admin's reply box (§9.7): the text, the **status** to set with it ("No change"
|
|
89
|
+
* first, then every status — {@link selectableFeedbackStatuses}), and **Reply**. A
|
|
90
|
+
* {@link ChatComposer} underneath: Ctrl/⌘+Enter sends, the count runs to 8 000, a draft
|
|
91
|
+
* typed while a reply is in flight stays.
|
|
92
|
+
*
|
|
93
|
+
* With `suggestedStatus` the line "The author has not been told. Add a reply." stands
|
|
94
|
+
* above it and that status is picked, so the reply that answers it records the status
|
|
95
|
+
* and the nudge goes away.
|
|
96
|
+
*/
|
|
97
|
+
export declare function FeedbackReplyComposer({ status, onReply, pending, suggestedStatus, commit, labels: labelsProp, className, }: FeedbackReplyComposerProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { BellOff } from "lucide-react";
|
|
5
|
+
import { Select } from "../components/select.js";
|
|
6
|
+
import { useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
|
|
7
|
+
import { cn } from "../lib/cn.js";
|
|
8
|
+
import { formatDate } from "../lib/format.js";
|
|
9
|
+
import { FeedbackStatusBadge, selectableFeedbackStatuses } from "./feedback-inbox.js";
|
|
10
|
+
import { useFeedbackStatusLabels } from "./feedback-labels.js";
|
|
11
|
+
import { FEEDBACK_DECIDED_STATUSES, FEEDBACK_REPLY_MAX } from "./feedback-record.js";
|
|
12
|
+
import { ChatComposer } from "./feedback-thread.js";
|
|
13
|
+
import { DEFAULT_FEEDBACK_REPLIES_LABELS } from "./feedback-thread-parts-labels.js";
|
|
14
|
+
function useFeedbackRepliesLabels(labels) {
|
|
15
|
+
return useKitLabels("feedbackReplies", DEFAULT_FEEDBACK_REPLIES_LABELS, labels);
|
|
16
|
+
}
|
|
17
|
+
function feedbackReplyNudge(row) {
|
|
18
|
+
if (!row.replies || !FEEDBACK_DECIDED_STATUSES.includes(row.status)) return void 0;
|
|
19
|
+
return row.replies.some((reply) => reply.status_to === row.status) ? void 0 : row.status;
|
|
20
|
+
}
|
|
21
|
+
function FeedbackReplyTimeline({
|
|
22
|
+
replies,
|
|
23
|
+
renderDate,
|
|
24
|
+
redact = true,
|
|
25
|
+
labels: labelsProp,
|
|
26
|
+
className
|
|
27
|
+
}) {
|
|
28
|
+
const labels = useFeedbackRepliesLabels(labelsProp);
|
|
29
|
+
const locale = useKitLocale();
|
|
30
|
+
const priv = redact ? "" : void 0;
|
|
31
|
+
if (replies.length === 0) {
|
|
32
|
+
return /* @__PURE__ */ jsx("p", { className: cn("text-sm text-placeholder", className), children: labels.empty });
|
|
33
|
+
}
|
|
34
|
+
const dateText = (iso) => renderDate ? renderDate(iso) : formatDate(iso, { dateStyle: "medium", timeStyle: "short" }, { locale });
|
|
35
|
+
return /* @__PURE__ */ jsx("ol", { "aria-label": labels.replies, className: cn("space-y-3 border-s-2 border-subtle ps-3", className), children: replies.map((reply) => /* @__PURE__ */ jsxs("li", { "data-feedback-reply": reply.id, className: "min-w-0 text-sm", children: [
|
|
36
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1 text-caption text-muted", children: [
|
|
37
|
+
/* @__PURE__ */ jsx("span", { "data-private": priv, className: "font-medium text-secondary", children: reply.author_name ?? labels.admin }),
|
|
38
|
+
/* @__PURE__ */ jsx("time", { dateTime: reply.created_at, className: "tabular-nums", children: dateText(reply.created_at) }),
|
|
39
|
+
reply.status_to && /* @__PURE__ */ jsxs("span", { className: "inline-flex min-w-0 max-w-full flex-wrap items-center gap-1", "data-feedback-reply-status": reply.status_to, children: [
|
|
40
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: labels.statusChanged }),
|
|
41
|
+
reply.status_from && reply.status_from !== reply.status_to && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
42
|
+
/* @__PURE__ */ jsx(FeedbackStatusBadge, { status: reply.status_from }),
|
|
43
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, children: "\u2192" })
|
|
44
|
+
] }),
|
|
45
|
+
!reply.status_from && /* @__PURE__ */ jsx("span", { "aria-hidden": true, children: "\u2192" }),
|
|
46
|
+
/* @__PURE__ */ jsx(FeedbackStatusBadge, { status: reply.status_to })
|
|
47
|
+
] })
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ jsx("p", { "data-private": priv, dir: "auto", className: "mt-0.5 whitespace-pre-wrap break-words text-start text-primary", children: reply.body })
|
|
50
|
+
] }, reply.id)) });
|
|
51
|
+
}
|
|
52
|
+
function FeedbackReplyComposer({
|
|
53
|
+
status,
|
|
54
|
+
onReply,
|
|
55
|
+
pending = false,
|
|
56
|
+
suggestedStatus,
|
|
57
|
+
commit,
|
|
58
|
+
labels: labelsProp,
|
|
59
|
+
className
|
|
60
|
+
}) {
|
|
61
|
+
const labels = useFeedbackRepliesLabels(labelsProp);
|
|
62
|
+
const statusNames = useFeedbackStatusLabels();
|
|
63
|
+
const [pick, setPick] = useState({
|
|
64
|
+
under: suggestedStatus,
|
|
65
|
+
value: suggestedStatus ?? ""
|
|
66
|
+
});
|
|
67
|
+
const picked = pick.under === suggestedStatus ? pick.value : suggestedStatus ?? "";
|
|
68
|
+
const send = (body) => {
|
|
69
|
+
const sent = picked;
|
|
70
|
+
return Promise.resolve(onReply(body, sent || void 0)).then(() => {
|
|
71
|
+
setPick((current) => current.value === sent ? { under: suggestedStatus, value: "" } : current);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
return /* @__PURE__ */ jsxs("div", { className: cn("space-y-2", className), "data-feedback-reply-composer": "", children: [
|
|
75
|
+
suggestedStatus && /* @__PURE__ */ jsxs("p", { className: "flex items-start gap-1.5 text-xs text-secondary", "data-feedback-nudge": suggestedStatus, children: [
|
|
76
|
+
/* @__PURE__ */ jsx(BellOff, { className: "mt-0.5 size-3.5 shrink-0 text-warning", "aria-hidden": true }),
|
|
77
|
+
/* @__PURE__ */ jsx("span", { children: labels.nudge })
|
|
78
|
+
] }),
|
|
79
|
+
/* @__PURE__ */ jsx(
|
|
80
|
+
ChatComposer,
|
|
81
|
+
{
|
|
82
|
+
onSend: send,
|
|
83
|
+
pending,
|
|
84
|
+
commit,
|
|
85
|
+
maxLength: FEEDBACK_REPLY_MAX,
|
|
86
|
+
showCount: true,
|
|
87
|
+
labels: { field: labels.field, placeholder: labels.placeholder, send: labels.reply },
|
|
88
|
+
attachmentSlot: /* @__PURE__ */ jsxs(
|
|
89
|
+
Select,
|
|
90
|
+
{
|
|
91
|
+
size: "sm",
|
|
92
|
+
"aria-label": labels.status,
|
|
93
|
+
value: picked,
|
|
94
|
+
disabled: pending,
|
|
95
|
+
onChange: (event) => setPick({ under: suggestedStatus, value: event.target.value }),
|
|
96
|
+
"data-feedback-reply-status-pick": "",
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ jsx("option", { value: "", children: labels.noChange }),
|
|
99
|
+
selectableFeedbackStatuses(status).map((value) => /* @__PURE__ */ jsx("option", { value, children: statusNames[value] }, value))
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] });
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
DEFAULT_FEEDBACK_REPLIES_LABELS,
|
|
109
|
+
FeedbackReplyComposer,
|
|
110
|
+
FeedbackReplyTimeline,
|
|
111
|
+
feedbackReplyNudge,
|
|
112
|
+
useFeedbackRepliesLabels
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=feedback-replies.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/feedback-replies.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport { BellOff } from \"lucide-react\";\nimport { Select } from \"../components/select\";\nimport type { CommitScope } from \"../components/write-lock\";\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport { formatDate } from \"../lib/format\";\nimport { FeedbackStatusBadge, selectableFeedbackStatuses, type FeedbackStatus } from \"./feedback-inbox\";\nimport { useFeedbackStatusLabels } from \"./feedback-labels\";\nimport type { FeedbackReply } from \"./feedback-public-types\";\nimport { FEEDBACK_DECIDED_STATUSES, FEEDBACK_REPLY_MAX } from \"./feedback-record\";\nimport { ChatComposer } from \"./feedback-thread\";\nimport { DEFAULT_FEEDBACK_REPLIES_LABELS } from \"./feedback-thread-parts-labels\";\n\n/**\n * The admin's answers as a list (docs/feedback-harmonization.md §9.7, decision 5): each\n * reply its own row — who, when, what, and the status it moved the report to — where\n * 0.37 had one `outcome` field that every answer overwrote. {@link FeedbackReplyTimeline}\n * draws them; {@link FeedbackReplyComposer} writes the next one, with the status picker\n * beside it (decision 13: a reply notifies the author, a status alone does not, so the\n * status belongs with the words).\n */\n\n/* ── Labels ───────────────────────────────────────────────────────────────── */\n\n/** The `feedbackReplies` namespace of `<UiKitProvider labels>`. */\nexport interface FeedbackRepliesLabels {\n /** The timeline's accessible name. de-CH: \"Antworten\" */\n replies: string;\n /** No reply yet. de-CH: \"Noch keine Antwort\" */\n empty: string;\n /** A reply without an author — a loop's, a migrated outcome, an erased admin (§9.7).\n * The app's word for its admin; never \"the team\". de-CH: \"Admin\" */\n admin: string;\n /** Read before a reply's status chip (\"→ Done\"). de-CH: \"Status geändert auf\" */\n statusChanged: string;\n /** The reply box's accessible name. de-CH: \"Antwort schreiben\" */\n field: string;\n /** de-CH: \"Antwort schreiben…\" */\n placeholder: string;\n /** The send button. de-CH: \"Antworten\" */\n reply: string;\n /** The status picker's accessible name. de-CH: \"Status mit der Antwort\" */\n status: string;\n /** The picker's first option: the reply changes no status. de-CH: \"Keine Änderung\" */\n noChange: string;\n /** Above the composer when a decided status was set without a reply (§9.7, B2).\n * de-CH: \"Die meldende Person wurde nicht benachrichtigt. Schreiben Sie eine Antwort.\" */\n nudge: string;\n}\n\nexport { DEFAULT_FEEDBACK_REPLIES_LABELS };\n\n/** `feedbackReplies` resolved: English, then `<UiKitProvider labels>`, then `labels`. */\nexport function useFeedbackRepliesLabels(labels?: LabelOverride<FeedbackRepliesLabels>): FeedbackRepliesLabels {\n return useKitLabels(\"feedbackReplies\", DEFAULT_FEEDBACK_REPLIES_LABELS, labels);\n}\n\n/**\n * The status a row detail should nudge toward (§9.7, B2), or `undefined`: the row's\n * status when it is decided ({@link FEEDBACK_DECIDED_STATUSES}) and no reply carries it\n * as its `status_to` — a status-only move from the table, a swipe or the pills told the\n * author nothing. `undefined` too without `replies` (a server before 0.38).\n */\nexport function feedbackReplyNudge(row: {\n status: FeedbackStatus;\n replies?: readonly Pick<FeedbackReply, \"status_to\">[] | null;\n}): FeedbackStatus | undefined {\n if (!row.replies || !FEEDBACK_DECIDED_STATUSES.includes(row.status)) return undefined;\n return row.replies.some((reply) => reply.status_to === row.status) ? undefined : row.status;\n}\n\n/* ── The timeline ─────────────────────────────────────────────────────────── */\n\nexport interface FeedbackReplyTimelineProps {\n /** Oldest first, as the server sends them. */\n replies: readonly FeedbackReply[];\n /** How a reply's time reads. Default: the date and time in the provider's locale. */\n renderDate?: (iso: string) => string;\n /** Tag bodies and names `data-private` (a host's screen-share blur). Default true. */\n redact?: boolean;\n labels?: LabelOverride<FeedbackRepliesLabels>;\n className?: string;\n}\n\n/**\n * The replies, oldest first, down a rule: each with its author (`null` → \"Admin\"), its\n * time, the status it set (\"→ Done\"; the admin view adds where from) and its text. No\n * edit and no delete (§9.7): a correction is a new reply.\n */\nexport function FeedbackReplyTimeline({\n replies,\n renderDate,\n redact = true,\n labels: labelsProp,\n className,\n}: FeedbackReplyTimelineProps) {\n const labels = useFeedbackRepliesLabels(labelsProp);\n const locale = useKitLocale();\n const priv = redact ? \"\" : undefined;\n if (replies.length === 0) {\n return <p className={cn(\"text-sm text-placeholder\", className)}>{labels.empty}</p>;\n }\n const dateText = (iso: string) =>\n renderDate ? renderDate(iso) : formatDate(iso, { dateStyle: \"medium\", timeStyle: \"short\" }, { locale });\n return (\n <ol aria-label={labels.replies} className={cn(\"space-y-3 border-s-2 border-subtle ps-3\", className)}>\n {replies.map((reply) => (\n <li key={reply.id} data-feedback-reply={reply.id} className=\"min-w-0 text-sm\">\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1 text-caption text-muted\">\n <span data-private={priv} className=\"font-medium text-secondary\">\n {reply.author_name ?? labels.admin}\n </span>\n <time dateTime={reply.created_at} className=\"tabular-nums\">\n {dateText(reply.created_at)}\n </time>\n {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\">{labels.statusChanged}</span>\n {reply.status_from && reply.status_from !== reply.status_to && (\n <>\n <FeedbackStatusBadge status={reply.status_from} />\n <span aria-hidden>→</span>\n </>\n )}\n {!reply.status_from && <span aria-hidden>→</span>}\n <FeedbackStatusBadge status={reply.status_to} />\n </span>\n )}\n </div>\n <p data-private={priv} dir=\"auto\" className=\"mt-0.5 whitespace-pre-wrap break-words text-start text-primary\">\n {reply.body}\n </p>\n </li>\n ))}\n </ol>\n );\n}\n\n/* ── The composer ─────────────────────────────────────────────────────────── */\n\nexport interface FeedbackReplyComposerProps {\n /** The report's status now — what \"No change\" keeps. */\n status: FeedbackStatus;\n /**\n * `POST /feedback/{id}/replies` — the body (1–{@link FEEDBACK_REPLY_MAX} after\n * trimming) and the status picked, `undefined` for \"No change\". Return the promise:\n * the box clears when it resolves, and keeps everything on a rejection.\n */\n onReply: (body: string, status?: FeedbackStatus) => void | Promise<unknown>;\n /** The reply is in flight. */\n pending?: boolean;\n /** Preselect this status and say the author has not been told (§9.7, the nudge) —\n * {@link feedbackReplyNudge}. */\n suggestedStatus?: FeedbackStatus;\n /** Reply COMMITS — see ChatComposer's `commit`. */\n commit?: CommitScope;\n labels?: LabelOverride<FeedbackRepliesLabels>;\n className?: string;\n}\n\n/**\n * The admin's reply box (§9.7): the text, the **status** to set with it (\"No change\"\n * first, then every status — {@link selectableFeedbackStatuses}), and **Reply**. A\n * {@link ChatComposer} underneath: Ctrl/⌘+Enter sends, the count runs to 8 000, a draft\n * typed while a reply is in flight stays.\n *\n * With `suggestedStatus` the line \"The author has not been told. Add a reply.\" stands\n * above it and that status is picked, so the reply that answers it records the status\n * and the nudge goes away.\n */\nexport function FeedbackReplyComposer({\n status,\n onReply,\n pending = false,\n suggestedStatus,\n commit,\n labels: labelsProp,\n className,\n}: FeedbackReplyComposerProps) {\n const labels = useFeedbackRepliesLabels(labelsProp);\n const statusNames = useFeedbackStatusLabels();\n // The pick, valid for the suggestion it was made under: a new suggestion (another\n // status set from the table) picks itself again.\n const [pick, setPick] = useState<{ under: FeedbackStatus | undefined; value: FeedbackStatus | \"\" }>({\n under: suggestedStatus,\n value: suggestedStatus ?? \"\",\n });\n const picked = pick.under === suggestedStatus ? pick.value : (suggestedStatus ?? \"\");\n\n const send = (body: string) => {\n const sent = picked;\n return Promise.resolve(onReply(body, sent || undefined)).then(() => {\n setPick((current) => (current.value === sent ? { under: suggestedStatus, value: \"\" } : current));\n });\n };\n\n return (\n <div className={cn(\"space-y-2\", className)} data-feedback-reply-composer=\"\">\n {suggestedStatus && (\n <p className=\"flex items-start gap-1.5 text-xs text-secondary\" data-feedback-nudge={suggestedStatus}>\n <BellOff className=\"mt-0.5 size-3.5 shrink-0 text-warning\" aria-hidden />\n <span>{labels.nudge}</span>\n </p>\n )}\n <ChatComposer\n onSend={send}\n pending={pending}\n commit={commit}\n maxLength={FEEDBACK_REPLY_MAX}\n showCount\n labels={{ field: labels.field, placeholder: labels.placeholder, send: labels.reply }}\n attachmentSlot={\n <Select\n size=\"sm\"\n aria-label={labels.status}\n value={picked}\n disabled={pending}\n onChange={(event) =>\n setPick({ under: suggestedStatus, value: event.target.value as FeedbackStatus | \"\" })\n }\n data-feedback-reply-status-pick=\"\"\n >\n <option value=\"\">{labels.noChange}</option>\n {selectableFeedbackStatuses(status).map((value) => (\n <option key={value} value={value}>\n {statusNames[value]}\n </option>\n ))}\n </Select>\n }\n />\n </div>\n );\n}\n"],"mappings":";AAqGW,SAmBO,UAnBP,KAmBO,YAnBP;AArGX,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,SAAS,cAAc;AAEvB,SAAS,cAAc,oBAAwC;AAC/D,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,qBAAqB,kC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;AAAA,OACtB;AAAA,IAEF;AAAA,MAAC;AAAA;AAAA,QACC,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA,WAAW;AAAA,QACX,WAAS;AAAA,QACT,QAAQ,EAAE,OAAO,OAAO,OAAO,aAAa,OAAO,aAAa,MAAM,OAAO,MAAM;AAAA,QACnF,gBACE;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL,cAAY,OAAO;AAAA,YACnB,OAAO;AAAA,YACP,UAAU;AAAA,YACV,UAAU,CAAC,UACT,QAAQ,EAAE,OAAO,iBAAiB,OAAO,MAAM,OAAO,MAA6B,CAAC;AAAA,YAEtF,mCAAgC;AAAA,YAEhC;AAAA,kCAAC,YAAO,OAAM,IAAI,iBAAO,UAAS;AAAA,cACjC,2BAA2B,MAAM,EAAE,IAAI,CAAC,UACvC,oBAAC,YAAmB,OACjB,sBAAY,KAAK,KADP,KAEb,CACD;AAAA;AAAA;AAAA,QACH;AAAA;AAAA,IAEJ;AAAA,KACF;AAEJ;","names":[]}
|
|
@@ -12,6 +12,7 @@ const DEFAULT_FEEDBACK_DETAIL_LABELS = {
|
|
|
12
12
|
download: (name) => `Download ${name}`,
|
|
13
13
|
downloadFailed: "The attachment could not be downloaded.",
|
|
14
14
|
outcome: "Outcome",
|
|
15
|
+
replies: "Replies",
|
|
15
16
|
resolvedAt: (date) => `Resolved: ${date}`,
|
|
16
17
|
outcomeAdd: "Add outcome",
|
|
17
18
|
outcomeUpdate: "Update",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feedback/feedback-row-detail-labels.ts"],"sourcesContent":["// The English words of ./feedback-row-detail, in a module with no component code: the\n// English catalogue (src/i18n/defaults.ts) imports them without the component, so `en`\n// loads as one chunk like the other languages (0.34, KS U8). ./feedback-row-detail\n// re-exports them.\n\nimport type { FeedbackDetailLabels } from \"./feedback-row-detail\";\n\nexport const DEFAULT_FEEDBACK_DETAIL_LABELS: FeedbackDetailLabels = {\n subject: \"Subject\",\n body: \"Description\",\n edit: \"Edit\",\n editDescription: \"Edit description\",\n save: \"Save\",\n cancel: \"Cancel\",\n url: \"URL\",\n copyUrl: \"Copy URL\",\n attachment: \"Attachment\",\n download: (name) => `Download ${name}`,\n downloadFailed: \"The attachment could not be downloaded.\",\n outcome: \"Outcome\",\n resolvedAt: (date) => `Resolved: ${date}`,\n outcomeAdd: \"Add outcome\",\n outcomeUpdate: \"Update\",\n outcomePlaceholder: \"What was done, decided, or why this won't be addressed.\",\n rework: \"Rework\",\n openPage: \"Open page\",\n reworkTitle: \"Send for rework\",\n reworkSend: \"Send rework\",\n reworkPlaceholder: \"What still needs refinement? Any new constraints or change of direction.\",\n reworkUploadFailed: \"The file could not be uploaded. The rework was not sent.\",\n status: \"Status\",\n note: \"Note\",\n};\n"],"mappings":";AAOO,MAAM,iCAAuD;AAAA,EAClE,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,UAAU,CAAC,SAAS,YAAY,IAAI;AAAA,EACpC,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,YAAY,CAAC,SAAS,aAAa,IAAI;AAAA,EACvC,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,QAAQ;AAAA,EACR,MAAM;AACR;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/feedback-row-detail-labels.ts"],"sourcesContent":["// The English words of ./feedback-row-detail, in a module with no component code: the\n// English catalogue (src/i18n/defaults.ts) imports them without the component, so `en`\n// loads as one chunk like the other languages (0.34, KS U8). ./feedback-row-detail\n// re-exports them.\n\nimport type { FeedbackDetailLabels } from \"./feedback-row-detail\";\n\nexport const DEFAULT_FEEDBACK_DETAIL_LABELS: FeedbackDetailLabels = {\n subject: \"Subject\",\n body: \"Description\",\n edit: \"Edit\",\n editDescription: \"Edit description\",\n save: \"Save\",\n cancel: \"Cancel\",\n url: \"URL\",\n copyUrl: \"Copy URL\",\n attachment: \"Attachment\",\n download: (name) => `Download ${name}`,\n downloadFailed: \"The attachment could not be downloaded.\",\n outcome: \"Outcome\",\n replies: \"Replies\",\n resolvedAt: (date) => `Resolved: ${date}`,\n outcomeAdd: \"Add outcome\",\n outcomeUpdate: \"Update\",\n outcomePlaceholder: \"What was done, decided, or why this won't be addressed.\",\n rework: \"Rework\",\n openPage: \"Open page\",\n reworkTitle: \"Send for rework\",\n reworkSend: \"Send rework\",\n reworkPlaceholder: \"What still needs refinement? Any new constraints or change of direction.\",\n reworkUploadFailed: \"The file could not be uploaded. The rework was not sent.\",\n status: \"Status\",\n note: \"Note\",\n};\n"],"mappings":";AAOO,MAAM,iCAAuD;AAAA,EAClE,SAAS;AAAA,EACT,MAAM;AAAA,EACN,MAAM;AAAA,EACN,iBAAiB;AAAA,EACjB,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,KAAK;AAAA,EACL,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,UAAU,CAAC,SAAS,YAAY,IAAI;AAAA,EACpC,gBAAgB;AAAA,EAChB,SAAS;AAAA,EACT,SAAS;AAAA,EACT,YAAY,CAAC,SAAS,aAAa,IAAI;AAAA,EACvC,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,oBAAoB;AAAA,EACpB,QAAQ;AAAA,EACR,UAAU;AAAA,EACV,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,mBAAmB;AAAA,EACnB,oBAAoB;AAAA,EACpB,QAAQ;AAAA,EACR,MAAM;AACR;","names":[]}
|