@eventop/sdk 1.1.2 → 1.1.4
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.cjs +28 -311
- package/dist/index.js +6 -289
- package/dist/react/index.cjs +225 -489
- package/dist/react/index.js +215 -482
- package/package.json +1 -1
package/dist/react/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, useContext, useRef, useEffect, Children, cloneElement, useState, useCallback } from 'react';
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Root context — holds the global feature registry.
|
|
@@ -23,6 +24,202 @@ function useFeatureScope() {
|
|
|
23
24
|
return useContext(EventopFeatureScopeContext); // null is fine — steps can declare feature explicitly
|
|
24
25
|
}
|
|
25
26
|
|
|
27
|
+
function EventopTarget({
|
|
28
|
+
children,
|
|
29
|
+
id,
|
|
30
|
+
name,
|
|
31
|
+
description,
|
|
32
|
+
navigate,
|
|
33
|
+
navigateWaitFor,
|
|
34
|
+
advanceOn,
|
|
35
|
+
waitFor,
|
|
36
|
+
...rest
|
|
37
|
+
}) {
|
|
38
|
+
const registry = useRegistry();
|
|
39
|
+
const ref = useRef(null);
|
|
40
|
+
const dataAttr = `data-evtp-${id}`;
|
|
41
|
+
const selector = `[${dataAttr}]`;
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
if (!id || !name) {
|
|
44
|
+
console.warn('[Eventop] <EventopTarget> requires id and name props.');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
registry.registerFeature({
|
|
48
|
+
id,
|
|
49
|
+
name,
|
|
50
|
+
description,
|
|
51
|
+
selector,
|
|
52
|
+
navigate,
|
|
53
|
+
navigateWaitFor,
|
|
54
|
+
waitFor,
|
|
55
|
+
advanceOn: advanceOn ? {
|
|
56
|
+
selector,
|
|
57
|
+
...advanceOn
|
|
58
|
+
} : null
|
|
59
|
+
});
|
|
60
|
+
return () => registry.unregisterFeature(id);
|
|
61
|
+
}, [id, name, description]);
|
|
62
|
+
const child = Children.only(children);
|
|
63
|
+
let wrapped;
|
|
64
|
+
try {
|
|
65
|
+
wrapped = /*#__PURE__*/cloneElement(child, {
|
|
66
|
+
[dataAttr]: '',
|
|
67
|
+
ref: node => {
|
|
68
|
+
ref.current = node;
|
|
69
|
+
const originalRef = child.ref;
|
|
70
|
+
if (typeof originalRef === 'function') originalRef(node);else if (originalRef && 'current' in originalRef) originalRef.current = node;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
} catch {
|
|
74
|
+
wrapped = /*#__PURE__*/jsx("span", {
|
|
75
|
+
[dataAttr]: '',
|
|
76
|
+
ref: ref,
|
|
77
|
+
style: {
|
|
78
|
+
display: 'contents'
|
|
79
|
+
},
|
|
80
|
+
children: child
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
return /*#__PURE__*/jsx(EventopFeatureScopeContext.Provider, {
|
|
84
|
+
value: id,
|
|
85
|
+
children: wrapped
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function EventopStep({
|
|
90
|
+
children,
|
|
91
|
+
feature,
|
|
92
|
+
index,
|
|
93
|
+
parentStep,
|
|
94
|
+
waitFor,
|
|
95
|
+
advanceOn
|
|
96
|
+
}) {
|
|
97
|
+
const registry = useRegistry();
|
|
98
|
+
const featureScope = useFeatureScope();
|
|
99
|
+
const featureId = feature || featureScope;
|
|
100
|
+
const ref = useRef(null);
|
|
101
|
+
if (!featureId) {
|
|
102
|
+
console.warn('[Eventop] <EventopStep> needs either a feature prop or an <EventopTarget> ancestor.');
|
|
103
|
+
}
|
|
104
|
+
if (index == null) {
|
|
105
|
+
console.warn('[Eventop] <EventopStep> requires an index prop.');
|
|
106
|
+
}
|
|
107
|
+
const dataAttr = `data-evtp-step-${featureId}-${parentStep != null ? `${parentStep}-` : ''}${index}`;
|
|
108
|
+
const selector = `[${dataAttr}]`;
|
|
109
|
+
useEffect(() => {
|
|
110
|
+
if (!featureId || index == null) return;
|
|
111
|
+
registry.registerStep(featureId, index, parentStep ?? null, {
|
|
112
|
+
selector,
|
|
113
|
+
waitFor: waitFor || null,
|
|
114
|
+
advanceOn: advanceOn ? {
|
|
115
|
+
selector,
|
|
116
|
+
...advanceOn
|
|
117
|
+
} : null
|
|
118
|
+
});
|
|
119
|
+
return () => registry.unregisterStep(featureId, index, parentStep ?? null);
|
|
120
|
+
}, [featureId, index, parentStep]);
|
|
121
|
+
const child = Children.only(children);
|
|
122
|
+
let wrapped;
|
|
123
|
+
try {
|
|
124
|
+
wrapped = /*#__PURE__*/cloneElement(child, {
|
|
125
|
+
[dataAttr]: '',
|
|
126
|
+
ref: node => {
|
|
127
|
+
ref.current = node;
|
|
128
|
+
const originalRef = child.ref;
|
|
129
|
+
if (typeof originalRef === 'function') originalRef(node);else if (originalRef && 'current' in originalRef) originalRef.current = node;
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
} catch {
|
|
133
|
+
wrapped = /*#__PURE__*/jsx("span", {
|
|
134
|
+
[dataAttr]: '',
|
|
135
|
+
ref: ref,
|
|
136
|
+
style: {
|
|
137
|
+
display: 'contents'
|
|
138
|
+
},
|
|
139
|
+
children: child
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
return wrapped;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
146
|
+
// useEventopAI
|
|
147
|
+
//
|
|
148
|
+
// Access the SDK programmatic API from inside any component.
|
|
149
|
+
// Use for stepComplete(), stepFail(), open(), close() etc.
|
|
150
|
+
//
|
|
151
|
+
// @example
|
|
152
|
+
// function CheckoutForm() {
|
|
153
|
+
// const { stepComplete, stepFail } = useEventopAI();
|
|
154
|
+
//
|
|
155
|
+
// async function handleNext() {
|
|
156
|
+
// const ok = await validateEmail(email);
|
|
157
|
+
// if (ok) stepComplete();
|
|
158
|
+
// else stepFail('Please enter a valid email address.');
|
|
159
|
+
// }
|
|
160
|
+
// }
|
|
161
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
162
|
+
|
|
163
|
+
function useEventopAI() {
|
|
164
|
+
const sdk = () => window.Eventop;
|
|
165
|
+
return {
|
|
166
|
+
open: () => sdk()?.open(),
|
|
167
|
+
close: () => sdk()?.close(),
|
|
168
|
+
cancelTour: () => sdk()?.cancelTour(),
|
|
169
|
+
resumeTour: () => sdk()?.resumeTour(),
|
|
170
|
+
isActive: () => sdk()?.isActive() ?? false,
|
|
171
|
+
isPaused: () => sdk()?.isPaused() ?? false,
|
|
172
|
+
stepComplete: () => sdk()?.stepComplete(),
|
|
173
|
+
stepFail: msg => sdk()?.stepFail(msg),
|
|
174
|
+
runTour: steps => sdk()?.runTour(steps)
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
179
|
+
// useEventopTour
|
|
180
|
+
//
|
|
181
|
+
// Reactively tracks tour state so you can render your own UI.
|
|
182
|
+
// Polls at 300ms — lightweight enough for a status indicator.
|
|
183
|
+
//
|
|
184
|
+
// @example
|
|
185
|
+
// function TourBar() {
|
|
186
|
+
// const { isActive, isPaused, resume, cancel } = useEventopTour();
|
|
187
|
+
// if (!isActive && !isPaused) return null;
|
|
188
|
+
// return (
|
|
189
|
+
// <div>
|
|
190
|
+
// {isPaused && <button onClick={resume}>Resume tour</button>}
|
|
191
|
+
// <button onClick={cancel}>End</button>
|
|
192
|
+
// </div>
|
|
193
|
+
// );
|
|
194
|
+
// }
|
|
195
|
+
// ═══════════════════════════════════════════════════════════════════════════
|
|
196
|
+
|
|
197
|
+
function useEventopTour() {
|
|
198
|
+
const [state, setState] = useState({
|
|
199
|
+
isActive: false,
|
|
200
|
+
isPaused: false
|
|
201
|
+
});
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
const id = setInterval(() => {
|
|
204
|
+
const sdk = window.Eventop;
|
|
205
|
+
if (!sdk) return;
|
|
206
|
+
const next = {
|
|
207
|
+
isActive: sdk.isActive(),
|
|
208
|
+
isPaused: sdk.isPaused()
|
|
209
|
+
};
|
|
210
|
+
setState(prev => prev.isActive !== next.isActive || prev.isPaused !== next.isPaused ? next : prev);
|
|
211
|
+
}, 300);
|
|
212
|
+
return () => clearInterval(id);
|
|
213
|
+
}, []);
|
|
214
|
+
return {
|
|
215
|
+
...state,
|
|
216
|
+
resume: useCallback(() => window.Eventop?.resumeTour(), []),
|
|
217
|
+
cancel: useCallback(() => window.Eventop?.cancelTour(), []),
|
|
218
|
+
open: useCallback(() => window.Eventop?.open(), []),
|
|
219
|
+
close: useCallback(() => window.Eventop?.close(), [])
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
|
|
26
223
|
/**
|
|
27
224
|
* FeatureRegistry
|
|
28
225
|
*
|
|
@@ -185,290 +382,6 @@ function createFeatureRegistry() {
|
|
|
185
382
|
};
|
|
186
383
|
}
|
|
187
384
|
|
|
188
|
-
var jsxRuntime = {exports: {}};
|
|
189
|
-
|
|
190
|
-
var reactJsxRuntime_production = {};
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* @license React
|
|
194
|
-
* react-jsx-runtime.production.js
|
|
195
|
-
*
|
|
196
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
197
|
-
*
|
|
198
|
-
* This source code is licensed under the MIT license found in the
|
|
199
|
-
* LICENSE file in the root directory of this source tree.
|
|
200
|
-
*/
|
|
201
|
-
var hasRequiredReactJsxRuntime_production;
|
|
202
|
-
function requireReactJsxRuntime_production() {
|
|
203
|
-
if (hasRequiredReactJsxRuntime_production) return reactJsxRuntime_production;
|
|
204
|
-
hasRequiredReactJsxRuntime_production = 1;
|
|
205
|
-
var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
206
|
-
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
|
|
207
|
-
function jsxProd(type, config, maybeKey) {
|
|
208
|
-
var key = null;
|
|
209
|
-
void 0 !== maybeKey && (key = "" + maybeKey);
|
|
210
|
-
void 0 !== config.key && (key = "" + config.key);
|
|
211
|
-
if ("key" in config) {
|
|
212
|
-
maybeKey = {};
|
|
213
|
-
for (var propName in config) "key" !== propName && (maybeKey[propName] = config[propName]);
|
|
214
|
-
} else maybeKey = config;
|
|
215
|
-
config = maybeKey.ref;
|
|
216
|
-
return {
|
|
217
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
218
|
-
type: type,
|
|
219
|
-
key: key,
|
|
220
|
-
ref: void 0 !== config ? config : null,
|
|
221
|
-
props: maybeKey
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
reactJsxRuntime_production.Fragment = REACT_FRAGMENT_TYPE;
|
|
225
|
-
reactJsxRuntime_production.jsx = jsxProd;
|
|
226
|
-
reactJsxRuntime_production.jsxs = jsxProd;
|
|
227
|
-
return reactJsxRuntime_production;
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
var reactJsxRuntime_development = {};
|
|
231
|
-
|
|
232
|
-
/**
|
|
233
|
-
* @license React
|
|
234
|
-
* react-jsx-runtime.development.js
|
|
235
|
-
*
|
|
236
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
237
|
-
*
|
|
238
|
-
* This source code is licensed under the MIT license found in the
|
|
239
|
-
* LICENSE file in the root directory of this source tree.
|
|
240
|
-
*/
|
|
241
|
-
var hasRequiredReactJsxRuntime_development;
|
|
242
|
-
function requireReactJsxRuntime_development() {
|
|
243
|
-
if (hasRequiredReactJsxRuntime_development) return reactJsxRuntime_development;
|
|
244
|
-
hasRequiredReactJsxRuntime_development = 1;
|
|
245
|
-
"production" !== process.env.NODE_ENV && function () {
|
|
246
|
-
function getComponentNameFromType(type) {
|
|
247
|
-
if (null == type) return null;
|
|
248
|
-
if ("function" === typeof type) return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
|
|
249
|
-
if ("string" === typeof type) return type;
|
|
250
|
-
switch (type) {
|
|
251
|
-
case REACT_FRAGMENT_TYPE:
|
|
252
|
-
return "Fragment";
|
|
253
|
-
case REACT_PROFILER_TYPE:
|
|
254
|
-
return "Profiler";
|
|
255
|
-
case REACT_STRICT_MODE_TYPE:
|
|
256
|
-
return "StrictMode";
|
|
257
|
-
case REACT_SUSPENSE_TYPE:
|
|
258
|
-
return "Suspense";
|
|
259
|
-
case REACT_SUSPENSE_LIST_TYPE:
|
|
260
|
-
return "SuspenseList";
|
|
261
|
-
case REACT_ACTIVITY_TYPE:
|
|
262
|
-
return "Activity";
|
|
263
|
-
}
|
|
264
|
-
if ("object" === typeof type) switch ("number" === typeof type.tag && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), type.$$typeof) {
|
|
265
|
-
case REACT_PORTAL_TYPE:
|
|
266
|
-
return "Portal";
|
|
267
|
-
case REACT_CONTEXT_TYPE:
|
|
268
|
-
return type.displayName || "Context";
|
|
269
|
-
case REACT_CONSUMER_TYPE:
|
|
270
|
-
return (type._context.displayName || "Context") + ".Consumer";
|
|
271
|
-
case REACT_FORWARD_REF_TYPE:
|
|
272
|
-
var innerType = type.render;
|
|
273
|
-
type = type.displayName;
|
|
274
|
-
type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
|
|
275
|
-
return type;
|
|
276
|
-
case REACT_MEMO_TYPE:
|
|
277
|
-
return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
|
|
278
|
-
case REACT_LAZY_TYPE:
|
|
279
|
-
innerType = type._payload;
|
|
280
|
-
type = type._init;
|
|
281
|
-
try {
|
|
282
|
-
return getComponentNameFromType(type(innerType));
|
|
283
|
-
} catch (x) {}
|
|
284
|
-
}
|
|
285
|
-
return null;
|
|
286
|
-
}
|
|
287
|
-
function testStringCoercion(value) {
|
|
288
|
-
return "" + value;
|
|
289
|
-
}
|
|
290
|
-
function checkKeyStringCoercion(value) {
|
|
291
|
-
try {
|
|
292
|
-
testStringCoercion(value);
|
|
293
|
-
var JSCompiler_inline_result = !1;
|
|
294
|
-
} catch (e) {
|
|
295
|
-
JSCompiler_inline_result = true;
|
|
296
|
-
}
|
|
297
|
-
if (JSCompiler_inline_result) {
|
|
298
|
-
JSCompiler_inline_result = console;
|
|
299
|
-
var JSCompiler_temp_const = JSCompiler_inline_result.error;
|
|
300
|
-
var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
|
|
301
|
-
JSCompiler_temp_const.call(JSCompiler_inline_result, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", JSCompiler_inline_result$jscomp$0);
|
|
302
|
-
return testStringCoercion(value);
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
function getTaskName(type) {
|
|
306
|
-
if (type === REACT_FRAGMENT_TYPE) return "<>";
|
|
307
|
-
if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE) return "<...>";
|
|
308
|
-
try {
|
|
309
|
-
var name = getComponentNameFromType(type);
|
|
310
|
-
return name ? "<" + name + ">" : "<...>";
|
|
311
|
-
} catch (x) {
|
|
312
|
-
return "<...>";
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
function getOwner() {
|
|
316
|
-
var dispatcher = ReactSharedInternals.A;
|
|
317
|
-
return null === dispatcher ? null : dispatcher.getOwner();
|
|
318
|
-
}
|
|
319
|
-
function UnknownOwner() {
|
|
320
|
-
return Error("react-stack-top-frame");
|
|
321
|
-
}
|
|
322
|
-
function hasValidKey(config) {
|
|
323
|
-
if (hasOwnProperty.call(config, "key")) {
|
|
324
|
-
var getter = Object.getOwnPropertyDescriptor(config, "key").get;
|
|
325
|
-
if (getter && getter.isReactWarning) return false;
|
|
326
|
-
}
|
|
327
|
-
return void 0 !== config.key;
|
|
328
|
-
}
|
|
329
|
-
function defineKeyPropWarningGetter(props, displayName) {
|
|
330
|
-
function warnAboutAccessingKey() {
|
|
331
|
-
specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", displayName));
|
|
332
|
-
}
|
|
333
|
-
warnAboutAccessingKey.isReactWarning = true;
|
|
334
|
-
Object.defineProperty(props, "key", {
|
|
335
|
-
get: warnAboutAccessingKey,
|
|
336
|
-
configurable: true
|
|
337
|
-
});
|
|
338
|
-
}
|
|
339
|
-
function elementRefGetterWithDeprecationWarning() {
|
|
340
|
-
var componentName = getComponentNameFromType(this.type);
|
|
341
|
-
didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."));
|
|
342
|
-
componentName = this.props.ref;
|
|
343
|
-
return void 0 !== componentName ? componentName : null;
|
|
344
|
-
}
|
|
345
|
-
function ReactElement(type, key, props, owner, debugStack, debugTask) {
|
|
346
|
-
var refProp = props.ref;
|
|
347
|
-
type = {
|
|
348
|
-
$$typeof: REACT_ELEMENT_TYPE,
|
|
349
|
-
type: type,
|
|
350
|
-
key: key,
|
|
351
|
-
props: props,
|
|
352
|
-
_owner: owner
|
|
353
|
-
};
|
|
354
|
-
null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
|
|
355
|
-
enumerable: false,
|
|
356
|
-
get: elementRefGetterWithDeprecationWarning
|
|
357
|
-
}) : Object.defineProperty(type, "ref", {
|
|
358
|
-
enumerable: false,
|
|
359
|
-
value: null
|
|
360
|
-
});
|
|
361
|
-
type._store = {};
|
|
362
|
-
Object.defineProperty(type._store, "validated", {
|
|
363
|
-
configurable: false,
|
|
364
|
-
enumerable: false,
|
|
365
|
-
writable: true,
|
|
366
|
-
value: 0
|
|
367
|
-
});
|
|
368
|
-
Object.defineProperty(type, "_debugInfo", {
|
|
369
|
-
configurable: false,
|
|
370
|
-
enumerable: false,
|
|
371
|
-
writable: true,
|
|
372
|
-
value: null
|
|
373
|
-
});
|
|
374
|
-
Object.defineProperty(type, "_debugStack", {
|
|
375
|
-
configurable: false,
|
|
376
|
-
enumerable: false,
|
|
377
|
-
writable: true,
|
|
378
|
-
value: debugStack
|
|
379
|
-
});
|
|
380
|
-
Object.defineProperty(type, "_debugTask", {
|
|
381
|
-
configurable: false,
|
|
382
|
-
enumerable: false,
|
|
383
|
-
writable: true,
|
|
384
|
-
value: debugTask
|
|
385
|
-
});
|
|
386
|
-
Object.freeze && (Object.freeze(type.props), Object.freeze(type));
|
|
387
|
-
return type;
|
|
388
|
-
}
|
|
389
|
-
function jsxDEVImpl(type, config, maybeKey, isStaticChildren, debugStack, debugTask) {
|
|
390
|
-
var children = config.children;
|
|
391
|
-
if (void 0 !== children) if (isStaticChildren) {
|
|
392
|
-
if (isArrayImpl(children)) {
|
|
393
|
-
for (isStaticChildren = 0; isStaticChildren < children.length; isStaticChildren++) validateChildKeys(children[isStaticChildren]);
|
|
394
|
-
Object.freeze && Object.freeze(children);
|
|
395
|
-
} else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
396
|
-
} else validateChildKeys(children);
|
|
397
|
-
if (hasOwnProperty.call(config, "key")) {
|
|
398
|
-
children = getComponentNameFromType(type);
|
|
399
|
-
var keys = Object.keys(config).filter(function (k) {
|
|
400
|
-
return "key" !== k;
|
|
401
|
-
});
|
|
402
|
-
isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
403
|
-
didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', isStaticChildren, children, keys, children), didWarnAboutKeySpread[children + isStaticChildren] = true);
|
|
404
|
-
}
|
|
405
|
-
children = null;
|
|
406
|
-
void 0 !== maybeKey && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
|
|
407
|
-
hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
|
|
408
|
-
if ("key" in config) {
|
|
409
|
-
maybeKey = {};
|
|
410
|
-
for (var propName in config) "key" !== propName && (maybeKey[propName] = config[propName]);
|
|
411
|
-
} else maybeKey = config;
|
|
412
|
-
children && defineKeyPropWarningGetter(maybeKey, "function" === typeof type ? type.displayName || type.name || "Unknown" : type);
|
|
413
|
-
return ReactElement(type, children, maybeKey, getOwner(), debugStack, debugTask);
|
|
414
|
-
}
|
|
415
|
-
function validateChildKeys(node) {
|
|
416
|
-
isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
|
|
417
|
-
}
|
|
418
|
-
function isValidElement(object) {
|
|
419
|
-
return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
420
|
-
}
|
|
421
|
-
var React = require$$0,
|
|
422
|
-
REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"),
|
|
423
|
-
REACT_PORTAL_TYPE = Symbol.for("react.portal"),
|
|
424
|
-
REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"),
|
|
425
|
-
REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"),
|
|
426
|
-
REACT_PROFILER_TYPE = Symbol.for("react.profiler"),
|
|
427
|
-
REACT_CONSUMER_TYPE = Symbol.for("react.consumer"),
|
|
428
|
-
REACT_CONTEXT_TYPE = Symbol.for("react.context"),
|
|
429
|
-
REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"),
|
|
430
|
-
REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"),
|
|
431
|
-
REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"),
|
|
432
|
-
REACT_MEMO_TYPE = Symbol.for("react.memo"),
|
|
433
|
-
REACT_LAZY_TYPE = Symbol.for("react.lazy"),
|
|
434
|
-
REACT_ACTIVITY_TYPE = Symbol.for("react.activity"),
|
|
435
|
-
REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"),
|
|
436
|
-
ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,
|
|
437
|
-
hasOwnProperty = Object.prototype.hasOwnProperty,
|
|
438
|
-
isArrayImpl = Array.isArray,
|
|
439
|
-
createTask = console.createTask ? console.createTask : function () {
|
|
440
|
-
return null;
|
|
441
|
-
};
|
|
442
|
-
React = {
|
|
443
|
-
react_stack_bottom_frame: function (callStackForError) {
|
|
444
|
-
return callStackForError();
|
|
445
|
-
}
|
|
446
|
-
};
|
|
447
|
-
var specialPropKeyWarningShown;
|
|
448
|
-
var didWarnAboutElementRef = {};
|
|
449
|
-
var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(React, UnknownOwner)();
|
|
450
|
-
var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
|
|
451
|
-
var didWarnAboutKeySpread = {};
|
|
452
|
-
reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
|
|
453
|
-
reactJsxRuntime_development.jsx = function (type, config, maybeKey) {
|
|
454
|
-
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
455
|
-
return jsxDEVImpl(type, config, maybeKey, false, trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack, trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
|
|
456
|
-
};
|
|
457
|
-
reactJsxRuntime_development.jsxs = function (type, config, maybeKey) {
|
|
458
|
-
var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
|
|
459
|
-
return jsxDEVImpl(type, config, maybeKey, true, trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack, trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
|
|
460
|
-
};
|
|
461
|
-
}();
|
|
462
|
-
return reactJsxRuntime_development;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
if (process.env.NODE_ENV === 'production') {
|
|
466
|
-
jsxRuntime.exports = requireReactJsxRuntime_production();
|
|
467
|
-
} else {
|
|
468
|
-
jsxRuntime.exports = requireReactJsxRuntime_development();
|
|
469
|
-
}
|
|
470
|
-
var jsxRuntimeExports = jsxRuntime.exports;
|
|
471
|
-
|
|
472
385
|
function EventopProvider({
|
|
473
386
|
children,
|
|
474
387
|
provider,
|
|
@@ -519,206 +432,26 @@ function EventopProvider({
|
|
|
519
432
|
unregisterStep: registry.unregisterStep,
|
|
520
433
|
isRegistered: registry.isRegistered
|
|
521
434
|
};
|
|
522
|
-
return /*#__PURE__*/
|
|
435
|
+
return /*#__PURE__*/jsx(EventopRegistryContext.Provider, {
|
|
523
436
|
value: ctx,
|
|
524
437
|
children: children
|
|
525
438
|
});
|
|
526
439
|
}
|
|
527
440
|
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
useEffect(() => {
|
|
544
|
-
if (!id || !name) {
|
|
545
|
-
console.warn('[Eventop] <EventopTarget> requires id and name props.');
|
|
546
|
-
return;
|
|
547
|
-
}
|
|
548
|
-
registry.registerFeature({
|
|
549
|
-
id,
|
|
550
|
-
name,
|
|
551
|
-
description,
|
|
552
|
-
selector,
|
|
553
|
-
navigate,
|
|
554
|
-
navigateWaitFor,
|
|
555
|
-
waitFor,
|
|
556
|
-
advanceOn: advanceOn ? {
|
|
557
|
-
selector,
|
|
558
|
-
...advanceOn
|
|
559
|
-
} : null
|
|
560
|
-
});
|
|
561
|
-
return () => registry.unregisterFeature(id);
|
|
562
|
-
}, [id, name, description]);
|
|
563
|
-
const child = Children.only(children);
|
|
564
|
-
let wrapped;
|
|
565
|
-
try {
|
|
566
|
-
wrapped = /*#__PURE__*/cloneElement(child, {
|
|
567
|
-
[dataAttr]: '',
|
|
568
|
-
ref: node => {
|
|
569
|
-
ref.current = node;
|
|
570
|
-
const originalRef = child.ref;
|
|
571
|
-
if (typeof originalRef === 'function') originalRef(node);else if (originalRef && 'current' in originalRef) originalRef.current = node;
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
} catch {
|
|
575
|
-
wrapped = /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
576
|
-
[dataAttr]: '',
|
|
577
|
-
ref: ref,
|
|
578
|
-
style: {
|
|
579
|
-
display: 'contents'
|
|
580
|
-
},
|
|
581
|
-
children: child
|
|
582
|
-
});
|
|
583
|
-
}
|
|
584
|
-
return /*#__PURE__*/jsxRuntimeExports.jsx(EventopFeatureScopeContext.Provider, {
|
|
585
|
-
value: id,
|
|
586
|
-
children: wrapped
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
function EventopStep({
|
|
591
|
-
children,
|
|
592
|
-
feature,
|
|
593
|
-
index,
|
|
594
|
-
parentStep,
|
|
595
|
-
waitFor,
|
|
596
|
-
advanceOn
|
|
597
|
-
}) {
|
|
598
|
-
const registry = useRegistry();
|
|
599
|
-
const featureScope = useFeatureScope();
|
|
600
|
-
const featureId = feature || featureScope;
|
|
601
|
-
const ref = useRef(null);
|
|
602
|
-
if (!featureId) {
|
|
603
|
-
console.warn('[Eventop] <EventopStep> needs either a feature prop or an <EventopTarget> ancestor.');
|
|
604
|
-
}
|
|
605
|
-
if (index == null) {
|
|
606
|
-
console.warn('[Eventop] <EventopStep> requires an index prop.');
|
|
607
|
-
}
|
|
608
|
-
const dataAttr = `data-evtp-step-${featureId}-${parentStep != null ? `${parentStep}-` : ''}${index}`;
|
|
609
|
-
const selector = `[${dataAttr}]`;
|
|
610
|
-
useEffect(() => {
|
|
611
|
-
if (!featureId || index == null) return;
|
|
612
|
-
registry.registerStep(featureId, index, parentStep ?? null, {
|
|
613
|
-
selector,
|
|
614
|
-
waitFor: waitFor || null,
|
|
615
|
-
advanceOn: advanceOn ? {
|
|
616
|
-
selector,
|
|
617
|
-
...advanceOn
|
|
618
|
-
} : null
|
|
619
|
-
});
|
|
620
|
-
return () => registry.unregisterStep(featureId, index, parentStep ?? null);
|
|
621
|
-
}, [featureId, index, parentStep]);
|
|
622
|
-
const child = Children.only(children);
|
|
623
|
-
let wrapped;
|
|
624
|
-
try {
|
|
625
|
-
wrapped = /*#__PURE__*/cloneElement(child, {
|
|
626
|
-
[dataAttr]: '',
|
|
627
|
-
ref: node => {
|
|
628
|
-
ref.current = node;
|
|
629
|
-
const originalRef = child.ref;
|
|
630
|
-
if (typeof originalRef === 'function') originalRef(node);else if (originalRef && 'current' in originalRef) originalRef.current = node;
|
|
631
|
-
}
|
|
632
|
-
});
|
|
633
|
-
} catch {
|
|
634
|
-
wrapped = /*#__PURE__*/jsxRuntimeExports.jsx("span", {
|
|
635
|
-
[dataAttr]: '',
|
|
636
|
-
ref: ref,
|
|
637
|
-
style: {
|
|
638
|
-
display: 'contents'
|
|
639
|
-
},
|
|
640
|
-
children: child
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
return wrapped;
|
|
644
|
-
}
|
|
645
|
-
|
|
646
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
647
|
-
// useEventopAI
|
|
648
|
-
//
|
|
649
|
-
// Access the SDK programmatic API from inside any component.
|
|
650
|
-
// Use for stepComplete(), stepFail(), open(), close() etc.
|
|
651
|
-
//
|
|
652
|
-
// @example
|
|
653
|
-
// function CheckoutForm() {
|
|
654
|
-
// const { stepComplete, stepFail } = useEventopAI();
|
|
655
|
-
//
|
|
656
|
-
// async function handleNext() {
|
|
657
|
-
// const ok = await validateEmail(email);
|
|
658
|
-
// if (ok) stepComplete();
|
|
659
|
-
// else stepFail('Please enter a valid email address.');
|
|
660
|
-
// }
|
|
661
|
-
// }
|
|
662
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
663
|
-
|
|
664
|
-
function useEventopAI() {
|
|
665
|
-
const sdk = () => window.Eventop;
|
|
666
|
-
return {
|
|
667
|
-
open: () => sdk()?.open(),
|
|
668
|
-
close: () => sdk()?.close(),
|
|
669
|
-
cancelTour: () => sdk()?.cancelTour(),
|
|
670
|
-
resumeTour: () => sdk()?.resumeTour(),
|
|
671
|
-
isActive: () => sdk()?.isActive() ?? false,
|
|
672
|
-
isPaused: () => sdk()?.isPaused() ?? false,
|
|
673
|
-
stepComplete: () => sdk()?.stepComplete(),
|
|
674
|
-
stepFail: msg => sdk()?.stepFail(msg),
|
|
675
|
-
runTour: steps => sdk()?.runTour(steps)
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
|
|
679
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
680
|
-
// useEventopTour
|
|
681
|
-
//
|
|
682
|
-
// Reactively tracks tour state so you can render your own UI.
|
|
683
|
-
// Polls at 300ms — lightweight enough for a status indicator.
|
|
684
|
-
//
|
|
685
|
-
// @example
|
|
686
|
-
// function TourBar() {
|
|
687
|
-
// const { isActive, isPaused, resume, cancel } = useEventopTour();
|
|
688
|
-
// if (!isActive && !isPaused) return null;
|
|
689
|
-
// return (
|
|
690
|
-
// <div>
|
|
691
|
-
// {isPaused && <button onClick={resume}>Resume tour</button>}
|
|
692
|
-
// <button onClick={cancel}>End</button>
|
|
693
|
-
// </div>
|
|
694
|
-
// );
|
|
695
|
-
// }
|
|
696
|
-
// ═══════════════════════════════════════════════════════════════════════════
|
|
697
|
-
|
|
698
|
-
function useEventopTour() {
|
|
699
|
-
const [state, setState] = useState({
|
|
700
|
-
isActive: false,
|
|
701
|
-
isPaused: false
|
|
702
|
-
});
|
|
703
|
-
useEffect(() => {
|
|
704
|
-
const id = setInterval(() => {
|
|
705
|
-
const sdk = window.Eventop;
|
|
706
|
-
if (!sdk) return;
|
|
707
|
-
const next = {
|
|
708
|
-
isActive: sdk.isActive(),
|
|
709
|
-
isPaused: sdk.isPaused()
|
|
710
|
-
};
|
|
711
|
-
setState(prev => prev.isActive !== next.isActive || prev.isPaused !== next.isPaused ? next : prev);
|
|
712
|
-
}, 300);
|
|
713
|
-
return () => clearInterval(id);
|
|
714
|
-
}, []);
|
|
715
|
-
return {
|
|
716
|
-
...state,
|
|
717
|
-
resume: useCallback(() => window.Eventop?.resumeTour(), []),
|
|
718
|
-
cancel: useCallback(() => window.Eventop?.cancelTour(), []),
|
|
719
|
-
open: useCallback(() => window.Eventop?.open(), []),
|
|
720
|
-
close: useCallback(() => window.Eventop?.close(), [])
|
|
721
|
-
};
|
|
722
|
-
}
|
|
441
|
+
window.EventopAI = {
|
|
442
|
+
init,
|
|
443
|
+
open,
|
|
444
|
+
close,
|
|
445
|
+
cancelTour,
|
|
446
|
+
resumeTour,
|
|
447
|
+
stepComplete,
|
|
448
|
+
stepFail,
|
|
449
|
+
isActive,
|
|
450
|
+
isPaused,
|
|
451
|
+
runTour,
|
|
452
|
+
_updateConfig,
|
|
453
|
+
providers
|
|
454
|
+
};
|
|
455
|
+
var index = window.EventopAI;
|
|
723
456
|
|
|
724
|
-
export { EventopProvider as EventopAIProvider, EventopStep, EventopTarget, useEventopAI, useEventopTour };
|
|
457
|
+
export { EventopProvider as EventopAIProvider, EventopStep, EventopTarget, index as default, useEventopAI, useEventopTour };
|