@brissoto/pay-react-native 0.0.0-stage → 1.4.5
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 +180 -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 +297 -0
- package/dist/checkout-core/messages/en.js +296 -0
- package/dist/checkout-core/messages/fr.d.ts +4 -0
- package/dist/checkout-core/messages/fr.js +297 -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 +230 -0
- package/dist/checkout-core/models/checkout.enum.js +256 -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 +696 -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 +328 -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 +132 -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 +139 -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 +3 -0
- package/dist/components/SheetTerminal.js +21 -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 +423 -0
- package/dist/models/sheet.interface.js +1 -0
- package/dist/models/sheet.utils.d.ts +68 -0
- package/dist/models/sheet.utils.js +211 -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,78 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { SHEET_BADGE_SIZE } from "../models/sheet.constants.js";
|
|
4
|
+
import { SheetIconEnum } from "../models/sheet.enum.js";
|
|
5
|
+
/** A sign in a disc, drawn with views: the sheet ships no icon font or SVG. */
|
|
6
|
+
export function SheetIcon({ kind, color, background, size = SHEET_BADGE_SIZE, }) {
|
|
7
|
+
const scale = size / 48;
|
|
8
|
+
const ink = { backgroundColor: color };
|
|
9
|
+
const line = { borderColor: color };
|
|
10
|
+
let sign;
|
|
11
|
+
switch (kind) {
|
|
12
|
+
case SheetIconEnum.CHECK:
|
|
13
|
+
sign = _jsx(View, { style: [styles.check, line] });
|
|
14
|
+
break;
|
|
15
|
+
case SheetIconEnum.CROSS:
|
|
16
|
+
// Crossed in a box of their own length: centred in the disc.
|
|
17
|
+
sign = (_jsxs(View, { style: styles.cross, children: [_jsx(View, { style: [styles.bar, styles.up, ink] }), _jsx(View, { style: [styles.bar, styles.down, ink] })] }));
|
|
18
|
+
break;
|
|
19
|
+
case SheetIconEnum.CLOCK:
|
|
20
|
+
sign = (_jsxs(View, { style: [styles.ring, line], children: [_jsx(View, { style: [styles.hour, ink] }), _jsx(View, { style: [styles.minute, ink] })] }));
|
|
21
|
+
break;
|
|
22
|
+
case SheetIconEnum.LOCK:
|
|
23
|
+
sign = (_jsxs(View, { style: styles.lock, children: [_jsx(View, { style: [styles.shackle, line] }), _jsx(View, { style: [styles.body, ink] })] }));
|
|
24
|
+
break;
|
|
25
|
+
default:
|
|
26
|
+
sign = (_jsx(View, { style: [styles.ring, line], children: _jsx(View, { style: [styles.slash, ink] }) }));
|
|
27
|
+
}
|
|
28
|
+
return (_jsx(View, { testID: `icon-${kind}`, style: [
|
|
29
|
+
styles.disc,
|
|
30
|
+
{
|
|
31
|
+
width: size,
|
|
32
|
+
height: size,
|
|
33
|
+
borderRadius: size / 2,
|
|
34
|
+
backgroundColor: background,
|
|
35
|
+
},
|
|
36
|
+
], children: _jsx(View, { style: { transform: [{ scale }] }, children: sign }) }));
|
|
37
|
+
}
|
|
38
|
+
const styles = StyleSheet.create({
|
|
39
|
+
disc: { alignItems: 'center', justifyContent: 'center' },
|
|
40
|
+
check: {
|
|
41
|
+
width: 10,
|
|
42
|
+
height: 18,
|
|
43
|
+
marginTop: -4,
|
|
44
|
+
borderRightWidth: 3,
|
|
45
|
+
borderBottomWidth: 3,
|
|
46
|
+
transform: [{ rotate: '45deg' }],
|
|
47
|
+
},
|
|
48
|
+
cross: {
|
|
49
|
+
width: 18,
|
|
50
|
+
height: 18,
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
},
|
|
54
|
+
bar: { position: 'absolute', width: 18, height: 2.6, borderRadius: 1.3 },
|
|
55
|
+
up: { transform: [{ rotate: '45deg' }] },
|
|
56
|
+
down: { transform: [{ rotate: '-45deg' }] },
|
|
57
|
+
ring: {
|
|
58
|
+
width: 20,
|
|
59
|
+
height: 20,
|
|
60
|
+
borderRadius: 10,
|
|
61
|
+
borderWidth: 2,
|
|
62
|
+
alignItems: 'center',
|
|
63
|
+
justifyContent: 'center',
|
|
64
|
+
},
|
|
65
|
+
slash: { width: 18, height: 2, transform: [{ rotate: '-45deg' }] },
|
|
66
|
+
hour: { position: 'absolute', width: 2, height: 6, top: 3, left: 7 },
|
|
67
|
+
minute: { position: 'absolute', width: 5, height: 2, top: 7, left: 7 },
|
|
68
|
+
lock: { alignItems: 'center' },
|
|
69
|
+
shackle: {
|
|
70
|
+
width: 12,
|
|
71
|
+
height: 10,
|
|
72
|
+
borderWidth: 2.4,
|
|
73
|
+
borderBottomWidth: 0,
|
|
74
|
+
borderTopLeftRadius: 6,
|
|
75
|
+
borderTopRightRadius: 6,
|
|
76
|
+
},
|
|
77
|
+
body: { width: 18, height: 12, borderRadius: 3 },
|
|
78
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SheetLayoutProps } from '../models/sheet.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* What scrolls, then "Payment secured by Brissoto Pay" over the actions
|
|
4
|
+
* pinned at the bottom, so Pay sits right on the keyboard. What scrolls is
|
|
5
|
+
* as tall as it is, until the sheet runs out of room. The keyboard pushes
|
|
6
|
+
* the actions up, without the room kept for the home bar: what scrolls
|
|
7
|
+
* follows to its end, where the number is. Once what scrolls fills the
|
|
8
|
+
* room the sheet has, its parts know how tall that room is, and one may
|
|
9
|
+
* hold it at its end.
|
|
10
|
+
*/
|
|
11
|
+
export declare function SheetLayout({ children, foot, secure, }: SheetLayoutProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
import { Keyboard, Platform, ScrollView, StyleSheet, View } from 'react-native';
|
|
4
|
+
import { useTranslations } from 'use-intl';
|
|
5
|
+
import { SheetRoomContext } from "../hooks/use-sheet-room.js";
|
|
6
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
7
|
+
import { SHEET_BODY_BOTTOM, SHEET_FOOT_BOTTOM, SHEET_FOOT_GAP, SHEET_FOOT_TOP, } from "../models/sheet.constants.js";
|
|
8
|
+
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
9
|
+
import { SheetText } from "./SheetText.js";
|
|
10
|
+
/**
|
|
11
|
+
* What scrolls, then "Payment secured by Brissoto Pay" over the actions
|
|
12
|
+
* pinned at the bottom, so Pay sits right on the keyboard. What scrolls is
|
|
13
|
+
* as tall as it is, until the sheet runs out of room. The keyboard pushes
|
|
14
|
+
* the actions up, without the room kept for the home bar: what scrolls
|
|
15
|
+
* follows to its end, where the number is. Once what scrolls fills the
|
|
16
|
+
* room the sheet has, its parts know how tall that room is, and one may
|
|
17
|
+
* hold it at its end.
|
|
18
|
+
*/
|
|
19
|
+
export function SheetLayout({ children, foot, secure = true, }) {
|
|
20
|
+
const t = useTranslations('checkout');
|
|
21
|
+
const { colors } = useSheetTheme();
|
|
22
|
+
const scroller = useRef(null);
|
|
23
|
+
const [keyboard, setKeyboard] = useState(false);
|
|
24
|
+
const [height, setHeight] = useState(0);
|
|
25
|
+
const [content, setContent] = useState(0);
|
|
26
|
+
const [pinned, setPinned] = useState(false);
|
|
27
|
+
// Taller content than shows: what scrolls is as tall as the sheet lets it be.
|
|
28
|
+
const room = content > height ? height - SHEET_BODY_BOTTOM : null;
|
|
29
|
+
const sheetRoom = useMemo(() => ({ room, pinEnd: setPinned }), [room]);
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (pinned)
|
|
32
|
+
scroller.current?.scrollToEnd();
|
|
33
|
+
}, [pinned, room]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
// iOS tells before the keyboard moves, Android only once it has.
|
|
36
|
+
const ios = Platform.OS === 'ios';
|
|
37
|
+
const listeners = [
|
|
38
|
+
Keyboard.addListener('keyboardDidShow', () => scroller.current?.scrollToEnd()),
|
|
39
|
+
Keyboard.addListener(ios ? 'keyboardWillShow' : 'keyboardDidShow', () => setKeyboard(true)),
|
|
40
|
+
Keyboard.addListener(ios ? 'keyboardWillHide' : 'keyboardDidHide', () => setKeyboard(false)),
|
|
41
|
+
];
|
|
42
|
+
return () => listeners.forEach((listener) => listener.remove());
|
|
43
|
+
}, []);
|
|
44
|
+
return (_jsxs(_Fragment, { children: [_jsx(ScrollView, { ref: scroller, style: styles.body, contentContainerStyle: styles.content, keyboardShouldPersistTaps: "handled", keyboardDismissMode: "interactive", scrollEnabled: !pinned, onLayout: ({ nativeEvent }) => setHeight(nativeEvent.layout.height), onContentSizeChange: (_width, tall) => setContent(tall), testID: "sheet-body", children: _jsx(SheetRoomContext, { value: sheetRoom, children: children }) }), (foot || secure) && (_jsxs(View, { testID: "sheet-foot", style: [
|
|
45
|
+
styles.foot,
|
|
46
|
+
keyboard && styles.footOnKeyboard,
|
|
47
|
+
{ borderColor: colors.line },
|
|
48
|
+
], children: [secure && (_jsxs(SheetText, { size: 11.5, color: colors.muted, style: styles.secure, children: [t('secured_by'), ' ', _jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 11.5, children: "Brissoto Pay" })] })), foot] }))] }));
|
|
49
|
+
}
|
|
50
|
+
const styles = StyleSheet.create({
|
|
51
|
+
body: { flexGrow: 0, flexShrink: 1, marginTop: 6 },
|
|
52
|
+
content: { paddingBottom: SHEET_BODY_BOTTOM },
|
|
53
|
+
foot: {
|
|
54
|
+
borderTopWidth: 1,
|
|
55
|
+
paddingHorizontal: 18,
|
|
56
|
+
paddingTop: SHEET_FOOT_TOP,
|
|
57
|
+
paddingBottom: SHEET_FOOT_BOTTOM,
|
|
58
|
+
gap: SHEET_FOOT_GAP,
|
|
59
|
+
},
|
|
60
|
+
footOnKeyboard: { paddingBottom: 12 },
|
|
61
|
+
// Android's extra font padding would push it off the middle.
|
|
62
|
+
secure: { textAlign: 'center', includeFontPadding: false },
|
|
63
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Image, StyleSheet } from 'react-native';
|
|
3
|
+
import { LOGO_RADIUS_RATIO, LOGO_SIZE, MEDIA_LINE, } from "../checkout-core/models/checkout.constants.js";
|
|
4
|
+
import { PROVIDER_LOGOS } from "../models/sheet.constants.js";
|
|
5
|
+
/** A brand's square tile, the same as on the web checkout. */
|
|
6
|
+
export function SheetLogo({ logo, size = LOGO_SIZE.INLINE, muted = false, }) {
|
|
7
|
+
return (_jsx(Image, { source: PROVIDER_LOGOS[logo], accessibilityIgnoresInvertColors: true, style: [
|
|
8
|
+
styles.logo,
|
|
9
|
+
{
|
|
10
|
+
width: size,
|
|
11
|
+
height: size,
|
|
12
|
+
borderRadius: Math.round(size * LOGO_RADIUS_RATIO),
|
|
13
|
+
},
|
|
14
|
+
muted && styles.muted,
|
|
15
|
+
] }));
|
|
16
|
+
}
|
|
17
|
+
const styles = StyleSheet.create({
|
|
18
|
+
logo: { borderWidth: 1, borderColor: MEDIA_LINE },
|
|
19
|
+
muted: { opacity: 0.45 },
|
|
20
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
4
|
+
import { FigtreeEnum, SheetIconEnum } from "../models/sheet.enum.js";
|
|
5
|
+
import { SheetIcon } from "./SheetIcon.js";
|
|
6
|
+
import { SheetText } from "./SheetText.js";
|
|
7
|
+
/** A dead end the payer cannot fix here: its sign, what happened and why. */
|
|
8
|
+
export function SheetMessage({ title, body, icon = SheetIconEnum.BAN, danger = false, }) {
|
|
9
|
+
const { colors } = useSheetTheme();
|
|
10
|
+
return (_jsxs(View, { style: styles.message, children: [_jsx(SheetIcon, { kind: icon, color: danger ? colors.danger : colors.ink2, background: danger ? colors.dangerSoft : colors.fill2 }), _jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 22, accessibilityRole: "header", style: styles.title, children: title }), _jsx(SheetText, { paragraph: true, size: 15, color: colors.inkStrong, children: body })] }));
|
|
11
|
+
}
|
|
12
|
+
const styles = StyleSheet.create({
|
|
13
|
+
message: { paddingHorizontal: 18, paddingTop: 28 },
|
|
14
|
+
title: { marginTop: 16, marginBottom: 8, letterSpacing: -0.4 },
|
|
15
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { MethodCardProps } from '../models/sheet.interface.js';
|
|
2
|
+
/** One method of the grid: logo and radio dot, then its name and network, or why it is greyed. Alone, one full-width row. Picked, ringed in the brand colour, its dot ticked. */
|
|
3
|
+
export declare function SheetMethodCard({ logo, name, sub, muted, checked, missing, alone, onSelect, }: MethodCardProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
3
|
+
import { LOGO_SIZE } from "../checkout-core/models/checkout.constants.js";
|
|
4
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
5
|
+
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
6
|
+
import { SheetLogo } from "./SheetLogo.js";
|
|
7
|
+
import { SheetText } from "./SheetText.js";
|
|
8
|
+
import { FIELD_RADIUS, PRESSED_OPACITY } from "../models/sheet.constants.js";
|
|
9
|
+
/** One method of the grid: logo and radio dot, then its name and network, or why it is greyed. Alone, one full-width row. Picked, ringed in the brand colour, its dot ticked. */
|
|
10
|
+
export function SheetMethodCard({ logo, name, sub, muted, checked, missing, alone, onSelect, }) {
|
|
11
|
+
const { colors, brand } = useSheetTheme();
|
|
12
|
+
const red = missing && !muted && !checked;
|
|
13
|
+
const texts = (_jsxs(_Fragment, { children: [_jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 15, numberOfLines: 1, color: muted ? colors.muted : colors.ink, children: name }), _jsx(SheetText, { size: 12.5, numberOfLines: 1, color: muted ? colors.warnInk : colors.muted, children: sub })] }));
|
|
14
|
+
return (_jsxs(TouchableOpacity, { onPress: onSelect, disabled: muted, activeOpacity: PRESSED_OPACITY, accessibilityRole: "radio", accessibilityLabel: `${name}, ${sub}`, accessibilityState: { checked, disabled: muted }, style: [
|
|
15
|
+
styles.card,
|
|
16
|
+
checked
|
|
17
|
+
? [styles.cardRinged, { borderColor: brand }]
|
|
18
|
+
: red
|
|
19
|
+
? [styles.cardRinged, { borderColor: colors.danger }]
|
|
20
|
+
: { borderColor: colors.line2 },
|
|
21
|
+
], children: [_jsxs(View, { style: alone ? styles.row : styles.top, children: [_jsx(SheetLogo, { logo: logo, size: LOGO_SIZE.ROW, muted: muted }), alone && _jsx(View, { style: styles.text, children: texts }), _jsx(View, { testID: checked ? 'method-checked' : undefined, style: [
|
|
22
|
+
styles.radio,
|
|
23
|
+
checked
|
|
24
|
+
? { borderColor: brand, backgroundColor: brand }
|
|
25
|
+
: {
|
|
26
|
+
borderColor: muted
|
|
27
|
+
? colors.line2
|
|
28
|
+
: red
|
|
29
|
+
? colors.danger
|
|
30
|
+
: colors.line4,
|
|
31
|
+
},
|
|
32
|
+
], children: checked && _jsx(View, { style: styles.tick }) })] }), !alone && texts] }));
|
|
33
|
+
}
|
|
34
|
+
const styles = StyleSheet.create({
|
|
35
|
+
card: {
|
|
36
|
+
flex: 1,
|
|
37
|
+
minWidth: 0,
|
|
38
|
+
borderWidth: 1,
|
|
39
|
+
borderRadius: FIELD_RADIUS,
|
|
40
|
+
padding: 12,
|
|
41
|
+
gap: 2,
|
|
42
|
+
},
|
|
43
|
+
// 1.5 like the web's ring; the padding gives back the half point.
|
|
44
|
+
cardRinged: { borderWidth: 1.5, padding: 11.5 },
|
|
45
|
+
top: {
|
|
46
|
+
flexDirection: 'row',
|
|
47
|
+
alignItems: 'flex-start',
|
|
48
|
+
justifyContent: 'space-between',
|
|
49
|
+
marginBottom: 10,
|
|
50
|
+
},
|
|
51
|
+
row: { flexDirection: 'row', alignItems: 'center', gap: 12 },
|
|
52
|
+
text: { flex: 1, minWidth: 0 },
|
|
53
|
+
radio: {
|
|
54
|
+
width: 20,
|
|
55
|
+
height: 20,
|
|
56
|
+
alignItems: 'center',
|
|
57
|
+
justifyContent: 'center',
|
|
58
|
+
borderRadius: 10,
|
|
59
|
+
borderWidth: 1.5,
|
|
60
|
+
},
|
|
61
|
+
// The chosen row's tick, a size up.
|
|
62
|
+
tick: {
|
|
63
|
+
width: 4.5,
|
|
64
|
+
height: 8.5,
|
|
65
|
+
marginTop: -1.5,
|
|
66
|
+
borderColor: 'white',
|
|
67
|
+
borderRightWidth: 2,
|
|
68
|
+
borderBottomWidth: 2,
|
|
69
|
+
transform: [{ rotate: '45deg' }],
|
|
70
|
+
},
|
|
71
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SheetScreenProps } from '../models/sheet.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* A bank redirect's account holder (ADR 0014), as on the web: the app's
|
|
4
|
+
* payer name at first. Pay without a first and a last name says so, shakes
|
|
5
|
+
* the field and brings the keyboard up on it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function SheetNameField({ core }: SheetScreenProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Animated, StyleSheet, View } from 'react-native';
|
|
4
|
+
import { useTranslations } from 'use-intl';
|
|
5
|
+
import { useShake } from "../hooks/use-shake.js";
|
|
6
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
7
|
+
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
8
|
+
import { SheetInput, SheetText } from "./SheetText.js";
|
|
9
|
+
import { FIELD_HEIGHT, FIELD_RADIUS } from "../models/sheet.constants.js";
|
|
10
|
+
/**
|
|
11
|
+
* A bank redirect's account holder (ADR 0014), as on the web: the app's
|
|
12
|
+
* payer name at first. Pay without a first and a last name says so, shakes
|
|
13
|
+
* the field and brings the keyboard up on it.
|
|
14
|
+
*/
|
|
15
|
+
export function SheetNameField({ core }) {
|
|
16
|
+
const t = useTranslations('checkout');
|
|
17
|
+
const { colors, brand } = useSheetTheme();
|
|
18
|
+
const { ui, derived, actions } = core;
|
|
19
|
+
const field = useRef(null);
|
|
20
|
+
const [focused, setFocused] = useState(false);
|
|
21
|
+
const shake = useShake(ui.nameMissing);
|
|
22
|
+
const error = derived.nameError;
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (ui.nameMissing > 0)
|
|
25
|
+
field.current?.focus();
|
|
26
|
+
}, [ui.nameMissing]);
|
|
27
|
+
return (_jsxs(View, { style: styles.section, children: [_jsx(SheetText, { weight: FigtreeEnum.BOLD, style: styles.label, children: t('bank.name_label') }), _jsx(Animated.View, { style: { transform: [{ translateX: shake }] }, children: _jsx(SheetInput, { ref: field, accessibilityLabel: t('bank.name_label'), textContentType: "name", autoComplete: "name", autoCapitalize: "words", autoCorrect: false, returnKeyType: "go", placeholder: t('bank.name_placeholder'), value: ui.payerName, onChangeText: actions.setPayerName, onFocus: () => setFocused(true), onBlur: () => setFocused(false), onSubmitEditing: actions.pay, editable: !ui.submitting, style: [
|
|
28
|
+
styles.input,
|
|
29
|
+
{
|
|
30
|
+
borderColor: error
|
|
31
|
+
? colors.danger
|
|
32
|
+
: focused
|
|
33
|
+
? brand
|
|
34
|
+
: colors.line3,
|
|
35
|
+
},
|
|
36
|
+
] }) }), _jsx(View, { accessibilityLiveRegion: "polite", style: styles.message, children: error && (_jsx(SheetText, { paragraph: true, weight: FigtreeEnum.MEDIUM, size: 13, color: colors.danger, children: t('bank.name_missing') })) })] }));
|
|
37
|
+
}
|
|
38
|
+
const styles = StyleSheet.create({
|
|
39
|
+
section: { marginTop: 18 },
|
|
40
|
+
label: { marginBottom: 8 },
|
|
41
|
+
input: {
|
|
42
|
+
height: FIELD_HEIGHT,
|
|
43
|
+
borderWidth: 1,
|
|
44
|
+
borderRadius: FIELD_RADIUS,
|
|
45
|
+
paddingHorizontal: 12,
|
|
46
|
+
},
|
|
47
|
+
message: { minHeight: 22, marginTop: 8 },
|
|
48
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SheetPaypalButtonProps } from '../models/sheet.interface.js';
|
|
2
|
+
/** PayPal's own gold button, "Pay with" and its wordmark, the same in both themes. */
|
|
3
|
+
export declare function SheetPaypalButton({ busy, onPress }: SheetPaypalButtonProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ActivityIndicator, Image, StyleSheet, TouchableOpacity, } from 'react-native';
|
|
3
|
+
import { useTranslations } from 'use-intl';
|
|
4
|
+
import { PAYPAL_BUTTON_COLORS } from "../checkout-core/models/checkout.constants.js";
|
|
5
|
+
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
6
|
+
import { FIELD_HEIGHT, FIELD_RADIUS, PAYPAL_WORDMARK, PAYPAL_WORDMARK_SIZE, } from "../models/sheet.constants.js";
|
|
7
|
+
import { SheetText } from "./SheetText.js";
|
|
8
|
+
/** PayPal's own gold button, "Pay with" and its wordmark, the same in both themes. */
|
|
9
|
+
export function SheetPaypalButton({ busy, onPress }) {
|
|
10
|
+
const t = useTranslations('checkout');
|
|
11
|
+
return (_jsx(TouchableOpacity, { onPress: onPress, disabled: busy, activeOpacity: 0.8, accessibilityRole: "button", accessibilityLabel: t('pay_with_method', { method: 'PayPal' }), accessibilityState: { disabled: busy, busy }, style: [styles.button, { backgroundColor: PAYPAL_BUTTON_COLORS.gold }], children: busy ? (_jsx(ActivityIndicator, { color: PAYPAL_BUTTON_COLORS.ink })) : (_jsxs(_Fragment, { children: [_jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 16, color: PAYPAL_BUTTON_COLORS.ink, children: t('pay_with') }), _jsx(Image, { source: PAYPAL_WORDMARK, accessibilityIgnoresInvertColors: true, style: PAYPAL_WORDMARK_SIZE })] })) }));
|
|
12
|
+
}
|
|
13
|
+
const styles = StyleSheet.create({
|
|
14
|
+
button: {
|
|
15
|
+
minHeight: FIELD_HEIGHT,
|
|
16
|
+
borderRadius: FIELD_RADIUS,
|
|
17
|
+
flexDirection: 'row',
|
|
18
|
+
alignItems: 'center',
|
|
19
|
+
justifyContent: 'center',
|
|
20
|
+
gap: 6,
|
|
21
|
+
paddingHorizontal: 16,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SheetPhoneFieldProps } from '../models/sheet.interface.js';
|
|
2
|
+
/** The Mobile Money number on the phone keyboard: the country's dial code, the number grouped as typed, its check. */
|
|
3
|
+
export declare function SheetPhoneField({ core, phoneRef }: SheetPhoneFieldProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Platform, Pressable, StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useTranslations } from 'use-intl';
|
|
4
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
5
|
+
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
6
|
+
import { flagOf } from "../models/sheet.utils.js";
|
|
7
|
+
import { SheetLogo } from "./SheetLogo.js";
|
|
8
|
+
import { SheetInput, SheetText } from "./SheetText.js";
|
|
9
|
+
import { FIELD_HEIGHT, FIELD_RADIUS } from "../models/sheet.constants.js";
|
|
10
|
+
/** The Mobile Money number on the phone keyboard: the country's dial code, the number grouped as typed, its check. */
|
|
11
|
+
export function SheetPhoneField({ core, phoneRef }) {
|
|
12
|
+
const t = useTranslations('checkout');
|
|
13
|
+
const { colors, brand } = useSheetTheme();
|
|
14
|
+
const { ui, derived, phone, actions } = core;
|
|
15
|
+
const { error } = phone.status;
|
|
16
|
+
const { mismatch, selected } = derived;
|
|
17
|
+
return (_jsxs(View, { style: styles.section, children: [_jsx(SheetText, { weight: FigtreeEnum.BOLD, style: styles.label, children: t('phone_label') }), _jsxs(View, { testID: "phone-field", style: [
|
|
18
|
+
styles.field,
|
|
19
|
+
{
|
|
20
|
+
borderColor: error
|
|
21
|
+
? colors.danger
|
|
22
|
+
: phone.focused
|
|
23
|
+
? brand
|
|
24
|
+
: colors.line3,
|
|
25
|
+
},
|
|
26
|
+
], children: [_jsxs(View, { style: [styles.dial, { borderColor: colors.line2 }], children: [_jsx(SheetText, { size: 16, children: flagOf(ui.country) }), _jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, size: 16, children: `+${phone.dial}` })] }), _jsx(SheetInput, { ref: phoneRef, accessibilityLabel: t('phone_label'), keyboardType: "phone-pad", textContentType: "telephoneNumber", autoComplete: "tel",
|
|
27
|
+
// iOS's number keypads have no Go key: asking for one adds a bar above them.
|
|
28
|
+
returnKeyType: Platform.OS === 'android' ? 'go' : undefined, placeholder: phone.placeholder, value: phone.value, onChangeText: (text) => void phone.type(text, text.length), onFocus: phone.onFocus, onBlur: phone.onBlur, onSubmitEditing: actions.pay, editable: !ui.submitting, style: styles.input })] }), _jsx(View, { accessibilityLiveRegion: "polite", style: styles.message, children: error ? (_jsx(SheetText, { paragraph: true, weight: FigtreeEnum.MEDIUM, size: 13, color: colors.danger, children: t(`phone_errors.${error}`) })) : mismatch ? (_jsxs(View, { style: styles.mismatch, children: [_jsx(SheetLogo, { logo: mismatch.logos[0] }), _jsx(SheetText, { paragraph: true, size: 13, color: colors.ink2, style: styles.grow, children: t('mismatch', { method: mismatch.name }) }), _jsx(Pressable, { onPress: actions.switchToDetected, accessibilityRole: "button", hitSlop: 6, style: [styles.switch, { borderColor: colors.line3 }], children: _jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, size: 13, children: t('switch_to') }) })] })) : (selected && (_jsx(SheetText, { paragraph: true, size: 13, color: colors.muted, children: t('helper', { method: selected.name }) }))) })] }));
|
|
29
|
+
}
|
|
30
|
+
const styles = StyleSheet.create({
|
|
31
|
+
section: { marginTop: 18 },
|
|
32
|
+
label: { marginBottom: 8 },
|
|
33
|
+
field: {
|
|
34
|
+
flexDirection: 'row',
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
height: FIELD_HEIGHT,
|
|
37
|
+
borderWidth: 1,
|
|
38
|
+
borderRadius: FIELD_RADIUS,
|
|
39
|
+
overflow: 'hidden',
|
|
40
|
+
},
|
|
41
|
+
dial: {
|
|
42
|
+
flexDirection: 'row',
|
|
43
|
+
alignItems: 'center',
|
|
44
|
+
gap: 6,
|
|
45
|
+
height: '100%',
|
|
46
|
+
paddingHorizontal: 12,
|
|
47
|
+
borderRightWidth: 1,
|
|
48
|
+
},
|
|
49
|
+
input: { flex: 1, height: '100%', paddingHorizontal: 12 },
|
|
50
|
+
message: { minHeight: 22, marginTop: 8 },
|
|
51
|
+
mismatch: { flexDirection: 'row', alignItems: 'center', gap: 8 },
|
|
52
|
+
grow: { flex: 1 },
|
|
53
|
+
switch: {
|
|
54
|
+
borderWidth: 1,
|
|
55
|
+
borderRadius: 8,
|
|
56
|
+
paddingHorizontal: 12,
|
|
57
|
+
paddingVertical: 6,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { SheetPillSelectProps } from '../models/sheet.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* The web checkout's pill: the current choice's flag and name and a down
|
|
4
|
+
* chevron, drawn with views. Pressed, it lists the choices in a small sheet
|
|
5
|
+
* over the payment sheet, which never moves.
|
|
6
|
+
*/
|
|
7
|
+
export declare function SheetPillSelect<T extends string>({ value, options, onChange, accessibilityLabel, disabled, }: SheetPillSelectProps<T>): import("react").JSX.Element;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState } from 'react';
|
|
3
|
+
import { Modal, Pressable, ScrollView, StyleSheet, TouchableOpacity, View, useWindowDimensions, } from 'react-native';
|
|
4
|
+
import { useTranslations } from 'use-intl';
|
|
5
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
6
|
+
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
7
|
+
import { pillListOffset } from "../models/sheet.utils.js";
|
|
8
|
+
import { SheetGrabber } from "./SheetGrabber.js";
|
|
9
|
+
import { SheetText } from "./SheetText.js";
|
|
10
|
+
import { CHECK_DISC_SIZE, CHEVRON_BOX, CHEVRON_SIZE, FIELD_RADIUS, PILL_HEIGHT, PILL_LIST_MAX_SHARE, PILL_ROW_HEIGHT, PRESSED_OPACITY, SHEET_DIM_OPACITY, SHEET_FOOT_BOTTOM, SHEET_TOP_RADIUS, STROKE_WIDTH, TICK_HEIGHT, TICK_WIDTH, } from "../models/sheet.constants.js";
|
|
11
|
+
/**
|
|
12
|
+
* The web checkout's pill: the current choice's flag and name and a down
|
|
13
|
+
* chevron, drawn with views. Pressed, it lists the choices in a small sheet
|
|
14
|
+
* over the payment sheet, which never moves.
|
|
15
|
+
*/
|
|
16
|
+
export function SheetPillSelect({ value, options, onChange, accessibilityLabel, disabled, }) {
|
|
17
|
+
const { colors } = useSheetTheme();
|
|
18
|
+
const [open, setOpen] = useState(false);
|
|
19
|
+
// The core keeps the current value among the options.
|
|
20
|
+
const current = options.find((option) => option.value === value);
|
|
21
|
+
const choose = (next) => {
|
|
22
|
+
setOpen(false);
|
|
23
|
+
if (next !== value)
|
|
24
|
+
onChange(next);
|
|
25
|
+
};
|
|
26
|
+
return (_jsxs(_Fragment, { children: [_jsxs(TouchableOpacity, { onPress: () => setOpen(true), disabled: disabled, activeOpacity: PRESSED_OPACITY, accessibilityRole: "button", accessibilityLabel: accessibilityLabel, accessibilityValue: { text: current.label }, accessibilityState: { expanded: open, disabled: !!disabled }, style: [
|
|
27
|
+
styles.pill,
|
|
28
|
+
{
|
|
29
|
+
borderColor: open ? colors.line4 : colors.line2,
|
|
30
|
+
backgroundColor: colors.surface,
|
|
31
|
+
},
|
|
32
|
+
], children: [_jsx(SheetText, { size: 15, children: current.flag }), _jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, size: 13, children: current.label }), _jsx(View, { style: styles.chevronBox, children: _jsx(View, { style: [
|
|
33
|
+
styles.chevron,
|
|
34
|
+
open && styles.chevronUp,
|
|
35
|
+
{ borderColor: colors.muted },
|
|
36
|
+
] }) })] }), _jsx(SheetPillList, { open: open, value: value, options: options, onChange: choose, onClose: () => setOpen(false), accessibilityLabel: accessibilityLabel })] }));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The pill's list: a small sheet over the payment sheet, its rows inset, the
|
|
40
|
+
* current one filled and ticked. A long list scrolls within its share of the
|
|
41
|
+
* screen, opened with the current choice in sight. A tap on the dim, back or
|
|
42
|
+
* the screen reader's escape closes it.
|
|
43
|
+
*/
|
|
44
|
+
function SheetPillList({ open, value, options, onChange, onClose, accessibilityLabel, }) {
|
|
45
|
+
const t = useTranslations('checkout');
|
|
46
|
+
const { colors } = useSheetTheme();
|
|
47
|
+
const { height } = useWindowDimensions();
|
|
48
|
+
const scroller = useRef(null);
|
|
49
|
+
const current = options.findIndex((option) => option.value === value);
|
|
50
|
+
return (_jsx(Modal, { testID: "pill-list", visible: open, transparent: true, animationType: "fade", statusBarTranslucent: true, onRequestClose: onClose, children: _jsxs(View, { testID: "pill-list-screen", accessibilityViewIsModal: true, onAccessibilityEscape: onClose, style: styles.screen, children: [_jsx(Pressable, { testID: "pill-list-backdrop", accessibilityRole: "button", accessibilityLabel: t('close'), onPress: onClose, style: [StyleSheet.absoluteFill, styles.dim] }), _jsxs(View, { testID: "pill-options", accessibilityRole: "radiogroup", accessibilityLabel: accessibilityLabel, style: [
|
|
51
|
+
styles.list,
|
|
52
|
+
{
|
|
53
|
+
backgroundColor: colors.surface,
|
|
54
|
+
maxHeight: height * PILL_LIST_MAX_SHARE,
|
|
55
|
+
},
|
|
56
|
+
], children: [_jsx(SheetGrabber, {}), _jsx(SheetText, { weight: FigtreeEnum.BOLD, size: 15, style: styles.title, children: accessibilityLabel }), _jsx(ScrollView, { testID: "pill-scroll", ref: scroller,
|
|
57
|
+
// Once its height is known, the list moves to the current row.
|
|
58
|
+
onLayout: (event) => scroller.current.scrollTo({
|
|
59
|
+
y: pillListOffset(current, options.length, event.nativeEvent.layout.height),
|
|
60
|
+
animated: false,
|
|
61
|
+
}), style: styles.scroll, children: options.map((option) => {
|
|
62
|
+
const on = option.value === value;
|
|
63
|
+
return (_jsxs(TouchableOpacity, { onPress: () => onChange(option.value), activeOpacity: PRESSED_OPACITY, accessibilityRole: "radio", accessibilityLabel: option.label, accessibilityState: { checked: on }, style: [
|
|
64
|
+
styles.option,
|
|
65
|
+
on && { backgroundColor: colors.fill },
|
|
66
|
+
], children: [_jsx(SheetText, { size: 20, children: option.flag }), _jsx(SheetText, { weight: on ? FigtreeEnum.SEMI_BOLD : FigtreeEnum.REGULAR, size: 15, numberOfLines: 1, style: styles.optionLabel, children: option.label }), on && (_jsx(View, { testID: "option-ticked", style: [styles.disc, { backgroundColor: colors.ink }], children: _jsx(View, { style: [styles.tick, { borderColor: colors.surface }] }) }))] }, option.value));
|
|
67
|
+
}) })] })] }) }));
|
|
68
|
+
}
|
|
69
|
+
const styles = StyleSheet.create({
|
|
70
|
+
// The web's pill: pr 10, pl 12, gap 8.
|
|
71
|
+
pill: {
|
|
72
|
+
height: PILL_HEIGHT,
|
|
73
|
+
flexDirection: 'row',
|
|
74
|
+
alignItems: 'center',
|
|
75
|
+
gap: 8,
|
|
76
|
+
paddingLeft: 12,
|
|
77
|
+
paddingRight: 10,
|
|
78
|
+
borderWidth: 1,
|
|
79
|
+
borderRadius: PILL_HEIGHT / 2,
|
|
80
|
+
},
|
|
81
|
+
chevronBox: {
|
|
82
|
+
width: CHEVRON_BOX,
|
|
83
|
+
height: CHEVRON_BOX,
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
justifyContent: 'center',
|
|
86
|
+
},
|
|
87
|
+
// Its two strokes, turned down, nudged up to the middle of the box.
|
|
88
|
+
chevron: {
|
|
89
|
+
width: CHEVRON_SIZE,
|
|
90
|
+
height: CHEVRON_SIZE,
|
|
91
|
+
marginTop: -3,
|
|
92
|
+
borderRightWidth: STROKE_WIDTH,
|
|
93
|
+
borderBottomWidth: STROKE_WIDTH,
|
|
94
|
+
transform: [{ rotate: '45deg' }],
|
|
95
|
+
},
|
|
96
|
+
chevronUp: { marginTop: 3, transform: [{ rotate: '-135deg' }] },
|
|
97
|
+
screen: { flex: 1, justifyContent: 'flex-end' },
|
|
98
|
+
dim: { backgroundColor: 'black', opacity: SHEET_DIM_OPACITY },
|
|
99
|
+
// The payment sheet's rounded top, and its room at the foot.
|
|
100
|
+
list: {
|
|
101
|
+
borderTopLeftRadius: SHEET_TOP_RADIUS,
|
|
102
|
+
borderTopRightRadius: SHEET_TOP_RADIUS,
|
|
103
|
+
paddingBottom: SHEET_FOOT_BOTTOM,
|
|
104
|
+
},
|
|
105
|
+
title: { paddingHorizontal: 24, paddingTop: 14, paddingBottom: 8 },
|
|
106
|
+
scroll: { flexGrow: 0 },
|
|
107
|
+
// Inset by 8, padded 16: the flag clears the filled row and lines up with the title at 24.
|
|
108
|
+
option: {
|
|
109
|
+
height: PILL_ROW_HEIGHT,
|
|
110
|
+
flexDirection: 'row',
|
|
111
|
+
alignItems: 'center',
|
|
112
|
+
gap: 12,
|
|
113
|
+
marginHorizontal: 8,
|
|
114
|
+
paddingHorizontal: 16,
|
|
115
|
+
borderRadius: FIELD_RADIUS,
|
|
116
|
+
},
|
|
117
|
+
optionLabel: { flex: 1, minWidth: 0 },
|
|
118
|
+
disc: {
|
|
119
|
+
width: CHECK_DISC_SIZE,
|
|
120
|
+
height: CHECK_DISC_SIZE,
|
|
121
|
+
borderRadius: CHECK_DISC_SIZE / 2,
|
|
122
|
+
alignItems: 'center',
|
|
123
|
+
justifyContent: 'center',
|
|
124
|
+
},
|
|
125
|
+
// Its two strokes, turned, nudged up to the middle of the disc.
|
|
126
|
+
tick: {
|
|
127
|
+
width: TICK_WIDTH,
|
|
128
|
+
height: TICK_HEIGHT,
|
|
129
|
+
marginTop: -2,
|
|
130
|
+
borderRightWidth: STROKE_WIDTH,
|
|
131
|
+
borderBottomWidth: STROKE_WIDTH,
|
|
132
|
+
transform: [{ rotate: '45deg' }],
|
|
133
|
+
},
|
|
134
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import { useSheetTheme } from "../hooks/use-sheet-theme.js";
|
|
4
|
+
import { FigtreeEnum } from "../models/sheet.enum.js";
|
|
5
|
+
import { SheetText } from "./SheetText.js";
|
|
6
|
+
/** A label on the left, its value on the right, a hairline under them. */
|
|
7
|
+
export function SheetRow({ label, children, urgent = false }) {
|
|
8
|
+
const { colors } = useSheetTheme();
|
|
9
|
+
return (_jsxs(View, { style: [styles.row, { borderColor: colors.line }], children: [_jsx(SheetText, { color: colors.muted, children: label }), _jsx(View, { style: styles.value, children: typeof children === 'string' ? (_jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, color: urgent ? colors.danger : colors.ink, style: styles.figures, children: children })) : (children) })] }));
|
|
10
|
+
}
|
|
11
|
+
const styles = StyleSheet.create({
|
|
12
|
+
row: {
|
|
13
|
+
flexDirection: 'row',
|
|
14
|
+
alignItems: 'center',
|
|
15
|
+
justifyContent: 'space-between',
|
|
16
|
+
gap: 12,
|
|
17
|
+
minHeight: 44,
|
|
18
|
+
paddingVertical: 11,
|
|
19
|
+
borderBottomWidth: 1,
|
|
20
|
+
},
|
|
21
|
+
value: {
|
|
22
|
+
flexShrink: 1,
|
|
23
|
+
flexDirection: 'row',
|
|
24
|
+
alignItems: 'center',
|
|
25
|
+
gap: 8,
|
|
26
|
+
},
|
|
27
|
+
figures: { fontVariant: ['tabular-nums'], textAlign: 'right' },
|
|
28
|
+
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SheetScreenProps } from '../models/sheet.interface.js';
|
|
2
|
+
/**
|
|
3
|
+
* On a test payment the Simulator took, the tester plays the payer's phone,
|
|
4
|
+
* or makes the provider misbehave. Never on a live payment.
|
|
5
|
+
*/
|
|
6
|
+
export declare function SheetSimulator({ core }: SheetScreenProps): import("react").JSX.Element;
|