@paypal/checkout-components 5.0.256 → 5.0.258

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.
Files changed (185) hide show
  1. package/README.md +8 -0
  2. package/__sdk__.js +72 -76
  3. package/dist/button.js +1 -1
  4. package/globals.js +28 -30
  5. package/package.json +6 -4
  6. package/src/constants/button.js +37 -36
  7. package/src/constants/class.js +32 -30
  8. package/src/constants/index.js +3 -3
  9. package/src/constants/misc.js +14 -12
  10. package/src/declarations.js +19 -19
  11. package/src/funding/applepay/config.jsx +51 -50
  12. package/src/funding/applepay/index.js +1 -1
  13. package/src/funding/applepay/style.scoped.scss +1 -1
  14. package/src/funding/applepay/template.jsx +16 -11
  15. package/src/funding/bancontact/config.jsx +48 -37
  16. package/src/funding/bancontact/index.js +1 -2
  17. package/src/funding/blik/config.jsx +48 -37
  18. package/src/funding/blik/index.js +1 -2
  19. package/src/funding/boleto/config.jsx +50 -39
  20. package/src/funding/boleto/index.js +1 -2
  21. package/src/funding/card/amex/config.js +9 -8
  22. package/src/funding/card/amex/index.js +1 -2
  23. package/src/funding/card/config.jsx +246 -177
  24. package/src/funding/card/discover/config.js +9 -7
  25. package/src/funding/card/discover/index.js +1 -2
  26. package/src/funding/card/elo/config.js +6 -7
  27. package/src/funding/card/elo/index.js +1 -2
  28. package/src/funding/card/hiper/config.js +9 -7
  29. package/src/funding/card/hiper/index.js +1 -2
  30. package/src/funding/card/index.js +1 -1
  31. package/src/funding/card/jcb/config.js +6 -7
  32. package/src/funding/card/jcb/index.js +1 -2
  33. package/src/funding/card/mastercard/config.js +9 -7
  34. package/src/funding/card/mastercard/index.js +1 -2
  35. package/src/funding/card/visa/config.js +9 -7
  36. package/src/funding/card/visa/index.js +1 -2
  37. package/src/funding/common.jsx +242 -216
  38. package/src/funding/config.js +212 -65
  39. package/src/funding/content.jsx +1946 -337
  40. package/src/funding/credit/config.jsx +74 -57
  41. package/src/funding/credit/index.js +1 -2
  42. package/src/funding/eps/config.jsx +45 -37
  43. package/src/funding/eps/index.js +1 -2
  44. package/src/funding/funding.js +193 -100
  45. package/src/funding/giropay/config.jsx +48 -38
  46. package/src/funding/giropay/index.js +1 -2
  47. package/src/funding/ideal/config.jsx +48 -37
  48. package/src/funding/ideal/index.js +1 -2
  49. package/src/funding/index.js +2 -2
  50. package/src/funding/itau/config.jsx +41 -41
  51. package/src/funding/itau/index.js +1 -1
  52. package/src/funding/maxima/config.jsx +25 -19
  53. package/src/funding/maxima/index.js +1 -2
  54. package/src/funding/mercadopago/config.jsx +48 -37
  55. package/src/funding/mercadopago/index.js +1 -2
  56. package/src/funding/multibanco/config.jsx +50 -39
  57. package/src/funding/multibanco/index.js +1 -2
  58. package/src/funding/mybank/config.jsx +48 -37
  59. package/src/funding/mybank/index.js +1 -2
  60. package/src/funding/oxxo/config.jsx +50 -39
  61. package/src/funding/oxxo/index.js +1 -2
  62. package/src/funding/p24/config.jsx +45 -37
  63. package/src/funding/p24/index.js +1 -2
  64. package/src/funding/paidy/config.jsx +50 -39
  65. package/src/funding/paidy/index.js +1 -1
  66. package/src/funding/paylater/config.jsx +118 -111
  67. package/src/funding/paylater/index.js +1 -2
  68. package/src/funding/paypal/config.jsx +44 -46
  69. package/src/funding/paypal/index.js +1 -2
  70. package/src/funding/paypal/style.scoped.scss +80 -74
  71. package/src/funding/paypal/template.jsx +450 -354
  72. package/src/funding/payu/config.jsx +50 -39
  73. package/src/funding/payu/index.js +1 -1
  74. package/src/funding/satispay/config.jsx +50 -39
  75. package/src/funding/satispay/index.js +1 -1
  76. package/src/funding/sepa/config.jsx +19 -13
  77. package/src/funding/sepa/index.js +1 -2
  78. package/src/funding/sofort/config.jsx +48 -37
  79. package/src/funding/sofort/index.js +1 -2
  80. package/src/funding/trustly/config.jsx +50 -39
  81. package/src/funding/trustly/index.js +1 -2
  82. package/src/funding/venmo/config.jsx +80 -75
  83. package/src/funding/venmo/index.js +1 -2
  84. package/src/funding/venmo/style.scoped.scss +30 -32
  85. package/src/funding/venmo/template.jsx +56 -57
  86. package/src/funding/verkkopankki/config.jsx +50 -39
  87. package/src/funding/verkkopankki/index.js +1 -1
  88. package/src/funding/wechatpay/config.jsx +48 -37
  89. package/src/funding/wechatpay/index.js +1 -2
  90. package/src/funding/zimpler/config.jsx +19 -13
  91. package/src/funding/zimpler/index.js +1 -2
  92. package/src/interface/button.js +60 -44
  93. package/src/interface/card-fields.js +11 -8
  94. package/src/interface/fields.js +7 -4
  95. package/src/interface/marks.js +4 -4
  96. package/src/interface/payment-fields.js +7 -4
  97. package/src/interface/wallet.js +4 -4
  98. package/src/lib/errors.js +7 -7
  99. package/src/lib/index.js +5 -5
  100. package/src/lib/isRTLLanguage.js +3 -3
  101. package/src/lib/perceived-latency-instrumentation.js +54 -36
  102. package/src/lib/security.js +21 -17
  103. package/src/lib/session.js +39 -35
  104. package/src/marks/component.jsx +114 -65
  105. package/src/marks/index.js +1 -2
  106. package/src/marks/template.jsx +79 -65
  107. package/src/types.js +48 -48
  108. package/src/ui/buttons/button.jsx +311 -249
  109. package/src/ui/buttons/buttonDesigns/control.jsx +3 -5
  110. package/src/ui/buttons/buttonDesigns/divideLogoAnimation.jsx +127 -99
  111. package/src/ui/buttons/buttonDesigns/index.js +78 -75
  112. package/src/ui/buttons/buttonDesigns/inlineLogoTextDesign.jsx +102 -82
  113. package/src/ui/buttons/buttonDesigns/script.jsx +24 -18
  114. package/src/ui/buttons/buttonDesigns/types.js +6 -7
  115. package/src/ui/buttons/buttons.jsx +318 -212
  116. package/src/ui/buttons/config.js +62 -59
  117. package/src/ui/buttons/content.jsx +304 -119
  118. package/src/ui/buttons/index.js +1 -1
  119. package/src/ui/buttons/menu-button/index.js +1 -1
  120. package/src/ui/buttons/menu-button/menu-button.jsx +29 -22
  121. package/src/ui/buttons/menu-button/menu-button.scoped.scss +16 -17
  122. package/src/ui/buttons/poweredBy.jsx +23 -23
  123. package/src/ui/buttons/props.js +680 -529
  124. package/src/ui/buttons/script.jsx +182 -160
  125. package/src/ui/buttons/spinner.jsx +4 -6
  126. package/src/ui/buttons/style.jsx +15 -14
  127. package/src/ui/buttons/styles/base.js +24 -16
  128. package/src/ui/buttons/styles/button.js +24 -22
  129. package/src/ui/buttons/styles/color.js +118 -118
  130. package/src/ui/buttons/styles/custom.js +30 -24
  131. package/src/ui/buttons/styles/index.js +1 -1
  132. package/src/ui/buttons/styles/labels.js +17 -13
  133. package/src/ui/buttons/styles/page.js +3 -3
  134. package/src/ui/buttons/styles/responsive.js +226 -118
  135. package/src/ui/buttons/tagline.jsx +53 -54
  136. package/src/ui/chevron.jsx +27 -16
  137. package/src/ui/index.js +3 -3
  138. package/src/ui/loading.jsx +25 -18
  139. package/src/ui/text/index.js +1 -1
  140. package/src/ui/text/style.scoped.scss +25 -26
  141. package/src/ui/text/text.jsx +42 -20
  142. package/src/ui/tracking.jsx +18 -11
  143. package/src/zoid/buttons/component.jsx +836 -684
  144. package/src/zoid/buttons/container.jsx +140 -107
  145. package/src/zoid/buttons/index.js +1 -1
  146. package/src/zoid/buttons/prerender.jsx +84 -64
  147. package/src/zoid/buttons/util.js +355 -254
  148. package/src/zoid/card-fields/component.jsx +581 -549
  149. package/src/zoid/card-fields/index.js +1 -1
  150. package/src/zoid/card-fields/prerender.jsx +20 -17
  151. package/src/zoid/card-form/component.js +155 -141
  152. package/src/zoid/card-form/index.js +1 -1
  153. package/src/zoid/checkout/component.jsx +314 -282
  154. package/src/zoid/checkout/config.js +2 -2
  155. package/src/zoid/checkout/content.js +190 -154
  156. package/src/zoid/checkout/hacks.js +31 -28
  157. package/src/zoid/checkout/index.js +2 -2
  158. package/src/zoid/checkout/props.js +27 -33
  159. package/src/zoid/installments/component.jsx +83 -70
  160. package/src/zoid/installments/index.js +1 -1
  161. package/src/zoid/installments/props.js +1 -1
  162. package/src/zoid/menu/component.jsx +53 -48
  163. package/src/zoid/menu/index.js +1 -1
  164. package/src/zoid/menu/props.js +1 -3
  165. package/src/zoid/modal/component.jsx +119 -106
  166. package/src/zoid/modal/index.js +1 -1
  167. package/src/zoid/modal/props.js +1 -3
  168. package/src/zoid/payment-fields/component.jsx +215 -191
  169. package/src/zoid/payment-fields/container.jsx +73 -64
  170. package/src/zoid/payment-fields/index.js +1 -1
  171. package/src/zoid/payment-fields/prerender.jsx +16 -14
  172. package/src/zoid/payment-fields/props.js +6 -6
  173. package/src/zoid/qr-code/component.jsx +131 -115
  174. package/src/zoid/qr-code/container.jsx +74 -68
  175. package/src/zoid/qr-code/index.js +1 -1
  176. package/src/zoid/qr-code/prerender.jsx +17 -12
  177. package/src/zoid/qr-code/types.js +2 -2
  178. package/src/zoid/wallet/component.jsx +298 -260
  179. package/src/zoid/wallet/container.jsx +73 -64
  180. package/src/zoid/wallet/index.js +1 -1
  181. package/src/zoid/wallet/prerender.jsx +14 -14
  182. package/src/zoid/wallet/props.js +4 -4
  183. package/src/actions/save/index.js +0 -40
  184. package/src/interface/actions.js +0 -14
  185. package/src/lib/getLogoCDNExperiment.js +0 -25
@@ -1,269 +1,331 @@
1
1
  /* @flow */
2
2
  /** @jsx node */
3
3
 
4
- import type { FundingEligibilityType } from '@paypal/sdk-client/src';
5
- import { FUNDING, ENV, type LocaleType } from '@paypal/sdk-constants/src';
6
- import { node, type ElementNode } from '@krakenjs/jsx-pragmatic/src';
7
- import { LOGO_COLOR, LOGO_CLASS } from '@paypal/sdk-logos/src';
8
- import { noop, preventClickFocus, isBrowser, isElement } from '@krakenjs/belter/src';
9
-
10
- import type { ContentType, Wallet, Experiment, WalletInstrument } from '../../types';
11
- import { ATTRIBUTE, CLASS, BUTTON_COLOR, BUTTON_NUMBER, EXPERIENCE, TEXT_COLOR, BUTTON_FLOW } from '../../constants';
12
- import { getFundingConfig } from '../../funding';
13
- import { DesignExperimentLabel } from '../../funding/paypal/template';
14
-
15
- import { getButtonDesign } from './buttonDesigns';
16
- import type { ButtonStyle, Personalization, OnShippingChange, OnShippingAddressChange, OnShippingOptionsChange } from './props';
17
- import { Spinner } from './spinner';
18
- import { MenuButton } from './menu-button';
4
+ import type { FundingEligibilityType } from "@paypal/sdk-client/src";
5
+ import { FUNDING, ENV, type LocaleType } from "@paypal/sdk-constants/src";
6
+ import { node, type ElementNode } from "@krakenjs/jsx-pragmatic/src";
7
+ import { LOGO_COLOR, LOGO_CLASS } from "@paypal/sdk-logos/src";
8
+ import {
9
+ noop,
10
+ preventClickFocus,
11
+ isBrowser,
12
+ isElement,
13
+ } from "@krakenjs/belter/src";
14
+
15
+ import type {
16
+ ContentType,
17
+ Wallet,
18
+ Experiment,
19
+ WalletInstrument,
20
+ } from "../../types";
21
+ import {
22
+ ATTRIBUTE,
23
+ CLASS,
24
+ BUTTON_COLOR,
25
+ BUTTON_NUMBER,
26
+ EXPERIENCE,
27
+ TEXT_COLOR,
28
+ BUTTON_FLOW,
29
+ } from "../../constants";
30
+ import { getFundingConfig } from "../../funding";
31
+ import { DesignExperimentLabel } from "../../funding/paypal/template";
32
+
33
+ import { getButtonDesign } from "./buttonDesigns";
34
+ import type {
35
+ ButtonStyle,
36
+ Personalization,
37
+ OnShippingChange,
38
+ OnShippingAddressChange,
39
+ OnShippingOptionsChange,
40
+ } from "./props";
41
+ import { Spinner } from "./spinner";
42
+ import { MenuButton } from "./menu-button";
19
43
 
20
44
  type IndividualButtonProps = {|
21
- style : ButtonStyle,
22
- fundingSource : $Values<typeof FUNDING>,
23
- multiple : boolean,
24
- locale : LocaleType,
25
- onClick? : Function,
26
- env : $Values<typeof ENV>,
27
- wallet? : ?Wallet,
28
- fundingEligibility : FundingEligibilityType,
29
- onShippingChange : ?OnShippingChange,
30
- onShippingAddressChange : ?OnShippingAddressChange,
31
- onShippingOptionsChange : ?OnShippingOptionsChange,
32
- i : number,
33
- nonce : string,
34
- userIDToken : ?string,
35
- personalization : ?Personalization,
36
- content : ?ContentType,
37
- tagline : ?boolean,
38
- commit : boolean,
39
- experiment : Experiment,
40
- flow : $Values<typeof BUTTON_FLOW>,
41
- vault : boolean,
42
- merchantFundingSource : ?$Values<typeof FUNDING>,
43
- instrument : ?WalletInstrument,
44
- experience? : string,
45
- showPayLabel : boolean
45
+ style: ButtonStyle,
46
+ fundingSource: $Values<typeof FUNDING>,
47
+ multiple: boolean,
48
+ locale: LocaleType,
49
+ onClick?: Function,
50
+ env: $Values<typeof ENV>,
51
+ wallet?: ?Wallet,
52
+ fundingEligibility: FundingEligibilityType,
53
+ onShippingChange: ?OnShippingChange,
54
+ onShippingAddressChange: ?OnShippingAddressChange,
55
+ onShippingOptionsChange: ?OnShippingOptionsChange,
56
+ i: number,
57
+ nonce: string,
58
+ userIDToken: ?string,
59
+ personalization: ?Personalization,
60
+ content: ?ContentType,
61
+ tagline: ?boolean,
62
+ commit: boolean,
63
+ experiment: Experiment,
64
+ flow: $Values<typeof BUTTON_FLOW>,
65
+ vault: boolean,
66
+ merchantFundingSource: ?$Values<typeof FUNDING>,
67
+ instrument: ?WalletInstrument,
68
+ experience?: string,
69
+ showPayLabel: boolean,
46
70
  |};
47
71
 
48
- export function Button({ fundingSource, style, multiple, locale, env, fundingEligibility, i, nonce, flow, vault,
49
- userIDToken, personalization, onClick = noop, content, tagline, commit, experiment, instrument, experience, showPayLabel } : IndividualButtonProps) : ElementNode {
50
-
51
- const { custom, layout, shape } = style;
52
- const inlineExperience = experience === EXPERIENCE.INLINE && custom && custom.label;
53
- const fundingConfig = getFundingConfig()[fundingSource];
54
-
55
- if (!fundingConfig) {
56
- throw new Error(`Can not find funding config for ${ fundingSource }`);
57
- }
58
-
59
- const colors = fundingConfig.colors;
60
- const secondaryColors = fundingConfig.secondaryColors || {};
61
-
62
- let {
63
- color = colors[0],
64
- period,
65
- label
66
- } = style;
67
-
68
- if (multiple && i > 0) {
69
- if (secondaryColors[color] && colors.indexOf(secondaryColors[color] !== -1)) {
70
- color = secondaryColors[color];
71
- } else if (colors.indexOf(secondaryColors[BUTTON_COLOR.DEFAULT]) !== -1) {
72
- color = secondaryColors[BUTTON_COLOR.DEFAULT];
73
- } else {
74
- color = colors[0];
75
- }
72
+ export function Button({
73
+ fundingSource,
74
+ style,
75
+ multiple,
76
+ locale,
77
+ env,
78
+ fundingEligibility,
79
+ i,
80
+ nonce,
81
+ flow,
82
+ vault,
83
+ userIDToken,
84
+ personalization,
85
+ onClick = noop,
86
+ content,
87
+ tagline,
88
+ commit,
89
+ experiment,
90
+ instrument,
91
+ experience,
92
+ showPayLabel,
93
+ }: IndividualButtonProps): ElementNode {
94
+ const { custom, layout, shape } = style;
95
+ const inlineExperience =
96
+ experience === EXPERIENCE.INLINE && custom && custom.label;
97
+ const fundingConfig = getFundingConfig()[fundingSource];
98
+
99
+ if (!fundingConfig) {
100
+ throw new Error(`Can not find funding config for ${fundingSource}`);
101
+ }
102
+
103
+ const colors = fundingConfig.colors;
104
+ const secondaryColors = fundingConfig.secondaryColors || {};
105
+
106
+ let { color = colors[0], period, label } = style;
107
+
108
+ if (multiple && i > 0) {
109
+ if (
110
+ secondaryColors[color] &&
111
+ colors.indexOf(secondaryColors[color] !== -1)
112
+ ) {
113
+ color = secondaryColors[color];
114
+ } else if (colors.indexOf(secondaryColors[BUTTON_COLOR.DEFAULT]) !== -1) {
115
+ color = secondaryColors[BUTTON_COLOR.DEFAULT];
116
+ } else {
117
+ color = colors[0];
76
118
  }
119
+ }
77
120
 
78
- const { logoColors, textColors } = fundingConfig;
79
-
80
- const logoColor = logoColors[color] || logoColors[LOGO_COLOR.DEFAULT] || LOGO_COLOR.DEFAULT;
81
- const textColor = textColors[color] || textColors[TEXT_COLOR.DEFAULT] || TEXT_COLOR.DEFAULT;
82
-
83
- const { Label, WalletLabel, Logo, showWalletMenu } = fundingConfig;
84
-
85
- const clickHandler = (event, opts) => {
86
- event.preventDefault();
87
- event.stopPropagation();
88
- onClick(event, { fundingSource, ...opts });
89
- };
121
+ const { logoColors, textColors } = fundingConfig;
90
122
 
91
- const keypressHandler = (event : KeyboardEvent, opts) => {
92
- if (event.keyCode === 13 || event.keyCode === 32) {
93
- clickHandler(event, opts);
94
- }
95
- };
123
+ const logoColor =
124
+ logoColors[color] || logoColors[LOGO_COLOR.DEFAULT] || LOGO_COLOR.DEFAULT;
125
+ const textColor =
126
+ textColors[color] || textColors[TEXT_COLOR.DEFAULT] || TEXT_COLOR.DEFAULT;
96
127
 
97
- const onButtonRender = el => {
98
- if (isBrowser() && isElement(el)) {
99
- preventClickFocus(el);
100
- }
101
- };
128
+ const { Label, WalletLabel, Logo, showWalletMenu } = fundingConfig;
102
129
 
103
- function getAriaLabel() : string {
104
- let labelText = typeof fundingConfig.labelText === 'function' ? fundingConfig.labelText({ content, fundingEligibility }) : (fundingConfig.labelText || fundingSource);
130
+ const clickHandler = (event, opts) => {
131
+ event.preventDefault();
132
+ event.stopPropagation();
133
+ onClick(event, { fundingSource, ...opts });
134
+ };
105
135
 
106
- if (!showPayLabel && instrument?.vendor && instrument.label) {
107
- labelText = instrument.secondaryInstruments ? `${instrument.secondaryInstruments[0].type} & ${instrument.vendor} ${instrument.label}` : `${instrument.vendor} ${instrument.label}`;
108
- }
109
-
110
- return labelText;
136
+ const keypressHandler = (event: KeyboardEvent, opts) => {
137
+ if (event.keyCode === 13 || event.keyCode === 32) {
138
+ clickHandler(event, opts);
111
139
  }
140
+ };
112
141
 
113
- const labelText = getAriaLabel();
114
-
115
- const logoNode = (
116
- <Logo
117
- label={ label }
118
- locale={ locale }
119
- logoColor={ logoColor }
120
- fundingEligibility={ fundingEligibility }
121
- onClick={ clickHandler }
122
- onKeyPress={ keypressHandler }
123
- nonce={ nonce }
124
- experiment={ experiment }
125
- env={ env }
126
- />
127
- );
128
-
129
- let labelNode = (
130
- <Label
131
- i={ i }
132
- logo={ logoNode }
133
- label={ label }
134
- nonce={ nonce }
135
- locale={ locale }
136
- logoColor={ logoColor }
137
- period={ period }
138
- layout={ layout }
139
- multiple={ multiple }
140
- fundingEligibility={ fundingEligibility }
141
- onClick={ clickHandler }
142
- onKeyPress={ keypressHandler }
143
- personalization={ personalization }
144
- tagline={ tagline }
145
- content={ content }
146
- custom={ inlineExperience ? custom : undefined }
147
- experiment={ experiment }
148
- />
149
- );
150
-
151
- // Only apply animation to the paypal button
152
- const buttonDesign = fundingSource === FUNDING.PAYPAL
153
- ? getButtonDesign(personalization)
154
- : {};
155
-
156
- const {
157
- buttonDesignContainerClass = '',
158
- buttonDesignComponent = null
159
- } = buttonDesign;
160
-
161
- if (buttonDesignComponent) {
162
- labelNode = (
163
- <DesignExperimentLabel
164
- i={ i }
165
- logo={ logoNode }
166
- label={ label }
167
- nonce={ nonce }
168
- locale={ locale }
169
- logoColor={ logoColor }
170
- period={ period }
171
- layout={ layout }
172
- multiple={ multiple }
173
- fundingEligibility={ fundingEligibility }
174
- onClick={ clickHandler }
175
- onKeyPress={ keypressHandler }
176
- personalization={ personalization }
177
- tagline={ tagline }
178
- content={ content }
179
- buttonDesignComponent={ buttonDesignComponent }
180
- />
181
- );
142
+ const onButtonRender = (el) => {
143
+ if (isBrowser() && isElement(el)) {
144
+ preventClickFocus(el);
182
145
  }
183
-
184
- let isWallet = false;
185
-
186
- if (
187
- WalletLabel &&
188
- (!showPayLabel || flow === BUTTON_FLOW.PURCHASE) &&
189
- (instrument || (__WEB__ && userIDToken && (fundingSource === FUNDING.PAYPAL || fundingSource === FUNDING.VENMO)))
190
- ) {
191
- labelNode = (
192
- <WalletLabel
193
- nonce={ nonce }
194
- logoColor={ logoColor }
195
- instrument={ instrument }
196
- locale={ locale }
197
- content={ content }
198
- commit={ commit }
199
- experiment={ experiment }
200
- vault={ vault }
201
- textColor={ textColor }
202
- fundingSource={ fundingSource }
203
- showPayLabel={ showPayLabel }
204
- />
205
- );
206
-
207
- isWallet = true;
146
+ };
147
+
148
+ function getAriaLabel(): string {
149
+ let labelText =
150
+ typeof fundingConfig.labelText === "function"
151
+ ? fundingConfig.labelText({ content, fundingEligibility })
152
+ : fundingConfig.labelText || fundingSource;
153
+
154
+ if (!showPayLabel && instrument?.vendor && instrument.label) {
155
+ labelText = instrument.secondaryInstruments
156
+ ? `${instrument.secondaryInstruments[0].type} & ${instrument.vendor} ${instrument.label}`
157
+ : `${instrument.vendor} ${instrument.label}`;
208
158
  }
209
159
 
210
- const shouldShowWalletMenu = isWallet && instrument && showWalletMenu({ instrument, userIDToken });
211
-
212
- return (
213
- <div
214
- class={ [
215
- CLASS.BUTTON_ROW,
216
- inlineExperience && fundingSource === FUNDING.CARD ? CLASS.CUSTOM : '',
217
- `${ CLASS.NUMBER }-${ i }`,
218
- `${ CLASS.LAYOUT }-${ layout }`,
219
- `${ CLASS.SHAPE }-${ shape }`,
220
- `${ CLASS.NUMBER }-${ multiple ? BUTTON_NUMBER.MULTIPLE : BUTTON_NUMBER.SINGLE }`,
221
- `${ CLASS.ENV }-${ env }`,
222
- `${ CLASS.COLOR }-${ color }`,
223
- `${ CLASS.TEXT_COLOR }-${ textColor }`,
224
- `${ LOGO_CLASS.LOGO_COLOR }-${ logoColor }`,
225
- `${ isWallet ? CLASS.WALLET : '' }`,
226
- `${ shouldShowWalletMenu ? CLASS.WALLET_MENU : '' }`,
227
- `${ buttonDesignContainerClass }`
228
- ].join(' ') }
229
- >
230
- <div
231
- role='link'
232
- { ...{
233
- [ ATTRIBUTE.BUTTON ]: true,
234
- [ ATTRIBUTE.FUNDING_SOURCE ]: fundingSource,
235
- [ ATTRIBUTE.PAYMENT_METHOD_ID ]: instrument ? instrument.tokenID : null,
236
- [ ATTRIBUTE.INSTRUMENT_ID ]: instrument ? instrument.instrumentID : null,
237
- [ ATTRIBUTE.INSTRUMENT_TYPE ]: instrument ? instrument.type : null,
238
- [ ATTRIBUTE.SECONDARY_INSTRUMENT_TYPE ]: instrument?.secondaryInstruments ? instrument.secondaryInstruments[0].type : null
239
- } }
240
- class={ [
241
- CLASS.BUTTON,
242
- inlineExperience && fundingSource === FUNDING.CARD ? CLASS.CUSTOM : '',
243
- `${ CLASS.NUMBER }-${ i }`,
244
- `${ CLASS.LAYOUT }-${ layout }`,
245
- `${ CLASS.SHAPE }-${ shape }`,
246
- `${ CLASS.NUMBER }-${ multiple ? BUTTON_NUMBER.MULTIPLE : BUTTON_NUMBER.SINGLE }`,
247
- `${ CLASS.ENV }-${ env }`,
248
- `${ CLASS.COLOR }-${ color }`,
249
- `${ CLASS.TEXT_COLOR }-${ textColor }`,
250
- `${ LOGO_CLASS.LOGO_COLOR }-${ logoColor }`,
251
- `${ isWallet ? CLASS.WALLET : '' }`
252
- ].join(' ') }
253
- onClick={ clickHandler }
254
- onRender={ onButtonRender }
255
- onKeyPress={ keypressHandler }
256
- tabindex='0'
257
- aria-label={ labelText }>
258
-
259
- <div class={ CLASS.BUTTON_LABEL }>
260
- { labelNode }
261
- </div>
262
-
263
- <Spinner />
264
- </div>
265
-
266
- { shouldShowWalletMenu ? <MenuButton textColor={ textColor } content={ content } /> : null }
267
- </div>
160
+ return labelText;
161
+ }
162
+
163
+ const labelText = getAriaLabel();
164
+
165
+ const logoNode = (
166
+ <Logo
167
+ label={label}
168
+ locale={locale}
169
+ logoColor={logoColor}
170
+ fundingEligibility={fundingEligibility}
171
+ onClick={clickHandler}
172
+ onKeyPress={keypressHandler}
173
+ nonce={nonce}
174
+ experiment={experiment}
175
+ env={env}
176
+ />
177
+ );
178
+
179
+ let labelNode = (
180
+ <Label
181
+ i={i}
182
+ logo={logoNode}
183
+ label={label}
184
+ nonce={nonce}
185
+ locale={locale}
186
+ logoColor={logoColor}
187
+ period={period}
188
+ layout={layout}
189
+ multiple={multiple}
190
+ fundingEligibility={fundingEligibility}
191
+ onClick={clickHandler}
192
+ onKeyPress={keypressHandler}
193
+ personalization={personalization}
194
+ tagline={tagline}
195
+ content={content}
196
+ custom={inlineExperience ? custom : undefined}
197
+ experiment={experiment}
198
+ />
199
+ );
200
+
201
+ // Only apply animation to the paypal button
202
+ const buttonDesign =
203
+ fundingSource === FUNDING.PAYPAL ? getButtonDesign(personalization) : {};
204
+
205
+ const { buttonDesignContainerClass = "", buttonDesignComponent = null } =
206
+ buttonDesign;
207
+
208
+ if (buttonDesignComponent) {
209
+ labelNode = (
210
+ <DesignExperimentLabel
211
+ i={i}
212
+ logo={logoNode}
213
+ label={label}
214
+ nonce={nonce}
215
+ locale={locale}
216
+ logoColor={logoColor}
217
+ period={period}
218
+ layout={layout}
219
+ multiple={multiple}
220
+ fundingEligibility={fundingEligibility}
221
+ onClick={clickHandler}
222
+ onKeyPress={keypressHandler}
223
+ personalization={personalization}
224
+ tagline={tagline}
225
+ content={content}
226
+ buttonDesignComponent={buttonDesignComponent}
227
+ />
228
+ );
229
+ }
230
+
231
+ let isWallet = false;
232
+
233
+ if (
234
+ WalletLabel &&
235
+ (!showPayLabel || flow === BUTTON_FLOW.PURCHASE) &&
236
+ (instrument ||
237
+ (__WEB__ &&
238
+ userIDToken &&
239
+ (fundingSource === FUNDING.PAYPAL || fundingSource === FUNDING.VENMO)))
240
+ ) {
241
+ labelNode = (
242
+ <WalletLabel
243
+ nonce={nonce}
244
+ logoColor={logoColor}
245
+ instrument={instrument}
246
+ locale={locale}
247
+ content={content}
248
+ commit={commit}
249
+ experiment={experiment}
250
+ vault={vault}
251
+ textColor={textColor}
252
+ fundingSource={fundingSource}
253
+ showPayLabel={showPayLabel}
254
+ />
268
255
  );
256
+
257
+ isWallet = true;
258
+ }
259
+
260
+ const shouldShowWalletMenu =
261
+ isWallet && instrument && showWalletMenu({ instrument, userIDToken });
262
+
263
+ return (
264
+ <div
265
+ class={[
266
+ CLASS.BUTTON_ROW,
267
+ inlineExperience && fundingSource === FUNDING.CARD ? CLASS.CUSTOM : "",
268
+ `${CLASS.NUMBER}-${i}`,
269
+ `${CLASS.LAYOUT}-${layout}`,
270
+ `${CLASS.SHAPE}-${shape}`,
271
+ `${CLASS.NUMBER}-${
272
+ multiple ? BUTTON_NUMBER.MULTIPLE : BUTTON_NUMBER.SINGLE
273
+ }`,
274
+ `${CLASS.ENV}-${env}`,
275
+ `${CLASS.COLOR}-${color}`,
276
+ `${CLASS.TEXT_COLOR}-${textColor}`,
277
+ `${LOGO_CLASS.LOGO_COLOR}-${logoColor}`,
278
+ `${isWallet ? CLASS.WALLET : ""}`,
279
+ `${shouldShowWalletMenu ? CLASS.WALLET_MENU : ""}`,
280
+ `${buttonDesignContainerClass}`,
281
+ ].join(" ")}
282
+ >
283
+ <div
284
+ role="link"
285
+ {...{
286
+ [ATTRIBUTE.BUTTON]: true,
287
+ [ATTRIBUTE.FUNDING_SOURCE]: fundingSource,
288
+ [ATTRIBUTE.PAYMENT_METHOD_ID]: instrument ? instrument.tokenID : null,
289
+ [ATTRIBUTE.INSTRUMENT_ID]: instrument
290
+ ? instrument.instrumentID
291
+ : null,
292
+ [ATTRIBUTE.INSTRUMENT_TYPE]: instrument ? instrument.type : null,
293
+ [ATTRIBUTE.SECONDARY_INSTRUMENT_TYPE]:
294
+ instrument?.secondaryInstruments
295
+ ? instrument.secondaryInstruments[0].type
296
+ : null,
297
+ }}
298
+ class={[
299
+ CLASS.BUTTON,
300
+ inlineExperience && fundingSource === FUNDING.CARD
301
+ ? CLASS.CUSTOM
302
+ : "",
303
+ `${CLASS.NUMBER}-${i}`,
304
+ `${CLASS.LAYOUT}-${layout}`,
305
+ `${CLASS.SHAPE}-${shape}`,
306
+ `${CLASS.NUMBER}-${
307
+ multiple ? BUTTON_NUMBER.MULTIPLE : BUTTON_NUMBER.SINGLE
308
+ }`,
309
+ `${CLASS.ENV}-${env}`,
310
+ `${CLASS.COLOR}-${color}`,
311
+ `${CLASS.TEXT_COLOR}-${textColor}`,
312
+ `${LOGO_CLASS.LOGO_COLOR}-${logoColor}`,
313
+ `${isWallet ? CLASS.WALLET : ""}`,
314
+ ].join(" ")}
315
+ onClick={clickHandler}
316
+ onRender={onButtonRender}
317
+ onKeyPress={keypressHandler}
318
+ tabindex="0"
319
+ aria-label={labelText}
320
+ >
321
+ <div class={CLASS.BUTTON_LABEL}>{labelNode}</div>
322
+
323
+ <Spinner />
324
+ </div>
325
+
326
+ {shouldShowWalletMenu ? (
327
+ <MenuButton textColor={textColor} content={content} />
328
+ ) : null}
329
+ </div>
330
+ );
269
331
  }
@@ -1,9 +1,7 @@
1
1
  /* @flow */
2
2
  /** @jsx node */
3
- import { node, type ChildType } from '@krakenjs/jsx-pragmatic/src';
3
+ import { node, type ChildType } from "@krakenjs/jsx-pragmatic/src";
4
4
 
5
- export function ControlDesignComponent(experimentId : string) : ChildType {
6
- return (
7
- <div data-design-experiment={ experimentId } />
8
- );
5
+ export function ControlDesignComponent(experimentId: string): ChildType {
6
+ return <div data-design-experiment={experimentId} />;
9
7
  }