@eifi1/ui-kit 0.36.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/components/field-parts.d.ts +3 -3
- package/dist/components/field-parts.js.map +1 -1
- package/dist/components/help-popover.d.ts +1 -1
- package/dist/components/help-popover.js.map +1 -1
- package/dist/components/numeric-field.d.ts +1 -1
- package/dist/components/numeric-field.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/eslint/role-utilities.d.ts +34 -2
- package/dist/eslint/role-utilities.js +30 -9
- package/dist/eslint/role-utilities.js.map +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 +20 -3
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +80 -3
- 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/i18n/shared-labels.js +1 -1
- package/dist/i18n/shared-labels.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/lib/plain-text.d.ts +1 -1
- package/dist/lib/plain-text.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/dist/rhf/fields.d.ts +1 -1
- package/dist/rhf/fields.js.map +1 -1
- package/dist/settings/device-reset-setting.d.ts +4 -4
- package/dist/settings/device-reset-setting.js.map +1 -1
- package/package.json +1 -1
- package/src/components/field-parts.tsx +4 -4
- package/src/components/help-popover.tsx +1 -1
- package/src/components/numeric-field.ts +1 -1
- package/src/eslint/role-utilities.ts +67 -11
- 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 +20 -3
- 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/i18n/shared-labels.ts +1 -1
- package/src/index.ts +9 -0
- package/src/lib/plain-text.ts +1 -1
- package/src/notifications/feedback-notification-types-labels.ts +24 -0
- package/src/notifications/feedback-notification-types.ts +46 -0
- package/src/rhf/fields.tsx +1 -1
- package/src/settings/device-reset-setting.tsx +4 -4
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { CommitScope } from "../components/write-lock.js";
|
|
2
|
+
import { type LabelOverride } from "../i18n/kit-labels.js";
|
|
3
|
+
import type { FeedbackComment, FeedbackReply } from "./feedback-public-types.js";
|
|
4
|
+
import { DEFAULT_FEEDBACK_COMMENTS_LABELS } from "./feedback-thread-parts-labels.js";
|
|
5
|
+
/**
|
|
6
|
+
* A report's conversation as everyone who may read it sees it
|
|
7
|
+
* (docs/feedback-harmonization.md §9.8): the admin's replies and other people's
|
|
8
|
+
* comments, each its own row, oldest first — merged by time, on the
|
|
9
|
+
* {@link FeedbackThread} look — and the box to add one.
|
|
10
|
+
*
|
|
11
|
+
* - **Replies** are drawn as staff posts with the status they set ("→ Done"); a reply
|
|
12
|
+
* without an author is "Admin" (§9.7).
|
|
13
|
+
* - **Comments**: the viewer's own at the reading end ("You"); someone else's under the
|
|
14
|
+
* first name the server sent, `null` as "A user" (§9.5, `feedbackPublic.anonymous`).
|
|
15
|
+
* - **Hidden** (§9.8): others see "Hidden by an admin" and no name, no text; the writer
|
|
16
|
+
* sees their text with that line; the admin sees it struck through, with **Unhide**.
|
|
17
|
+
* An admin has **Hide** on every visible comment; the writer **Delete** on their own,
|
|
18
|
+
* after a confirm (it is a hard delete). Nobody edits a comment.
|
|
19
|
+
* - **The composer** (1–4 000 characters, no files) only with `onComment`: left out for
|
|
20
|
+
* a reader who may not write (a demo, a CRASH report — the app knows).
|
|
21
|
+
*
|
|
22
|
+
* Delete asks through `useConfirm`, so a thread with `onDelete` and a comment of the
|
|
23
|
+
* viewer's needs the app's `ConfirmProvider` (each app mounts one already).
|
|
24
|
+
*/
|
|
25
|
+
/** The `feedbackComments` namespace of `<UiKitProvider labels>`. A `null` name is
|
|
26
|
+
* `feedbackPublic.anonymous`, the public pages' word, so the two say the same. */
|
|
27
|
+
export interface FeedbackCommentsLabels {
|
|
28
|
+
/** The thread's accessible name. de-CH: "Kommentare" */
|
|
29
|
+
comments: string;
|
|
30
|
+
/** Nothing yet. de-CH: "Noch keine Kommentare" */
|
|
31
|
+
empty: string;
|
|
32
|
+
/** In place of a hidden comment. de-CH: "Von einem Admin ausgeblendet" */
|
|
33
|
+
hidden: string;
|
|
34
|
+
/** The admin's button. de-CH: "Ausblenden" */
|
|
35
|
+
hide: string;
|
|
36
|
+
/** The admin's button on a hidden comment. de-CH: "Einblenden" */
|
|
37
|
+
unhide: string;
|
|
38
|
+
/** The writer's button. de-CH: "Löschen" */
|
|
39
|
+
delete: string;
|
|
40
|
+
/** The confirm's question. de-CH: "Diesen Kommentar löschen?" */
|
|
41
|
+
deleteTitle: string;
|
|
42
|
+
/** The confirm's line. de-CH: "Er wird für alle entfernt. Das kann nicht rückgängig
|
|
43
|
+
* gemacht werden." */
|
|
44
|
+
deleteBody: string;
|
|
45
|
+
/** The box's accessible name. de-CH: "Kommentar schreiben" */
|
|
46
|
+
field: string;
|
|
47
|
+
/** de-CH: "Kommentar schreiben…" */
|
|
48
|
+
placeholder: string;
|
|
49
|
+
/** The send button. de-CH: "Kommentieren" */
|
|
50
|
+
send: string;
|
|
51
|
+
}
|
|
52
|
+
export { DEFAULT_FEEDBACK_COMMENTS_LABELS };
|
|
53
|
+
export interface FeedbackCommentThreadProps {
|
|
54
|
+
/** The report's replies (§9.7), oldest first. `[]` when it has none. */
|
|
55
|
+
replies: readonly FeedbackReply[];
|
|
56
|
+
/** `GET /feedback/{id}/comments`, oldest first. */
|
|
57
|
+
comments: readonly FeedbackComment[];
|
|
58
|
+
/** The viewer is the app's admin: Hide / Unhide, the hidden text struck through. */
|
|
59
|
+
isAdmin: boolean;
|
|
60
|
+
/** `POST /feedback/{id}/comments`. Return the promise: the box clears when it
|
|
61
|
+
* resolves. Left out, no composer. */
|
|
62
|
+
onComment?: (body: string) => void | Promise<unknown>;
|
|
63
|
+
/** `PATCH /feedback/{id}/comments/{comment_id} {hidden}` — the admin's. Left out, no
|
|
64
|
+
* Hide / Unhide. */
|
|
65
|
+
onHide?: (comment: FeedbackComment, hidden: boolean) => void | Promise<unknown>;
|
|
66
|
+
/** `DELETE /feedback/{id}/comments/{comment_id}` — the writer's own, after the
|
|
67
|
+
* confirm. Left out, no Delete. */
|
|
68
|
+
onDelete?: (comment: FeedbackComment) => void | Promise<unknown>;
|
|
69
|
+
/** A comment is being sent. */
|
|
70
|
+
pending?: boolean;
|
|
71
|
+
/** The comments are loading. */
|
|
72
|
+
loading?: boolean;
|
|
73
|
+
/** Comment, Hide and Delete COMMIT — see Button's `commit`. */
|
|
74
|
+
commit?: CommitScope;
|
|
75
|
+
/** "Now" for the relative times — pin it in tests and stories. */
|
|
76
|
+
now?: Date | number;
|
|
77
|
+
labels?: LabelOverride<FeedbackCommentsLabels>;
|
|
78
|
+
className?: string;
|
|
79
|
+
}
|
|
80
|
+
export declare function FeedbackCommentThread({ replies, comments, isAdmin, onComment, onHide, onDelete, pending, loading, commit, now, labels: labelsProp, className, }: FeedbackCommentThreadProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { EyeOff } from "lucide-react";
|
|
4
|
+
import { Button } from "../components/button.js";
|
|
5
|
+
import { useConfirm } from "../components/confirm-dialog.js";
|
|
6
|
+
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
7
|
+
import { FeedbackStatusBadge } from "./feedback-inbox.js";
|
|
8
|
+
import { DEFAULT_FEEDBACK_PUBLIC_LABELS } from "./feedback-public-labels.js";
|
|
9
|
+
import { FEEDBACK_COMMENT_MAX } from "./feedback-record.js";
|
|
10
|
+
import { useFeedbackRepliesLabels } from "./feedback-replies.js";
|
|
11
|
+
import { ChatComposer, FeedbackThread } from "./feedback-thread.js";
|
|
12
|
+
import { DEFAULT_FEEDBACK_COMMENTS_LABELS } from "./feedback-thread-parts-labels.js";
|
|
13
|
+
const instant = (iso) => {
|
|
14
|
+
const ms = Date.parse(iso);
|
|
15
|
+
return Number.isNaN(ms) ? 0 : ms;
|
|
16
|
+
};
|
|
17
|
+
function FeedbackCommentThread({
|
|
18
|
+
replies,
|
|
19
|
+
comments,
|
|
20
|
+
isAdmin,
|
|
21
|
+
onComment,
|
|
22
|
+
onHide,
|
|
23
|
+
onDelete,
|
|
24
|
+
pending = false,
|
|
25
|
+
loading = false,
|
|
26
|
+
commit,
|
|
27
|
+
now,
|
|
28
|
+
labels: labelsProp,
|
|
29
|
+
className
|
|
30
|
+
}) {
|
|
31
|
+
const labels = useKitLabels("feedbackComments", DEFAULT_FEEDBACK_COMMENTS_LABELS, labelsProp);
|
|
32
|
+
const anonymous = useKitLabels("feedbackPublic", DEFAULT_FEEDBACK_PUBLIC_LABELS).anonymous;
|
|
33
|
+
const replyLabels = useFeedbackRepliesLabels();
|
|
34
|
+
const entries = [];
|
|
35
|
+
replies.forEach((reply, order) => {
|
|
36
|
+
entries.push({
|
|
37
|
+
at: instant(reply.created_at),
|
|
38
|
+
order,
|
|
39
|
+
message: {
|
|
40
|
+
id: `reply-${reply.id}`,
|
|
41
|
+
author: reply.author_name ?? replyLabels.admin,
|
|
42
|
+
createdAt: reply.created_at,
|
|
43
|
+
body: reply.body,
|
|
44
|
+
staff: true,
|
|
45
|
+
badge: 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: [
|
|
46
|
+
/* @__PURE__ */ jsx("span", { className: "sr-only", children: replyLabels.statusChanged }),
|
|
47
|
+
/* @__PURE__ */ jsx("span", { "aria-hidden": true, children: "\u2192" }),
|
|
48
|
+
/* @__PURE__ */ jsx(FeedbackStatusBadge, { status: reply.status_to })
|
|
49
|
+
] }) : void 0
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
comments.forEach((comment, index) => {
|
|
54
|
+
const veiled = comment.hidden && !comment.mine && !isAdmin;
|
|
55
|
+
const actions = [];
|
|
56
|
+
if (comment.hidden) {
|
|
57
|
+
actions.push(
|
|
58
|
+
/* @__PURE__ */ jsxs("span", { className: "inline-flex items-center gap-1", "data-feedback-comment-hidden": "", children: [
|
|
59
|
+
/* @__PURE__ */ jsx(EyeOff, { className: "size-3", "aria-hidden": true }),
|
|
60
|
+
labels.hidden
|
|
61
|
+
] }, "hidden")
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (isAdmin && onHide) {
|
|
65
|
+
actions.push(
|
|
66
|
+
/* @__PURE__ */ jsx(
|
|
67
|
+
Button,
|
|
68
|
+
{
|
|
69
|
+
type: "button",
|
|
70
|
+
variant: "link",
|
|
71
|
+
tone: "muted",
|
|
72
|
+
size: "sm",
|
|
73
|
+
commit,
|
|
74
|
+
onClick: () => void onHide(comment, !comment.hidden),
|
|
75
|
+
children: comment.hidden ? labels.unhide : labels.hide
|
|
76
|
+
},
|
|
77
|
+
"hide"
|
|
78
|
+
)
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
if (comment.mine && onDelete) {
|
|
82
|
+
actions.push(
|
|
83
|
+
/* @__PURE__ */ jsx(DeleteCommentButton, { comment, onDelete, commit, labels }, "delete")
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
entries.push({
|
|
87
|
+
at: instant(comment.created_at),
|
|
88
|
+
// Replies first on a tie, then the comments in their order.
|
|
89
|
+
order: replies.length + index,
|
|
90
|
+
message: {
|
|
91
|
+
id: `comment-${comment.id}`,
|
|
92
|
+
own: comment.mine,
|
|
93
|
+
author: veiled ? void 0 : comment.mine ? void 0 : comment.author_name ?? anonymous,
|
|
94
|
+
createdAt: comment.created_at,
|
|
95
|
+
body: veiled ? "" : comment.body ?? "",
|
|
96
|
+
staff: !veiled && comment.staff,
|
|
97
|
+
struck: comment.hidden && isAdmin && !veiled,
|
|
98
|
+
footer: actions.length > 0 ? actions : void 0
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
entries.sort((a, b) => a.at - b.at || a.order - b.order);
|
|
103
|
+
return /* @__PURE__ */ jsxs("div", { className, "data-feedback-comment-thread": "", children: [
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
FeedbackThread,
|
|
106
|
+
{
|
|
107
|
+
messages: entries.map((entry) => entry.message),
|
|
108
|
+
loading,
|
|
109
|
+
now,
|
|
110
|
+
labels: { thread: labels.comments, empty: labels.empty }
|
|
111
|
+
}
|
|
112
|
+
),
|
|
113
|
+
onComment && /* @__PURE__ */ jsx(
|
|
114
|
+
ChatComposer,
|
|
115
|
+
{
|
|
116
|
+
className: "mt-3",
|
|
117
|
+
onSend: (body) => onComment(body),
|
|
118
|
+
pending,
|
|
119
|
+
commit,
|
|
120
|
+
maxLength: FEEDBACK_COMMENT_MAX,
|
|
121
|
+
showCount: true,
|
|
122
|
+
labels: { field: labels.field, placeholder: labels.placeholder, send: labels.send }
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
] });
|
|
126
|
+
}
|
|
127
|
+
function DeleteCommentButton({
|
|
128
|
+
comment,
|
|
129
|
+
onDelete,
|
|
130
|
+
commit,
|
|
131
|
+
labels
|
|
132
|
+
}) {
|
|
133
|
+
const confirm = useConfirm();
|
|
134
|
+
const remove = async () => {
|
|
135
|
+
const ok = await confirm({
|
|
136
|
+
title: labels.deleteTitle,
|
|
137
|
+
body: labels.deleteBody,
|
|
138
|
+
confirmLabel: labels.delete,
|
|
139
|
+
tone: "danger",
|
|
140
|
+
commit
|
|
141
|
+
});
|
|
142
|
+
if (ok) await onDelete(comment);
|
|
143
|
+
};
|
|
144
|
+
return /* @__PURE__ */ jsx(
|
|
145
|
+
Button,
|
|
146
|
+
{
|
|
147
|
+
type: "button",
|
|
148
|
+
variant: "link",
|
|
149
|
+
tone: "danger",
|
|
150
|
+
size: "sm",
|
|
151
|
+
commit,
|
|
152
|
+
onClick: () => void remove().catch(() => {
|
|
153
|
+
}),
|
|
154
|
+
children: labels.delete
|
|
155
|
+
}
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
DEFAULT_FEEDBACK_COMMENTS_LABELS,
|
|
160
|
+
FeedbackCommentThread
|
|
161
|
+
};
|
|
162
|
+
//# sourceMappingURL=feedback-comment-thread.js.map
|
|
@@ -0,0 +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;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Q,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":[]}
|
|
@@ -9,7 +9,8 @@ const DEFAULT_FEEDBACK_DIALOG_LABELS = {
|
|
|
9
9
|
// The modifier as `form.submitShortcut` writes it: "⌘ Enter" on Apple, "Ctrl+Enter" elsewhere.
|
|
10
10
|
submitHint: (apple) => apple ? "\u2318 Enter to send" : "Ctrl+Enter to send",
|
|
11
11
|
cancel: "Cancel",
|
|
12
|
-
save: "Send"
|
|
12
|
+
save: "Send",
|
|
13
|
+
publicNotice: "Other users will see the title and text (never your screenshots or files)."
|
|
13
14
|
};
|
|
14
15
|
export {
|
|
15
16
|
DEFAULT_FEEDBACK_DIALOG_LABELS
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feedback/feedback-dialog-labels.ts"],"sourcesContent":["// The English words of ./feedback-dialog, in a module with no component code: the English\n// catalogue (src/i18n/defaults.ts) imports them without the component, so `en` loads as one\n// chunk like the other languages (0.34, KS U8). ./feedback-dialog re-exports them.\n\nimport type { FeedbackDialogTextLabels } from \"./feedback-dialog\";\n\n/**\n * English. The feedback contract's wording (docs/feedback-harmonization.md §4.2, 0.27.0):\n * \"Send\", not keksdose's \"Save\", and the body asks \"What happened?\" (Marcel's two calls);\n * the rest is keksdose's. Since 0.27.0 `attachment`, the single-mode heading, is keksdose's\n * `feedback.attachment` **\"Attachment\"** (it said \"Screenshot\" over a button that says \"Add\n * attachment\" and a picker that may offer a PDF), and `submitHint` is keksdose's\n * **\"Ctrl+Enter to send\"** — \"⌘ Enter to send\" on Apple platforms, where the old\n * \"Ctrl/⌘ + Enter\" made every reader parse both. The `attachments=\"multiple\"` heading is\n * `feedbackAttachment.attachmentList` (\"Attachments\") and did not change.\n */\nexport const DEFAULT_FEEDBACK_DIALOG_LABELS: FeedbackDialogTextLabels = {\n title: \"Send feedback\",\n category: \"Category\",\n subject: \"Subject\",\n body: \"What happened?\",\n bodyOptional: \"What happened? (optional)\",\n attachment: \"Attachment\",\n // The modifier as `form.submitShortcut` writes it: \"⌘ Enter\" on Apple, \"Ctrl+Enter\" elsewhere.\n submitHint: (apple) => (apple ? \"⌘ Enter to send\" : \"Ctrl+Enter to send\"),\n cancel: \"Cancel\",\n save: \"Send\",\n};\n"],"mappings":";AAgBO,MAAM,iCAA2D;AAAA,EACtE,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AAAA,EACT,MAAM;AAAA,EACN,cAAc;AAAA,EACd,YAAY;AAAA;AAAA,EAEZ,YAAY,CAAC,UAAW,QAAQ,yBAAoB;AAAA,EACpD,QAAQ;AAAA,EACR,MAAM;
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/feedback-dialog-labels.ts"],"sourcesContent":["// The English words of ./feedback-dialog, in a module with no component code: the English\n// catalogue (src/i18n/defaults.ts) imports them without the component, so `en` loads as one\n// chunk like the other languages (0.34, KS U8). ./feedback-dialog re-exports them.\n\nimport type { FeedbackDialogTextLabels } from \"./feedback-dialog\";\n\n/**\n * English. The feedback contract's wording (docs/feedback-harmonization.md §4.2, 0.27.0):\n * \"Send\", not keksdose's \"Save\", and the body asks \"What happened?\" (Marcel's two calls);\n * the rest is keksdose's. Since 0.27.0 `attachment`, the single-mode heading, is keksdose's\n * `feedback.attachment` **\"Attachment\"** (it said \"Screenshot\" over a button that says \"Add\n * attachment\" and a picker that may offer a PDF), and `submitHint` is keksdose's\n * **\"Ctrl+Enter to send\"** — \"⌘ Enter to send\" on Apple platforms, where the old\n * \"Ctrl/⌘ + Enter\" made every reader parse both. The `attachments=\"multiple\"` heading is\n * `feedbackAttachment.attachmentList` (\"Attachments\") and did not change.\n */\nexport const DEFAULT_FEEDBACK_DIALOG_LABELS: FeedbackDialogTextLabels = {\n title: \"Send feedback\",\n category: \"Category\",\n subject: \"Subject\",\n body: \"What happened?\",\n bodyOptional: \"What happened? (optional)\",\n attachment: \"Attachment\",\n // The modifier as `form.submitShortcut` writes it: \"⌘ Enter\" on Apple, \"Ctrl+Enter\" elsewhere.\n submitHint: (apple) => (apple ? \"⌘ Enter to send\" : \"Ctrl+Enter to send\"),\n cancel: \"Cancel\",\n save: \"Send\",\n publicNotice: \"Other users will see the title and text (never your screenshots or files).\",\n};\n"],"mappings":";AAgBO,MAAM,iCAA2D;AAAA,EACtE,OAAO;AAAA,EACP,UAAU;AAAA,EACV,SAAS;AAAA,EACT,MAAM;AAAA,EACN,cAAc;AAAA,EACd,YAAY;AAAA;AAAA,EAEZ,YAAY,CAAC,UAAW,QAAQ,yBAAoB;AAAA,EACpD,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,cAAc;AAChB;","names":[]}
|
|
@@ -73,6 +73,11 @@ export interface FeedbackDialogTextLabels {
|
|
|
73
73
|
submitHint: FeedbackSubmitHint;
|
|
74
74
|
cancel: string;
|
|
75
75
|
save: string;
|
|
76
|
+
/** 0.38 (docs/feedback-harmonization.md §9.2 decision 6): the line under the body when
|
|
77
|
+
* reports are public — `useFeedbackSubmit({ publicNotice: true })` shows it. Optional,
|
|
78
|
+
* so a complete `UiKitLabels` typed before 0.38 still compiles. de-CH "Andere Personen
|
|
79
|
+
* sehen Titel und Text (nie Ihre Screenshots oder Dateien)." */
|
|
80
|
+
publicNotice?: string;
|
|
76
81
|
}
|
|
77
82
|
export { DEFAULT_FEEDBACK_DIALOG_LABELS };
|
|
78
83
|
export interface FeedbackSubmission {
|
|
@@ -136,6 +141,14 @@ interface FeedbackDialogBaseProps {
|
|
|
136
141
|
/** The attachment field's `buttonSize` (0.25.0) — with {@link attachmentButtonVariant}.
|
|
137
142
|
* Default `"md"`; `"sm"` draws the paperclip and camera at 14px. */
|
|
138
143
|
attachmentButtonSize?: ButtonSize;
|
|
144
|
+
/**
|
|
145
|
+
* A muted line under the body saying who will read it (0.38, docs/feedback-harmonization.md
|
|
146
|
+
* §9.2 decision 6) — the kit's sentence is `feedbackDialog.publicNotice`, "Other users
|
|
147
|
+
* will see the title and text (never your screenshots or files)", which
|
|
148
|
+
* `useFeedbackSubmit({ publicNotice: true })` passes. Attached to the body field with
|
|
149
|
+
* `aria-describedby`, so it is heard where the text is written. Left out: no line.
|
|
150
|
+
*/
|
|
151
|
+
publicNotice?: ReactNode;
|
|
139
152
|
}
|
|
140
153
|
/** One attachment — a screenshot, a picked or a pasted image; a second replaces
|
|
141
154
|
* nothing, it has to wait for the first to be removed. The default. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useState } from "react";
|
|
3
|
+
import { useId, useState } from "react";
|
|
4
4
|
import { Button } from "../components/button.js";
|
|
5
5
|
import { Input } from "../components/input.js";
|
|
6
6
|
import { Select } from "../components/select.js";
|
|
@@ -31,7 +31,8 @@ function FeedbackDialog(props) {
|
|
|
31
31
|
onCaptureScreenshot,
|
|
32
32
|
requireBody = true,
|
|
33
33
|
attachmentButtonVariant,
|
|
34
|
-
attachmentButtonSize
|
|
34
|
+
attachmentButtonSize,
|
|
35
|
+
publicNotice
|
|
35
36
|
} = props;
|
|
36
37
|
const [title, setTitle] = useState("");
|
|
37
38
|
const [body, setBody] = useState("");
|
|
@@ -39,6 +40,8 @@ function FeedbackDialog(props) {
|
|
|
39
40
|
const [screenshot, setScreenshot] = useState(null);
|
|
40
41
|
const [files, setFiles] = useState([]);
|
|
41
42
|
const isMobile = usePhoneLayout();
|
|
43
|
+
const noticeId = useId();
|
|
44
|
+
const hasNotice = publicNotice !== void 0 && publicNotice !== null && publicNotice !== false && publicNotice !== "";
|
|
42
45
|
const labels = useKitLabels("feedbackDialog", DEFAULT_FEEDBACK_DIALOG_LABELS, labelsProp);
|
|
43
46
|
const attachmentText = useKitLabels("feedbackAttachment", DEFAULT_FEEDBACK_ATTACHMENT_LABELS, labelsProp);
|
|
44
47
|
const listHeading = labelsProp?.attachmentList ?? attachmentText.attachmentList ?? DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentList;
|
|
@@ -66,15 +69,20 @@ function FeedbackDialog(props) {
|
|
|
66
69
|
if (!open) return null;
|
|
67
70
|
const categoryField = /* @__PURE__ */ jsx(Select, { label: labels.category, value: category, onChange: (e) => onCategoryChange(e.target.value), children: categories.map((c) => /* @__PURE__ */ jsx("option", { value: c.value, children: c.label }, c.value)) });
|
|
68
71
|
const subjectField = /* @__PURE__ */ jsx(Input, { label: labels.subject, value: title, onChange: (e) => setTitle(e.target.value), variant: "display" });
|
|
69
|
-
const
|
|
72
|
+
const bodyTextarea = /* @__PURE__ */ jsx(
|
|
70
73
|
Textarea,
|
|
71
74
|
{
|
|
72
75
|
rows: 5,
|
|
73
76
|
label: requireBody ? labels.body : labelsProp?.body ?? labels.bodyOptional ?? labels.body,
|
|
74
77
|
value: body,
|
|
75
|
-
onChange: (e) => setBody(e.target.value)
|
|
78
|
+
onChange: (e) => setBody(e.target.value),
|
|
79
|
+
"aria-describedby": hasNotice ? noticeId : void 0
|
|
76
80
|
}
|
|
77
81
|
);
|
|
82
|
+
const bodyField = hasNotice ? /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
83
|
+
bodyTextarea,
|
|
84
|
+
/* @__PURE__ */ jsx("p", { id: noticeId, className: "text-xs text-muted", "data-feedback-public-notice": "", children: publicNotice })
|
|
85
|
+
] }) : bodyTextarea;
|
|
78
86
|
const fieldProps = {
|
|
79
87
|
labels: attachmentLabels,
|
|
80
88
|
accept: attachmentAccept,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feedback/feedback-dialog.tsx"],"sourcesContent":["import { useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { Button } from \"../components/button\";\nimport { Input } from \"../components/input\";\nimport { Select } from \"../components/select\";\nimport { Textarea } from \"../components/textarea\";\nimport type { ButtonSize, ButtonVariant } from \"../components/button-look\";\nimport { Modal } from \"../components/modal\";\nimport { isApplePlatform } from \"../hooks/use-hotkey\";\nimport { usePhoneLayout } from \"../hooks/use-breakpoint\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport {\n DEFAULT_ATTACHMENT_ACCEPT,\n DEFAULT_FEEDBACK_ATTACHMENT_LABELS,\n DEFAULT_MAX_ATTACHMENT_BYTES,\n FeedbackAttachmentField,\n type FeedbackAttachmentError,\n type FeedbackAttachmentErrorInfo,\n} from \"./feedback-attachment\";\nimport { DEFAULT_FEEDBACK_DIALOG_LABELS } from \"./feedback-dialog-labels\";\n\nexport interface FeedbackCategoryOption {\n value: string;\n label: string;\n}\n\nexport interface FeedbackAttachmentLabels {\n /** The heading over the field. Optional: a note editor puts the buttons\n * straight under its textarea, where a second heading is noise. */\n attachment?: string;\n attachmentAdd: string;\n /** Label for the \"capture screenshot\" button. Optional — falls back to the provider's\n * `feedbackAttachment.attachmentCapture`, then English. */\n attachmentCapture?: string;\n /** The line under the attachment buttons saying a screenshot can be pasted\n * straight in. Optional — falls back to the provider's `feedbackAttachment`, then English. */\n attachmentPaste?: string;\n attachmentRemove: string;\n /** `multiple` mode (0.15.5): the chip list's accessible name — and, in\n * `<FeedbackDialog attachments=\"multiple\">`, the heading over it (0.16.0). Optional,\n * as are the keys below — they fall back to the provider's `feedbackAttachment`,\n * then English. */\n attachmentList?: string;\n /** `multiple` mode (0.16.0): the screenshot slot's chip title, in place of its file name. */\n attachmentScreenshot?: string;\n /** `multiple` mode: one chip's remove button, given the file's name. */\n attachmentRemoveFile?: (name: string) => string;\n /** `multiple` mode: the line shown once `max` files are attached. */\n attachmentLimit?: (max: number) => string;\n /** `refs` mode (0.22.0): the second line of a chip whose upload is still running. */\n attachmentUploading?: string;\n}\n\nexport interface FeedbackDialogLabels extends FeedbackAttachmentLabels {\n title: string;\n category: string;\n subject: string;\n body: string;\n attachment: string;\n /** See {@link FeedbackDialogTextLabels.submitHint}. */\n submitHint: FeedbackSubmitHint;\n cancel: string;\n save: string;\n}\n\n/** The submit hint: a string, or the line for the platform (`apple`: Mac, iPhone, iPad). */\nexport type FeedbackSubmitHint = string | ((apple: boolean) => string);\n\n/**\n * The dialog's own strings — the `feedbackDialog` namespace of `<UiKitProvider\n * labels>` (0.12.0). The attachment keys are not repeated here: they are the\n * `feedbackAttachment` namespace's, which the field inside already reads.\n *\n * Before, every key was required at the call site, so each app restated ten strings\n * wherever it mounted the dialog (kastlan feedback-button.tsx built the object inline).\n */\nexport interface FeedbackDialogTextLabels {\n title: string;\n category: string;\n subject: string;\n body: string;\n /** The body's label when `requireBody={false}`: \"What happened? (optional)\".\n * Optional, so a complete `UiKitLabels` typed before 0.14.2 still compiles. */\n bodyOptional?: string;\n /** The heading over the attachment buttons. */\n attachment: string;\n /**\n * The line beside the buttons naming the shortcut. Since 0.27.0 a function of the\n * platform, like `form.submitShortcut`: `apple` is true on a Mac, iPhone or iPad, where\n * the key is Cmd — \"⌘ Enter to send\" there, keksdose's \"Ctrl+Enter to send\" elsewhere\n * (§7.12). A plain string is still taken and shown everywhere, as before 0.27.0.\n */\n submitHint: FeedbackSubmitHint;\n cancel: string;\n save: string;\n}\n\n// Defined in ./feedback-dialog-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_FEEDBACK_DIALOG_LABELS };\n\nexport interface FeedbackSubmission {\n title: string;\n body: string;\n category: string;\n attachment: File | null;\n}\n\n/**\n * What `onSubmit` gets under `attachments=\"multiple\"` (0.15.5): the screenshot and\n * the picked/pasted files apart, because an app files them differently — keksdose\n * attaches the screenshot to the report and the photos as its evidence list. No\n * `attachment`: there is no one file it could name.\n */\nexport interface FeedbackMultipleSubmission {\n title: string;\n body: string;\n category: string;\n /** What `onCaptureScreenshot` returned, or `null` — at most one. */\n screenshot: File | null;\n /** Picked and pasted files, in the order they were added; at most `maxAttachments`. */\n attachments: File[];\n}\n\ninterface FeedbackDialogBaseProps {\n open: boolean;\n onClose: () => void;\n categories: FeedbackCategoryOption[];\n category: string;\n onCategoryChange: (value: string) => void;\n /** Prop > `<UiKitProvider labels={{ feedbackDialog, feedbackAttachment }}>` >\n * English. Optional since 0.12.0; a whole `FeedbackDialogLabels` still fits. */\n labels?: LabelOverride<FeedbackDialogLabels>;\n submitting?: boolean;\n contextSlot?: ReactNode;\n attachmentAccept?: string[];\n maxAttachmentBytes?: number;\n /**\n * Optional: capture a screenshot of the underlying app view and return it as a\n * File. When provided, a \"Capture screenshot\" button is shown next to \"Add\n * attachment\"; the returned file is fed through the same validation + preview.\n */\n onCaptureScreenshot?: () => Promise<File | null>;\n /**\n * `false`: a report with only a subject can be sent, and the body's label says it is\n * optional (`bodyOptional`, unless `labels.body` is passed). Default `true`, the\n * dialog's behaviour until 0.14.2 (keksdose K1: its backend takes title-only reports).\n */\n requireBody?: boolean;\n /**\n * The attachment field's add and capture buttons: its `buttonVariant` (0.25.0),\n * Button's own `variant`. Default `\"secondary\"`, the look they always had.\n *\n * The field took `buttonVariant` / `buttonSize` in 0.24.0 (keksdose's support chat),\n * but the dialog builds its field itself and passed neither, so a host that wanted\n * quieter buttons here — a dialog that already ends in a row of Cancel / Send — had\n * no way to say so short of rebuilding the dialog. Named after the dialog's other\n * attachment options (`attachmentAccept`, `onAttachmentError`) and handed through\n * unchanged, in both `attachments` modes.\n */\n attachmentButtonVariant?: ButtonVariant;\n /** The attachment field's `buttonSize` (0.25.0) — with {@link attachmentButtonVariant}.\n * Default `\"md\"`; `\"sm\"` draws the paperclip and camera at 14px. */\n attachmentButtonSize?: ButtonSize;\n}\n\n/** One attachment — a screenshot, a picked or a pasted image; a second replaces\n * nothing, it has to wait for the first to be removed. The default. */\nexport interface FeedbackDialogSingleProps extends FeedbackDialogBaseProps {\n attachments?: \"single\";\n onSubmit: (data: FeedbackSubmission) => void | Promise<void>;\n /** `info` (0.23.0) names the refused file and the limit — see\n * {@link FeedbackAttachmentErrorInfo}. */\n onAttachmentError?: (kind: \"type\" | \"size\", info: FeedbackAttachmentErrorInfo) => void;\n /** Multiple mode only — refused here rather than silently ignored. */\n maxAttachments?: never;\n}\n\n/**\n * One screenshot plus up to `maxAttachments` picked or pasted files (0.15.5, keksdose\n * dev#578: \"pasted two photos, the second overwrote the first\"). The capture button is\n * offered while there is no screenshot yet; the add button while there is room.\n */\nexport interface FeedbackDialogMultipleProps extends FeedbackDialogBaseProps {\n attachments: \"multiple\";\n /** Default `DEFAULT_MAX_ATTACHMENTS` (5). The screenshot does not count. */\n maxAttachments?: number;\n onSubmit: (data: FeedbackMultipleSubmission) => void | Promise<void>;\n /** `\"count\"`: more files arrived at once than there was room for; the surplus was\n * dropped. `info` (0.23.0) names the refused file(s) and the limit. */\n onAttachmentError?: (kind: FeedbackAttachmentError, info: FeedbackAttachmentErrorInfo) => void;\n}\n\nexport type FeedbackDialogProps = FeedbackDialogSingleProps | FeedbackDialogMultipleProps;\n\n/**\n * The generic feedback form dialog: category + subject + body + an optional image\n * attachment, with Ctrl/Cmd+Enter to submit. Domain-free — the app supplies the\n * category options, labels and an `onSubmit` that talks to its own backend, plus\n * an optional `contextSlot` for app-specific context (user, current URL, …).\n *\n * **A screenshot can be pasted straight in.** Ctrl/Cmd+V anywhere in the dialog\n * takes an image off the clipboard and makes it the attachment, through the same\n * validation and the same preview as the file picker. It is the gesture the two\n * ways in did not cover: `onCaptureScreenshot` snapshots the *whole* app view,\n * and the file picker needs a file — so somebody who wanted to show one panel,\n * or one region of one, had to save a crop to disk first and then find it again\n * (Steering Design feedback #39). The clipboard is where a region snip already\n * is on every platform.\n *\n * **`attachments=\"multiple\"`** (0.15.5) takes several: every paste and pick adds a\n * chip, and `onSubmit` gets `{ screenshot, attachments }` ({@link\n * FeedbackMultipleSubmission}) instead of `attachment`. Opt-in, so a caller typed\n * against the one-file submission keeps compiling and behaving as before.\n */\nexport function FeedbackDialog(props: FeedbackDialogProps) {\n const {\n open,\n onClose,\n categories,\n category,\n onCategoryChange,\n labels: labelsProp,\n submitting = false,\n contextSlot,\n attachmentAccept = DEFAULT_ATTACHMENT_ACCEPT,\n maxAttachmentBytes = DEFAULT_MAX_ATTACHMENT_BYTES,\n onCaptureScreenshot,\n requireBody = true,\n attachmentButtonVariant,\n attachmentButtonSize,\n } = props;\n const [title, setTitle] = useState(\"\");\n const [body, setBody] = useState(\"\");\n const [attachment, setAttachment] = useState<File | null>(null);\n // `attachments=\"multiple\"` only: the capture, apart from the picked/pasted files.\n const [screenshot, setScreenshot] = useState<File | null>(null);\n const [files, setFiles] = useState<File[]>([]);\n const isMobile = usePhoneLayout();\n const labels = useKitLabels(\"feedbackDialog\", DEFAULT_FEEDBACK_DIALOG_LABELS, labelsProp);\n const attachmentText = useKitLabels(\"feedbackAttachment\", DEFAULT_FEEDBACK_ATTACHMENT_LABELS, labelsProp);\n // Under `multiple` the heading is `attachmentList` — a screenshot AND photos — which\n // also names the chip list beneath it: one string, so the two cannot disagree. Its old\n // second name, `feedbackDialog.attachments`, went in 0.34.\n const listHeading =\n labelsProp?.attachmentList ??\n attachmentText.attachmentList ??\n DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentList!;\n // The attachment field resolves its own keys from `feedbackAttachment`; it gets the\n // prop's (so a caller's `attachmentAdd` still wins) plus the resolved heading.\n const attachmentLabels =\n props.attachments === \"multiple\"\n ? { ...labelsProp, attachment: listHeading, attachmentList: listHeading }\n : { ...labelsProp, attachment: labels.attachment };\n\n // Reset the form whenever the dialog is (re)opened — during render, on the\n // closed-to-open transition, so the old draft never paints for a frame.\n const [wasOpen, setWasOpen] = useState(open);\n if (open !== wasOpen) {\n setWasOpen(open);\n if (open) {\n setTitle(\"\");\n setBody(\"\");\n setAttachment(null);\n setScreenshot(null);\n setFiles([]);\n }\n }\n\n // Trimmed: a subject or body of spaces is empty (keksdose's API answers a blank title\n // with a 422, and a blank report is no report).\n const canSubmit = !!title.trim() && (!requireBody || !!body.trim()) && !submitting;\n const trySubmit = () => {\n if (!canSubmit) return;\n if (props.attachments === \"multiple\") {\n void props.onSubmit({ title, body, category, screenshot, attachments: files });\n } else {\n void props.onSubmit({ title, body, category, attachment });\n }\n };\n\n if (!open) return null;\n\n const categoryField = (\n <Select label={labels.category} value={category} onChange={(e) => onCategoryChange(e.target.value)}>\n {categories.map((c) => (\n <option key={c.value} value={c.value}>\n {c.label}\n </option>\n ))}\n </Select>\n );\n // On a phone the subject leads as a heading rather than as the second of two\n // identical boxes under a select (Keksdose feedback #179). `variant=\"display\"`\n // is a no-op above the phone breakpoint, so the desktop dialog is unchanged.\n const subjectField = (\n <Input label={labels.subject} value={title} onChange={(e) => setTitle(e.target.value)} variant=\"display\" />\n );\n const bodyField = (\n <Textarea\n rows={5}\n label={requireBody ? labels.body : (labelsProp?.body ?? labels.bodyOptional ?? labels.body)}\n value={body}\n onChange={(e) => setBody(e.target.value)}\n />\n );\n const fieldProps = {\n labels: attachmentLabels,\n accept: attachmentAccept,\n maxBytes: maxAttachmentBytes,\n onCaptureScreenshot,\n // Left undefined they are the field's own defaults (secondary / md).\n buttonVariant: attachmentButtonVariant,\n buttonSize: attachmentButtonSize,\n // On `document`, not on the panel: the Modal focuses its own panel on open\n // and traps Tab inside it, so while this dialog is up every paste in the\n // page is meant for it — including the one made with nothing in\n // particular focused, which never reaches a React `onPaste` on a child.\n documentPaste: open,\n };\n const attachmentField =\n props.attachments === \"multiple\" ? (\n <FeedbackAttachmentField\n {...fieldProps}\n multiple\n value={files}\n onChange={setFiles}\n max={props.maxAttachments}\n // The capture goes to its own slot, so it is offered once and never crowds\n // out a photo; a paste is a photo (a region snip is chosen evidence, not \"the\n // screenshot\").\n screenshot={screenshot}\n onScreenshotChange={setScreenshot}\n onError={props.onAttachmentError}\n />\n ) : (\n <FeedbackAttachmentField\n {...fieldProps}\n value={attachment}\n onChange={setAttachment}\n onError={props.onAttachmentError}\n />\n );\n\n return (\n <Modal\n onClose={onClose}\n // The one dialog whose subject is the page behind it (Keksdose dev#460: \"Make\n // the feedback dialog draggable so I can see behind it if it blocks\n // something\") — you are describing what is under it while you type.\n draggable\n onKeyDown={(e) => {\n if ((e.ctrlKey || e.metaKey) && e.key === \"Enter\") {\n e.preventDefault();\n trySubmit();\n }\n }}\n >\n {/* Also the drag handle: pressing anywhere on the panel's own chrome moves it,\n and the heading is the strip a user reaches for. */}\n <h2 className=\"mb-3 text-lg font-semibold\">{labels.title}</h2>\n <div className=\"space-y-3\">\n {isMobile ? (\n // Phone shape, the same reasoning as the transaction editor's (#177):\n // the desktop order is the DATA MODEL's order — category, then subject,\n // then body — but nobody opens this dialog to pick a category. What they\n // came to do is say the thing, so that leads; the classification and the\n // evidence follow, a tier down.\n <>\n {subjectField}\n {bodyField}\n <div className=\"space-y-3 border-t border-subtle pt-3\">\n {categoryField}\n {attachmentField}\n {contextSlot}\n </div>\n </>\n ) : (\n <>\n {categoryField}\n {subjectField}\n {bodyField}\n {attachmentField}\n {contextSlot}\n </>\n )}\n <div className=\"flex items-center justify-between gap-2\">\n <div className=\"text-xs text-placeholder\">\n {typeof labels.submitHint === \"function\" ? labels.submitHint(isApplePlatform()) : labels.submitHint}\n </div>\n <div className=\"flex gap-2\">\n <Button variant=\"ghost\" onClick={onClose}>\n {labels.cancel}\n </Button>\n <Button onClick={trySubmit} disabled={!canSubmit}>\n {labels.save}\n </Button>\n </div>\n </div>\n </div>\n </Modal>\n );\n}\n"],"mappings":";AA6RQ,SAkFE,UAlFF,KAqFI,YArFJ;AA7RR,SAAS,gBAAgB;AAEzB,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AAEzB,SAAS,aAAa;AACtB,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,oBAAwC;AACjD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,sCAAsC;AAmMxC,SAAS,eAAe,OAA4B;AACzD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,aAAa;AAAA,IACb;AAAA,IACA,mBAAmB;AAAA,IACnB,qBAAqB;AAAA,IACrB;AAAA,IACA,cAAc;AAAA,IACd;AAAA,IACA;AAAA,EACF,IAAI;AACJ,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAS,EAAE;AACrC,QAAM,CAAC,MAAM,OAAO,IAAI,SAAS,EAAE;AACnC,QAAM,CAAC,YAAY,aAAa,IAAI,SAAsB,IAAI;AAE9D,QAAM,CAAC,YAAY,aAAa,IAAI,SAAsB,IAAI;AAC9D,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAiB,CAAC,CAAC;AAC7C,QAAM,WAAW,eAAe;AAChC,QAAM,SAAS,aAAa,kBAAkB,gCAAgC,UAA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U,2CACb;AAAA,gCAAC,SAAI,WAAU,4BACZ,iBAAO,OAAO,eAAe,aAAa,OAAO,WAAW,gBAAgB,CAAC,IAAI,OAAO,YAC3F;AAAA,YACA,qBAAC,SAAI,WAAU,cACb;AAAA,kCAAC,UAAO,SAAQ,SAAQ,SAAS,SAC9B,iBAAO,QACV;AAAA,cACA,oBAAC,UAAO,SAAS,WAAW,UAAU,CAAC,WACpC,iBAAO,MACV;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/feedback-dialog.tsx"],"sourcesContent":["import { useId, useState } from \"react\";\nimport type { ReactNode } from \"react\";\nimport { Button } from \"../components/button\";\nimport { Input } from \"../components/input\";\nimport { Select } from \"../components/select\";\nimport { Textarea } from \"../components/textarea\";\nimport type { ButtonSize, ButtonVariant } from \"../components/button-look\";\nimport { Modal } from \"../components/modal\";\nimport { isApplePlatform } from \"../hooks/use-hotkey\";\nimport { usePhoneLayout } from \"../hooks/use-breakpoint\";\nimport { useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport {\n DEFAULT_ATTACHMENT_ACCEPT,\n DEFAULT_FEEDBACK_ATTACHMENT_LABELS,\n DEFAULT_MAX_ATTACHMENT_BYTES,\n FeedbackAttachmentField,\n type FeedbackAttachmentError,\n type FeedbackAttachmentErrorInfo,\n} from \"./feedback-attachment\";\nimport { DEFAULT_FEEDBACK_DIALOG_LABELS } from \"./feedback-dialog-labels\";\n\nexport interface FeedbackCategoryOption {\n value: string;\n label: string;\n}\n\nexport interface FeedbackAttachmentLabels {\n /** The heading over the field. Optional: a note editor puts the buttons\n * straight under its textarea, where a second heading is noise. */\n attachment?: string;\n attachmentAdd: string;\n /** Label for the \"capture screenshot\" button. Optional — falls back to the provider's\n * `feedbackAttachment.attachmentCapture`, then English. */\n attachmentCapture?: string;\n /** The line under the attachment buttons saying a screenshot can be pasted\n * straight in. Optional — falls back to the provider's `feedbackAttachment`, then English. */\n attachmentPaste?: string;\n attachmentRemove: string;\n /** `multiple` mode (0.15.5): the chip list's accessible name — and, in\n * `<FeedbackDialog attachments=\"multiple\">`, the heading over it (0.16.0). Optional,\n * as are the keys below — they fall back to the provider's `feedbackAttachment`,\n * then English. */\n attachmentList?: string;\n /** `multiple` mode (0.16.0): the screenshot slot's chip title, in place of its file name. */\n attachmentScreenshot?: string;\n /** `multiple` mode: one chip's remove button, given the file's name. */\n attachmentRemoveFile?: (name: string) => string;\n /** `multiple` mode: the line shown once `max` files are attached. */\n attachmentLimit?: (max: number) => string;\n /** `refs` mode (0.22.0): the second line of a chip whose upload is still running. */\n attachmentUploading?: string;\n}\n\nexport interface FeedbackDialogLabels extends FeedbackAttachmentLabels {\n title: string;\n category: string;\n subject: string;\n body: string;\n attachment: string;\n /** See {@link FeedbackDialogTextLabels.submitHint}. */\n submitHint: FeedbackSubmitHint;\n cancel: string;\n save: string;\n}\n\n/** The submit hint: a string, or the line for the platform (`apple`: Mac, iPhone, iPad). */\nexport type FeedbackSubmitHint = string | ((apple: boolean) => string);\n\n/**\n * The dialog's own strings — the `feedbackDialog` namespace of `<UiKitProvider\n * labels>` (0.12.0). The attachment keys are not repeated here: they are the\n * `feedbackAttachment` namespace's, which the field inside already reads.\n *\n * Before, every key was required at the call site, so each app restated ten strings\n * wherever it mounted the dialog (kastlan feedback-button.tsx built the object inline).\n */\nexport interface FeedbackDialogTextLabels {\n title: string;\n category: string;\n subject: string;\n body: string;\n /** The body's label when `requireBody={false}`: \"What happened? (optional)\".\n * Optional, so a complete `UiKitLabels` typed before 0.14.2 still compiles. */\n bodyOptional?: string;\n /** The heading over the attachment buttons. */\n attachment: string;\n /**\n * The line beside the buttons naming the shortcut. Since 0.27.0 a function of the\n * platform, like `form.submitShortcut`: `apple` is true on a Mac, iPhone or iPad, where\n * the key is Cmd — \"⌘ Enter to send\" there, keksdose's \"Ctrl+Enter to send\" elsewhere\n * (§7.12). A plain string is still taken and shown everywhere, as before 0.27.0.\n */\n submitHint: FeedbackSubmitHint;\n cancel: string;\n save: string;\n /** 0.38 (docs/feedback-harmonization.md §9.2 decision 6): the line under the body when\n * reports are public — `useFeedbackSubmit({ publicNotice: true })` shows it. Optional,\n * so a complete `UiKitLabels` typed before 0.38 still compiles. de-CH \"Andere Personen\n * sehen Titel und Text (nie Ihre Screenshots oder Dateien).\" */\n publicNotice?: string;\n}\n\n// Defined in ./feedback-dialog-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_FEEDBACK_DIALOG_LABELS };\n\nexport interface FeedbackSubmission {\n title: string;\n body: string;\n category: string;\n attachment: File | null;\n}\n\n/**\n * What `onSubmit` gets under `attachments=\"multiple\"` (0.15.5): the screenshot and\n * the picked/pasted files apart, because an app files them differently — keksdose\n * attaches the screenshot to the report and the photos as its evidence list. No\n * `attachment`: there is no one file it could name.\n */\nexport interface FeedbackMultipleSubmission {\n title: string;\n body: string;\n category: string;\n /** What `onCaptureScreenshot` returned, or `null` — at most one. */\n screenshot: File | null;\n /** Picked and pasted files, in the order they were added; at most `maxAttachments`. */\n attachments: File[];\n}\n\ninterface FeedbackDialogBaseProps {\n open: boolean;\n onClose: () => void;\n categories: FeedbackCategoryOption[];\n category: string;\n onCategoryChange: (value: string) => void;\n /** Prop > `<UiKitProvider labels={{ feedbackDialog, feedbackAttachment }}>` >\n * English. Optional since 0.12.0; a whole `FeedbackDialogLabels` still fits. */\n labels?: LabelOverride<FeedbackDialogLabels>;\n submitting?: boolean;\n contextSlot?: ReactNode;\n attachmentAccept?: string[];\n maxAttachmentBytes?: number;\n /**\n * Optional: capture a screenshot of the underlying app view and return it as a\n * File. When provided, a \"Capture screenshot\" button is shown next to \"Add\n * attachment\"; the returned file is fed through the same validation + preview.\n */\n onCaptureScreenshot?: () => Promise<File | null>;\n /**\n * `false`: a report with only a subject can be sent, and the body's label says it is\n * optional (`bodyOptional`, unless `labels.body` is passed). Default `true`, the\n * dialog's behaviour until 0.14.2 (keksdose K1: its backend takes title-only reports).\n */\n requireBody?: boolean;\n /**\n * The attachment field's add and capture buttons: its `buttonVariant` (0.25.0),\n * Button's own `variant`. Default `\"secondary\"`, the look they always had.\n *\n * The field took `buttonVariant` / `buttonSize` in 0.24.0 (keksdose's support chat),\n * but the dialog builds its field itself and passed neither, so a host that wanted\n * quieter buttons here — a dialog that already ends in a row of Cancel / Send — had\n * no way to say so short of rebuilding the dialog. Named after the dialog's other\n * attachment options (`attachmentAccept`, `onAttachmentError`) and handed through\n * unchanged, in both `attachments` modes.\n */\n attachmentButtonVariant?: ButtonVariant;\n /** The attachment field's `buttonSize` (0.25.0) — with {@link attachmentButtonVariant}.\n * Default `\"md\"`; `\"sm\"` draws the paperclip and camera at 14px. */\n attachmentButtonSize?: ButtonSize;\n /**\n * A muted line under the body saying who will read it (0.38, docs/feedback-harmonization.md\n * §9.2 decision 6) — the kit's sentence is `feedbackDialog.publicNotice`, \"Other users\n * will see the title and text (never your screenshots or files)\", which\n * `useFeedbackSubmit({ publicNotice: true })` passes. Attached to the body field with\n * `aria-describedby`, so it is heard where the text is written. Left out: no line.\n */\n publicNotice?: ReactNode;\n}\n\n/** One attachment — a screenshot, a picked or a pasted image; a second replaces\n * nothing, it has to wait for the first to be removed. The default. */\nexport interface FeedbackDialogSingleProps extends FeedbackDialogBaseProps {\n attachments?: \"single\";\n onSubmit: (data: FeedbackSubmission) => void | Promise<void>;\n /** `info` (0.23.0) names the refused file and the limit — see\n * {@link FeedbackAttachmentErrorInfo}. */\n onAttachmentError?: (kind: \"type\" | \"size\", info: FeedbackAttachmentErrorInfo) => void;\n /** Multiple mode only — refused here rather than silently ignored. */\n maxAttachments?: never;\n}\n\n/**\n * One screenshot plus up to `maxAttachments` picked or pasted files (0.15.5, keksdose\n * dev#578: \"pasted two photos, the second overwrote the first\"). The capture button is\n * offered while there is no screenshot yet; the add button while there is room.\n */\nexport interface FeedbackDialogMultipleProps extends FeedbackDialogBaseProps {\n attachments: \"multiple\";\n /** Default `DEFAULT_MAX_ATTACHMENTS` (5). The screenshot does not count. */\n maxAttachments?: number;\n onSubmit: (data: FeedbackMultipleSubmission) => void | Promise<void>;\n /** `\"count\"`: more files arrived at once than there was room for; the surplus was\n * dropped. `info` (0.23.0) names the refused file(s) and the limit. */\n onAttachmentError?: (kind: FeedbackAttachmentError, info: FeedbackAttachmentErrorInfo) => void;\n}\n\nexport type FeedbackDialogProps = FeedbackDialogSingleProps | FeedbackDialogMultipleProps;\n\n/**\n * The generic feedback form dialog: category + subject + body + an optional image\n * attachment, with Ctrl/Cmd+Enter to submit. Domain-free — the app supplies the\n * category options, labels and an `onSubmit` that talks to its own backend, plus\n * an optional `contextSlot` for app-specific context (user, current URL, …).\n *\n * **A screenshot can be pasted straight in.** Ctrl/Cmd+V anywhere in the dialog\n * takes an image off the clipboard and makes it the attachment, through the same\n * validation and the same preview as the file picker. It is the gesture the two\n * ways in did not cover: `onCaptureScreenshot` snapshots the *whole* app view,\n * and the file picker needs a file — so somebody who wanted to show one panel,\n * or one region of one, had to save a crop to disk first and then find it again\n * (Steering Design feedback #39). The clipboard is where a region snip already\n * is on every platform.\n *\n * **`attachments=\"multiple\"`** (0.15.5) takes several: every paste and pick adds a\n * chip, and `onSubmit` gets `{ screenshot, attachments }` ({@link\n * FeedbackMultipleSubmission}) instead of `attachment`. Opt-in, so a caller typed\n * against the one-file submission keeps compiling and behaving as before.\n */\nexport function FeedbackDialog(props: FeedbackDialogProps) {\n const {\n open,\n onClose,\n categories,\n category,\n onCategoryChange,\n labels: labelsProp,\n submitting = false,\n contextSlot,\n attachmentAccept = DEFAULT_ATTACHMENT_ACCEPT,\n maxAttachmentBytes = DEFAULT_MAX_ATTACHMENT_BYTES,\n onCaptureScreenshot,\n requireBody = true,\n attachmentButtonVariant,\n attachmentButtonSize,\n publicNotice,\n } = props;\n const [title, setTitle] = useState(\"\");\n const [body, setBody] = useState(\"\");\n const [attachment, setAttachment] = useState<File | null>(null);\n // `attachments=\"multiple\"` only: the capture, apart from the picked/pasted files.\n const [screenshot, setScreenshot] = useState<File | null>(null);\n const [files, setFiles] = useState<File[]>([]);\n const isMobile = usePhoneLayout();\n const noticeId = useId();\n const hasNotice = publicNotice !== undefined && publicNotice !== null && publicNotice !== false && publicNotice !== \"\";\n const labels = useKitLabels(\"feedbackDialog\", DEFAULT_FEEDBACK_DIALOG_LABELS, labelsProp);\n const attachmentText = useKitLabels(\"feedbackAttachment\", DEFAULT_FEEDBACK_ATTACHMENT_LABELS, labelsProp);\n // Under `multiple` the heading is `attachmentList` — a screenshot AND photos — which\n // also names the chip list beneath it: one string, so the two cannot disagree. Its old\n // second name, `feedbackDialog.attachments`, went in 0.34.\n const listHeading =\n labelsProp?.attachmentList ??\n attachmentText.attachmentList ??\n DEFAULT_FEEDBACK_ATTACHMENT_LABELS.attachmentList!;\n // The attachment field resolves its own keys from `feedbackAttachment`; it gets the\n // prop's (so a caller's `attachmentAdd` still wins) plus the resolved heading.\n const attachmentLabels =\n props.attachments === \"multiple\"\n ? { ...labelsProp, attachment: listHeading, attachmentList: listHeading }\n : { ...labelsProp, attachment: labels.attachment };\n\n // Reset the form whenever the dialog is (re)opened — during render, on the\n // closed-to-open transition, so the old draft never paints for a frame.\n const [wasOpen, setWasOpen] = useState(open);\n if (open !== wasOpen) {\n setWasOpen(open);\n if (open) {\n setTitle(\"\");\n setBody(\"\");\n setAttachment(null);\n setScreenshot(null);\n setFiles([]);\n }\n }\n\n // Trimmed: a subject or body of spaces is empty (keksdose's API answers a blank title\n // with a 422, and a blank report is no report).\n const canSubmit = !!title.trim() && (!requireBody || !!body.trim()) && !submitting;\n const trySubmit = () => {\n if (!canSubmit) return;\n if (props.attachments === \"multiple\") {\n void props.onSubmit({ title, body, category, screenshot, attachments: files });\n } else {\n void props.onSubmit({ title, body, category, attachment });\n }\n };\n\n if (!open) return null;\n\n const categoryField = (\n <Select label={labels.category} value={category} onChange={(e) => onCategoryChange(e.target.value)}>\n {categories.map((c) => (\n <option key={c.value} value={c.value}>\n {c.label}\n </option>\n ))}\n </Select>\n );\n // On a phone the subject leads as a heading rather than as the second of two\n // identical boxes under a select (Keksdose feedback #179). `variant=\"display\"`\n // is a no-op above the phone breakpoint, so the desktop dialog is unchanged.\n const subjectField = (\n <Input label={labels.subject} value={title} onChange={(e) => setTitle(e.target.value)} variant=\"display\" />\n );\n const bodyTextarea = (\n <Textarea\n rows={5}\n label={requireBody ? labels.body : (labelsProp?.body ?? labels.bodyOptional ?? labels.body)}\n value={body}\n onChange={(e) => setBody(e.target.value)}\n aria-describedby={hasNotice ? noticeId : undefined}\n />\n );\n // 0.38: who will read it, right under what they are writing (§9.2 decision 6).\n const bodyField = hasNotice ? (\n <div className=\"space-y-1\">\n {bodyTextarea}\n <p id={noticeId} className=\"text-xs text-muted\" data-feedback-public-notice=\"\">\n {publicNotice}\n </p>\n </div>\n ) : (\n bodyTextarea\n );\n const fieldProps = {\n labels: attachmentLabels,\n accept: attachmentAccept,\n maxBytes: maxAttachmentBytes,\n onCaptureScreenshot,\n // Left undefined they are the field's own defaults (secondary / md).\n buttonVariant: attachmentButtonVariant,\n buttonSize: attachmentButtonSize,\n // On `document`, not on the panel: the Modal focuses its own panel on open\n // and traps Tab inside it, so while this dialog is up every paste in the\n // page is meant for it — including the one made with nothing in\n // particular focused, which never reaches a React `onPaste` on a child.\n documentPaste: open,\n };\n const attachmentField =\n props.attachments === \"multiple\" ? (\n <FeedbackAttachmentField\n {...fieldProps}\n multiple\n value={files}\n onChange={setFiles}\n max={props.maxAttachments}\n // The capture goes to its own slot, so it is offered once and never crowds\n // out a photo; a paste is a photo (a region snip is chosen evidence, not \"the\n // screenshot\").\n screenshot={screenshot}\n onScreenshotChange={setScreenshot}\n onError={props.onAttachmentError}\n />\n ) : (\n <FeedbackAttachmentField\n {...fieldProps}\n value={attachment}\n onChange={setAttachment}\n onError={props.onAttachmentError}\n />\n );\n\n return (\n <Modal\n onClose={onClose}\n // The one dialog whose subject is the page behind it (Keksdose dev#460: \"Make\n // the feedback dialog draggable so I can see behind it if it blocks\n // something\") — you are describing what is under it while you type.\n draggable\n onKeyDown={(e) => {\n if ((e.ctrlKey || e.metaKey) && e.key === \"Enter\") {\n e.preventDefault();\n trySubmit();\n }\n }}\n >\n {/* Also the drag handle: pressing anywhere on the panel's own chrome moves it,\n and the heading is the strip a user reaches for. */}\n <h2 className=\"mb-3 text-lg font-semibold\">{labels.title}</h2>\n <div className=\"space-y-3\">\n {isMobile ? (\n // Phone shape, the same reasoning as the transaction editor's (#177):\n // the desktop order is the DATA MODEL's order — category, then subject,\n // then body — but nobody opens this dialog to pick a category. What they\n // came to do is say the thing, so that leads; the classification and the\n // evidence follow, a tier down.\n <>\n {subjectField}\n {bodyField}\n <div className=\"space-y-3 border-t border-subtle pt-3\">\n {categoryField}\n {attachmentField}\n {contextSlot}\n </div>\n </>\n ) : (\n <>\n {categoryField}\n {subjectField}\n {bodyField}\n {attachmentField}\n {contextSlot}\n </>\n )}\n <div className=\"flex items-center justify-between gap-2\">\n <div className=\"text-xs text-placeholder\">\n {typeof labels.submitHint === \"function\" ? labels.submitHint(isApplePlatform()) : labels.submitHint}\n </div>\n <div className=\"flex gap-2\">\n <Button variant=\"ghost\" onClick={onClose}>\n {labels.cancel}\n </Button>\n <Button onClick={trySubmit} disabled={!canSubmit}>\n {labels.save}\n </Button>\n </div>\n </div>\n </div>\n </Modal>\n );\n}\n"],"mappings":";AA6SQ,SA8FE,UA9FF,KAuBJ,YAvBI;AA7SR,SAAS,OAAO,gBAAgB;AAEhC,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,gBAAgB;AAEzB,SAAS,aAAa;AACtB,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B,SAAS,oBAAwC;AACjD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,sCAAsC;AAgNxC,SAAS,eAAe,OAA4B;AACzD,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,I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MACP,UAAU;AAAA,MACV,KAAK,MAAM;AAAA,MAIX;AAAA,MACA,oBAAoB;AAAA,MACpB,SAAS,MAAM;AAAA;AAAA,EACjB,IAEA;AAAA,IAAC;AAAA;AAAA,MACE,GAAG;AAAA,MACJ,OAAO;AAAA,MACP,UAAU;AAAA,MACV,SAAS,MAAM;AAAA;AAAA,EACjB;AAGJ,SACE;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MAIA,WAAS;AAAA,MACT,WAAW,CAAC,MAAM;AAChB,aAAK,EAAE,WAAW,EAAE,YAAY,EAAE,QAAQ,SAAS;AACjD,YAAE,eAAe;AACjB,oBAAU;AAAA,QACZ;AAAA,MACF;AAAA,MAIA;AAAA,4BAAC,QAAG,WAAU,8BAA8B,iBAAO,OAAM;AAAA,QACzD,qBAAC,SAAI,WAAU,aACZ;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,YAMC,iCACG;AAAA;AAAA,cACA;AAAA,cACD,qBAAC,SAAI,WAAU,yCACZ;AAAA;AAAA,gBACA;AAAA,gBACA;AAAA,iBACH;AAAA,eACF;AAAA,cAEA,iCACG;AAAA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,aACH;AAAA,UAEF,qBAAC,SAAI,WAAU,2CACb;AAAA,gCAAC,SAAI,WAAU,4BACZ,iBAAO,OAAO,eAAe,aAAa,OAAO,WAAW,gBAAgB,CAAC,IAAI,OAAO,YAC3F;AAAA,YACA,qBAAC,SAAI,WAAU,cACb;AAAA,kCAAC,UAAO,SAAQ,SAAQ,SAAS,SAC9B,iBAAO,QACV;AAAA,cACA,oBAAC,UAAO,SAAS,WAAW,UAAU,CAAC,WACpC,iBAAO,MACV;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feedback/feedback-menu-labels.ts"],"sourcesContent":["// The English words of ./feedback-menu, in a module with no component code: the English\n// catalogue (src/i18n/defaults.ts) imports them without the component, so `en` loads as one\n// chunk like the other languages (0.34, KS U8). ./feedback-menu re-exports them.\n\nimport type { FeedbackMenuLabels } from \"./feedback-menu\";\n\nexport const DEFAULT_FEEDBACK_MENU_LABELS: FeedbackMenuLabels = {\n trigger: \"Send feedback\",\n myFeedback: \"My feedback\",\n viewFeedback: \"View feedback\",\n};\n"],"mappings":";AAMO,MAAM,+BAAmD;AAAA,EAC9D,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,cAAc;
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/feedback-menu-labels.ts"],"sourcesContent":["// The English words of ./feedback-menu, in a module with no component code: the English\n// catalogue (src/i18n/defaults.ts) imports them without the component, so `en` loads as one\n// chunk like the other languages (0.34, KS U8). ./feedback-menu re-exports them.\n\nimport type { FeedbackMenuLabels } from \"./feedback-menu\";\n\nexport const DEFAULT_FEEDBACK_MENU_LABELS: FeedbackMenuLabels = {\n trigger: \"Send feedback\",\n myFeedback: \"My feedback\",\n viewFeedback: \"View feedback\",\n allFeedback: \"All feedback\",\n};\n"],"mappings":";AAMO,MAAM,+BAAmD;AAAA,EAC9D,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AACf;","names":[]}
|
|
@@ -19,6 +19,10 @@ export interface FeedbackMenuLabels {
|
|
|
19
19
|
/** The link to the inbox — an admin's one list link, in place of "My feedback".
|
|
20
20
|
* keksdose `feedback.view_all`. */
|
|
21
21
|
viewFeedback: string;
|
|
22
|
+
/** The link to every public report, {@link FeedbackMenuProps.publicHref} (0.38,
|
|
23
|
+
* docs/feedback-harmonization.md §9.2 decision 21). Optional, so a complete
|
|
24
|
+
* `UiKitLabels` typed before 0.38 still compiles. de-CH "Alle Rückmeldungen". */
|
|
25
|
+
allFeedback?: string;
|
|
22
26
|
}
|
|
23
27
|
export { DEFAULT_FEEDBACK_MENU_LABELS };
|
|
24
28
|
export interface FeedbackMenuProps {
|
|
@@ -34,7 +38,7 @@ export interface FeedbackMenuProps {
|
|
|
34
38
|
* `Sparkles` Help assistant → `/assistant` and `MessagesSquare` Support chat →
|
|
35
39
|
* `/support` with its unread chip. Any {@link TopBarMenuEntry}; keep their `key`s clear
|
|
36
40
|
* of the menu's own (`BUG`, `IDEA`, `QUESTION`, `OTHER`, `feedback-divider`,
|
|
37
|
-
* `my-feedback`, `view-feedback`).
|
|
41
|
+
* `all-feedback`, `my-feedback`, `view-feedback`).
|
|
38
42
|
*/
|
|
39
43
|
extraEntries?: TopBarMenuEntry[];
|
|
40
44
|
/** The user's own reports, linked for everyone but an admin. Default `"/my-feedback"`
|
|
@@ -42,6 +46,15 @@ export interface FeedbackMenuProps {
|
|
|
42
46
|
myFeedbackHref?: string;
|
|
43
47
|
/** The admin inbox, linked for an admin. Default `"/feedback"` (§2.3). */
|
|
44
48
|
inboxHref?: string;
|
|
49
|
+
/**
|
|
50
|
+
* The public list (0.38, docs/feedback-harmonization.md §9.2 decision 21): when passed,
|
|
51
|
+
* an **All feedback** row (`Users`, key `all-feedback`) above the list link, for
|
|
52
|
+
* everyone — the admin too, who reads what the others read there. keksdose:
|
|
53
|
+
* `"/all-feedback"`; "My feedback" stays as it is. Leave it out where the app has no
|
|
54
|
+
* public parts (kastlan) or the viewer may not see them (a Kurvenschmiede customer, a
|
|
55
|
+
* demo — §9.2 decisions 7, 8).
|
|
56
|
+
*/
|
|
57
|
+
publicHref?: string;
|
|
45
58
|
/** A dot on the trigger — keksdose's unread support replies (`tone: "danger"`). Its
|
|
46
59
|
* `label` joins the trigger's name ("Send feedback 2 unread"). The words are the app's. */
|
|
47
60
|
iconBadge?: UserAvatarBadge | null;
|
|
@@ -60,7 +73,8 @@ export interface FeedbackMenuProps {
|
|
|
60
73
|
* the category badges' own glyphs), each calling `onFile(category)`;
|
|
61
74
|
* 3. a divider, always;
|
|
62
75
|
* 4. the app's `extraEntries`;
|
|
63
|
-
* 5.
|
|
76
|
+
* 5. with `publicHref` (0.38), **All feedback** → the public list, for everyone;
|
|
77
|
+
* 6. ONE list link, `Inbox`: an admin's is "View feedback" → `/feedback`, everyone
|
|
64
78
|
* else's "My feedback" → `/my-feedback` — keksdose's (`top-bar.tsx:205-214`, feedback
|
|
65
79
|
* #331: admins get the management view, everyone else their own submissions).
|
|
66
80
|
*
|
|
@@ -80,4 +94,4 @@ export interface FeedbackMenuProps {
|
|
|
80
94
|
* tour anchor (`data-tour="feedback-menu"`) stays on a wrapping `<span>`. Needs a router,
|
|
81
95
|
* as every `TopBarActionMenu` with link rows does.
|
|
82
96
|
*/
|
|
83
|
-
export declare function FeedbackMenu({ onFile, isAdmin, extraEntries, myFeedbackHref, inboxHref, iconBadge, labels: labelsProp, align, }: FeedbackMenuProps): import("react").JSX.Element;
|
|
97
|
+
export declare function FeedbackMenu({ onFile, isAdmin, extraEntries, myFeedbackHref, inboxHref, publicHref, iconBadge, labels: labelsProp, align, }: FeedbackMenuProps): import("react").JSX.Element;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Inbox, MessageSquare } from "lucide-react";
|
|
3
|
+
import { Inbox, MessageSquare, Users } from "lucide-react";
|
|
4
4
|
import { useKitLabels } from "../i18n/kit-labels.js";
|
|
5
5
|
import { TopBarActionMenu } from "../shell/topbar-action-menu.js";
|
|
6
6
|
import { FEEDBACK_CATEGORY_META } from "./feedback-vocabulary.js";
|
|
@@ -13,6 +13,7 @@ function FeedbackMenu({
|
|
|
13
13
|
extraEntries,
|
|
14
14
|
myFeedbackHref = "/my-feedback",
|
|
15
15
|
inboxHref = "/feedback",
|
|
16
|
+
publicHref,
|
|
16
17
|
iconBadge,
|
|
17
18
|
labels: labelsProp,
|
|
18
19
|
align
|
|
@@ -31,6 +32,15 @@ function FeedbackMenu({
|
|
|
31
32
|
}),
|
|
32
33
|
{ kind: "divider", key: "feedback-divider" },
|
|
33
34
|
...extraEntries ?? [],
|
|
35
|
+
...publicHref ? [
|
|
36
|
+
{
|
|
37
|
+
kind: "link",
|
|
38
|
+
key: "all-feedback",
|
|
39
|
+
to: publicHref,
|
|
40
|
+
icon: /* @__PURE__ */ jsx(Users, { className: "size-4" }),
|
|
41
|
+
label: labels.allFeedback ?? DEFAULT_FEEDBACK_MENU_LABELS.allFeedback
|
|
42
|
+
}
|
|
43
|
+
] : [],
|
|
34
44
|
{
|
|
35
45
|
kind: "link",
|
|
36
46
|
key: isAdmin ? "view-feedback" : "my-feedback",
|