@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,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.announce = announce;
|
|
4
|
+
exports.Button = Button;
|
|
5
|
+
exports.XGlyph = XGlyph;
|
|
6
|
+
exports.TextField = TextField;
|
|
7
|
+
exports.Status = Status;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const react_1 = require("react");
|
|
10
|
+
const react_native_1 = require("react-native");
|
|
11
|
+
const context_1 = require("./context");
|
|
12
|
+
/** VoiceOver has no live regions; Android already reads `accessibilityLiveRegion` text. */
|
|
13
|
+
function announce(text) {
|
|
14
|
+
if (react_native_1.Platform.OS === "ios")
|
|
15
|
+
react_native_1.AccessibilityInfo.announceForAccessibility(text);
|
|
16
|
+
}
|
|
17
|
+
function Button({ label, variant, onPress, disabled = false, busy = false, testID }) {
|
|
18
|
+
const { styles } = (0, context_1.useFeedbackUi)();
|
|
19
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Pressable, { accessibilityRole: "button", accessibilityState: { disabled, busy }, disabled: disabled, onPress: onPress, ...(testID === undefined ? {} : { testID }), style: ({ pressed }) => [
|
|
20
|
+
styles.button,
|
|
21
|
+
styles[variant],
|
|
22
|
+
pressed && styles[`${variant}Pressed`],
|
|
23
|
+
disabled && styles.disabled,
|
|
24
|
+
], children: (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.buttonLabel, variant === "primary" && styles.primaryLabel], numberOfLines: 1, children: label }) }));
|
|
25
|
+
}
|
|
26
|
+
/** lucide:x (two 2/24-stroke diagonals from 6,6 to 18,18) drawn with Views: no SVG renderer in pure JS. */
|
|
27
|
+
function XGlyph({ size, color }) {
|
|
28
|
+
const thickness = Math.max(1.5, size / 12);
|
|
29
|
+
const bar = {
|
|
30
|
+
position: "absolute",
|
|
31
|
+
width: size * 0.71 + thickness,
|
|
32
|
+
height: thickness,
|
|
33
|
+
borderRadius: thickness / 2,
|
|
34
|
+
backgroundColor: color,
|
|
35
|
+
};
|
|
36
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: { width: size, height: size, alignItems: "center", justifyContent: "center" }, children: [(0, jsx_runtime_1.jsx)(react_native_1.View, { style: [bar, { transform: [{ rotate: "45deg" }] }] }), (0, jsx_runtime_1.jsx)(react_native_1.View, { style: [bar, { transform: [{ rotate: "-45deg" }] }] })] }));
|
|
37
|
+
}
|
|
38
|
+
/** Visible label + input + error/meta line; errors sit under the field that failed. */
|
|
39
|
+
function TextField({ label, value, onChangeText, error = null, meta, short = false, input }) {
|
|
40
|
+
const { styles, tokens } = (0, context_1.useFeedbackUi)();
|
|
41
|
+
const [focused, setFocused] = (0, react_1.useState)(false);
|
|
42
|
+
const multiline = input?.multiline === true;
|
|
43
|
+
return ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.field, children: [(0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.label, children: label }), (0, jsx_runtime_1.jsx)(react_native_1.TextInput, { ...input, accessibilityLabel: label, ...(error === null ? {} : { accessibilityHint: error }), value: value, onChangeText: onChangeText, onFocus: () => setFocused(true), onBlur: () => setFocused(false), placeholderTextColor: tokens.mutedText, selectionColor: tokens.accent, keyboardAppearance: tokens.scheme, style: [
|
|
44
|
+
styles.input,
|
|
45
|
+
multiline && (short ? styles.multilineShort : styles.multiline),
|
|
46
|
+
focused && styles.inputFocused,
|
|
47
|
+
error !== null && styles.inputInvalid,
|
|
48
|
+
] }), error === null && meta === undefined ? null : ((0, jsx_runtime_1.jsxs)(react_native_1.View, { style: styles.fieldFoot, children: [error === null ? null : ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: styles.error, accessibilityLiveRegion: "polite", children: error })), meta === undefined ? null : (0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.meta, styles.end], children: meta })] }))] }));
|
|
49
|
+
}
|
|
50
|
+
function Status({ text, tone }) {
|
|
51
|
+
const { styles } = (0, context_1.useFeedbackUi)();
|
|
52
|
+
if (text === null)
|
|
53
|
+
return null;
|
|
54
|
+
return ((0, jsx_runtime_1.jsx)(react_native_1.Text, { style: [styles.status, tone === "error" && styles.statusError], accessibilityLiveRegion: "polite", children: text }));
|
|
55
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A prop the app can also override imperatively (`setScreen`, `setUser`, …). The override holds
|
|
4
|
+
* until the prop itself changes, so a re-rendered prop always wins over an older setter call.
|
|
5
|
+
*/
|
|
6
|
+
export declare function usePropOverride<T>(prop: T): readonly [T, (next: T) => void];
|
|
7
|
+
/** Latest value for callbacks/effects that must not re-run when an inline prop changes identity. */
|
|
8
|
+
export declare function useLatestRef<T>(value: T): RefObject<T>;
|
|
9
|
+
export declare function devWarn(message: string): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePropOverride = usePropOverride;
|
|
4
|
+
exports.useLatestRef = useLatestRef;
|
|
5
|
+
exports.devWarn = devWarn;
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
/**
|
|
8
|
+
* A prop the app can also override imperatively (`setScreen`, `setUser`, …). The override holds
|
|
9
|
+
* until the prop itself changes, so a re-rendered prop always wins over an older setter call.
|
|
10
|
+
*/
|
|
11
|
+
function usePropOverride(prop) {
|
|
12
|
+
const [override, setOverride] = (0, react_1.useState)(null);
|
|
13
|
+
const set = (0, react_1.useCallback)((value) => setOverride({ base: prop, value }), [prop]);
|
|
14
|
+
return [override !== null && Object.is(override.base, prop) ? override.value : prop, set];
|
|
15
|
+
}
|
|
16
|
+
/** Latest value for callbacks/effects that must not re-run when an inline prop changes identity. */
|
|
17
|
+
function useLatestRef(value) {
|
|
18
|
+
const ref = (0, react_1.useRef)(value);
|
|
19
|
+
(0, react_1.useEffect)(() => {
|
|
20
|
+
ref.current = value;
|
|
21
|
+
});
|
|
22
|
+
return ref;
|
|
23
|
+
}
|
|
24
|
+
function devWarn(message) {
|
|
25
|
+
if (__DEV__)
|
|
26
|
+
console.warn(`[TheSeekerFeedback] ${message}`);
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** Survey cooldown storage: any `{getItem,setItem}` pair, sync or async (AsyncStorage, MMKV wrapper, …). */
|
|
2
|
+
export type FeedbackStorage = Readonly<{
|
|
3
|
+
getItem(key: string): string | null | Promise<string | null>;
|
|
4
|
+
setItem(key: string, value: string): void | Promise<void>;
|
|
5
|
+
}>;
|
|
6
|
+
export type StorageRead = Readonly<{
|
|
7
|
+
ok: true;
|
|
8
|
+
value: string | null;
|
|
9
|
+
}> | Readonly<{
|
|
10
|
+
ok: false;
|
|
11
|
+
error: Error;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function createMemoryStorage(): FeedbackStorage;
|
|
14
|
+
export declare function readStorage(storage: FeedbackStorage, key: string): Promise<StorageRead>;
|
|
15
|
+
export declare function writeStorage(storage: FeedbackStorage, key: string, value: string): Promise<Error | null>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createMemoryStorage = createMemoryStorage;
|
|
4
|
+
exports.readStorage = readStorage;
|
|
5
|
+
exports.writeStorage = writeStorage;
|
|
6
|
+
function createMemoryStorage() {
|
|
7
|
+
const items = new Map();
|
|
8
|
+
return {
|
|
9
|
+
getItem: (key) => items.get(key) ?? null,
|
|
10
|
+
setItem: (key, value) => {
|
|
11
|
+
items.set(key, value);
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
async function readStorage(storage, key) {
|
|
16
|
+
try {
|
|
17
|
+
return { ok: true, value: await storage.getItem(key) };
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
if (error instanceof Error)
|
|
21
|
+
return { ok: false, error };
|
|
22
|
+
throw error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
async function writeStorage(storage, key, value) {
|
|
26
|
+
try {
|
|
27
|
+
await storage.setItem(key, value);
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
if (error instanceof Error)
|
|
32
|
+
return error;
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
}
|