@brissoto/pay-react-native 1.5.1 → 1.6.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/README.md CHANGED
@@ -173,10 +173,42 @@ The sheet takes the payment's `language` and `theme`. Without them it follows th
173
173
 
174
174
  `BrissotoPayProvider` takes:
175
175
 
176
- | Option | Default | What it is |
177
- | ------ | ------------------------------ | ------------------------------------------------------------------------------------------------------- |
178
- | `url` | `https://api-pay.brissoto.com` | The Brissoto Pay backend. One serves Live and Test. Set it only to point the sheet at a dev deployment. |
176
+ | Option | Default | What it is |
177
+ | ------------ | ------------------------------ | ------------------------------------------------------------------------------------------------------- |
178
+ | `url` | `https://api-pay.brissoto.com` | The Brissoto Pay backend. One serves Live and Test. Set it only to point the sheet at a dev deployment. |
179
+ | `appearance` | none | The sheet's look in your app: see [Appearance](#appearance). |
179
180
 
180
181
  ```tsx
181
182
  <BrissotoPayProvider url={process.env.EXPO_PUBLIC_BRISSOTO_PAY_URL}>
182
183
  ```
184
+
185
+ ## Appearance
186
+
187
+ Style the buttons at the foot of the sheet, per kind. Anything left out keeps the sheet's own look.
188
+
189
+ ```tsx
190
+ <BrissotoPayProvider
191
+ appearance={{
192
+ buttons: {
193
+ primary: { height: 56, radius: 28, fontSize: 17, labelColor: '#fff' },
194
+ secondary: { radius: 28, labelColor: { light: '#111', dark: '#eee' } },
195
+ plain: { fontSize: 15 },
196
+ },
197
+ }}
198
+ >
199
+ ```
200
+
201
+ | Button | Which |
202
+ | ----------- | --------------------------------------------------------------------------------------------------------------- |
203
+ | `primary` | Continue, Pay, Pay with the store, Try again, Done, Return to the app. PayPal takes its height and radius only. |
204
+ | `secondary` | Send again (outlined). |
205
+ | `plain` | Try with…, Use another method (no border). |
206
+
207
+ | Field | Default | Allowed |
208
+ | ------------ | ------------------------------------------------- | ------------------------------ |
209
+ | `height` | 50 | 44 or more |
210
+ | `radius` | 14 | 0 to half the height (a pill) |
211
+ | `fontSize` | 16 | 12 to 22 |
212
+ | `labelColor` | white on `primary`, the theme's ink on the others | a colour, or `{ light, dark }` |
213
+
214
+ Values out of range are brought back in it.
@@ -5,4 +5,4 @@ import type { BrissotoPayProviderProps } from '../models/sheet.interface.js';
5
5
  * sheet follows its payment live only while the payer waits on it. On
6
6
  * start, store purchases the app never reported are sent again.
7
7
  */
8
- export declare function BrissotoPayProvider({ url, children, }: BrissotoPayProviderProps): import("react").JSX.Element;
8
+ export declare function BrissotoPayProvider({ url, appearance, children, }: BrissotoPayProviderProps): import("react").JSX.Element;
@@ -11,7 +11,7 @@ import { PaymentSheetModal } from "./PaymentSheetModal.js";
11
11
  * sheet follows its payment live only while the payer waits on it. On
12
12
  * start, store purchases the app never reported are sent again.
13
13
  */
14
- export function BrissotoPayProvider({ url = DEFAULT_URL, children, }) {
14
+ export function BrissotoPayProvider({ url = DEFAULT_URL, appearance, children, }) {
15
15
  const connection = useMemo(() => convexCheckoutConnection(url), [url]);
16
16
  const recovery = useMemo(() => convexStoreRecovery(url), [url]);
17
17
  useStoreRecovery(recovery);
@@ -35,5 +35,5 @@ export function BrissotoPayProvider({ url = DEFAULT_URL, children, }) {
35
35
  setRequest({ ...closing, open: false });
36
36
  closing.resolve(result);
37
37
  };
38
- return (_jsxs(PaymentSheetContext, { value: sheet, children: [children, request && (_jsx(PaymentSheetModal, { connection: connection, request: request, onClose: (result) => close(request, result) }, count))] }));
38
+ return (_jsxs(PaymentSheetContext, { value: sheet, children: [children, request && (_jsx(PaymentSheetModal, { connection: connection, appearance: appearance, request: request, onClose: (result) => close(request, result) }, count))] }));
39
39
  }
@@ -6,4 +6,4 @@ import type { PaymentSheetModalProps } from '../models/sheet.interface.js';
6
6
  * while a prompt waits on the phone asks first, and resolves `pending`.
7
7
  * Android's back on the details goes back to the methods instead.
8
8
  */
9
- export declare function PaymentSheetModal({ connection, request, onClose, }: PaymentSheetModalProps): import("react").JSX.Element;
9
+ export declare function PaymentSheetModal({ connection, appearance, request, onClose, }: PaymentSheetModalProps): import("react").JSX.Element;
@@ -8,8 +8,8 @@ import { useCheckoutPayment } from "../checkout-core/hooks/use-checkout-payment.
8
8
  import { CheckoutThemeEnum } from "../checkout-core/models/checkout.enum.js";
9
9
  import { useSheetMotion } from "../hooks/use-sheet-motion.js";
10
10
  import { SheetThemeContext } from "../hooks/use-sheet-theme.js";
11
- import { FIGTREE_FILES, MESSAGES, TIME_ZONE, } from "../models/sheet.constants.js";
12
- import { sheetLanguage, sheetResult, sheetTheme, } from "../models/sheet.utils.js";
11
+ import { FIGTREE_FILES, MESSAGES, SHEET_TOP_RADIUS, TIME_ZONE, } from "../models/sheet.constants.js";
12
+ import { sheetButtonLooks, sheetDim, sheetLanguage, sheetResult, sheetTheme, } from "../models/sheet.utils.js";
13
13
  import { SheetContent } from "./SheetContent.js";
14
14
  /**
15
15
  * One payment in a bottom sheet over the dimmed app, as tall as what it
@@ -18,7 +18,7 @@ import { SheetContent } from "./SheetContent.js";
18
18
  * while a prompt waits on the phone asks first, and resolves `pending`.
19
19
  * Android's back on the details goes back to the methods instead.
20
20
  */
21
- export function PaymentSheetModal({ connection, request, onClose, }) {
21
+ export function PaymentSheetModal({ connection, appearance, request, onClose, }) {
22
22
  const payment = useCheckoutPayment(connection, request.open ? request.paymentId : null);
23
23
  const { view } = payment;
24
24
  const scheme = useColorScheme();
@@ -36,7 +36,8 @@ export function PaymentSheetModal({ connection, request, onClose, }) {
36
36
  colors: CHECKOUT_COLORS[dark ? CheckoutThemeEnum.DARK : CheckoutThemeEnum.LIGHT],
37
37
  brand: color ?? (dark ? INVALID_BRAND_DARK : INVALID_BRAND_LIGHT),
38
38
  dark,
39
- }), [dark, color]);
39
+ buttons: sheetButtonLooks(appearance, dark),
40
+ }), [dark, color, appearance]);
40
41
  /** What the sheet last heard, for the close alert, which answers later. */
41
42
  const latest = useRef({ view, failed: payment.failed });
42
43
  useEffect(() => {
@@ -84,8 +85,7 @@ export function PaymentSheetModal({ connection, request, onClose, }) {
84
85
  close();
85
86
  }, children: _jsxs(View, { style: [styles.screen, !request.open && styles.leaving], children: [_jsx(Pressable, { testID: "payment-sheet-backdrop", accessible: false, onPress: close, style: StyleSheet.absoluteFill, children: _jsx(Animated.View, { style: [
86
87
  StyleSheet.absoluteFill,
87
- styles.dim,
88
- { opacity: motion.dim },
88
+ { backgroundColor: sheetDim(dark), opacity: motion.dim },
89
89
  ] }) }), _jsx(Animated.View, { style: [
90
90
  styles.stage,
91
91
  { transform: [{ translateY: motion.translateY }] },
@@ -97,10 +97,15 @@ export function PaymentSheetModal({ connection, request, onClose, }) {
97
97
  const styles = StyleSheet.create({
98
98
  screen: { flex: 1 },
99
99
  leaving: { pointerEvents: 'none' },
100
- dim: { backgroundColor: 'black' },
101
100
  // The app's dim shows through around the sheet.
102
101
  stage: { flex: 1, justifyContent: 'flex-end', pointerEvents: 'box-none' },
103
102
  sheet: { flexShrink: 1 },
104
103
  // Under the sheet's rounded top, down to the screen's bottom.
105
- floor: { position: 'absolute', top: 14, right: 0, bottom: 0, left: 0 },
104
+ floor: {
105
+ position: 'absolute',
106
+ top: SHEET_TOP_RADIUS,
107
+ right: 0,
108
+ bottom: 0,
109
+ left: 0,
110
+ },
106
111
  });
@@ -2,6 +2,7 @@ import type { SheetButtonProps } from '../models/sheet.interface.js';
2
2
  /**
3
3
  * The sheet's buttons: filled in the app colour for the main action,
4
4
  * outlined for the rest, plain (no border) for a quiet second choice, a link
5
- * in the app colour for a quiet action in a line of its own.
5
+ * in the app colour for a quiet action in a line of its own. In the sheet's
6
+ * foot, the app's appearance sets their height, corner and label.
6
7
  */
7
8
  export declare function SheetButton({ label, onPress, variant, busy, disabled, inactive, }: SheetButtonProps): import("react").JSX.Element;
@@ -1,25 +1,32 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ActivityIndicator, StyleSheet, TouchableOpacity } from 'react-native';
3
3
  import { CheckoutButtonVariantEnum } from "../checkout-core/models/checkout.enum.js";
4
+ import { useSheetButtonLook } from "../hooks/use-sheet-foot.js";
4
5
  import { useSheetTheme } from "../hooks/use-sheet-theme.js";
5
6
  import { FigtreeEnum } from "../models/sheet.enum.js";
6
7
  import { SheetText } from "./SheetText.js";
7
- import { FIELD_HEIGHT, FIELD_RADIUS } from "../models/sheet.constants.js";
8
8
  /**
9
9
  * The sheet's buttons: filled in the app colour for the main action,
10
10
  * outlined for the rest, plain (no border) for a quiet second choice, a link
11
- * in the app colour for a quiet action in a line of its own.
11
+ * in the app colour for a quiet action in a line of its own. In the sheet's
12
+ * foot, the app's appearance sets their height, corner and label.
12
13
  */
13
14
  export function SheetButton({ label, onPress, variant = CheckoutButtonVariantEnum.PRIMARY, busy = false, disabled = false, inactive = false, }) {
14
15
  const { colors, brand } = useSheetTheme();
15
16
  const primary = variant === CheckoutButtonVariantEnum.PRIMARY;
16
17
  const link = variant === CheckoutButtonVariantEnum.LINK;
17
- const ink = primary ? 'white' : link ? brand : colors.ink;
18
+ const look = useSheetButtonLook(variant);
19
+ const ink = look.labelColor ?? (primary ? 'white' : link ? brand : colors.ink);
18
20
  const off = disabled || busy;
19
21
  return (_jsxs(TouchableOpacity, { onPress: onPress, disabled: off, activeOpacity: 0.8, accessibilityRole: "button", accessibilityState: { disabled: off, busy },
20
22
  // A link's text is short: its tap reaches a little past it.
21
23
  hitSlop: link ? 6 : undefined, style: [
22
- link ? styles.link : styles.button,
24
+ link
25
+ ? styles.link
26
+ : [
27
+ styles.button,
28
+ { minHeight: look.height, borderRadius: look.radius },
29
+ ],
23
30
  primary
24
31
  ? { backgroundColor: brand }
25
32
  : variant !== CheckoutButtonVariantEnum.PLAIN &&
@@ -28,12 +35,10 @@ export function SheetButton({ label, onPress, variant = CheckoutButtonVariantEnu
28
35
  borderColor: colors.line3,
29
36
  },
30
37
  (disabled || inactive) && styles.disabled,
31
- ], children: [busy && _jsx(ActivityIndicator, { color: ink }), _jsx(SheetText, { weight: FigtreeEnum.BOLD, size: link ? 13 : 16, color: ink, style: !link && styles.label, children: label })] }));
38
+ ], children: [busy && _jsx(ActivityIndicator, { color: ink }), _jsx(SheetText, { weight: FigtreeEnum.BOLD, size: link ? 13 : look.fontSize, color: ink, style: !link && styles.label, children: label })] }));
32
39
  }
33
40
  const styles = StyleSheet.create({
34
41
  button: {
35
- minHeight: FIELD_HEIGHT,
36
- borderRadius: FIELD_RADIUS,
37
42
  flexDirection: 'row',
38
43
  alignItems: 'center',
39
44
  justifyContent: 'center',
@@ -30,7 +30,9 @@ const styles = StyleSheet.create({
30
30
  alignItems: 'center',
31
31
  gap: 10,
32
32
  paddingHorizontal: 18,
33
- paddingTop: 10,
33
+ // The grabber above and the body's first line below sit 16 away: the row
34
+ // is centred between them.
35
+ paddingTop: 16,
34
36
  },
35
37
  logo: {
36
38
  width: SHEET_BADGE_SIZE,
@@ -3,6 +3,7 @@ import { useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { Keyboard, Platform, ScrollView, StyleSheet, View } from 'react-native';
4
4
  import { useTranslations } from 'use-intl';
5
5
  import { SheetRoomContext } from "../hooks/use-sheet-room.js";
6
+ import { SheetFootContext } from "../hooks/use-sheet-foot.js";
6
7
  import { useSheetTheme } from "../hooks/use-sheet-theme.js";
7
8
  import { SHEET_BODY_BOTTOM, SHEET_FOOT_BOTTOM, SHEET_FOOT_GAP, SHEET_FOOT_TOP, } from "../models/sheet.constants.js";
8
9
  import { FigtreeEnum } from "../models/sheet.enum.js";
@@ -45,10 +46,10 @@ export function SheetLayout({ children, foot, secure = true, }) {
45
46
  styles.foot,
46
47
  keyboard && styles.footOnKeyboard,
47
48
  { 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
+ ], 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" })] })), _jsx(SheetFootContext, { value: true, children: foot })] }))] }));
49
50
  }
50
51
  const styles = StyleSheet.create({
51
- body: { flexGrow: 0, flexShrink: 1, marginTop: 6 },
52
+ body: { flexGrow: 0, flexShrink: 1 },
52
53
  content: { paddingBottom: SHEET_BODY_BOTTOM },
53
54
  foot: {
54
55
  borderTopWidth: 1,
@@ -1,3 +1,7 @@
1
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. */
2
+ /**
3
+ * PayPal's own gold button, "Pay with" and its wordmark, the same in both
4
+ * themes. It takes the main button's height and corner; its colours and
5
+ * label stay PayPal's.
6
+ */
3
7
  export declare function SheetPaypalButton({ busy, onPress }: SheetPaypalButtonProps): import("react").JSX.Element;
@@ -2,18 +2,30 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
2
2
  import { ActivityIndicator, Image, StyleSheet, TouchableOpacity, } from 'react-native';
3
3
  import { useTranslations } from 'use-intl';
4
4
  import { PAYPAL_BUTTON_COLORS } from "../checkout-core/models/checkout.constants.js";
5
+ import { CheckoutButtonVariantEnum } from "../checkout-core/models/checkout.enum.js";
6
+ import { useSheetButtonLook } from "../hooks/use-sheet-foot.js";
5
7
  import { FigtreeEnum } from "../models/sheet.enum.js";
6
- import { FIELD_HEIGHT, FIELD_RADIUS, PAYPAL_WORDMARK, PAYPAL_WORDMARK_SIZE, } from "../models/sheet.constants.js";
8
+ import { PAYPAL_WORDMARK, PAYPAL_WORDMARK_SIZE, } from "../models/sheet.constants.js";
7
9
  import { SheetText } from "./SheetText.js";
8
- /** PayPal's own gold button, "Pay with" and its wordmark, the same in both themes. */
10
+ /**
11
+ * PayPal's own gold button, "Pay with" and its wordmark, the same in both
12
+ * themes. It takes the main button's height and corner; its colours and
13
+ * label stay PayPal's.
14
+ */
9
15
  export function SheetPaypalButton({ busy, onPress }) {
10
16
  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 })] })) }));
17
+ const look = useSheetButtonLook(CheckoutButtonVariantEnum.PRIMARY);
18
+ return (_jsx(TouchableOpacity, { onPress: onPress, disabled: busy, activeOpacity: 0.8, accessibilityRole: "button", accessibilityLabel: t('pay_with_method', { method: 'PayPal' }), accessibilityState: { disabled: busy, busy }, style: [
19
+ styles.button,
20
+ {
21
+ minHeight: look.height,
22
+ borderRadius: look.radius,
23
+ backgroundColor: PAYPAL_BUTTON_COLORS.gold,
24
+ },
25
+ ], 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
26
  }
13
27
  const styles = StyleSheet.create({
14
28
  button: {
15
- minHeight: FIELD_HEIGHT,
16
- borderRadius: FIELD_RADIUS,
17
29
  flexDirection: 'row',
18
30
  alignItems: 'center',
19
31
  justifyContent: 'center',
@@ -4,10 +4,10 @@ import { Modal, Pressable, ScrollView, StyleSheet, TouchableOpacity, View, useWi
4
4
  import { useTranslations } from 'use-intl';
5
5
  import { useSheetTheme } from "../hooks/use-sheet-theme.js";
6
6
  import { FigtreeEnum } from "../models/sheet.enum.js";
7
- import { pillListOffset } from "../models/sheet.utils.js";
7
+ import { pillListOffset, sheetDim } from "../models/sheet.utils.js";
8
8
  import { SheetGrabber } from "./SheetGrabber.js";
9
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";
10
+ import { CHECK_DISC_SIZE, CHEVRON_BOX, CHEVRON_SIZE, FIELD_RADIUS, PILL_HEIGHT, PILL_LIST_MAX_SHARE, PILL_ROW_HEIGHT, PRESSED_OPACITY, SHEET_FOOT_BOTTOM, SHEET_TOP_RADIUS, STROKE_WIDTH, TICK_HEIGHT, TICK_WIDTH, } from "../models/sheet.constants.js";
11
11
  /**
12
12
  * The web checkout's pill: the current choice's flag and name and a down
13
13
  * chevron, drawn with views. Pressed, it lists the choices in a small sheet
@@ -43,11 +43,11 @@ export function SheetPillSelect({ value, options, onChange, accessibilityLabel,
43
43
  */
44
44
  function SheetPillList({ open, value, options, onChange, onClose, accessibilityLabel, }) {
45
45
  const t = useTranslations('checkout');
46
- const { colors } = useSheetTheme();
46
+ const { colors, dark } = useSheetTheme();
47
47
  const { height } = useWindowDimensions();
48
48
  const scroller = useRef(null);
49
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: [
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, { backgroundColor: sheetDim(dark) }] }), _jsxs(View, { testID: "pill-options", accessibilityRole: "radiogroup", accessibilityLabel: accessibilityLabel, style: [
51
51
  styles.list,
52
52
  {
53
53
  backgroundColor: colors.surface,
@@ -95,7 +95,6 @@ const styles = StyleSheet.create({
95
95
  },
96
96
  chevronUp: { marginTop: 3, transform: [{ rotate: '-135deg' }] },
97
97
  screen: { flex: 1, justifyContent: 'flex-end' },
98
- dim: { backgroundColor: 'black', opacity: SHEET_DIM_OPACITY },
99
98
  // The payment sheet's rounded top, and its room at the foot.
100
99
  list: {
101
100
  borderTopLeftRadius: SHEET_TOP_RADIUS,
@@ -1,6 +1,6 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  import { useState } from 'react';
3
- import { Pressable, StyleSheet, View } from 'react-native';
3
+ import { StyleSheet, View } from 'react-native';
4
4
  import { useTranslations } from 'use-intl';
5
5
  import { FLOW_TRAITS, URGENT_SECONDS, WAIT_SECONDS, } from "../checkout-core/models/checkout.constants.js";
6
6
  import { CheckoutButtonVariantEnum, PayRouteEnum, } from "../checkout-core/models/checkout.enum.js";
@@ -43,7 +43,7 @@ export function SheetWaiting({ core }) {
43
43
  : t('send_again'), disabled: sendAgainIn > 0, onPress: () => {
44
44
  setSentAt(WAIT_SECONDS - waitLeft);
45
45
  actions.sendAgain();
46
- } })), _jsx(Pressable, { onPress: actions.useAnother, accessibilityRole: "button", style: styles.link, children: _jsx(SheetText, { weight: FigtreeEnum.SEMI_BOLD, style: styles.center, children: t('use_another') }) })] }), children: _jsxs(View, { style: styles.waiting, children: [_jsxs(View, { style: styles.pulse, children: [_jsx(View, { style: [styles.halo, styles.outer, { backgroundColor: brand }] }), _jsx(View, { style: [styles.halo, styles.inner, { backgroundColor: brand }] }), _jsx(View, { testID: "icon-phone", style: [styles.phone, { borderColor: brand }], children: _jsx(View, { style: [styles.speaker, { backgroundColor: brand }] }) })] }), _jsx(SheetText, { weight: FigtreeEnum.EXTRA_BOLD, size: 21, accessibilityRole: "header", style: [styles.center, styles.title], children: prompt
46
+ } })), _jsx(SheetButton, { variant: CheckoutButtonVariantEnum.PLAIN, label: t('use_another'), onPress: actions.useAnother })] }), children: _jsxs(View, { style: styles.waiting, children: [_jsxs(View, { style: styles.pulse, children: [_jsx(View, { style: [styles.halo, styles.outer, { backgroundColor: brand }] }), _jsx(View, { style: [styles.halo, styles.inner, { backgroundColor: brand }] }), _jsx(View, { testID: "icon-phone", style: [styles.phone, { borderColor: brand }], children: _jsx(View, { style: [styles.speaker, { backgroundColor: brand }] }) })] }), _jsx(SheetText, { weight: FigtreeEnum.EXTRA_BOLD, size: 21, accessibilityRole: "header", style: [styles.center, styles.title], children: prompt
47
47
  ? t('sheet.approve_title')
48
48
  : attempt.pendingAtStore
49
49
  ? t('sheet.store_pending_title')
@@ -84,5 +84,4 @@ const styles = StyleSheet.create({
84
84
  title: { marginTop: 22, marginBottom: 8, letterSpacing: -0.4 },
85
85
  center: { textAlign: 'center' },
86
86
  rows: { borderTopWidth: 1, marginTop: 22 },
87
- link: { minHeight: 40, justifyContent: 'center' },
88
87
  });
@@ -0,0 +1,6 @@
1
+ import type { CheckoutButtonVariantEnum } from '../checkout-core/models/checkout.enum.js';
2
+ import type { SheetButtonLook } from '../models/sheet.interface.js';
3
+ /** True inside a `SheetLayout`'s foot: the buttons the app's appearance shapes. */
4
+ export declare const SheetFootContext: import("react").Context<boolean>;
5
+ /** A button's shape and label: the app's in the foot, the sheet's own elsewhere. */
6
+ export declare function useSheetButtonLook(variant: CheckoutButtonVariantEnum): SheetButtonLook;
@@ -0,0 +1,11 @@
1
+ import { createContext, use } from 'react';
2
+ import { SHEET_BUTTON_LOOK } from "../models/sheet.constants.js";
3
+ import { useSheetTheme } from "./use-sheet-theme.js";
4
+ /** True inside a `SheetLayout`'s foot: the buttons the app's appearance shapes. */
5
+ export const SheetFootContext = createContext(false);
6
+ /** A button's shape and label: the app's in the foot, the sheet's own elsewhere. */
7
+ export function useSheetButtonLook(variant) {
8
+ const { buttons } = useSheetTheme();
9
+ const foot = use(SheetFootContext);
10
+ return (foot && buttons[variant]) || SHEET_BUTTON_LOOK;
11
+ }
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import { Animated, Easing, PanResponder, useWindowDimensions, } from 'react-native';
3
- import { SHEET_DIM_OPACITY, SHEET_SLIDE_MS, SHEET_TOP_GAP, } from "../models/sheet.constants.js";
3
+ import { SHEET_SLIDE_MS, SHEET_TOP_GAP } from "../models/sheet.constants.js";
4
4
  import { sheetSwipeCloses } from "../models/sheet.utils.js";
5
5
  /**
6
6
  * The bottom sheet's moves, in plain React Native: it slides up from below
@@ -49,7 +49,7 @@ export function useSheetMotion(open, onSwipe) {
49
49
  const [translateY] = useState(() => Animated.add(slide, drag));
50
50
  const dim = useMemo(() => translateY.interpolate({
51
51
  inputRange: [0, height],
52
- outputRange: [SHEET_DIM_OPACITY, 0],
52
+ outputRange: [1, 0],
53
53
  extrapolate: 'clamp',
54
54
  }), [translateY, height]);
55
55
  return {
@@ -1,10 +1,12 @@
1
1
  import { createContext, use } from 'react';
2
2
  import { CHECKOUT_COLORS } from "../checkout-core/models/checkout.constants.js";
3
3
  import { CheckoutThemeEnum } from "../checkout-core/models/checkout.enum.js";
4
+ import { sheetButtonLooks } from "../models/sheet.utils.js";
4
5
  export const SheetThemeContext = createContext({
5
6
  colors: CHECKOUT_COLORS[CheckoutThemeEnum.LIGHT],
6
7
  brand: CHECKOUT_COLORS[CheckoutThemeEnum.LIGHT].ink,
7
8
  dark: false,
9
+ buttons: sheetButtonLooks(undefined, false),
8
10
  });
9
11
  /** The open sheet's colours. */
10
12
  export function useSheetTheme() {
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export { BrissotoPayProvider } from './components/BrissotoPayProvider.js';
2
2
  export { usePaymentSheet } from './hooks/use-payment-sheet.js';
3
- export type { BrissotoPayProviderProps, PaymentSheet, PaymentSheetError, PaymentSheetResult, PaymentSheetStatus, PresentPaymentOptions, } from './models/sheet.interface.js';
3
+ export type { BrissotoPayAppearance, BrissotoPayButtonAppearance, BrissotoPayButtonsAppearance, BrissotoPayProviderProps, BrissotoPayThemedColor, PaymentSheet, PaymentSheetError, PaymentSheetResult, PaymentSheetStatus, PresentPaymentOptions, } from './models/sheet.interface.js';
@@ -1,7 +1,7 @@
1
1
  import type { LayoutAnimationConfig } from 'react-native';
2
2
  import type { StoreTabSpec } from './sheet.interface.js';
3
3
  import en from '../checkout-core/messages/en.js';
4
- import { PhoneStoreEnum } from '../checkout-core/models/checkout.enum.js';
4
+ import { CheckoutThemeEnum, PhoneStoreEnum } from '../checkout-core/models/checkout.enum.js';
5
5
  import { LangEnum, ProviderLogoEnum } from '../checkout-core/models/domain.enum.js';
6
6
  import { FigtreeEnum } from './sheet.enum.js';
7
7
  /** The production backend: Live and Test payments alike. */
@@ -54,8 +54,11 @@ export declare const MESSAGES: Record<LangEnum, {
54
54
  export declare const PROVIDER_LOGOS: Record<ProviderLogoEnum, number>;
55
55
  /** At its tallest, the sheet leaves this share of the screen above it, clear of the status bar. */
56
56
  export declare const SHEET_TOP_GAP = 0.1;
57
- /** How dark the app gets behind the sheet. */
58
- export declare const SHEET_DIM_OPACITY = 0.4;
57
+ /**
58
+ * How dark the app gets behind a sheet. A dark sheet is close to a dark
59
+ * app's own colours: only a deeper dim shows it standing above the app.
60
+ */
61
+ export declare const SHEET_DIM_OPACITY: Record<CheckoutThemeEnum, number>;
59
62
  /** How long the sheet takes to slide up or away, in ms. */
60
63
  export declare const SHEET_SLIDE_MS = 280;
61
64
  /** Points down that close the sheet when the finger lets go. */
@@ -78,9 +81,19 @@ export declare const STEP_SLIDE_DISTANCE = 32;
78
81
  /** A field the payer still has to fill, shaken once when Pay is pressed: its offsets, then back. */
79
82
  export declare const SHAKE_MS = 300;
80
83
  export declare const SHAKE_OFFSETS: number[];
81
- /** The form's one row height and one corner, Pay's: the tabs, the method picked, the fields and the buttons line up. */
84
+ /** The form's one row height and one corner, Pay's: the tabs, the method picked, the fields and the buttons line up, unless the app shapes its footer buttons. */
82
85
  export declare const FIELD_HEIGHT = 50;
83
86
  export declare const FIELD_RADIUS = 14;
87
+ /** The sheet's own button: every button outside the foot, and the foot's unless the app sets its own. */
88
+ export declare const SHEET_BUTTON_LOOK: {
89
+ height: number;
90
+ radius: number;
91
+ fontSize: number;
92
+ };
93
+ /** What an app's footer buttons may take: a tap target at least (Apple's 44), labels that stay readable and fit. */
94
+ export declare const BUTTON_MIN_HEIGHT = 44;
95
+ export declare const BUTTON_MIN_FONT_SIZE = 12;
96
+ export declare const BUTTON_MAX_FONT_SIZE = 22;
84
97
  /** The tabs' inset around the tab on: its corner follows the bar's. */
85
98
  export declare const TABS_INSET = 3;
86
99
  /** The web's h-9 pill: its height, and a corner of half of it. */
@@ -99,8 +112,11 @@ export declare const CHEVRON_SIZE = 6.5;
99
112
  export declare const STROKE_WIDTH = 2;
100
113
  /** How see-through a row or a pill turns while pressed. */
101
114
  export declare const PRESSED_OPACITY = 0.7;
102
- /** The rounded top of the payment sheet and of the sheets over it. */
103
- export declare const SHEET_TOP_RADIUS = 14;
115
+ /**
116
+ * The rounded top of the payment sheet and of the sheets over it, as round
117
+ * as iOS 26's own sheets, whose corners follow the screen's.
118
+ */
119
+ export declare const SHEET_TOP_RADIUS = 38;
104
120
  /** Room under a sheet's last line, over the home indicator or the navigation bar. */
105
121
  export declare const SHEET_FOOT_BOTTOM = 28;
106
122
  /**
@@ -34,7 +34,7 @@ import logoVisa from '../../assets/logos/visa.png';
34
34
  import logoWave from '../../assets/logos/wave.png';
35
35
  import { LayoutAnimation } from 'react-native';
36
36
  import en from "../checkout-core/messages/en.js";
37
- import { PhoneStoreEnum } from "../checkout-core/models/checkout.enum.js";
37
+ import { CheckoutThemeEnum, PhoneStoreEnum, } from "../checkout-core/models/checkout.enum.js";
38
38
  import fr from "../checkout-core/messages/fr.js";
39
39
  import { LangEnum, ProviderLogoEnum, } from "../checkout-core/models/domain.enum.js";
40
40
  import { FigtreeEnum } from "./sheet.enum.js";
@@ -133,8 +133,14 @@ export const PROVIDER_LOGOS = {
133
133
  };
134
134
  /** At its tallest, the sheet leaves this share of the screen above it, clear of the status bar. */
135
135
  export const SHEET_TOP_GAP = 0.1;
136
- /** How dark the app gets behind the sheet. */
137
- export const SHEET_DIM_OPACITY = 0.4;
136
+ /**
137
+ * How dark the app gets behind a sheet. A dark sheet is close to a dark
138
+ * app's own colours: only a deeper dim shows it standing above the app.
139
+ */
140
+ export const SHEET_DIM_OPACITY = {
141
+ [CheckoutThemeEnum.LIGHT]: 0.4,
142
+ [CheckoutThemeEnum.DARK]: 0.75,
143
+ };
138
144
  /** How long the sheet takes to slide up or away, in ms. */
139
145
  export const SHEET_SLIDE_MS = 280;
140
146
  /** Points down that close the sheet when the finger lets go. */
@@ -160,9 +166,19 @@ export const STEP_SLIDE_DISTANCE = 32;
160
166
  /** A field the payer still has to fill, shaken once when Pay is pressed: its offsets, then back. */
161
167
  export const SHAKE_MS = 300;
162
168
  export const SHAKE_OFFSETS = [-6, 6, -3, 0];
163
- /** The form's one row height and one corner, Pay's: the tabs, the method picked, the fields and the buttons line up. */
169
+ /** The form's one row height and one corner, Pay's: the tabs, the method picked, the fields and the buttons line up, unless the app shapes its footer buttons. */
164
170
  export const FIELD_HEIGHT = 50;
165
171
  export const FIELD_RADIUS = 14;
172
+ /** The sheet's own button: every button outside the foot, and the foot's unless the app sets its own. */
173
+ export const SHEET_BUTTON_LOOK = {
174
+ height: FIELD_HEIGHT,
175
+ radius: FIELD_RADIUS,
176
+ fontSize: 16,
177
+ };
178
+ /** What an app's footer buttons may take: a tap target at least (Apple's 44), labels that stay readable and fit. */
179
+ export const BUTTON_MIN_HEIGHT = 44;
180
+ export const BUTTON_MIN_FONT_SIZE = 12;
181
+ export const BUTTON_MAX_FONT_SIZE = 22;
166
182
  /** The tabs' inset around the tab on: its corner follows the bar's. */
167
183
  export const TABS_INSET = 3;
168
184
  /** The web's h-9 pill: its height, and a corner of half of it. */
@@ -181,8 +197,11 @@ export const CHEVRON_SIZE = 6.5;
181
197
  export const STROKE_WIDTH = 2;
182
198
  /** How see-through a row or a pill turns while pressed. */
183
199
  export const PRESSED_OPACITY = 0.7;
184
- /** The rounded top of the payment sheet and of the sheets over it. */
185
- export const SHEET_TOP_RADIUS = 14;
200
+ /**
201
+ * The rounded top of the payment sheet and of the sheets over it, as round
202
+ * as iOS 26's own sheets, whose corners follow the screen's.
203
+ */
204
+ export const SHEET_TOP_RADIUS = 38;
186
205
  /** Room under a sheet's last line, over the home indicator or the navigation bar. */
187
206
  export const SHEET_FOOT_BOTTOM = 28;
188
207
  /**
@@ -7,11 +7,10 @@ import type { CardFieldsMessage, CheckoutColors, CheckoutCore, CheckoutToast, Ch
7
7
  import type { FigtreeEnum, SheetIconEnum, StoreProductTypeEnum, WebBrowserResultEnum } from './sheet.enum.js';
8
8
  /**
9
9
  * How the sheet ended. `closed`: the payer closed it with the payment still
10
- * open. `unavailable`: no method could take the payment, so its tabs said
11
- * so and nothing was paid (`payment.unavailable` on the server). A hint only: ship on `payment.paid` from the webhook or `getPayment`.
10
+ * open. A hint only: ship on `payment.paid` from the webhook or `getPayment`.
12
11
  */
13
12
  export type PaymentSheetStatus = 'paid' | 'pending' | 'cancelled' | 'expired' | 'locked' | 'refunded' | 'closed'
14
- /** No payment method could take the payment: the sheet said so, nothing was paid. */
13
+ /** No method could take the payment (`payment.unavailable`): nothing was paid. */
15
14
  | 'unavailable';
16
15
  /** Why the sheet could not show the payment: no payment has this id, or it could not load. */
17
16
  export type PaymentSheetError = 'not_found' | 'network';
@@ -30,8 +29,37 @@ export interface PaymentSheet {
30
29
  export interface BrissotoPayProviderProps {
31
30
  /** The Brissoto Pay backend; the production one by default. One backend serves Live and Test. */
32
31
  url?: string;
32
+ /** The sheet's look, set once for the whole app. */
33
+ appearance?: BrissotoPayAppearance;
33
34
  children?: ReactNode;
34
35
  }
36
+ /** How the payment sheet looks in this app. Anything left out keeps the sheet's own look. */
37
+ export interface BrissotoPayAppearance {
38
+ /** The buttons at the foot of the sheet, per kind. */
39
+ buttons?: BrissotoPayButtonsAppearance;
40
+ }
41
+ export interface BrissotoPayButtonsAppearance {
42
+ /** The main action: Continue, Pay, Pay with the store, Try again, Done, Return to the app. Its height and corner also shape the PayPal button. */
43
+ primary?: BrissotoPayButtonAppearance;
44
+ /** Outlined: Send again. */
45
+ secondary?: BrissotoPayButtonAppearance;
46
+ /** No border, a quiet second choice: Try with…, Use another method. */
47
+ plain?: BrissotoPayButtonAppearance;
48
+ }
49
+ export interface BrissotoPayButtonAppearance {
50
+ /** In points, 44 at least (50 by default). */
51
+ height?: number;
52
+ /** In points, half the height at most: a pill (14 by default). */
53
+ radius?: number;
54
+ /** The label's size in points, 12 to 22 (16 by default). */
55
+ fontSize?: number;
56
+ /** The label's colour: one for both themes, or one per theme. */
57
+ labelColor?: string | BrissotoPayThemedColor;
58
+ }
59
+ export interface BrissotoPayThemedColor {
60
+ light: string;
61
+ dark: string;
62
+ }
35
63
  /** The sheet the app asked for, and how to answer it. */
36
64
  export interface SheetRequest {
37
65
  paymentId: string;
@@ -46,6 +74,7 @@ export interface SheetConnection extends CheckoutConnection {
46
74
  }
47
75
  export interface PaymentSheetModalProps {
48
76
  connection: SheetConnection;
77
+ appearance?: BrissotoPayAppearance;
49
78
  request: SheetRequest;
50
79
  onClose: (result: PaymentSheetResult) => void;
51
80
  }
@@ -68,7 +97,7 @@ export interface SheetMotion {
68
97
  shown: boolean;
69
98
  /** How far below its place the sheet is drawn. */
70
99
  translateY: Animated.AnimatedAddition;
71
- /** The dim over the app, lighter as the sheet goes down. */
100
+ /** How much of the dim shows, 1 up to 0 as the sheet goes down. */
72
101
  dim: Animated.AnimatedInterpolation<number>;
73
102
  dragHandlers: GestureResponderHandlers;
74
103
  /** Room left above the sheet at its tallest, in points. */
@@ -79,6 +108,16 @@ export interface SheetTheme {
79
108
  colors: CheckoutColors;
80
109
  brand: string;
81
110
  dark: boolean;
111
+ /** The footer buttons' shape and label, from the app's appearance, by variant. */
112
+ buttons: Partial<Record<CheckoutButtonVariantEnum, SheetButtonLook>>;
113
+ }
114
+ /** A footer button's shape and label, worked out for the sheet's theme. */
115
+ export interface SheetButtonLook {
116
+ height: number;
117
+ radius: number;
118
+ fontSize: number;
119
+ /** Unset: the variant's own colour. */
120
+ labelColor?: string;
82
121
  }
83
122
  export interface SheetTextProps extends TextProps {
84
123
  weight?: FigtreeEnum;
@@ -1,8 +1,8 @@
1
- import { CheckoutThemeEnum, StoreSheetOutcomeEnum } from '../checkout-core/models/checkout.enum.js';
1
+ import { CheckoutButtonVariantEnum, CheckoutThemeEnum, StoreSheetOutcomeEnum } from '../checkout-core/models/checkout.enum.js';
2
2
  import { LangEnum } from '../checkout-core/models/domain.enum.js';
3
3
  import type { CountryEnum } from '../checkout-core/models/domain.enum.js';
4
4
  import type { CardFieldsMessage, CheckoutView } from '../checkout-core/models/checkout.interface.js';
5
- import type { CardFieldsAddress, PaymentSheetResult, StorePurchase, StoreSheetAttempt, UnreportedPurchase } from './sheet.interface.js';
5
+ import type { BrissotoPayAppearance, CardFieldsAddress, PaymentSheetResult, SheetButtonLook, StorePurchase, StoreSheetAttempt, UnreportedPurchase } from './sheet.interface.js';
6
6
  /** The payment's language, else the device's when the sheet speaks it, else English. */
7
7
  export declare function sheetLanguage(payment: LangEnum | null, deviceLocale: string): LangEnum;
8
8
  /** The payment's theme, else the device's scheme. */
@@ -66,3 +66,7 @@ export declare function sheetOutcomeOf(code: string): StoreSheetOutcomeEnum;
66
66
  export declare function quietly(call: Promise<unknown>): void;
67
67
  /** What `read` answers within `ms`; null when it fails or is later. */
68
68
  export declare function answerWithin<TAnswer>(read: () => Promise<TAnswer>, ms: number): Promise<TAnswer | null>;
69
+ /** A sheet's dim over the app, deeper behind a dark sheet. */
70
+ export declare function sheetDim(dark: boolean): string;
71
+ /** The footer buttons the app's appearance asks for, in the sheet's theme. */
72
+ export declare function sheetButtonLooks(appearance: BrissotoPayAppearance | undefined, dark: boolean): Partial<Record<CheckoutButtonVariantEnum, SheetButtonLook>>;
@@ -1,6 +1,6 @@
1
- import { CardFieldsMessageEnum, CheckoutPaymentStatusEnum, CheckoutThemeEnum, PayRefusalEnum, StoreSheetOutcomeEnum, } from "../checkout-core/models/checkout.enum.js";
1
+ import { CardFieldsMessageEnum, CheckoutButtonVariantEnum, CheckoutPaymentStatusEnum, CheckoutThemeEnum, PayRefusalEnum, StoreSheetOutcomeEnum, } from "../checkout-core/models/checkout.enum.js";
2
2
  import { AttemptStatusEnum, LangEnum, } from "../checkout-core/models/domain.enum.js";
3
- import { BANK_PAGE_VIEWPORT, PAGE_VIEWPORT, PILL_ROW_HEIGHT, SHEET_FLICK_SPEED, SHEET_SWIPE_DISTANCE, STORE_TOKEN_PATTERN, } from "./sheet.constants.js";
3
+ import { BANK_PAGE_VIEWPORT, BUTTON_MAX_FONT_SIZE, BUTTON_MIN_FONT_SIZE, BUTTON_MIN_HEIGHT, PAGE_VIEWPORT, PILL_ROW_HEIGHT, SHEET_BUTTON_LOOK, SHEET_DIM_OPACITY, SHEET_FLICK_SPEED, SHEET_SWIPE_DISTANCE, STORE_TOKEN_PATTERN, } from "./sheet.constants.js";
4
4
  import { StoreErrorCodeEnum, StorePurchaseStateEnum } from "./sheet.enum.js";
5
5
  /** The payment's language, else the device's when the sheet speaks it, else English. */
6
6
  export function sheetLanguage(payment, deviceLocale) {
@@ -212,3 +212,33 @@ export async function answerWithin(read, ms) {
212
212
  clearTimeout(timer);
213
213
  }
214
214
  }
215
+ /** A sheet's dim over the app, deeper behind a dark sheet. */
216
+ export function sheetDim(dark) {
217
+ const theme = dark ? CheckoutThemeEnum.DARK : CheckoutThemeEnum.LIGHT;
218
+ return `rgba(0, 0, 0, ${SHEET_DIM_OPACITY[theme]})`;
219
+ }
220
+ /** One footer button's shape and label, kept within what stays usable. */
221
+ function sheetButtonLook(style, dark) {
222
+ const height = Math.max(style?.height ?? SHEET_BUTTON_LOOK.height, BUTTON_MIN_HEIGHT);
223
+ const fontSize = Math.min(Math.max(style?.fontSize ?? SHEET_BUTTON_LOOK.fontSize, BUTTON_MIN_FONT_SIZE), BUTTON_MAX_FONT_SIZE);
224
+ const look = {
225
+ height,
226
+ radius: Math.min(Math.max(style?.radius ?? SHEET_BUTTON_LOOK.radius, 0), height / 2),
227
+ fontSize,
228
+ };
229
+ const color = style?.labelColor;
230
+ if (color !== undefined) {
231
+ look.labelColor =
232
+ typeof color === 'string' ? color : dark ? color.dark : color.light;
233
+ }
234
+ return look;
235
+ }
236
+ /** The footer buttons the app's appearance asks for, in the sheet's theme. */
237
+ export function sheetButtonLooks(appearance, dark) {
238
+ const buttons = appearance?.buttons;
239
+ return {
240
+ [CheckoutButtonVariantEnum.PRIMARY]: sheetButtonLook(buttons?.primary, dark),
241
+ [CheckoutButtonVariantEnum.SECONDARY]: sheetButtonLook(buttons?.secondary, dark),
242
+ [CheckoutButtonVariantEnum.PLAIN]: sheetButtonLook(buttons?.plain, dark),
243
+ };
244
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brissoto/pay-react-native",
3
- "version": "1.5.1",
3
+ "version": "1.6.0",
4
4
  "description": "Brissoto Pay for Expo and React Native apps: the payment sheet.",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,