@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.
- package/README.md +266 -2
- package/dist/core/author-token.d.ts +16 -0
- package/dist/core/author-token.js +96 -0
- package/dist/core/client.d.ts +55 -0
- package/dist/core/client.js +98 -0
- package/dist/core/config.d.ts +59 -0
- package/dist/core/config.js +112 -0
- package/dist/core/posts-schema.d.ts +306 -0
- package/dist/core/posts-schema.js +131 -0
- package/dist/core/posts.d.ts +67 -0
- package/dist/core/posts.js +113 -0
- package/dist/core/request.d.ts +53 -0
- package/dist/core/request.js +88 -0
- package/dist/core/survey.d.ts +12 -0
- package/dist/core/survey.js +26 -0
- package/dist/core/texts.d.ts +196 -0
- package/dist/core/texts.js +232 -0
- package/dist/core/theme.d.ts +6 -0
- package/dist/core/theme.js +55 -0
- package/dist/core/transport.d.ts +9 -0
- package/dist/core/transport.js +37 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +34 -0
- package/dist/ui/Attachments.d.ts +9 -0
- package/dist/ui/Attachments.js +27 -0
- package/dist/ui/FeedbackForm.d.ts +8 -0
- package/dist/ui/FeedbackForm.js +92 -0
- package/dist/ui/FeedbackPostScreen.d.ts +8 -0
- package/dist/ui/FeedbackPostScreen.js +74 -0
- package/dist/ui/FeedbackSheet.d.ts +2 -0
- package/dist/ui/FeedbackSheet.js +14 -0
- package/dist/ui/FollowUpSheet.d.ts +17 -0
- package/dist/ui/FollowUpSheet.js +50 -0
- package/dist/ui/Inline.d.ts +6 -0
- package/dist/ui/Inline.js +16 -0
- package/dist/ui/Launcher.d.ts +1 -0
- package/dist/ui/Launcher.js +16 -0
- package/dist/ui/MyFeedbackModal.d.ts +10 -0
- package/dist/ui/MyFeedbackModal.js +45 -0
- package/dist/ui/MyFeedbackScreen.d.ts +9 -0
- package/dist/ui/MyFeedbackScreen.js +88 -0
- package/dist/ui/PostThread.d.ts +17 -0
- package/dist/ui/PostThread.js +57 -0
- package/dist/ui/Provider.d.ts +24 -0
- package/dist/ui/Provider.js +186 -0
- package/dist/ui/SurveyPrompt.d.ts +2 -0
- package/dist/ui/SurveyPrompt.js +52 -0
- package/dist/ui/context.d.ts +122 -0
- package/dist/ui/context.js +28 -0
- package/dist/ui/device.d.ts +10 -0
- package/dist/ui/device.js +22 -0
- package/dist/ui/forms.d.ts +32 -0
- package/dist/ui/forms.js +62 -0
- package/dist/ui/motion.d.ts +1 -0
- package/dist/ui/motion.js +23 -0
- package/dist/ui/post-format.d.ts +19 -0
- package/dist/ui/post-format.js +79 -0
- package/dist/ui/post-pieces.d.ts +24 -0
- package/dist/ui/post-pieces.js +60 -0
- package/dist/ui/post-styles.d.ts +317 -0
- package/dist/ui/post-styles.js +103 -0
- package/dist/ui/post-view-model.d.ts +52 -0
- package/dist/ui/post-view-model.js +181 -0
- package/dist/ui/primitives.d.ts +33 -0
- package/dist/ui/primitives.js +55 -0
- package/dist/ui/prop-state.d.ts +9 -0
- package/dist/ui/prop-state.js +27 -0
- package/dist/ui/storage.d.ts +15 -0
- package/dist/ui/storage.js +35 -0
- package/dist/ui/styles.d.ts +774 -0
- package/dist/ui/styles.js +185 -0
- package/dist/ui/surfaces.d.ts +13 -0
- package/dist/ui/surfaces.js +41 -0
- package/dist/ui/tokens.d.ts +16 -0
- package/dist/ui/tokens.js +62 -0
- package/dist/ui/useMyPosts.d.ts +35 -0
- package/dist/ui/useMyPosts.js +124 -0
- package/dist/ui/useSurvey.d.ts +12 -0
- package/dist/ui/useSurvey.js +52 -0
- package/package.json +32 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { PostsClient } from "../core/posts";
|
|
2
|
+
export type FollowUpSheetProps = Readonly<{
|
|
3
|
+
visible: boolean;
|
|
4
|
+
client: PostsClient;
|
|
5
|
+
number: number;
|
|
6
|
+
isPublic: boolean;
|
|
7
|
+
/** Owned by the post screen, so a swipe-dismissed sheet reopens with the unsent text. */
|
|
8
|
+
draft: string;
|
|
9
|
+
onDraftChange: (draft: string) => void;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
onSent: () => void;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* "추가 의견" composer: a native page sheet on iOS (swipe down to dismiss; UIKit hands the drag to
|
|
15
|
+
* the content until it is scrolled to the top), a full-screen dialog with back on Android.
|
|
16
|
+
*/
|
|
17
|
+
export declare function FollowUpSheet(props: FollowUpSheetProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FollowUpSheet = FollowUpSheet;
|
|
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 posts_1 = require("../core/posts");
|
|
8
|
+
const context_1 = require("./context");
|
|
9
|
+
const motion_1 = require("./motion");
|
|
10
|
+
const post_styles_1 = require("./post-styles");
|
|
11
|
+
const post_view_model_1 = require("./post-view-model");
|
|
12
|
+
const primitives_1 = require("./primitives");
|
|
13
|
+
/**
|
|
14
|
+
* "추가 의견" composer: a native page sheet on iOS (swipe down to dismiss; UIKit hands the drag to
|
|
15
|
+
* the content until it is scrolled to the top), a full-screen dialog with back on Android.
|
|
16
|
+
*/
|
|
17
|
+
function FollowUpSheet(props) {
|
|
18
|
+
const { visible, client, number, isPublic, draft, onDraftChange, onClose, onSent } = props;
|
|
19
|
+
const { texts, tokens, styles: base } = (0, context_1.useFeedbackUi)();
|
|
20
|
+
const styles = (0, post_styles_1.usePostStyles)();
|
|
21
|
+
const reducedMotion = (0, motion_1.useReducedMotion)();
|
|
22
|
+
const [busy, setBusy] = (0, react_1.useState)(false);
|
|
23
|
+
const [fieldError, setFieldError] = (0, react_1.useState)(null);
|
|
24
|
+
const [failure, setFailure] = (0, react_1.useState)(null);
|
|
25
|
+
function edit(value) {
|
|
26
|
+
onDraftChange(value);
|
|
27
|
+
setFieldError(null);
|
|
28
|
+
}
|
|
29
|
+
async function send() {
|
|
30
|
+
if (busy)
|
|
31
|
+
return;
|
|
32
|
+
if (!draft.trim()) {
|
|
33
|
+
setFieldError(texts.empty);
|
|
34
|
+
return (0, primitives_1.announce)(texts.empty);
|
|
35
|
+
}
|
|
36
|
+
setBusy(true);
|
|
37
|
+
setFailure(null);
|
|
38
|
+
const result = await client.addFollowUp(number, draft);
|
|
39
|
+
setBusy(false);
|
|
40
|
+
if (!result.ok) {
|
|
41
|
+
const text = texts[(0, post_view_model_1.followUpErrorKey)(result.code)];
|
|
42
|
+
setFailure(text);
|
|
43
|
+
return (0, primitives_1.announce)(text);
|
|
44
|
+
}
|
|
45
|
+
onDraftChange("");
|
|
46
|
+
(0, primitives_1.announce)(texts.followUpSent);
|
|
47
|
+
onSent();
|
|
48
|
+
}
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Modal, { visible: visible, animationType: reducedMotion ? "fade" : "slide", presentationStyle: "pageSheet", allowSwipeDismissal: true, onRequestClose: onClose, backdropColor: tokens.background, children: (0, jsx_runtime_1.jsx)(react_native_1.KeyboardAvoidingView, { behavior: "padding", style: styles.screen, children: (0, jsx_runtime_1.jsxs)(react_native_1.ScrollView, { keyboardShouldPersistTaps: "handled", contentContainerStyle: styles.sheetBody, alwaysBounceVertical: false, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: base.title, accessibilityRole: "header", children: texts.followUp }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.hint, children: isPublic ? `${texts.followUpHint} ${texts.followUpPublicHint}` : texts.followUpHint }), (0, jsx_runtime_1.jsx)(primitives_1.TextField, { label: texts.content, value: draft, onChangeText: edit, error: fieldError, meta: `${draft.length} / ${posts_1.MAX_FOLLOW_UP}`, input: { testID: "theseeker-follow-up-body", multiline: true, maxLength: posts_1.MAX_FOLLOW_UP, autoFocus: true } }), (0, jsx_runtime_1.jsx)(primitives_1.Status, { text: failure, tone: "error" }), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: base.actions, children: [(0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "secondary", label: texts.cancel, onPress: onClose, testID: "theseeker-follow-up-cancel" }), (0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "primary", label: busy ? texts.sending : texts.followUpSubmit, onPress: () => void send(), disabled: busy, busy: busy, testID: "theseeker-follow-up-submit" })] })] }) }) }));
|
|
50
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
export type TheSeekerFeedbackInlineProps = Readonly<{
|
|
3
|
+
style?: StyleProp<ViewStyle>;
|
|
4
|
+
}>;
|
|
5
|
+
/** The feedback form as an in-place card (e.g. a settings screen); renders nothing until the config loads. */
|
|
6
|
+
export declare function TheSeekerFeedbackInline({ style }: TheSeekerFeedbackInlineProps): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TheSeekerFeedbackInline = TheSeekerFeedbackInline;
|
|
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 FeedbackForm_1 = require("./FeedbackForm");
|
|
9
|
+
/** The feedback form as an in-place card (e.g. a settings screen); renders nothing until the config loads. */
|
|
10
|
+
function TheSeekerFeedbackInline({ style }) {
|
|
11
|
+
(0, context_1.useTheSeekerFeedback)();
|
|
12
|
+
const ui = (0, react_1.useContext)(context_1.FeedbackUiContext);
|
|
13
|
+
if (ui === null)
|
|
14
|
+
return null;
|
|
15
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.View, { testID: "theseeker-feedback-inline", style: [ui.styles.card, style], children: (0, jsx_runtime_1.jsx)(FeedbackForm_1.FeedbackForm, { variant: "inline" }) }));
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Launcher(): import("react").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Launcher = Launcher;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_native_1 = require("react-native");
|
|
6
|
+
const context_1 = require("./context");
|
|
7
|
+
function Launcher() {
|
|
8
|
+
const { config, texts, styles, open, mine } = (0, context_1.useFeedbackUi)();
|
|
9
|
+
const unread = mine?.unreadCount ?? 0;
|
|
10
|
+
const label = unread > 0 ? `${texts.launcher}, ${texts.unreadCount.replace("{n}", String(unread))}` : texts.launcher;
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { testID: "theseeker-feedback-launcher", accessibilityRole: "button", accessibilityLabel: label, onPress: open, style: ({ pressed }) => [
|
|
12
|
+
styles.launcher,
|
|
13
|
+
config.position === "bottom-left" ? styles.launcherLeft : styles.launcherRight,
|
|
14
|
+
pressed && styles.launcherPressed,
|
|
15
|
+
], children: (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.launcherRow, children: [unread > 0 ? (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.launcherDot }) : null, (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.launcherLabel, numberOfLines: 1, children: texts.launcher })] }) }));
|
|
16
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { MineUi } from "./context";
|
|
2
|
+
/**
|
|
3
|
+
* Hosts "내 피드백" and the post screen. iOS: a page sheet that swipes down to close (UIKit only
|
|
4
|
+
* starts that drag once the content is scrolled to the top). Android: a full-screen dialog where
|
|
5
|
+
* back returns from a post to the list, then closes. Every open starts again at the list.
|
|
6
|
+
*/
|
|
7
|
+
export declare function MyFeedbackModal({ mine, onWrite }: Readonly<{
|
|
8
|
+
mine: MineUi;
|
|
9
|
+
onWrite: () => void;
|
|
10
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MyFeedbackModal = MyFeedbackModal;
|
|
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 FeedbackPostScreen_1 = require("./FeedbackPostScreen");
|
|
9
|
+
const motion_1 = require("./motion");
|
|
10
|
+
const MyFeedbackScreen_1 = require("./MyFeedbackScreen");
|
|
11
|
+
const LIST = { name: "list" };
|
|
12
|
+
/**
|
|
13
|
+
* Hosts "내 피드백" and the post screen. iOS: a page sheet that swipes down to close (UIKit only
|
|
14
|
+
* starts that drag once the content is scrolled to the top). Android: a full-screen dialog where
|
|
15
|
+
* back returns from a post to the list, then closes. Every open starts again at the list.
|
|
16
|
+
*/
|
|
17
|
+
function MyFeedbackModal({ mine, onWrite }) {
|
|
18
|
+
const { tokens, modalDismissed } = (0, context_1.useFeedbackUi)();
|
|
19
|
+
const reducedMotion = (0, motion_1.useReducedMotion)();
|
|
20
|
+
const [stored, setStored] = (0, react_1.useState)({
|
|
21
|
+
session: mine.session,
|
|
22
|
+
route: LIST,
|
|
23
|
+
});
|
|
24
|
+
const route = stored.session === mine.session ? stored.route : LIST;
|
|
25
|
+
const go = (next) => setStored({ session: mine.session, route: next });
|
|
26
|
+
function requestClose() {
|
|
27
|
+
if (react_native_1.Platform.OS === "android" && route.name === "post")
|
|
28
|
+
return go(LIST);
|
|
29
|
+
mine.close();
|
|
30
|
+
}
|
|
31
|
+
function screen() {
|
|
32
|
+
switch (route.name) {
|
|
33
|
+
case "list":
|
|
34
|
+
return ((0, jsx_runtime_1.jsx)(MyFeedbackScreen_1.MyFeedbackScreen, { mine: mine, onOpen: (number) => go({ name: "post", number }), onClose: mine.close, onWrite: onWrite }));
|
|
35
|
+
case "post":
|
|
36
|
+
return (0, jsx_runtime_1.jsx)(FeedbackPostScreen_1.FeedbackPostScreen, { mine: mine, number: route.number, onBack: () => go(LIST) }, route.number);
|
|
37
|
+
default:
|
|
38
|
+
return assertNever(route);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Modal, { visible: mine.isOpen, animationType: reducedMotion ? "fade" : "slide", presentationStyle: "pageSheet", allowSwipeDismissal: true, onRequestClose: requestClose, onDismiss: modalDismissed, backdropColor: tokens.background, children: screen() }));
|
|
42
|
+
}
|
|
43
|
+
function assertNever(value) {
|
|
44
|
+
throw new TypeError(`Unexpected route: ${JSON.stringify(value)}`);
|
|
45
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MineUi } from "./context";
|
|
2
|
+
export type MyFeedbackScreenProps = Readonly<{
|
|
3
|
+
mine: MineUi;
|
|
4
|
+
onOpen: (number: number) => void;
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
onWrite: () => void;
|
|
7
|
+
}>;
|
|
8
|
+
/** "내 피드백": the author's posts, newest first, with status, answer state and unread dots. */
|
|
9
|
+
export declare function MyFeedbackScreen({ mine, onOpen, onClose, onWrite }: MyFeedbackScreenProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MyFeedbackScreen = MyFeedbackScreen;
|
|
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 post_pieces_1 = require("./post-pieces");
|
|
9
|
+
const post_styles_1 = require("./post-styles");
|
|
10
|
+
const post_view_model_1 = require("./post-view-model");
|
|
11
|
+
const primitives_1 = require("./primitives");
|
|
12
|
+
function Separator() {
|
|
13
|
+
const styles = (0, post_styles_1.usePostStyles)();
|
|
14
|
+
return (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.separator });
|
|
15
|
+
}
|
|
16
|
+
function PostRowView({ row, onPress }) {
|
|
17
|
+
const styles = (0, post_styles_1.usePostStyles)();
|
|
18
|
+
const { tokens } = (0, context_1.useFeedbackUi)();
|
|
19
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.Pressable, { accessibilityRole: "button", accessibilityLabel: row.accessibilityLabel, onPress: onPress, testID: `theseeker-my-feedback-post-${row.number}`, style: ({ pressed }) => [styles.row, pressed && styles.rowPressed], children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.rowTop, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.rowTitle, numberOfLines: 1, children: row.title }), (0, jsx_runtime_1.jsx)(post_pieces_1.Chevron, { size: 14, color: tokens.mutedText, direction: "forward" })] }), row.excerpt === null ? null : ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.excerpt, numberOfLines: 1, children: row.excerpt })), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.tags, children: [(0, jsx_runtime_1.jsx)(post_pieces_1.StatusBadge, { label: row.status }), row.answer === null ? null : ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: row.answer.tone === "answered" ? styles.answered : styles.awaiting, children: row.answer.text })), row.unread ? (0, jsx_runtime_1.jsx)(post_pieces_1.UnreadDot, {}) : null, (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.meta, styles.end], children: row.date })] })] }));
|
|
20
|
+
}
|
|
21
|
+
/** "내 피드백": the author's posts, newest first, with status, answer state and unread dots. */
|
|
22
|
+
function MyFeedbackScreen({ mine, onOpen, onClose, onWrite }) {
|
|
23
|
+
const { texts, tokens, locale } = (0, context_1.useFeedbackUi)();
|
|
24
|
+
const styles = (0, post_styles_1.usePostStyles)();
|
|
25
|
+
const [now] = (0, react_1.useState)(() => new Date());
|
|
26
|
+
const [state, setState] = (0, react_1.useState)({ status: "loading" });
|
|
27
|
+
const [refreshing, setRefreshing] = (0, react_1.useState)(false);
|
|
28
|
+
const { client, site } = mine;
|
|
29
|
+
const ctx = (0, react_1.useMemo)(() => ({ texts, locale, now, site }), [texts, locale, now, site]);
|
|
30
|
+
const firstPage = (0, react_1.useCallback)(async () => {
|
|
31
|
+
const result = await client.listMyPosts();
|
|
32
|
+
return result.ok ? { status: "ready", page: result.value, more: "idle" } : { status: "failed", code: result.code };
|
|
33
|
+
}, [client]);
|
|
34
|
+
(0, react_1.useEffect)(() => {
|
|
35
|
+
let live = true;
|
|
36
|
+
async function load() {
|
|
37
|
+
const next = await firstPage();
|
|
38
|
+
if (live)
|
|
39
|
+
setState(next);
|
|
40
|
+
}
|
|
41
|
+
void load();
|
|
42
|
+
return () => {
|
|
43
|
+
live = false;
|
|
44
|
+
};
|
|
45
|
+
}, [firstPage]);
|
|
46
|
+
async function retry() {
|
|
47
|
+
setState({ status: "loading" });
|
|
48
|
+
setState(await firstPage());
|
|
49
|
+
}
|
|
50
|
+
async function refresh() {
|
|
51
|
+
setRefreshing(true);
|
|
52
|
+
const next = await firstPage();
|
|
53
|
+
setRefreshing(false);
|
|
54
|
+
if (next.status === "ready")
|
|
55
|
+
return setState(next);
|
|
56
|
+
(0, primitives_1.announce)(texts[(0, post_view_model_1.loadErrorKey)(next.code)]);
|
|
57
|
+
}
|
|
58
|
+
async function more(page) {
|
|
59
|
+
if (page.nextCursor === null)
|
|
60
|
+
return;
|
|
61
|
+
setState({ status: "ready", page, more: "loading" });
|
|
62
|
+
const result = await client.listMyPosts(page.nextCursor);
|
|
63
|
+
if (!result.ok)
|
|
64
|
+
return setState({ status: "ready", page, more: "failed" });
|
|
65
|
+
const posts = [...page.posts, ...result.value.posts];
|
|
66
|
+
setState({ status: "ready", page: { posts, nextCursor: result.value.nextCursor }, more: "idle" });
|
|
67
|
+
}
|
|
68
|
+
function body() {
|
|
69
|
+
switch (state.status) {
|
|
70
|
+
case "loading":
|
|
71
|
+
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 }) }));
|
|
72
|
+
case "failed":
|
|
73
|
+
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)] }), (0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "secondary", label: texts.retry, onPress: () => void retry() })] }));
|
|
74
|
+
case "ready":
|
|
75
|
+
return state.page.posts.length === 0 ? ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.state, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.stateTitle, children: texts.emptyMine }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.stateBody, children: texts.emptyMineHint }), (0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "primary", label: texts.writeFeedback, onPress: onWrite, testID: "theseeker-my-feedback-empty-write" })] })) : ((0, jsx_runtime_1.jsx)(react_native_1.FlatList, { data: state.page.posts, keyExtractor: (post) => String(post.number), renderItem: ({ item }) => (0, jsx_runtime_1.jsx)(PostRowView, { row: (0, post_view_model_1.postRow)(item, ctx), onPress: () => onOpen(item.number) }), ItemSeparatorComponent: Separator, contentContainerStyle: styles.listEnd, keyboardShouldPersistTaps: "handled", ...(react_native_1.Platform.OS === "android"
|
|
76
|
+
? {
|
|
77
|
+
refreshControl: ((0, jsx_runtime_1.jsx)(react_native_1.RefreshControl, { refreshing: refreshing, onRefresh: () => void refresh(), colors: [tokens.accent], progressBackgroundColor: tokens.background })),
|
|
78
|
+
}
|
|
79
|
+
: {}), ListFooterComponent: state.page.nextCursor === null ? null : ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.footer, children: [(0, jsx_runtime_1.jsx)(primitives_1.Status, { text: state.more === "failed" ? texts.loadFailed : null, tone: "error" }), (0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "secondary", label: state.more === "loading" ? texts.loading : texts.loadMore, onPress: () => void more(state.page), disabled: state.more === "loading", busy: state.more === "loading" })] })) }));
|
|
80
|
+
default:
|
|
81
|
+
return assertNever(state);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
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.close, onPress: onClose, testID: "theseeker-my-feedback-close" }, trailing: { label: texts.writeFeedback, onPress: onWrite, testID: "theseeker-my-feedback-write" } }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.screenTitle, accessibilityRole: "header", children: texts.myFeedback }), body()] }));
|
|
85
|
+
}
|
|
86
|
+
function assertNever(value) {
|
|
87
|
+
throw new TypeError(`Unexpected list state: ${JSON.stringify(value)}`);
|
|
88
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ImageSource, PostDetail } from "../core/posts";
|
|
2
|
+
import type { ThreadItem, TimelineStep, ViewContext } from "./post-view-model";
|
|
3
|
+
export type PostHeaderProps = Readonly<{
|
|
4
|
+
post: PostDetail;
|
|
5
|
+
ctx: ViewContext;
|
|
6
|
+
imageSource: (imageId: string) => ImageSource;
|
|
7
|
+
}>;
|
|
8
|
+
/** The author's post on top: status, board, title, date, body and attachments. */
|
|
9
|
+
export declare function PostHeader({ post, ctx, imageSource }: PostHeaderProps): import("react").JSX.Element;
|
|
10
|
+
/** Two-way thread: full-width answer and follow-up blocks with dates, status lines between them. */
|
|
11
|
+
export declare function Thread({ items }: Readonly<{
|
|
12
|
+
items: readonly ThreadItem[];
|
|
13
|
+
}>): import("react").JSX.Element;
|
|
14
|
+
/** One-way sites: "접수됨 · 현재 상태" with the status steps only; no answers, no follow-ups. */
|
|
15
|
+
export declare function OneWayStatus({ steps }: Readonly<{
|
|
16
|
+
steps: readonly TimelineStep[];
|
|
17
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PostHeader = PostHeader;
|
|
4
|
+
exports.Thread = Thread;
|
|
5
|
+
exports.OneWayStatus = OneWayStatus;
|
|
6
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
|
+
const react_native_1 = require("react-native");
|
|
8
|
+
const context_1 = require("./context");
|
|
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
|
+
/** The author's post on top: status, board, title, date, body and attachments. */
|
|
13
|
+
function PostHeader({ post, ctx, imageSource }) {
|
|
14
|
+
const styles = (0, post_styles_1.usePostStyles)();
|
|
15
|
+
const { texts } = (0, context_1.useFeedbackUi)();
|
|
16
|
+
const meta = (0, post_view_model_1.postMeta)(post, ctx);
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.tags, children: [meta.badges.map((label, index) => ((0, jsx_runtime_1.jsx)(post_pieces_1.StatusBadge, { label: label }, `${index}:${label}`))), meta.board === null ? null : (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.meta, children: meta.board })] }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.postTitle, accessibilityRole: "header", children: meta.title }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.written, children: meta.written }), meta.links.map((link) => ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.written, children: link }, link))), post.content === "" ? null : ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.content, selectable: true, children: post.content })), post.images.length === 0 ? null : ((0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.images, children: post.images.map((image, index) => ((0, jsx_runtime_1.jsx)(react_native_1.Image, { source: imageSource(image.id), alt: `${texts.image} ${index + 1}`, style: styles.thumb, accessibilityIgnoresInvertColors: true }, image.id))) }))] }));
|
|
18
|
+
}
|
|
19
|
+
function ThreadRow({ item, styles }) {
|
|
20
|
+
const toneStyles = { team: styles.teamBlock, auto: styles.teamBlock, author: styles.authorBlock, comment: null };
|
|
21
|
+
switch (item.kind) {
|
|
22
|
+
case "line":
|
|
23
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.line, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.lineDot }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.lineText, children: item.text })] }));
|
|
24
|
+
case "block":
|
|
25
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [styles.block, toneStyles[item.tone]], children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.blockHead, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.blockLabel, children: item.label }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.meta, styles.end], children: item.date })] }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.blockBody, selectable: true, children: item.body })] }));
|
|
26
|
+
default:
|
|
27
|
+
return assertNever(item);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/** Two-way thread: full-width answer and follow-up blocks with dates, status lines between them. */
|
|
31
|
+
function Thread({ items }) {
|
|
32
|
+
const styles = (0, post_styles_1.usePostStyles)();
|
|
33
|
+
const { texts } = (0, context_1.useFeedbackUi)();
|
|
34
|
+
const answered = items.some((item) => item.kind === "block" && item.tone === "team");
|
|
35
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.thread, children: [items.map((item) => ((0, jsx_runtime_1.jsx)(ThreadRow, { item: item, styles: styles }, item.id))), answered ? null : (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.note, children: texts.noAnswerYet })] }));
|
|
36
|
+
}
|
|
37
|
+
function markerStyle(state, styles) {
|
|
38
|
+
switch (state) {
|
|
39
|
+
case "done":
|
|
40
|
+
return styles.markerDone;
|
|
41
|
+
case "current":
|
|
42
|
+
return styles.markerCurrent;
|
|
43
|
+
case "todo":
|
|
44
|
+
return null;
|
|
45
|
+
default:
|
|
46
|
+
return assertNever(state);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** One-way sites: "접수됨 · 현재 상태" with the status steps only; no answers, no follow-ups. */
|
|
50
|
+
function OneWayStatus({ steps }) {
|
|
51
|
+
const styles = (0, post_styles_1.usePostStyles)();
|
|
52
|
+
const { texts } = (0, context_1.useFeedbackUi)();
|
|
53
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { children: [(0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.timeline, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.blockLabel, accessibilityRole: "header", children: texts.receivedStatus }), steps.map((step) => ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.step, accessible: true, accessibilityLabel: `${step.label}, ${step.detail}`, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: [styles.marker, markerStyle(step.state, styles)] }), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.stepText, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.stepLabel, step.state === "todo" && styles.stepTodo], children: step.label }), step.detail === "" ? null : (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.meta, children: step.detail })] })] }, step.key)))] }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.note, children: texts.oneWayNote })] }));
|
|
54
|
+
}
|
|
55
|
+
function assertNever(value) {
|
|
56
|
+
throw new TypeError(`Unexpected thread variant: ${JSON.stringify(value)}`);
|
|
57
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { RandomBytes } from "../core/author-token";
|
|
3
|
+
import type { ClientMetadata, FeedbackErrorCode } from "../core/request";
|
|
4
|
+
import type { LocaleMode } from "../core/texts";
|
|
5
|
+
import type { PickImages, SubmissionKind } from "./context";
|
|
6
|
+
import type { FeedbackStorage } from "./storage";
|
|
7
|
+
export type TheSeekerFeedbackProviderProps = Readonly<{
|
|
8
|
+
widgetKey: string;
|
|
9
|
+
appId: string;
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
userId?: string | number | null;
|
|
12
|
+
locale?: LocaleMode;
|
|
13
|
+
screen?: string;
|
|
14
|
+
launcher?: boolean;
|
|
15
|
+
pickImages?: PickImages;
|
|
16
|
+
storage?: FeedbackStorage;
|
|
17
|
+
client?: ClientMetadata;
|
|
18
|
+
/** Secure RNG for the author token when `globalThis.crypto.getRandomValues` is missing. */
|
|
19
|
+
randomBytes?: RandomBytes;
|
|
20
|
+
onSubmitted?: (id: string, kind: SubmissionKind) => void;
|
|
21
|
+
onError?: (code: FeedbackErrorCode) => void;
|
|
22
|
+
children?: ReactNode;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function TheSeekerFeedbackProvider(props: TheSeekerFeedbackProviderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TheSeekerFeedbackProvider = TheSeekerFeedbackProvider;
|
|
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 client_1 = require("../core/client");
|
|
8
|
+
const request_1 = require("../core/request");
|
|
9
|
+
const texts_1 = require("../core/texts");
|
|
10
|
+
const context_1 = require("./context");
|
|
11
|
+
const device_1 = require("./device");
|
|
12
|
+
const FeedbackSheet_1 = require("./FeedbackSheet");
|
|
13
|
+
const forms_1 = require("./forms");
|
|
14
|
+
const Launcher_1 = require("./Launcher");
|
|
15
|
+
const MyFeedbackModal_1 = require("./MyFeedbackModal");
|
|
16
|
+
const prop_state_1 = require("./prop-state");
|
|
17
|
+
const storage_1 = require("./storage");
|
|
18
|
+
const styles_1 = require("./styles");
|
|
19
|
+
const surfaces_1 = require("./surfaces");
|
|
20
|
+
const SurveyPrompt_1 = require("./SurveyPrompt");
|
|
21
|
+
const useMyPosts_1 = require("./useMyPosts");
|
|
22
|
+
const useSurvey_1 = require("./useSurvey");
|
|
23
|
+
const DEFAULT_STORAGE = (0, storage_1.createMemoryStorage)();
|
|
24
|
+
const DEFAULT_CLIENT = (0, device_1.clientFromPlatform)({
|
|
25
|
+
os: react_native_1.Platform.OS,
|
|
26
|
+
version: react_native_1.Platform.Version,
|
|
27
|
+
...(react_native_1.Platform.OS === "android" ? { release: react_native_1.Platform.constants.Release } : {}),
|
|
28
|
+
...(react_native_1.Platform.OS === "ios" ? { isPad: react_native_1.Platform.isPad } : {}),
|
|
29
|
+
});
|
|
30
|
+
function TheSeekerFeedbackProvider(props) {
|
|
31
|
+
const { widgetKey, appId, baseUrl = client_1.DEFAULT_BASE_URL, launcher = true, children } = props;
|
|
32
|
+
const [screen, setScreen] = (0, prop_state_1.usePropOverride)(props.screen ?? "/");
|
|
33
|
+
const [uid, setUser] = (0, prop_state_1.usePropOverride)(props.userId ?? null);
|
|
34
|
+
const [localeMode, setLocale] = (0, prop_state_1.usePropOverride)(props.locale ?? "ko");
|
|
35
|
+
const [contact, setContact] = (0, react_1.useState)(null);
|
|
36
|
+
const [draft] = (0, react_1.useState)(forms_1.createDraftStore);
|
|
37
|
+
const latest = (0, prop_state_1.useLatestRef)(props);
|
|
38
|
+
const storage = (0, prop_state_1.useLatestRef)(props.storage ?? DEFAULT_STORAGE);
|
|
39
|
+
const appStorage = (0, prop_state_1.useLatestRef)(props.storage);
|
|
40
|
+
const randomBytes = (0, prop_state_1.useLatestRef)(props.randomBytes);
|
|
41
|
+
const persistent = props.storage !== undefined;
|
|
42
|
+
const mine = (0, useMyPosts_1.useMyPosts)({ baseUrl, widgetKey, appId, persistent, storage: appStorage, randomBytes });
|
|
43
|
+
const surfaces = (0, surfaces_1.useSurfaces)();
|
|
44
|
+
const api = (0, react_1.useMemo)(() => (0, client_1.createFeedbackClient)({ baseUrl, widgetKey, appId }), [baseUrl, widgetKey, appId]);
|
|
45
|
+
const [loaded, setLoaded] = (0, react_1.useState)(null);
|
|
46
|
+
const config = loaded !== null && loaded.api === api ? loaded.config : null;
|
|
47
|
+
(0, react_1.useEffect)(() => {
|
|
48
|
+
let live = true;
|
|
49
|
+
async function load() {
|
|
50
|
+
const result = await api.fetchConfig();
|
|
51
|
+
if (!live)
|
|
52
|
+
return;
|
|
53
|
+
if (result.ok)
|
|
54
|
+
return setLoaded({ api, config: result.config });
|
|
55
|
+
(0, prop_state_1.devWarn)(`widget config unavailable (${result.code}); feedback UI stays hidden.`);
|
|
56
|
+
latest.current.onError?.(result.code);
|
|
57
|
+
}
|
|
58
|
+
void load();
|
|
59
|
+
return () => {
|
|
60
|
+
live = false;
|
|
61
|
+
};
|
|
62
|
+
}, [api, latest]);
|
|
63
|
+
const report = (0, react_1.useCallback)((result, kind) => {
|
|
64
|
+
if (result.ok)
|
|
65
|
+
latest.current.onSubmitted?.(result.id, kind);
|
|
66
|
+
else
|
|
67
|
+
latest.current.onError?.(result.code);
|
|
68
|
+
return result;
|
|
69
|
+
}, [latest]);
|
|
70
|
+
const clientMeta = props.client ?? DEFAULT_CLIENT;
|
|
71
|
+
const base = (0, react_1.useMemo)(() => ({ key: widgetKey, appId, screen, uid, ...(clientMeta === undefined ? {} : { client: clientMeta }) }), [widgetKey, appId, screen, uid, clientMeta]);
|
|
72
|
+
const submit = (0, react_1.useCallback)(async ({ message, contact: given, images = [] }) => {
|
|
73
|
+
if (config === null)
|
|
74
|
+
return report({ ok: false, code: "WIDGET_NOT_FOUND" }, "feedback");
|
|
75
|
+
if (!message.trim())
|
|
76
|
+
return report({ ok: false, code: "VALIDATION_ERROR" }, "feedback");
|
|
77
|
+
if (images.length > 0 && !config.images)
|
|
78
|
+
return report({ ok: false, code: "IMAGES_DISABLED" }, "feedback");
|
|
79
|
+
const payload = (0, request_1.buildFeedbackPayload)({
|
|
80
|
+
...base,
|
|
81
|
+
message,
|
|
82
|
+
contact: given ?? contact,
|
|
83
|
+
contactMode: config.contactMode,
|
|
84
|
+
});
|
|
85
|
+
const owned = mine.source;
|
|
86
|
+
const result = owned === null ? await api.submit(payload, images) : await (0, useMyPosts_1.submitAsPost)(owned.client, payload, screen, images);
|
|
87
|
+
return report(result, "feedback");
|
|
88
|
+
}, [api, base, config, contact, report, mine.source, screen]);
|
|
89
|
+
const slot = (0, useSurvey_1.useSurvey)(config?.survey ?? null, screen, storage);
|
|
90
|
+
const { survey, dismiss } = slot;
|
|
91
|
+
const sendSurvey = (0, react_1.useCallback)(async (score, message) => {
|
|
92
|
+
if (survey === null)
|
|
93
|
+
return { ok: false, code: "VALIDATION_ERROR" };
|
|
94
|
+
const payload = (0, request_1.buildSurveyPayload)({ ...base, message, kind: survey.type, score, surveyId: survey.id });
|
|
95
|
+
return report(await api.submit(payload), survey.type);
|
|
96
|
+
}, [api, base, report, survey]);
|
|
97
|
+
const ready = config !== null;
|
|
98
|
+
const { show, hide: close, shown, session, dismissed } = surfaces;
|
|
99
|
+
const { source, unreadCount, refreshUnread } = mine;
|
|
100
|
+
const myFeedbackReady = ready && source !== null;
|
|
101
|
+
const open = (0, react_1.useCallback)(() => {
|
|
102
|
+
if (ready)
|
|
103
|
+
show("send");
|
|
104
|
+
}, [ready, show]);
|
|
105
|
+
const openMyFeedback = (0, react_1.useCallback)(() => {
|
|
106
|
+
if (myFeedbackReady)
|
|
107
|
+
show("mine");
|
|
108
|
+
}, [myFeedbackReady, show]);
|
|
109
|
+
const value = (0, react_1.useMemo)(() => ({
|
|
110
|
+
ready,
|
|
111
|
+
config,
|
|
112
|
+
open,
|
|
113
|
+
close,
|
|
114
|
+
setScreen,
|
|
115
|
+
setUser,
|
|
116
|
+
setContact,
|
|
117
|
+
setLocale,
|
|
118
|
+
submit,
|
|
119
|
+
presentFeedback: open,
|
|
120
|
+
myFeedbackReady,
|
|
121
|
+
openMyFeedback,
|
|
122
|
+
presentMyFeedback: openMyFeedback,
|
|
123
|
+
unreadCount,
|
|
124
|
+
refreshUnread,
|
|
125
|
+
}), [
|
|
126
|
+
ready,
|
|
127
|
+
config,
|
|
128
|
+
open,
|
|
129
|
+
close,
|
|
130
|
+
setScreen,
|
|
131
|
+
setUser,
|
|
132
|
+
setLocale,
|
|
133
|
+
submit,
|
|
134
|
+
myFeedbackReady,
|
|
135
|
+
openMyFeedback,
|
|
136
|
+
unreadCount,
|
|
137
|
+
refreshUnread,
|
|
138
|
+
]);
|
|
139
|
+
const mineUi = (0, react_1.useMemo)(() => source === null
|
|
140
|
+
? null
|
|
141
|
+
: { ...source, isOpen: shown === "mine", session, open: openMyFeedback, close, unreadCount, refreshUnread }, [source, shown, session, openMyFeedback, close, unreadCount, refreshUnread]);
|
|
142
|
+
const locale = (0, texts_1.resolveLocale)(localeMode, localeMode === "auto" ? (0, device_1.deviceLocale)() : null);
|
|
143
|
+
const theme = (0, styles_1.useFeedbackTheme)(config);
|
|
144
|
+
const { pickImages } = props;
|
|
145
|
+
const ui = (0, react_1.useMemo)(() => {
|
|
146
|
+
if (config === null || theme === null)
|
|
147
|
+
return null;
|
|
148
|
+
return {
|
|
149
|
+
...theme,
|
|
150
|
+
config,
|
|
151
|
+
locale,
|
|
152
|
+
mine: mineUi,
|
|
153
|
+
modalDismissed: dismissed,
|
|
154
|
+
texts: (0, texts_1.resolveTexts)(config, locale),
|
|
155
|
+
isOpen: shown === "send",
|
|
156
|
+
launcherShown: launcher && config.mode === "launcher",
|
|
157
|
+
contact,
|
|
158
|
+
draft,
|
|
159
|
+
pickImages: config.images ? pickImages : undefined,
|
|
160
|
+
open,
|
|
161
|
+
close,
|
|
162
|
+
submit,
|
|
163
|
+
survey,
|
|
164
|
+
dismissSurvey: dismiss,
|
|
165
|
+
sendSurvey,
|
|
166
|
+
};
|
|
167
|
+
}, [
|
|
168
|
+
config,
|
|
169
|
+
theme,
|
|
170
|
+
locale,
|
|
171
|
+
mineUi,
|
|
172
|
+
dismissed,
|
|
173
|
+
shown,
|
|
174
|
+
launcher,
|
|
175
|
+
contact,
|
|
176
|
+
draft,
|
|
177
|
+
open,
|
|
178
|
+
close,
|
|
179
|
+
submit,
|
|
180
|
+
survey,
|
|
181
|
+
dismiss,
|
|
182
|
+
sendSurvey,
|
|
183
|
+
pickImages,
|
|
184
|
+
]);
|
|
185
|
+
return ((0, jsx_runtime_1.jsx)(context_1.FeedbackApiContext.Provider, { value: value, children: (0, jsx_runtime_1.jsxs)(context_1.FeedbackUiContext.Provider, { value: ui, children: [children, ui?.launcherShown === true ? (0, jsx_runtime_1.jsx)(Launcher_1.Launcher, {}) : null, ui === null ? null : (0, jsx_runtime_1.jsx)(FeedbackSheet_1.FeedbackSheet, {}), ui === null || ui.mine === null ? null : (0, jsx_runtime_1.jsx)(MyFeedbackModal_1.MyFeedbackModal, { mine: ui.mine, onWrite: open }), ui === null || ui.survey === null ? null : (0, jsx_runtime_1.jsx)(SurveyPrompt_1.SurveyPrompt, {}, ui.survey.id)] }) }));
|
|
186
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SurveyPrompt = SurveyPrompt;
|
|
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 context_1 = require("./context");
|
|
9
|
+
const forms_1 = require("./forms");
|
|
10
|
+
const primitives_1 = require("./primitives");
|
|
11
|
+
/** NPS/CSAT card docked above the launcher; Close and a successful send both count as "shown". */
|
|
12
|
+
function SurveyPrompt() {
|
|
13
|
+
const { survey, config, texts, styles, launcherShown, dismissSurvey, sendSurvey } = (0, context_1.useFeedbackUi)();
|
|
14
|
+
const [score, setScore] = (0, react_1.useState)(null);
|
|
15
|
+
const [followUp, setFollowUp] = (0, react_1.useState)("");
|
|
16
|
+
const [busy, setBusy] = (0, react_1.useState)(false);
|
|
17
|
+
const [outcome, setOutcome] = (0, react_1.useState)(null);
|
|
18
|
+
const done = outcome?.tone === "info";
|
|
19
|
+
(0, react_1.useEffect)(() => {
|
|
20
|
+
if (!done)
|
|
21
|
+
return;
|
|
22
|
+
const timer = setTimeout(dismissSurvey, forms_1.AUTO_CLOSE_MS);
|
|
23
|
+
return () => clearTimeout(timer);
|
|
24
|
+
}, [done, dismissSurvey]);
|
|
25
|
+
if (survey === null)
|
|
26
|
+
return null;
|
|
27
|
+
const nps = survey.type === "nps";
|
|
28
|
+
async function send() {
|
|
29
|
+
if (score === null || busy)
|
|
30
|
+
return;
|
|
31
|
+
setBusy(true);
|
|
32
|
+
const result = await sendSurvey(score, followUp);
|
|
33
|
+
setBusy(false);
|
|
34
|
+
const next = result.ok
|
|
35
|
+
? { text: texts.surveyThanks, tone: "info" }
|
|
36
|
+
: { text: texts[(0, request_1.errorMessageKey)(result.code)], tone: "error" };
|
|
37
|
+
setOutcome(next);
|
|
38
|
+
(0, primitives_1.announce)(next.text);
|
|
39
|
+
}
|
|
40
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.KeyboardAvoidingView, { behavior: "padding", style: [
|
|
41
|
+
styles.surveyDock,
|
|
42
|
+
launcherShown ? styles.dockRaised : styles.dockLow,
|
|
43
|
+
config.position === "bottom-left" ? styles.dockStart : styles.dockEnd,
|
|
44
|
+
], children: (0, jsx_runtime_1.jsxs)(react_native_1.View, { testID: "theseeker-survey", style: styles.surveyCard, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.question, accessibilityRole: "header", children: survey.question }), (0, jsx_runtime_1.jsx)(react_native_1.View, { style: styles.scale, accessibilityRole: "radiogroup", accessibilityLabel: nps ? texts.npsScale : texts.csatScale, children: (0, forms_1.surveyScores)(survey.type).map((value) => {
|
|
45
|
+
const selected = value === score;
|
|
46
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { testID: `theseeker-survey-score-${value}`, accessibilityRole: "radio", accessibilityLabel: texts.score.replace("{n}", String(value)), accessibilityState: { checked: selected, disabled: done }, disabled: done, onPress: () => setScore(value), style: ({ pressed }) => [
|
|
47
|
+
styles.score,
|
|
48
|
+
pressed && styles.scorePressed,
|
|
49
|
+
selected && styles.scoreSelected,
|
|
50
|
+
], children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.scoreLabel, selected && styles.scoreLabelSelected], children: value }) }, value));
|
|
51
|
+
}) }), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: [styles.anchors, styles.anchorGap], children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.meta, children: nps ? texts.npsLow : texts.csatLow }), (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.meta, children: nps ? texts.npsHigh : texts.csatHigh })] }), survey.followUp === null ? null : ((0, jsx_runtime_1.jsx)(primitives_1.TextField, { label: survey.followUp, value: followUp, onChangeText: setFollowUp, short: true, input: { testID: "theseeker-survey-follow-up", multiline: true, maxLength: forms_1.MAX_MESSAGE, editable: !done } })), (0, jsx_runtime_1.jsx)(primitives_1.Status, { text: outcome?.text ?? null, tone: outcome?.tone ?? "info" }), (0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.actions, children: [(0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "ghost", label: texts.close, onPress: dismissSurvey, testID: "theseeker-survey-close" }), (0, jsx_runtime_1.jsx)(primitives_1.Button, { variant: "primary", label: busy ? texts.sending : texts.send, onPress: () => void send(), disabled: score === null || busy || done, busy: busy, testID: "theseeker-survey-send" })] })] }) }));
|
|
52
|
+
}
|