@appfunnel-dev/sdk 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-BUF5FDKC.cjs → chunk-EVUYCLVY.cjs} +42 -19
- package/dist/chunk-EVUYCLVY.cjs.map +1 -0
- package/dist/{chunk-E6KSJ5UI.js → chunk-H3KHXZSI.js} +42 -20
- package/dist/chunk-H3KHXZSI.js.map +1 -0
- package/dist/chunk-P4SLDMWY.js +104 -0
- package/dist/chunk-P4SLDMWY.js.map +1 -0
- package/dist/chunk-XP44I2MU.cjs +108 -0
- package/dist/chunk-XP44I2MU.cjs.map +1 -0
- package/dist/elements/index.cjs +12172 -0
- package/dist/elements/index.cjs.map +1 -0
- package/dist/elements/index.d.cts +602 -0
- package/dist/elements/index.d.ts +602 -0
- package/dist/elements/index.js +12137 -0
- package/dist/elements/index.js.map +1 -0
- package/dist/index.cjs +233 -114
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +70 -3
- package/dist/index.d.ts +70 -3
- package/dist/index.js +199 -91
- package/dist/index.js.map +1 -1
- package/dist/{internal-BlgQ9C2d.d.cts → internal-C7seLJBr.d.cts} +1 -0
- package/dist/{internal-BlgQ9C2d.d.ts → internal-C7seLJBr.d.ts} +1 -0
- package/dist/internal.cjs +2 -2
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/package.json +17 -2
- package/dist/chunk-BUF5FDKC.cjs.map +0 -1
- package/dist/chunk-E6KSJ5UI.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkXP44I2MU_cjs = require('./chunk-XP44I2MU.cjs');
|
|
4
|
+
var chunkEVUYCLVY_cjs = require('./chunk-EVUYCLVY.cjs');
|
|
4
5
|
var react = require('react');
|
|
5
6
|
var stripeJs = require('@stripe/stripe-js');
|
|
6
7
|
var reactStripeJs = require('@stripe/react-stripe-js');
|
|
@@ -14,7 +15,7 @@ function definePage(definition) {
|
|
|
14
15
|
return definition;
|
|
15
16
|
}
|
|
16
17
|
function useVariable(id) {
|
|
17
|
-
const { variableStore } =
|
|
18
|
+
const { variableStore } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
18
19
|
const subscribe = react.useCallback(
|
|
19
20
|
(callback) => variableStore.subscribe(callback, { keys: [id] }),
|
|
20
21
|
[variableStore, id]
|
|
@@ -31,7 +32,7 @@ function useVariable(id) {
|
|
|
31
32
|
return [value, setValue];
|
|
32
33
|
}
|
|
33
34
|
function useVariables() {
|
|
34
|
-
const { variableStore } =
|
|
35
|
+
const { variableStore } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
35
36
|
const subscribe = react.useCallback(
|
|
36
37
|
(callback) => variableStore.subscribe(callback),
|
|
37
38
|
[variableStore]
|
|
@@ -42,8 +43,104 @@ function useVariables() {
|
|
|
42
43
|
);
|
|
43
44
|
return react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
44
45
|
}
|
|
46
|
+
|
|
47
|
+
// src/utils/date.ts
|
|
48
|
+
function toISODate(input) {
|
|
49
|
+
if (!input || !input.trim()) return "";
|
|
50
|
+
const s = input.trim();
|
|
51
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(s)) return s;
|
|
52
|
+
if (/^\d{4}-\d{2}-\d{2}T/.test(s)) return s.slice(0, 10);
|
|
53
|
+
const sepMatch = s.match(/^(\d{1,2})[/\-.](\d{1,2})[/\-.](\d{4})$/);
|
|
54
|
+
if (sepMatch) {
|
|
55
|
+
const a = parseInt(sepMatch[1], 10);
|
|
56
|
+
const b = parseInt(sepMatch[2], 10);
|
|
57
|
+
const year = sepMatch[3];
|
|
58
|
+
let month;
|
|
59
|
+
let day;
|
|
60
|
+
if (a > 12 && b <= 12) {
|
|
61
|
+
day = a;
|
|
62
|
+
month = b;
|
|
63
|
+
} else if (b > 12 && a <= 12) {
|
|
64
|
+
month = a;
|
|
65
|
+
day = b;
|
|
66
|
+
} else {
|
|
67
|
+
month = a;
|
|
68
|
+
day = b;
|
|
69
|
+
}
|
|
70
|
+
if (month >= 1 && month <= 12 && day >= 1 && day <= 31) {
|
|
71
|
+
return `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const ymdSlash = s.match(/^(\d{4})[/\-.](\d{1,2})[/\-.](\d{1,2})$/);
|
|
75
|
+
if (ymdSlash) {
|
|
76
|
+
const year = ymdSlash[1];
|
|
77
|
+
const month = parseInt(ymdSlash[2], 10);
|
|
78
|
+
const day = parseInt(ymdSlash[3], 10);
|
|
79
|
+
if (month >= 1 && month <= 12 && day >= 1 && day <= 31) {
|
|
80
|
+
return `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (/^\d{8}$/.test(s)) {
|
|
84
|
+
const a = parseInt(s.slice(0, 2), 10);
|
|
85
|
+
const b = parseInt(s.slice(2, 4), 10);
|
|
86
|
+
const year = s.slice(4, 8);
|
|
87
|
+
let month;
|
|
88
|
+
let day;
|
|
89
|
+
if (a > 12 && b <= 12) {
|
|
90
|
+
day = a;
|
|
91
|
+
month = b;
|
|
92
|
+
} else {
|
|
93
|
+
month = a;
|
|
94
|
+
day = b;
|
|
95
|
+
}
|
|
96
|
+
if (month >= 1 && month <= 12 && day >= 1 && day <= 31) {
|
|
97
|
+
return `${year}-${String(month).padStart(2, "0")}-${String(day).padStart(2, "0")}`;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
throw new Error(
|
|
101
|
+
`[AppFunnel] Invalid date format: "${input}". Expected a date string like MM/DD/YYYY, DD/MM/YYYY, YYYY-MM-DD, or MMDDYYYY.`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
function toISODateWithFormat(input, format) {
|
|
105
|
+
if (!input || !input.trim()) return "";
|
|
106
|
+
const s = input.trim();
|
|
107
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(s) || /^\d{4}-\d{2}-\d{2}T/.test(s)) {
|
|
108
|
+
return s.slice(0, 10);
|
|
109
|
+
}
|
|
110
|
+
const digits = s.replace(/[^\d]/g, "");
|
|
111
|
+
if (format === "YYYY-MM-DD") {
|
|
112
|
+
const m = s.match(/^(\d{4})[/\-.](\d{1,2})[/\-.](\d{1,2})$/);
|
|
113
|
+
if (m) return `${m[1]}-${m[2].padStart(2, "0")}-${m[3].padStart(2, "0")}`;
|
|
114
|
+
if (digits.length === 8) {
|
|
115
|
+
return `${digits.slice(0, 4)}-${digits.slice(4, 6)}-${digits.slice(6, 8)}`;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (format === "MM/DD/YYYY") {
|
|
119
|
+
const m = s.match(/^(\d{1,2})[/\-.](\d{1,2})[/\-.](\d{4})$/);
|
|
120
|
+
if (m) return `${m[3]}-${m[1].padStart(2, "0")}-${m[2].padStart(2, "0")}`;
|
|
121
|
+
if (digits.length === 8) {
|
|
122
|
+
return `${digits.slice(4, 8)}-${digits.slice(0, 2)}-${digits.slice(2, 4)}`;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
if (format === "DD/MM/YYYY") {
|
|
126
|
+
const m = s.match(/^(\d{1,2})[/\-.](\d{1,2})[/\-.](\d{4})$/);
|
|
127
|
+
if (m) return `${m[3]}-${m[2].padStart(2, "0")}-${m[1].padStart(2, "0")}`;
|
|
128
|
+
if (digits.length === 8) {
|
|
129
|
+
return `${digits.slice(4, 8)}-${digits.slice(2, 4)}-${digits.slice(0, 2)}`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
throw new Error(
|
|
133
|
+
`[AppFunnel] Invalid date format: "${input}". Expected format ${format} (e.g. ${{
|
|
134
|
+
"MM/DD/YYYY": "03/15/1990 or 03151990",
|
|
135
|
+
"DD/MM/YYYY": "15/03/1990 or 15031990",
|
|
136
|
+
"YYYY-MM-DD": "1990-03-15 or 19900315"
|
|
137
|
+
}[format]}).`
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// src/hooks/useUser.ts
|
|
45
142
|
function useUser() {
|
|
46
|
-
const { variableStore } =
|
|
143
|
+
const { variableStore } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
47
144
|
const subscribe = react.useCallback(
|
|
48
145
|
(cb) => variableStore.subscribe(cb, { prefix: "user." }),
|
|
49
146
|
[variableStore]
|
|
@@ -67,14 +164,14 @@ function useUser() {
|
|
|
67
164
|
variableStore.set("user.name", name);
|
|
68
165
|
},
|
|
69
166
|
setDateOfBirth(dateOfBirth) {
|
|
70
|
-
variableStore.set("user.dateOfBirth", dateOfBirth);
|
|
167
|
+
variableStore.set("user.dateOfBirth", toISODate(dateOfBirth));
|
|
71
168
|
}
|
|
72
169
|
}),
|
|
73
170
|
[variables, variableStore]
|
|
74
171
|
);
|
|
75
172
|
}
|
|
76
173
|
function useUserProperty(field) {
|
|
77
|
-
const { variableStore } =
|
|
174
|
+
const { variableStore } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
78
175
|
const key = `user.${field}`;
|
|
79
176
|
const subscribe = react.useCallback(
|
|
80
177
|
(cb) => variableStore.subscribe(cb, { keys: [key] }),
|
|
@@ -91,47 +188,26 @@ function useUserProperty(field) {
|
|
|
91
188
|
);
|
|
92
189
|
return [value, setValue];
|
|
93
190
|
}
|
|
94
|
-
function
|
|
95
|
-
const { variableStore } =
|
|
96
|
-
const
|
|
191
|
+
function useDateOfBirth(format = "MM/DD/YYYY") {
|
|
192
|
+
const { variableStore } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
193
|
+
const key = "user.dateOfBirth";
|
|
97
194
|
const subscribe = react.useCallback(
|
|
98
|
-
(cb) => variableStore.subscribe(cb, { keys: [
|
|
99
|
-
[variableStore
|
|
195
|
+
(cb) => variableStore.subscribe(cb, { keys: [key] }),
|
|
196
|
+
[variableStore]
|
|
100
197
|
);
|
|
101
198
|
const getSnapshot = react.useCallback(
|
|
102
|
-
() => variableStore.get(
|
|
103
|
-
[variableStore
|
|
199
|
+
() => variableStore.get(key) || "",
|
|
200
|
+
[variableStore]
|
|
104
201
|
);
|
|
105
202
|
const value = react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
106
203
|
const setValue = react.useCallback(
|
|
107
|
-
(v) => variableStore.set(
|
|
108
|
-
[variableStore,
|
|
204
|
+
(v) => variableStore.set(key, toISODateWithFormat(v, format)),
|
|
205
|
+
[variableStore, format]
|
|
109
206
|
);
|
|
110
207
|
return [value, setValue];
|
|
111
208
|
}
|
|
112
|
-
function useResponses() {
|
|
113
|
-
const { variableStore } = chunkBUF5FDKC_cjs.useFunnelContext();
|
|
114
|
-
const subscribe = react.useCallback(
|
|
115
|
-
(cb) => variableStore.subscribe(cb, { prefix: "answers." }),
|
|
116
|
-
[variableStore]
|
|
117
|
-
);
|
|
118
|
-
const getSnapshot = react.useCallback(
|
|
119
|
-
() => variableStore.getState(),
|
|
120
|
-
[variableStore]
|
|
121
|
-
);
|
|
122
|
-
const variables = react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
123
|
-
return react.useMemo(() => {
|
|
124
|
-
const result = {};
|
|
125
|
-
for (const [key, value] of Object.entries(variables)) {
|
|
126
|
-
if (key.startsWith("answers.")) {
|
|
127
|
-
result[key.slice(8)] = value;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return result;
|
|
131
|
-
}, [variables]);
|
|
132
|
-
}
|
|
133
209
|
function useQueryParams() {
|
|
134
|
-
const { variableStore } =
|
|
210
|
+
const { variableStore } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
135
211
|
const subscribe = react.useCallback(
|
|
136
212
|
(cb) => variableStore.subscribe(cb, { prefix: "query." }),
|
|
137
213
|
[variableStore]
|
|
@@ -152,7 +228,7 @@ function useQueryParams() {
|
|
|
152
228
|
}, [variables]);
|
|
153
229
|
}
|
|
154
230
|
function useQueryParam(key) {
|
|
155
|
-
const { variableStore } =
|
|
231
|
+
const { variableStore } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
156
232
|
const prefixedKey = `query.${key}`;
|
|
157
233
|
const subscribe = react.useCallback(
|
|
158
234
|
(cb) => variableStore.subscribe(cb, { keys: [prefixedKey] }),
|
|
@@ -165,7 +241,7 @@ function useQueryParam(key) {
|
|
|
165
241
|
return react.useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
|
|
166
242
|
}
|
|
167
243
|
function useData(key) {
|
|
168
|
-
const { variableStore } =
|
|
244
|
+
const { variableStore } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
169
245
|
const prefixedKey = `data.${key}`;
|
|
170
246
|
const subscribe = react.useCallback(
|
|
171
247
|
(cb) => variableStore.subscribe(cb, { keys: [prefixedKey] }),
|
|
@@ -218,7 +294,7 @@ function detect24Hour(locale) {
|
|
|
218
294
|
}
|
|
219
295
|
}
|
|
220
296
|
function useTranslation() {
|
|
221
|
-
const { i18n } =
|
|
297
|
+
const { i18n } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
222
298
|
const subscribe = react.useCallback(
|
|
223
299
|
(cb) => i18n.subscribe(cb),
|
|
224
300
|
[i18n]
|
|
@@ -240,66 +316,8 @@ function useTranslation() {
|
|
|
240
316
|
const availableLocales = i18n.getAvailableLocales();
|
|
241
317
|
return { t, locale, setLocale, availableLocales };
|
|
242
318
|
}
|
|
243
|
-
function useNavigation() {
|
|
244
|
-
const { router, variableStore, tracker } = chunkBUF5FDKC_cjs.useFunnelContext();
|
|
245
|
-
react.useSyncExternalStore(
|
|
246
|
-
react.useCallback((cb) => router.subscribe(cb), [router]),
|
|
247
|
-
react.useCallback(() => router.getSnapshot(), [router]),
|
|
248
|
-
react.useCallback(() => router.getSnapshot(), [router])
|
|
249
|
-
);
|
|
250
|
-
const afterNavigate = react.useCallback((key) => {
|
|
251
|
-
const page = router.getCurrentPage();
|
|
252
|
-
if (page) {
|
|
253
|
-
tracker.track("page.view", {
|
|
254
|
-
pageId: page.key,
|
|
255
|
-
pageKey: page.key,
|
|
256
|
-
pageName: page.name
|
|
257
|
-
});
|
|
258
|
-
tracker.startPageTracking(page.key);
|
|
259
|
-
}
|
|
260
|
-
variableStore.setMany({
|
|
261
|
-
"page.currentId": key,
|
|
262
|
-
"page.currentIndex": router.getPageHistory().length,
|
|
263
|
-
"page.current": router.getPageHistory().length + 1,
|
|
264
|
-
"page.startedAt": Date.now()
|
|
265
|
-
});
|
|
266
|
-
}, [router, tracker, variableStore]);
|
|
267
|
-
const goToNextPage = react.useCallback(() => {
|
|
268
|
-
const previousPage = router.getCurrentPage();
|
|
269
|
-
if (previousPage) {
|
|
270
|
-
tracker.stopPageTracking();
|
|
271
|
-
}
|
|
272
|
-
const variables = variableStore.getState();
|
|
273
|
-
const nextKey = router.goToNextPage(variables);
|
|
274
|
-
if (nextKey) {
|
|
275
|
-
afterNavigate(nextKey);
|
|
276
|
-
}
|
|
277
|
-
}, [router, tracker, variableStore, afterNavigate]);
|
|
278
|
-
const goBack = react.useCallback(() => {
|
|
279
|
-
tracker.stopPageTracking();
|
|
280
|
-
const prevKey = router.goBack();
|
|
281
|
-
if (prevKey) {
|
|
282
|
-
afterNavigate(prevKey);
|
|
283
|
-
}
|
|
284
|
-
}, [router, tracker, afterNavigate]);
|
|
285
|
-
const goToPage = react.useCallback((pageKey) => {
|
|
286
|
-
tracker.stopPageTracking();
|
|
287
|
-
const key = router.goToPage(pageKey);
|
|
288
|
-
if (key) {
|
|
289
|
-
afterNavigate(key);
|
|
290
|
-
}
|
|
291
|
-
}, [router, tracker, afterNavigate]);
|
|
292
|
-
return {
|
|
293
|
-
goToNextPage,
|
|
294
|
-
goBack,
|
|
295
|
-
goToPage,
|
|
296
|
-
currentPage: router.getCurrentPage(),
|
|
297
|
-
pageHistory: router.getPageHistory(),
|
|
298
|
-
progress: router.getProgress()
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
319
|
function useProducts() {
|
|
302
|
-
const { products, variableStore, selectProduct: ctxSelect } =
|
|
320
|
+
const { products, variableStore, selectProduct: ctxSelect } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
303
321
|
const subscribe = react.useCallback(
|
|
304
322
|
(cb) => variableStore.subscribe(cb, { keys: ["products.selectedProductId"] }),
|
|
305
323
|
[variableStore]
|
|
@@ -316,7 +334,7 @@ function useProducts() {
|
|
|
316
334
|
return { products, selected, select };
|
|
317
335
|
}
|
|
318
336
|
function useTracking() {
|
|
319
|
-
const { tracker } =
|
|
337
|
+
const { tracker } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
320
338
|
const track = react.useCallback(
|
|
321
339
|
(eventName, data) => {
|
|
322
340
|
tracker.track(eventName, data);
|
|
@@ -341,7 +359,7 @@ var PAYMENT_KEYS = [
|
|
|
341
359
|
"payment.customerId"
|
|
342
360
|
];
|
|
343
361
|
function usePayment() {
|
|
344
|
-
const { variableStore } =
|
|
362
|
+
const { variableStore } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
345
363
|
const subscribe = react.useCallback(
|
|
346
364
|
(cb) => variableStore.subscribe(cb, { keys: PAYMENT_KEYS }),
|
|
347
365
|
[variableStore]
|
|
@@ -386,7 +404,7 @@ var DEVICE_KEYS = [
|
|
|
386
404
|
"browser.language"
|
|
387
405
|
];
|
|
388
406
|
function useDeviceInfo() {
|
|
389
|
-
const { variableStore } =
|
|
407
|
+
const { variableStore } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
390
408
|
const subscribe = react.useCallback(
|
|
391
409
|
(cb) => variableStore.subscribe(cb, { keys: DEVICE_KEYS }),
|
|
392
410
|
[variableStore]
|
|
@@ -422,6 +440,95 @@ function useDeviceInfo() {
|
|
|
422
440
|
}
|
|
423
441
|
}), [variables]);
|
|
424
442
|
}
|
|
443
|
+
function useSafeArea() {
|
|
444
|
+
const [insets, setInsets] = react.useState({ top: 0, right: 0, bottom: 0, left: 0 });
|
|
445
|
+
react.useEffect(() => {
|
|
446
|
+
if (typeof window === "undefined") return;
|
|
447
|
+
const el = document.createElement("div");
|
|
448
|
+
el.style.cssText = [
|
|
449
|
+
"position:fixed",
|
|
450
|
+
"top:env(safe-area-inset-top,0px)",
|
|
451
|
+
"right:env(safe-area-inset-right,0px)",
|
|
452
|
+
"bottom:env(safe-area-inset-bottom,0px)",
|
|
453
|
+
"left:env(safe-area-inset-left,0px)",
|
|
454
|
+
"pointer-events:none",
|
|
455
|
+
"visibility:hidden",
|
|
456
|
+
"z-index:-1"
|
|
457
|
+
].join(";");
|
|
458
|
+
document.body.appendChild(el);
|
|
459
|
+
function read() {
|
|
460
|
+
const style = getComputedStyle(el);
|
|
461
|
+
setInsets({
|
|
462
|
+
top: parseFloat(style.top) || 0,
|
|
463
|
+
right: parseFloat(style.right) || 0,
|
|
464
|
+
bottom: parseFloat(style.bottom) || 0,
|
|
465
|
+
left: parseFloat(style.left) || 0
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
read();
|
|
469
|
+
const observer = new ResizeObserver(read);
|
|
470
|
+
observer.observe(el);
|
|
471
|
+
window.addEventListener("resize", read);
|
|
472
|
+
return () => {
|
|
473
|
+
observer.disconnect();
|
|
474
|
+
window.removeEventListener("resize", read);
|
|
475
|
+
el.remove();
|
|
476
|
+
};
|
|
477
|
+
}, []);
|
|
478
|
+
return insets;
|
|
479
|
+
}
|
|
480
|
+
function useKeyboard() {
|
|
481
|
+
const [state, setState] = react.useState({ isOpen: false, height: 0 });
|
|
482
|
+
const timeoutRef = react.useRef();
|
|
483
|
+
react.useEffect(() => {
|
|
484
|
+
if (typeof window === "undefined") return;
|
|
485
|
+
if ("virtualKeyboard" in navigator) {
|
|
486
|
+
const vk = navigator.virtualKeyboard;
|
|
487
|
+
vk.overlaysContent = true;
|
|
488
|
+
const handler = () => {
|
|
489
|
+
const h = vk.boundingRect.height;
|
|
490
|
+
setState((prev) => {
|
|
491
|
+
if (prev.height === h && prev.isOpen === h > 0) return prev;
|
|
492
|
+
return { isOpen: h > 0, height: h };
|
|
493
|
+
});
|
|
494
|
+
};
|
|
495
|
+
vk.addEventListener("geometrychange", handler);
|
|
496
|
+
handler();
|
|
497
|
+
return () => vk.removeEventListener("geometrychange", handler);
|
|
498
|
+
}
|
|
499
|
+
const vv = window.visualViewport;
|
|
500
|
+
if (!vv) return;
|
|
501
|
+
let layoutHeight = window.innerHeight;
|
|
502
|
+
function compute() {
|
|
503
|
+
const kbHeight = Math.max(0, layoutHeight - vv.height);
|
|
504
|
+
const h = kbHeight > 40 ? Math.round(kbHeight) : 0;
|
|
505
|
+
setState((prev) => {
|
|
506
|
+
if (prev.height === h && prev.isOpen === h > 0) return prev;
|
|
507
|
+
return { isOpen: h > 0, height: h };
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
function onViewportResize() {
|
|
511
|
+
compute();
|
|
512
|
+
clearTimeout(timeoutRef.current);
|
|
513
|
+
timeoutRef.current = setTimeout(compute, 1e3);
|
|
514
|
+
}
|
|
515
|
+
function onWindowResize() {
|
|
516
|
+
layoutHeight = window.innerHeight;
|
|
517
|
+
compute();
|
|
518
|
+
}
|
|
519
|
+
vv.addEventListener("resize", onViewportResize);
|
|
520
|
+
window.addEventListener("resize", onWindowResize);
|
|
521
|
+
window.addEventListener("orientationchange", onWindowResize);
|
|
522
|
+
compute();
|
|
523
|
+
return () => {
|
|
524
|
+
clearTimeout(timeoutRef.current);
|
|
525
|
+
vv.removeEventListener("resize", onViewportResize);
|
|
526
|
+
window.removeEventListener("resize", onWindowResize);
|
|
527
|
+
window.removeEventListener("orientationchange", onWindowResize);
|
|
528
|
+
};
|
|
529
|
+
}, []);
|
|
530
|
+
return state;
|
|
531
|
+
}
|
|
425
532
|
var PAGE_KEYS = [
|
|
426
533
|
"page.currentId",
|
|
427
534
|
"page.currentIndex",
|
|
@@ -431,7 +538,7 @@ var PAGE_KEYS = [
|
|
|
431
538
|
"page.startedAt"
|
|
432
539
|
];
|
|
433
540
|
function usePageData() {
|
|
434
|
-
const { variableStore } =
|
|
541
|
+
const { variableStore } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
435
542
|
const subscribe = react.useCallback(
|
|
436
543
|
(cb) => variableStore.subscribe(cb, { keys: PAGE_KEYS }),
|
|
437
544
|
[variableStore]
|
|
@@ -453,16 +560,16 @@ function usePageData() {
|
|
|
453
560
|
|
|
454
561
|
// src/hooks/useFunnel.ts
|
|
455
562
|
function useFunnel() {
|
|
456
|
-
const { funnelId, campaignId, tracker } =
|
|
563
|
+
const { funnelId, campaignId, tracker } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
457
564
|
return {
|
|
458
565
|
funnelId,
|
|
459
566
|
campaignId,
|
|
460
567
|
sessionId: tracker.getSessionId(),
|
|
461
568
|
variables: useVariables(),
|
|
462
569
|
user: useUser(),
|
|
463
|
-
responses: useResponses(),
|
|
570
|
+
responses: chunkXP44I2MU_cjs.useResponses(),
|
|
464
571
|
queryParams: useQueryParams(),
|
|
465
|
-
navigation: useNavigation(),
|
|
572
|
+
navigation: chunkXP44I2MU_cjs.useNavigation(),
|
|
466
573
|
products: useProducts(),
|
|
467
574
|
tracking: useTracking(),
|
|
468
575
|
payment: usePayment()
|
|
@@ -474,7 +581,7 @@ var InnerPaymentForm = react.forwardRef(
|
|
|
474
581
|
const stripe = reactStripeJs.useStripe();
|
|
475
582
|
const elements = reactStripeJs.useElements();
|
|
476
583
|
const [error, setError] = react.useState(null);
|
|
477
|
-
const { variableStore, campaignId, tracker, products } =
|
|
584
|
+
const { variableStore, campaignId, tracker, products } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
478
585
|
const readyFired = react.useRef(false);
|
|
479
586
|
react.useEffect(() => {
|
|
480
587
|
if (stripe && elements && !readyFired.current) {
|
|
@@ -614,7 +721,7 @@ var StripePaymentForm = react.forwardRef(
|
|
|
614
721
|
appearance,
|
|
615
722
|
layout
|
|
616
723
|
}, ref) {
|
|
617
|
-
const { campaignId, tracker, variableStore, products } =
|
|
724
|
+
const { campaignId, tracker, variableStore, products } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
618
725
|
const [email] = useVariable("user.email");
|
|
619
726
|
const validateOnly = mode === "validate-only";
|
|
620
727
|
const product = react.useMemo(() => {
|
|
@@ -751,7 +858,7 @@ function PaddleCheckout({
|
|
|
751
858
|
onError,
|
|
752
859
|
className
|
|
753
860
|
}) {
|
|
754
|
-
const { variableStore, tracker, products } =
|
|
861
|
+
const { variableStore, tracker, products } = chunkEVUYCLVY_cjs.useFunnelContext();
|
|
755
862
|
const containerRef = react.useRef(null);
|
|
756
863
|
const initializedRef = react.useRef(false);
|
|
757
864
|
const product = productId ? products.find((p) => p.id === productId) : products.find((p) => p.id === variableStore.get("products.selectedProductId"));
|
|
@@ -808,30 +915,42 @@ function PaddleCheckout({
|
|
|
808
915
|
return null;
|
|
809
916
|
}
|
|
810
917
|
|
|
918
|
+
Object.defineProperty(exports, "useNavigation", {
|
|
919
|
+
enumerable: true,
|
|
920
|
+
get: function () { return chunkXP44I2MU_cjs.useNavigation; }
|
|
921
|
+
});
|
|
922
|
+
Object.defineProperty(exports, "useResponse", {
|
|
923
|
+
enumerable: true,
|
|
924
|
+
get: function () { return chunkXP44I2MU_cjs.useResponse; }
|
|
925
|
+
});
|
|
926
|
+
Object.defineProperty(exports, "useResponses", {
|
|
927
|
+
enumerable: true,
|
|
928
|
+
get: function () { return chunkXP44I2MU_cjs.useResponses; }
|
|
929
|
+
});
|
|
811
930
|
Object.defineProperty(exports, "FunnelProvider", {
|
|
812
931
|
enumerable: true,
|
|
813
|
-
get: function () { return
|
|
932
|
+
get: function () { return chunkEVUYCLVY_cjs.FunnelProvider; }
|
|
814
933
|
});
|
|
815
934
|
Object.defineProperty(exports, "registerIntegration", {
|
|
816
935
|
enumerable: true,
|
|
817
|
-
get: function () { return
|
|
936
|
+
get: function () { return chunkEVUYCLVY_cjs.registerIntegration; }
|
|
818
937
|
});
|
|
819
938
|
exports.PaddleCheckout = PaddleCheckout;
|
|
820
939
|
exports.StripePaymentForm = StripePaymentForm;
|
|
821
940
|
exports.defineConfig = defineConfig;
|
|
822
941
|
exports.definePage = definePage;
|
|
823
942
|
exports.useData = useData;
|
|
943
|
+
exports.useDateOfBirth = useDateOfBirth;
|
|
824
944
|
exports.useDeviceInfo = useDeviceInfo;
|
|
825
945
|
exports.useFunnel = useFunnel;
|
|
946
|
+
exports.useKeyboard = useKeyboard;
|
|
826
947
|
exports.useLocale = useLocale;
|
|
827
|
-
exports.useNavigation = useNavigation;
|
|
828
948
|
exports.usePageData = usePageData;
|
|
829
949
|
exports.usePayment = usePayment;
|
|
830
950
|
exports.useProducts = useProducts;
|
|
831
951
|
exports.useQueryParam = useQueryParam;
|
|
832
952
|
exports.useQueryParams = useQueryParams;
|
|
833
|
-
exports.
|
|
834
|
-
exports.useResponses = useResponses;
|
|
953
|
+
exports.useSafeArea = useSafeArea;
|
|
835
954
|
exports.useTracking = useTracking;
|
|
836
955
|
exports.useTranslation = useTranslation;
|
|
837
956
|
exports.useUser = useUser;
|