@brissoto/pay-react-native 1.6.5 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -202,7 +202,7 @@ Style the buttons at the foot of the sheet, per kind. Anything left out keeps th
202
202
  | ----------- | --------------------------------------------------------------------------------------------------------------- |
203
203
  | `primary` | Continue, Pay, Pay with the store, Try again, Done, Return to the app. PayPal takes its height and radius only. |
204
204
  | `secondary` | Send again (outlined). |
205
- | `plain` | Try with…, Use another method (no border). |
205
+ | `plain` | Try with…, Use another method: a text button, so `fontSize` and `labelColor` only. |
206
206
 
207
207
  | Field | Default | Allowed |
208
208
  | ------------ | ------------------------------------------------- | ------------------------------ |
@@ -192,7 +192,7 @@ export declare enum TerminalKindEnum {
192
192
  export declare enum CheckoutButtonVariantEnum {
193
193
  PRIMARY = "primary",
194
194
  SECONDARY = "secondary",
195
- /** The second choice under Pay or Try again: the secondary's look, no border. */
195
+ /** The second choice under Pay or Try again: a text button, no box, centred. */
196
196
  PLAIN = "plain",
197
197
  /** Gives something up: cancelling the payment. */
198
198
  DANGER = "danger",
@@ -215,7 +215,7 @@ export var CheckoutButtonVariantEnum;
215
215
  (function (CheckoutButtonVariantEnum) {
216
216
  CheckoutButtonVariantEnum["PRIMARY"] = "primary";
217
217
  CheckoutButtonVariantEnum["SECONDARY"] = "secondary";
218
- /** The second choice under Pay or Try again: the secondary's look, no border. */
218
+ /** The second choice under Pay or Try again: a text button, no box, centred. */
219
219
  CheckoutButtonVariantEnum["PLAIN"] = "plain";
220
220
  /** Gives something up: cancelling the payment. */
221
221
  CheckoutButtonVariantEnum["DANGER"] = "danger";
@@ -1,8 +1,8 @@
1
1
  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
- * 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. In the sheet's
6
- * foot, the app's appearance sets their height, corner and label.
4
+ * outlined for the rest, plain (a text button, no box) for a quiet second
5
+ * choice, a link in the app colour for a quiet action in a line of its own.
6
+ * In the sheet's foot, the app's appearance sets their height, corner and label.
7
7
  */
8
8
  export declare function SheetButton({ label, onPress, variant, busy, disabled, inactive, }: SheetButtonProps): import("react").JSX.Element;
@@ -7,29 +7,32 @@ import { FigtreeEnum } from "../models/sheet.enum.js";
7
7
  import { SheetText } from "./SheetText.js";
8
8
  /**
9
9
  * The sheet's buttons: filled in the app colour for the main action,
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. In the sheet's
12
- * foot, the app's appearance sets their height, corner and label.
10
+ * outlined for the rest, plain (a text button, no box) for a quiet second
11
+ * choice, a link in the app colour for a quiet action in a line of its own.
12
+ * In the sheet's foot, the app's appearance sets their height, corner and label.
13
13
  */
14
14
  export function SheetButton({ label, onPress, variant = CheckoutButtonVariantEnum.PRIMARY, busy = false, disabled = false, inactive = false, }) {
15
15
  const { colors, brand } = useSheetTheme();
16
16
  const primary = variant === CheckoutButtonVariantEnum.PRIMARY;
17
17
  const link = variant === CheckoutButtonVariantEnum.LINK;
18
+ const plain = variant === CheckoutButtonVariantEnum.PLAIN;
18
19
  const look = useSheetButtonLook(variant);
19
20
  const ink = look.labelColor ?? (primary ? 'white' : link ? brand : colors.ink);
20
21
  const off = disabled || busy;
21
22
  return (_jsxs(TouchableOpacity, { onPress: onPress, disabled: off, activeOpacity: 0.8, accessibilityRole: "button", accessibilityState: { disabled: off, busy },
22
- // A link's text is short: its tap reaches a little past it.
23
- hitSlop: link ? 6 : undefined, style: [
23
+ // A text button is short: its tap reaches a little past it.
24
+ hitSlop: link ? 6 : plain ? 8 : undefined, style: [
24
25
  link
25
26
  ? styles.link
26
- : [
27
- styles.button,
28
- { minHeight: look.height, borderRadius: look.radius },
29
- ],
27
+ : plain
28
+ ? styles.plain
29
+ : [
30
+ styles.button,
31
+ { minHeight: look.height, borderRadius: look.radius },
32
+ ],
30
33
  primary
31
34
  ? { backgroundColor: brand }
32
- : variant !== CheckoutButtonVariantEnum.PLAIN &&
35
+ : !plain &&
33
36
  !link && {
34
37
  borderWidth: 1,
35
38
  borderColor: colors.line3,
@@ -45,6 +48,15 @@ const styles = StyleSheet.create({
45
48
  gap: 10,
46
49
  paddingHorizontal: 16,
47
50
  },
51
+ // Text only, centred under the action it backs up: no box, no full width.
52
+ plain: {
53
+ alignSelf: 'center',
54
+ flexDirection: 'row',
55
+ alignItems: 'center',
56
+ gap: 10,
57
+ paddingVertical: 6,
58
+ paddingHorizontal: 12,
59
+ },
48
60
  // The web's link: a line of its own, as tall as a tap needs.
49
61
  link: { alignSelf: 'flex-start', height: 32, justifyContent: 'center' },
50
62
  label: { textAlign: 'center', fontVariant: ['tabular-nums'] },
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 { BrissotoPayAppearance, BrissotoPayButtonAppearance, BrissotoPayButtonsAppearance, BrissotoPayProviderProps, BrissotoPayThemedColor, PaymentSheet, PaymentSheetError, PaymentSheetResult, PaymentSheetStatus, PresentPaymentOptions, } from './models/sheet.interface.js';
3
+ export type { BrissotoPayAppearance, BrissotoPayButtonAppearance, BrissotoPayTextButtonAppearance, BrissotoPayButtonsAppearance, BrissotoPayProviderProps, BrissotoPayThemedColor, PaymentSheet, PaymentSheetError, PaymentSheetResult, PaymentSheetStatus, PresentPaymentOptions, } from './models/sheet.interface.js';
@@ -43,19 +43,22 @@ export interface BrissotoPayButtonsAppearance {
43
43
  primary?: BrissotoPayButtonAppearance;
44
44
  /** Outlined: Send again. */
45
45
  secondary?: BrissotoPayButtonAppearance;
46
- /** No border, a quiet second choice: Try with…, Use another method. */
47
- plain?: BrissotoPayButtonAppearance;
46
+ /** A text button, no box: Try with…, Use another method. Its label only. */
47
+ plain?: BrissotoPayTextButtonAppearance;
48
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;
49
+ /** A text button's label. */
50
+ export interface BrissotoPayTextButtonAppearance {
54
51
  /** The label's size in points, 12 to 22 (16 by default). */
55
52
  fontSize?: number;
56
53
  /** The label's colour: one for both themes, or one per theme. */
57
54
  labelColor?: string | BrissotoPayThemedColor;
58
55
  }
56
+ export interface BrissotoPayButtonAppearance extends BrissotoPayTextButtonAppearance {
57
+ /** In points, 44 at least (50 by default). */
58
+ height?: number;
59
+ /** In points, half the height at most: a pill (14 by default). */
60
+ radius?: number;
61
+ }
59
62
  export interface BrissotoPayThemedColor {
60
63
  light: string;
61
64
  dark: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brissoto/pay-react-native",
3
- "version": "1.6.5",
3
+ "version": "1.7.0",
4
4
  "description": "Brissoto Pay for Expo and React Native apps: the payment sheet.",
5
5
  "license": "MIT",
6
6
  "sideEffects": false,