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