ontheway-sdk 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 +110 -0
- package/dist/checklist.cjs +319 -0
- package/dist/checklist.cjs.map +1 -0
- package/dist/checklist.d.cts +58 -0
- package/dist/checklist.d.ts +58 -0
- package/dist/checklist.js +314 -0
- package/dist/checklist.js.map +1 -0
- package/dist/chunk-254YHUN3.cjs +26 -0
- package/dist/chunk-254YHUN3.cjs.map +1 -0
- package/dist/chunk-DDAAVRWG.js +23 -0
- package/dist/chunk-DDAAVRWG.js.map +1 -0
- package/dist/chunk-NRUQU5AR.cjs +94 -0
- package/dist/chunk-NRUQU5AR.cjs.map +1 -0
- package/dist/chunk-OKJ5GEH3.js +358 -0
- package/dist/chunk-OKJ5GEH3.js.map +1 -0
- package/dist/chunk-RNQLNLNI.js +91 -0
- package/dist/chunk-RNQLNLNI.js.map +1 -0
- package/dist/chunk-UE3T6TSM.cjs +361 -0
- package/dist/chunk-UE3T6TSM.cjs.map +1 -0
- package/dist/components.cjs +211 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.d.cts +51 -0
- package/dist/components.d.ts +51 -0
- package/dist/components.js +205 -0
- package/dist/components.js.map +1 -0
- package/dist/devtools.cjs +733 -0
- package/dist/devtools.cjs.map +1 -0
- package/dist/devtools.d.cts +18 -0
- package/dist/devtools.d.ts +18 -0
- package/dist/devtools.js +727 -0
- package/dist/devtools.js.map +1 -0
- package/dist/index.cjs +19 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +163 -0
- package/dist/index.d.ts +163 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +18 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +68 -0
- package/dist/react.d.ts +68 -0
- package/dist/react.js +5 -0
- package/dist/react.js.map +1 -0
- package/package.json +93 -0
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { useOnTheWay } from './chunk-RNQLNLNI.js';
|
|
2
|
+
import './chunk-OKJ5GEH3.js';
|
|
3
|
+
import { __spreadProps, __spreadValues } from './chunk-DDAAVRWG.js';
|
|
4
|
+
import { useState, useRef, useEffect, useCallback } from 'react';
|
|
5
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
var STORAGE_KEY_PREFIX = "otw_checklist_";
|
|
8
|
+
function getCompletedSlugs(projectId) {
|
|
9
|
+
if (typeof localStorage === "undefined") return /* @__PURE__ */ new Set();
|
|
10
|
+
try {
|
|
11
|
+
const raw = localStorage.getItem(STORAGE_KEY_PREFIX + projectId);
|
|
12
|
+
if (raw) return new Set(JSON.parse(raw));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
}
|
|
15
|
+
return /* @__PURE__ */ new Set();
|
|
16
|
+
}
|
|
17
|
+
function saveCompletedSlugs(projectId, slugs) {
|
|
18
|
+
if (typeof localStorage === "undefined") return;
|
|
19
|
+
localStorage.setItem(STORAGE_KEY_PREFIX + projectId, JSON.stringify([...slugs]));
|
|
20
|
+
}
|
|
21
|
+
function OnTheWayChecklist({
|
|
22
|
+
tasks,
|
|
23
|
+
title = "Getting Started",
|
|
24
|
+
position = "bottom-right",
|
|
25
|
+
onAllComplete,
|
|
26
|
+
autoHide = true,
|
|
27
|
+
autoHideDelay = 4e3
|
|
28
|
+
}) {
|
|
29
|
+
var _a;
|
|
30
|
+
const { otw, ready, start, isTaskCompleted } = useOnTheWay();
|
|
31
|
+
const [expanded, setExpanded] = useState(true);
|
|
32
|
+
const [completedSlugs, setCompletedSlugs] = useState(/* @__PURE__ */ new Set());
|
|
33
|
+
const [hidden, setHidden] = useState(false);
|
|
34
|
+
const [celebrating, setCelebrating] = useState(false);
|
|
35
|
+
const allCompleteFired = useRef(false);
|
|
36
|
+
const projectId = (_a = otw == null ? void 0 : otw.getProjectId()) != null ? _a : "default";
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
const stored = getCompletedSlugs(projectId);
|
|
39
|
+
if (stored.size > 0) setCompletedSlugs(stored);
|
|
40
|
+
}, [projectId]);
|
|
41
|
+
useEffect(() => {
|
|
42
|
+
if (!ready || !otw) return;
|
|
43
|
+
const interval = setInterval(() => {
|
|
44
|
+
let changed = false;
|
|
45
|
+
const next = new Set(completedSlugs);
|
|
46
|
+
for (const task of tasks) {
|
|
47
|
+
if (!next.has(task.slug) && isTaskCompleted(task.slug)) {
|
|
48
|
+
next.add(task.slug);
|
|
49
|
+
changed = true;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (changed) {
|
|
53
|
+
setCompletedSlugs(next);
|
|
54
|
+
saveCompletedSlugs(projectId, next);
|
|
55
|
+
}
|
|
56
|
+
}, 500);
|
|
57
|
+
return () => clearInterval(interval);
|
|
58
|
+
}, [ready, otw, tasks, completedSlugs, isTaskCompleted, projectId]);
|
|
59
|
+
const requiredTasks = tasks.filter((t) => t.required !== false);
|
|
60
|
+
const allDone = requiredTasks.length > 0 && requiredTasks.every((t) => completedSlugs.has(t.slug));
|
|
61
|
+
const completedCount = tasks.filter((t) => completedSlugs.has(t.slug)).length;
|
|
62
|
+
const progress = tasks.length > 0 ? Math.round(completedCount / tasks.length * 100) : 0;
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
if (allDone && !allCompleteFired.current) {
|
|
65
|
+
allCompleteFired.current = true;
|
|
66
|
+
setCelebrating(true);
|
|
67
|
+
onAllComplete == null ? void 0 : onAllComplete();
|
|
68
|
+
if (autoHide) {
|
|
69
|
+
const timer = setTimeout(() => setHidden(true), autoHideDelay);
|
|
70
|
+
return () => clearTimeout(timer);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}, [allDone, onAllComplete, autoHide, autoHideDelay]);
|
|
74
|
+
const handleTaskClick = useCallback(
|
|
75
|
+
(slug) => {
|
|
76
|
+
if (completedSlugs.has(slug)) return;
|
|
77
|
+
start(slug);
|
|
78
|
+
},
|
|
79
|
+
[completedSlugs, start]
|
|
80
|
+
);
|
|
81
|
+
if (hidden) return null;
|
|
82
|
+
const isRight = position === "bottom-right";
|
|
83
|
+
const containerStyle = __spreadProps(__spreadValues({
|
|
84
|
+
position: "fixed",
|
|
85
|
+
bottom: 24
|
|
86
|
+
}, isRight ? { right: 24 } : { left: 24 }), {
|
|
87
|
+
zIndex: 2147483640,
|
|
88
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
89
|
+
fontSize: 13,
|
|
90
|
+
width: expanded ? 320 : "auto"
|
|
91
|
+
});
|
|
92
|
+
const cardStyle = {
|
|
93
|
+
background: "#fff",
|
|
94
|
+
borderRadius: 12,
|
|
95
|
+
boxShadow: "0 8px 32px rgba(0,0,0,0.15)",
|
|
96
|
+
border: "1px solid #e5e7eb",
|
|
97
|
+
overflow: "hidden"
|
|
98
|
+
};
|
|
99
|
+
const headerStyle = {
|
|
100
|
+
display: "flex",
|
|
101
|
+
alignItems: "center",
|
|
102
|
+
justifyContent: "space-between",
|
|
103
|
+
padding: "12px 16px",
|
|
104
|
+
cursor: "pointer",
|
|
105
|
+
userSelect: "none",
|
|
106
|
+
background: celebrating ? "#f0fdf4" : "#fff",
|
|
107
|
+
borderBottom: expanded ? "1px solid #f3f4f6" : "none"
|
|
108
|
+
};
|
|
109
|
+
const progressBarBg = {
|
|
110
|
+
height: 4,
|
|
111
|
+
background: "#f3f4f6",
|
|
112
|
+
borderRadius: 2,
|
|
113
|
+
overflow: "hidden",
|
|
114
|
+
marginTop: 8
|
|
115
|
+
};
|
|
116
|
+
const progressBarFill = {
|
|
117
|
+
height: "100%",
|
|
118
|
+
width: `${progress}%`,
|
|
119
|
+
background: allDone ? "#22c55e" : "#3b82f6",
|
|
120
|
+
borderRadius: 2,
|
|
121
|
+
transition: "width 0.4s ease"
|
|
122
|
+
};
|
|
123
|
+
const taskItemStyle = (done) => ({
|
|
124
|
+
display: "flex",
|
|
125
|
+
alignItems: "flex-start",
|
|
126
|
+
gap: 10,
|
|
127
|
+
padding: "10px 16px",
|
|
128
|
+
cursor: done ? "default" : "pointer",
|
|
129
|
+
borderBottom: "1px solid #f9fafb",
|
|
130
|
+
opacity: done ? 0.6 : 1,
|
|
131
|
+
transition: "background 0.15s"
|
|
132
|
+
});
|
|
133
|
+
const checkboxStyle = (done) => ({
|
|
134
|
+
width: 18,
|
|
135
|
+
height: 18,
|
|
136
|
+
borderRadius: 4,
|
|
137
|
+
border: done ? "2px solid #22c55e" : "2px solid #d1d5db",
|
|
138
|
+
background: done ? "#22c55e" : "#fff",
|
|
139
|
+
display: "flex",
|
|
140
|
+
alignItems: "center",
|
|
141
|
+
justifyContent: "center",
|
|
142
|
+
flexShrink: 0,
|
|
143
|
+
marginTop: 1,
|
|
144
|
+
transition: "all 0.2s",
|
|
145
|
+
color: "#fff",
|
|
146
|
+
fontSize: 11,
|
|
147
|
+
fontWeight: 700
|
|
148
|
+
});
|
|
149
|
+
if (!expanded) {
|
|
150
|
+
return /* @__PURE__ */ jsx("div", { style: containerStyle, children: /* @__PURE__ */ jsxs(
|
|
151
|
+
"button",
|
|
152
|
+
{
|
|
153
|
+
onClick: () => setExpanded(true),
|
|
154
|
+
style: {
|
|
155
|
+
display: "flex",
|
|
156
|
+
alignItems: "center",
|
|
157
|
+
gap: 8,
|
|
158
|
+
padding: "10px 16px",
|
|
159
|
+
background: celebrating ? "#22c55e" : "#111",
|
|
160
|
+
color: "#fff",
|
|
161
|
+
border: "none",
|
|
162
|
+
borderRadius: 24,
|
|
163
|
+
cursor: "pointer",
|
|
164
|
+
fontSize: 13,
|
|
165
|
+
fontWeight: 600,
|
|
166
|
+
boxShadow: "0 4px 14px rgba(0,0,0,0.2)"
|
|
167
|
+
},
|
|
168
|
+
children: [
|
|
169
|
+
celebrating ? "\u{1F389}" : "\u{1F4CB}",
|
|
170
|
+
" ",
|
|
171
|
+
title,
|
|
172
|
+
/* @__PURE__ */ jsxs(
|
|
173
|
+
"span",
|
|
174
|
+
{
|
|
175
|
+
style: {
|
|
176
|
+
background: "rgba(255,255,255,0.2)",
|
|
177
|
+
padding: "2px 8px",
|
|
178
|
+
borderRadius: 12,
|
|
179
|
+
fontSize: 11
|
|
180
|
+
},
|
|
181
|
+
children: [
|
|
182
|
+
completedCount,
|
|
183
|
+
"/",
|
|
184
|
+
tasks.length
|
|
185
|
+
]
|
|
186
|
+
}
|
|
187
|
+
)
|
|
188
|
+
]
|
|
189
|
+
}
|
|
190
|
+
) });
|
|
191
|
+
}
|
|
192
|
+
return /* @__PURE__ */ jsx("div", { style: containerStyle, children: /* @__PURE__ */ jsxs("div", { style: cardStyle, children: [
|
|
193
|
+
/* @__PURE__ */ jsxs("div", { style: headerStyle, onClick: () => setExpanded(false), children: [
|
|
194
|
+
/* @__PURE__ */ jsxs("div", { style: { flex: 1 }, children: [
|
|
195
|
+
/* @__PURE__ */ jsxs(
|
|
196
|
+
"div",
|
|
197
|
+
{
|
|
198
|
+
style: {
|
|
199
|
+
fontWeight: 600,
|
|
200
|
+
fontSize: 14,
|
|
201
|
+
color: "#111",
|
|
202
|
+
display: "flex",
|
|
203
|
+
alignItems: "center",
|
|
204
|
+
gap: 6
|
|
205
|
+
},
|
|
206
|
+
children: [
|
|
207
|
+
celebrating ? "\u{1F389}" : "\u{1F4CB}",
|
|
208
|
+
" ",
|
|
209
|
+
title
|
|
210
|
+
]
|
|
211
|
+
}
|
|
212
|
+
),
|
|
213
|
+
/* @__PURE__ */ jsx("div", { style: progressBarBg, children: /* @__PURE__ */ jsx("div", { style: progressBarFill }) }),
|
|
214
|
+
/* @__PURE__ */ jsxs("div", { style: { fontSize: 11, color: "#9ca3af", marginTop: 4 }, children: [
|
|
215
|
+
completedCount,
|
|
216
|
+
" of ",
|
|
217
|
+
tasks.length,
|
|
218
|
+
" complete"
|
|
219
|
+
] })
|
|
220
|
+
] }),
|
|
221
|
+
/* @__PURE__ */ jsx(
|
|
222
|
+
"span",
|
|
223
|
+
{
|
|
224
|
+
style: {
|
|
225
|
+
color: "#9ca3af",
|
|
226
|
+
fontSize: 18,
|
|
227
|
+
marginLeft: 8,
|
|
228
|
+
transition: "transform 0.2s",
|
|
229
|
+
transform: "rotate(0deg)"
|
|
230
|
+
},
|
|
231
|
+
children: "\u25BE"
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
] }),
|
|
235
|
+
celebrating && /* @__PURE__ */ jsx(
|
|
236
|
+
"div",
|
|
237
|
+
{
|
|
238
|
+
style: {
|
|
239
|
+
padding: "12px 16px",
|
|
240
|
+
background: "#f0fdf4",
|
|
241
|
+
borderBottom: "1px solid #dcfce7",
|
|
242
|
+
textAlign: "center",
|
|
243
|
+
fontSize: 13,
|
|
244
|
+
color: "#15803d",
|
|
245
|
+
fontWeight: 500
|
|
246
|
+
},
|
|
247
|
+
children: "\u{1F389} All done! You're all set."
|
|
248
|
+
}
|
|
249
|
+
),
|
|
250
|
+
/* @__PURE__ */ jsx("div", { style: { maxHeight: 320, overflowY: "auto" }, children: tasks.map((task) => {
|
|
251
|
+
const done = completedSlugs.has(task.slug);
|
|
252
|
+
return /* @__PURE__ */ jsxs(
|
|
253
|
+
"div",
|
|
254
|
+
{
|
|
255
|
+
style: taskItemStyle(done),
|
|
256
|
+
onClick: () => handleTaskClick(task.slug),
|
|
257
|
+
onMouseEnter: (e) => {
|
|
258
|
+
if (!done) e.currentTarget.style.background = "#f9fafb";
|
|
259
|
+
},
|
|
260
|
+
onMouseLeave: (e) => {
|
|
261
|
+
e.currentTarget.style.background = "";
|
|
262
|
+
},
|
|
263
|
+
role: "button",
|
|
264
|
+
tabIndex: 0,
|
|
265
|
+
onKeyDown: (e) => {
|
|
266
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
267
|
+
e.preventDefault();
|
|
268
|
+
handleTaskClick(task.slug);
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
children: [
|
|
272
|
+
/* @__PURE__ */ jsx("div", { style: checkboxStyle(done), children: done ? "\u2713" : "" }),
|
|
273
|
+
/* @__PURE__ */ jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
274
|
+
/* @__PURE__ */ jsxs(
|
|
275
|
+
"div",
|
|
276
|
+
{
|
|
277
|
+
style: {
|
|
278
|
+
fontWeight: 500,
|
|
279
|
+
fontSize: 13,
|
|
280
|
+
color: done ? "#9ca3af" : "#374151",
|
|
281
|
+
textDecoration: done ? "line-through" : "none"
|
|
282
|
+
},
|
|
283
|
+
children: [
|
|
284
|
+
task.title,
|
|
285
|
+
task.required === false && /* @__PURE__ */ jsx(
|
|
286
|
+
"span",
|
|
287
|
+
{
|
|
288
|
+
style: {
|
|
289
|
+
fontSize: 10,
|
|
290
|
+
color: "#9ca3af",
|
|
291
|
+
marginLeft: 6,
|
|
292
|
+
fontWeight: 400
|
|
293
|
+
},
|
|
294
|
+
children: "optional"
|
|
295
|
+
}
|
|
296
|
+
)
|
|
297
|
+
]
|
|
298
|
+
}
|
|
299
|
+
),
|
|
300
|
+
task.description && /* @__PURE__ */ jsx("div", { style: { fontSize: 11, color: "#9ca3af", marginTop: 2 }, children: task.description })
|
|
301
|
+
] }),
|
|
302
|
+
!done && /* @__PURE__ */ jsx("span", { style: { color: "#d1d5db", fontSize: 16, marginTop: 1 }, children: "\u203A" })
|
|
303
|
+
]
|
|
304
|
+
},
|
|
305
|
+
task.slug
|
|
306
|
+
);
|
|
307
|
+
}) })
|
|
308
|
+
] }) });
|
|
309
|
+
}
|
|
310
|
+
var checklist_default = OnTheWayChecklist;
|
|
311
|
+
|
|
312
|
+
export { OnTheWayChecklist, checklist_default as default };
|
|
313
|
+
//# sourceMappingURL=checklist.js.map
|
|
314
|
+
//# sourceMappingURL=checklist.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/checklist.tsx"],"names":[],"mappings":";;;;;;AA8CA,IAAM,kBAAA,GAAqB,gBAAA;AAE3B,SAAS,kBAAkB,SAAA,EAAgC;AACzD,EAAA,IAAI,OAAO,YAAA,KAAiB,WAAA,EAAa,2BAAW,GAAA,EAAI;AACxD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AA,EAAU,EAAA;AAAA,oBACV,KAAA,EAAO,OAAO,SAAA,GAAY,SAAA;AAAA,oBAC1B,cAAA,EAAgB,OAAO,cAAA,GAAiB;AAAA,mBAC1C;AAAA,kBAEC,QAAA,EAAA;AAAA,oBAAA,IAAA,CAAK,KAAA;AAAA,oBACL,IAAA,CAAK,aAAa,KAAA,oBACjB,GAAA;AAAA,sBAAC,MAAA;AAAA,sBAAA;AAAA,wBACC,KAAA,EAAO;AAAA,0BACL,QAAA,EAAU,EAAA;AAAA,0BACV,KAAA,EAAO,SAAA;AAAA,0BACP,UAAA,EAAY,CAAA;AAAA,0BACZ,UAAA,EAAY;AAAA,yBACd;AAAA,wBACD,QAAA,EAAA;AAAA;AAAA;AAED;AAAA;AAAA,eAEJ;AAAA,cACC,IAAA,CAAK,WAAA,oBACJ,GAAA,CAAC,KAAA,EAAA,EAAI,OAAO,EAAE,QAAA,EAAU,EAAA,EAAI,KAAA,EAAO,SAAA,EAAW,SAAA,EAAW,CAAA,EAAE,EACxD,eAAK,WAAA,EACR;AAAA,aAAA,EAEJ,CAAA;AAAA,YACC,CAAC,IAAA,oBACA,GAAA,CAAC,MAAA,EAAA,EAAK,KAAA,EAAO,EAAE,KAAA,EAAO,SAAA,EAAW,QAAA,EAAU,EAAA,EAAI,SAAA,EAAW,CAAA,IAAK,QAAA,EAAA,QAAA,EAAC;AAAA;AAAA,SAAA;AAAA,QAnD7D,IAAA,CAAK;AAAA,OAqDZ;AAAA,IAEJ,CAAC,CAAA,EACH;AAAA,GAAA,EACF,CAAA,EACF,CAAA;AAEJ;AAEA,IAAO,iBAAA,GAAQ","file":"checklist.js","sourcesContent":["'use client'\n\nimport { useState, useEffect, useCallback, useRef } from 'react'\nimport { useOnTheWay } from './react'\n\n// ---- Types ----\n\n/**\n * A single task entry in the checklist.\n */\nexport interface ChecklistTask {\n /** Slug of the OnTheWay task — must match a server-side task slug */\n slug: string\n /** Human-readable title displayed in the list */\n title: string\n /** Optional description shown below the title */\n description?: string\n /** Whether this task must be completed before the checklist hides (default `true`) */\n required?: boolean\n}\n\n/**\n * Props for the `<OnTheWayChecklist>` component.\n */\nexport interface OnTheWayChecklistProps {\n /** Ordered list of tasks to display */\n tasks: ChecklistTask[]\n /** Panel title (default \"Getting Started\") */\n title?: string\n /** Panel position (default \"bottom-right\") */\n position?: 'bottom-right' | 'bottom-left'\n /** Fired when all required tasks are completed */\n onAllComplete?: () => void\n /**\n * Auto-hide the panel a few seconds after all required tasks are completed.\n * Default `true`. Set to `false` to keep it visible.\n */\n autoHide?: boolean\n /**\n * Delay in ms before auto-hiding after completion (default 4000).\n */\n autoHideDelay?: number\n}\n\n// ---- Storage helpers ----\n\nconst STORAGE_KEY_PREFIX = 'otw_checklist_'\n\nfunction getCompletedSlugs(projectId: string): Set<string> {\n if (typeof localStorage === 'undefined') return new Set()\n try {\n const raw = localStorage.getItem(STORAGE_KEY_PREFIX + projectId)\n if (raw) return new Set(JSON.parse(raw))\n } catch {\n // ignore\n }\n return new Set()\n}\n\nfunction saveCompletedSlugs(projectId: string, slugs: Set<string>) {\n if (typeof localStorage === 'undefined') return\n localStorage.setItem(STORAGE_KEY_PREFIX + projectId, JSON.stringify([...slugs]))\n}\n\n// ---- Component ----\n\n/**\n * Floating checklist panel that shows onboarding progress.\n *\n * Each task maps to an OnTheWay tour by slug. Clicking a task starts the\n * corresponding tour; completion is tracked and persisted to `localStorage`.\n *\n * @example\n * ```tsx\n * <OnTheWayChecklist\n * tasks={[\n * { slug: 'add-company', title: '接入公司' },\n * { slug: 'add-courier', title: '添加快递员' },\n * { slug: 'first-sync', title: '首次同步', required: false },\n * ]}\n * onAllComplete={() => console.log('🎉 All done!')}\n * />\n * ```\n */\nexport function OnTheWayChecklist({\n tasks,\n title = 'Getting Started',\n position = 'bottom-right',\n onAllComplete,\n autoHide = true,\n autoHideDelay = 4000,\n}: OnTheWayChecklistProps) {\n const { otw, ready, start, isTaskCompleted } = useOnTheWay()\n const [expanded, setExpanded] = useState(true)\n const [completedSlugs, setCompletedSlugs] = useState<Set<string>>(new Set())\n const [hidden, setHidden] = useState(false)\n const [celebrating, setCelebrating] = useState(false)\n const allCompleteFired = useRef(false)\n\n // Access projectId from the SDK instance\n const projectId = otw?.getProjectId() ?? 'default'\n\n // Load persisted state\n useEffect(() => {\n const stored = getCompletedSlugs(projectId)\n if (stored.size > 0) setCompletedSlugs(stored)\n }, [projectId])\n\n // Poll for newly completed tasks (the SDK marks them on tour finish)\n useEffect(() => {\n if (!ready || !otw) return\n const interval = setInterval(() => {\n let changed = false\n const next = new Set(completedSlugs)\n for (const task of tasks) {\n if (!next.has(task.slug) && isTaskCompleted(task.slug)) {\n next.add(task.slug)\n changed = true\n }\n }\n if (changed) {\n setCompletedSlugs(next)\n saveCompletedSlugs(projectId, next)\n }\n }, 500)\n return () => clearInterval(interval)\n }, [ready, otw, tasks, completedSlugs, isTaskCompleted, projectId])\n\n // Check all-complete\n const requiredTasks = tasks.filter(t => t.required !== false)\n const allDone = requiredTasks.length > 0 && requiredTasks.every(t => completedSlugs.has(t.slug))\n const completedCount = tasks.filter(t => completedSlugs.has(t.slug)).length\n const progress = tasks.length > 0 ? Math.round((completedCount / tasks.length) * 100) : 0\n\n useEffect(() => {\n if (allDone && !allCompleteFired.current) {\n allCompleteFired.current = true\n setCelebrating(true)\n onAllComplete?.()\n if (autoHide) {\n const timer = setTimeout(() => setHidden(true), autoHideDelay)\n return () => clearTimeout(timer)\n }\n }\n }, [allDone, onAllComplete, autoHide, autoHideDelay])\n\n const handleTaskClick = useCallback(\n (slug: string) => {\n if (completedSlugs.has(slug)) return\n start(slug)\n },\n [completedSlugs, start],\n )\n\n if (hidden) return null\n\n // ---- Styles ----\n const isRight = position === 'bottom-right'\n\n const containerStyle: React.CSSProperties = {\n position: 'fixed',\n bottom: 24,\n ...(isRight ? { right: 24 } : { left: 24 }),\n zIndex: 2147483640,\n fontFamily: 'system-ui, -apple-system, sans-serif',\n fontSize: 13,\n width: expanded ? 320 : 'auto',\n }\n\n const cardStyle: React.CSSProperties = {\n background: '#fff',\n borderRadius: 12,\n boxShadow: '0 8px 32px rgba(0,0,0,0.15)',\n border: '1px solid #e5e7eb',\n overflow: 'hidden',\n }\n\n const headerStyle: React.CSSProperties = {\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'space-between',\n padding: '12px 16px',\n cursor: 'pointer',\n userSelect: 'none',\n background: celebrating ? '#f0fdf4' : '#fff',\n borderBottom: expanded ? '1px solid #f3f4f6' : 'none',\n }\n\n const progressBarBg: React.CSSProperties = {\n height: 4,\n background: '#f3f4f6',\n borderRadius: 2,\n overflow: 'hidden',\n marginTop: 8,\n }\n\n const progressBarFill: React.CSSProperties = {\n height: '100%',\n width: `${progress}%`,\n background: allDone ? '#22c55e' : '#3b82f6',\n borderRadius: 2,\n transition: 'width 0.4s ease',\n }\n\n const taskItemStyle = (done: boolean): React.CSSProperties => ({\n display: 'flex',\n alignItems: 'flex-start',\n gap: 10,\n padding: '10px 16px',\n cursor: done ? 'default' : 'pointer',\n borderBottom: '1px solid #f9fafb',\n opacity: done ? 0.6 : 1,\n transition: 'background 0.15s',\n })\n\n const checkboxStyle = (done: boolean): React.CSSProperties => ({\n width: 18,\n height: 18,\n borderRadius: 4,\n border: done ? '2px solid #22c55e' : '2px solid #d1d5db',\n background: done ? '#22c55e' : '#fff',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n flexShrink: 0,\n marginTop: 1,\n transition: 'all 0.2s',\n color: '#fff',\n fontSize: 11,\n fontWeight: 700,\n })\n\n // Collapsed badge\n if (!expanded) {\n return (\n <div style={containerStyle}>\n <button\n onClick={() => setExpanded(true)}\n style={{\n display: 'flex',\n alignItems: 'center',\n gap: 8,\n padding: '10px 16px',\n background: celebrating ? '#22c55e' : '#111',\n color: '#fff',\n border: 'none',\n borderRadius: 24,\n cursor: 'pointer',\n fontSize: 13,\n fontWeight: 600,\n boxShadow: '0 4px 14px rgba(0,0,0,0.2)',\n }}\n >\n {celebrating ? '🎉' : '📋'} {title}\n <span\n style={{\n background: 'rgba(255,255,255,0.2)',\n padding: '2px 8px',\n borderRadius: 12,\n fontSize: 11,\n }}\n >\n {completedCount}/{tasks.length}\n </span>\n </button>\n </div>\n )\n }\n\n return (\n <div style={containerStyle}>\n <div style={cardStyle}>\n {/* Header */}\n <div style={headerStyle} onClick={() => setExpanded(false)}>\n <div style={{ flex: 1 }}>\n <div\n style={{\n fontWeight: 600,\n fontSize: 14,\n color: '#111',\n display: 'flex',\n alignItems: 'center',\n gap: 6,\n }}\n >\n {celebrating ? '🎉' : '📋'} {title}\n </div>\n <div style={progressBarBg}>\n <div style={progressBarFill} />\n </div>\n <div style={{ fontSize: 11, color: '#9ca3af', marginTop: 4 }}>\n {completedCount} of {tasks.length} complete\n </div>\n </div>\n <span\n style={{\n color: '#9ca3af',\n fontSize: 18,\n marginLeft: 8,\n transition: 'transform 0.2s',\n transform: 'rotate(0deg)',\n }}\n >\n ▾\n </span>\n </div>\n\n {/* Celebration banner */}\n {celebrating && (\n <div\n style={{\n padding: '12px 16px',\n background: '#f0fdf4',\n borderBottom: '1px solid #dcfce7',\n textAlign: 'center',\n fontSize: 13,\n color: '#15803d',\n fontWeight: 500,\n }}\n >\n 🎉 All done! You're all set.\n </div>\n )}\n\n {/* Task list */}\n <div style={{ maxHeight: 320, overflowY: 'auto' }}>\n {tasks.map(task => {\n const done = completedSlugs.has(task.slug)\n return (\n <div\n key={task.slug}\n style={taskItemStyle(done)}\n onClick={() => handleTaskClick(task.slug)}\n onMouseEnter={e => {\n if (!done) (e.currentTarget as HTMLElement).style.background = '#f9fafb'\n }}\n onMouseLeave={e => {\n (e.currentTarget as HTMLElement).style.background = ''\n }}\n role=\"button\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n handleTaskClick(task.slug)\n }\n }}\n >\n <div style={checkboxStyle(done)}>\n {done ? '✓' : ''}\n </div>\n <div style={{ flex: 1, minWidth: 0 }}>\n <div\n style={{\n fontWeight: 500,\n fontSize: 13,\n color: done ? '#9ca3af' : '#374151',\n textDecoration: done ? 'line-through' : 'none',\n }}\n >\n {task.title}\n {task.required === false && (\n <span\n style={{\n fontSize: 10,\n color: '#9ca3af',\n marginLeft: 6,\n fontWeight: 400,\n }}\n >\n optional\n </span>\n )}\n </div>\n {task.description && (\n <div style={{ fontSize: 11, color: '#9ca3af', marginTop: 2 }}>\n {task.description}\n </div>\n )}\n </div>\n {!done && (\n <span style={{ color: '#d1d5db', fontSize: 16, marginTop: 1 }}>›</span>\n )}\n </div>\n )\n })}\n </div>\n </div>\n </div>\n )\n}\n\nexport default OnTheWayChecklist\n"]}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
9
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
10
|
+
var __spreadValues = (a, b) => {
|
|
11
|
+
for (var prop in b || (b = {}))
|
|
12
|
+
if (__hasOwnProp.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
if (__getOwnPropSymbols)
|
|
15
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
16
|
+
if (__propIsEnum.call(b, prop))
|
|
17
|
+
__defNormalProp(a, prop, b[prop]);
|
|
18
|
+
}
|
|
19
|
+
return a;
|
|
20
|
+
};
|
|
21
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
22
|
+
|
|
23
|
+
exports.__spreadProps = __spreadProps;
|
|
24
|
+
exports.__spreadValues = __spreadValues;
|
|
25
|
+
//# sourceMappingURL=chunk-254YHUN3.cjs.map
|
|
26
|
+
//# sourceMappingURL=chunk-254YHUN3.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-254YHUN3.cjs"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
|
|
21
|
+
export { __spreadProps, __spreadValues };
|
|
22
|
+
//# sourceMappingURL=chunk-DDAAVRWG.js.map
|
|
23
|
+
//# sourceMappingURL=chunk-DDAAVRWG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"chunk-DDAAVRWG.js"}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkUE3T6TSM_cjs = require('./chunk-UE3T6TSM.cjs');
|
|
4
|
+
var react = require('react');
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
|
|
7
|
+
var OnTheWayContext = react.createContext({
|
|
8
|
+
otw: null,
|
|
9
|
+
ready: false,
|
|
10
|
+
start: () => {
|
|
11
|
+
},
|
|
12
|
+
reset: () => {
|
|
13
|
+
},
|
|
14
|
+
resetAll: () => {
|
|
15
|
+
},
|
|
16
|
+
registerCondition: () => {
|
|
17
|
+
},
|
|
18
|
+
checkConditions: () => {
|
|
19
|
+
},
|
|
20
|
+
isTaskCompleted: () => false
|
|
21
|
+
});
|
|
22
|
+
function OnTheWayProvider({
|
|
23
|
+
projectId,
|
|
24
|
+
apiUrl,
|
|
25
|
+
onComplete,
|
|
26
|
+
onSkip,
|
|
27
|
+
children
|
|
28
|
+
}) {
|
|
29
|
+
const [otw, setOtw] = react.useState(null);
|
|
30
|
+
const [ready, setReady] = react.useState(false);
|
|
31
|
+
react.useEffect(() => {
|
|
32
|
+
const instance = new chunkUE3T6TSM_cjs.OnTheWay({
|
|
33
|
+
projectId,
|
|
34
|
+
apiUrl,
|
|
35
|
+
onComplete,
|
|
36
|
+
onSkip
|
|
37
|
+
});
|
|
38
|
+
setOtw(instance);
|
|
39
|
+
const check = setInterval(() => {
|
|
40
|
+
if (instance.isReady()) {
|
|
41
|
+
setReady(true);
|
|
42
|
+
clearInterval(check);
|
|
43
|
+
}
|
|
44
|
+
}, 100);
|
|
45
|
+
return () => {
|
|
46
|
+
clearInterval(check);
|
|
47
|
+
};
|
|
48
|
+
}, [projectId, apiUrl]);
|
|
49
|
+
const start = react.useCallback(
|
|
50
|
+
(slugOrId) => otw == null ? void 0 : otw.start(slugOrId),
|
|
51
|
+
[otw]
|
|
52
|
+
);
|
|
53
|
+
const reset = react.useCallback(
|
|
54
|
+
(slugOrId) => otw == null ? void 0 : otw.reset(slugOrId),
|
|
55
|
+
[otw]
|
|
56
|
+
);
|
|
57
|
+
const resetAll = react.useCallback(() => otw == null ? void 0 : otw.resetAll(), [otw]);
|
|
58
|
+
const registerCondition = react.useCallback(
|
|
59
|
+
(slug, fn) => otw == null ? void 0 : otw.registerCondition(slug, fn),
|
|
60
|
+
[otw]
|
|
61
|
+
);
|
|
62
|
+
const checkConditions = react.useCallback(() => otw == null ? void 0 : otw.checkConditions(), [otw]);
|
|
63
|
+
const isTaskCompleted = react.useCallback(
|
|
64
|
+
(slugOrId) => {
|
|
65
|
+
var _a;
|
|
66
|
+
return (_a = otw == null ? void 0 : otw.isTaskCompleted(slugOrId)) != null ? _a : false;
|
|
67
|
+
},
|
|
68
|
+
[otw]
|
|
69
|
+
);
|
|
70
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
71
|
+
OnTheWayContext.Provider,
|
|
72
|
+
{
|
|
73
|
+
value: {
|
|
74
|
+
otw,
|
|
75
|
+
ready,
|
|
76
|
+
start,
|
|
77
|
+
reset,
|
|
78
|
+
resetAll,
|
|
79
|
+
registerCondition,
|
|
80
|
+
checkConditions,
|
|
81
|
+
isTaskCompleted
|
|
82
|
+
},
|
|
83
|
+
children
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
function useOnTheWay() {
|
|
88
|
+
return react.useContext(OnTheWayContext);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
exports.OnTheWayProvider = OnTheWayProvider;
|
|
92
|
+
exports.useOnTheWay = useOnTheWay;
|
|
93
|
+
//# sourceMappingURL=chunk-NRUQU5AR.cjs.map
|
|
94
|
+
//# sourceMappingURL=chunk-NRUQU5AR.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.tsx"],"names":["createContext","useState","useEffect","OnTheWay","useCallback","jsx","useContext"],"mappings":";;;;;;AA4CA,IAAM,kBAAkBA,mBAAA,CAAoC;AAAA,EAC1D,GAAA,EAAK,IAAA;AAAA,EACL,KAAA,EA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QU5AR.cjs","sourcesContent":["'use client'\n\nimport { createContext, useContext, useEffect, useState, useCallback, useRef, type ReactNode } from 'react'\nimport { OnTheWay } from './index'\n\n// ---- Types ----\n\n/** Context value exposed by the OnTheWay provider */\nexport interface OnTheWayContextValue {\n /** SDK instance, null before initialisation */\n otw: OnTheWay | null\n /** Whether the SDK has finished loading */\n ready: boolean\n /** Start a tour by slug or ID */\n start: (slugOrId: string) => void\n /** Reset a specific task */\n reset: (slugOrId: string) => void\n /** Reset all tasks */\n resetAll: () => void\n /**\n * Register a condition function for conditional triggers.\n * The function is evaluated during auto-start when the task trigger is `'condition'`.\n */\n registerCondition: (slug: string, fn: () => boolean) => void\n /**\n * Re-evaluate conditions and start eligible tours.\n * Call after state changes that might satisfy a condition.\n */\n checkConditions: () => void\n /** Check whether a given task has been completed */\n isTaskCompleted: (slugOrId: string) => boolean\n}\n\n/** Props for the OnTheWayProvider component */\nexport interface OnTheWayProviderProps {\n projectId: string\n apiUrl?: string\n onComplete?: (taskId: string) => void\n onSkip?: (taskId: string, stepIndex: number) => void\n children: ReactNode\n}\n\n// ---- Context ----\n\nconst OnTheWayContext = createContext<OnTheWayContextValue>({\n otw: null,\n ready: false,\n start: () => {},\n reset: () => {},\n resetAll: () => {},\n registerCondition: () => {},\n checkConditions: () => {},\n isTaskCompleted: () => false,\n})\n\n// ---- Provider ----\n\n/**\n * Provides the OnTheWay SDK to descendant components.\n *\n * Wrap your application (or a subtree) with this provider so that\n * `useOnTheWay()` returns the SDK instance.\n *\n * On mount the provider also checks for any pending cross-page tour\n * (persisted in `sessionStorage`) and resumes it automatically.\n *\n * @example\n * ```tsx\n * <OnTheWayProvider projectId=\"proj_abc\">\n * <App />\n * </OnTheWayProvider>\n * ```\n */\nexport function OnTheWayProvider({\n projectId,\n apiUrl,\n onComplete,\n onSkip,\n children,\n}: OnTheWayProviderProps) {\n const [otw, setOtw] = useState<OnTheWay | null>(null)\n const [ready, setReady] = useState(false)\n\n useEffect(() => {\n const instance = new OnTheWay({\n projectId,\n apiUrl,\n onComplete,\n onSkip,\n })\n\n setOtw(instance)\n\n // Poll until ready (cross-page resume happens inside init)\n const check = setInterval(() => {\n if (instance.isReady()) {\n setReady(true)\n clearInterval(check)\n }\n }, 100)\n\n return () => {\n clearInterval(check)\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [projectId, apiUrl])\n\n const start = useCallback(\n (slugOrId: string) => otw?.start(slugOrId),\n [otw],\n )\n\n const reset = useCallback(\n (slugOrId: string) => otw?.reset(slugOrId),\n [otw],\n )\n\n const resetAll = useCallback(() => otw?.resetAll(), [otw])\n\n const registerCondition = useCallback(\n (slug: string, fn: () => boolean) => otw?.registerCondition(slug, fn),\n [otw],\n )\n\n const checkConditions = useCallback(() => otw?.checkConditions(), [otw])\n\n const isTaskCompleted = useCallback(\n (slugOrId: string) => otw?.isTaskCompleted(slugOrId) ?? false,\n [otw],\n )\n\n return (\n <OnTheWayContext.Provider\n value={{\n otw,\n ready,\n start,\n reset,\n resetAll,\n registerCondition,\n checkConditions,\n isTaskCompleted,\n }}\n >\n {children}\n </OnTheWayContext.Provider>\n )\n}\n\n// ---- Hook ----\n\n/**\n * Access the OnTheWay SDK from any component wrapped by `<OnTheWayProvider>`.\n *\n * @example\n * ```tsx\n * function HelpButton() {\n * const { start } = useOnTheWay()\n * return <button onClick={() => start('welcome')}>Help</button>\n * }\n * ```\n */\nexport function useOnTheWay() {\n return useContext(OnTheWayContext)\n}\n"]}
|