@eifi1/ui-kit 0.52.0 → 0.54.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 +52 -59
- package/dist/account/delete-account-setting.d.ts +3 -2
- package/dist/account/delete-account-setting.js.map +1 -1
- package/dist/auth/auth-errors.d.ts +36 -0
- package/dist/auth/auth-errors.js +20 -0
- package/dist/auth/auth-errors.js.map +1 -1
- package/dist/billing/cancel-subscription.d.ts +5 -14
- package/dist/billing/cancel-subscription.js +1 -3
- package/dist/billing/cancel-subscription.js.map +1 -1
- package/dist/billing/plan-card.d.ts +5 -13
- package/dist/billing/plan-card.js +3 -11
- package/dist/billing/plan-card.js.map +1 -1
- package/dist/billing/plan-switch.d.ts +5 -14
- package/dist/billing/plan-switch.js +1 -3
- package/dist/billing/plan-switch.js.map +1 -1
- package/dist/chart.d.ts +3 -14
- package/dist/chart.js +64 -11
- package/dist/chart.js.map +1 -1
- package/dist/components/amount-input.d.ts +2 -1
- package/dist/components/amount-input.js.map +1 -1
- package/dist/components/calendar-heatmap.js +4 -2
- package/dist/components/calendar-heatmap.js.map +1 -1
- package/dist/components/currency-option-list.d.ts +2 -1
- package/dist/components/currency-option-list.js +10 -3
- package/dist/components/currency-option-list.js.map +1 -1
- package/dist/components/currency-select.d.ts +3 -1
- package/dist/components/currency-select.js.map +1 -1
- package/dist/components/danger-confirm.d.ts +22 -1
- package/dist/components/danger-confirm.js +50 -28
- package/dist/components/danger-confirm.js.map +1 -1
- package/dist/components/data-table-filter-popover.d.ts +2 -1
- package/dist/components/data-table-filter-popover.js +3 -2
- package/dist/components/data-table-filter-popover.js.map +1 -1
- package/dist/components/data-table-filters.d.ts +33 -3
- package/dist/components/data-table-filters.js +6 -4
- package/dist/components/data-table-filters.js.map +1 -1
- package/dist/components/date-field.d.ts +1 -1
- package/dist/components/date-field.js.map +1 -1
- package/dist/components/date-picker.d.ts +1 -1
- package/dist/components/date-picker.js.map +1 -1
- package/dist/components/date-range-picker.d.ts +4 -17
- package/dist/components/date-range-picker.js +2 -2
- package/dist/components/date-range-picker.js.map +1 -1
- package/dist/components/dialog-frame.d.ts +3 -1
- package/dist/components/dialog-frame.js +6 -2
- package/dist/components/dialog-frame.js.map +1 -1
- package/dist/components/mini-calendar.js +3 -2
- package/dist/components/mini-calendar.js.map +1 -1
- package/dist/components/modal.d.ts +27 -0
- package/dist/components/modal.js +5 -3
- package/dist/components/modal.js.map +1 -1
- package/dist/components/nav-pills.d.ts +1 -1
- package/dist/components/nav-pills.js.map +1 -1
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/series-chart-axes.d.ts +1 -1
- package/dist/components/series-chart-axes.js.map +1 -1
- package/dist/components/series-chart.d.ts +64 -19
- package/dist/components/series-chart.js +2 -1
- package/dist/components/series-chart.js.map +1 -1
- package/dist/components/stat-tile.d.ts +21 -2
- package/dist/components/stat-tile.js +4 -2
- package/dist/components/stat-tile.js.map +1 -1
- package/dist/components/treemap-labels.d.ts +6 -1
- package/dist/components/treemap-labels.js +2 -2
- package/dist/components/treemap-labels.js.map +1 -1
- package/dist/components/treemap.d.ts +29 -4
- package/dist/components/treemap.js +22 -9
- package/dist/components/treemap.js.map +1 -1
- package/dist/currencies.d.ts +16 -2
- package/dist/currencies.js +2 -1
- package/dist/currencies.js.map +1 -1
- package/dist/data-table.d.ts +1 -6
- package/dist/data-table.js +1 -9
- package/dist/data-table.js.map +1 -1
- package/dist/demo/demo-countdown.d.ts +0 -5
- package/dist/demo/demo-countdown.js +0 -4
- package/dist/demo/demo-countdown.js.map +1 -1
- package/dist/eslint/index.js +1 -1
- package/dist/feedback/feedback-context-labels.js +2 -1
- package/dist/feedback/feedback-context-labels.js.map +1 -1
- package/dist/feedback/feedback-context.d.ts +19 -3
- package/dist/feedback/feedback-context.js +12 -1
- package/dist/feedback/feedback-context.js.map +1 -1
- package/dist/feedback/feedback-diagnostics.d.ts +17 -0
- package/dist/feedback/feedback-diagnostics.js +27 -0
- package/dist/feedback/feedback-diagnostics.js.map +1 -0
- package/dist/feedback/feedback-dialog.d.ts +10 -0
- package/dist/feedback/feedback-dialog.js +6 -4
- package/dist/feedback/feedback-dialog.js.map +1 -1
- package/dist/feedback/feedback-mutation.d.ts +11 -23
- package/dist/feedback/feedback-mutation.js +1 -9
- package/dist/feedback/feedback-mutation.js.map +1 -1
- package/dist/feedback/feedback-public-list.d.ts +1 -6
- package/dist/feedback/feedback-public-list.js +1 -2
- package/dist/feedback/feedback-public-list.js.map +1 -1
- package/dist/feedback/feedback-record.d.ts +5 -0
- package/dist/feedback/feedback-record.js.map +1 -1
- package/dist/feedback/feedback-row-detail-labels.js +1 -8
- package/dist/feedback/feedback-row-detail-labels.js.map +1 -1
- package/dist/feedback/feedback-row-detail.d.ts +6 -50
- package/dist/feedback/feedback-row-detail.js +3 -8
- package/dist/feedback/feedback-row-detail.js.map +1 -1
- package/dist/feedback/feedback-status-undo.d.ts +3 -19
- package/dist/feedback/feedback-status-undo.js.map +1 -1
- package/dist/feedback/feedback-submit-dialog.d.ts +5 -1
- package/dist/feedback/feedback-submit-dialog.js +15 -3
- package/dist/feedback/feedback-submit-dialog.js.map +1 -1
- package/dist/feedback/feedback-submit.d.ts +30 -2
- package/dist/feedback/feedback-submit.js +5 -2
- package/dist/feedback/feedback-submit.js.map +1 -1
- package/dist/feedback/feedback-thread.d.ts +0 -9
- package/dist/feedback/feedback-thread.js.map +1 -1
- package/dist/feedback.d.ts +6 -40
- package/dist/feedback.js +88 -46
- package/dist/feedback.js.map +1 -1
- package/dist/hooks/use-hotkey.js +11 -1
- package/dist/hooks/use-hotkey.js.map +1 -1
- package/dist/i18n/defaults.js +0 -4
- package/dist/i18n/defaults.js.map +1 -1
- package/dist/i18n/german.js +5 -20
- package/dist/i18n/german.js.map +1 -1
- package/dist/i18n/kit-labels.d.ts +5 -14
- package/dist/i18n/kit-labels.js.map +1 -1
- package/dist/i18n/locales/en.js +5 -31
- package/dist/i18n/locales/en.js.map +3 -3
- package/dist/i18n/locales/es.js +5 -20
- package/dist/i18n/locales/es.js.map +1 -1
- package/dist/i18n/locales/fr.js +5 -20
- package/dist/i18n/locales/fr.js.map +1 -1
- package/dist/i18n/locales/hu.js +5 -20
- package/dist/i18n/locales/hu.js.map +1 -1
- package/dist/i18n/locales/it.js +5 -21
- package/dist/i18n/locales/it.js.map +1 -1
- package/dist/i18n/locales/zh.js +5 -20
- package/dist/i18n/locales/zh.js.map +1 -1
- package/dist/i18n/review.js +9 -4
- package/dist/i18n/review.js.map +1 -1
- package/dist/i18n/shared-labels.js +0 -1
- package/dist/i18n/shared-labels.js.map +1 -1
- package/dist/index.d.ts +18 -67
- package/dist/index.js +28 -103
- package/dist/index.js.map +1 -1
- package/dist/lib/dates.d.ts +7 -1
- package/dist/lib/dates.js +8 -1
- package/dist/lib/dates.js.map +1 -1
- package/dist/lib/format.d.ts +37 -2
- package/dist/lib/format.js +25 -1
- package/dist/lib/format.js.map +1 -1
- package/dist/lib/intl-cache.d.ts +4 -2
- package/dist/lib/intl-cache.js.map +1 -1
- package/dist/lib/translation-review.d.ts +26 -0
- package/dist/lib/translation-review.js +14 -0
- package/dist/lib/translation-review.js.map +1 -1
- package/dist/rhf/fields.d.ts +2 -2
- package/dist/rhf/fields.js.map +1 -1
- package/dist/search/search-index.d.ts +0 -6
- package/dist/search/search-index.js +0 -4
- package/dist/search/search-index.js.map +1 -1
- package/dist/search.d.ts +1 -8
- package/dist/search.js +2 -7
- package/dist/search.js.map +1 -1
- package/dist/shell/account-menu-language.d.ts +7 -21
- package/dist/shell/account-menu-language.js +1 -3
- package/dist/shell/account-menu-language.js.map +1 -1
- package/dist/shell/account-menu-text-size.d.ts +9 -23
- package/dist/shell/account-menu-text-size.js +2 -3
- package/dist/shell/account-menu-text-size.js.map +1 -1
- package/dist/shell/app-shell.d.ts +0 -10
- package/dist/shell/app-shell.js +1 -7
- package/dist/shell/app-shell.js.map +1 -1
- package/dist/shell/company-switcher.d.ts +1 -1
- package/dist/shell/company-switcher.js.map +1 -1
- package/dist/shell/dev-menu.d.ts +1 -1
- package/dist/shell/dev-menu.js.map +1 -1
- package/dist/shell/top-bar-parts-labels.d.ts +1 -1
- package/dist/shell/top-bar-parts-labels.js.map +1 -1
- package/dist/shell.d.ts +7 -29
- package/dist/shell.js +12 -42
- package/dist/shell.js.map +1 -1
- package/dist/sync.d.ts +2 -6
- package/dist/sync.js +2 -15
- package/dist/sync.js.map +1 -1
- package/dist/theme/chart-palette.d.ts +0 -5
- package/dist/theme/chart-palette.js +0 -2
- package/dist/theme/chart-palette.js.map +1 -1
- package/package.json +1 -1
- package/src/account/delete-account-setting.tsx +3 -2
- package/src/auth/auth-errors.ts +69 -0
- package/src/billing/cancel-subscription.tsx +5 -16
- package/src/billing/plan-card.tsx +7 -24
- package/src/billing/plan-switch.tsx +5 -16
- package/src/chart.ts +62 -13
- package/src/components/amount-input.tsx +2 -1
- package/src/components/calendar-heatmap.tsx +8 -2
- package/src/components/currency-option-list.tsx +12 -4
- package/src/components/currency-select.tsx +3 -1
- package/src/components/danger-confirm.tsx +80 -27
- package/src/components/data-table-filter-popover.tsx +19 -11
- package/src/components/data-table-filters.ts +36 -8
- package/src/components/date-field.tsx +1 -1
- package/src/components/date-picker.tsx +0 -1
- package/src/components/date-range-picker.tsx +6 -22
- package/src/components/dialog-frame.tsx +12 -4
- package/src/components/mini-calendar.tsx +5 -2
- package/src/components/modal.tsx +36 -7
- package/src/components/nav-pills.tsx +1 -1
- package/src/components/number-input.tsx +4 -3
- package/src/components/series-chart-axes.ts +6 -1
- package/src/components/series-chart.tsx +78 -21
- package/src/components/stat-tile.tsx +32 -3
- package/src/components/treemap-labels.ts +11 -3
- package/src/components/treemap.tsx +65 -12
- package/src/currencies.ts +23 -3
- package/src/data-table.ts +1 -11
- package/src/demo/demo-countdown.ts +3 -8
- package/src/feedback/feedback-context-labels.ts +1 -0
- package/src/feedback/feedback-context.tsx +34 -2
- package/src/feedback/feedback-diagnostics.tsx +41 -0
- package/src/feedback/feedback-dialog.tsx +16 -4
- package/src/feedback/feedback-mutation.ts +12 -33
- package/src/feedback/feedback-public-list.tsx +1 -7
- package/src/feedback/feedback-record.ts +5 -0
- package/src/feedback/feedback-row-detail-labels.ts +1 -8
- package/src/feedback/feedback-row-detail.tsx +21 -58
- package/src/feedback/feedback-status-undo.ts +4 -18
- package/src/feedback/feedback-submit-dialog.tsx +15 -2
- package/src/feedback/feedback-submit.tsx +36 -3
- package/src/feedback/feedback-thread.tsx +0 -10
- package/src/feedback.ts +89 -48
- package/src/hooks/use-hotkey.ts +24 -1
- package/src/i18n/defaults.ts +0 -4
- package/src/i18n/german.ts +4 -19
- package/src/i18n/kit-labels.tsx +5 -14
- package/src/i18n/locales/es.ts +4 -19
- package/src/i18n/locales/fr.ts +4 -19
- package/src/i18n/locales/hu.ts +4 -19
- package/src/i18n/locales/it.ts +4 -20
- package/src/i18n/locales/zh.ts +4 -19
- package/src/i18n/review.ts +9 -4
- package/src/i18n/shared-labels.ts +0 -1
- package/src/index.ts +44 -114
- package/src/lib/dates.ts +24 -2
- package/src/lib/format.ts +66 -3
- package/src/lib/intl-cache.ts +4 -2
- package/src/lib/translation-review.ts +52 -0
- package/src/rhf/fields.tsx +2 -2
- package/src/search/search-index.ts +0 -15
- package/src/search.ts +8 -8
- package/src/shell/account-menu-language.tsx +7 -27
- package/src/shell/account-menu-text-size.tsx +13 -32
- package/src/shell/app-shell.tsx +0 -13
- package/src/shell/company-switcher.tsx +1 -1
- package/src/shell/dev-menu.tsx +1 -1
- package/src/shell/top-bar-parts-labels.ts +1 -1
- package/src/shell.ts +17 -44
- package/src/sync.ts +2 -15
- package/src/theme/chart-palette.ts +0 -2
- package/tokens.css +4 -4
- package/dist/billing/dialog-close.d.ts +0 -29
- package/dist/billing/dialog-close.js +0 -8
- package/dist/billing/dialog-close.js.map +0 -1
- package/dist/components/field-sync-labels.d.ts +0 -3
- package/dist/components/field-sync-labels.js +0 -12
- package/dist/components/field-sync-labels.js.map +0 -1
- package/dist/components/field-sync.d.ts +0 -186
- package/dist/components/field-sync.js +0 -269
- package/dist/components/field-sync.js.map +0 -1
- package/dist/components/section-nav.d.ts +0 -44
- package/dist/components/section-nav.js +0 -33
- package/dist/components/section-nav.js.map +0 -1
- package/dist/components/sign-chip-labels.d.ts +0 -3
- package/dist/components/sign-chip-labels.js +0 -11
- package/dist/components/sign-chip-labels.js.map +0 -1
- package/dist/components/sign-chip.d.ts +0 -77
- package/dist/components/sign-chip.js +0 -47
- package/dist/components/sign-chip.js.map +0 -1
- package/dist/lib/isin.d.ts +0 -38
- package/dist/lib/isin.js +0 -36
- package/dist/lib/isin.js.map +0 -1
- package/dist/shell/role-switcher.d.ts +0 -28
- package/dist/shell/role-switcher.js +0 -31
- package/dist/shell/role-switcher.js.map +0 -1
- package/src/billing/dialog-close.ts +0 -34
- package/src/components/field-sync-labels.ts +0 -14
- package/src/components/field-sync.tsx +0 -504
- package/src/components/section-nav.tsx +0 -72
- package/src/components/sign-chip-labels.ts +0 -13
- package/src/components/sign-chip.tsx +0 -133
- package/src/lib/isin.ts +0 -72
- package/src/shell/role-switcher.tsx +0 -53
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feedback/feedback-context-labels.ts"],"sourcesContent":["// The English words of ./feedback-context, 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-context re-exports them.\n\nimport type { FeedbackContextLabels } from \"./feedback-context\";\n\nexport const DEFAULT_FEEDBACK_CONTEXT_LABELS: FeedbackContextLabels = {\n user: \"User\",\n attachUrl: \"Attach current page URL\",\n};\n"],"mappings":";AAMO,MAAM,kCAAyD;AAAA,EACpE,MAAM;AAAA,EACN,WAAW;
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/feedback-context-labels.ts"],"sourcesContent":["// The English words of ./feedback-context, 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-context re-exports them.\n\nimport type { FeedbackContextLabels } from \"./feedback-context\";\n\nexport const DEFAULT_FEEDBACK_CONTEXT_LABELS: FeedbackContextLabels = {\n user: \"User\",\n attachUrl: \"Attach current page URL\",\n diagnostics: \"Diagnostics sent with the report\",\n};\n"],"mappings":";AAMO,MAAM,kCAAyD;AAAA,EACpE,MAAM;AAAA,EACN,WAAW;AAAA,EACX,aAAa;AACf;","names":[]}
|
|
@@ -52,16 +52,21 @@ export interface FeedbackContextInput {
|
|
|
52
52
|
viewport?: string;
|
|
53
53
|
/** Default `navigator.userAgent`. */
|
|
54
54
|
ua?: string;
|
|
55
|
+
/** What the app attached about the thing reported — `useFeedbackSubmit().open(category,
|
|
56
|
+
* { diagnostics })` (keksdose live #481). Sent whatever `attachUrl` says, as the box
|
|
57
|
+
* shows it; left out of the object when it has no key to show. */
|
|
58
|
+
diagnostics?: Readonly<Record<string, unknown>> | null;
|
|
55
59
|
}
|
|
56
60
|
/**
|
|
57
61
|
* The `context` object of `POST /feedback` (§3.2), keys in keksdose's order: `url`, `route`,
|
|
58
62
|
* `origin`, `environment`, `user_id`, `user_email`, `user_display_name`, `viewport`, `ua`,
|
|
59
|
-
* `version`.
|
|
63
|
+
* `version`, then the app's `diagnostics`.
|
|
60
64
|
*
|
|
61
65
|
* With `attachUrl: false`, `url` and `route` are `""` — present and empty, as keksdose
|
|
62
66
|
* sends them, so a reader can tell "withheld" from "an old row without the key".
|
|
63
67
|
* `environment` and `version` are omitted when the app passes none (kastlan had no
|
|
64
|
-
* version), rather than sent as `undefined
|
|
68
|
+
* version), rather than sent as `undefined`; `diagnostics` when the box would show no
|
|
69
|
+
* line of it (none, `{}`, not a record).
|
|
65
70
|
*
|
|
66
71
|
* Reads `window` / `navigator` only for the defaults it was not given, so it is a pure
|
|
67
72
|
* function in a test that passes everything.
|
|
@@ -78,6 +83,9 @@ export interface FeedbackContextLabels {
|
|
|
78
83
|
user: string;
|
|
79
84
|
/** The checkbox. The URL it is about is the line beneath it. */
|
|
80
85
|
attachUrl: string;
|
|
86
|
+
/** The heading over what the app attached — `open(category, { diagnostics })`, shown
|
|
87
|
+
* read-only under the URL (keksdose live #481). de-CH: "Mitgesendete Diagnose" */
|
|
88
|
+
diagnostics: string;
|
|
81
89
|
}
|
|
82
90
|
export { DEFAULT_FEEDBACK_CONTEXT_LABELS };
|
|
83
91
|
export interface FeedbackContextBoxProps {
|
|
@@ -88,6 +96,10 @@ export interface FeedbackContextBoxProps {
|
|
|
88
96
|
/** The checkbox, on by default in the dialog (§4.2) — the same `attachUrl`. */
|
|
89
97
|
attachUrl: boolean;
|
|
90
98
|
onAttachUrlChange: (next: boolean) => void;
|
|
99
|
+
/** What the app attached — the same `diagnostics` handed to {@link feedbackContext}.
|
|
100
|
+
* Shown read-only, each key and its value as the row detail draws them; no block when
|
|
101
|
+
* there is no line to show. */
|
|
102
|
+
diagnostics?: Readonly<Record<string, unknown>> | null;
|
|
91
103
|
/** Prop > `<UiKitProvider labels={{ feedbackContext }}>` > English. */
|
|
92
104
|
labels?: LabelOverride<FeedbackContextLabels>;
|
|
93
105
|
className?: string;
|
|
@@ -104,7 +116,11 @@ export interface FeedbackContextBoxProps {
|
|
|
104
116
|
* against whatever screen happened to be open, the queue reads as if it were about that
|
|
105
117
|
* screen.
|
|
106
118
|
*
|
|
119
|
+
* Below the URL, what the app attached (`diagnostics`, keksdose live #481: a stuck receipt
|
|
120
|
+
* scan's bookkeeping), read-only and in the row detail's own lines: the reporter sees what
|
|
121
|
+
* goes with the report, and that the URL checkbox does not withhold it.
|
|
122
|
+
*
|
|
107
123
|
* Nothing in here is the app's: hand it the values handed to {@link feedbackContext}, and
|
|
108
124
|
* what the box shows is what is sent.
|
|
109
125
|
*/
|
|
110
|
-
export declare function FeedbackContextBox({ user, url, attachUrl, onAttachUrlChange, labels: labelsProp, className, }: FeedbackContextBoxProps): import("react").JSX.Element;
|
|
126
|
+
export declare function FeedbackContextBox({ user, url, attachUrl, onAttachUrlChange, diagnostics, labels: labelsProp, className, }: FeedbackContextBoxProps): import("react").JSX.Element;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId } from "react";
|
|
3
4
|
import { Checkbox } from "../components/checkbox.js";
|
|
4
5
|
import { DEFAULT_COMMON_LABELS, useKitLabels } from "../i18n/kit-labels.js";
|
|
5
6
|
import { cn } from "../lib/cn.js";
|
|
6
7
|
import { DEFAULT_FEEDBACK_CONTEXT_LABELS } from "./feedback-context-labels.js";
|
|
8
|
+
import { diagnosticsEntries, FeedbackDiagnosticsList } from "./feedback-diagnostics.js";
|
|
7
9
|
function submitterLine(user) {
|
|
8
10
|
const name = user?.display_name?.trim();
|
|
9
11
|
const email = user?.email?.trim();
|
|
@@ -34,6 +36,7 @@ function feedbackContext(input) {
|
|
|
34
36
|
context.viewport = input.viewport ?? (win ? `${win.innerWidth}x${win.innerHeight}` : "");
|
|
35
37
|
context.ua = input.ua ?? (typeof navigator === "undefined" ? "" : navigator.userAgent);
|
|
36
38
|
if (input.version !== void 0) context.version = input.version;
|
|
39
|
+
if (input.diagnostics && diagnosticsEntries(input.diagnostics).length) context.diagnostics = input.diagnostics;
|
|
37
40
|
return context;
|
|
38
41
|
}
|
|
39
42
|
function FeedbackContextBox({
|
|
@@ -41,11 +44,14 @@ function FeedbackContextBox({
|
|
|
41
44
|
url,
|
|
42
45
|
attachUrl,
|
|
43
46
|
onAttachUrlChange,
|
|
47
|
+
diagnostics,
|
|
44
48
|
labels: labelsProp,
|
|
45
49
|
className
|
|
46
50
|
}) {
|
|
47
51
|
const labels = useKitLabels("feedbackContext", DEFAULT_FEEDBACK_CONTEXT_LABELS, labelsProp);
|
|
48
52
|
const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
|
|
53
|
+
const diagnosticsId = useId();
|
|
54
|
+
const attached = diagnosticsEntries(diagnostics);
|
|
49
55
|
const submitter = submitterLine(user);
|
|
50
56
|
const line = common.fieldValue(labels.user, submitter);
|
|
51
57
|
const lead = line.endsWith(submitter) ? line.slice(0, line.length - submitter.length) : null;
|
|
@@ -77,7 +83,12 @@ function FeedbackContextBox({
|
|
|
77
83
|
)
|
|
78
84
|
) : void 0
|
|
79
85
|
}
|
|
80
|
-
)
|
|
86
|
+
),
|
|
87
|
+
attached.length > 0 && // A named group, so a screen reader hears what the pairs are before it reads them.
|
|
88
|
+
/* @__PURE__ */ jsxs("div", { role: "group", "aria-labelledby": diagnosticsId, className: "space-y-0.5 pt-1", children: [
|
|
89
|
+
/* @__PURE__ */ jsx("div", { id: diagnosticsId, className: "font-medium text-secondary", children: labels.diagnostics }),
|
|
90
|
+
/* @__PURE__ */ jsx(FeedbackDiagnosticsList, { entries: attached })
|
|
91
|
+
] })
|
|
81
92
|
]
|
|
82
93
|
}
|
|
83
94
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feedback/feedback-context.tsx"],"sourcesContent":["import { Checkbox } from \"../components/checkbox\";\nimport { DEFAULT_COMMON_LABELS, useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport type { FeedbackContext, FeedbackEnvironment } from \"./feedback-record\";\nimport { DEFAULT_FEEDBACK_CONTEXT_LABELS } from \"./feedback-context-labels\";\n\n/**\n * The reporter context of a feedback report: the box the submit dialog shows, and the\n * `context` object `POST /feedback` sends (0.27.0, docs/feedback-harmonization.md §3.2,\n * §4.2). One file for both, so what the box SAYS will be sent and what IS sent cannot\n * drift apart.\n *\n * Each app had written both halves itself (keksdose `use-feedback-dialog.tsx:105` and\n * `:222`, kastlan `feedback-button.tsx:80`, Kurvenschmiede `use-feedback-dialog.tsx:124`),\n * and they had drifted: kastlan sent six keys with `user_email: null` and no version,\n * Kurvenschmiede a `page_path` column and a sentence where keksdose had a labelled box,\n * and only keksdose showed the full URL it was about to send.\n */\n\n/* ── Who is filing ───────────────────────────────────────────────────────── */\n\n/**\n * The person filing, as the app knows them. Snake case on purpose: keksdose's and\n * Kurvenschmiede's user objects already have this shape (`id`, `email`, `display_name`),\n * so they pass their `user` as it is; kastlan maps its token's `sub` and name parts.\n *\n * A SNAPSHOT for the report and the box. The server should overwrite the three `user_*`\n * keys from the session (§3.2; Kurvenschmiede does), so nobody can file in someone else's\n * name — this is what the reporter is SHOWN, not proof of who they are.\n */\nexport interface FeedbackSubmitter {\n id?: number | null;\n email?: string | null;\n display_name?: string | null;\n}\n\n/** \"Ada Example (ada@example.com)\", the name alone, the email alone, or \"—\" when the app\n * knows neither (keksdose `use-feedback-dialog.tsx:228`). */\nfunction submitterLine(user: FeedbackSubmitter | null | undefined): string {\n const name = user?.display_name?.trim();\n const email = user?.email?.trim();\n if (name && email) return `${name} (${email})`;\n return name || email || \"—\";\n}\n\n/* ── The object (§3.2) ───────────────────────────────────────────────────── */\n\n/** What {@link feedbackContext} is built from. */\nexport interface FeedbackContextInput {\n /** The submitter, or `null` when signed out / unknown — the three `user_*` keys are then\n * `null`, as keksdose sends them. */\n user?: FeedbackSubmitter | null;\n /** The box's \"Attach current page URL\" checkbox. `false` withholds `url` and `route`\n * (both `\"\"`); nothing else is withheld — `origin` says which copy of the app, which is\n * not personal, and triage needs it first (keksdose `use-feedback-dialog.tsx:110`). */\n attachUrl: boolean;\n /** `location.href` when the dialog OPENED — the page the report is about, not the one\n * the reporter may have navigated to while typing. */\n url: string;\n /** Its pathname. Default: read off `url` (a path-only `url` works too). */\n route?: string;\n /** Default `location.origin`. */\n origin?: string;\n /** `\"prod\"` / `\"dev\"` / `\"local\"` — the app's own reading (keksdose\n * `app/deploy-environment.ts`). Left out of the object when not given. */\n environment?: FeedbackEnvironment | (string & {});\n /** The app build (`__APP_VERSION__`). Left out of the object when not given. */\n version?: string;\n /** Default `${innerWidth}x${innerHeight}` at the time of the call — \"406x816\". */\n viewport?: string;\n /** Default `navigator.userAgent`. */\n ua?: string;\n}\n\n/** The pathname of a full or path-only URL; `\"\"` for something that is neither. */\nfunction pathOf(url: string, base: string | undefined): string {\n if (!url) return \"\";\n try {\n return new URL(url, base || \"http://localhost\").pathname;\n } catch {\n return \"\";\n }\n}\n\n/**\n * The `context` object of `POST /feedback` (§3.2), keys in keksdose's order: `url`, `route`,\n * `origin`, `environment`, `user_id`, `user_email`, `user_display_name`, `viewport`, `ua`,\n * `version`.\n *\n * With `attachUrl: false`, `url` and `route` are `\"\"` — present and empty, as keksdose\n * sends them, so a reader can tell \"withheld\" from \"an old row without the key\".\n * `environment` and `version` are omitted when the app passes none (kastlan had no\n * version), rather than sent as `undefined`.\n *\n * Reads `window` / `navigator` only for the defaults it was not given, so it is a pure\n * function in a test that passes everything.\n */\nexport function feedbackContext(input: FeedbackContextInput): FeedbackContext {\n const { user, attachUrl, url } = input;\n const win = typeof window === \"undefined\" ? undefined : window;\n const origin = input.origin ?? win?.location.origin ?? \"\";\n const context: FeedbackContext = {\n url: attachUrl ? url : \"\",\n route: attachUrl ? (input.route ?? pathOf(url, origin || win?.location.href)) : \"\",\n origin,\n };\n if (input.environment !== undefined) context.environment = input.environment;\n context.user_id = user?.id ?? null;\n context.user_email = user?.email ?? null;\n context.user_display_name = user?.display_name ?? null;\n context.viewport = input.viewport ?? (win ? `${win.innerWidth}x${win.innerHeight}` : \"\");\n context.ua = input.ua ?? (typeof navigator === \"undefined\" ? \"\" : navigator.userAgent);\n if (input.version !== undefined) context.version = input.version;\n return context;\n}\n\n/* ── The box (§4.2) ──────────────────────────────────────────────────────── */\n\n/**\n * `feedbackContext` — the context box's words. de-CH canon (keksdose `de-CH.json`):\n * `user` \"Nutzer\", `attachUrl` \"Aktuelle Seiten-URL anhängen\".\n */\nexport interface FeedbackContextLabels {\n /** The submitter line's label — the box draws \"**User:** Ada Example (ada@example.com)\".\n * The label alone: the colon between it and the person is the language's\n * `common.fieldValue` (fr \"Utilisateur : …\", zh \"用户:…\"). */\n user: string;\n /** The checkbox. The URL it is about is the line beneath it. */\n attachUrl: string;\n}\n\n// Defined in ./feedback-context-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_FEEDBACK_CONTEXT_LABELS };\n\nexport interface FeedbackContextBoxProps {\n /** Who is filing — the same value handed to {@link feedbackContext}. */\n user?: FeedbackSubmitter | null;\n /** The URL that goes with the report — the same `url` handed to {@link feedbackContext}. */\n url: string;\n /** The checkbox, on by default in the dialog (§4.2) — the same `attachUrl`. */\n attachUrl: boolean;\n onAttachUrlChange: (next: boolean) => void;\n /** Prop > `<UiKitProvider labels={{ feedbackContext }}>` > English. */\n labels?: LabelOverride<FeedbackContextLabels>;\n className?: string;\n}\n\n/**\n * The submit dialog's context box — the dialog's `contextSlot` (keksdose\n * `use-feedback-dialog.tsx:222`, §4.2): who is filing, and the page URL with a checkbox to\n * leave it out, ON by default.\n *\n * The URL stays visible when the box is off, struck through: the reporter sees what they\n * withheld rather than a line that vanished, and ticking it back on is the same glance.\n * Kurvenschmiede's argument for the checkbox is why it exists at all (its feedback #101):\n * the route is right for a bug and wrong for an idea about a screen one is not on — filed\n * against whatever screen happened to be open, the queue reads as if it were about that\n * screen.\n *\n * Nothing in here is the app's: hand it the values handed to {@link feedbackContext}, and\n * what the box shows is what is sent.\n */\nexport function FeedbackContextBox({\n user,\n url,\n attachUrl,\n onAttachUrlChange,\n labels: labelsProp,\n className,\n}: FeedbackContextBoxProps) {\n const labels = useKitLabels(\"feedbackContext\", DEFAULT_FEEDBACK_CONTEXT_LABELS, labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const submitter = submitterLine(user);\n // \"User: Ada …\" through `common.fieldValue`, so French gets its space before the colon\n // and Chinese its full-width one; the label and its punctuation are drawn bold, as\n // keksdose's box does. A `fieldValue` that does not end in the value (an app's own\n // order) is shown whole, unbolded, rather than cut in the wrong place.\n const line = common.fieldValue(labels.user, submitter);\n const lead = line.endsWith(submitter) ? line.slice(0, line.length - submitter.length) : null;\n return (\n <div\n className={cn(\"space-y-1 rounded-md border border-subtle bg-surface-2 px-3 py-2 text-xs text-muted\", className)}\n >\n <div className=\"[overflow-wrap:anywhere]\">\n {lead === null ? (\n line\n ) : (\n <>\n <span className=\"font-medium text-secondary\">{lead}</span>\n {submitter}\n </>\n )}\n </div>\n <Checkbox\n checked={attachUrl}\n onCheckedChange={onAttachUrlChange}\n label={<span className=\"text-xs font-medium text-secondary\">{labels.attachUrl}</span>}\n description={\n url ? (\n // `break-all`: a URL is one unbreakable word, and at 390px a long query string\n // would otherwise push the dialog sideways.\n <span\n data-withheld={attachUrl ? undefined : \"\"}\n className={cn(\"break-all text-xs\", !attachUrl && \"line-through opacity-60\")}\n >\n {url}\n </span>\n ) : undefined\n }\n />\n </div>\n );\n}\n"],"mappings":";AA2LU,mBACE,KADF;AA3LV,SAAS,gBAAgB;AACzB,SAAS,uBAAuB,oBAAwC;AACxE,SAAS,UAAU;AAEnB,SAAS,uCAAuC;AAkChD,SAAS,cAAc,MAAoD;AACzE,QAAM,OAAO,MAAM,cAAc,KAAK;AACtC,QAAM,QAAQ,MAAM,OAAO,KAAK;AAChC,MAAI,QAAQ,MAAO,QAAO,GAAG,IAAI,KAAK,KAAK;AAC3C,SAAO,QAAQ,SAAS;AAC1B;AAgCA,SAAS,OAAO,KAAa,MAAkC;AAC7D,MAAI,CAAC,IAAK,QAAO;AACjB,MAAI;AACF,WAAO,IAAI,IAAI,KAAK,QAAQ,kBAAkB,EAAE;AAAA,EAClD,QAAQ;AACN,WAAO;AAAA,EACT;AACF;AAeO,SAAS,gBAAgB,OAA8C;AAC5E,QAAM,EAAE,MAAM,WAAW,IAAI,IAAI;AACjC,QAAM,MAAM,OAAO,WAAW,cAAc,SAAY;AACxD,QAAM,SAAS,MAAM,UAAU,KAAK,SAAS,UAAU;AACvD,QAAM,UAA2B;AAAA,IAC/B,KAAK,YAAY,MAAM;AAAA,IACvB,OAAO,YAAa,MAAM,SAAS,OAAO,KAAK,UAAU,KAAK,SAAS,IAAI,IAAK;AAAA,IAChF;AAAA,EACF;A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AAAA,gBACE;AAAA;AAAA,QAER;AAAA;AAAA;AAAA,EACF;AAEJ;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/feedback-context.tsx"],"sourcesContent":["import { useId } from \"react\";\nimport { Checkbox } from \"../components/checkbox\";\nimport { DEFAULT_COMMON_LABELS, useKitLabels, type LabelOverride } from \"../i18n/kit-labels\";\nimport { cn } from \"../lib/cn\";\nimport type { FeedbackContext, FeedbackEnvironment } from \"./feedback-record\";\nimport { DEFAULT_FEEDBACK_CONTEXT_LABELS } from \"./feedback-context-labels\";\nimport { diagnosticsEntries, FeedbackDiagnosticsList } from \"./feedback-diagnostics\";\n\n/**\n * The reporter context of a feedback report: the box the submit dialog shows, and the\n * `context` object `POST /feedback` sends (0.27.0, docs/feedback-harmonization.md §3.2,\n * §4.2). One file for both, so what the box SAYS will be sent and what IS sent cannot\n * drift apart.\n *\n * Each app had written both halves itself (keksdose `use-feedback-dialog.tsx:105` and\n * `:222`, kastlan `feedback-button.tsx:80`, Kurvenschmiede `use-feedback-dialog.tsx:124`),\n * and they had drifted: kastlan sent six keys with `user_email: null` and no version,\n * Kurvenschmiede a `page_path` column and a sentence where keksdose had a labelled box,\n * and only keksdose showed the full URL it was about to send.\n */\n\n/* ── Who is filing ───────────────────────────────────────────────────────── */\n\n/**\n * The person filing, as the app knows them. Snake case on purpose: keksdose's and\n * Kurvenschmiede's user objects already have this shape (`id`, `email`, `display_name`),\n * so they pass their `user` as it is; kastlan maps its token's `sub` and name parts.\n *\n * A SNAPSHOT for the report and the box. The server should overwrite the three `user_*`\n * keys from the session (§3.2; Kurvenschmiede does), so nobody can file in someone else's\n * name — this is what the reporter is SHOWN, not proof of who they are.\n */\nexport interface FeedbackSubmitter {\n id?: number | null;\n email?: string | null;\n display_name?: string | null;\n}\n\n/** \"Ada Example (ada@example.com)\", the name alone, the email alone, or \"—\" when the app\n * knows neither (keksdose `use-feedback-dialog.tsx:228`). */\nfunction submitterLine(user: FeedbackSubmitter | null | undefined): string {\n const name = user?.display_name?.trim();\n const email = user?.email?.trim();\n if (name && email) return `${name} (${email})`;\n return name || email || \"—\";\n}\n\n/* ── The object (§3.2) ───────────────────────────────────────────────────── */\n\n/** What {@link feedbackContext} is built from. */\nexport interface FeedbackContextInput {\n /** The submitter, or `null` when signed out / unknown — the three `user_*` keys are then\n * `null`, as keksdose sends them. */\n user?: FeedbackSubmitter | null;\n /** The box's \"Attach current page URL\" checkbox. `false` withholds `url` and `route`\n * (both `\"\"`); nothing else is withheld — `origin` says which copy of the app, which is\n * not personal, and triage needs it first (keksdose `use-feedback-dialog.tsx:110`). */\n attachUrl: boolean;\n /** `location.href` when the dialog OPENED — the page the report is about, not the one\n * the reporter may have navigated to while typing. */\n url: string;\n /** Its pathname. Default: read off `url` (a path-only `url` works too). */\n route?: string;\n /** Default `location.origin`. */\n origin?: string;\n /** `\"prod\"` / `\"dev\"` / `\"local\"` — the app's own reading (keksdose\n * `app/deploy-environment.ts`). Left out of the object when not given. */\n environment?: FeedbackEnvironment | (string & {});\n /** The app build (`__APP_VERSION__`). Left out of the object when not given. */\n version?: string;\n /** Default `${innerWidth}x${innerHeight}` at the time of the call — \"406x816\". */\n viewport?: string;\n /** Default `navigator.userAgent`. */\n ua?: string;\n /** What the app attached about the thing reported — `useFeedbackSubmit().open(category,\n * { diagnostics })` (keksdose live #481). Sent whatever `attachUrl` says, as the box\n * shows it; left out of the object when it has no key to show. */\n diagnostics?: Readonly<Record<string, unknown>> | null;\n}\n\n/** The pathname of a full or path-only URL; `\"\"` for something that is neither. */\nfunction pathOf(url: string, base: string | undefined): string {\n if (!url) return \"\";\n try {\n return new URL(url, base || \"http://localhost\").pathname;\n } catch {\n return \"\";\n }\n}\n\n/**\n * The `context` object of `POST /feedback` (§3.2), keys in keksdose's order: `url`, `route`,\n * `origin`, `environment`, `user_id`, `user_email`, `user_display_name`, `viewport`, `ua`,\n * `version`, then the app's `diagnostics`.\n *\n * With `attachUrl: false`, `url` and `route` are `\"\"` — present and empty, as keksdose\n * sends them, so a reader can tell \"withheld\" from \"an old row without the key\".\n * `environment` and `version` are omitted when the app passes none (kastlan had no\n * version), rather than sent as `undefined`; `diagnostics` when the box would show no\n * line of it (none, `{}`, not a record).\n *\n * Reads `window` / `navigator` only for the defaults it was not given, so it is a pure\n * function in a test that passes everything.\n */\nexport function feedbackContext(input: FeedbackContextInput): FeedbackContext {\n const { user, attachUrl, url } = input;\n const win = typeof window === \"undefined\" ? undefined : window;\n const origin = input.origin ?? win?.location.origin ?? \"\";\n const context: FeedbackContext = {\n url: attachUrl ? url : \"\",\n route: attachUrl ? (input.route ?? pathOf(url, origin || win?.location.href)) : \"\",\n origin,\n };\n if (input.environment !== undefined) context.environment = input.environment;\n context.user_id = user?.id ?? null;\n context.user_email = user?.email ?? null;\n context.user_display_name = user?.display_name ?? null;\n context.viewport = input.viewport ?? (win ? `${win.innerWidth}x${win.innerHeight}` : \"\");\n context.ua = input.ua ?? (typeof navigator === \"undefined\" ? \"\" : navigator.userAgent);\n if (input.version !== undefined) context.version = input.version;\n // The box's own test: what it draws no line of is not sent either.\n if (input.diagnostics && diagnosticsEntries(input.diagnostics).length) context.diagnostics = input.diagnostics;\n return context;\n}\n\n/* ── The box (§4.2) ──────────────────────────────────────────────────────── */\n\n/**\n * `feedbackContext` — the context box's words. de-CH canon (keksdose `de-CH.json`):\n * `user` \"Nutzer\", `attachUrl` \"Aktuelle Seiten-URL anhängen\".\n */\nexport interface FeedbackContextLabels {\n /** The submitter line's label — the box draws \"**User:** Ada Example (ada@example.com)\".\n * The label alone: the colon between it and the person is the language's\n * `common.fieldValue` (fr \"Utilisateur : …\", zh \"用户:…\"). */\n user: string;\n /** The checkbox. The URL it is about is the line beneath it. */\n attachUrl: string;\n /** The heading over what the app attached — `open(category, { diagnostics })`, shown\n * read-only under the URL (keksdose live #481). de-CH: \"Mitgesendete Diagnose\" */\n diagnostics: string;\n}\n\n// Defined in ./feedback-context-labels, which holds no component code (0.34, KS U8).\nexport { DEFAULT_FEEDBACK_CONTEXT_LABELS };\n\nexport interface FeedbackContextBoxProps {\n /** Who is filing — the same value handed to {@link feedbackContext}. */\n user?: FeedbackSubmitter | null;\n /** The URL that goes with the report — the same `url` handed to {@link feedbackContext}. */\n url: string;\n /** The checkbox, on by default in the dialog (§4.2) — the same `attachUrl`. */\n attachUrl: boolean;\n onAttachUrlChange: (next: boolean) => void;\n /** What the app attached — the same `diagnostics` handed to {@link feedbackContext}.\n * Shown read-only, each key and its value as the row detail draws them; no block when\n * there is no line to show. */\n diagnostics?: Readonly<Record<string, unknown>> | null;\n /** Prop > `<UiKitProvider labels={{ feedbackContext }}>` > English. */\n labels?: LabelOverride<FeedbackContextLabels>;\n className?: string;\n}\n\n/**\n * The submit dialog's context box — the dialog's `contextSlot` (keksdose\n * `use-feedback-dialog.tsx:222`, §4.2): who is filing, and the page URL with a checkbox to\n * leave it out, ON by default.\n *\n * The URL stays visible when the box is off, struck through: the reporter sees what they\n * withheld rather than a line that vanished, and ticking it back on is the same glance.\n * Kurvenschmiede's argument for the checkbox is why it exists at all (its feedback #101):\n * the route is right for a bug and wrong for an idea about a screen one is not on — filed\n * against whatever screen happened to be open, the queue reads as if it were about that\n * screen.\n *\n * Below the URL, what the app attached (`diagnostics`, keksdose live #481: a stuck receipt\n * scan's bookkeeping), read-only and in the row detail's own lines: the reporter sees what\n * goes with the report, and that the URL checkbox does not withhold it.\n *\n * Nothing in here is the app's: hand it the values handed to {@link feedbackContext}, and\n * what the box shows is what is sent.\n */\nexport function FeedbackContextBox({\n user,\n url,\n attachUrl,\n onAttachUrlChange,\n diagnostics,\n labels: labelsProp,\n className,\n}: FeedbackContextBoxProps) {\n const labels = useKitLabels(\"feedbackContext\", DEFAULT_FEEDBACK_CONTEXT_LABELS, labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const diagnosticsId = useId();\n const attached = diagnosticsEntries(diagnostics);\n const submitter = submitterLine(user);\n // \"User: Ada …\" through `common.fieldValue`, so French gets its space before the colon\n // and Chinese its full-width one; the label and its punctuation are drawn bold, as\n // keksdose's box does. A `fieldValue` that does not end in the value (an app's own\n // order) is shown whole, unbolded, rather than cut in the wrong place.\n const line = common.fieldValue(labels.user, submitter);\n const lead = line.endsWith(submitter) ? line.slice(0, line.length - submitter.length) : null;\n return (\n <div\n className={cn(\"space-y-1 rounded-md border border-subtle bg-surface-2 px-3 py-2 text-xs text-muted\", className)}\n >\n <div className=\"[overflow-wrap:anywhere]\">\n {lead === null ? (\n line\n ) : (\n <>\n <span className=\"font-medium text-secondary\">{lead}</span>\n {submitter}\n </>\n )}\n </div>\n <Checkbox\n checked={attachUrl}\n onCheckedChange={onAttachUrlChange}\n label={<span className=\"text-xs font-medium text-secondary\">{labels.attachUrl}</span>}\n description={\n url ? (\n // `break-all`: a URL is one unbreakable word, and at 390px a long query string\n // would otherwise push the dialog sideways.\n <span\n data-withheld={attachUrl ? undefined : \"\"}\n className={cn(\"break-all text-xs\", !attachUrl && \"line-through opacity-60\")}\n >\n {url}\n </span>\n ) : undefined\n }\n />\n {attached.length > 0 && (\n // A named group, so a screen reader hears what the pairs are before it reads them.\n <div role=\"group\" aria-labelledby={diagnosticsId} className=\"space-y-0.5 pt-1\">\n <div id={diagnosticsId} className=\"font-medium text-secondary\">\n {labels.diagnostics}\n </div>\n <FeedbackDiagnosticsList entries={attached} />\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";AAkNU,mBACE,KADF;AAlNV,SAAS,aAAa;AACtB,SAAS,gBAAgB;AACzB,SAAS,uBAAuB,oBAAwC;AACxE,SAAS,UAAU;AAEnB,SAAS,uCAAuC;AAChD,SAAS,oBAAoB,+BAA+B;AAkC5D,SAAS,cAAc,MAAoD;AACzE,QAAM,OAAO,MAAM,cAAc,KAAK;AACtC,QAAM,QAAQ,MAAM,OAAO,KAAK;AAChC,MAAI,QAAQ,MAAO,QAAO,GAAG,IAAI,KAAK,KAAK;AAC3C,SAAO,QAAQ,SAAS;AAC1B;AAoCA,SAAS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O,WAAW,OAAO,MAAM,SAAS;AACrD,QAAM,OAAO,KAAK,SAAS,SAAS,IAAI,KAAK,MAAM,GAAG,KAAK,SAAS,UAAU,MAAM,IAAI;AACxF,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,GAAG,uFAAuF,SAAS;AAAA,MAE9G;AAAA,4BAAC,SAAI,WAAU,4BACZ,mBAAS,OACR,OAEA,iCACE;AAAA,8BAAC,UAAK,WAAU,8BAA8B,gBAAK;AAAA,UAClD;AAAA,WACH,GAEJ;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,SAAS;AAAA,YACT,iBAAiB;AAAA,YACjB,OAAO,oBAAC,UAAK,WAAU,sCAAsC,iBAAO,WAAU;AAAA,YAC9E,aACE;AAAA;AAAA;AAAA,cAGE;AAAA,gBAAC;AAAA;AAAA,kBACC,iBAAe,YAAY,SAAY;AAAA,kBACvC,WAAW,GAAG,qBAAqB,CAAC,aAAa,yBAAyB;AAAA,kBAEzE;AAAA;AAAA,cACH;AAAA,gBACE;AAAA;AAAA,QAER;AAAA,QACC,SAAS,SAAS;AAAA,QAEjB,qBAAC,SAAI,MAAK,SAAQ,mBAAiB,eAAe,WAAU,oBAC1D;AAAA,8BAAC,SAAI,IAAI,eAAe,WAAU,8BAC/B,iBAAO,aACV;AAAA,UACA,oBAAC,2BAAwB,SAAS,UAAU;AAAA,WAC9C;AAAA;AAAA;AAAA,EAEJ;AAEJ;","names":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `context.diagnostics` (§3.2), drawn one way wherever it shows: in the submit dialog's
|
|
3
|
+
* context box, to the reporter before it goes (§4.2), and in the row detail, to the admin
|
|
4
|
+
* and the author afterwards (§4.4.2). One module for both, so the reporter is shown the
|
|
5
|
+
* very lines the admin will read (keksdose live #481).
|
|
6
|
+
*
|
|
7
|
+
* Internal: neither `@eifi1/ui-kit/feedback` nor the barrel names it.
|
|
8
|
+
*/
|
|
9
|
+
/** `diagnostics` as [key, text] pairs, in the app's order: a string, number or boolean as
|
|
10
|
+
* written, an object or a list as JSON, nothing as "—". Empty for no diagnostics, and for
|
|
11
|
+
* a value that is not a plain object — the server stores whatever the client sent. */
|
|
12
|
+
export declare function diagnosticsEntries(diagnostics: unknown): Array<[string, string]>;
|
|
13
|
+
/** The pairs as a definition list: each key beside its value, in monospace. Read-only in
|
|
14
|
+
* both places; the heading over it is the caller's. */
|
|
15
|
+
export declare function FeedbackDiagnosticsList({ entries }: {
|
|
16
|
+
entries: ReadonlyArray<readonly [string, string]>;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
function diagnosticsEntries(diagnostics) {
|
|
4
|
+
if (!diagnostics || typeof diagnostics !== "object" || Array.isArray(diagnostics)) return [];
|
|
5
|
+
return Object.entries(diagnostics).map(([key, v]) => [
|
|
6
|
+
key,
|
|
7
|
+
v === null || v === void 0 || v === "" ? "\u2014" : typeof v === "object" ? JSON.stringify(v) : String(v)
|
|
8
|
+
]);
|
|
9
|
+
}
|
|
10
|
+
function FeedbackDiagnosticsList({ entries }) {
|
|
11
|
+
return /* @__PURE__ */ jsx(
|
|
12
|
+
"dl",
|
|
13
|
+
{
|
|
14
|
+
className: "grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5 font-mono text-xs",
|
|
15
|
+
"data-feedback-diagnostics": "",
|
|
16
|
+
children: entries.map(([key, text]) => /* @__PURE__ */ jsxs("div", { className: "contents", children: [
|
|
17
|
+
/* @__PURE__ */ jsx("dt", { className: "text-muted", children: key }),
|
|
18
|
+
/* @__PURE__ */ jsx("dd", { className: "min-w-0 break-words text-secondary", children: text })
|
|
19
|
+
] }, key))
|
|
20
|
+
}
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
FeedbackDiagnosticsList,
|
|
25
|
+
diagnosticsEntries
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=feedback-diagnostics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/feedback-diagnostics.tsx"],"sourcesContent":["/**\n * `context.diagnostics` (§3.2), drawn one way wherever it shows: in the submit dialog's\n * context box, to the reporter before it goes (§4.2), and in the row detail, to the admin\n * and the author afterwards (§4.4.2). One module for both, so the reporter is shown the\n * very lines the admin will read (keksdose live #481).\n *\n * Internal: neither `@eifi1/ui-kit/feedback` nor the barrel names it.\n */\n\n/** `diagnostics` as [key, text] pairs, in the app's order: a string, number or boolean as\n * written, an object or a list as JSON, nothing as \"—\". Empty for no diagnostics, and for\n * a value that is not a plain object — the server stores whatever the client sent. */\nexport function diagnosticsEntries(diagnostics: unknown): Array<[string, string]> {\n if (!diagnostics || typeof diagnostics !== \"object\" || Array.isArray(diagnostics)) return [];\n return Object.entries(diagnostics).map(([key, v]) => [\n key,\n v === null || v === undefined || v === \"\"\n ? \"—\"\n : typeof v === \"object\"\n ? JSON.stringify(v)\n : String(v as string | number | boolean | bigint),\n ]);\n}\n\n/** The pairs as a definition list: each key beside its value, in monospace. Read-only in\n * both places; the heading over it is the caller's. */\nexport function FeedbackDiagnosticsList({ entries }: { entries: ReadonlyArray<readonly [string, string]> }) {\n return (\n <dl\n className=\"grid grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-0.5 font-mono text-xs\"\n data-feedback-diagnostics=\"\"\n >\n {entries.map(([key, text]) => (\n <div key={key} className=\"contents\">\n <dt className=\"text-muted\">{key}</dt>\n <dd className=\"min-w-0 break-words text-secondary\">{text}</dd>\n </div>\n ))}\n </dl>\n );\n}\n"],"mappings":";AAiCQ,SACE,KADF;AArBD,SAAS,mBAAmB,aAA+C;AAChF,MAAI,CAAC,eAAe,OAAO,gBAAgB,YAAY,MAAM,QAAQ,WAAW,EAAG,QAAO,CAAC;AAC3F,SAAO,OAAO,QAAQ,WAAW,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM;AAAA,IACnD;AAAA,IACA,MAAM,QAAQ,MAAM,UAAa,MAAM,KACnC,WACA,OAAO,MAAM,WACX,KAAK,UAAU,CAAC,IAChB,OAAO,CAAuC;AAAA,EACtD,CAAC;AACH;AAIO,SAAS,wBAAwB,EAAE,QAAQ,GAA0D;AAC1G,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAU;AAAA,MACV,6BAA0B;AAAA,MAEzB,kBAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,MACtB,qBAAC,SAAc,WAAU,YACvB;AAAA,4BAAC,QAAG,WAAU,cAAc,eAAI;AAAA,QAChC,oBAAC,QAAG,WAAU,sCAAsC,gBAAK;AAAA,WAFjD,GAGV,CACD;AAAA;AAAA,EACH;AAEJ;","names":[]}
|
|
@@ -120,6 +120,16 @@ interface FeedbackDialogBaseProps<C extends string = string> {
|
|
|
120
120
|
* English. Optional since 0.12.0; a whole `FeedbackDialogLabels` still fits. */
|
|
121
121
|
labels?: LabelOverride<FeedbackDialogLabels>;
|
|
122
122
|
submitting?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* The subject and the body each opening starts with, in place of empty fields — the
|
|
125
|
+
* reporter edits them like anything typed. `useFeedbackSubmit().open(category, { title,
|
|
126
|
+
* body })` passes them (keksdose live #481: "Report this problem" opens on words the
|
|
127
|
+
* screen already knows). Read when the dialog opens; a change while it is open leaves
|
|
128
|
+
* the draft alone.
|
|
129
|
+
*/
|
|
130
|
+
defaultTitle?: string;
|
|
131
|
+
/** The body's, as `defaultTitle` is the subject's. */
|
|
132
|
+
defaultBody?: string;
|
|
123
133
|
contextSlot?: ReactNode;
|
|
124
134
|
attachmentAccept?: string[];
|
|
125
135
|
maxAttachmentBytes?: number;
|
|
@@ -26,6 +26,8 @@ function FeedbackDialog(props) {
|
|
|
26
26
|
onCategoryChange,
|
|
27
27
|
labels: labelsProp,
|
|
28
28
|
submitting = false,
|
|
29
|
+
defaultTitle = "",
|
|
30
|
+
defaultBody = "",
|
|
29
31
|
contextSlot,
|
|
30
32
|
attachmentAccept = DEFAULT_ATTACHMENT_ACCEPT,
|
|
31
33
|
maxAttachmentBytes = DEFAULT_MAX_ATTACHMENT_BYTES,
|
|
@@ -35,8 +37,8 @@ function FeedbackDialog(props) {
|
|
|
35
37
|
attachmentButtonSize,
|
|
36
38
|
publicNotice
|
|
37
39
|
} = props;
|
|
38
|
-
const [title, setTitle] = useState(
|
|
39
|
-
const [body, setBody] = useState(
|
|
40
|
+
const [title, setTitle] = useState(defaultTitle);
|
|
41
|
+
const [body, setBody] = useState(defaultBody);
|
|
40
42
|
const [attachment, setAttachment] = useState(null);
|
|
41
43
|
const [screenshot, setScreenshot] = useState(null);
|
|
42
44
|
const [files, setFiles] = useState([]);
|
|
@@ -51,8 +53,8 @@ function FeedbackDialog(props) {
|
|
|
51
53
|
if (open !== wasOpen) {
|
|
52
54
|
setWasOpen(open);
|
|
53
55
|
if (open) {
|
|
54
|
-
setTitle(
|
|
55
|
-
setBody(
|
|
56
|
+
setTitle(defaultTitle);
|
|
57
|
+
setBody(defaultBody);
|
|
56
58
|
setAttachment(null);
|
|
57
59
|
setScreenshot(null);
|
|
58
60
|
setFiles([]);
|
|
@@ -1 +1 @@
|
|
|
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 { hasContent } from \"../lib/presence\";\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\n/** One category the dialog offers. `C` (0.52): the app's category type — the kit's\n * `FeedbackCategory`, or `string` (the default) for a vocabulary of the app's own. */\nexport interface FeedbackCategoryOption<C extends string = string> {\n value: C;\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<C extends string = string> {\n title: string;\n body: string;\n category: C;\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<C extends string = string> {\n title: string;\n body: string;\n category: C;\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\n/**\n * `C` (0.52, refactor audit 2026-10-30, API-7): the category type, inferred from\n * `categories` and `category` — `FeedbackCategory` hands `onCategoryChange` and\n * `onSubmit` a `FeedbackCategory` back, where a plain `string` had to be cast (the kit's\n * own `useFeedbackSubmit` did). `string` by default, so an app's own vocabulary fits.\n */\ninterface FeedbackDialogBaseProps<C extends string = string> {\n open: boolean;\n onClose: () => void;\n /** `readonly` since 0.52: the dialog never changes it. */\n categories: readonly FeedbackCategoryOption<C>[];\n category: C;\n onCategoryChange: (value: C) => 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<C extends string = string> extends FeedbackDialogBaseProps<C> {\n attachments?: \"single\";\n onSubmit: (data: FeedbackSubmission<C>) => 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<C extends string = string> extends FeedbackDialogBaseProps<C> {\n attachments: \"multiple\";\n /** Default `DEFAULT_MAX_ATTACHMENTS` (5). The screenshot does not count. */\n maxAttachments?: number;\n onSubmit: (data: FeedbackMultipleSubmission<C>) => 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<C extends string = string> =\n FeedbackDialogSingleProps<C> | FeedbackDialogMultipleProps<C>;\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<C extends string = string>(props: FeedbackDialogProps<C>) {\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 = hasContent(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 ?? attachmentText.attachmentList ?? 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 // The select offers exactly `categories`' values, so what it answers is one of them.\n <Select label={labels.category} value={category} onChange={(e) => onCategoryChange(e.target.value as C)}>\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":";AAuTQ,SA8FE,UA9FF,KAuBJ,YAvBI;AAvTR,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,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,sCAAsC;AA0NxC,SAAS,eAA0C,OAA+B;AACvF,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,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,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AS;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
|
+
{"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 { hasContent } from \"../lib/presence\";\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\n/** One category the dialog offers. `C` (0.52): the app's category type — the kit's\n * `FeedbackCategory`, or `string` (the default) for a vocabulary of the app's own. */\nexport interface FeedbackCategoryOption<C extends string = string> {\n value: C;\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<C extends string = string> {\n title: string;\n body: string;\n category: C;\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<C extends string = string> {\n title: string;\n body: string;\n category: C;\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\n/**\n * `C` (0.52, refactor audit 2026-10-30, API-7): the category type, inferred from\n * `categories` and `category` — `FeedbackCategory` hands `onCategoryChange` and\n * `onSubmit` a `FeedbackCategory` back, where a plain `string` had to be cast (the kit's\n * own `useFeedbackSubmit` did). `string` by default, so an app's own vocabulary fits.\n */\ninterface FeedbackDialogBaseProps<C extends string = string> {\n open: boolean;\n onClose: () => void;\n /** `readonly` since 0.52: the dialog never changes it. */\n categories: readonly FeedbackCategoryOption<C>[];\n category: C;\n onCategoryChange: (value: C) => 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 /**\n * The subject and the body each opening starts with, in place of empty fields — the\n * reporter edits them like anything typed. `useFeedbackSubmit().open(category, { title,\n * body })` passes them (keksdose live #481: \"Report this problem\" opens on words the\n * screen already knows). Read when the dialog opens; a change while it is open leaves\n * the draft alone.\n */\n defaultTitle?: string;\n /** The body's, as `defaultTitle` is the subject's. */\n defaultBody?: string;\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<C extends string = string> extends FeedbackDialogBaseProps<C> {\n attachments?: \"single\";\n onSubmit: (data: FeedbackSubmission<C>) => 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<C extends string = string> extends FeedbackDialogBaseProps<C> {\n attachments: \"multiple\";\n /** Default `DEFAULT_MAX_ATTACHMENTS` (5). The screenshot does not count. */\n maxAttachments?: number;\n onSubmit: (data: FeedbackMultipleSubmission<C>) => 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<C extends string = string> =\n FeedbackDialogSingleProps<C> | FeedbackDialogMultipleProps<C>;\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<C extends string = string>(props: FeedbackDialogProps<C>) {\n const {\n open,\n onClose,\n categories,\n category,\n onCategoryChange,\n labels: labelsProp,\n submitting = false,\n defaultTitle = \"\",\n defaultBody = \"\",\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(defaultTitle);\n const [body, setBody] = useState(defaultBody);\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 = hasContent(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 ?? attachmentText.attachmentList ?? 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(defaultTitle);\n setBody(defaultBody);\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 // The select offers exactly `categories`' values, so what it answers is one of them.\n <Select label={labels.category} value={category} onChange={(e) => onCategoryChange(e.target.value as C)}>\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":";AAmUQ,SA8FE,UA9FF,KAuBJ,YAvBI;AAnUR,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,SAAS,kBAAkB;AAC3B;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAGK;AACP,SAAS,sCAAsC;AAoOxC,SAAS,eAA0C,OAA+B;AACvF,QAAM;AAAA,IACJ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,QAAQ;AAAA,IACR,aAAa;AAAA,IACb,eAAe;AAAA,IACf,cAAc;A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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,30 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A page's mutation
|
|
3
|
-
*
|
|
2
|
+
* A page's mutation, run once (refactor audit 2026-10-30, FLW-3): TanStack Query's
|
|
3
|
+
* `mutateAsync`, or any `(patch) => Promise` that resolves once the PATCH has landed.
|
|
4
4
|
*
|
|
5
|
-
* The parts
|
|
6
|
-
* v5 calls per-call callbacks for the LATEST `mutate()` on
|
|
7
|
-
* overwrites the options and detaches from the earlier mutation —
|
|
8
|
-
* before the first PATCH answered (another swipe, another pill,
|
|
9
|
-
* first change's Undo toast, and the detail's editor stayed
|
|
10
|
-
* `mutateAsync` returns settles for every call, whatever the observer
|
|
5
|
+
* The parts took TanStack Query's `mutate` with a per-call `onSuccess` until 0.53
|
|
6
|
+
* (deprecated in 0.52). TanStack v5 calls per-call callbacks for the LATEST `mutate()` on
|
|
7
|
+
* an observer only — it overwrites the options and detaches from the earlier mutation —
|
|
8
|
+
* so a second change sent before the first PATCH answered (another swipe, another pill,
|
|
9
|
+
* the Undo itself) lost the first change's Undo toast, and the detail's editor stayed
|
|
10
|
+
* open. The promise `mutateAsync` returns settles for every call, whatever the observer
|
|
11
|
+
* does next.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
* taken from whichever comes first: the callback, or the promise the call returned. A
|
|
14
|
-
* rejected promise is the mutation's own to report (its `onError`), so it is caught here
|
|
13
|
+
* A rejected promise is the mutation's own to report (its `onError`), so it is caught here
|
|
15
14
|
* and nothing more happens.
|
|
16
15
|
*
|
|
17
16
|
* @internal Not part of `/feedback` or the barrel.
|
|
18
17
|
*/
|
|
19
|
-
|
|
20
|
-
* A mutation in either form: the promise form (0.52) — TanStack's `mutateAsync`, any
|
|
21
|
-
* `(patch) => Promise` — or the callback form before it — TanStack's `mutate`, a function
|
|
22
|
-
* that calls `onSuccess` once the PATCH has landed, and only then. One signature for
|
|
23
|
-
* both, so an inline function handed to a prop of this type gets its parameter types (a
|
|
24
|
-
* union of the two leaves `async (patch) => …` an implicit `any`).
|
|
25
|
-
*/
|
|
26
|
-
export type FeedbackMutationCall<P> = (patch: P, callbacks: {
|
|
27
|
-
onSuccess: () => void;
|
|
28
|
-
}) => void | Promise<unknown>;
|
|
29
|
-
/** Send `patch` through `call`, and run `landed` once when it has landed. */
|
|
30
|
-
export declare function runMutation<P>(call: FeedbackMutationCall<P>, patch: P, landed: () => void): void;
|
|
18
|
+
export declare function runMutation<P>(call: (patch: P) => Promise<unknown>, patch: P, landed: () => void): void;
|
|
@@ -1,14 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { isThenable } from "../lib/thenable.js";
|
|
3
2
|
function runMutation(call, patch, landed) {
|
|
4
|
-
|
|
5
|
-
const once = () => {
|
|
6
|
-
if (done) return;
|
|
7
|
-
done = true;
|
|
8
|
-
landed();
|
|
9
|
-
};
|
|
10
|
-
const answer = call(patch, { onSuccess: once });
|
|
11
|
-
if (isThenable(answer)) answer.then(once, () => void 0);
|
|
3
|
+
call(patch).then(landed, () => void 0);
|
|
12
4
|
}
|
|
13
5
|
export {
|
|
14
6
|
runMutation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/feedback/feedback-mutation.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../src/feedback/feedback-mutation.ts"],"sourcesContent":["/**\n * A page's mutation, run once (refactor audit 2026-10-30, FLW-3): TanStack Query's\n * `mutateAsync`, or any `(patch) => Promise` that resolves once the PATCH has landed.\n *\n * The parts took TanStack Query's `mutate` with a per-call `onSuccess` until 0.53\n * (deprecated in 0.52). TanStack v5 calls per-call callbacks for the LATEST `mutate()` on\n * an observer only — it overwrites the options and detaches from the earlier mutation —\n * so a second change sent before the first PATCH answered (another swipe, another pill,\n * the Undo itself) lost the first change's Undo toast, and the detail's editor stayed\n * open. The promise `mutateAsync` returns settles for every call, whatever the observer\n * does next.\n *\n * A rejected promise is the mutation's own to report (its `onError`), so it is caught here\n * and nothing more happens.\n *\n * @internal Not part of `/feedback` or the barrel.\n */\nexport function runMutation<P>(call: (patch: P) => Promise<unknown>, patch: P, landed: () => void): void {\n call(patch).then(landed, () => undefined);\n}\n"],"mappings":";AAiBO,SAAS,YAAe,MAAsC,OAAU,QAA0B;AACvG,OAAK,KAAK,EAAE,KAAK,QAAQ,MAAM,MAAS;AAC1C;","names":[]}
|
|
@@ -43,11 +43,6 @@ export interface FeedbackPublicListProps<T extends FeedbackPublicListItem = Feed
|
|
|
43
43
|
* what it carries: every other `onOpenChange` in the kit is a boolean (refactor audit
|
|
44
44
|
* 2026-10-30, API-5). */
|
|
45
45
|
onOpenIdChange?: (id: number | null) => void;
|
|
46
|
-
/**
|
|
47
|
-
* @deprecated 0.52 — `onOpenIdChange`, the same call: an `onOpenChange` is a boolean
|
|
48
|
-
* everywhere else in the kit; removed in 0.53
|
|
49
|
-
*/
|
|
50
|
-
onOpenChange?: (id: number | null) => void;
|
|
51
46
|
/**
|
|
52
47
|
* 0.38.1: the opened report when it is NOT on this page — a `?row=` link to an older
|
|
53
48
|
* one (Kurvenschmiede). The app fetches it (`GET /feedback/public/{id}`, a list item's
|
|
@@ -105,7 +100,7 @@ export interface FeedbackPublicListProps<T extends FeedbackPublicListItem = Feed
|
|
|
105
100
|
* next strip that needs no total (0.38.1); `openRow` shows a `?row=` report from
|
|
106
101
|
* another page. Needs a router, as every `DataTable` does.
|
|
107
102
|
*/
|
|
108
|
-
export declare function FeedbackPublicList<T extends FeedbackPublicListItem = FeedbackPublicListItem>({ rows, total, sort, onSortChange, search, onSearchChange, renderDetail, onVote, loading, openId: openIdProp, onOpenIdChange,
|
|
103
|
+
export declare function FeedbackPublicList<T extends FeedbackPublicListItem = FeedbackPublicListItem>({ rows, total, sort, onSortChange, search, onSearchChange, renderDetail, onVote, loading, openId: openIdProp, onOpenIdChange, openRow, page: pageIndex, hasMore, onPageChange, commit, renderDate: renderDateProp, labels: labelsProp, pageLabels: pageLabelsProp, fillHeight, className, }: FeedbackPublicListProps<T>): import("react").JSX.Element;
|
|
109
104
|
export interface FeedbackPublicDetailProps {
|
|
110
105
|
/** `GET /feedback/public/{id}`: the public body (attachment URLs already stripped by
|
|
111
106
|
* the server, §9.4) and the replies. */
|
|
@@ -111,7 +111,6 @@ function FeedbackPublicList({
|
|
|
111
111
|
loading = false,
|
|
112
112
|
openId: openIdProp,
|
|
113
113
|
onOpenIdChange,
|
|
114
|
-
onOpenChange,
|
|
115
114
|
openRow,
|
|
116
115
|
page: pageIndex = 0,
|
|
117
116
|
hasMore = false,
|
|
@@ -131,7 +130,7 @@ function FeedbackPublicList({
|
|
|
131
130
|
const openId = openIdProp !== void 0 ? openIdProp : ownOpenId;
|
|
132
131
|
const setOpen = (id) => {
|
|
133
132
|
if (openIdProp === void 0) setOwnOpenId(id);
|
|
134
|
-
|
|
133
|
+
onOpenIdChange?.(id);
|
|
135
134
|
};
|
|
136
135
|
const shownRows = openRow && openId === openRow.id && !rows.some((row) => row.id === openRow.id) ? [openRow, ...rows] : rows;
|
|
137
136
|
const columns = useMemo(
|