@sunboard/react 0.1.3 → 0.3.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/dist/index.d.mts +70 -31
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +359 -224
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +773 -560
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
2
|
import { RuntimeBootstrapRequest, RuntimeBootstrapResponse, RuntimeExperience, RuntimeProgress, RuntimeTrackRequest, RuntimeTrackResponse, SunboardRuntimeApiError, SunboardRuntimeClient, SunboardRuntimeClientOptions } from "@sunboard/core/runtime-api";
|
|
3
|
-
import * as
|
|
4
|
-
import { NormalizedSunboardSpec, SunboardHotspot, SunboardStep, SunboardTourStep, TrackEventName } from "@sunboard/core";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
import { NormalizedSunboardSpec, SunboardHotspot, SunboardStep, SunboardTourStep, SurveyQuestionType, TrackEventName } from "@sunboard/core";
|
|
5
5
|
|
|
6
6
|
//#region src/adapters/navigation.d.ts
|
|
7
7
|
type NavigateCallback = (url: string) => void | Promise<void>;
|
|
@@ -20,20 +20,18 @@ type TrackResult = {
|
|
|
20
20
|
ok: false;
|
|
21
21
|
reason: "not-ready" | "missing-user" | "network-error";
|
|
22
22
|
};
|
|
23
|
+
type SurveyResult = {
|
|
24
|
+
ok: true;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
reason: "not-ready" | "missing-user" | "not-survey" | "network-error";
|
|
28
|
+
};
|
|
23
29
|
type TourResult = {
|
|
24
30
|
ok: true;
|
|
25
31
|
} | {
|
|
26
32
|
ok: false;
|
|
27
33
|
reason: "not-ready" | "missing-user" | "missing-tour";
|
|
28
34
|
};
|
|
29
|
-
type SunboardRuntimeMode = "production" | "preview";
|
|
30
|
-
type SunboardTourError = {
|
|
31
|
-
message: string;
|
|
32
|
-
route?: string;
|
|
33
|
-
stepKey?: string;
|
|
34
|
-
target?: string;
|
|
35
|
-
tourKey: string;
|
|
36
|
-
};
|
|
37
35
|
type ActiveSunboardTour = {
|
|
38
36
|
key: string;
|
|
39
37
|
name: string;
|
|
@@ -46,14 +44,18 @@ type SunboardContextValue = {
|
|
|
46
44
|
user?: SunboardUser | null;
|
|
47
45
|
loading: boolean;
|
|
48
46
|
route?: string;
|
|
49
|
-
mode: SunboardRuntimeMode;
|
|
50
47
|
completedStepKeys: ReadonlySet<string>;
|
|
51
48
|
completedTourKeys: ReadonlySet<string>;
|
|
52
49
|
completedCount: number;
|
|
53
50
|
totalSteps: number;
|
|
54
51
|
activeTour: ActiveSunboardTour | null;
|
|
55
|
-
tourError: SunboardTourError | null;
|
|
56
52
|
track: (eventName: TrackEventName, properties?: TrackProperties) => Promise<TrackResult>;
|
|
53
|
+
/**
|
|
54
|
+
* Submit survey answers for the active survey experience. On success the
|
|
55
|
+
* runtime re-bootstraps so the freshly collected attributes route the user
|
|
56
|
+
* into the next experience in-session.
|
|
57
|
+
*/
|
|
58
|
+
submitSurvey: (answers: Record<string, unknown>) => Promise<SurveyResult>;
|
|
57
59
|
startTour: (tourKey: string) => Promise<TourResult>;
|
|
58
60
|
/**
|
|
59
61
|
* Close the active tour. User-initiated dismissals are reported to the
|
|
@@ -67,7 +69,6 @@ type SunboardContextValue = {
|
|
|
67
69
|
advanceTour: () => Promise<TourResult>;
|
|
68
70
|
navigateToStep: (step: SunboardStep) => Promise<void>;
|
|
69
71
|
startChecklistStep: (step: SunboardStep) => Promise<TourResult | void>;
|
|
70
|
-
reportTourError: (error: SunboardTourError | null) => void;
|
|
71
72
|
visibleHotspots: Array<{
|
|
72
73
|
key: string;
|
|
73
74
|
hotspot: SunboardHotspot;
|
|
@@ -79,7 +80,6 @@ type SunboardProviderProps = {
|
|
|
79
80
|
spec?: NormalizedSunboardSpec | null;
|
|
80
81
|
user?: SunboardUser | null;
|
|
81
82
|
loading?: boolean;
|
|
82
|
-
mode?: SunboardRuntimeMode;
|
|
83
83
|
route?: string;
|
|
84
84
|
navigate?: NavigateCallback;
|
|
85
85
|
/**
|
|
@@ -89,7 +89,6 @@ type SunboardProviderProps = {
|
|
|
89
89
|
*/
|
|
90
90
|
apiUrl?: string;
|
|
91
91
|
publishableKey?: string;
|
|
92
|
-
environment?: string;
|
|
93
92
|
onTrack?: (eventName: TrackEventName, properties?: TrackProperties) => void | Promise<void>;
|
|
94
93
|
children: ReactNode;
|
|
95
94
|
};
|
|
@@ -97,39 +96,30 @@ declare function SunboardProvider({
|
|
|
97
96
|
spec: specProp,
|
|
98
97
|
user,
|
|
99
98
|
loading: loadingProp,
|
|
100
|
-
mode: modeProp,
|
|
101
99
|
route,
|
|
102
100
|
navigate,
|
|
103
101
|
apiUrl,
|
|
104
102
|
publishableKey,
|
|
105
|
-
environment,
|
|
106
103
|
onTrack,
|
|
107
104
|
children
|
|
108
|
-
}: SunboardProviderProps):
|
|
105
|
+
}: SunboardProviderProps): react_jsx_runtime0.JSX.Element;
|
|
109
106
|
//#endregion
|
|
110
107
|
//#region src/components/SunboardHotspots.d.ts
|
|
111
|
-
declare function SunboardHotspots():
|
|
108
|
+
declare function SunboardHotspots(): react_jsx_runtime0.JSX.Element;
|
|
112
109
|
//#endregion
|
|
113
110
|
//#region src/components/SunboardTour.d.ts
|
|
114
|
-
declare function SunboardTour():
|
|
111
|
+
declare function SunboardTour(): react_jsx_runtime0.JSX.Element | null;
|
|
115
112
|
//#endregion
|
|
116
113
|
//#region src/components/Sunboard.d.ts
|
|
117
|
-
declare function SunboardChecklist():
|
|
114
|
+
declare function SunboardChecklist(): react_jsx_runtime0.JSX.Element | null;
|
|
115
|
+
declare function SunboardSurvey(): react_jsx_runtime0.JSX.Element | null;
|
|
118
116
|
declare const Sunboard: typeof SunboardChecklist & {
|
|
119
117
|
Checklist: typeof SunboardChecklist;
|
|
118
|
+
Survey: typeof SunboardSurvey;
|
|
120
119
|
Hotspots: typeof SunboardHotspots;
|
|
121
120
|
Tour: typeof SunboardTour;
|
|
122
121
|
};
|
|
123
122
|
//#endregion
|
|
124
|
-
//#region src/hooks/useSunboardPreviewSpec.d.ts
|
|
125
|
-
type SunboardPreviewSpecState = {
|
|
126
|
-
error: Error | null;
|
|
127
|
-
loading: boolean;
|
|
128
|
-
source: "none" | "preview";
|
|
129
|
-
spec: NormalizedSunboardSpec | null;
|
|
130
|
-
};
|
|
131
|
-
declare function useSunboardPreviewSpec(): SunboardPreviewSpecState;
|
|
132
|
-
//#endregion
|
|
133
123
|
//#region src/hooks/useSunboard.d.ts
|
|
134
124
|
declare function useSunboard(): SunboardContextValue;
|
|
135
125
|
//#endregion
|
|
@@ -165,5 +155,54 @@ type UseChecklistResult = {
|
|
|
165
155
|
};
|
|
166
156
|
declare function useChecklist(): UseChecklistResult;
|
|
167
157
|
//#endregion
|
|
168
|
-
|
|
158
|
+
//#region src/hooks/useSurvey.d.ts
|
|
159
|
+
type SurveyViewOption = {
|
|
160
|
+
value: string;
|
|
161
|
+
label: string;
|
|
162
|
+
};
|
|
163
|
+
type SurveyViewQuestion = {
|
|
164
|
+
key: string;
|
|
165
|
+
prompt: string;
|
|
166
|
+
type: SurveyQuestionType;
|
|
167
|
+
required: boolean;
|
|
168
|
+
options: SurveyViewOption[];
|
|
169
|
+
};
|
|
170
|
+
type SurveyViewStep = {
|
|
171
|
+
title?: string;
|
|
172
|
+
subtitle?: string;
|
|
173
|
+
questions: SurveyViewQuestion[];
|
|
174
|
+
};
|
|
175
|
+
type UseSurveyResult = {
|
|
176
|
+
visible: boolean;
|
|
177
|
+
title?: string;
|
|
178
|
+
subtitle?: string;
|
|
179
|
+
/** Every question across all steps — for all-at-once renderers (the built-in modal). */
|
|
180
|
+
questions: SurveyViewQuestion[];
|
|
181
|
+
/** The authored step grouping (one question per step by default). */
|
|
182
|
+
steps: SurveyViewStep[];
|
|
183
|
+
/** Hook-owned navigation. */
|
|
184
|
+
stepIndex: number;
|
|
185
|
+
totalSteps: number;
|
|
186
|
+
currentStep?: SurveyViewStep;
|
|
187
|
+
progress: number;
|
|
188
|
+
isFirstStep: boolean;
|
|
189
|
+
isLastStep: boolean;
|
|
190
|
+
/** True when the current step's required questions are answered. */
|
|
191
|
+
canAdvance: boolean;
|
|
192
|
+
/** Advance to the next step, or submit on the last step. */
|
|
193
|
+
next: () => void;
|
|
194
|
+
back: () => void;
|
|
195
|
+
answers: Record<string, unknown>;
|
|
196
|
+
setAnswer: (key: string, value: string) => void;
|
|
197
|
+
toggleAnswer: (key: string, value: string) => void;
|
|
198
|
+
isAnswered: (key: string) => boolean;
|
|
199
|
+
/** True when every required question (across all steps) is answered. */
|
|
200
|
+
canSubmit: boolean;
|
|
201
|
+
submitting: boolean;
|
|
202
|
+
error: string | null;
|
|
203
|
+
submit: () => Promise<void>;
|
|
204
|
+
};
|
|
205
|
+
declare function useSurvey(): UseSurveyResult;
|
|
206
|
+
//#endregion
|
|
207
|
+
export { type ChecklistViewStep, type RuntimeBootstrapRequest, type RuntimeBootstrapResponse, type RuntimeExperience, type RuntimeProgress, type RuntimeTrackRequest, type RuntimeTrackResponse, Sunboard, SunboardChecklist, type SunboardContextValue, SunboardHotspots, SunboardProvider, type SunboardProviderProps, SunboardRuntimeApiError, SunboardRuntimeClient, type SunboardRuntimeClientOptions, SunboardSurvey, SunboardTour, type SunboardUser, type SurveyResult, type SurveyViewOption, type SurveyViewQuestion, type SurveyViewStep, type TourResult, type TrackProperties, type TrackResult, type UseChecklistResult, type UseSurveyResult, useChecklist, useSunboard, useSurvey };
|
|
169
208
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/adapters/navigation.ts","../src/hooks/sunboard-context.ts","../src/components/SunboardProvider.tsx","../src/components/SunboardHotspots.tsx","../src/components/SunboardTour.tsx","../src/components/Sunboard.tsx","../src/hooks/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/adapters/navigation.ts","../src/hooks/sunboard-context.ts","../src/components/SunboardProvider.tsx","../src/components/SunboardHotspots.tsx","../src/components/SunboardTour.tsx","../src/components/Sunboard.tsx","../src/hooks/useSunboard.ts","../src/hooks/useChecklist.ts","../src/hooks/useSurvey.ts"],"sourcesContent":[],"mappings":";;;;;;KAAY,gBAAA,2BAA2C;;;KCS3C,YAAA;;;;eAIG;ADbf,CAAA;KCgBY,eAAA,GAAkB;KAElB,WAAA;;AATZ,CAAA,GAAY;EAOA,EAAA,EAAA,KAAA;EAEA,MAAA,EAAA,WAAW,GAAA,cAAA,GAAA,eAAA;AAIvB,CAAA;AAOY,KAPA,YAAA,GAOU;EAIV,EAAA,EAAA,IAAA;AAQZ,CAAA,GAAY;EACH,EAAA,EAAA,KAAA;EACA,MAAA,EAAA,WAAA,GAAA,cAAA,GAAA,YAAA,GAAA,eAAA;CAGY;AACA,KAlBT,UAAA,GAkBS;EAGP,EAAA,EAAA,IAAA;CAEC,GAAA;EACE,EAAA,EAAA,KAAA;EACF,MAAA,EAAA,WAAA,GAAA,cAAA,GAAA,cAAA;CAAR;AAMmB,KA3Bd,kBAAA,GA2Bc;EAAoC,GAAA,EAAA,MAAA;EAAR,IAAA,EAAA,MAAA;EACZ,IAAA,EAzBlC,gBAyBkC;EAAR,SAAA,EAAA,MAAA;EAOyB,UAAA,EAAA,MAAA;CAAR;AACtB,KA5BjB,oBAAA,GA4BiB;EAAR,IAAA,CAAA,EA3BZ,sBA2BY,GAAA,IAAA;EACI,IAAA,CAAA,EA3BhB,YA2BgB,GAAA,IAAA;EAAiB,OAAA,EAAA,OAAA;EACb,KAAA,CAAA,EAAA,MAAA;EAAyB,iBAAA,EAzBjC,WAyBiC,CAAA,MAAA,CAAA;EAAR,iBAAA,EAxBzB,WAwByB,CAAA,MAAA,CAAA;EACG,cAAA,EAAA,MAAA;EAA9B,UAAA,E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