fdbck-react 0.2.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/LICENSE +21 -0
- package/README.md +145 -0
- package/dist/index.css +418 -0
- package/dist/index.d.mts +115 -0
- package/dist/index.d.ts +115 -0
- package/dist/index.js +716 -0
- package/dist/index.mjs +688 -0
- package/package.json +52 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/** Error codes produced by the React SDK */
|
|
5
|
+
type FdbckErrorCode = 'invalid_token' | 'already_responded' | 'question_expired' | 'network_error' | 'dismissed' | 'unknown';
|
|
6
|
+
/** Typed error for fdbck React SDK */
|
|
7
|
+
declare class FdbckError extends Error {
|
|
8
|
+
readonly code: FdbckErrorCode;
|
|
9
|
+
constructor(code: FdbckErrorCode, message: string);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Question type */
|
|
13
|
+
type QuestionType = 'yes_no' | 'single_choice' | 'multiple_choice' | 'rating';
|
|
14
|
+
/** Rating scale options as returned by the API */
|
|
15
|
+
interface RatingOptions {
|
|
16
|
+
min: number;
|
|
17
|
+
max: number;
|
|
18
|
+
min_label?: string;
|
|
19
|
+
max_label?: string;
|
|
20
|
+
}
|
|
21
|
+
/** Question data from GET /v1/f/:token */
|
|
22
|
+
interface QuestionData {
|
|
23
|
+
id: string;
|
|
24
|
+
question: string;
|
|
25
|
+
type: QuestionType;
|
|
26
|
+
options: string[] | RatingOptions;
|
|
27
|
+
theme_color: string | null;
|
|
28
|
+
theme_mode: 'light' | 'dark';
|
|
29
|
+
hide_branding: boolean;
|
|
30
|
+
welcome_message: string | null;
|
|
31
|
+
thank_you_message: string | null;
|
|
32
|
+
}
|
|
33
|
+
/** Response value submitted by the respondent */
|
|
34
|
+
type ResponseValue = string | string[] | number;
|
|
35
|
+
/** Display mode for the widget */
|
|
36
|
+
type FdbckMode = 'inline' | 'modal' | 'popover';
|
|
37
|
+
/** Result returned when a response is submitted or dismissed */
|
|
38
|
+
interface FdbckResult {
|
|
39
|
+
status: 'submitted' | 'dismissed';
|
|
40
|
+
value?: ResponseValue;
|
|
41
|
+
}
|
|
42
|
+
/** Custom locale strings */
|
|
43
|
+
interface FdbckLocale {
|
|
44
|
+
submit?: string;
|
|
45
|
+
poweredBy?: string;
|
|
46
|
+
loading?: string;
|
|
47
|
+
errorTitle?: string;
|
|
48
|
+
errorMessage?: string;
|
|
49
|
+
retry?: string;
|
|
50
|
+
close?: string;
|
|
51
|
+
}
|
|
52
|
+
/** Style overrides for the widget */
|
|
53
|
+
interface FdbckStyle {
|
|
54
|
+
width?: string;
|
|
55
|
+
maxWidth?: string;
|
|
56
|
+
borderRadius?: string;
|
|
57
|
+
fontFamily?: string;
|
|
58
|
+
fontSize?: string;
|
|
59
|
+
}
|
|
60
|
+
/** Props for the low-level FdbckWidget component (takes a pre-resolved token) */
|
|
61
|
+
interface FdbckWidgetProps {
|
|
62
|
+
token: string;
|
|
63
|
+
mode?: FdbckMode;
|
|
64
|
+
open?: boolean;
|
|
65
|
+
baseUrl?: string;
|
|
66
|
+
delay?: number;
|
|
67
|
+
autoCloseAfter?: number;
|
|
68
|
+
closeOnOverlayClick?: boolean;
|
|
69
|
+
closeOnEscape?: boolean;
|
|
70
|
+
locale?: FdbckLocale;
|
|
71
|
+
style?: FdbckStyle;
|
|
72
|
+
onSubmit?: (value: ResponseValue) => void;
|
|
73
|
+
onDismiss?: () => void;
|
|
74
|
+
onError?: (error: FdbckError) => void;
|
|
75
|
+
onLoad?: (question: QuestionData) => void;
|
|
76
|
+
children?: ReactNode;
|
|
77
|
+
}
|
|
78
|
+
/** Props for the FdbckProvider context */
|
|
79
|
+
interface FdbckProviderProps {
|
|
80
|
+
baseUrl?: string;
|
|
81
|
+
locale?: FdbckLocale;
|
|
82
|
+
style?: FdbckStyle;
|
|
83
|
+
children: ReactNode;
|
|
84
|
+
}
|
|
85
|
+
/** Return type from useFdbck hook */
|
|
86
|
+
interface UseFdbckReturn {
|
|
87
|
+
show: (options: UseFdbckOptions) => Promise<FdbckResult>;
|
|
88
|
+
dismiss: () => void;
|
|
89
|
+
isActive: boolean;
|
|
90
|
+
}
|
|
91
|
+
/** Options passed to useFdbck().show() */
|
|
92
|
+
type UseFdbckOptions = {
|
|
93
|
+
token: string;
|
|
94
|
+
} & Omit<FdbckWidgetProps, 'token' | 'onSubmit' | 'onDismiss'>;
|
|
95
|
+
/** Token page response from GET /v1/f/:token */
|
|
96
|
+
interface TokenPageResponse {
|
|
97
|
+
status: 'valid' | 'invalid' | 'already_responded' | 'token_expired' | 'question_ended';
|
|
98
|
+
question?: QuestionData;
|
|
99
|
+
token?: string;
|
|
100
|
+
expires_at?: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Low-level public component. Takes a pre-resolved token and renders the
|
|
105
|
+
* feedback widget in inline, modal, or popover mode.
|
|
106
|
+
*/
|
|
107
|
+
declare function FdbckWidget({ token, mode, open, baseUrl, delay, autoCloseAfter, closeOnOverlayClick, closeOnEscape, locale: localeProp, style: styleProp, onSubmit, onDismiss, onError, onLoad, }: FdbckWidgetProps): react_jsx_runtime.JSX.Element | null;
|
|
108
|
+
|
|
109
|
+
/** Context provider for the imperative useFdbck() hook */
|
|
110
|
+
declare function FdbckProvider({ baseUrl, locale, style, children }: FdbckProviderProps): react_jsx_runtime.JSX.Element;
|
|
111
|
+
|
|
112
|
+
/** Imperative API for showing/dismissing feedback widgets. Must be used within FdbckProvider. */
|
|
113
|
+
declare function useFdbck(): UseFdbckReturn;
|
|
114
|
+
|
|
115
|
+
export { FdbckError, type FdbckErrorCode, type FdbckLocale, type FdbckMode, FdbckProvider, type FdbckProviderProps, type FdbckResult, type FdbckStyle, FdbckWidget, type FdbckWidgetProps, type QuestionData, type QuestionType, type RatingOptions, type ResponseValue, type TokenPageResponse, type UseFdbckOptions, type UseFdbckReturn, useFdbck };
|