@brissoto/pay-react-native 0.0.0-stage → 1.5.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/LICENSE +21 -0
- package/README.md +181 -2
- package/assets/brand/paypal-wordmark.png +0 -0
- package/assets/fonts/Figtree-Bold.ttf +0 -0
- package/assets/fonts/Figtree-ExtraBold.ttf +0 -0
- package/assets/fonts/Figtree-Medium.ttf +0 -0
- package/assets/fonts/Figtree-Regular.ttf +0 -0
- package/assets/fonts/Figtree-SemiBold.ttf +0 -0
- package/assets/fonts/OFL.txt +93 -0
- package/assets/logos/airtel.png +0 -0
- package/assets/logos/app-store.png +0 -0
- package/assets/logos/apple-pay.png +0 -0
- package/assets/logos/at.png +0 -0
- package/assets/logos/bancontact.png +0 -0
- package/assets/logos/card.png +0 -0
- package/assets/logos/cb.png +0 -0
- package/assets/logos/celtiis.png +0 -0
- package/assets/logos/eps.png +0 -0
- package/assets/logos/feexpay.png +0 -0
- package/assets/logos/google-pay.png +0 -0
- package/assets/logos/google-play.png +0 -0
- package/assets/logos/iapkit.png +0 -0
- package/assets/logos/ideal.png +0 -0
- package/assets/logos/mastercard.png +0 -0
- package/assets/logos/mixx.png +0 -0
- package/assets/logos/moov.png +0 -0
- package/assets/logos/mtn.png +0 -0
- package/assets/logos/mybank.png +0 -0
- package/assets/logos/nexus.png +0 -0
- package/assets/logos/orange.png +0 -0
- package/assets/logos/pawapay.png +0 -0
- package/assets/logos/paypal.png +0 -0
- package/assets/logos/telecel.png +0 -0
- package/assets/logos/tnm.png +0 -0
- package/assets/logos/visa.png +0 -0
- package/assets/logos/vodacom.png +0 -0
- package/assets/logos/wave.png +0 -0
- package/dist/checkout-core/hooks/use-checkout-controller.d.ts +9 -0
- package/dist/checkout-core/hooks/use-checkout-controller.js +563 -0
- package/dist/checkout-core/hooks/use-checkout-payment.d.ts +9 -0
- package/dist/checkout-core/hooks/use-checkout-payment.js +136 -0
- package/dist/checkout-core/hooks/use-checkout-timers.d.ts +15 -0
- package/dist/checkout-core/hooks/use-checkout-timers.js +44 -0
- package/dist/checkout-core/hooks/use-phone-number.d.ts +7 -0
- package/dist/checkout-core/hooks/use-phone-number.js +82 -0
- package/dist/checkout-core/messages/en.d.ts +302 -0
- package/dist/checkout-core/messages/en.js +301 -0
- package/dist/checkout-core/messages/fr.d.ts +4 -0
- package/dist/checkout-core/messages/fr.js +302 -0
- package/dist/checkout-core/models/checkout.card.utils.d.ts +7 -0
- package/dist/checkout-core/models/checkout.card.utils.js +25 -0
- package/dist/checkout-core/models/checkout.constants.d.ts +101 -0
- package/dist/checkout-core/models/checkout.constants.js +339 -0
- package/dist/checkout-core/models/checkout.country.utils.d.ts +17 -0
- package/dist/checkout-core/models/checkout.country.utils.js +45 -0
- package/dist/checkout-core/models/checkout.enum.d.ts +233 -0
- package/dist/checkout-core/models/checkout.enum.js +259 -0
- package/dist/checkout-core/models/checkout.fetch.utils.d.ts +6 -0
- package/dist/checkout-core/models/checkout.fetch.utils.js +22 -0
- package/dist/checkout-core/models/checkout.interface.d.ts +698 -0
- package/dist/checkout-core/models/checkout.interface.js +1 -0
- package/dist/checkout-core/models/checkout.money.utils.d.ts +7 -0
- package/dist/checkout-core/models/checkout.money.utils.js +21 -0
- package/dist/checkout-core/models/checkout.phone.utils.d.ts +33 -0
- package/dist/checkout-core/models/checkout.phone.utils.js +159 -0
- package/dist/checkout-core/models/checkout.view.utils.d.ts +77 -0
- package/dist/checkout-core/models/checkout.view.utils.js +331 -0
- package/dist/checkout-core/models/domain.enum.d.ts +106 -0
- package/dist/checkout-core/models/domain.enum.js +113 -0
- package/dist/components/BrissotoPayProvider.d.ts +8 -0
- package/dist/components/BrissotoPayProvider.js +39 -0
- package/dist/components/PaymentSheetModal.d.ts +9 -0
- package/dist/components/PaymentSheetModal.js +106 -0
- package/dist/components/SheetBone.d.ts +3 -0
- package/dist/components/SheetBone.js +12 -0
- package/dist/components/SheetButton.d.ts +7 -0
- package/dist/components/SheetButton.js +47 -0
- package/dist/components/SheetCardFields.d.ts +10 -0
- package/dist/components/SheetCardFields.js +86 -0
- package/dist/components/SheetChosenMethod.d.ts +3 -0
- package/dist/components/SheetChosenMethod.js +60 -0
- package/dist/components/SheetCodeField.d.ts +8 -0
- package/dist/components/SheetCodeField.js +98 -0
- package/dist/components/SheetContent.d.ts +3 -0
- package/dist/components/SheetContent.js +133 -0
- package/dist/components/SheetDial.d.ts +7 -0
- package/dist/components/SheetDial.js +36 -0
- package/dist/components/SheetFailed.d.ts +3 -0
- package/dist/components/SheetFailed.js +44 -0
- package/dist/components/SheetForm.d.ts +8 -0
- package/dist/components/SheetForm.js +141 -0
- package/dist/components/SheetGrabber.d.ts +2 -0
- package/dist/components/SheetGrabber.js +17 -0
- package/dist/components/SheetHeader.d.ts +7 -0
- package/dist/components/SheetHeader.js +83 -0
- package/dist/components/SheetIcon.d.ts +3 -0
- package/dist/components/SheetIcon.js +78 -0
- package/dist/components/SheetLayout.d.ts +11 -0
- package/dist/components/SheetLayout.js +63 -0
- package/dist/components/SheetLogo.d.ts +3 -0
- package/dist/components/SheetLogo.js +20 -0
- package/dist/components/SheetMessage.d.ts +3 -0
- package/dist/components/SheetMessage.js +15 -0
- package/dist/components/SheetMethodCard.d.ts +3 -0
- package/dist/components/SheetMethodCard.js +71 -0
- package/dist/components/SheetNameField.d.ts +7 -0
- package/dist/components/SheetNameField.js +48 -0
- package/dist/components/SheetPaypalButton.d.ts +3 -0
- package/dist/components/SheetPaypalButton.js +23 -0
- package/dist/components/SheetPhoneField.d.ts +3 -0
- package/dist/components/SheetPhoneField.js +59 -0
- package/dist/components/SheetPillSelect.d.ts +7 -0
- package/dist/components/SheetPillSelect.js +134 -0
- package/dist/components/SheetRow.d.ts +3 -0
- package/dist/components/SheetRow.js +28 -0
- package/dist/components/SheetSimulator.d.ts +6 -0
- package/dist/components/SheetSimulator.js +40 -0
- package/dist/components/SheetSkeleton.d.ts +5 -0
- package/dist/components/SheetSkeleton.js +23 -0
- package/dist/components/SheetStep.d.ts +6 -0
- package/dist/components/SheetStep.js +21 -0
- package/dist/components/SheetStoreTab.d.ts +7 -0
- package/dist/components/SheetStoreTab.js +27 -0
- package/dist/components/SheetSuccess.d.ts +3 -0
- package/dist/components/SheetSuccess.js +51 -0
- package/dist/components/SheetSummary.d.ts +3 -0
- package/dist/components/SheetSummary.js +32 -0
- package/dist/components/SheetTerminal.d.ts +6 -0
- package/dist/components/SheetTerminal.js +31 -0
- package/dist/components/SheetText.d.ts +5 -0
- package/dist/components/SheetText.js +27 -0
- package/dist/components/SheetToast.d.ts +7 -0
- package/dist/components/SheetToast.js +71 -0
- package/dist/components/SheetWaiting.d.ts +7 -0
- package/dist/components/SheetWaiting.js +88 -0
- package/dist/hooks/use-native-platform.d.ts +10 -0
- package/dist/hooks/use-native-platform.js +71 -0
- package/dist/hooks/use-payment-sheet.d.ts +4 -0
- package/dist/hooks/use-payment-sheet.js +10 -0
- package/dist/hooks/use-shake.d.ts +3 -0
- package/dist/hooks/use-shake.js +18 -0
- package/dist/hooks/use-sheet-motion.d.ts +7 -0
- package/dist/hooks/use-sheet-motion.js +62 -0
- package/dist/hooks/use-sheet-resize.d.ts +6 -0
- package/dist/hooks/use-sheet-resize.js +15 -0
- package/dist/hooks/use-sheet-room.d.ts +4 -0
- package/dist/hooks/use-sheet-room.js +8 -0
- package/dist/hooks/use-sheet-theme.d.ts +4 -0
- package/dist/hooks/use-sheet-theme.js +12 -0
- package/dist/hooks/use-step-slide.d.ts +16 -0
- package/dist/hooks/use-step-slide.js +50 -0
- package/dist/hooks/use-store-recovery.d.ts +9 -0
- package/dist/hooks/use-store-recovery.js +50 -0
- package/dist/hooks/use-store-tab.d.ts +11 -0
- package/dist/hooks/use-store-tab.js +112 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -0
- package/dist/models/sheet.constants.d.ts +125 -0
- package/dist/models/sheet.constants.js +204 -0
- package/dist/models/sheet.enum.d.ts +46 -0
- package/dist/models/sheet.enum.js +53 -0
- package/dist/models/sheet.interface.d.ts +426 -0
- package/dist/models/sheet.interface.js +1 -0
- package/dist/models/sheet.utils.d.ts +68 -0
- package/dist/models/sheet.utils.js +214 -0
- package/dist/services/checkout.service.d.ts +15 -0
- package/dist/services/checkout.service.js +96 -0
- package/dist/services/provider-window.service.d.ts +13 -0
- package/dist/services/provider-window.service.js +53 -0
- package/dist/services/store.service.d.ts +36 -0
- package/dist/services/store.service.js +107 -0
- package/package.json +73 -4
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { AppState, Linking, Platform, StyleSheet, TouchableOpacity, View, } from 'react-native';
|
|
4
|
+
import { useTranslations } from 'use-intl';
|
|
5
|
+
import { OTP_MAX_LENGTH } from "../checkout-core/models/checkout.constants.js";
|
|
6
|
+
import { telHref } from "../checkout-core/models/checkout.phone.utils.js";
|
|
7
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
8
|
+
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
9
|
+
import { SheetInput, SheetText } from "./SheetText.js";
|
|
10
|
+
import { FIELD_HEIGHT, FIELD_RADIUS, PRESSED_OPACITY, } from "../models/sheet.constants.js";
|
|
11
|
+
/**
|
|
12
|
+
* OTP methods: Dial opens the network's code in the phone dialler for a
|
|
13
|
+
* one-time payment code (on Android; on iOS it says to dial it by hand);
|
|
14
|
+
* back in the app the code field comes up, filled from the SMS when the
|
|
15
|
+
* phone offers it. Sent once with Pay, never kept.
|
|
16
|
+
*/
|
|
17
|
+
export function SheetCodeField({ core }) {
|
|
18
|
+
const t = useTranslations('checkout');
|
|
19
|
+
const { colors, brand } = useSheetTheme();
|
|
20
|
+
const { ui, derived, actions } = core;
|
|
21
|
+
// Shown only while an OTP method, which always has its code, is picked.
|
|
22
|
+
const method = derived.selected;
|
|
23
|
+
const code = method.otpCode;
|
|
24
|
+
const field = useRef(null);
|
|
25
|
+
const [focused, setFocused] = useState(false);
|
|
26
|
+
/** Waiting for the payer to come back from the dialler. */
|
|
27
|
+
const away = useRef(null);
|
|
28
|
+
const stopWaiting = () => {
|
|
29
|
+
away.current?.remove();
|
|
30
|
+
away.current = null;
|
|
31
|
+
};
|
|
32
|
+
useEffect(() => stopWaiting, []);
|
|
33
|
+
const dial = () => {
|
|
34
|
+
// The iPhone's Phone app refuses a tel: link with * or #: say to dial it by hand.
|
|
35
|
+
if (Platform.OS === 'ios') {
|
|
36
|
+
actions.cannotDial();
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
stopWaiting();
|
|
40
|
+
away.current = AppState.addEventListener('change', (state) => {
|
|
41
|
+
if (state !== 'active')
|
|
42
|
+
return;
|
|
43
|
+
stopWaiting();
|
|
44
|
+
field.current?.focus();
|
|
45
|
+
});
|
|
46
|
+
Linking.openURL(telHref(code)).catch(() => {
|
|
47
|
+
stopWaiting();
|
|
48
|
+
actions.cannotDial();
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
return (_jsxs(View, { style: styles.section, children: [_jsx(SheetText, { weight: FigtreeEnum.BOLD, style: styles.label, children: t('otp_label') }), _jsx(SheetInput, { ref: field, accessibilityLabel: t('otp_label'), keyboardType: "number-pad", textContentType: "oneTimeCode", autoComplete: "sms-otp",
|
|
52
|
+
// iOS's number keypads have no Go key: asking for one adds a bar above them.
|
|
53
|
+
returnKeyType: Platform.OS === 'android' ? 'go' : undefined, maxLength: OTP_MAX_LENGTH, value: ui.code, onChangeText: actions.setCode, onFocus: () => setFocused(true), onBlur: () => setFocused(false), onSubmitEditing: actions.pay, editable: !ui.submitting, style: [styles.input, { borderColor: focused ? brand : colors.line3 }] }), _jsxs(View, { style: [styles.help, { backgroundColor: colors.fill2 }], children: [_jsx(SheetText, { paragraph: true, size: 13, color: colors.ink2, style: styles.grow, children: t('otp_help', { method: method.name }) }), _jsxs(TouchableOpacity, { onPress: dial, activeOpacity: PRESSED_OPACITY, accessibilityRole: "button", accessibilityLabel: t('sheet.dial', { code }), style: [
|
|
54
|
+
styles.dial,
|
|
55
|
+
{ borderColor: colors.line3, backgroundColor: colors.surface },
|
|
56
|
+
], children: [_jsx(View, { style: [styles.phone, { borderColor: colors.ink }], children: _jsx(View, { style: [styles.speaker, { backgroundColor: colors.ink }] }) }), _jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 14, children: code })] })] })] }));
|
|
57
|
+
}
|
|
58
|
+
const styles = StyleSheet.create({
|
|
59
|
+
section: { marginTop: 10 },
|
|
60
|
+
label: { marginBottom: 8 },
|
|
61
|
+
input: {
|
|
62
|
+
height: FIELD_HEIGHT,
|
|
63
|
+
borderWidth: 1,
|
|
64
|
+
borderRadius: FIELD_RADIUS,
|
|
65
|
+
paddingHorizontal: 14,
|
|
66
|
+
fontSize: 18,
|
|
67
|
+
letterSpacing: 5,
|
|
68
|
+
},
|
|
69
|
+
help: {
|
|
70
|
+
flexDirection: 'row',
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
gap: 12,
|
|
73
|
+
borderRadius: 12,
|
|
74
|
+
paddingHorizontal: 14,
|
|
75
|
+
paddingVertical: 12,
|
|
76
|
+
marginTop: 12,
|
|
77
|
+
},
|
|
78
|
+
grow: { flex: 1 },
|
|
79
|
+
dial: {
|
|
80
|
+
flexDirection: 'row',
|
|
81
|
+
alignItems: 'center',
|
|
82
|
+
gap: 6,
|
|
83
|
+
borderWidth: 1,
|
|
84
|
+
borderRadius: 9,
|
|
85
|
+
paddingHorizontal: 12,
|
|
86
|
+
minHeight: 40,
|
|
87
|
+
},
|
|
88
|
+
phone: {
|
|
89
|
+
width: 10,
|
|
90
|
+
height: 16,
|
|
91
|
+
borderWidth: 1.6,
|
|
92
|
+
borderRadius: 3,
|
|
93
|
+
alignItems: 'center',
|
|
94
|
+
justifyContent: 'flex-end',
|
|
95
|
+
paddingBottom: 1.5,
|
|
96
|
+
},
|
|
97
|
+
speaker: { width: 3, height: 1.4, borderRadius: 0.7 },
|
|
98
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SheetContentProps } from '../models/sheet.interface.js';
|
|
2
|
+
/** The sheet's screens, driven by the shared checkout controller. */
|
|
3
|
+
export declare function SheetContent({ payment, fontsReady, deviceLocale, ipCountry, onClose, dragHandlers, backRef, }: SheetContentProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
3
|
+
import { StyleSheet, View } from 'react-native';
|
|
4
|
+
import { useTranslations } from 'use-intl';
|
|
5
|
+
import { useCheckoutController } from "../checkout-core/hooks/use-checkout-controller.js";
|
|
6
|
+
import { CURRENCY_LABEL, FLOW_TRAITS, } from "../checkout-core/models/checkout.constants.js";
|
|
7
|
+
import { CheckoutScreenEnum, CheckoutStepEnum, CheckoutTabEnum, TerminalKindEnum, } from "../checkout-core/models/checkout.enum.js";
|
|
8
|
+
import { formatAmount } from "../checkout-core/models/checkout.money.utils.js";
|
|
9
|
+
import { useNativePlatform } from "../hooks/use-native-platform.js";
|
|
10
|
+
import { useSheetResize } from "../hooks/use-sheet-resize.js";
|
|
11
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
12
|
+
import { useStoreTab } from "../hooks/use-store-tab.js";
|
|
13
|
+
import { SHEET_TOP_RADIUS } from "../models/sheet.constants.js";
|
|
14
|
+
import { SheetButton } from "./SheetButton.js";
|
|
15
|
+
import { SheetFailed } from "./SheetFailed.js";
|
|
16
|
+
import { SheetForm } from "./SheetForm.js";
|
|
17
|
+
import { SheetHeader } from "./SheetHeader.js";
|
|
18
|
+
import { SheetLayout } from "./SheetLayout.js";
|
|
19
|
+
import { SheetMessage } from "./SheetMessage.js";
|
|
20
|
+
import { SheetSkeleton } from "./SheetSkeleton.js";
|
|
21
|
+
import { SheetStep } from "./SheetStep.js";
|
|
22
|
+
import { SheetSuccess } from "./SheetSuccess.js";
|
|
23
|
+
import { SheetPaypalButton } from "./SheetPaypalButton.js";
|
|
24
|
+
import { SheetSummary } from "./SheetSummary.js";
|
|
25
|
+
import { SheetTerminal } from "./SheetTerminal.js";
|
|
26
|
+
import { SheetToast } from "./SheetToast.js";
|
|
27
|
+
import { SheetWaiting } from "./SheetWaiting.js";
|
|
28
|
+
const TERMINAL_KIND = {
|
|
29
|
+
[CheckoutScreenEnum.EXPIRED]: TerminalKindEnum.EXPIRED,
|
|
30
|
+
[CheckoutScreenEnum.CANCELLED]: TerminalKindEnum.CANCELLED,
|
|
31
|
+
[CheckoutScreenEnum.LOCKED]: TerminalKindEnum.LOCKED,
|
|
32
|
+
[CheckoutScreenEnum.NO_METHOD]: TerminalKindEnum.NO_METHOD,
|
|
33
|
+
[CheckoutScreenEnum.UNAVAILABLE]: TerminalKindEnum.UNAVAILABLE,
|
|
34
|
+
};
|
|
35
|
+
/** The sheet's screens, driven by the shared checkout controller. */
|
|
36
|
+
export function SheetContent({ payment, fontsReady, deviceLocale, ipCountry, onClose, dragHandlers, backRef, }) {
|
|
37
|
+
const t = useTranslations('checkout');
|
|
38
|
+
const { colors } = useSheetTheme();
|
|
39
|
+
const clues = useMemo(() => ({ ipCountry: ipCountry ?? null, languages: [deviceLocale] }), [ipCountry, deviceLocale]);
|
|
40
|
+
const phoneRef = useRef(null);
|
|
41
|
+
const { platform, cardFields } = useNativePlatform(onClose, phoneRef);
|
|
42
|
+
// Shown once the payer's country is known too: the tab it opens on never jumps.
|
|
43
|
+
const view = ipCountry === undefined ? undefined : payment.view;
|
|
44
|
+
const core = useCheckoutController(view, {
|
|
45
|
+
clues,
|
|
46
|
+
calls: payment.calls,
|
|
47
|
+
platform,
|
|
48
|
+
});
|
|
49
|
+
const { ui, derived, actions } = core;
|
|
50
|
+
const { screen } = derived;
|
|
51
|
+
const store = useStoreTab(core, payment.calls.mutations.store);
|
|
52
|
+
const onStore = ui.tab === CheckoutTabEnum.STORE && !!store;
|
|
53
|
+
// A payment that could not load, or could not be priced, is not loading any more.
|
|
54
|
+
const failed = payment.failed && (view === undefined || view?.priced === false);
|
|
55
|
+
const loading = !fontsReady || (screen === CheckoutScreenEnum.LOADING && !failed);
|
|
56
|
+
const terminal = TERMINAL_KIND[screen];
|
|
57
|
+
const { step } = derived;
|
|
58
|
+
const details = step === CheckoutStepEnum.DETAILS;
|
|
59
|
+
const busy = ui.submitting || ui.cardPaying;
|
|
60
|
+
// The form shows: the methods, or the details of the method picked.
|
|
61
|
+
const onForm = !loading &&
|
|
62
|
+
!failed &&
|
|
63
|
+
(screen === CheckoutScreenEnum.FORM ||
|
|
64
|
+
screen === CheckoutScreenEnum.SUBMITTING);
|
|
65
|
+
const canGoBack = onForm && details && !busy;
|
|
66
|
+
const back = actions.backToMethods;
|
|
67
|
+
// Android's back on the details goes back a step, not out of the sheet.
|
|
68
|
+
useEffect(() => {
|
|
69
|
+
backRef.current = canGoBack
|
|
70
|
+
? () => {
|
|
71
|
+
back();
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
: null;
|
|
75
|
+
});
|
|
76
|
+
useSheetResize([
|
|
77
|
+
loading,
|
|
78
|
+
failed,
|
|
79
|
+
screen,
|
|
80
|
+
step,
|
|
81
|
+
ui.tab,
|
|
82
|
+
!!store,
|
|
83
|
+
ui.country,
|
|
84
|
+
derived.selected?.id,
|
|
85
|
+
core.cardHeight,
|
|
86
|
+
Boolean(core.phone.status.error || derived.mismatch),
|
|
87
|
+
].join('|'));
|
|
88
|
+
let body;
|
|
89
|
+
if (loading) {
|
|
90
|
+
body = (_jsx(SheetLayout, { secure: false, children: _jsx(SheetSkeleton, {}) }));
|
|
91
|
+
}
|
|
92
|
+
else if (failed) {
|
|
93
|
+
body = (_jsx(SheetLayout, { secure: false, children: _jsx(SheetMessage, { title: t('error.title'), body: t('error.body') }) }));
|
|
94
|
+
}
|
|
95
|
+
else if (screen === CheckoutScreenEnum.INVALID) {
|
|
96
|
+
body = (_jsx(SheetLayout, { secure: false, children: _jsx(SheetMessage, { title: t('invalid.title'), body: t('invalid.body') }) }));
|
|
97
|
+
}
|
|
98
|
+
else if (terminal) {
|
|
99
|
+
body = _jsx(SheetTerminal, { core: core, kind: terminal, onClose: onClose });
|
|
100
|
+
}
|
|
101
|
+
else if (screen === CheckoutScreenEnum.WAITING) {
|
|
102
|
+
body = _jsx(SheetWaiting, { core: core });
|
|
103
|
+
}
|
|
104
|
+
else if (screen === CheckoutScreenEnum.FAILED) {
|
|
105
|
+
body = _jsx(SheetFailed, { core: core });
|
|
106
|
+
}
|
|
107
|
+
else if (screen === CheckoutScreenEnum.SUCCESS ||
|
|
108
|
+
// Done counted down: the sheet slides away on its receipt.
|
|
109
|
+
screen === CheckoutScreenEnum.REDIRECT) {
|
|
110
|
+
body = _jsx(SheetSuccess, { core: core, onClose: onClose });
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
body = (_jsx(SheetLayout, { foot: onStore ? (_jsx(SheetButton, { label: busy
|
|
114
|
+
? t('sending')
|
|
115
|
+
: t('sheet.store_pay', { price: store.offer.displayPrice }), busy: busy, onPress: store.buy })) : derived.selected &&
|
|
116
|
+
FLOW_TRAITS[derived.selected.flow].ownButton ? (_jsx(SheetPaypalButton, { busy: busy, onPress: actions.pay })) : details ? (_jsx(SheetButton, { label: busy
|
|
117
|
+
? t('sending')
|
|
118
|
+
: t('pay_plain', {
|
|
119
|
+
amount: formatAmount(derived.total.amount, derived.total.currency),
|
|
120
|
+
currency: CURRENCY_LABEL[derived.total.currency],
|
|
121
|
+
}), busy: busy, inactive: !derived.canPay, onPress: actions.pay })) : (_jsx(SheetButton, { label: t('continue'), inactive: !derived.selected, onPress: actions.continueToDetails })), children: _jsxs(SheetStep, { core: core, phoneRef: phoneRef, children: [!details && _jsx(SheetSummary, { total: derived.total }), _jsx(SheetForm, { core: core, phoneRef: phoneRef, cardFields: cardFields, store: store })] }) }));
|
|
122
|
+
}
|
|
123
|
+
return (_jsxs(View, { testID: "payment-sheet", accessibilityViewIsModal: true, onAccessibilityEscape: onClose, style: [styles.sheet, { backgroundColor: colors.surface }], children: [_jsx(SheetHeader, { view: view, loading: loading, onClose: onClose, onBack: canGoBack ? back : undefined, dragHandlers: dragHandlers }), body, _jsx(SheetToast, { toast: core.toast })] }));
|
|
124
|
+
}
|
|
125
|
+
const styles = StyleSheet.create({
|
|
126
|
+
// As tall as its screen; past the room it has, the screen scrolls.
|
|
127
|
+
sheet: {
|
|
128
|
+
flexShrink: 1,
|
|
129
|
+
borderTopLeftRadius: SHEET_TOP_RADIUS,
|
|
130
|
+
borderTopRightRadius: SHEET_TOP_RADIUS,
|
|
131
|
+
overflow: 'hidden',
|
|
132
|
+
},
|
|
133
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SheetScreenProps } from '../models/sheet.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* A payer with no prompt and no new request left: the network's USSD steps, or the
|
|
4
|
+
* method's code to see pending payments, with one tap to dial where a code is
|
|
5
|
+
* given (on Android; on iOS it says to dial it by hand).
|
|
6
|
+
*/
|
|
7
|
+
export declare function SheetDial({ core }: SheetScreenProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Linking, Platform, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useTranslations } from 'use-intl';
|
|
4
|
+
import { CheckoutButtonVariantEnum } from "../checkout-core/models/checkout.enum.js";
|
|
5
|
+
import { telHref } from "../checkout-core/models/checkout.phone.utils.js";
|
|
6
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
7
|
+
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
8
|
+
import { SheetButton } from "./SheetButton.js";
|
|
9
|
+
import { SheetText } from "./SheetText.js";
|
|
10
|
+
/**
|
|
11
|
+
* A payer with no prompt and no new request left: the network's USSD steps, or the
|
|
12
|
+
* method's code to see pending payments, with one tap to dial where a code is
|
|
13
|
+
* given (on Android; on iOS it says to dial it by hand).
|
|
14
|
+
*/
|
|
15
|
+
export function SheetDial({ core }) {
|
|
16
|
+
const t = useTranslations('checkout');
|
|
17
|
+
const { colors } = useSheetTheme();
|
|
18
|
+
const { channels, pendingCode } = core.dialHelp;
|
|
19
|
+
const dial = (code) => {
|
|
20
|
+
// The iPhone's Phone app refuses a tel: link with * or #: say to dial it by hand.
|
|
21
|
+
if (Platform.OS === 'ios') {
|
|
22
|
+
core.actions.cannotDialCode(code);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
Linking.openURL(telHref(code)).catch(() => {
|
|
26
|
+
core.actions.cannotDialCode(code);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
return (_jsxs(_Fragment, { children: [channels.map(({ title, steps, quickLink }) => (_jsxs(View, { style: styles.block, children: [_jsx(SheetText, { weight: FigtreeEnum.BOLD, accessibilityRole: "header", children: title }), quickLink && (_jsx(SheetButton, { variant: CheckoutButtonVariantEnum.SECONDARY, label: t('sheet.dial', { code: quickLink }), onPress: () => dial(quickLink) })), steps.map((step, index) => (_jsxs(View, { style: styles.step, children: [_jsxs(SheetText, { weight: FigtreeEnum.BOLD, style: styles.number, children: [index + 1, "."] }), _jsx(SheetText, { paragraph: true, size: 14, style: styles.text, children: step })] }, step)))] }, steps.join()))), pendingCode && (_jsxs(View, { style: styles.block, children: [_jsx(SheetText, { weight: FigtreeEnum.BOLD, children: t('no_prompt') }), _jsx(SheetText, { paragraph: true, size: 14, color: colors.muted, children: t('dial_pending') }), _jsx(SheetButton, { variant: CheckoutButtonVariantEnum.SECONDARY, label: t('sheet.dial', { code: pendingCode }), onPress: () => dial(pendingCode) })] }))] }));
|
|
30
|
+
}
|
|
31
|
+
const styles = StyleSheet.create({
|
|
32
|
+
block: { marginTop: 18, gap: 10 },
|
|
33
|
+
step: { flexDirection: 'row', gap: 8 },
|
|
34
|
+
number: { width: 20 },
|
|
35
|
+
text: { flex: 1 },
|
|
36
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useTranslations } from 'use-intl';
|
|
4
|
+
import { CheckoutButtonVariantEnum, FlowAskEnum, } from "../checkout-core/models/checkout.enum.js";
|
|
5
|
+
import { FLOW_TRAITS } from "../checkout-core/models/checkout.constants.js";
|
|
6
|
+
import { FailureReasonEnum } from "../checkout-core/models/domain.enum.js";
|
|
7
|
+
import { formatMoney } from "../checkout-core/models/checkout.money.utils.js";
|
|
8
|
+
import { logoOf } from "../checkout-core/models/checkout.view.utils.js";
|
|
9
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
10
|
+
import { FigtreeEnum, SheetIconEnum } from "../models/sheet.enum.js";
|
|
11
|
+
import { SheetButton } from "./SheetButton.js";
|
|
12
|
+
import { SheetIcon } from "./SheetIcon.js";
|
|
13
|
+
import { SheetLayout } from "./SheetLayout.js";
|
|
14
|
+
import { SheetLogo } from "./SheetLogo.js";
|
|
15
|
+
import { SheetRow } from "./SheetRow.js";
|
|
16
|
+
import { SheetText } from "./SheetText.js";
|
|
17
|
+
/** The last attempt failed: why, in plain words, Try again and another method. */
|
|
18
|
+
export function SheetFailed({ core }) {
|
|
19
|
+
const t = useTranslations('checkout');
|
|
20
|
+
const { colors } = useSheetTheme();
|
|
21
|
+
const { view, ui, derived, actions } = core;
|
|
22
|
+
const attempt = view.attempt;
|
|
23
|
+
// A failure only ever comes with its reason.
|
|
24
|
+
const reason = attempt.failureReason;
|
|
25
|
+
const values = { method: attempt.methodName };
|
|
26
|
+
const { suggestion } = derived;
|
|
27
|
+
return (_jsx(SheetLayout, { foot: _jsxs(_Fragment, { children: [_jsx(SheetButton, { label: ui.submitting
|
|
28
|
+
? t('sending')
|
|
29
|
+
: FLOW_TRAITS[attempt.flow].asks.includes(FlowAskEnum.CODE)
|
|
30
|
+
? t('retry_code')
|
|
31
|
+
: t('retry'), busy: ui.submitting, onPress: actions.retry }), _jsx(SheetButton, { variant: CheckoutButtonVariantEnum.PLAIN, label: suggestion
|
|
32
|
+
? t('try_with', { method: suggestion.name })
|
|
33
|
+
: t('use_another'), onPress: actions.useAnother })] }), children: _jsxs(View, { style: styles.failed, children: [_jsx(SheetIcon, { kind: SheetIconEnum.CROSS, color: colors.danger, background: colors.dangerSoft }), _jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 22, accessibilityRole: "header", style: styles.title, children: t(`failure.${reason}.title`, values) }), _jsx(SheetText, { paragraph: true, size: 15, color: colors.inkStrong, children: t(`failure.${reason}.body`, values) }), _jsx(SheetText, { paragraph: true, color: colors.ink2, style: styles.next, children: t(`failure.${reason}.next`, values) }), _jsxs(View, { style: [styles.rows, { borderColor: colors.line }], children: [_jsx(SheetRow, { label: t('amount'), children: formatMoney(attempt.price.amount, attempt.price.currency) }), _jsxs(SheetRow, { label: t('method'), children: [_jsx(SheetLogo, { logo: logoOf(attempt) }), _jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, children: attempt.methodName })] }), _jsx(SheetRow, { label: t('tries_left'), children: t('tries_value', {
|
|
34
|
+
left: view.attemptsLeft,
|
|
35
|
+
max: view.maxAttempts,
|
|
36
|
+
}) })] }), reason !== FailureReasonEnum.MISMATCH && (_jsx(SheetText, { paragraph: true, size: 13, color: colors.muted, style: styles.note, children: t('not_charged') }))] }) }));
|
|
37
|
+
}
|
|
38
|
+
const styles = StyleSheet.create({
|
|
39
|
+
failed: { paddingHorizontal: 18, paddingTop: 28 },
|
|
40
|
+
title: { marginTop: 16, marginBottom: 8, letterSpacing: -0.4 },
|
|
41
|
+
next: { marginTop: 8 },
|
|
42
|
+
rows: { borderTopWidth: 1, marginTop: 20 },
|
|
43
|
+
note: { marginTop: 16, textAlign: 'center' },
|
|
44
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { SheetFormProps } from '../models/sheet.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* The form, in two steps. The methods: "Pay with" and, when there are several,
|
|
4
|
+
* the country in a pill that lists them over the sheet, the Mobile Money / Card tabs (and the phone's store, for a product it
|
|
5
|
+
* sells) and the methods two by two, the one picked ticked. The details: the method picked, with Change, then the number and
|
|
6
|
+
* the payment code of an OTP method, a card's fields, or a bank redirect's account holder.
|
|
7
|
+
*/
|
|
8
|
+
export declare function SheetForm({ core, phoneRef, cardFields, store, }: SheetFormProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Animated, Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useTranslations } from 'use-intl';
|
|
4
|
+
import { CheckoutButtonVariantEnum, CheckoutStepEnum, CheckoutTabEnum, FlowAskEnum, MethodLineEnum, MethodStateEnum, } from "../checkout-core/models/checkout.enum.js";
|
|
5
|
+
import { FLOW_TRAITS } from "../checkout-core/models/checkout.constants.js";
|
|
6
|
+
import { logoOf, methodLineOf, } from "../checkout-core/models/checkout.view.utils.js";
|
|
7
|
+
import { useShake } from "../hooks/use-shake.js";
|
|
8
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
9
|
+
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
10
|
+
import { flagOf } from "../models/sheet.utils.js";
|
|
11
|
+
import { SheetButton } from "./SheetButton.js";
|
|
12
|
+
import { SheetCardFields } from "./SheetCardFields.js";
|
|
13
|
+
import { SheetChosenMethod } from "./SheetChosenMethod.js";
|
|
14
|
+
import { SheetCodeField } from "./SheetCodeField.js";
|
|
15
|
+
import { SheetMethodCard } from "./SheetMethodCard.js";
|
|
16
|
+
import { SheetNameField } from "./SheetNameField.js";
|
|
17
|
+
import { SheetPhoneField } from "./SheetPhoneField.js";
|
|
18
|
+
import { SheetPillSelect } from "./SheetPillSelect.js";
|
|
19
|
+
import { SheetStoreTab } from "./SheetStoreTab.js";
|
|
20
|
+
import { SheetText } from "./SheetText.js";
|
|
21
|
+
import { FIELD_HEIGHT, FIELD_RADIUS, STORE_TABS, TABS_INSET, } from "../models/sheet.constants.js";
|
|
22
|
+
/** Cards two a row, the last one alone when they are odd; red after Continue with none picked. */
|
|
23
|
+
function GridRows({ cards, missing, alone }) {
|
|
24
|
+
const rows = [];
|
|
25
|
+
for (let index = 0; index < cards.length; index += 2) {
|
|
26
|
+
rows.push(cards.slice(index, index + 2));
|
|
27
|
+
}
|
|
28
|
+
return rows.map((row) => (_jsxs(View, { style: styles.gridRow, children: [row.map(({ id, ...card }) => (_jsx(SheetMethodCard, { ...card, missing: missing, alone: alone }, id))), row.length === 1 && !alone && _jsx(View, { style: styles.gridSpacer })] }, row[0].id)));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The tab's methods, a lone one full width, or a line saying it has none; then, on the Card tab of a
|
|
32
|
+
* guessed country, the other countries' bank redirects behind "Paying from
|
|
33
|
+
* another country?". Red with a hint, and shaken, after Continue with none picked.
|
|
34
|
+
*/
|
|
35
|
+
function MethodGrid({ cards, others, missing }) {
|
|
36
|
+
const t = useTranslations('checkout');
|
|
37
|
+
const { colors } = useSheetTheme();
|
|
38
|
+
const shake = useShake(missing);
|
|
39
|
+
return (_jsxs(Animated.View, { testID: "method-grid", accessibilityRole: "radiogroup", style: [styles.grid, { transform: [{ translateX: shake }] }], children: [cards.length === 0 && !others ? (_jsx(View, { style: styles.empty, children: _jsx(SheetText, { size: 13, color: colors.muted, style: styles.emptyText, children: t('tab_empty') }) })) : (_jsx(GridRows, { cards: cards, missing: missing > 0, alone: cards.length === 1 })), others &&
|
|
40
|
+
(others.open ? (_jsxs(View, { style: styles.others, children: [_jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, size: 13, color: colors.muted, children: t('bank.other_countries') }), _jsx(GridRows, { cards: others.cards, missing: missing > 0, alone: false })] })) : (_jsx(View, { style: styles.othersLink, children: _jsx(SheetButton, { variant: CheckoutButtonVariantEnum.LINK, label: t('bank.other_countries'), onPress: others.onOpen }) }))), missing > 0 && (_jsx(SheetText, { accessibilityRole: "alert", weight: FigtreeEnum.MEDIUM, size: 13, color: colors.danger, children: t('method_missing') }))] }));
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The form, in two steps. The methods: "Pay with" and, when there are several,
|
|
44
|
+
* the country in a pill that lists them over the sheet, the Mobile Money / Card tabs (and the phone's store, for a product it
|
|
45
|
+
* sells) and the methods two by two, the one picked ticked. The details: the method picked, with Change, then the number and
|
|
46
|
+
* the payment code of an OTP method, a card's fields, or a bank redirect's account holder.
|
|
47
|
+
*/
|
|
48
|
+
export function SheetForm({ core, phoneRef, cardFields, store, }) {
|
|
49
|
+
const t = useTranslations('checkout');
|
|
50
|
+
const { colors } = useSheetTheme();
|
|
51
|
+
const { ui, derived, actions } = core;
|
|
52
|
+
const onCard = ui.tab === CheckoutTabEnum.CARD;
|
|
53
|
+
const onStore = ui.tab === CheckoutTabEnum.STORE && !!store;
|
|
54
|
+
const { selected } = derived;
|
|
55
|
+
const countryName = (country) => t(`countries.${country}`);
|
|
56
|
+
if (derived.step === CheckoutStepEnum.DETAILS) {
|
|
57
|
+
// What the picked method's flow asks for, in the order the fields show.
|
|
58
|
+
const { asks } = FLOW_TRAITS[selected.flow];
|
|
59
|
+
return (_jsxs(View, { style: styles.form, children: [_jsx(SheetChosenMethod, { logo: logoOf(selected), name: selected.name, sub: methodLineOf(selected, countryName), onChange: actions.backToMethods }), asks.includes(FlowAskEnum.PHONE) && (_jsx(SheetPhoneField, { core: core, phoneRef: phoneRef })), asks.includes(FlowAskEnum.CODE) && _jsx(SheetCodeField, { core: core }), asks.includes(FlowAskEnum.CARD) && (_jsx(SheetCardFields, { core: core, bridge: cardFields })), asks.includes(FlowAskEnum.NAME) && _jsx(SheetNameField, { core: core })] }));
|
|
60
|
+
}
|
|
61
|
+
const subOf = (method) => method.state === MethodStateEnum.SOON
|
|
62
|
+
? t('soon')
|
|
63
|
+
: method.state === MethodStateEnum.MAINTENANCE
|
|
64
|
+
? (method.note ?? t('unavailable'))
|
|
65
|
+
: FLOW_TRAITS[method.flow].line === MethodLineEnum.CHARGED_IN
|
|
66
|
+
? t('charged_in', { currency: method.price.currency })
|
|
67
|
+
: methodLineOf(method, countryName);
|
|
68
|
+
const cardOf = (method) => ({
|
|
69
|
+
id: method.id,
|
|
70
|
+
logo: logoOf(method),
|
|
71
|
+
name: method.name,
|
|
72
|
+
sub: subOf(method),
|
|
73
|
+
muted: method.state !== MethodStateEnum.AVAILABLE,
|
|
74
|
+
checked: method.id === selected?.id,
|
|
75
|
+
onSelect: () => actions.selectMethod(method),
|
|
76
|
+
});
|
|
77
|
+
// Wallets still to come stay off the sheet: only what can be paid with today.
|
|
78
|
+
const cards = onCard ? derived.cards.map(cardOf) : derived.wallets.map(cardOf);
|
|
79
|
+
const others = onCard && derived.otherBanks.length > 0
|
|
80
|
+
? {
|
|
81
|
+
cards: derived.otherBanks.map(cardOf),
|
|
82
|
+
open: derived.otherBanksOpen,
|
|
83
|
+
onOpen: actions.showOtherBanks,
|
|
84
|
+
}
|
|
85
|
+
: undefined;
|
|
86
|
+
const tab = (value, label) => {
|
|
87
|
+
const on = ui.tab === value;
|
|
88
|
+
return (_jsx(Pressable, { onPress: () => actions.setTab(value), accessibilityRole: "tab", accessibilityState: { selected: on }, style: [
|
|
89
|
+
styles.tab,
|
|
90
|
+
on && [styles.tabOn, { backgroundColor: colors.tabOn }],
|
|
91
|
+
], children: _jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, size: 13.5, color: on ? colors.ink : colors.muted, numberOfLines: 1, adjustsFontSizeToFit: true, minimumFontScale: 0.8, children: label }) }));
|
|
92
|
+
};
|
|
93
|
+
// Only Mobile Money methods have a country; with one, there is nothing to pick.
|
|
94
|
+
const pickCountry = !onCard && !onStore && derived.countries.length > 1;
|
|
95
|
+
return (_jsxs(View, { style: styles.form, children: [_jsxs(View, { style: styles.payWith, children: [_jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 15, children: t('pay_with') }), pickCountry && (_jsx(SheetPillSelect, { value: ui.country, options: derived.countries.map((country) => ({
|
|
96
|
+
value: country,
|
|
97
|
+
label: t(`countries.${country}`),
|
|
98
|
+
flag: flagOf(country),
|
|
99
|
+
})), onChange: actions.setCountry, accessibilityLabel: t('country'), disabled: ui.submitting }))] }), _jsxs(View, { testID: "sheet-tabs", accessibilityRole: "tablist", style: [styles.tabs, { backgroundColor: colors.fill }], children: [tab(CheckoutTabEnum.MOBILE_MONEY, t('tab_wallet')), tab(CheckoutTabEnum.CARD, t('tab_card')), store && tab(CheckoutTabEnum.STORE, STORE_TABS[store.store].name)] }), onStore ? (_jsx(SheetStoreTab, { store: store })) : (_jsx(MethodGrid, { cards: cards, others: others, missing: ui.methodMissing }))] }));
|
|
100
|
+
}
|
|
101
|
+
const styles = StyleSheet.create({
|
|
102
|
+
form: { paddingHorizontal: 18, paddingTop: 14, paddingBottom: 8 },
|
|
103
|
+
// The web's min-h-9 row: the tabs stay put when the pill comes and goes.
|
|
104
|
+
payWith: {
|
|
105
|
+
minHeight: 36,
|
|
106
|
+
flexDirection: 'row',
|
|
107
|
+
alignItems: 'center',
|
|
108
|
+
justifyContent: 'space-between',
|
|
109
|
+
gap: 12,
|
|
110
|
+
},
|
|
111
|
+
tabs: {
|
|
112
|
+
flexDirection: 'row',
|
|
113
|
+
height: FIELD_HEIGHT,
|
|
114
|
+
borderRadius: FIELD_RADIUS,
|
|
115
|
+
padding: TABS_INSET,
|
|
116
|
+
marginTop: 12,
|
|
117
|
+
},
|
|
118
|
+
tab: {
|
|
119
|
+
flex: 1,
|
|
120
|
+
alignItems: 'center',
|
|
121
|
+
justifyContent: 'center',
|
|
122
|
+
borderRadius: FIELD_RADIUS - TABS_INSET,
|
|
123
|
+
},
|
|
124
|
+
tabOn: {
|
|
125
|
+
shadowColor: 'black',
|
|
126
|
+
shadowOpacity: 0.12,
|
|
127
|
+
shadowRadius: 2,
|
|
128
|
+
shadowOffset: { width: 0, height: 1 },
|
|
129
|
+
elevation: 1,
|
|
130
|
+
},
|
|
131
|
+
grid: { gap: 8, marginTop: 12 },
|
|
132
|
+
empty: { paddingVertical: 16 },
|
|
133
|
+
emptyText: { textAlign: 'center' },
|
|
134
|
+
gridRow: { flexDirection: 'row', gap: 8 },
|
|
135
|
+
// A card's flex share leaves out its padding and border (13 a side): the
|
|
136
|
+
// spacer takes the same, so a lone last card is as wide as the others.
|
|
137
|
+
gridSpacer: { flex: 1, paddingHorizontal: 13 },
|
|
138
|
+
// The web's mt-4 and its label's mt-2 before the cards.
|
|
139
|
+
others: { gap: 8, marginTop: 8 },
|
|
140
|
+
othersLink: { marginTop: 4 },
|
|
141
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
4
|
+
/** The small bar at the top of a sheet, the payment sheet's and the ones over it. */
|
|
5
|
+
export function SheetGrabber() {
|
|
6
|
+
const { colors } = useSheetTheme();
|
|
7
|
+
return _jsx(View, { style: [styles.grabber, { backgroundColor: colors.line3 }] });
|
|
8
|
+
}
|
|
9
|
+
const styles = StyleSheet.create({
|
|
10
|
+
grabber: {
|
|
11
|
+
alignSelf: 'center',
|
|
12
|
+
width: 38,
|
|
13
|
+
height: 5,
|
|
14
|
+
borderRadius: 3,
|
|
15
|
+
marginTop: 7,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SheetHeaderProps } from '../models/sheet.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* The grabber, then back to the methods on the details, the app being paid:
|
|
4
|
+
* its logo and name, the Test badge, and close. Dragged down, the sheet
|
|
5
|
+
* follows.
|
|
6
|
+
*/
|
|
7
|
+
export declare function SheetHeader({ view, loading, onClose, onBack, dragHandlers, }: SheetHeaderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Image, Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useTranslations } from 'use-intl';
|
|
4
|
+
import { MEDIA_LINE } from "../checkout-core/models/checkout.constants.js";
|
|
5
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
6
|
+
import { SHEET_BADGE_RADIUS, SHEET_BADGE_SIZE, } from "../models/sheet.constants.js";
|
|
7
|
+
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
8
|
+
import { SheetBone } from "./SheetBone.js";
|
|
9
|
+
import { SheetGrabber } from "./SheetGrabber.js";
|
|
10
|
+
import { SheetText } from "./SheetText.js";
|
|
11
|
+
/**
|
|
12
|
+
* The grabber, then back to the methods on the details, the app being paid:
|
|
13
|
+
* its logo and name, the Test badge, and close. Dragged down, the sheet
|
|
14
|
+
* follows.
|
|
15
|
+
*/
|
|
16
|
+
export function SheetHeader({ view, loading, onClose, onBack, dragHandlers, }) {
|
|
17
|
+
const t = useTranslations('checkout');
|
|
18
|
+
const { colors, brand } = useSheetTheme();
|
|
19
|
+
const app = view?.app;
|
|
20
|
+
return (_jsxs(View, { ...dragHandlers, children: [_jsx(SheetGrabber, {}), _jsxs(View, { style: styles.row, children: [onBack && (_jsx(Pressable, { onPress: onBack, accessibilityRole: "button", accessibilityLabel: t('back'), hitSlop: 8, style: styles.back, children: _jsx(View, { style: [styles.chevron, { borderColor: colors.ink }] }) })), loading ? (_jsxs(_Fragment, { children: [_jsx(SheetBone, { width: SHEET_BADGE_SIZE, height: SHEET_BADGE_SIZE, radius: SHEET_BADGE_RADIUS }), _jsx(View, { style: styles.name, children: _jsx(SheetBone, { width: 84, height: 14 }) })] })) : (app &&
|
|
21
|
+
(app.logoUrl ? (_jsx(Image, { testID: "app-logo", source: { uri: app.logoUrl }, accessibilityIgnoresInvertColors: true, style: styles.logo })) : (_jsx(View, { testID: "app-initial", style: [styles.initial, { backgroundColor: brand }], children: _jsx(SheetText, { weight: FigtreeEnum.EXTRA_BOLD, size: 18, color: "white", style: styles.centred, children: app.name.charAt(0) }) })))), !loading && (_jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 16, numberOfLines: 1, accessibilityRole: "header", style: [styles.name, styles.centred], children: app?.name ?? 'Brissoto Pay' })), !loading && view?.test && (_jsx(View, { style: [styles.badge, { backgroundColor: colors.warnSoft }], children: _jsx(SheetText, { weight: FigtreeEnum.EXTRA_BOLD, size: 10.5, color: colors.warnInk, style: [styles.badgeText, styles.centred], children: t('test_badge') }) })), _jsxs(Pressable, { onPress: onClose, accessibilityRole: "button", accessibilityLabel: t('close'), hitSlop: 8, style: [styles.close, { backgroundColor: colors.fill }], children: [_jsx(View, { style: [styles.bar, styles.barUp, { backgroundColor: colors.ink2 }] }), _jsx(View, { style: [
|
|
22
|
+
styles.bar,
|
|
23
|
+
styles.barDown,
|
|
24
|
+
{ backgroundColor: colors.ink2 },
|
|
25
|
+
] })] })] })] }));
|
|
26
|
+
}
|
|
27
|
+
const styles = StyleSheet.create({
|
|
28
|
+
row: {
|
|
29
|
+
flexDirection: 'row',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
gap: 10,
|
|
32
|
+
paddingHorizontal: 18,
|
|
33
|
+
paddingTop: 10,
|
|
34
|
+
},
|
|
35
|
+
logo: {
|
|
36
|
+
width: SHEET_BADGE_SIZE,
|
|
37
|
+
height: SHEET_BADGE_SIZE,
|
|
38
|
+
borderRadius: SHEET_BADGE_RADIUS,
|
|
39
|
+
borderWidth: 1,
|
|
40
|
+
borderColor: MEDIA_LINE,
|
|
41
|
+
},
|
|
42
|
+
initial: {
|
|
43
|
+
width: SHEET_BADGE_SIZE,
|
|
44
|
+
height: SHEET_BADGE_SIZE,
|
|
45
|
+
borderRadius: SHEET_BADGE_RADIUS,
|
|
46
|
+
alignItems: 'center',
|
|
47
|
+
justifyContent: 'center',
|
|
48
|
+
},
|
|
49
|
+
name: { flex: 1 },
|
|
50
|
+
// Android adds font padding above the ascender: without it, each text sits
|
|
51
|
+
// on the row's centre line like the logo, the badge and close.
|
|
52
|
+
centred: { includeFontPadding: false, textAlignVertical: 'center' },
|
|
53
|
+
badge: { borderRadius: 6, paddingHorizontal: 7, paddingVertical: 3 },
|
|
54
|
+
badgeText: { letterSpacing: 0.6, textTransform: 'uppercase' },
|
|
55
|
+
close: {
|
|
56
|
+
width: 30,
|
|
57
|
+
height: 30,
|
|
58
|
+
borderRadius: 15,
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
justifyContent: 'center',
|
|
61
|
+
},
|
|
62
|
+
bar: { position: 'absolute', width: 14, height: 2, borderRadius: 1 },
|
|
63
|
+
back: {
|
|
64
|
+
width: 30,
|
|
65
|
+
height: 30,
|
|
66
|
+
marginLeft: -6,
|
|
67
|
+
marginRight: -4,
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
justifyContent: 'center',
|
|
70
|
+
},
|
|
71
|
+
// Two strokes of a square turned a quarter: a chevron to the left, nudged to its middle.
|
|
72
|
+
chevron: {
|
|
73
|
+
width: 11,
|
|
74
|
+
height: 11,
|
|
75
|
+
marginLeft: 4,
|
|
76
|
+
borderLeftWidth: 2,
|
|
77
|
+
borderBottomWidth: 2,
|
|
78
|
+
borderRadius: 1,
|
|
79
|
+
transform: [{ rotate: '45deg' }],
|
|
80
|
+
},
|
|
81
|
+
barUp: { transform: [{ rotate: '45deg' }] },
|
|
82
|
+
barDown: { transform: [{ rotate: '-45deg' }] },
|
|
83
|
+
});
|