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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +215 -2
  2. package/dist/core/client.d.ts +57 -0
  3. package/dist/core/client.js +113 -0
  4. package/dist/core/config.d.ts +59 -0
  5. package/dist/core/config.js +112 -0
  6. package/dist/core/request.d.ts +53 -0
  7. package/dist/core/request.js +86 -0
  8. package/dist/core/survey.d.ts +12 -0
  9. package/dist/core/survey.js +26 -0
  10. package/dist/core/texts.d.ts +104 -0
  11. package/dist/core/texts.js +140 -0
  12. package/dist/core/theme.d.ts +6 -0
  13. package/dist/core/theme.js +55 -0
  14. package/dist/index.d.ts +14 -0
  15. package/dist/index.js +32 -0
  16. package/dist/ui/Attachments.d.ts +9 -0
  17. package/dist/ui/Attachments.js +27 -0
  18. package/dist/ui/FeedbackForm.d.ts +8 -0
  19. package/dist/ui/FeedbackForm.js +90 -0
  20. package/dist/ui/FeedbackSheet.d.ts +2 -0
  21. package/dist/ui/FeedbackSheet.js +32 -0
  22. package/dist/ui/Inline.d.ts +6 -0
  23. package/dist/ui/Inline.js +16 -0
  24. package/dist/ui/Launcher.d.ts +1 -0
  25. package/dist/ui/Launcher.js +14 -0
  26. package/dist/ui/Provider.d.ts +21 -0
  27. package/dist/ui/Provider.js +131 -0
  28. package/dist/ui/SurveyPrompt.d.ts +2 -0
  29. package/dist/ui/SurveyPrompt.js +52 -0
  30. package/dist/ui/context.d.ts +79 -0
  31. package/dist/ui/context.js +28 -0
  32. package/dist/ui/device.d.ts +10 -0
  33. package/dist/ui/device.js +22 -0
  34. package/dist/ui/forms.d.ts +32 -0
  35. package/dist/ui/forms.js +62 -0
  36. package/dist/ui/primitives.d.ts +33 -0
  37. package/dist/ui/primitives.js +55 -0
  38. package/dist/ui/prop-state.d.ts +9 -0
  39. package/dist/ui/prop-state.js +27 -0
  40. package/dist/ui/storage.d.ts +15 -0
  41. package/dist/ui/storage.js +35 -0
  42. package/dist/ui/styles.d.ts +697 -0
  43. package/dist/ui/styles.js +177 -0
  44. package/dist/ui/tokens.d.ts +16 -0
  45. package/dist/ui/tokens.js +62 -0
  46. package/dist/ui/useSurvey.d.ts +12 -0
  47. package/dist/ui/useSurvey.js +52 -0
  48. package/package.json +34 -4
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.configUrl = configUrl;
4
+ exports.appHeaders = appHeaders;
5
+ exports.screenPageUrl = screenPageUrl;
6
+ exports.buildFeedbackPayload = buildFeedbackPayload;
7
+ exports.buildSurveyPayload = buildSurveyPayload;
8
+ exports.validateImages = validateImages;
9
+ exports.errorMessageKey = errorMessageKey;
10
+ function configUrl(baseUrl, key) {
11
+ return `${baseUrl.replace(/\/+$/, "")}/api/feedback/widget/config?key=${encodeURIComponent(key)}`;
12
+ }
13
+ function appHeaders(appId) {
14
+ return { "X-TheSeeker-App": appId };
15
+ }
16
+ function screenPageUrl(appId, screen) {
17
+ return `app://${appId}/${screen.replace(/^\/+/, "")}`.slice(0, 2000);
18
+ }
19
+ function buildFeedbackPayload(input) {
20
+ const contact = input.contact?.trim();
21
+ const uid = typeof input.uid === "number" && Number.isFinite(input.uid) ? String(input.uid) : input.uid;
22
+ return {
23
+ key: input.key,
24
+ kind: "feedback",
25
+ content: input.message.trim(),
26
+ pageUrl: screenPageUrl(input.appId, input.screen),
27
+ ...contactFields(input.contactMode ?? "email", contact),
28
+ ...(typeof uid === "string" && uid.trim() !== "" && uid.length <= 128 ? { uid } : {}),
29
+ ...(input.client === undefined ? {} : { client: input.client }),
30
+ };
31
+ }
32
+ function contactFields(mode, contact) {
33
+ if (!contact)
34
+ return {};
35
+ switch (mode) {
36
+ case "email":
37
+ return { contactEmail: contact };
38
+ case "text":
39
+ return { contact };
40
+ case "hidden":
41
+ return {};
42
+ default:
43
+ return assertNever(mode);
44
+ }
45
+ }
46
+ function buildSurveyPayload(input) {
47
+ return { ...buildFeedbackPayload(input), kind: input.kind, score: input.score, surveyId: input.surveyId };
48
+ }
49
+ function validateImages(assets) {
50
+ if (assets.length > 4)
51
+ return "TOO_MANY_IMAGES";
52
+ for (const asset of assets) {
53
+ if (!["image/png", "image/jpeg", "image/gif", "image/webp"].includes(asset.mimeType))
54
+ return "INVALID_IMAGE";
55
+ if (asset.fileSize !== undefined && (!Number.isFinite(asset.fileSize) || asset.fileSize < 0))
56
+ return "INVALID_IMAGE";
57
+ if (asset.fileSize !== undefined && asset.fileSize > 2097152)
58
+ return "IMAGE_TOO_LARGE";
59
+ }
60
+ return "ok";
61
+ }
62
+ function errorMessageKey(code) {
63
+ switch (code) {
64
+ case "RATE_LIMITED":
65
+ return "rateLimited";
66
+ case "IMAGES_DISABLED":
67
+ return "imagesOff";
68
+ case "TOO_MANY_IMAGES":
69
+ return "tooMany";
70
+ case "IMAGE_TOO_LARGE":
71
+ return "imageTooLarge";
72
+ case "INVALID_IMAGE":
73
+ return "invalidImage";
74
+ case "APP_NOT_ALLOWED":
75
+ case "ORIGIN_NOT_ALLOWED":
76
+ case "VALIDATION_ERROR":
77
+ case "WIDGET_NOT_FOUND":
78
+ case "NETWORK_ERROR":
79
+ return "failed";
80
+ default:
81
+ return assertNever(code);
82
+ }
83
+ }
84
+ function assertNever(value) {
85
+ throw new TypeError(`Unexpected feedback variant: ${value}`);
86
+ }
@@ -0,0 +1,12 @@
1
+ import type { Survey } from "./config";
2
+ export declare const DAY_MS = 86400000;
3
+ export declare function pathMatches(pattern: string | null, path: string): boolean;
4
+ export declare function surveyStorageKey(id: string): string;
5
+ export type SurveyEligibility = Readonly<{
6
+ survey: Survey;
7
+ screen: string;
8
+ lastShown: string | null;
9
+ now: number;
10
+ random: number;
11
+ }>;
12
+ export declare function isSurveyEligible({ survey, screen, lastShown, now, random }: SurveyEligibility): boolean;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DAY_MS = void 0;
4
+ exports.pathMatches = pathMatches;
5
+ exports.surveyStorageKey = surveyStorageKey;
6
+ exports.isSurveyEligible = isSurveyEligible;
7
+ exports.DAY_MS = 86400000;
8
+ function pathMatches(pattern, path) {
9
+ if (pattern === null)
10
+ return true;
11
+ const source = pattern
12
+ .split("*")
13
+ .map((part) => part.replace(/[.+?^${}()|[\]\\]/g, "\\$&"))
14
+ .join(".*");
15
+ return new RegExp(`^${source}$`).test(path);
16
+ }
17
+ function surveyStorageKey(id) {
18
+ return `tsfb:survey:${id}`;
19
+ }
20
+ function isSurveyEligible({ survey, screen, lastShown, now, random }) {
21
+ if (!pathMatches(survey.pathPattern, screen))
22
+ return false;
23
+ if (lastShown !== null && now - Number(lastShown) < survey.cooldownDays * exports.DAY_MS)
24
+ return false;
25
+ return random * 100 < survey.sampleRate;
26
+ }
@@ -0,0 +1,104 @@
1
+ import type { WidgetConfig } from "./config";
2
+ export declare const DEFAULT_TEXTS: {
3
+ readonly ko: {
4
+ readonly launcher: "피드백";
5
+ readonly title: "피드백 보내기";
6
+ readonly intro: "불편한 점이나 아이디어를 알려 주세요.";
7
+ readonly content: "내용";
8
+ readonly email: "이메일 (선택)";
9
+ readonly attachImage: "이미지 첨부";
10
+ readonly imageHint: "PNG·JPEG·WebP·GIF, 최대 4장, 장당 2MB";
11
+ readonly image: "첨부 이미지";
12
+ readonly dropHere: "여기에 이미지를 놓으세요";
13
+ readonly preparing: "이미지를 준비하는 중…";
14
+ readonly attached: "이미지를 첨부했습니다";
15
+ readonly tooMany: "이미지는 최대 4장까지 첨부할 수 있습니다";
16
+ readonly badType: "PNG, JPEG, WebP, GIF 이미지만 첨부할 수 있습니다";
17
+ readonly imageTooLarge: "이미지가 너무 큽니다 (장당 최대 2MB)";
18
+ readonly decodeFailed: "이미지를 불러오지 못했습니다";
19
+ readonly invalidImage: "이미지 파일을 확인해 주세요";
20
+ readonly imagesOff: "이미지 첨부가 꺼져 있습니다";
21
+ readonly inlineMissing: "인라인 위젯을 넣을 요소를 찾지 못했습니다";
22
+ readonly remove: "삭제";
23
+ readonly send: "보내기";
24
+ readonly close: "닫기";
25
+ readonly sending: "보내는 중…";
26
+ readonly thanks: "보내 주셔서 감사합니다";
27
+ readonly surveyThanks: "응답해 주셔서 감사합니다";
28
+ readonly rateLimited: "잠시 후 다시 시도해 주세요";
29
+ readonly tooLarge: "첨부가 너무 큽니다";
30
+ readonly failed: "전송에 실패했습니다";
31
+ readonly empty: "내용을 입력해 주세요";
32
+ readonly badEmail: "이메일 주소 형식을 확인해 주세요";
33
+ readonly npsScale: "0점부터 10점까지 선택";
34
+ readonly csatScale: "1점부터 5점까지 선택";
35
+ readonly npsLow: "추천하지 않음";
36
+ readonly npsHigh: "적극 추천";
37
+ readonly csatLow: "매우 불만족";
38
+ readonly csatHigh: "매우 만족";
39
+ readonly contact: "연락처 (선택)";
40
+ readonly contactPlaceholder: "텔레그램 아이디 또는 이메일";
41
+ readonly emailPlaceholder: "name@example.com";
42
+ readonly cancel: "취소";
43
+ readonly score: "{n}점";
44
+ };
45
+ readonly en: {
46
+ readonly launcher: "Feedback";
47
+ readonly title: "Send feedback";
48
+ readonly intro: "Tell us what's not working or share an idea.";
49
+ readonly content: "Message";
50
+ readonly email: "Email (optional)";
51
+ readonly attachImage: "Attach image";
52
+ readonly imageHint: "PNG, JPEG, WebP or GIF, up to 4 images, 2 MB each";
53
+ readonly image: "Attached image";
54
+ readonly dropHere: "Drop images here";
55
+ readonly preparing: "Preparing image…";
56
+ readonly attached: "Image attached";
57
+ readonly tooMany: "You can attach up to 4 images";
58
+ readonly badType: "Only PNG, JPEG, WebP and GIF images can be attached";
59
+ readonly imageTooLarge: "Image is too large (2 MB max each)";
60
+ readonly decodeFailed: "Couldn't load the image";
61
+ readonly invalidImage: "Check the image file";
62
+ readonly imagesOff: "Image attachments are turned off";
63
+ readonly inlineMissing: "Couldn't find the element for the inline widget";
64
+ readonly remove: "Remove";
65
+ readonly send: "Send";
66
+ readonly close: "Close";
67
+ readonly sending: "Sending…";
68
+ readonly thanks: "Thanks for your feedback";
69
+ readonly surveyThanks: "Thanks for your response";
70
+ readonly rateLimited: "Please try again in a moment";
71
+ readonly tooLarge: "Attachments are too large";
72
+ readonly failed: "Couldn't send your feedback";
73
+ readonly empty: "Enter a message";
74
+ readonly badEmail: "Check the email address format";
75
+ readonly npsScale: "Choose a score from 0 to 10";
76
+ readonly csatScale: "Choose a score from 1 to 5";
77
+ readonly npsLow: "Not likely";
78
+ readonly npsHigh: "Very likely";
79
+ readonly csatLow: "Very dissatisfied";
80
+ readonly csatHigh: "Very satisfied";
81
+ readonly contact: "Contact (optional)";
82
+ readonly contactPlaceholder: "Telegram handle or email";
83
+ readonly emailPlaceholder: "name@example.com";
84
+ readonly cancel: "Cancel";
85
+ readonly score: "Score {n}";
86
+ };
87
+ };
88
+ export type Locale = "ko" | "en";
89
+ export type LocaleMode = Locale | "auto";
90
+ export type FormTexts = Readonly<{
91
+ title: string;
92
+ description: string;
93
+ contentLabel: string;
94
+ contentPlaceholder: string;
95
+ contactLabel: string;
96
+ contactPlaceholder: string;
97
+ submitLabel: string;
98
+ cancelLabel: string;
99
+ thanks: string;
100
+ }>;
101
+ export type ResolvedTexts = Readonly<Record<keyof typeof DEFAULT_TEXTS.ko, string>> & FormTexts;
102
+ export declare function parseTexts(raw: unknown, contactMode: unknown, locale: Locale): FormTexts;
103
+ export declare function resolveLocale(locale: LocaleMode, deviceLocale?: string | null): Locale;
104
+ export declare function resolveTexts(config: WidgetConfig, locale: Locale): ResolvedTexts;
@@ -0,0 +1,140 @@
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
+ },
51
+ en: {
52
+ launcher: "Feedback",
53
+ title: "Send feedback",
54
+ intro: "Tell us what's not working or share an idea.",
55
+ content: "Message",
56
+ email: "Email (optional)",
57
+ attachImage: "Attach image",
58
+ imageHint: "PNG, JPEG, WebP or GIF, up to 4 images, 2 MB each",
59
+ image: "Attached image",
60
+ dropHere: "Drop images here",
61
+ preparing: "Preparing image…",
62
+ attached: "Image attached",
63
+ tooMany: "You can attach up to 4 images",
64
+ badType: "Only PNG, JPEG, WebP and GIF images can be attached",
65
+ imageTooLarge: "Image is too large (2 MB max each)",
66
+ decodeFailed: "Couldn't load the image",
67
+ invalidImage: "Check the image file",
68
+ imagesOff: "Image attachments are turned off",
69
+ inlineMissing: "Couldn't find the element for the inline widget",
70
+ remove: "Remove",
71
+ send: "Send",
72
+ close: "Close",
73
+ sending: "Sending…",
74
+ thanks: "Thanks for your feedback",
75
+ surveyThanks: "Thanks for your response",
76
+ rateLimited: "Please try again in a moment",
77
+ tooLarge: "Attachments are too large",
78
+ failed: "Couldn't send your feedback",
79
+ empty: "Enter a message",
80
+ badEmail: "Check the email address format",
81
+ npsScale: "Choose a score from 0 to 10",
82
+ csatScale: "Choose a score from 1 to 5",
83
+ npsLow: "Not likely",
84
+ npsHigh: "Very likely",
85
+ csatLow: "Very dissatisfied",
86
+ csatHigh: "Very satisfied",
87
+ contact: "Contact (optional)",
88
+ contactPlaceholder: "Telegram handle or email",
89
+ emailPlaceholder: "name@example.com",
90
+ cancel: "Cancel",
91
+ score: "Score {n}",
92
+ },
93
+ };
94
+ const textOverride = zod_1.z.string().trim().min(1).max(200).optional().catch(undefined);
95
+ const textSchema = zod_1.z
96
+ .object({
97
+ title: textOverride,
98
+ description: textOverride,
99
+ contentLabel: textOverride,
100
+ contentPlaceholder: textOverride,
101
+ contactLabel: textOverride,
102
+ contactPlaceholder: textOverride,
103
+ submitLabel: textOverride,
104
+ cancelLabel: textOverride,
105
+ thanks: textOverride,
106
+ })
107
+ .catch({});
108
+ function parseTexts(raw, contactMode, locale) {
109
+ const value = textSchema.parse(raw);
110
+ const defaults = exports.DEFAULT_TEXTS[locale];
111
+ return {
112
+ title: value.title ?? defaults.title,
113
+ description: value.description ?? defaults.intro,
114
+ contentLabel: value.contentLabel ?? defaults.content,
115
+ contentPlaceholder: value.contentPlaceholder ?? "",
116
+ contactLabel: value.contactLabel ?? (contactMode === "text" ? defaults.contact : defaults.email),
117
+ contactPlaceholder: value.contactPlaceholder ?? (contactMode === "text" ? defaults.contactPlaceholder : defaults.emailPlaceholder),
118
+ submitLabel: value.submitLabel ?? defaults.send,
119
+ cancelLabel: value.cancelLabel ?? defaults.cancel,
120
+ thanks: value.thanks ?? defaults.thanks,
121
+ };
122
+ }
123
+ function resolveLocale(locale, deviceLocale) {
124
+ switch (locale) {
125
+ case "ko":
126
+ return "ko";
127
+ case "en":
128
+ return "en";
129
+ case "auto":
130
+ return deviceLocale?.toLowerCase().startsWith("en") ? "en" : "ko";
131
+ default:
132
+ return assertNever(locale);
133
+ }
134
+ }
135
+ function resolveTexts(config, locale) {
136
+ return { ...exports.DEFAULT_TEXTS[locale], ...config.texts[locale], launcher: config.labels[locale] };
137
+ }
138
+ function assertNever(value) {
139
+ throw new TypeError(`Unexpected locale: ${value}`);
140
+ }
@@ -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,14 @@
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 { TheSeekerFeedbackProvider } from "./ui/Provider";
8
+ export type { TheSeekerFeedbackProviderProps } from "./ui/Provider";
9
+ export { TheSeekerFeedbackInline } from "./ui/Inline";
10
+ export type { TheSeekerFeedbackInlineProps } from "./ui/Inline";
11
+ export { TheSeekerFeedbackContextError, useTheSeekerFeedback } from "./ui/context";
12
+ export type { PickImages, SubmissionKind, SubmitInput, TheSeekerFeedbackApi } from "./ui/context";
13
+ export { createMemoryStorage } from "./ui/storage";
14
+ export type { FeedbackStorage } from "./ui/storage";
package/dist/index.js ADDED
@@ -0,0 +1,32 @@
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
+ var Provider_1 = require("./ui/Provider");
25
+ Object.defineProperty(exports, "TheSeekerFeedbackProvider", { enumerable: true, get: function () { return Provider_1.TheSeekerFeedbackProvider; } });
26
+ var Inline_1 = require("./ui/Inline");
27
+ Object.defineProperty(exports, "TheSeekerFeedbackInline", { enumerable: true, get: function () { return Inline_1.TheSeekerFeedbackInline; } });
28
+ var context_1 = require("./ui/context");
29
+ Object.defineProperty(exports, "TheSeekerFeedbackContextError", { enumerable: true, get: function () { return context_1.TheSeekerFeedbackContextError; } });
30
+ Object.defineProperty(exports, "useTheSeekerFeedback", { enumerable: true, get: function () { return context_1.useTheSeekerFeedback; } });
31
+ var storage_1 = require("./ui/storage");
32
+ 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,90 @@
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 primitives_1 = require("./primitives");
12
+ /**
13
+ * Shared feedback form. The sheet keeps its unsent draft across close/open and closes 1.5 s after
14
+ * a successful send; the inline card shows the thanks line for 1.5 s and returns to an empty form.
15
+ */
16
+ function FeedbackForm({ variant }) {
17
+ const ui = (0, context_1.useFeedbackUi)();
18
+ const { config, texts, styles, close, draft: store } = ui;
19
+ const sheet = variant === "sheet";
20
+ const [draft, setDraft] = (0, react_1.useState)(() => (sheet ? store.read() : forms_1.EMPTY_DRAFT));
21
+ const [fieldError, setFieldError] = (0, react_1.useState)(null);
22
+ const [imageError, setImageError] = (0, react_1.useState)(null);
23
+ const [failure, setFailure] = (0, react_1.useState)(null);
24
+ const [busy, setBusy] = (0, react_1.useState)(false);
25
+ const [sent, setSent] = (0, react_1.useState)(false);
26
+ const contact = draft.contact ?? ui.contact ?? "";
27
+ const email = config.contactMode === "email";
28
+ (0, react_1.useEffect)(() => {
29
+ if (!sent)
30
+ return;
31
+ const timer = setTimeout(() => {
32
+ if (sheet)
33
+ close();
34
+ else
35
+ setSent(false);
36
+ }, forms_1.AUTO_CLOSE_MS);
37
+ return () => clearTimeout(timer);
38
+ }, [sent, sheet, close]);
39
+ function save(next) {
40
+ setDraft(next);
41
+ if (sheet)
42
+ store.write(next);
43
+ }
44
+ function edit(field, value) {
45
+ save({ ...draft, [field]: value });
46
+ if (fieldError?.field === field)
47
+ setFieldError(null);
48
+ }
49
+ async function send() {
50
+ if (busy)
51
+ return;
52
+ const problem = (0, forms_1.draftError)(draft.message, contact, config.contactMode);
53
+ setFieldError(problem);
54
+ if (problem !== null)
55
+ return (0, primitives_1.announce)(texts[problem.key]);
56
+ setBusy(true);
57
+ setFailure(null);
58
+ const result = await ui.submit({ message: draft.message, contact, images: draft.images });
59
+ setBusy(false);
60
+ if (!result.ok) {
61
+ const text = texts[(0, request_1.errorMessageKey)(result.code)];
62
+ setFailure(text);
63
+ return (0, primitives_1.announce)(text);
64
+ }
65
+ save(forms_1.EMPTY_DRAFT);
66
+ setImageError(null);
67
+ setSent(true);
68
+ (0, primitives_1.announce)(texts.thanks);
69
+ }
70
+ const errorFor = (field) => (fieldError?.field === field ? texts[fieldError.key] : null);
71
+ return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.title, accessibilityRole: "header", children: texts.title }), 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: {
72
+ testID: "theseeker-feedback-message",
73
+ multiline: true,
74
+ maxLength: forms_1.MAX_MESSAGE,
75
+ placeholder: texts.contentPlaceholder,
76
+ autoFocus: sheet,
77
+ } }), 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: {
78
+ testID: "theseeker-feedback-contact",
79
+ placeholder: texts.contactPlaceholder,
80
+ maxLength: email ? 254 : 120,
81
+ autoCapitalize: "none",
82
+ autoCorrect: false,
83
+ ...(email
84
+ ? { keyboardType: "email-address", autoComplete: "email", textContentType: "emailAddress" }
85
+ : {}),
86
+ } })), (0, jsx_runtime_1.jsx)(Attachments_1.Attachments, { images: draft.images, error: imageError, disabled: busy, onChange: (images, error) => {
87
+ save({ ...draft, images });
88
+ setImageError(error);
89
+ } }), (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" })] })] }))] }));
90
+ }
@@ -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;