@sunboard/react 0.4.0 → 0.6.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 +95 -13
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +402 -21
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +85 -0
- package/package.json +4 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
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, SurveyQuestionType, TrackEventName } from "@sunboard/core";
|
|
2
|
+
import { RuntimeBootstrapRequest, RuntimeBootstrapResponse, RuntimeExperience, RuntimeProgress, RuntimeTrackRequest, RuntimeTrackResponse, SunboardRuntimeApiError, SunboardRuntimeClient, SunboardRuntimeClientOptions, TooltipDismissVia } from "@sunboard/core/runtime-api";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
import { NormalizedSunboardSpec, SunboardHotspot, SunboardPlacement, SunboardStep, SunboardTooltip, 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>;
|
|
@@ -52,6 +52,23 @@ type TourResult = {
|
|
|
52
52
|
ok: false;
|
|
53
53
|
reason: "not-ready" | "missing-user" | "missing-tour";
|
|
54
54
|
};
|
|
55
|
+
type TooltipResult = {
|
|
56
|
+
ok: true;
|
|
57
|
+
} | {
|
|
58
|
+
ok: false;
|
|
59
|
+
reason: "not-ready" | "missing-user" | "missing-tooltip";
|
|
60
|
+
};
|
|
61
|
+
type VisibleSunboardTooltip = {
|
|
62
|
+
key: string;
|
|
63
|
+
tooltip: SunboardTooltip;
|
|
64
|
+
/**
|
|
65
|
+
* True when the user asked for this tooltip (a checklist step's
|
|
66
|
+
* `openTooltip` action), false when it is showing proactively. A requested
|
|
67
|
+
* tooltip shows even if it was dismissed before — the user explicitly asked
|
|
68
|
+
* to be shown where the action happens.
|
|
69
|
+
*/
|
|
70
|
+
requested: boolean;
|
|
71
|
+
};
|
|
55
72
|
type ActiveSunboardTour = {
|
|
56
73
|
key: string;
|
|
57
74
|
name: string;
|
|
@@ -88,11 +105,32 @@ type SunboardContextValue = {
|
|
|
88
105
|
}) => Promise<TourResult>;
|
|
89
106
|
advanceTour: () => Promise<TourResult>;
|
|
90
107
|
navigateToStep: (step: SunboardStep) => Promise<void>;
|
|
91
|
-
startChecklistStep: (step: SunboardStep) => Promise<TourResult | void>;
|
|
108
|
+
startChecklistStep: (step: SunboardStep) => Promise<TourResult | TooltipResult | void>;
|
|
92
109
|
visibleHotspots: Array<{
|
|
93
110
|
key: string;
|
|
94
111
|
hotspot: SunboardHotspot;
|
|
95
112
|
}>;
|
|
113
|
+
dismissedTooltipKeys: ReadonlySet<string>;
|
|
114
|
+
/**
|
|
115
|
+
* Tooltips that qualify for the current route, requested-first. Renderers
|
|
116
|
+
* show ONE at a time: the first entry whose target resolves.
|
|
117
|
+
*/
|
|
118
|
+
visibleTooltips: VisibleSunboardTooltip[];
|
|
119
|
+
/**
|
|
120
|
+
* Open a tooltip on demand (the checklist's openTooltip action). Navigates
|
|
121
|
+
* are the caller's job; this just marks the tooltip requested so it renders
|
|
122
|
+
* once its route matches and its target is present, dismissal or not.
|
|
123
|
+
*/
|
|
124
|
+
openTooltip: (tooltipKey: string) => Promise<TooltipResult>;
|
|
125
|
+
/**
|
|
126
|
+
* Never show this tooltip again. `via: "close"` is the negative signal (the
|
|
127
|
+
* default); `via: "action"` records that the user took the tooltip's action.
|
|
128
|
+
*/
|
|
129
|
+
dismissTooltip: (tooltipKey: string, options?: {
|
|
130
|
+
via?: TooltipDismissVia;
|
|
131
|
+
}) => Promise<TooltipResult>;
|
|
132
|
+
/** Report that a tooltip actually reached the user's eyes (deduped per session). */
|
|
133
|
+
markTooltipSeen: (tooltipKey: string) => void;
|
|
96
134
|
};
|
|
97
135
|
//#endregion
|
|
98
136
|
//#region src/components/SunboardProvider.d.ts
|
|
@@ -112,9 +150,10 @@ type SunboardProviderProps = {
|
|
|
112
150
|
/**
|
|
113
151
|
* Analytics-provider ids for joining Sunboard's funnel data to your product
|
|
114
152
|
* analytics. Omit it and installed providers (PostHog) are detected
|
|
115
|
-
* automatically on each bootstrap
|
|
116
|
-
*
|
|
117
|
-
*
|
|
153
|
+
* automatically, on each bootstrap and for a few seconds after, so a
|
|
154
|
+
* provider that initializes late is still captured. Pass explicit ids to
|
|
155
|
+
* override detection; pass `false` to disable capture entirely. Captured ids
|
|
156
|
+
* are inert until the provider is connected to the project in Sunboard.
|
|
118
157
|
*/
|
|
119
158
|
identities?: IdentitiesProp;
|
|
120
159
|
onTrack?: (eventName: TrackEventName, properties?: TrackProperties) => void | Promise<void>;
|
|
@@ -131,21 +170,31 @@ declare function SunboardProvider({
|
|
|
131
170
|
identities: identitiesProp,
|
|
132
171
|
onTrack,
|
|
133
172
|
children
|
|
134
|
-
}: SunboardProviderProps):
|
|
173
|
+
}: SunboardProviderProps): react_jsx_runtime0.JSX.Element;
|
|
135
174
|
//#endregion
|
|
136
175
|
//#region src/components/SunboardHotspots.d.ts
|
|
137
|
-
declare function SunboardHotspots():
|
|
176
|
+
declare function SunboardHotspots(): react_jsx_runtime0.JSX.Element;
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/components/SunboardTooltips.d.ts
|
|
179
|
+
/**
|
|
180
|
+
* Renders at most one tooltip: the first visible candidate whose target
|
|
181
|
+
* resolves. A candidate whose selector never appears is skipped for the rest
|
|
182
|
+
* of the session (without recording a dismissal — the user rejected nothing),
|
|
183
|
+
* so one stale selector can't block the tooltips behind it.
|
|
184
|
+
*/
|
|
185
|
+
declare function SunboardTooltips(): react_jsx_runtime0.JSX.Element | null;
|
|
138
186
|
//#endregion
|
|
139
187
|
//#region src/components/SunboardTour.d.ts
|
|
140
|
-
declare function SunboardTour():
|
|
188
|
+
declare function SunboardTour(): react_jsx_runtime0.JSX.Element | null;
|
|
141
189
|
//#endregion
|
|
142
190
|
//#region src/components/Sunboard.d.ts
|
|
143
|
-
declare function SunboardChecklist():
|
|
144
|
-
declare function SunboardSurvey():
|
|
191
|
+
declare function SunboardChecklist(): react_jsx_runtime0.JSX.Element | null;
|
|
192
|
+
declare function SunboardSurvey(): react_jsx_runtime0.JSX.Element | null;
|
|
145
193
|
declare const Sunboard: typeof SunboardChecklist & {
|
|
146
194
|
Checklist: typeof SunboardChecklist;
|
|
147
195
|
Survey: typeof SunboardSurvey;
|
|
148
196
|
Hotspots: typeof SunboardHotspots;
|
|
197
|
+
Tooltips: typeof SunboardTooltips;
|
|
149
198
|
Tour: typeof SunboardTour;
|
|
150
199
|
};
|
|
151
200
|
//#endregion
|
|
@@ -233,5 +282,38 @@ type UseSurveyResult = {
|
|
|
233
282
|
};
|
|
234
283
|
declare function useSurvey(): UseSurveyResult;
|
|
235
284
|
//#endregion
|
|
236
|
-
|
|
285
|
+
//#region src/hooks/useTooltips.d.ts
|
|
286
|
+
type TooltipView = {
|
|
287
|
+
key: string;
|
|
288
|
+
title: string;
|
|
289
|
+
body?: string;
|
|
290
|
+
/** CSS selector of the element the tooltip points at. */
|
|
291
|
+
target: string;
|
|
292
|
+
placement: SunboardPlacement;
|
|
293
|
+
/** True when a tour action is attached; `engage` starts it. */
|
|
294
|
+
hasAction: boolean;
|
|
295
|
+
actionLabel?: string;
|
|
296
|
+
/** True when the user asked for this tooltip via a checklist step. */
|
|
297
|
+
requested: boolean;
|
|
298
|
+
};
|
|
299
|
+
type UseTooltipsResult = {
|
|
300
|
+
/**
|
|
301
|
+
* Tooltips that qualify for the current route (undismissed, or explicitly
|
|
302
|
+
* requested). Render ONE at a time — the first whose target you can anchor.
|
|
303
|
+
*/
|
|
304
|
+
tooltips: TooltipView[];
|
|
305
|
+
/** Report that a tooltip is actually on screen (deduped per session). */
|
|
306
|
+
markSeen: (key: string) => void;
|
|
307
|
+
/** Close without acting — the tooltip never shows again. */
|
|
308
|
+
dismiss: (key: string) => void;
|
|
309
|
+
/** Take the tooltip's action: starts its tour and retires the tooltip. */
|
|
310
|
+
engage: (key: string) => void;
|
|
311
|
+
};
|
|
312
|
+
/**
|
|
313
|
+
* Headless counterpart of `<SunboardTooltips>`: the same visibility, seen,
|
|
314
|
+
* dismissal, and engagement semantics with rendering left to the host.
|
|
315
|
+
*/
|
|
316
|
+
declare function useTooltips(): UseTooltipsResult;
|
|
317
|
+
//#endregion
|
|
318
|
+
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, SunboardTooltips, SunboardTour, type SunboardUser, type SurveyResult, type SurveyViewOption, type SurveyViewQuestion, type SurveyViewStep, type TooltipResult, type TooltipView, type TourResult, type TrackProperties, type TrackResult, type UseChecklistResult, type UseSurveyResult, type UseTooltipsResult, type VisibleSunboardTooltip, useChecklist, useSunboard, useSurvey, useTooltips };
|
|
237
319
|
//# 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/lib/detect-identities.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;;;;;;;;;AAAvD;;;;ACkBA;;;;
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/adapters/navigation.ts","../src/lib/detect-identities.ts","../src/hooks/sunboard-context.ts","../src/components/SunboardProvider.tsx","../src/components/SunboardHotspots.tsx","../src/components/SunboardTooltips.tsx","../src/components/SunboardTour.tsx","../src/components/Sunboard.tsx","../src/hooks/useSunboard.ts","../src/hooks/useChecklist.ts","../src/hooks/useSurvey.ts","../src/hooks/useTooltips.ts"],"sourcesContent":[],"mappings":";;;;;;KAAY,gBAAA,2BAA2C;;;;;;;;;AAAvD;;;;ACkBA;;;;ACPA;AAOA;AAEA;AAIY,KDNA,cAAA,GAAiB,MCML,CAAA,MAAA,EAAA,MAAA,CAAA,GAAA,KAAA;;;KAbZ,YAAA;;;;EFXA,UAAA,CAAA,EEeG,MFfa,CAAA,MAAA,EAAA,OAA2B,CAAA;;KEkB3C,eAAA,GAAkB;KAElB,WAAA;EDFA,EAAA,EAAA,IAAA;;;;ACPZ,CAAA;AAOY,KAMA,YAAA,GANe;EAEf,EAAA,EAAA,IAAA;AAIZ,CAAA,GAAY;EAOA,EAAA,EAAA,KAAA;EAIA,MAAA,EAAA,WAAa,GAAA,cAAA,GAAA,YAAA,GAAA,eAAA;AAIzB,CAAA;AAYY,KApBA,UAAA,GAoBkB;EAQlB,EAAA,EAAA,IAAA;CACH,GAAA;EACA,EAAA,EAAA,KAAA;EAGY,MAAA,EAAA,WAAA,GAAA,cAAA,GAAA,cAAA;CACA;AAGP,KAjCF,aAAA,GAiCE;EAEC,EAAA,EAAA,IAAA;CACE,GAAA;EACF,EAAA,EAAA,KAAA;EAAR,MAAA,EAAA,WAAA,GAAA,cAAA,GAAA,iBAAA;CAMmB;AAAoC,KAvClD,sBAAA,GAuCkD;EAAR,GAAA,EAAA,M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