@sunboard/react 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/LICENSE +21 -0
- package/README.md +59 -0
- package/dist/index.d.mts +156 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1250 -0
- package/dist/index.mjs.map +1 -0
- package/dist/styles.css +560 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sunboardhq.com
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# @sunboard/react
|
|
2
|
+
|
|
3
|
+
React SDK for [Sunboard](https://sunboardhq.com) — agent-native onboarding for SaaS apps.
|
|
4
|
+
|
|
5
|
+
Renders the in-app checklist, product tours, and hotspots that your AI agent authors and you promote to active in Sunboard.
|
|
6
|
+
|
|
7
|
+
> **You usually don't install this by hand.** Run `npm i -g sunboard && sunboard init` in your app and the CLI wires the provider, stylesheet, and environment variables for you. The reference below is for people who want to understand or customize that wiring after the fact.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm i @sunboard/react
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Peer dependencies: `react` >= 18.3 and `react-dom` >= 18.3 (React 19 supported).
|
|
16
|
+
|
|
17
|
+
## Wiring
|
|
18
|
+
|
|
19
|
+
Wrap your app once with `SunboardProvider`, drop `<Sunboard />` somewhere in your layout, and import the default stylesheet:
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { SunboardProvider, Sunboard } from "@sunboard/react";
|
|
23
|
+
import "@sunboard/react/styles.css";
|
|
24
|
+
|
|
25
|
+
export default function RootLayout({ children }) {
|
|
26
|
+
return (
|
|
27
|
+
<SunboardProvider
|
|
28
|
+
runtimeKey={process.env.NEXT_PUBLIC_SUNBOARD_KEY!}
|
|
29
|
+
user={{ id: currentUser.id, firstName: currentUser.firstName }}
|
|
30
|
+
navigate={(href) => router.push(href)}
|
|
31
|
+
>
|
|
32
|
+
{children}
|
|
33
|
+
<Sunboard />
|
|
34
|
+
</SunboardProvider>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`sunboard init` produces this exact wiring for Next.js (App Router and Pages) and Vite. `sunboard doctor` confirms it's still correct after upgrades.
|
|
40
|
+
|
|
41
|
+
## What gets rendered
|
|
42
|
+
|
|
43
|
+
- **`<Sunboard />`** — the main entry point. Renders the active checklist, any in-progress tours, and any visible hotspots based on the current route and user.
|
|
44
|
+
- **`<SunboardChecklist />`**, **`<SunboardHotspots />`**, **`<SunboardTour />`** — individual surfaces, if you want to place them manually.
|
|
45
|
+
- **`useSunboard()`** — hook returning runtime state and imperative helpers like `startTour(key)`, useful for custom product UI.
|
|
46
|
+
|
|
47
|
+
## Theming
|
|
48
|
+
|
|
49
|
+
Override CSS variables defined in `@sunboard/react/styles.css` to match your app's design system. Import the Sunboard stylesheet *before* your own so your overrides win the cascade.
|
|
50
|
+
|
|
51
|
+
## Links
|
|
52
|
+
|
|
53
|
+
- CLI + agent skills: [`sunboard`](https://www.npmjs.com/package/sunboard)
|
|
54
|
+
- App: <https://app.sunboardhq.com>
|
|
55
|
+
- Documentation: <https://sunboardhq.com>
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
MIT — see [LICENSE](./LICENSE).
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { RuntimeBootstrapRequest, RuntimeBootstrapResponse, RuntimeExperience, RuntimeProgress, RuntimeTrackRequest, RuntimeTrackResponse, SunboardRuntimeApiError, SunboardRuntimeClient, SunboardRuntimeClientOptions } from "@sunboard/core/runtime-api";
|
|
3
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
|
+
import { NormalizedSunboardSpec, SunboardHotspot, SunboardStep, SunboardTourStep, TrackEventName } from "@sunboard/core";
|
|
5
|
+
|
|
6
|
+
//#region src/adapters/navigation.d.ts
|
|
7
|
+
type NavigateCallback = (url: string) => void | Promise<void>;
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/hooks/sunboard-context.d.ts
|
|
10
|
+
type SunboardUser = {
|
|
11
|
+
id: string;
|
|
12
|
+
email?: string | null;
|
|
13
|
+
group?: string | null;
|
|
14
|
+
properties?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
type TrackProperties = Record<string, unknown>;
|
|
17
|
+
type TrackResult = {
|
|
18
|
+
ok: true;
|
|
19
|
+
} | {
|
|
20
|
+
ok: false;
|
|
21
|
+
reason: "not-ready" | "missing-user" | "network-error";
|
|
22
|
+
};
|
|
23
|
+
type TourResult = {
|
|
24
|
+
ok: true;
|
|
25
|
+
} | {
|
|
26
|
+
ok: false;
|
|
27
|
+
reason: "not-ready" | "missing-user" | "missing-tour";
|
|
28
|
+
};
|
|
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
|
+
type ActiveSunboardTour = {
|
|
38
|
+
key: string;
|
|
39
|
+
name: string;
|
|
40
|
+
step: SunboardTourStep;
|
|
41
|
+
stepIndex: number;
|
|
42
|
+
totalSteps: number;
|
|
43
|
+
};
|
|
44
|
+
type SunboardContextValue = {
|
|
45
|
+
spec?: NormalizedSunboardSpec | null;
|
|
46
|
+
user?: SunboardUser | null;
|
|
47
|
+
loading: boolean;
|
|
48
|
+
route?: string;
|
|
49
|
+
mode: SunboardRuntimeMode;
|
|
50
|
+
completedStepKeys: ReadonlySet<string>;
|
|
51
|
+
completedTourKeys: ReadonlySet<string>;
|
|
52
|
+
completedCount: number;
|
|
53
|
+
totalSteps: number;
|
|
54
|
+
activeTour: ActiveSunboardTour | null;
|
|
55
|
+
tourError: SunboardTourError | null;
|
|
56
|
+
track: (eventName: TrackEventName, properties?: TrackProperties) => Promise<TrackResult>;
|
|
57
|
+
startTour: (tourKey: string) => Promise<TourResult>;
|
|
58
|
+
dismissTour: () => Promise<TourResult>;
|
|
59
|
+
advanceTour: () => Promise<TourResult>;
|
|
60
|
+
navigateToStep: (step: SunboardStep) => Promise<void>;
|
|
61
|
+
startChecklistStep: (step: SunboardStep) => Promise<TourResult | void>;
|
|
62
|
+
reportTourError: (error: SunboardTourError | null) => void;
|
|
63
|
+
visibleHotspots: Array<{
|
|
64
|
+
key: string;
|
|
65
|
+
hotspot: SunboardHotspot;
|
|
66
|
+
}>;
|
|
67
|
+
};
|
|
68
|
+
//#endregion
|
|
69
|
+
//#region src/components/SunboardProvider.d.ts
|
|
70
|
+
type SunboardProviderProps = {
|
|
71
|
+
spec?: NormalizedSunboardSpec | null;
|
|
72
|
+
user?: SunboardUser | null;
|
|
73
|
+
loading?: boolean;
|
|
74
|
+
mode?: SunboardRuntimeMode;
|
|
75
|
+
route?: string;
|
|
76
|
+
navigate?: NavigateCallback;
|
|
77
|
+
apiUrl?: string;
|
|
78
|
+
publishableKey?: string;
|
|
79
|
+
environment?: string;
|
|
80
|
+
onTrack?: (eventName: TrackEventName, properties?: TrackProperties) => void | Promise<void>;
|
|
81
|
+
children: ReactNode;
|
|
82
|
+
};
|
|
83
|
+
declare function SunboardProvider({
|
|
84
|
+
spec: specProp,
|
|
85
|
+
user,
|
|
86
|
+
loading: loadingProp,
|
|
87
|
+
mode: modeProp,
|
|
88
|
+
route,
|
|
89
|
+
navigate,
|
|
90
|
+
apiUrl,
|
|
91
|
+
publishableKey,
|
|
92
|
+
environment,
|
|
93
|
+
onTrack,
|
|
94
|
+
children
|
|
95
|
+
}: SunboardProviderProps): react_jsx_runtime0.JSX.Element;
|
|
96
|
+
//#endregion
|
|
97
|
+
//#region src/components/SunboardHotspots.d.ts
|
|
98
|
+
declare function SunboardHotspots(): react_jsx_runtime0.JSX.Element;
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/components/SunboardTour.d.ts
|
|
101
|
+
declare function SunboardTour(): react_jsx_runtime0.JSX.Element | null;
|
|
102
|
+
//#endregion
|
|
103
|
+
//#region src/components/Sunboard.d.ts
|
|
104
|
+
declare function SunboardChecklist(): react_jsx_runtime0.JSX.Element | null;
|
|
105
|
+
declare const Sunboard: typeof SunboardChecklist & {
|
|
106
|
+
Checklist: typeof SunboardChecklist;
|
|
107
|
+
Hotspots: typeof SunboardHotspots;
|
|
108
|
+
Tour: typeof SunboardTour;
|
|
109
|
+
};
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/hooks/useSunboardPreviewSpec.d.ts
|
|
112
|
+
type SunboardPreviewSpecState = {
|
|
113
|
+
error: Error | null;
|
|
114
|
+
loading: boolean;
|
|
115
|
+
source: "none" | "preview";
|
|
116
|
+
spec: NormalizedSunboardSpec | null;
|
|
117
|
+
};
|
|
118
|
+
declare function useSunboardPreviewSpec(): SunboardPreviewSpecState;
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/hooks/useSunboard.d.ts
|
|
121
|
+
declare function useSunboard(): SunboardContextValue;
|
|
122
|
+
//#endregion
|
|
123
|
+
//#region src/hooks/useChecklist.d.ts
|
|
124
|
+
type ChecklistViewStep = {
|
|
125
|
+
key: string;
|
|
126
|
+
title: string;
|
|
127
|
+
description?: string;
|
|
128
|
+
badge?: string;
|
|
129
|
+
actionLabel?: string;
|
|
130
|
+
};
|
|
131
|
+
type ChecklistCompletion = {
|
|
132
|
+
title: string;
|
|
133
|
+
subtitle?: string;
|
|
134
|
+
message?: string;
|
|
135
|
+
dismissAfterMs?: number;
|
|
136
|
+
};
|
|
137
|
+
type UseChecklistResult = {
|
|
138
|
+
visible: boolean;
|
|
139
|
+
title?: string;
|
|
140
|
+
subtitle?: string;
|
|
141
|
+
steps: ChecklistViewStep[];
|
|
142
|
+
completedStepKeys: ReadonlySet<string>;
|
|
143
|
+
completedCount: number;
|
|
144
|
+
totalSteps: number;
|
|
145
|
+
remainingCount: number;
|
|
146
|
+
progress: number;
|
|
147
|
+
isCompleted: (key: string) => boolean;
|
|
148
|
+
hasAction: (step: ChecklistViewStep) => boolean;
|
|
149
|
+
startStep: (step: ChecklistViewStep) => void;
|
|
150
|
+
completion?: ChecklistCompletion;
|
|
151
|
+
dismissCompletion: () => void;
|
|
152
|
+
};
|
|
153
|
+
declare function useChecklist(): UseChecklistResult;
|
|
154
|
+
//#endregion
|
|
155
|
+
export { type ChecklistViewStep, type RuntimeBootstrapRequest, type RuntimeBootstrapResponse, type RuntimeExperience, type RuntimeProgress, type RuntimeTrackRequest, type RuntimeTrackResponse, Sunboard, SunboardChecklist, type SunboardContextValue, SunboardHotspots, type SunboardPreviewSpecState, SunboardProvider, type SunboardProviderProps, SunboardRuntimeApiError, SunboardRuntimeClient, type SunboardRuntimeClientOptions, type SunboardRuntimeMode, SunboardTour, type SunboardTourError, type SunboardUser, type TourResult, type TrackProperties, type TrackResult, type UseChecklistResult, useChecklist, useSunboard, useSunboardPreviewSpec };
|
|
156
|
+
//# sourceMappingURL=index.d.mts.map
|
|
@@ -0,0 +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/useSunboardPreviewSpec.ts","../src/hooks/useSunboard.ts","../src/hooks/useChecklist.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;AAIY,KAJA,UAAA,GAIA;EAEA,EAAA,EAAA,IAAA;AAQZ,CAAA,GAAY;EAQA,EAAA,EAAA,KAAA;EACH,MAAA,EAAA,WAAA,GAAA,cAAA,GAAA,cAAA;CACA;AAGD,KAvBI,mBAAA,GAuBJ,YAAA,GAAA,SAAA;AACa,KAtBT,iBAAA,GAsBS;EACA,OAAA,EAAA,MAAA;EAGP,KAAA,CAAA,EAAA,MAAA;EACD,OAAA,CAAA,EAAA,MAAA;EAEE,MAAA,CAAA,EAAA,MAAA;EACE,OAAA,EAAA,MAAA;CACF;AAAR,KAvBK,kBAAA,GAuBL;EACmC,GAAA,EAAA,MAAA;EAAR,IAAA,EAAA,MA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