@flopay/shared 1.15.0 → 1.16.1

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.
@@ -17,6 +17,11 @@ export interface PaymentMethodCountryRule {
17
17
  countries: string[];
18
18
  /** The order for these countries. Left out, the default `order` applies. */
19
19
  order?: PaymentMethodGroup[];
20
+ /**
21
+ * The groups behind "More payment options" for these countries. Left out,
22
+ * the default `moreOptions` applies; `[]` shows every group.
23
+ */
24
+ moreOptions?: PaymentMethodGroup[];
20
25
  }
21
26
  /**
22
27
  * The merchant's payment method layout rules. The billing API applies them to
@@ -30,6 +35,12 @@ export interface PaymentMethodLayoutRules {
30
35
  * console warning.
31
36
  */
32
37
  order?: PaymentMethodGroup[];
38
+ /**
39
+ * The groups shown only after the buyer opens a closed "More payment
40
+ * options" link. In the default layout the card form always stays in view,
41
+ * so `'card'` there applies to the buttons layout only.
42
+ */
43
+ moreOptions?: PaymentMethodGroup[];
33
44
  /** Rules for buyers in particular countries, at most 50. The first rule naming the buyer country applies. */
34
45
  countryRules?: PaymentMethodCountryRule[];
35
46
  }
@@ -57,14 +68,43 @@ export interface PaymentMethodLayout {
57
68
  */
58
69
  export declare function normalizePaymentMethodLayout(raw: unknown): PaymentMethodLayout | null;
59
70
  /**
60
- * The merchant's default order, resolved without the billing API: the
61
- * fallback when the API returns no layout (an older API, a network failure or
62
- * a slow answer). It applies no country rules. Listed groups come first, in
63
- * the merchant's order; groups left out follow in the default order. Unknown
64
- * and repeated values are dropped with a console warning (once per distinct
65
- * value), and anything that is not an array gives the default order.
71
+ * The merchant's default order, resolved without the billing API. Listed
72
+ * groups come first, in the merchant's order; groups left out follow in the
73
+ * default order. Unknown and repeated values are dropped with a console
74
+ * warning (once per distinct value), and anything that is not an array gives
75
+ * the default order.
66
76
  */
67
77
  export declare function resolvePaymentMethodOrder(order: unknown): PaymentMethodGroup[];
78
+ /** The order to render the groups in, and the ones behind "More payment options". */
79
+ export type PaymentMethodGroupLayout = Pick<PaymentMethodLayout, 'order' | 'moreOptions'>;
80
+ /**
81
+ * The merchant's default rule, resolved without the billing API: the fallback
82
+ * when the API returns no layout (an older API, a network failure or a slow
83
+ * answer). It applies no country rules. `moreOptions` comes back in the
84
+ * resolved order.
85
+ */
86
+ export declare function resolveDefaultPaymentMethodLayout(rules: PaymentMethodLayoutRules): PaymentMethodGroupLayout;
87
+ /** Where a layout's groups render: in view, or behind "More payment options". */
88
+ export interface PaymentMethodGroupPlacement {
89
+ /** The groups in view, in the resolved order. */
90
+ inView: PaymentMethodGroup[];
91
+ /** The groups behind the link, in the resolved order. */
92
+ behindLink: PaymentMethodGroup[];
93
+ /** Whether to show the link: something behind it is available. */
94
+ showLink: boolean;
95
+ }
96
+ /**
97
+ * Splits a resolved layout between the groups in view and the groups behind
98
+ * the "More payment options" link. `canHide` says which groups this layout
99
+ * may put behind the link (the default layout keeps its card form in view),
100
+ * and `available` which groups can show a payment method. When nothing
101
+ * available would stay in view, every group shows and there is no link; when
102
+ * nothing behind the link is available, there is no link.
103
+ */
104
+ export declare function placePaymentMethodGroups(layout: PaymentMethodGroupLayout, { canHide, available, }: {
105
+ canHide: (group: PaymentMethodGroup) => boolean;
106
+ available: (group: PaymentMethodGroup) => boolean;
107
+ }): PaymentMethodGroupPlacement;
68
108
  /**
69
109
  * Whether the default layout puts its card form above the buttons. Only when
70
110
  * Card is listed first: the card form is one block, so anywhere else it keeps
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flopay/shared",
3
- "version": "1.15.0",
3
+ "version": "1.16.1",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "publishConfig": {