@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.
- package/README.md +215 -2
- package/dist/core/client.d.ts +57 -0
- package/dist/core/client.js +113 -0
- package/dist/core/config.d.ts +59 -0
- package/dist/core/config.js +112 -0
- package/dist/core/request.d.ts +53 -0
- package/dist/core/request.js +86 -0
- package/dist/core/survey.d.ts +12 -0
- package/dist/core/survey.js +26 -0
- package/dist/core/texts.d.ts +104 -0
- package/dist/core/texts.js +140 -0
- package/dist/core/theme.d.ts +6 -0
- package/dist/core/theme.js +55 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +32 -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 +90 -0
- package/dist/ui/FeedbackSheet.d.ts +2 -0
- package/dist/ui/FeedbackSheet.js +32 -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 +14 -0
- package/dist/ui/Provider.d.ts +21 -0
- package/dist/ui/Provider.js +131 -0
- package/dist/ui/SurveyPrompt.d.ts +2 -0
- package/dist/ui/SurveyPrompt.js +52 -0
- package/dist/ui/context.d.ts +79 -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/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 +697 -0
- package/dist/ui/styles.js +177 -0
- package/dist/ui/tokens.d.ts +16 -0
- package/dist/ui/tokens.js +62 -0
- package/dist/ui/useSurvey.d.ts +12 -0
- package/dist/ui/useSurvey.js +52 -0
- package/package.json +34 -4
|
@@ -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
|
+
}
|