@quantaroute/checkout 1.6.0 → 1.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/CHANGELOG.md +14 -0
- package/README.md +27 -0
- package/dist/lib/index.d.ts +15 -0
- package/dist/lib/quantaroute-checkout.es.js +186 -186
- package/dist/lib/quantaroute-checkout.umd.js +86 -86
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/CheckoutWidget.tsx +82 -3
- package/src/components/PaymentStep.tsx +15 -5
- package/src/core/types.ts +15 -0
- package/src/index.ts +2 -0
- package/src/styles/checkout.css +542 -0
|
@@ -55,6 +55,14 @@ interface AuthState {
|
|
|
55
55
|
buyerId: string;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
type MobileStepStatus = 'complete' | 'active' | 'pending';
|
|
59
|
+
|
|
60
|
+
interface MobileStepItem {
|
|
61
|
+
id: 'auth' | 'address' | 'payment';
|
|
62
|
+
label: string;
|
|
63
|
+
status: MobileStepStatus;
|
|
64
|
+
}
|
|
65
|
+
|
|
58
66
|
// ─── Success screen ───────────────────────────────────────────────────────────
|
|
59
67
|
|
|
60
68
|
interface SuccessScreenProps {
|
|
@@ -195,8 +203,10 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
|
|
|
195
203
|
theme = 'light',
|
|
196
204
|
className = '',
|
|
197
205
|
style,
|
|
198
|
-
mapHeight = '
|
|
206
|
+
mapHeight = 'min(52dvh, 420px)',
|
|
199
207
|
title = 'Add Delivery Address',
|
|
208
|
+
mobilePresentation = 'auto',
|
|
209
|
+
mobileStepLabels,
|
|
200
210
|
indiaBoundaryUrl,
|
|
201
211
|
enableSearch = true,
|
|
202
212
|
enablePhoneAuth = false,
|
|
@@ -657,6 +667,44 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
|
|
|
657
667
|
const currentIndex = stepToIndex(step, authMode, withPayment);
|
|
658
668
|
const total = totalSteps(authMode, withPayment);
|
|
659
669
|
|
|
670
|
+
const activeMobileStep: MobileStepItem['id'] =
|
|
671
|
+
step === 'payment'
|
|
672
|
+
? 'payment'
|
|
673
|
+
: step === 'phone' || step === 'otp' || step === 'email' || step === 'email-otp'
|
|
674
|
+
? 'auth'
|
|
675
|
+
: 'address';
|
|
676
|
+
|
|
677
|
+
const authStepLabel =
|
|
678
|
+
mobileStepLabels?.auth ?? (authMode === 'email' ? 'Email' : 'Mobile');
|
|
679
|
+
|
|
680
|
+
const mobileSteps: MobileStepItem[] = [
|
|
681
|
+
...(authMode === 'none'
|
|
682
|
+
? []
|
|
683
|
+
: [{
|
|
684
|
+
id: 'auth' as const,
|
|
685
|
+
label: authStepLabel,
|
|
686
|
+
status: (activeMobileStep === 'auth'
|
|
687
|
+
? 'active'
|
|
688
|
+
: 'complete') as MobileStepStatus,
|
|
689
|
+
}]),
|
|
690
|
+
{
|
|
691
|
+
id: 'address',
|
|
692
|
+
label: mobileStepLabels?.address ?? 'Address',
|
|
693
|
+
status: (activeMobileStep === 'address'
|
|
694
|
+
? 'active'
|
|
695
|
+
: activeMobileStep === 'payment'
|
|
696
|
+
? 'complete'
|
|
697
|
+
: 'pending') as MobileStepStatus,
|
|
698
|
+
},
|
|
699
|
+
...(withPayment
|
|
700
|
+
? [{
|
|
701
|
+
id: 'payment' as const,
|
|
702
|
+
label: mobileStepLabels?.payment ?? 'Pay',
|
|
703
|
+
status: (activeMobileStep === 'payment' ? 'active' : 'pending') as MobileStepStatus,
|
|
704
|
+
}]
|
|
705
|
+
: []),
|
|
706
|
+
];
|
|
707
|
+
|
|
660
708
|
const renderProgress = () => {
|
|
661
709
|
const dots = Array.from({ length: total + 1 }, (_, i) => i);
|
|
662
710
|
return (
|
|
@@ -680,11 +728,37 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
|
|
|
680
728
|
);
|
|
681
729
|
};
|
|
682
730
|
|
|
731
|
+
const renderMobileStepper = () => (
|
|
732
|
+
<div
|
|
733
|
+
className="qr-mobile-stepper"
|
|
734
|
+
role="list"
|
|
735
|
+
aria-label="Checkout progress"
|
|
736
|
+
>
|
|
737
|
+
{mobileSteps.map((item, index) => (
|
|
738
|
+
<React.Fragment key={item.id}>
|
|
739
|
+
<div
|
|
740
|
+
className={`qr-mobile-stepper__item qr-mobile-stepper__item--${item.status}`}
|
|
741
|
+
role="listitem"
|
|
742
|
+
aria-current={item.status === 'active' ? 'step' : undefined}
|
|
743
|
+
>
|
|
744
|
+
<span className="qr-mobile-stepper__mark" aria-hidden="true">
|
|
745
|
+
{item.status === 'complete' ? '✓' : index + 1}
|
|
746
|
+
</span>
|
|
747
|
+
<span className="qr-mobile-stepper__label">{item.label}</span>
|
|
748
|
+
</div>
|
|
749
|
+
{index < mobileSteps.length - 1 ? (
|
|
750
|
+
<span className="qr-mobile-stepper__rail" aria-hidden="true" />
|
|
751
|
+
) : null}
|
|
752
|
+
</React.Fragment>
|
|
753
|
+
))}
|
|
754
|
+
</div>
|
|
755
|
+
);
|
|
756
|
+
|
|
683
757
|
// ── Render ────────────────────────────────────────────────────────────────
|
|
684
758
|
|
|
685
759
|
return (
|
|
686
760
|
<div
|
|
687
|
-
className={`qr-checkout qr-checkout--${theme} ${className}`}
|
|
761
|
+
className={`qr-checkout qr-checkout--${theme} qr-checkout--mobile-${mobilePresentation} ${className}`}
|
|
688
762
|
style={rootStyle}
|
|
689
763
|
data-testid="quantaroute-checkout"
|
|
690
764
|
>
|
|
@@ -719,7 +793,12 @@ const CheckoutWidget: React.FC<CheckoutWidgetProps> = ({
|
|
|
719
793
|
)}
|
|
720
794
|
<span className="qr-header__title">{title}</span>
|
|
721
795
|
</div>
|
|
722
|
-
|
|
796
|
+
<div className="qr-header__progress-desktop">
|
|
797
|
+
{renderProgress()}
|
|
798
|
+
</div>
|
|
799
|
+
</div>
|
|
800
|
+
<div className="qr-header__progress-mobile">
|
|
801
|
+
{renderMobileStepper()}
|
|
723
802
|
</div>
|
|
724
803
|
{headerBanner ? (
|
|
725
804
|
<div className="qr-header-banner" role="region" aria-label="Merchant message">
|
|
@@ -142,22 +142,32 @@ const PaymentStep: React.FC<PaymentStepProps> = ({
|
|
|
142
142
|
|
|
143
143
|
<button
|
|
144
144
|
type="button"
|
|
145
|
-
className="qr-
|
|
145
|
+
className="qr-payment-option qr-payment-option--primary"
|
|
146
146
|
onClick={handlePrepaid}
|
|
147
147
|
disabled={loading}
|
|
148
148
|
>
|
|
149
|
-
|
|
149
|
+
<span className="qr-payment-option__icon" aria-hidden="true">UPI</span>
|
|
150
|
+
<span className="qr-payment-option__copy">
|
|
151
|
+
<span className="qr-payment-option__title">
|
|
152
|
+
{loading ? 'Processing...' : 'Pay online'}
|
|
153
|
+
</span>
|
|
154
|
+
<span className="qr-payment-option__sub">UPI, cards, wallets</span>
|
|
155
|
+
</span>
|
|
156
|
+
<strong className="qr-payment-option__amount">{amountDisplay}</strong>
|
|
150
157
|
</button>
|
|
151
158
|
|
|
152
159
|
{enableCod && codAllowed ? (
|
|
153
160
|
<button
|
|
154
161
|
type="button"
|
|
155
|
-
className="qr-
|
|
162
|
+
className="qr-payment-option qr-payment-option--secondary"
|
|
156
163
|
onClick={handleCod}
|
|
157
164
|
disabled={loading}
|
|
158
|
-
style={{ marginTop: 8 }}
|
|
159
165
|
>
|
|
160
|
-
|
|
166
|
+
<span className="qr-payment-option__icon" aria-hidden="true">₹</span>
|
|
167
|
+
<span className="qr-payment-option__copy">
|
|
168
|
+
<span className="qr-payment-option__title">Cash on Delivery</span>
|
|
169
|
+
<span className="qr-payment-option__sub">Pay when the order arrives</span>
|
|
170
|
+
</span>
|
|
161
171
|
</button>
|
|
162
172
|
) : null}
|
|
163
173
|
|
package/src/core/types.ts
CHANGED
|
@@ -104,6 +104,14 @@ export interface CheckoutWidgetController {
|
|
|
104
104
|
getStep: () => string;
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
export type CheckoutMobilePresentation = 'auto' | 'sheet' | 'card';
|
|
108
|
+
|
|
109
|
+
export interface CheckoutMobileStepLabels {
|
|
110
|
+
auth?: string;
|
|
111
|
+
address?: string;
|
|
112
|
+
payment?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
107
115
|
// ─── Checkout event (client-side analytics hook) ─────────────────────────────
|
|
108
116
|
|
|
109
117
|
/** All step-transition event types emitted by the widget. */
|
|
@@ -263,6 +271,13 @@ export interface CheckoutWidgetProps {
|
|
|
263
271
|
mapHeight?: string | number;
|
|
264
272
|
/** Widget header title. Defaults to 'Add Delivery Address'. */
|
|
265
273
|
title?: string;
|
|
274
|
+
/**
|
|
275
|
+
* Mobile visual treatment. `auto` applies the improved mobile layout below 480px,
|
|
276
|
+
* `sheet` is for storefront drawers/modals, and `card` preserves the compact card feel.
|
|
277
|
+
*/
|
|
278
|
+
mobilePresentation?: CheckoutMobilePresentation;
|
|
279
|
+
/** Override the compact mobile step labels (e.g. Mobile / Address / Pay). */
|
|
280
|
+
mobileStepLabels?: CheckoutMobileStepLabels;
|
|
266
281
|
/**
|
|
267
282
|
* URL to an India boundary GeoJSON file (FeatureCollection).
|
|
268
283
|
* When provided, a thin grey outline is drawn on the map for legal compliance.
|
package/src/index.ts
CHANGED
|
@@ -120,6 +120,8 @@ export type { UtmParams } from './core/utm';
|
|
|
120
120
|
export { getWebDeviceContext, detectDeviceType, detectPlatform } from './core/device';
|
|
121
121
|
export type {
|
|
122
122
|
CheckoutWidgetProps,
|
|
123
|
+
CheckoutMobilePresentation,
|
|
124
|
+
CheckoutMobileStepLabels,
|
|
123
125
|
MapPinSelectorProps,
|
|
124
126
|
AddressFormProps,
|
|
125
127
|
AddressFormInitialValues,
|