@quantaroute/checkout 1.4.1 → 1.4.3
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/CHANGELOG.md +26 -0
- package/README.md +9 -0
- package/dist/lib/index.d.ts +33 -0
- package/dist/lib/quantaroute-checkout.es.js +117 -114
- package/dist/lib/quantaroute-checkout.umd.js +136 -133
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/AddressForm.native.tsx +55 -1
- package/src/components/AddressForm.tsx +39 -1
- package/src/components/CheckoutWidget.tsx +78 -26
- package/src/components/MapPinSelector.native.tsx +3 -3
- package/src/components/MapPinSelector.tsx +3 -4
- package/src/core/api.ts +2 -5
- package/src/core/digipin.ts +29 -4
- package/src/core/types.ts +23 -0
- package/src/index.ts +5 -0
- package/src/styles/checkout.css +42 -0
- package/src/styles/checkout.native.ts +48 -0
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
} from '../core/api';
|
|
9
9
|
import type {
|
|
10
10
|
AddressFormProps,
|
|
11
|
+
AddressLabel,
|
|
11
12
|
AdministrativeInfo,
|
|
12
13
|
CompleteAddress,
|
|
13
14
|
LocationAlternative,
|
|
@@ -30,6 +31,7 @@ type FormState =
|
|
|
30
31
|
adminInfo: AdministrativeInfo;
|
|
31
32
|
alternatives: LocationAlternative[];
|
|
32
33
|
selectedLocality: string; // Selected locality name (from adminInfo or alternatives)
|
|
34
|
+
selectedLabel: AddressLabel;
|
|
33
35
|
fields: ManualFields;
|
|
34
36
|
submitting: boolean;
|
|
35
37
|
/** At least one India Post office with "Delivery" (not only "Non Delivery") */
|
|
@@ -48,6 +50,7 @@ type FormAction =
|
|
|
48
50
|
| { type: 'LOAD_ERROR'; message: string }
|
|
49
51
|
| { type: 'SET_FIELD'; key: keyof ManualFields; value: string }
|
|
50
52
|
| { type: 'SET_LOCALITY'; locality: string }
|
|
53
|
+
| { type: 'SET_LABEL'; label: AddressLabel }
|
|
51
54
|
| { type: 'SUBMIT_START' }
|
|
52
55
|
| { type: 'SUBMIT_END' };
|
|
53
56
|
|
|
@@ -103,6 +106,7 @@ function reducer(state: FormState, action: FormAction): FormState {
|
|
|
103
106
|
adminInfo: action.adminInfo,
|
|
104
107
|
alternatives: action.alternatives || [],
|
|
105
108
|
selectedLocality: action.adminInfo.locality,
|
|
109
|
+
selectedLabel: 'home',
|
|
106
110
|
fields: { ...INITIAL_FIELDS, ...preFilled },
|
|
107
111
|
submitting: false,
|
|
108
112
|
pincodeHasDelivery: action.pincodeHasDelivery,
|
|
@@ -116,6 +120,9 @@ function reducer(state: FormState, action: FormAction): FormState {
|
|
|
116
120
|
case 'SET_LOCALITY':
|
|
117
121
|
if (state.status !== 'ready') return state;
|
|
118
122
|
return { ...state, selectedLocality: action.locality };
|
|
123
|
+
case 'SET_LABEL':
|
|
124
|
+
if (state.status !== 'ready') return state;
|
|
125
|
+
return { ...state, selectedLabel: action.label };
|
|
119
126
|
case 'SUBMIT_START':
|
|
120
127
|
if (state.status !== 'ready') return state;
|
|
121
128
|
return { ...state, submitting: true };
|
|
@@ -202,7 +209,7 @@ const AddressForm: React.FC<AddressFormProps> = ({
|
|
|
202
209
|
e.preventDefault();
|
|
203
210
|
if (state.status !== 'ready') return;
|
|
204
211
|
|
|
205
|
-
const { adminInfo, selectedLocality, fields } = state;
|
|
212
|
+
const { adminInfo, selectedLocality, selectedLabel, fields } = state;
|
|
206
213
|
|
|
207
214
|
const parts: string[] = [
|
|
208
215
|
fields.flatNumber,
|
|
@@ -228,6 +235,7 @@ const AddressForm: React.FC<AddressFormProps> = ({
|
|
|
228
235
|
country: adminInfo.country ?? 'India',
|
|
229
236
|
...fields,
|
|
230
237
|
formattedAddress: parts.join(', '),
|
|
238
|
+
label: selectedLabel,
|
|
231
239
|
};
|
|
232
240
|
|
|
233
241
|
dispatch({ type: 'SUBMIT_START' });
|
|
@@ -387,6 +395,36 @@ const AddressForm: React.FC<AddressFormProps> = ({
|
|
|
387
395
|
</div>
|
|
388
396
|
)}
|
|
389
397
|
|
|
398
|
+
{/* Address label */}
|
|
399
|
+
<fieldset className="qr-fieldset">
|
|
400
|
+
<legend className="qr-fieldset__legend">Save as</legend>
|
|
401
|
+
<div className="qr-label-picker" role="radiogroup" aria-label="Address label">
|
|
402
|
+
{(
|
|
403
|
+
[
|
|
404
|
+
{ value: 'home' as const, title: 'Home', icon: '🏠' },
|
|
405
|
+
{ value: 'work' as const, title: 'Work', icon: '💼' },
|
|
406
|
+
{ value: 'other' as const, title: 'Other', icon: '📍' },
|
|
407
|
+
] as const
|
|
408
|
+
).map(({ value, title, icon }) => (
|
|
409
|
+
<button
|
|
410
|
+
key={value}
|
|
411
|
+
type="button"
|
|
412
|
+
role="radio"
|
|
413
|
+
aria-checked={state.selectedLabel === value}
|
|
414
|
+
className={`qr-label-picker__option${
|
|
415
|
+
state.selectedLabel === value ? ' qr-label-picker__option--active' : ''
|
|
416
|
+
}`}
|
|
417
|
+
onClick={() => dispatch({ type: 'SET_LABEL', label: value })}
|
|
418
|
+
>
|
|
419
|
+
<span className="qr-label-picker__icon" aria-hidden="true">
|
|
420
|
+
{icon}
|
|
421
|
+
</span>
|
|
422
|
+
<span>{title}</span>
|
|
423
|
+
</button>
|
|
424
|
+
))}
|
|
425
|
+
</div>
|
|
426
|
+
</fieldset>
|
|
427
|
+
|
|
390
428
|
{/* Manual entry section */}
|
|
391
429
|
<fieldset className="qr-fieldset">
|
|
392
430
|
<legend className="qr-fieldset__legend">
|
|
@@ -170,6 +170,7 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
|
|
|
170
170
|
enablePrepaidNudge = false,
|
|
171
171
|
prepaidNudgeCopy,
|
|
172
172
|
prepaidNudgeCtaUrl,
|
|
173
|
+
registerController,
|
|
173
174
|
}) => {
|
|
174
175
|
const authMode: AuthMode = enablePhoneAuth ? 'phone' : enableEmailAuth ? 'email' : 'none';
|
|
175
176
|
const initialStep: Step = authMode === 'phone' ? 'phone' : authMode === 'email' ? 'email' : 'map';
|
|
@@ -376,6 +377,10 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
|
|
|
376
377
|
]
|
|
377
378
|
.filter(Boolean)
|
|
378
379
|
.join(', '),
|
|
380
|
+
label: (saved.label === 'work' || saved.label === 'other'
|
|
381
|
+
? saved.label
|
|
382
|
+
: 'home') as CompleteAddress['label'],
|
|
383
|
+
addressId: saved.id,
|
|
379
384
|
};
|
|
380
385
|
void finishAddress(complete);
|
|
381
386
|
};
|
|
@@ -411,26 +416,28 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
|
|
|
411
416
|
locality: address.locality,
|
|
412
417
|
}).catch(() => {/* silent */});
|
|
413
418
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
419
|
+
if (!address.addressId) {
|
|
420
|
+
try {
|
|
421
|
+
await createAddress(checkoutConfig, auth.sessionToken, {
|
|
422
|
+
digipin: address.digipin,
|
|
423
|
+
lat: address.lat,
|
|
424
|
+
lng: address.lng,
|
|
425
|
+
state: address.state,
|
|
426
|
+
district: address.district,
|
|
427
|
+
locality: address.locality,
|
|
428
|
+
pincode: address.pincode,
|
|
429
|
+
delivery_status: address.delivery,
|
|
430
|
+
flat_number: address.flatNumber,
|
|
431
|
+
floor_number: address.floorNumber,
|
|
432
|
+
building_name: address.buildingName,
|
|
433
|
+
street_name: address.streetName,
|
|
434
|
+
full_address_json: address as unknown as Record<string, unknown>,
|
|
435
|
+
label: address.label ?? 'home',
|
|
436
|
+
is_default: false,
|
|
437
|
+
});
|
|
438
|
+
} catch {
|
|
439
|
+
// Silent
|
|
440
|
+
}
|
|
434
441
|
}
|
|
435
442
|
}
|
|
436
443
|
|
|
@@ -446,16 +453,61 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
|
|
|
446
453
|
await finishAddress(address);
|
|
447
454
|
};
|
|
448
455
|
|
|
449
|
-
const handleBack = () => {
|
|
456
|
+
const handleBack = (): boolean => {
|
|
450
457
|
if (step === 'form') {
|
|
451
458
|
setStep('map');
|
|
452
|
-
|
|
459
|
+
return true;
|
|
460
|
+
}
|
|
461
|
+
if (step === 'map' && auth?.sessionToken) {
|
|
453
462
|
setStep('saved');
|
|
454
|
-
|
|
463
|
+
return true;
|
|
464
|
+
}
|
|
465
|
+
if (step === 'email-otp') {
|
|
455
466
|
setStep('email');
|
|
467
|
+
return true;
|
|
456
468
|
}
|
|
469
|
+
if (step === 'otp') {
|
|
470
|
+
setStep('phone');
|
|
471
|
+
return true;
|
|
472
|
+
}
|
|
473
|
+
if (step === 'payment') {
|
|
474
|
+
setStep('form');
|
|
475
|
+
return true;
|
|
476
|
+
}
|
|
477
|
+
return false;
|
|
457
478
|
};
|
|
458
479
|
|
|
480
|
+
useEffect(() => {
|
|
481
|
+
if (!registerController) return;
|
|
482
|
+
registerController({
|
|
483
|
+
goBack: () => {
|
|
484
|
+
const current = stepRef.current;
|
|
485
|
+
if (current === 'form') {
|
|
486
|
+
setStep('map');
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
if (current === 'map' && auth?.sessionToken) {
|
|
490
|
+
setStep('saved');
|
|
491
|
+
return true;
|
|
492
|
+
}
|
|
493
|
+
if (current === 'email-otp') {
|
|
494
|
+
setStep('email');
|
|
495
|
+
return true;
|
|
496
|
+
}
|
|
497
|
+
if (current === 'otp') {
|
|
498
|
+
setStep('phone');
|
|
499
|
+
return true;
|
|
500
|
+
}
|
|
501
|
+
if (current === 'payment') {
|
|
502
|
+
setStep('form');
|
|
503
|
+
return true;
|
|
504
|
+
}
|
|
505
|
+
return false;
|
|
506
|
+
},
|
|
507
|
+
getStep: () => stepRef.current,
|
|
508
|
+
});
|
|
509
|
+
}, [registerController, auth?.sessionToken]);
|
|
510
|
+
|
|
459
511
|
const handleEditAddress = () => {
|
|
460
512
|
emit({ type: 'widget_reset', step: initialStep });
|
|
461
513
|
setStep(initialStep);
|
|
@@ -595,7 +647,7 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
|
|
|
595
647
|
email={emailPending}
|
|
596
648
|
codeReused={emailCodeReused}
|
|
597
649
|
onVerified={handleEmailVerified}
|
|
598
|
-
onBack={
|
|
650
|
+
onBack={handleBack}
|
|
599
651
|
functionBaseUrl={supabaseFunctionBaseUrl}
|
|
600
652
|
merchantId={merchantId}
|
|
601
653
|
sessionContext={sessionContext}
|
|
@@ -617,7 +669,7 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
|
|
|
617
669
|
<OtpStep
|
|
618
670
|
mobile={auth.mobile}
|
|
619
671
|
onVerified={handleVerified}
|
|
620
|
-
onBack={
|
|
672
|
+
onBack={handleBack}
|
|
621
673
|
functionBaseUrl={supabaseFunctionBaseUrl}
|
|
622
674
|
merchantId={merchantId}
|
|
623
675
|
sessionContext={sessionContext}
|
|
@@ -677,7 +729,7 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
|
|
|
677
729
|
codAllowed={codAllowed}
|
|
678
730
|
theme={theme}
|
|
679
731
|
onComplete={handlePaymentComplete}
|
|
680
|
-
onBack={
|
|
732
|
+
onBack={handleBack}
|
|
681
733
|
onEvent={(type, paymentMethod) =>
|
|
682
734
|
emit({ type, step: 'payment', paymentMethod, buyerId: auth?.buyerId })
|
|
683
735
|
}
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
import { OSMView, LocationButton } from 'expo-osm-sdk';
|
|
13
13
|
import type { OSMViewRef, MarkerConfig } from 'expo-osm-sdk';
|
|
14
14
|
import * as Location from 'expo-location';
|
|
15
|
-
import { getDigiPin, getLatLngFromDigiPin, isWithinIndia } from '../core/digipin';
|
|
15
|
+
import { getDigiPin, getLatLngFromDigiPin, formatDigiPin, isWithinIndia } from '../core/digipin';
|
|
16
16
|
import { autocompleteAddress, looksLikeDigiPin } from '../core/api';
|
|
17
17
|
import type { AutocompleteSuggestion } from '../core/api';
|
|
18
18
|
import type { MapPinSelectorProps } from '../core/types';
|
|
@@ -139,10 +139,10 @@ const MapPinSelector: React.FC<MapPinSelectorProps> = ({
|
|
|
139
139
|
// Keep the text visible in the input; just close the keyboard and dropdown.
|
|
140
140
|
if (looksLikeDigiPin(trimmed)) {
|
|
141
141
|
try {
|
|
142
|
-
const coords = getLatLngFromDigiPin(trimmed
|
|
142
|
+
const coords = getLatLngFromDigiPin(trimmed);
|
|
143
143
|
flyToCoord(parseFloat(coords.latitude), parseFloat(coords.longitude));
|
|
144
144
|
setSuggestions([]);
|
|
145
|
-
setSearchQuery(trimmed
|
|
145
|
+
setSearchQuery(formatDigiPin(trimmed));
|
|
146
146
|
Keyboard.dismiss();
|
|
147
147
|
} catch {
|
|
148
148
|
setSearchError('Invalid DigiPin code');
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useRef, useState, useCallback, useId } from 'react';
|
|
2
2
|
import maplibregl from 'maplibre-gl';
|
|
3
3
|
import 'maplibre-gl/dist/maplibre-gl.css';
|
|
4
|
-
import { getDigiPin, getLatLngFromDigiPin, isWithinIndia } from '../core/digipin';
|
|
4
|
+
import { getDigiPin, getLatLngFromDigiPin, formatDigiPin, isWithinIndia } from '../core/digipin';
|
|
5
5
|
import { autocompleteAddress, looksLikeDigiPin } from '../core/api';
|
|
6
6
|
import type { AutocompleteSuggestion } from '../core/api';
|
|
7
7
|
import { useGeolocation } from '../hooks/useGeolocation';
|
|
@@ -177,14 +177,13 @@ const MapPinSelector: React.FC<MapPinSelectorProps> = ({
|
|
|
177
177
|
// Keep the text in the input so the user can see what resolved.
|
|
178
178
|
if (looksLikeDigiPin(trimmed)) {
|
|
179
179
|
try {
|
|
180
|
-
const coords = getLatLngFromDigiPin(trimmed
|
|
180
|
+
const coords = getLatLngFromDigiPin(trimmed);
|
|
181
181
|
const la = parseFloat(coords.latitude);
|
|
182
182
|
const lo = parseFloat(coords.longitude);
|
|
183
183
|
flyToCoord(la, lo);
|
|
184
184
|
setSuggestions([]);
|
|
185
185
|
setDropdownOpen(false);
|
|
186
|
-
|
|
187
|
-
setSearchQuery(trimmed.toUpperCase());
|
|
186
|
+
setSearchQuery(formatDigiPin(trimmed));
|
|
188
187
|
} catch {
|
|
189
188
|
setSearchError('Invalid DigiPin code');
|
|
190
189
|
}
|
package/src/core/api.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import type { LocationLookupResponse } from './types';
|
|
2
|
+
import { isCompleteDigiPinInput } from './digipin';
|
|
2
3
|
|
|
3
4
|
const DEFAULT_BASE_URL = 'https://api.quantaroute.com';
|
|
4
5
|
|
|
5
|
-
// ─── DigiPin regex (matches "XXX-XXX-XXXX" with valid characters) ─────────────
|
|
6
|
-
// Valid chars: F C 9 8 J 3 2 7 K 4 5 6 L M P T (from the 4×4 DIGIPIN_GRID)
|
|
7
|
-
const DIGIPIN_PATTERN = /^[FC98J327K456LMPT]{3}-[FC98J327K456LMPT]{3}-[FC98J327K456LMPT]{4}$/i;
|
|
8
|
-
|
|
9
6
|
/**
|
|
10
7
|
* Cross-platform timeout signal.
|
|
11
8
|
* AbortSignal.timeout() is not available in React Native / Hermes — fall back
|
|
@@ -235,7 +232,7 @@ export interface AutocompleteResponse {
|
|
|
235
232
|
* Used to skip the API call and resolve offline instead.
|
|
236
233
|
*/
|
|
237
234
|
export function looksLikeDigiPin(input: string): boolean {
|
|
238
|
-
return
|
|
235
|
+
return isCompleteDigiPinInput(input);
|
|
239
236
|
}
|
|
240
237
|
|
|
241
238
|
/**
|
package/src/core/digipin.ts
CHANGED
|
@@ -32,6 +32,31 @@ const BOUNDS = {
|
|
|
32
32
|
maxLon: 99.5,
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
/** Characters that appear in the official 4×4 DigiPin grid */
|
|
36
|
+
const DIGIPIN_ALPHABET = 'FC98J327K456LMPT';
|
|
37
|
+
const VALID_DIGIPIN_BODY = new RegExp(`^[${DIGIPIN_ALPHABET}]{10}$`, 'i');
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Normalise user input to a 10-character DigiPin body (no separators).
|
|
41
|
+
* Accepts dashed, spaced, or compact forms — e.g. `4P3-J68-637F`, `4P3 J68 637F`, `4P3J68637F`.
|
|
42
|
+
*/
|
|
43
|
+
export function normalizeDigiPinInput(input: string): string {
|
|
44
|
+
return input.trim().toUpperCase().replace(/[\s\-_.]/g, '');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Canonical display format: XXX-XXX-XXXX */
|
|
48
|
+
export function formatDigiPin(input: string): string {
|
|
49
|
+
const pin = normalizeDigiPinInput(input);
|
|
50
|
+
if (pin.length !== 10) return input.trim().toUpperCase();
|
|
51
|
+
return `${pin.slice(0, 3)}-${pin.slice(3, 6)}-${pin.slice(6)}`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** True when input is a complete 10-character DigiPin (any common separator style). */
|
|
55
|
+
export function isCompleteDigiPinInput(input: string): boolean {
|
|
56
|
+
const pin = normalizeDigiPinInput(input);
|
|
57
|
+
return pin.length === 10 && VALID_DIGIPIN_BODY.test(pin);
|
|
58
|
+
}
|
|
59
|
+
|
|
35
60
|
export interface DigiPinCoordinates {
|
|
36
61
|
latitude: string;
|
|
37
62
|
longitude: string;
|
|
@@ -88,9 +113,9 @@ export function getDigiPin(lat: number, lon: number): string {
|
|
|
88
113
|
* @throws if the DigiPin format is invalid
|
|
89
114
|
*/
|
|
90
115
|
export function getLatLngFromDigiPin(digiPin: string): DigiPinCoordinates {
|
|
91
|
-
const pin = digiPin
|
|
116
|
+
const pin = normalizeDigiPinInput(digiPin);
|
|
92
117
|
if (pin.length !== 10) {
|
|
93
|
-
throw new Error('Invalid DIGIPIN: must be 10 characters (excluding
|
|
118
|
+
throw new Error('Invalid DIGIPIN: must be 10 characters (excluding separators)');
|
|
94
119
|
}
|
|
95
120
|
|
|
96
121
|
let minLat = BOUNDS.minLat;
|
|
@@ -145,9 +170,9 @@ export function getLatLngFromDigiPin(digiPin: string): DigiPinCoordinates {
|
|
|
145
170
|
*/
|
|
146
171
|
export function isValidDigiPin(digiPin: string): boolean {
|
|
147
172
|
if (!digiPin || typeof digiPin !== 'string') return false;
|
|
148
|
-
if (
|
|
173
|
+
if (!isCompleteDigiPinInput(digiPin)) return false;
|
|
149
174
|
try {
|
|
150
|
-
getLatLngFromDigiPin(digiPin
|
|
175
|
+
getLatLngFromDigiPin(digiPin);
|
|
151
176
|
return true;
|
|
152
177
|
} catch {
|
|
153
178
|
return false;
|
package/src/core/types.ts
CHANGED
|
@@ -49,6 +49,13 @@ export interface LocationLookupResponse {
|
|
|
49
49
|
message?: string;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
// ─── Address labels (saved-address book) ─────────────────────────────────────
|
|
53
|
+
|
|
54
|
+
/** Label for a saved buyer address — stored in checkout-addresses API. */
|
|
55
|
+
export type AddressLabel = 'home' | 'work' | 'other';
|
|
56
|
+
|
|
57
|
+
export const ADDRESS_LABELS: AddressLabel[] = ['home', 'work', 'other'];
|
|
58
|
+
|
|
52
59
|
// ─── Complete Address (output) ───────────────────────────────────────────────
|
|
53
60
|
|
|
54
61
|
export interface CompleteAddress {
|
|
@@ -82,6 +89,17 @@ export interface CompleteAddress {
|
|
|
82
89
|
streetName: string;
|
|
83
90
|
/** Combined formatted address string */
|
|
84
91
|
formattedAddress: string;
|
|
92
|
+
/** Buyer-chosen label for saved-address book (defaults to home) */
|
|
93
|
+
label?: AddressLabel;
|
|
94
|
+
/** Set when the buyer re-selected an existing saved row (skip createAddress). */
|
|
95
|
+
addressId?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** Imperative hooks for host pages (e.g. Shopify pre-checkout shell). */
|
|
99
|
+
export interface CheckoutWidgetController {
|
|
100
|
+
/** Navigate one step back within the widget. Returns true if handled. */
|
|
101
|
+
goBack: () => boolean;
|
|
102
|
+
getStep: () => string;
|
|
85
103
|
}
|
|
86
104
|
|
|
87
105
|
// ─── Checkout event (client-side analytics hook) ─────────────────────────────
|
|
@@ -318,6 +336,11 @@ export interface CheckoutWidgetProps {
|
|
|
318
336
|
prepaidNudgeCopy?: string;
|
|
319
337
|
/** Override merchant prepaid nudge CTA URL. */
|
|
320
338
|
prepaidNudgeCtaUrl?: string;
|
|
339
|
+
/**
|
|
340
|
+
* Called once on mount with imperative navigation helpers for host shells
|
|
341
|
+
* (step-aware back button, etc.).
|
|
342
|
+
*/
|
|
343
|
+
registerController?: (controller: CheckoutWidgetController) => void;
|
|
321
344
|
}
|
|
322
345
|
|
|
323
346
|
// ─── Phone / OTP step props ───────────────────────────────────────────────────
|
package/src/index.ts
CHANGED
|
@@ -43,6 +43,9 @@ export {
|
|
|
43
43
|
getLatLngFromDigiPin,
|
|
44
44
|
isValidDigiPin,
|
|
45
45
|
isWithinIndia,
|
|
46
|
+
normalizeDigiPinInput,
|
|
47
|
+
formatDigiPin,
|
|
48
|
+
isCompleteDigiPinInput,
|
|
46
49
|
DIGIPIN_BOUNDS,
|
|
47
50
|
} from './core/digipin';
|
|
48
51
|
|
|
@@ -120,6 +123,8 @@ export type {
|
|
|
120
123
|
PaymentStepProps,
|
|
121
124
|
PrepaidNudgeProps,
|
|
122
125
|
CompleteAddress,
|
|
126
|
+
AddressLabel,
|
|
127
|
+
ADDRESS_LABELS,
|
|
123
128
|
AdministrativeInfo,
|
|
124
129
|
LocationAlternative,
|
|
125
130
|
LocationLookupResponse,
|
package/src/styles/checkout.css
CHANGED
|
@@ -814,6 +814,47 @@
|
|
|
814
814
|
font-size: 14px;
|
|
815
815
|
}
|
|
816
816
|
|
|
817
|
+
.qr-label-picker {
|
|
818
|
+
display: grid;
|
|
819
|
+
grid-template-columns: repeat(3, 1fr);
|
|
820
|
+
gap: 8px;
|
|
821
|
+
padding: 0 16px 12px;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
.qr-label-picker__option {
|
|
825
|
+
display: flex;
|
|
826
|
+
flex-direction: column;
|
|
827
|
+
align-items: center;
|
|
828
|
+
justify-content: center;
|
|
829
|
+
gap: 4px;
|
|
830
|
+
min-height: 72px;
|
|
831
|
+
padding: 10px 8px;
|
|
832
|
+
border: 1.5px solid var(--qr-border);
|
|
833
|
+
border-radius: 10px;
|
|
834
|
+
background: var(--qr-bg, #fff);
|
|
835
|
+
color: var(--qr-text-muted);
|
|
836
|
+
font-family: inherit;
|
|
837
|
+
font-size: 13px;
|
|
838
|
+
font-weight: 500;
|
|
839
|
+
cursor: pointer;
|
|
840
|
+
transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
.qr-label-picker__option:hover:not(.qr-label-picker__option--active) {
|
|
844
|
+
border-color: color-mix(in srgb, var(--qr-accent, var(--qr-navy)) 35%, var(--qr-border));
|
|
845
|
+
}
|
|
846
|
+
|
|
847
|
+
.qr-label-picker__option--active {
|
|
848
|
+
border-color: var(--qr-accent, var(--qr-navy));
|
|
849
|
+
background: color-mix(in srgb, var(--qr-accent, var(--qr-navy)) 10%, var(--qr-bg, #fff));
|
|
850
|
+
color: var(--qr-text);
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
.qr-label-picker__icon {
|
|
854
|
+
font-size: 18px;
|
|
855
|
+
line-height: 1;
|
|
856
|
+
}
|
|
857
|
+
|
|
817
858
|
/* ── Auto-filled grid ────────────────────────────────────── */
|
|
818
859
|
.qr-auto-grid {
|
|
819
860
|
display: grid;
|
|
@@ -1375,6 +1416,7 @@
|
|
|
1375
1416
|
|
|
1376
1417
|
/* ── Focus visible (keyboard nav) ────────────────────────── */
|
|
1377
1418
|
.qr-btn:focus-visible,
|
|
1419
|
+
.qr-label-picker__option:focus-visible,
|
|
1378
1420
|
.qr-back-btn:focus-visible,
|
|
1379
1421
|
.qr-locate-btn:focus-visible {
|
|
1380
1422
|
outline: 2px solid var(--qr-primary);
|
|
@@ -721,6 +721,54 @@ export const styles = StyleSheet.create({
|
|
|
721
721
|
fontWeight: '700',
|
|
722
722
|
},
|
|
723
723
|
|
|
724
|
+
// ── Address label picker ────────────────────────────────────────────────────
|
|
725
|
+
labelPicker: {
|
|
726
|
+
flexDirection: 'row',
|
|
727
|
+
gap: 8,
|
|
728
|
+
paddingHorizontal: 16,
|
|
729
|
+
paddingBottom: 12,
|
|
730
|
+
},
|
|
731
|
+
labelPickerOption: {
|
|
732
|
+
flex: 1,
|
|
733
|
+
alignItems: 'center',
|
|
734
|
+
justifyContent: 'center',
|
|
735
|
+
gap: 4,
|
|
736
|
+
minHeight: 72,
|
|
737
|
+
paddingVertical: 10,
|
|
738
|
+
paddingHorizontal: 8,
|
|
739
|
+
borderWidth: 1.5,
|
|
740
|
+
borderColor: COLORS.border,
|
|
741
|
+
borderRadius: 10,
|
|
742
|
+
backgroundColor: COLORS.bg,
|
|
743
|
+
},
|
|
744
|
+
labelPickerOptionDark: {
|
|
745
|
+
borderColor: COLORS.borderDark,
|
|
746
|
+
backgroundColor: COLORS.bgDark,
|
|
747
|
+
},
|
|
748
|
+
labelPickerOptionActive: {
|
|
749
|
+
borderColor: COLORS.primary,
|
|
750
|
+
backgroundColor: COLORS.primaryLight,
|
|
751
|
+
},
|
|
752
|
+
labelPickerOptionActiveDark: {
|
|
753
|
+
borderColor: COLORS.primary,
|
|
754
|
+
backgroundColor: '#0c4a6e33',
|
|
755
|
+
},
|
|
756
|
+
labelPickerIcon: {
|
|
757
|
+
fontSize: 18,
|
|
758
|
+
},
|
|
759
|
+
labelPickerText: {
|
|
760
|
+
fontSize: 13,
|
|
761
|
+
fontWeight: '500',
|
|
762
|
+
color: COLORS.textMuted,
|
|
763
|
+
},
|
|
764
|
+
labelPickerTextDark: {
|
|
765
|
+
color: COLORS.textMutedDark,
|
|
766
|
+
},
|
|
767
|
+
labelPickerTextActive: {
|
|
768
|
+
color: COLORS.text,
|
|
769
|
+
fontWeight: '600',
|
|
770
|
+
},
|
|
771
|
+
|
|
724
772
|
// ── Manual fields ───────────────────────────────────────────────────────────
|
|
725
773
|
fieldsGrid: {
|
|
726
774
|
paddingHorizontal: 16,
|