@the-seeker/feedback-react-native 0.0.0-stage → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/README.md +266 -2
  2. package/dist/core/author-token.d.ts +16 -0
  3. package/dist/core/author-token.js +96 -0
  4. package/dist/core/client.d.ts +55 -0
  5. package/dist/core/client.js +98 -0
  6. package/dist/core/config.d.ts +59 -0
  7. package/dist/core/config.js +112 -0
  8. package/dist/core/posts-schema.d.ts +306 -0
  9. package/dist/core/posts-schema.js +131 -0
  10. package/dist/core/posts.d.ts +67 -0
  11. package/dist/core/posts.js +113 -0
  12. package/dist/core/request.d.ts +53 -0
  13. package/dist/core/request.js +88 -0
  14. package/dist/core/survey.d.ts +12 -0
  15. package/dist/core/survey.js +26 -0
  16. package/dist/core/texts.d.ts +196 -0
  17. package/dist/core/texts.js +232 -0
  18. package/dist/core/theme.d.ts +6 -0
  19. package/dist/core/theme.js +55 -0
  20. package/dist/core/transport.d.ts +9 -0
  21. package/dist/core/transport.js +37 -0
  22. package/dist/index.d.ts +16 -0
  23. package/dist/index.js +34 -0
  24. package/dist/ui/Attachments.d.ts +9 -0
  25. package/dist/ui/Attachments.js +27 -0
  26. package/dist/ui/FeedbackForm.d.ts +8 -0
  27. package/dist/ui/FeedbackForm.js +92 -0
  28. package/dist/ui/FeedbackPostScreen.d.ts +8 -0
  29. package/dist/ui/FeedbackPostScreen.js +74 -0
  30. package/dist/ui/FeedbackSheet.d.ts +2 -0
  31. package/dist/ui/FeedbackSheet.js +14 -0
  32. package/dist/ui/FollowUpSheet.d.ts +17 -0
  33. package/dist/ui/FollowUpSheet.js +50 -0
  34. package/dist/ui/Inline.d.ts +6 -0
  35. package/dist/ui/Inline.js +16 -0
  36. package/dist/ui/Launcher.d.ts +1 -0
  37. package/dist/ui/Launcher.js +16 -0
  38. package/dist/ui/MyFeedbackModal.d.ts +10 -0
  39. package/dist/ui/MyFeedbackModal.js +45 -0
  40. package/dist/ui/MyFeedbackScreen.d.ts +9 -0
  41. package/dist/ui/MyFeedbackScreen.js +88 -0
  42. package/dist/ui/PostThread.d.ts +17 -0
  43. package/dist/ui/PostThread.js +57 -0
  44. package/dist/ui/Provider.d.ts +24 -0
  45. package/dist/ui/Provider.js +186 -0
  46. package/dist/ui/SurveyPrompt.d.ts +2 -0
  47. package/dist/ui/SurveyPrompt.js +52 -0
  48. package/dist/ui/context.d.ts +122 -0
  49. package/dist/ui/context.js +28 -0
  50. package/dist/ui/device.d.ts +10 -0
  51. package/dist/ui/device.js +22 -0
  52. package/dist/ui/forms.d.ts +32 -0
  53. package/dist/ui/forms.js +62 -0
  54. package/dist/ui/motion.d.ts +1 -0
  55. package/dist/ui/motion.js +23 -0
  56. package/dist/ui/post-format.d.ts +19 -0
  57. package/dist/ui/post-format.js +79 -0
  58. package/dist/ui/post-pieces.d.ts +24 -0
  59. package/dist/ui/post-pieces.js +60 -0
  60. package/dist/ui/post-styles.d.ts +317 -0
  61. package/dist/ui/post-styles.js +103 -0
  62. package/dist/ui/post-view-model.d.ts +52 -0
  63. package/dist/ui/post-view-model.js +181 -0
  64. package/dist/ui/primitives.d.ts +33 -0
  65. package/dist/ui/primitives.js +55 -0
  66. package/dist/ui/prop-state.d.ts +9 -0
  67. package/dist/ui/prop-state.js +27 -0
  68. package/dist/ui/storage.d.ts +15 -0
  69. package/dist/ui/storage.js +35 -0
  70. package/dist/ui/styles.d.ts +774 -0
  71. package/dist/ui/styles.js +185 -0
  72. package/dist/ui/surfaces.d.ts +13 -0
  73. package/dist/ui/surfaces.js +41 -0
  74. package/dist/ui/tokens.d.ts +16 -0
  75. package/dist/ui/tokens.js +62 -0
  76. package/dist/ui/useMyPosts.d.ts +35 -0
  77. package/dist/ui/useMyPosts.js +124 -0
  78. package/dist/ui/useSurvey.d.ts +12 -0
  79. package/dist/ui/useSurvey.js +52 -0
  80. package/package.json +32 -3
@@ -0,0 +1,232 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_TEXTS = void 0;
4
+ exports.parseTexts = parseTexts;
5
+ exports.resolveLocale = resolveLocale;
6
+ exports.resolveTexts = resolveTexts;
7
+ const zod_1 = require("zod");
8
+ exports.DEFAULT_TEXTS = {
9
+ ko: {
10
+ launcher: "피드백",
11
+ title: "피드백 보내기",
12
+ intro: "불편한 점이나 아이디어를 알려 주세요.",
13
+ content: "내용",
14
+ email: "이메일 (선택)",
15
+ attachImage: "이미지 첨부",
16
+ imageHint: "PNG·JPEG·WebP·GIF, 최대 4장, 장당 2MB",
17
+ image: "첨부 이미지",
18
+ dropHere: "여기에 이미지를 놓으세요",
19
+ preparing: "이미지를 준비하는 중…",
20
+ attached: "이미지를 첨부했습니다",
21
+ tooMany: "이미지는 최대 4장까지 첨부할 수 있습니다",
22
+ badType: "PNG, JPEG, WebP, GIF 이미지만 첨부할 수 있습니다",
23
+ imageTooLarge: "이미지가 너무 큽니다 (장당 최대 2MB)",
24
+ decodeFailed: "이미지를 불러오지 못했습니다",
25
+ invalidImage: "이미지 파일을 확인해 주세요",
26
+ imagesOff: "이미지 첨부가 꺼져 있습니다",
27
+ inlineMissing: "인라인 위젯을 넣을 요소를 찾지 못했습니다",
28
+ remove: "삭제",
29
+ send: "보내기",
30
+ close: "닫기",
31
+ sending: "보내는 중…",
32
+ thanks: "보내 주셔서 감사합니다",
33
+ surveyThanks: "응답해 주셔서 감사합니다",
34
+ rateLimited: "잠시 후 다시 시도해 주세요",
35
+ tooLarge: "첨부가 너무 큽니다",
36
+ failed: "전송에 실패했습니다",
37
+ empty: "내용을 입력해 주세요",
38
+ badEmail: "이메일 주소 형식을 확인해 주세요",
39
+ npsScale: "0점부터 10점까지 선택",
40
+ csatScale: "1점부터 5점까지 선택",
41
+ npsLow: "추천하지 않음",
42
+ npsHigh: "적극 추천",
43
+ csatLow: "매우 불만족",
44
+ csatHigh: "매우 만족",
45
+ contact: "연락처 (선택)",
46
+ contactPlaceholder: "텔레그램 아이디 또는 이메일",
47
+ emailPlaceholder: "name@example.com",
48
+ cancel: "취소",
49
+ score: "{n}점",
50
+ myFeedback: "내 피드백",
51
+ teamAnswer: "운영팀 답변",
52
+ followUp: "추가 의견",
53
+ addFollowUp: "추가 의견 남기기",
54
+ followUpHint: "이 글 아래 추가 의견으로 달립니다.",
55
+ followUpPublicHint: "공개 보드 글이라 다른 사용자도 볼 수 있습니다.",
56
+ followUpSubmit: "등록",
57
+ followUpSent: "추가 의견을 등록했습니다",
58
+ followUpClosed: "닫힌 글에는 추가 의견을 남길 수 없습니다",
59
+ followUpOneWay: "이 앱은 추가 의견을 받지 않습니다",
60
+ autoReply: "자동 안내",
61
+ awaitingAnswer: "답변 대기",
62
+ answered: "답변 완료",
63
+ unreadCount: "새 답변 {n}개",
64
+ answerPosted: "피드백에 답변이 등록되었습니다",
65
+ receivedStatus: "접수됨 · 현재 상태",
66
+ received: "접수됨",
67
+ checking: "운영팀이 확인하고 있습니다",
68
+ notYet: "아직",
69
+ oneWayNote: "이 앱은 피드백을 받기만 합니다. 답변은 달리지 않고, 처리 상태를 여기에서 확인할 수 있습니다.",
70
+ statusNew: "새 피드백",
71
+ statusInProgress: "처리 중",
72
+ statusResolved: "해결됨",
73
+ statusClosed: "닫힘",
74
+ boardReview: "검토 중",
75
+ boardPlanned: "예정",
76
+ boardInProgress: "진행 중",
77
+ boardDone: "완료",
78
+ statusChangedTo: "{status}{ro} 변경",
79
+ statusChanged: "상태 변경",
80
+ roadmapLinked: "로드맵에 추가됨",
81
+ releaseLinked: "업데이트에 반영됨",
82
+ publicBoard: "공개 보드",
83
+ anonymousPosted: "익명으로 남김",
84
+ writtenOn: "{date} 작성",
85
+ untitled: "피드백 #{n}",
86
+ emptyMine: "보낸 피드백이 없습니다",
87
+ emptyMineHint: "피드백을 보내면 운영팀 답변과 처리 상태를 여기에서 확인할 수 있습니다.",
88
+ writeFeedback: "피드백 쓰기",
89
+ noAnswerYet: "아직 답변이 없습니다. 답변이 등록되면 이 글 아래에 표시됩니다.",
90
+ loadFailed: "불러오지 못했습니다. 연결을 확인하고 다시 시도해 주세요.",
91
+ retry: "다시 시도",
92
+ postMissing: "이 글을 찾을 수 없습니다",
93
+ loadMore: "더 보기",
94
+ loading: "불러오는 중…",
95
+ notEligible: "이메일을 남기거나 로그인한 뒤 다시 보내 주세요",
96
+ },
97
+ en: {
98
+ launcher: "Feedback",
99
+ title: "Send feedback",
100
+ intro: "Tell us what's not working or share an idea.",
101
+ content: "Message",
102
+ email: "Email (optional)",
103
+ attachImage: "Attach image",
104
+ imageHint: "PNG, JPEG, WebP or GIF, up to 4 images, 2 MB each",
105
+ image: "Attached image",
106
+ dropHere: "Drop images here",
107
+ preparing: "Preparing image…",
108
+ attached: "Image attached",
109
+ tooMany: "You can attach up to 4 images",
110
+ badType: "Only PNG, JPEG, WebP and GIF images can be attached",
111
+ imageTooLarge: "Image is too large (2 MB max each)",
112
+ decodeFailed: "Couldn't load the image",
113
+ invalidImage: "Check the image file",
114
+ imagesOff: "Image attachments are turned off",
115
+ inlineMissing: "Couldn't find the element for the inline widget",
116
+ remove: "Remove",
117
+ send: "Send",
118
+ close: "Close",
119
+ sending: "Sending…",
120
+ thanks: "Thanks for your feedback",
121
+ surveyThanks: "Thanks for your response",
122
+ rateLimited: "Please try again in a moment",
123
+ tooLarge: "Attachments are too large",
124
+ failed: "Couldn't send your feedback",
125
+ empty: "Enter a message",
126
+ badEmail: "Check the email address format",
127
+ npsScale: "Choose a score from 0 to 10",
128
+ csatScale: "Choose a score from 1 to 5",
129
+ npsLow: "Not likely",
130
+ npsHigh: "Very likely",
131
+ csatLow: "Very dissatisfied",
132
+ csatHigh: "Very satisfied",
133
+ contact: "Contact (optional)",
134
+ contactPlaceholder: "Telegram handle or email",
135
+ emailPlaceholder: "name@example.com",
136
+ cancel: "Cancel",
137
+ score: "Score {n}",
138
+ myFeedback: "My feedback",
139
+ teamAnswer: "Team answer",
140
+ followUp: "Follow-up",
141
+ addFollowUp: "Add a follow-up",
142
+ followUpHint: "It's added below your post as a follow-up.",
143
+ followUpPublicHint: "This post is on the public board, so others can see it.",
144
+ followUpSubmit: "Post",
145
+ followUpSent: "Follow-up posted",
146
+ followUpClosed: "This post is closed to follow-ups",
147
+ followUpOneWay: "This app doesn't take follow-ups",
148
+ autoReply: "Automatic reply",
149
+ awaitingAnswer: "Awaiting answer",
150
+ answered: "Answered",
151
+ unreadCount: "New answers: {n}",
152
+ answerPosted: "Your feedback has an answer",
153
+ receivedStatus: "Received · Current status",
154
+ received: "Received",
155
+ checking: "The team is looking into it",
156
+ notYet: "Not yet",
157
+ oneWayNote: "This app only receives feedback. There are no answers, but you can follow the status here.",
158
+ statusNew: "New",
159
+ statusInProgress: "In progress",
160
+ statusResolved: "Resolved",
161
+ statusClosed: "Closed",
162
+ boardReview: "Under review",
163
+ boardPlanned: "Planned",
164
+ boardInProgress: "In progress",
165
+ boardDone: "Done",
166
+ statusChangedTo: "Changed to {status}",
167
+ statusChanged: "Status changed",
168
+ roadmapLinked: "Added to the roadmap",
169
+ releaseLinked: "Shipped in an update",
170
+ publicBoard: "Public board",
171
+ anonymousPosted: "Posted anonymously",
172
+ writtenOn: "Posted {date}",
173
+ untitled: "Feedback #{n}",
174
+ emptyMine: "No feedback yet",
175
+ emptyMineHint: "Send feedback to follow team answers and its status here.",
176
+ writeFeedback: "Write feedback",
177
+ noAnswerYet: "No answer yet. Answers appear below your post.",
178
+ loadFailed: "Unable to load. Check your connection and try again.",
179
+ retry: "Try again",
180
+ postMissing: "This post isn't available",
181
+ loadMore: "Load more",
182
+ loading: "Loading…",
183
+ notEligible: "Add your email or sign in, then send again",
184
+ },
185
+ };
186
+ const textOverride = zod_1.z.string().trim().min(1).max(200).optional().catch(undefined);
187
+ const textSchema = zod_1.z
188
+ .object({
189
+ title: textOverride,
190
+ description: textOverride,
191
+ contentLabel: textOverride,
192
+ contentPlaceholder: textOverride,
193
+ contactLabel: textOverride,
194
+ contactPlaceholder: textOverride,
195
+ submitLabel: textOverride,
196
+ cancelLabel: textOverride,
197
+ thanks: textOverride,
198
+ })
199
+ .catch({});
200
+ function parseTexts(raw, contactMode, locale) {
201
+ const value = textSchema.parse(raw);
202
+ const defaults = exports.DEFAULT_TEXTS[locale];
203
+ return {
204
+ title: value.title ?? defaults.title,
205
+ description: value.description ?? defaults.intro,
206
+ contentLabel: value.contentLabel ?? defaults.content,
207
+ contentPlaceholder: value.contentPlaceholder ?? "",
208
+ contactLabel: value.contactLabel ?? (contactMode === "text" ? defaults.contact : defaults.email),
209
+ contactPlaceholder: value.contactPlaceholder ?? (contactMode === "text" ? defaults.contactPlaceholder : defaults.emailPlaceholder),
210
+ submitLabel: value.submitLabel ?? defaults.send,
211
+ cancelLabel: value.cancelLabel ?? defaults.cancel,
212
+ thanks: value.thanks ?? defaults.thanks,
213
+ };
214
+ }
215
+ function resolveLocale(locale, deviceLocale) {
216
+ switch (locale) {
217
+ case "ko":
218
+ return "ko";
219
+ case "en":
220
+ return "en";
221
+ case "auto":
222
+ return deviceLocale?.toLowerCase().startsWith("en") ? "en" : "ko";
223
+ default:
224
+ return assertNever(locale);
225
+ }
226
+ }
227
+ function resolveTexts(config, locale) {
228
+ return { ...exports.DEFAULT_TEXTS[locale], ...config.texts[locale], launcher: config.labels[locale] };
229
+ }
230
+ function assertNever(value) {
231
+ throw new TypeError(`Unexpected locale: ${value}`);
232
+ }
@@ -0,0 +1,6 @@
1
+ import type { PaletteColors, Radii, Scheme, Theme, WidgetConfig } from "./config";
2
+ export type Palette = PaletteColors & Readonly<{
3
+ radius: Radii;
4
+ }>;
5
+ export declare function resolveScheme(theme: Theme, systemScheme?: Scheme | null): Scheme;
6
+ export declare function resolvePalette(config: WidgetConfig, scheme: Scheme): Palette;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveScheme = resolveScheme;
4
+ exports.resolvePalette = resolvePalette;
5
+ const config_1 = require("./config");
6
+ const DARK_ACCENTS = {
7
+ neutral: "#e4e4e7",
8
+ blue: "#3b82f6",
9
+ green: "#22c55e",
10
+ violet: "#8b5cf6",
11
+ orange: "#f97316",
12
+ rose: "#f43f5e",
13
+ };
14
+ const PALETTES = {
15
+ light: { background: "#ffffff", text: "#08090a", mutedText: "#5f6b67", border: "rgba(0,0,0,.08)" },
16
+ dark: { background: "#17181c", text: "#f4f5f6", mutedText: "#a1a7b3", border: "rgba(255,255,255,.1)" },
17
+ };
18
+ function resolveScheme(theme, systemScheme) {
19
+ switch (theme) {
20
+ case "light":
21
+ return "light";
22
+ case "dark":
23
+ return "dark";
24
+ case "auto":
25
+ case "system":
26
+ return systemScheme ?? "light";
27
+ default:
28
+ return assertNever(theme);
29
+ }
30
+ }
31
+ function luminance(hex) {
32
+ const channel = (start) => {
33
+ const n = Number.parseInt(hex.slice(start, start + 2), 16) / 255;
34
+ return n <= 0.04045 ? n / 12.92 : ((n + 0.055) / 1.055) ** 2.4;
35
+ };
36
+ return channel(1) * 0.2126 + channel(3) * 0.7152 + channel(5) * 0.0722;
37
+ }
38
+ function resolvePalette(config, scheme) {
39
+ const overrides = config.appearance[scheme];
40
+ const accent = overrides.accent ??
41
+ (scheme === "dark" ? config.appearance.light.accent : undefined) ??
42
+ (scheme === "dark" ? DARK_ACCENTS : config_1.ACCENTS)[config.accentName];
43
+ const lightness = luminance(accent);
44
+ const foreground = 1.05 / (lightness + 0.05) >= (lightness + 0.05) / (luminance("#0a0a0a") + 0.05) ? "#ffffff" : "#0a0a0a";
45
+ return {
46
+ ...PALETTES[scheme],
47
+ ...overrides,
48
+ accent,
49
+ accentText: overrides.accentText ?? foreground,
50
+ radius: config.appearance.radius,
51
+ };
52
+ }
53
+ function assertNever(value) {
54
+ throw new TypeError(`Unexpected theme: ${value}`);
55
+ }
@@ -0,0 +1,9 @@
1
+ import type { FormDataLike, XhrLike } from "./client";
2
+ export type ClientResponse = {
3
+ readonly status: number;
4
+ json(): Promise<unknown>;
5
+ };
6
+ /** Multipart upload over XHR: RN's fetch cannot stream a `FormData` with native file parts reliably. */
7
+ export declare function xhrPost(XhrImpl: new () => XhrLike, url: string, headers: Readonly<Record<string, string>>, form: FormDataLike): Promise<ClientResponse>;
8
+ /** Response body as JSON, or `undefined` when it is not JSON (an old server's HTML 404, a cut-off body). */
9
+ export declare function readJson(response: ClientResponse): Promise<unknown>;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.xhrPost = xhrPost;
4
+ exports.readJson = readJson;
5
+ /** Multipart upload over XHR: RN's fetch cannot stream a `FormData` with native file parts reliably. */
6
+ function xhrPost(XhrImpl, url, headers, form) {
7
+ return new Promise((resolve, reject) => {
8
+ const xhr = new XhrImpl();
9
+ Object.assign(xhr, {
10
+ onload: () => resolve({
11
+ status: xhr.status,
12
+ json: async () => {
13
+ const raw = JSON.parse(xhr.responseText);
14
+ return raw;
15
+ },
16
+ }),
17
+ onerror: () => reject(new TypeError("Multipart upload failed")),
18
+ ontimeout: () => reject(new TypeError("Multipart upload timed out")),
19
+ });
20
+ xhr.open("POST", url);
21
+ xhr.timeout = 30000;
22
+ for (const [name, value] of Object.entries(headers))
23
+ xhr.setRequestHeader(name, value);
24
+ xhr.send(form);
25
+ });
26
+ }
27
+ /** Response body as JSON, or `undefined` when it is not JSON (an old server's HTML 404, a cut-off body). */
28
+ async function readJson(response) {
29
+ try {
30
+ return await response.json();
31
+ }
32
+ catch (error) {
33
+ if (error instanceof Error)
34
+ return undefined;
35
+ throw error;
36
+ }
37
+ }
@@ -0,0 +1,16 @@
1
+ export * from "./core/config";
2
+ export * from "./core/texts";
3
+ export * from "./core/survey";
4
+ export * from "./core/request";
5
+ export * from "./core/theme";
6
+ export * from "./core/client";
7
+ export * from "./core/posts";
8
+ export * from "./core/author-token";
9
+ export { TheSeekerFeedbackProvider } from "./ui/Provider";
10
+ export type { TheSeekerFeedbackProviderProps } from "./ui/Provider";
11
+ export { TheSeekerFeedbackInline } from "./ui/Inline";
12
+ export type { TheSeekerFeedbackInlineProps } from "./ui/Inline";
13
+ export { TheSeekerFeedbackContextError, useTheSeekerFeedback } from "./ui/context";
14
+ export type { PickImages, SubmissionKind, SubmitInput, TheSeekerFeedbackApi } from "./ui/context";
15
+ export { createMemoryStorage } from "./ui/storage";
16
+ export type { FeedbackStorage } from "./ui/storage";
package/dist/index.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.createMemoryStorage = exports.useTheSeekerFeedback = exports.TheSeekerFeedbackContextError = exports.TheSeekerFeedbackInline = exports.TheSeekerFeedbackProvider = void 0;
18
+ __exportStar(require("./core/config"), exports);
19
+ __exportStar(require("./core/texts"), exports);
20
+ __exportStar(require("./core/survey"), exports);
21
+ __exportStar(require("./core/request"), exports);
22
+ __exportStar(require("./core/theme"), exports);
23
+ __exportStar(require("./core/client"), exports);
24
+ __exportStar(require("./core/posts"), exports);
25
+ __exportStar(require("./core/author-token"), exports);
26
+ var Provider_1 = require("./ui/Provider");
27
+ Object.defineProperty(exports, "TheSeekerFeedbackProvider", { enumerable: true, get: function () { return Provider_1.TheSeekerFeedbackProvider; } });
28
+ var Inline_1 = require("./ui/Inline");
29
+ Object.defineProperty(exports, "TheSeekerFeedbackInline", { enumerable: true, get: function () { return Inline_1.TheSeekerFeedbackInline; } });
30
+ var context_1 = require("./ui/context");
31
+ Object.defineProperty(exports, "TheSeekerFeedbackContextError", { enumerable: true, get: function () { return context_1.TheSeekerFeedbackContextError; } });
32
+ Object.defineProperty(exports, "useTheSeekerFeedback", { enumerable: true, get: function () { return context_1.useTheSeekerFeedback; } });
33
+ var storage_1 = require("./ui/storage");
34
+ Object.defineProperty(exports, "createMemoryStorage", { enumerable: true, get: function () { return storage_1.createMemoryStorage; } });
@@ -0,0 +1,9 @@
1
+ import type { ImageAsset } from "../core/request";
2
+ import type { TextKey } from "./forms";
3
+ export type AttachmentsProps = Readonly<{
4
+ images: readonly ImageAsset[];
5
+ error: TextKey | null;
6
+ disabled: boolean;
7
+ onChange: (images: readonly ImageAsset[], error: TextKey | null) => void;
8
+ }>;
9
+ export declare function Attachments({ images, error, disabled, onChange }: AttachmentsProps): import("react").JSX.Element | null;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Attachments = Attachments;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_native_1 = require("react-native");
6
+ const context_1 = require("./context");
7
+ const forms_1 = require("./forms");
8
+ const primitives_1 = require("./primitives");
9
+ function Attachments({ images, error, disabled, onChange }) {
10
+ const { texts, styles, tokens, pickImages } = (0, context_1.useFeedbackUi)();
11
+ if (pickImages === undefined)
12
+ return null;
13
+ async function pick(adapter) {
14
+ let picked;
15
+ try {
16
+ picked = await adapter();
17
+ }
18
+ catch (failure) {
19
+ if (failure instanceof Error)
20
+ return onChange(images, "decodeFailed");
21
+ throw failure;
22
+ }
23
+ const outcome = (0, forms_1.addPicked)(images, picked);
24
+ onChange(outcome.images, outcome.errorKey);
25
+ }
26
+ return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.field, children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.tools, children: [(0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "secondary", label: texts.attachImage, onPress: () => void pick(pickImages), disabled: disabled || images.length >= forms_1.MAX_IMAGES, testID: "theseeker-feedback-attach" }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.meta, styles.end], children: `${images.length} / ${forms_1.MAX_IMAGES}` })] }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.hint, children: texts.imageHint }), images.length === 0 ? null : ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.strip, children: images.map((image, index) => ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsx)(react_native_1.Image, { source: { uri: image.uri }, alt: `${texts.image} ${index + 1}`, style: styles.thumb, accessibilityIgnoresInvertColors: true }), (0, jsx_runtime_1.jsx)(react_native_1.Pressable, { testID: `theseeker-feedback-remove-${index}`, accessibilityRole: "button", accessibilityLabel: `${texts.remove} · ${texts.image} ${index + 1}`, hitSlop: 10, disabled: disabled, onPress: () => onChange(images.filter((_, other) => other !== index), null), style: ({ pressed }) => [styles.removeBadge, pressed && styles.removePressed], children: (0, jsx_runtime_1.jsx)(primitives_1.XGlyph, { size: 12, color: tokens.background }) })] }, `${image.uri}#${index}`))) })), error === null ? null : ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.fieldFoot, children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.error, accessibilityLiveRegion: "polite", children: texts[error] }) }))] }));
27
+ }
@@ -0,0 +1,8 @@
1
+ export type FeedbackFormProps = Readonly<{
2
+ variant: "sheet" | "inline";
3
+ }>;
4
+ /**
5
+ * Shared feedback form. The sheet keeps its unsent draft across close/open and closes 1.5 s after
6
+ * a successful send; the inline card shows the thanks line for 1.5 s and returns to an empty form.
7
+ */
8
+ export declare function FeedbackForm({ variant }: FeedbackFormProps): import("react").JSX.Element;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FeedbackForm = FeedbackForm;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const react_native_1 = require("react-native");
7
+ const request_1 = require("../core/request");
8
+ const Attachments_1 = require("./Attachments");
9
+ const context_1 = require("./context");
10
+ const forms_1 = require("./forms");
11
+ const post_pieces_1 = require("./post-pieces");
12
+ const primitives_1 = require("./primitives");
13
+ /**
14
+ * Shared feedback form. The sheet keeps its unsent draft across close/open and closes 1.5 s after
15
+ * a successful send; the inline card shows the thanks line for 1.5 s and returns to an empty form.
16
+ */
17
+ function FeedbackForm({ variant }) {
18
+ const ui = (0, context_1.useFeedbackUi)();
19
+ const { config, texts, styles, close, draft: store } = ui;
20
+ const sheet = variant === "sheet";
21
+ const [draft, setDraft] = (0, react_1.useState)(() => (sheet ? store.read() : forms_1.EMPTY_DRAFT));
22
+ const [fieldError, setFieldError] = (0, react_1.useState)(null);
23
+ const [imageError, setImageError] = (0, react_1.useState)(null);
24
+ const [failure, setFailure] = (0, react_1.useState)(null);
25
+ const [busy, setBusy] = (0, react_1.useState)(false);
26
+ const [sent, setSent] = (0, react_1.useState)(false);
27
+ const contact = draft.contact ?? ui.contact ?? "";
28
+ const email = config.contactMode === "email";
29
+ (0, react_1.useEffect)(() => {
30
+ if (!sent)
31
+ return;
32
+ const timer = setTimeout(() => {
33
+ if (sheet)
34
+ close();
35
+ else
36
+ setSent(false);
37
+ }, forms_1.AUTO_CLOSE_MS);
38
+ return () => clearTimeout(timer);
39
+ }, [sent, sheet, close]);
40
+ function save(next) {
41
+ setDraft(next);
42
+ if (sheet)
43
+ store.write(next);
44
+ }
45
+ function edit(field, value) {
46
+ save({ ...draft, [field]: value });
47
+ if (fieldError?.field === field)
48
+ setFieldError(null);
49
+ }
50
+ async function send() {
51
+ if (busy)
52
+ return;
53
+ const problem = (0, forms_1.draftError)(draft.message, contact, config.contactMode);
54
+ setFieldError(problem);
55
+ if (problem !== null)
56
+ return (0, primitives_1.announce)(texts[problem.key]);
57
+ setBusy(true);
58
+ setFailure(null);
59
+ const result = await ui.submit({ message: draft.message, contact, images: draft.images });
60
+ setBusy(false);
61
+ if (!result.ok) {
62
+ const text = texts[(0, request_1.errorMessageKey)(result.code)];
63
+ setFailure(text);
64
+ return (0, primitives_1.announce)(text);
65
+ }
66
+ save(forms_1.EMPTY_DRAFT);
67
+ setImageError(null);
68
+ setSent(true);
69
+ (0, primitives_1.announce)(texts.thanks);
70
+ }
71
+ const errorFor = (field) => (fieldError?.field === field ? texts[fieldError.key] : null);
72
+ const title = ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.title, ui.mine !== null && styles.headTitle], accessibilityRole: "header", children: texts.title }));
73
+ return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [ui.mine === null ? (title) : ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.head, children: [title, (0, jsx_runtime_1.jsx)(post_pieces_1.MyFeedbackEntry, {})] })), sent ? ((0, jsx_runtime_1.jsx)(react_native_1.Text, { testID: "theseeker-feedback-thanks", style: styles.thanks, accessibilityLiveRegion: "polite", children: texts.thanks })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.description, children: texts.description }), (0, jsx_runtime_1.jsx)(primitives_1.TextField, { label: texts.contentLabel, value: draft.message, onChangeText: (value) => edit("message", value), error: errorFor("message"), meta: `${draft.message.length} / ${forms_1.MAX_MESSAGE}`, input: {
74
+ testID: "theseeker-feedback-message",
75
+ multiline: true,
76
+ maxLength: forms_1.MAX_MESSAGE,
77
+ placeholder: texts.contentPlaceholder,
78
+ autoFocus: sheet,
79
+ } }), config.contactMode === "hidden" ? null : ((0, jsx_runtime_1.jsx)(primitives_1.TextField, { label: texts.contactLabel, value: contact, onChangeText: (value) => edit("contact", value), error: errorFor("contact"), input: {
80
+ testID: "theseeker-feedback-contact",
81
+ placeholder: texts.contactPlaceholder,
82
+ maxLength: email ? 254 : 120,
83
+ autoCapitalize: "none",
84
+ autoCorrect: false,
85
+ ...(email
86
+ ? { keyboardType: "email-address", autoComplete: "email", textContentType: "emailAddress" }
87
+ : {}),
88
+ } })), (0, jsx_runtime_1.jsx)(Attachments_1.Attachments, { images: draft.images, error: imageError, disabled: busy, onChange: (images, error) => {
89
+ save({ ...draft, images });
90
+ setImageError(error);
91
+ } }), (0, jsx_runtime_1.jsx)(primitives_1.Status, { text: failure, tone: "error" }), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.actions, children: [sheet ? (0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "secondary", label: texts.cancelLabel, onPress: close }) : null, (0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "primary", label: busy ? texts.sending : texts.submitLabel, onPress: () => void send(), disabled: busy, busy: busy, testID: "theseeker-feedback-submit" })] })] }))] }));
92
+ }
@@ -0,0 +1,8 @@
1
+ import type { MineUi } from "./context";
2
+ export type FeedbackPostScreenProps = Readonly<{
3
+ mine: MineUi;
4
+ number: number;
5
+ onBack: () => void;
6
+ }>;
7
+ /** "피드백 글 상세": the post on top, then the team's answers, status lines and the author's follow-ups. */
8
+ export declare function FeedbackPostScreen({ mine, number, onBack }: FeedbackPostScreenProps): import("react").JSX.Element;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FeedbackPostScreen = FeedbackPostScreen;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const react_native_1 = require("react-native");
7
+ const context_1 = require("./context");
8
+ const FollowUpSheet_1 = require("./FollowUpSheet");
9
+ const post_pieces_1 = require("./post-pieces");
10
+ const post_styles_1 = require("./post-styles");
11
+ const post_view_model_1 = require("./post-view-model");
12
+ const PostThread_1 = require("./PostThread");
13
+ const primitives_1 = require("./primitives");
14
+ function PostBody({ post, ctx, onFollowUp }) {
15
+ const styles = (0, post_styles_1.usePostStyles)();
16
+ const { texts } = (0, context_1.useFeedbackUi)();
17
+ const oneWay = post.mode === "one_way";
18
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.divider }), oneWay ? (0, jsx_runtime_1.jsx)(PostThread_1.OneWayStatus, { steps: (0, post_view_model_1.oneWaySteps)(post, ctx) }) : (0, jsx_runtime_1.jsx)(PostThread_1.Thread, { items: (0, post_view_model_1.threadItems)(post, ctx) }), (0, post_view_model_1.followUpVisible)(post) ? ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.action, children: (0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "secondary", label: texts.addFollowUp, onPress: onFollowUp, testID: "theseeker-post-follow-up" }) })) : null, !oneWay && post.status === "closed" ? (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.note, children: texts.followUpClosed }) : null] }));
19
+ }
20
+ /** "피드백 글 상세": the post on top, then the team's answers, status lines and the author's follow-ups. */
21
+ function FeedbackPostScreen({ mine, number, onBack }) {
22
+ const { texts, tokens, locale } = (0, context_1.useFeedbackUi)();
23
+ const styles = (0, post_styles_1.usePostStyles)();
24
+ const [now] = (0, react_1.useState)(() => new Date());
25
+ const [state, setState] = (0, react_1.useState)({ status: "loading" });
26
+ const [composing, setComposing] = (0, react_1.useState)(false);
27
+ const [draft, setDraft] = (0, react_1.useState)("");
28
+ const { client, site, refreshUnread } = mine;
29
+ const ctx = (0, react_1.useMemo)(() => ({ texts, locale, now, site }), [texts, locale, now, site]);
30
+ const fetchPost = (0, react_1.useCallback)(async () => {
31
+ const result = await client.getPost(number);
32
+ return result.ok ? { status: "ready", post: result.value } : { status: "failed", code: result.code };
33
+ }, [client, number]);
34
+ (0, react_1.useEffect)(() => {
35
+ let live = true;
36
+ async function load() {
37
+ const next = await fetchPost();
38
+ if (!live)
39
+ return;
40
+ setState(next);
41
+ // Reading the post marks its answers read on the server.
42
+ if (next.status === "ready")
43
+ await refreshUnread();
44
+ }
45
+ void load();
46
+ return () => {
47
+ live = false;
48
+ };
49
+ }, [fetchPost, refreshUnread]);
50
+ async function retry() {
51
+ setState({ status: "loading" });
52
+ setState(await fetchPost());
53
+ }
54
+ async function sent() {
55
+ setComposing(false);
56
+ setState(await fetchPost());
57
+ }
58
+ function content() {
59
+ switch (state.status) {
60
+ case "loading":
61
+ return ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.state, children: (0, jsx_runtime_1.jsx)(react_native_1.ActivityIndicator, { color: tokens.mutedText, accessibilityLabel: texts.loading }) }));
62
+ case "failed":
63
+ return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.state, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.stateBody, accessibilityLiveRegion: "polite", children: texts[(0, post_view_model_1.loadErrorKey)(state.code)] }), state.code === "NOT_FOUND" ? null : ((0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "secondary", label: texts.retry, onPress: () => void retry() }))] }));
64
+ case "ready":
65
+ return ((0, jsx_runtime_1.jsxs)(react_native_1.ScrollView, { contentContainerStyle: styles.body, keyboardShouldPersistTaps: "handled", children: [(0, jsx_runtime_1.jsx)(PostThread_1.PostHeader, { post: state.post, ctx: ctx, imageSource: (imageId) => client.imageSource(state.post.number, imageId) }), (0, jsx_runtime_1.jsx)(PostBody, { post: state.post, ctx: ctx, onFollowUp: () => setComposing(true) })] }));
66
+ default:
67
+ return assertNever(state);
68
+ }
69
+ }
70
+ return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.screen, children: [(0, jsx_runtime_1.jsx)(post_pieces_1.NavBar, { leading: { label: texts.myFeedback, onPress: onBack, back: true, testID: "theseeker-post-back" } }), content(), state.status === "ready" && (0, post_view_model_1.followUpVisible)(state.post) ? ((0, jsx_runtime_1.jsx)(FollowUpSheet_1.FollowUpSheet, { visible: composing, client: client, number: state.post.number, isPublic: state.post.visibility === "public", draft: draft, onDraftChange: setDraft, onClose: () => setComposing(false), onSent: () => void sent() })) : null] }));
71
+ }
72
+ function assertNever(value) {
73
+ throw new TypeError(`Unexpected post state: ${JSON.stringify(value)}`);
74
+ }
@@ -0,0 +1,2 @@
1
+ /** Bottom sheet: slides up (cross-fades under Reduce Motion); scrim tap, Cancel and back close it. */
2
+ export declare function FeedbackSheet(): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FeedbackSheet = FeedbackSheet;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_native_1 = require("react-native");
6
+ const context_1 = require("./context");
7
+ const FeedbackForm_1 = require("./FeedbackForm");
8
+ const motion_1 = require("./motion");
9
+ /** Bottom sheet: slides up (cross-fades under Reduce Motion); scrim tap, Cancel and back close it. */
10
+ function FeedbackSheet() {
11
+ const { isOpen, close, styles, modalDismissed } = (0, context_1.useFeedbackUi)();
12
+ const reducedMotion = (0, motion_1.useReducedMotion)();
13
+ return ((0, jsx_runtime_1.jsx)(react_native_1.Modal, { visible: isOpen, transparent: true, animationType: reducedMotion ? "fade" : "slide", onRequestClose: close, onDismiss: modalDismissed, statusBarTranslucent: true, children: (0, jsx_runtime_1.jsxs)(react_native_1.KeyboardAvoidingView, { behavior: "padding", style: styles.sheetRoot, children: [(0, jsx_runtime_1.jsx)(react_native_1.Pressable, { testID: "theseeker-feedback-scrim", style: styles.scrim, onPress: close, accessible: false, importantForAccessibility: "no" }), (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.sheet, accessibilityViewIsModal: true, onAccessibilityEscape: close, children: (0, jsx_runtime_1.jsx)(react_native_1.ScrollView, { keyboardShouldPersistTaps: "handled", contentContainerStyle: styles.sheetContent, alwaysBounceVertical: false, children: (0, jsx_runtime_1.jsx)(FeedbackForm_1.FeedbackForm, { variant: "sheet" }) }) })] }) }));
14
+ }