@appfunnel-dev/sdk 0.5.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-EVUYCLVY.cjs +1326 -0
- package/dist/chunk-EVUYCLVY.cjs.map +1 -0
- package/dist/chunk-H3KHXZSI.js +1321 -0
- 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 +590 -371
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +132 -14
- package/dist/index.d.ts +132 -14
- package/dist/index.js +555 -355
- package/dist/index.js.map +1 -1
- package/dist/internal-C7seLJBr.d.cts +516 -0
- package/dist/internal-C7seLJBr.d.ts +516 -0
- package/dist/internal.cjs +5 -1196
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +2 -204
- package/dist/internal.d.ts +2 -204
- package/dist/internal.js +1 -1199
- package/dist/internal.js.map +1 -1
- package/package.json +17 -2
- package/dist/types-ChorYUCl.d.cts +0 -255
- package/dist/types-ChorYUCl.d.ts +0 -255
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { A as AppFunnelConfig, P as PageDefinition, V as VariableValue, U as UserState, L as LocaleState, T as TranslationState, N as NavigationState, a as ProductsState, b as TrackingState, c as PaymentState, F as FunnelState } from './
|
|
2
|
-
export { C as ConditionConfig,
|
|
3
|
-
import * as
|
|
1
|
+
import { A as AppFunnelConfig, P as PageDefinition, V as VariableValue, U as UserState, L as LocaleState, T as TranslationState, N as NavigationState, a as ProductsState, b as TrackingState, c as PaymentState, D as DeviceInfo, d as PageData, F as FunnelState } from './internal-C7seLJBr.cjs';
|
|
2
|
+
export { C as ConditionConfig, e as ConditionGroupConfig, f as FunnelProvider, g as FunnelProviderProps, h as FunnelSettings, i as PageConfig, j as PageState, k as PageType, l as ProductConfig, m as ProductsConfig, n as Progress, R as RouteConfig, o as RuntimeProduct, p as VariableConfig, q as VariableType } from './internal-C7seLJBr.cjs';
|
|
3
|
+
import * as react from 'react';
|
|
4
4
|
import { Appearance } from '@stripe/stripe-js';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Type helper for appfunnel.config.ts.
|
|
@@ -39,6 +40,9 @@ declare function definePage(definition: PageDefinition): PageDefinition;
|
|
|
39
40
|
/**
|
|
40
41
|
* Read/write a single variable.
|
|
41
42
|
*
|
|
43
|
+
* **Advanced** — this hook is not intended for normal page usage.
|
|
44
|
+
* Prefer accessing variables through the standard page props instead.
|
|
45
|
+
*
|
|
42
46
|
* ```tsx
|
|
43
47
|
* const [email, setEmail] = useVariable<string>('email')
|
|
44
48
|
* const [count, setCount] = useVariable<number>('count')
|
|
@@ -51,12 +55,21 @@ declare function useVariable<T extends VariableValue>(id: string): [T, (value: T
|
|
|
51
55
|
/**
|
|
52
56
|
* Read all variables (including system variables). Read-only.
|
|
53
57
|
* Use useVariable() to write individual variables.
|
|
58
|
+
*
|
|
59
|
+
* **Advanced** — this hook is not intended for normal page usage.
|
|
60
|
+
* Prefer accessing variables through the standard page props instead.
|
|
61
|
+
*
|
|
62
|
+
* Warning: this hook subscribes to ALL variable changes, so the
|
|
63
|
+
* component will re-render on every single variable update.
|
|
54
64
|
*/
|
|
55
65
|
declare function useVariables(): Record<string, VariableValue>;
|
|
56
66
|
|
|
67
|
+
type DateFormat = 'MM/DD/YYYY' | 'DD/MM/YYYY' | 'YYYY-MM-DD';
|
|
68
|
+
|
|
57
69
|
/**
|
|
58
70
|
* Read built-in user state (email, name, customerId).
|
|
59
71
|
*
|
|
72
|
+
* Only re-renders when a `user.*` variable changes.
|
|
60
73
|
* For reading/writing arbitrary user fields, use `useUserProperty('fieldName')`.
|
|
61
74
|
*/
|
|
62
75
|
declare function useUser(): UserState;
|
|
@@ -70,6 +83,21 @@ declare function useUser(): UserState;
|
|
|
70
83
|
* ```
|
|
71
84
|
*/
|
|
72
85
|
declare function useUserProperty(field: string): [string, (value: string) => void];
|
|
86
|
+
/**
|
|
87
|
+
* Read/write the user's date of birth.
|
|
88
|
+
* Always stores the value as YYYY-MM-DD regardless of input format.
|
|
89
|
+
*
|
|
90
|
+
* @param format - How the input string should be interpreted (default: MM/DD/YYYY).
|
|
91
|
+
*
|
|
92
|
+
* ```tsx
|
|
93
|
+
* const [dob, setDob] = useDateOfBirth() // defaults to MM/DD/YYYY
|
|
94
|
+
* const [dob, setDob] = useDateOfBirth('DD/MM/YYYY') // explicit EU format
|
|
95
|
+
*
|
|
96
|
+
* setDob('03/15/1990') // stored as "1990-03-15"
|
|
97
|
+
* setDob('03151990') // stored as "1990-03-15"
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
declare function useDateOfBirth(format?: DateFormat): [string, (value: string) => void];
|
|
73
101
|
|
|
74
102
|
/**
|
|
75
103
|
* Read/write a single response variable (answers.*).
|
|
@@ -83,6 +111,8 @@ declare function useResponse<T extends VariableValue>(key: string): [T, (value:
|
|
|
83
111
|
/**
|
|
84
112
|
* Read all response variables as a flat object (without the `answers.` prefix).
|
|
85
113
|
*
|
|
114
|
+
* Only re-renders when an `answers.*` variable changes.
|
|
115
|
+
*
|
|
86
116
|
* ```tsx
|
|
87
117
|
* const responses = useResponses()
|
|
88
118
|
* // { goal: 'weight_loss', interests: ['yoga', 'running'] }
|
|
@@ -93,10 +123,7 @@ declare function useResponses(): Record<string, VariableValue>;
|
|
|
93
123
|
/**
|
|
94
124
|
* Read all URL query parameters as a flat object (without the `query.` prefix).
|
|
95
125
|
*
|
|
96
|
-
* `query.*`
|
|
97
|
-
* e.g. `?utm_source=google&ref=abc` → `{ utm_source: 'google', ref: 'abc' }`.
|
|
98
|
-
*
|
|
99
|
-
* These are read-only from the developer's perspective — they come from the URL.
|
|
126
|
+
* Only re-renders when a `query.*` variable changes.
|
|
100
127
|
*/
|
|
101
128
|
declare function useQueryParams(): Record<string, string>;
|
|
102
129
|
/**
|
|
@@ -149,11 +176,16 @@ declare function useTranslation(): TranslationState;
|
|
|
149
176
|
|
|
150
177
|
/**
|
|
151
178
|
* Navigation hook — evaluates routes, navigates between pages, tracks progress.
|
|
179
|
+
*
|
|
180
|
+
* Only re-renders when the router's current page changes (not on variable changes).
|
|
181
|
+
* Variables are read lazily at navigation time — callbacks are referentially stable.
|
|
152
182
|
*/
|
|
153
183
|
declare function useNavigation(): NavigationState;
|
|
154
184
|
|
|
155
185
|
/**
|
|
156
186
|
* Products hook — access product list, selected product, and selection handler.
|
|
187
|
+
*
|
|
188
|
+
* Only re-renders when `products.selectedProductId` changes.
|
|
157
189
|
*/
|
|
158
190
|
declare function useProducts(): ProductsState;
|
|
159
191
|
|
|
@@ -163,33 +195,119 @@ declare function useProducts(): ProductsState;
|
|
|
163
195
|
declare function useTracking(): TrackingState;
|
|
164
196
|
|
|
165
197
|
/**
|
|
166
|
-
* Payment hook — reads payment-related
|
|
198
|
+
* Payment hook — reads payment-related variables.
|
|
199
|
+
*
|
|
200
|
+
* Only re-renders when payment/card variables change.
|
|
167
201
|
*/
|
|
168
202
|
declare function usePayment(): PaymentState;
|
|
169
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Read device, browser, and OS metadata.
|
|
206
|
+
*
|
|
207
|
+
* These values are set once on mount and don't change, so this hook
|
|
208
|
+
* will rarely (if ever) re-render.
|
|
209
|
+
*
|
|
210
|
+
* ```tsx
|
|
211
|
+
* const { device, browser, os } = useDeviceInfo()
|
|
212
|
+
* if (device.isMobile) { ... }
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
declare function useDeviceInfo(): DeviceInfo;
|
|
216
|
+
|
|
217
|
+
interface SafeAreaInsets {
|
|
218
|
+
top: number;
|
|
219
|
+
right: number;
|
|
220
|
+
bottom: number;
|
|
221
|
+
left: number;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Returns the current safe-area insets (in px) from `env(safe-area-inset-*)`.
|
|
225
|
+
*
|
|
226
|
+
* Useful for positioning fixed elements above the Safari home-indicator bar.
|
|
227
|
+
*
|
|
228
|
+
* ```tsx
|
|
229
|
+
* const { bottom } = useSafeArea()
|
|
230
|
+
* <div style={{ position: 'fixed', bottom: 0, paddingBottom: bottom }} />
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
declare function useSafeArea(): SafeAreaInsets;
|
|
234
|
+
|
|
235
|
+
interface KeyboardState {
|
|
236
|
+
/** Whether the virtual keyboard is currently visible */
|
|
237
|
+
isOpen: boolean;
|
|
238
|
+
/** Height of the keyboard in pixels (0 when closed) */
|
|
239
|
+
height: number;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Detects the virtual keyboard on mobile devices.
|
|
243
|
+
*
|
|
244
|
+
* Uses the VirtualKeyboard API where available, with a
|
|
245
|
+
* visualViewport fallback for Safari/older browsers.
|
|
246
|
+
*
|
|
247
|
+
* The visualViewport path follows the approach described at
|
|
248
|
+
* https://martijnhols.nl/blog/how-to-get-document-height-ios-safari-osk
|
|
249
|
+
* to handle iOS Safari's delayed viewport updates on keyboard close.
|
|
250
|
+
*
|
|
251
|
+
* ```tsx
|
|
252
|
+
* const { isOpen, height } = useKeyboard()
|
|
253
|
+
* <div style={{ position: 'fixed', bottom: isOpen ? height : 0 }} />
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
declare function useKeyboard(): KeyboardState;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Read page-level system variables.
|
|
260
|
+
*
|
|
261
|
+
* Re-renders when page variables change (e.g. on navigation).
|
|
262
|
+
*
|
|
263
|
+
* ```tsx
|
|
264
|
+
* const { currentId, progressPercentage, startedAt } = usePageData()
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
declare function usePageData(): PageData;
|
|
268
|
+
|
|
170
269
|
/**
|
|
171
270
|
* Convenience hook that combines all SDK hooks.
|
|
172
271
|
* Useful for simple funnels where you don't want multiple hook imports.
|
|
173
272
|
*/
|
|
174
273
|
declare function useFunnel(): FunnelState;
|
|
175
274
|
|
|
176
|
-
interface
|
|
275
|
+
interface StripePaymentHandle {
|
|
276
|
+
/** Programmatically submit the payment form */
|
|
277
|
+
submit: () => Promise<void>;
|
|
278
|
+
}
|
|
279
|
+
interface StripePaymentFormProps {
|
|
177
280
|
/** Product ID override (default: currently selected product) */
|
|
178
281
|
productId?: string;
|
|
179
282
|
/** "checkout" for full payment, "validate-only" to just collect card */
|
|
180
283
|
mode?: 'checkout' | 'validate-only';
|
|
284
|
+
/** "elements" for PaymentElement, "embedded" for Stripe Embedded Checkout */
|
|
285
|
+
variant?: 'elements' | 'embedded';
|
|
181
286
|
/** Called on successful payment */
|
|
182
287
|
onSuccess?: () => void;
|
|
183
288
|
/** Called on payment error */
|
|
184
289
|
onError?: (error: string) => void;
|
|
185
|
-
/**
|
|
186
|
-
|
|
290
|
+
/** Called when the Stripe form is ready to accept submissions */
|
|
291
|
+
onReady?: () => void;
|
|
187
292
|
/** Additional CSS class */
|
|
188
293
|
className?: string;
|
|
189
|
-
/** Stripe Appearance override */
|
|
294
|
+
/** Stripe Appearance override (elements variant only) */
|
|
190
295
|
appearance?: Appearance;
|
|
296
|
+
/** PaymentElement layout option (default: 'tabs') */
|
|
297
|
+
layout?: 'tabs' | 'accordion' | 'auto';
|
|
191
298
|
}
|
|
192
|
-
|
|
299
|
+
/**
|
|
300
|
+
* Stripe payment component supporting PaymentElement and Embedded Checkout.
|
|
301
|
+
*
|
|
302
|
+
* Use a ref to submit the form from an external button:
|
|
303
|
+
* ```tsx
|
|
304
|
+
* const paymentRef = useRef<StripePaymentHandle>(null)
|
|
305
|
+
*
|
|
306
|
+
* <StripePaymentForm ref={paymentRef} onSuccess={goToNextPage} />
|
|
307
|
+
* <button onClick={() => paymentRef.current?.submit()}>Pay Now</button>
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
declare const StripePaymentForm: react.ForwardRefExoticComponent<StripePaymentFormProps & react.RefAttributes<StripePaymentHandle>>;
|
|
193
311
|
|
|
194
312
|
interface PaddleCheckoutProps {
|
|
195
313
|
/** Product ID to checkout (default: currently selected product) */
|
|
@@ -237,4 +355,4 @@ type IntegrationLoader = (config: Record<string, unknown>) => void;
|
|
|
237
355
|
*/
|
|
238
356
|
declare function registerIntegration(id: string, loader: IntegrationLoader): void;
|
|
239
357
|
|
|
240
|
-
export { AppFunnelConfig, FunnelState, type IntegrationConfigs, LocaleState, NavigationState, PaddleCheckout, type PaddleCheckoutProps, PageDefinition,
|
|
358
|
+
export { AppFunnelConfig, type DateFormat, DeviceInfo, FunnelState, type IntegrationConfigs, type KeyboardState, LocaleState, NavigationState, PaddleCheckout, type PaddleCheckoutProps, PageData, PageDefinition, PaymentState, ProductsState, type SafeAreaInsets, StripePaymentForm, type StripePaymentFormProps, type StripePaymentHandle, TrackingState, TranslationState, UserState, VariableValue, defineConfig, definePage, registerIntegration, useData, useDateOfBirth, useDeviceInfo, useFunnel, useKeyboard, useLocale, useNavigation, usePageData, usePayment, useProducts, useQueryParam, useQueryParams, useResponse, useResponses, useSafeArea, useTracking, useTranslation, useUser, useUserProperty, useVariable, useVariables };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { A as AppFunnelConfig, P as PageDefinition, V as VariableValue, U as UserState, L as LocaleState, T as TranslationState, N as NavigationState, a as ProductsState, b as TrackingState, c as PaymentState, F as FunnelState } from './
|
|
2
|
-
export { C as ConditionConfig,
|
|
3
|
-
import * as
|
|
1
|
+
import { A as AppFunnelConfig, P as PageDefinition, V as VariableValue, U as UserState, L as LocaleState, T as TranslationState, N as NavigationState, a as ProductsState, b as TrackingState, c as PaymentState, D as DeviceInfo, d as PageData, F as FunnelState } from './internal-C7seLJBr.js';
|
|
2
|
+
export { C as ConditionConfig, e as ConditionGroupConfig, f as FunnelProvider, g as FunnelProviderProps, h as FunnelSettings, i as PageConfig, j as PageState, k as PageType, l as ProductConfig, m as ProductsConfig, n as Progress, R as RouteConfig, o as RuntimeProduct, p as VariableConfig, q as VariableType } from './internal-C7seLJBr.js';
|
|
3
|
+
import * as react from 'react';
|
|
4
4
|
import { Appearance } from '@stripe/stripe-js';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Type helper for appfunnel.config.ts.
|
|
@@ -39,6 +40,9 @@ declare function definePage(definition: PageDefinition): PageDefinition;
|
|
|
39
40
|
/**
|
|
40
41
|
* Read/write a single variable.
|
|
41
42
|
*
|
|
43
|
+
* **Advanced** — this hook is not intended for normal page usage.
|
|
44
|
+
* Prefer accessing variables through the standard page props instead.
|
|
45
|
+
*
|
|
42
46
|
* ```tsx
|
|
43
47
|
* const [email, setEmail] = useVariable<string>('email')
|
|
44
48
|
* const [count, setCount] = useVariable<number>('count')
|
|
@@ -51,12 +55,21 @@ declare function useVariable<T extends VariableValue>(id: string): [T, (value: T
|
|
|
51
55
|
/**
|
|
52
56
|
* Read all variables (including system variables). Read-only.
|
|
53
57
|
* Use useVariable() to write individual variables.
|
|
58
|
+
*
|
|
59
|
+
* **Advanced** — this hook is not intended for normal page usage.
|
|
60
|
+
* Prefer accessing variables through the standard page props instead.
|
|
61
|
+
*
|
|
62
|
+
* Warning: this hook subscribes to ALL variable changes, so the
|
|
63
|
+
* component will re-render on every single variable update.
|
|
54
64
|
*/
|
|
55
65
|
declare function useVariables(): Record<string, VariableValue>;
|
|
56
66
|
|
|
67
|
+
type DateFormat = 'MM/DD/YYYY' | 'DD/MM/YYYY' | 'YYYY-MM-DD';
|
|
68
|
+
|
|
57
69
|
/**
|
|
58
70
|
* Read built-in user state (email, name, customerId).
|
|
59
71
|
*
|
|
72
|
+
* Only re-renders when a `user.*` variable changes.
|
|
60
73
|
* For reading/writing arbitrary user fields, use `useUserProperty('fieldName')`.
|
|
61
74
|
*/
|
|
62
75
|
declare function useUser(): UserState;
|
|
@@ -70,6 +83,21 @@ declare function useUser(): UserState;
|
|
|
70
83
|
* ```
|
|
71
84
|
*/
|
|
72
85
|
declare function useUserProperty(field: string): [string, (value: string) => void];
|
|
86
|
+
/**
|
|
87
|
+
* Read/write the user's date of birth.
|
|
88
|
+
* Always stores the value as YYYY-MM-DD regardless of input format.
|
|
89
|
+
*
|
|
90
|
+
* @param format - How the input string should be interpreted (default: MM/DD/YYYY).
|
|
91
|
+
*
|
|
92
|
+
* ```tsx
|
|
93
|
+
* const [dob, setDob] = useDateOfBirth() // defaults to MM/DD/YYYY
|
|
94
|
+
* const [dob, setDob] = useDateOfBirth('DD/MM/YYYY') // explicit EU format
|
|
95
|
+
*
|
|
96
|
+
* setDob('03/15/1990') // stored as "1990-03-15"
|
|
97
|
+
* setDob('03151990') // stored as "1990-03-15"
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
declare function useDateOfBirth(format?: DateFormat): [string, (value: string) => void];
|
|
73
101
|
|
|
74
102
|
/**
|
|
75
103
|
* Read/write a single response variable (answers.*).
|
|
@@ -83,6 +111,8 @@ declare function useResponse<T extends VariableValue>(key: string): [T, (value:
|
|
|
83
111
|
/**
|
|
84
112
|
* Read all response variables as a flat object (without the `answers.` prefix).
|
|
85
113
|
*
|
|
114
|
+
* Only re-renders when an `answers.*` variable changes.
|
|
115
|
+
*
|
|
86
116
|
* ```tsx
|
|
87
117
|
* const responses = useResponses()
|
|
88
118
|
* // { goal: 'weight_loss', interests: ['yoga', 'running'] }
|
|
@@ -93,10 +123,7 @@ declare function useResponses(): Record<string, VariableValue>;
|
|
|
93
123
|
/**
|
|
94
124
|
* Read all URL query parameters as a flat object (without the `query.` prefix).
|
|
95
125
|
*
|
|
96
|
-
* `query.*`
|
|
97
|
-
* e.g. `?utm_source=google&ref=abc` → `{ utm_source: 'google', ref: 'abc' }`.
|
|
98
|
-
*
|
|
99
|
-
* These are read-only from the developer's perspective — they come from the URL.
|
|
126
|
+
* Only re-renders when a `query.*` variable changes.
|
|
100
127
|
*/
|
|
101
128
|
declare function useQueryParams(): Record<string, string>;
|
|
102
129
|
/**
|
|
@@ -149,11 +176,16 @@ declare function useTranslation(): TranslationState;
|
|
|
149
176
|
|
|
150
177
|
/**
|
|
151
178
|
* Navigation hook — evaluates routes, navigates between pages, tracks progress.
|
|
179
|
+
*
|
|
180
|
+
* Only re-renders when the router's current page changes (not on variable changes).
|
|
181
|
+
* Variables are read lazily at navigation time — callbacks are referentially stable.
|
|
152
182
|
*/
|
|
153
183
|
declare function useNavigation(): NavigationState;
|
|
154
184
|
|
|
155
185
|
/**
|
|
156
186
|
* Products hook — access product list, selected product, and selection handler.
|
|
187
|
+
*
|
|
188
|
+
* Only re-renders when `products.selectedProductId` changes.
|
|
157
189
|
*/
|
|
158
190
|
declare function useProducts(): ProductsState;
|
|
159
191
|
|
|
@@ -163,33 +195,119 @@ declare function useProducts(): ProductsState;
|
|
|
163
195
|
declare function useTracking(): TrackingState;
|
|
164
196
|
|
|
165
197
|
/**
|
|
166
|
-
* Payment hook — reads payment-related
|
|
198
|
+
* Payment hook — reads payment-related variables.
|
|
199
|
+
*
|
|
200
|
+
* Only re-renders when payment/card variables change.
|
|
167
201
|
*/
|
|
168
202
|
declare function usePayment(): PaymentState;
|
|
169
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Read device, browser, and OS metadata.
|
|
206
|
+
*
|
|
207
|
+
* These values are set once on mount and don't change, so this hook
|
|
208
|
+
* will rarely (if ever) re-render.
|
|
209
|
+
*
|
|
210
|
+
* ```tsx
|
|
211
|
+
* const { device, browser, os } = useDeviceInfo()
|
|
212
|
+
* if (device.isMobile) { ... }
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
declare function useDeviceInfo(): DeviceInfo;
|
|
216
|
+
|
|
217
|
+
interface SafeAreaInsets {
|
|
218
|
+
top: number;
|
|
219
|
+
right: number;
|
|
220
|
+
bottom: number;
|
|
221
|
+
left: number;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Returns the current safe-area insets (in px) from `env(safe-area-inset-*)`.
|
|
225
|
+
*
|
|
226
|
+
* Useful for positioning fixed elements above the Safari home-indicator bar.
|
|
227
|
+
*
|
|
228
|
+
* ```tsx
|
|
229
|
+
* const { bottom } = useSafeArea()
|
|
230
|
+
* <div style={{ position: 'fixed', bottom: 0, paddingBottom: bottom }} />
|
|
231
|
+
* ```
|
|
232
|
+
*/
|
|
233
|
+
declare function useSafeArea(): SafeAreaInsets;
|
|
234
|
+
|
|
235
|
+
interface KeyboardState {
|
|
236
|
+
/** Whether the virtual keyboard is currently visible */
|
|
237
|
+
isOpen: boolean;
|
|
238
|
+
/** Height of the keyboard in pixels (0 when closed) */
|
|
239
|
+
height: number;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Detects the virtual keyboard on mobile devices.
|
|
243
|
+
*
|
|
244
|
+
* Uses the VirtualKeyboard API where available, with a
|
|
245
|
+
* visualViewport fallback for Safari/older browsers.
|
|
246
|
+
*
|
|
247
|
+
* The visualViewport path follows the approach described at
|
|
248
|
+
* https://martijnhols.nl/blog/how-to-get-document-height-ios-safari-osk
|
|
249
|
+
* to handle iOS Safari's delayed viewport updates on keyboard close.
|
|
250
|
+
*
|
|
251
|
+
* ```tsx
|
|
252
|
+
* const { isOpen, height } = useKeyboard()
|
|
253
|
+
* <div style={{ position: 'fixed', bottom: isOpen ? height : 0 }} />
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
declare function useKeyboard(): KeyboardState;
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* Read page-level system variables.
|
|
260
|
+
*
|
|
261
|
+
* Re-renders when page variables change (e.g. on navigation).
|
|
262
|
+
*
|
|
263
|
+
* ```tsx
|
|
264
|
+
* const { currentId, progressPercentage, startedAt } = usePageData()
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
declare function usePageData(): PageData;
|
|
268
|
+
|
|
170
269
|
/**
|
|
171
270
|
* Convenience hook that combines all SDK hooks.
|
|
172
271
|
* Useful for simple funnels where you don't want multiple hook imports.
|
|
173
272
|
*/
|
|
174
273
|
declare function useFunnel(): FunnelState;
|
|
175
274
|
|
|
176
|
-
interface
|
|
275
|
+
interface StripePaymentHandle {
|
|
276
|
+
/** Programmatically submit the payment form */
|
|
277
|
+
submit: () => Promise<void>;
|
|
278
|
+
}
|
|
279
|
+
interface StripePaymentFormProps {
|
|
177
280
|
/** Product ID override (default: currently selected product) */
|
|
178
281
|
productId?: string;
|
|
179
282
|
/** "checkout" for full payment, "validate-only" to just collect card */
|
|
180
283
|
mode?: 'checkout' | 'validate-only';
|
|
284
|
+
/** "elements" for PaymentElement, "embedded" for Stripe Embedded Checkout */
|
|
285
|
+
variant?: 'elements' | 'embedded';
|
|
181
286
|
/** Called on successful payment */
|
|
182
287
|
onSuccess?: () => void;
|
|
183
288
|
/** Called on payment error */
|
|
184
289
|
onError?: (error: string) => void;
|
|
185
|
-
/**
|
|
186
|
-
|
|
290
|
+
/** Called when the Stripe form is ready to accept submissions */
|
|
291
|
+
onReady?: () => void;
|
|
187
292
|
/** Additional CSS class */
|
|
188
293
|
className?: string;
|
|
189
|
-
/** Stripe Appearance override */
|
|
294
|
+
/** Stripe Appearance override (elements variant only) */
|
|
190
295
|
appearance?: Appearance;
|
|
296
|
+
/** PaymentElement layout option (default: 'tabs') */
|
|
297
|
+
layout?: 'tabs' | 'accordion' | 'auto';
|
|
191
298
|
}
|
|
192
|
-
|
|
299
|
+
/**
|
|
300
|
+
* Stripe payment component supporting PaymentElement and Embedded Checkout.
|
|
301
|
+
*
|
|
302
|
+
* Use a ref to submit the form from an external button:
|
|
303
|
+
* ```tsx
|
|
304
|
+
* const paymentRef = useRef<StripePaymentHandle>(null)
|
|
305
|
+
*
|
|
306
|
+
* <StripePaymentForm ref={paymentRef} onSuccess={goToNextPage} />
|
|
307
|
+
* <button onClick={() => paymentRef.current?.submit()}>Pay Now</button>
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
declare const StripePaymentForm: react.ForwardRefExoticComponent<StripePaymentFormProps & react.RefAttributes<StripePaymentHandle>>;
|
|
193
311
|
|
|
194
312
|
interface PaddleCheckoutProps {
|
|
195
313
|
/** Product ID to checkout (default: currently selected product) */
|
|
@@ -237,4 +355,4 @@ type IntegrationLoader = (config: Record<string, unknown>) => void;
|
|
|
237
355
|
*/
|
|
238
356
|
declare function registerIntegration(id: string, loader: IntegrationLoader): void;
|
|
239
357
|
|
|
240
|
-
export { AppFunnelConfig, FunnelState, type IntegrationConfigs, LocaleState, NavigationState, PaddleCheckout, type PaddleCheckoutProps, PageDefinition,
|
|
358
|
+
export { AppFunnelConfig, type DateFormat, DeviceInfo, FunnelState, type IntegrationConfigs, type KeyboardState, LocaleState, NavigationState, PaddleCheckout, type PaddleCheckoutProps, PageData, PageDefinition, PaymentState, ProductsState, type SafeAreaInsets, StripePaymentForm, type StripePaymentFormProps, type StripePaymentHandle, TrackingState, TranslationState, UserState, VariableValue, defineConfig, definePage, registerIntegration, useData, useDateOfBirth, useDeviceInfo, useFunnel, useKeyboard, useLocale, useNavigation, usePageData, usePayment, useProducts, useQueryParam, useQueryParams, useResponse, useResponses, useSafeArea, useTracking, useTranslation, useUser, useUserProperty, useVariable, useVariables };
|