@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.
- package/README.md +8 -0
- package/__sdk__.js +72 -76
- package/dist/button.js +1 -1
- package/globals.js +28 -30
- package/package.json +6 -4
- package/src/constants/button.js +37 -36
- package/src/constants/class.js +32 -30
- package/src/constants/index.js +3 -3
- package/src/constants/misc.js +14 -12
- package/src/declarations.js +19 -19
- package/src/funding/applepay/config.jsx +51 -50
- package/src/funding/applepay/index.js +1 -1
- package/src/funding/applepay/style.scoped.scss +1 -1
- package/src/funding/applepay/template.jsx +16 -11
- package/src/funding/bancontact/config.jsx +48 -37
- package/src/funding/bancontact/index.js +1 -2
- package/src/funding/blik/config.jsx +48 -37
- package/src/funding/blik/index.js +1 -2
- package/src/funding/boleto/config.jsx +50 -39
- package/src/funding/boleto/index.js +1 -2
- package/src/funding/card/amex/config.js +9 -8
- package/src/funding/card/amex/index.js +1 -2
- package/src/funding/card/config.jsx +246 -177
- package/src/funding/card/discover/config.js +9 -7
- package/src/funding/card/discover/index.js +1 -2
- package/src/funding/card/elo/config.js +6 -7
- package/src/funding/card/elo/index.js +1 -2
- package/src/funding/card/hiper/config.js +9 -7
- package/src/funding/card/hiper/index.js +1 -2
- package/src/funding/card/index.js +1 -1
- package/src/funding/card/jcb/config.js +6 -7
- package/src/funding/card/jcb/index.js +1 -2
- package/src/funding/card/mastercard/config.js +9 -7
- package/src/funding/card/mastercard/index.js +1 -2
- package/src/funding/card/visa/config.js +9 -7
- package/src/funding/card/visa/index.js +1 -2
- package/src/funding/common.jsx +242 -216
- package/src/funding/config.js +212 -65
- package/src/funding/content.jsx +1946 -337
- package/src/funding/credit/config.jsx +74 -57
- package/src/funding/credit/index.js +1 -2
- package/src/funding/eps/config.jsx +45 -37
- package/src/funding/eps/index.js +1 -2
- package/src/funding/funding.js +193 -100
- package/src/funding/giropay/config.jsx +48 -38
- package/src/funding/giropay/index.js +1 -2
- package/src/funding/ideal/config.jsx +48 -37
- package/src/funding/ideal/index.js +1 -2
- package/src/funding/index.js +2 -2
- package/src/funding/itau/config.jsx +41 -41
- package/src/funding/itau/index.js +1 -1
- package/src/funding/maxima/config.jsx +25 -19
- package/src/funding/maxima/index.js +1 -2
- package/src/funding/mercadopago/config.jsx +48 -37
- package/src/funding/mercadopago/index.js +1 -2
- package/src/funding/multibanco/config.jsx +50 -39
- package/src/funding/multibanco/index.js +1 -2
- package/src/funding/mybank/config.jsx +48 -37
- package/src/funding/mybank/index.js +1 -2
- package/src/funding/oxxo/config.jsx +50 -39
- package/src/funding/oxxo/index.js +1 -2
- package/src/funding/p24/config.jsx +45 -37
- package/src/funding/p24/index.js +1 -2
- package/src/funding/paidy/config.jsx +50 -39
- package/src/funding/paidy/index.js +1 -1
- package/src/funding/paylater/config.jsx +118 -111
- package/src/funding/paylater/index.js +1 -2
- package/src/funding/paypal/config.jsx +44 -46
- package/src/funding/paypal/index.js +1 -2
- package/src/funding/paypal/style.scoped.scss +80 -74
- package/src/funding/paypal/template.jsx +450 -354
- package/src/funding/payu/config.jsx +50 -39
- package/src/funding/payu/index.js +1 -1
- package/src/funding/satispay/config.jsx +50 -39
- package/src/funding/satispay/index.js +1 -1
- package/src/funding/sepa/config.jsx +19 -13
- package/src/funding/sepa/index.js +1 -2
- package/src/funding/sofort/config.jsx +48 -37
- package/src/funding/sofort/index.js +1 -2
- package/src/funding/trustly/config.jsx +50 -39
- package/src/funding/trustly/index.js +1 -2
- package/src/funding/venmo/config.jsx +80 -75
- package/src/funding/venmo/index.js +1 -2
- package/src/funding/venmo/style.scoped.scss +30 -32
- package/src/funding/venmo/template.jsx +56 -57
- package/src/funding/verkkopankki/config.jsx +50 -39
- package/src/funding/verkkopankki/index.js +1 -1
- package/src/funding/wechatpay/config.jsx +48 -37
- package/src/funding/wechatpay/index.js +1 -2
- package/src/funding/zimpler/config.jsx +19 -13
- package/src/funding/zimpler/index.js +1 -2
- package/src/interface/button.js +60 -44
- package/src/interface/card-fields.js +11 -8
- package/src/interface/fields.js +7 -4
- package/src/interface/marks.js +4 -4
- package/src/interface/payment-fields.js +7 -4
- package/src/interface/wallet.js +4 -4
- package/src/lib/errors.js +7 -7
- package/src/lib/index.js +5 -5
- package/src/lib/isRTLLanguage.js +3 -3
- package/src/lib/perceived-latency-instrumentation.js +54 -36
- package/src/lib/security.js +21 -17
- package/src/lib/session.js +39 -35
- package/src/marks/component.jsx +114 -65
- package/src/marks/index.js +1 -2
- package/src/marks/template.jsx +79 -65
- package/src/types.js +48 -48
- package/src/ui/buttons/button.jsx +311 -249
- package/src/ui/buttons/buttonDesigns/control.jsx +3 -5
- package/src/ui/buttons/buttonDesigns/divideLogoAnimation.jsx +127 -99
- package/src/ui/buttons/buttonDesigns/index.js +78 -75
- package/src/ui/buttons/buttonDesigns/inlineLogoTextDesign.jsx +102 -82
- package/src/ui/buttons/buttonDesigns/script.jsx +24 -18
- package/src/ui/buttons/buttonDesigns/types.js +6 -7
- package/src/ui/buttons/buttons.jsx +318 -212
- package/src/ui/buttons/config.js +62 -59
- package/src/ui/buttons/content.jsx +304 -119
- package/src/ui/buttons/index.js +1 -1
- package/src/ui/buttons/menu-button/index.js +1 -1
- package/src/ui/buttons/menu-button/menu-button.jsx +29 -22
- package/src/ui/buttons/menu-button/menu-button.scoped.scss +16 -17
- package/src/ui/buttons/poweredBy.jsx +23 -23
- package/src/ui/buttons/props.js +680 -529
- package/src/ui/buttons/script.jsx +182 -160
- package/src/ui/buttons/spinner.jsx +4 -6
- package/src/ui/buttons/style.jsx +15 -14
- package/src/ui/buttons/styles/base.js +24 -16
- package/src/ui/buttons/styles/button.js +24 -22
- package/src/ui/buttons/styles/color.js +118 -118
- package/src/ui/buttons/styles/custom.js +30 -24
- package/src/ui/buttons/styles/index.js +1 -1
- package/src/ui/buttons/styles/labels.js +17 -13
- package/src/ui/buttons/styles/page.js +3 -3
- package/src/ui/buttons/styles/responsive.js +226 -118
- package/src/ui/buttons/tagline.jsx +53 -54
- package/src/ui/chevron.jsx +27 -16
- package/src/ui/index.js +3 -3
- package/src/ui/loading.jsx +25 -18
- package/src/ui/text/index.js +1 -1
- package/src/ui/text/style.scoped.scss +25 -26
- package/src/ui/text/text.jsx +42 -20
- package/src/ui/tracking.jsx +18 -11
- package/src/zoid/buttons/component.jsx +836 -684
- package/src/zoid/buttons/container.jsx +140 -107
- package/src/zoid/buttons/index.js +1 -1
- package/src/zoid/buttons/prerender.jsx +84 -64
- package/src/zoid/buttons/util.js +355 -254
- package/src/zoid/card-fields/component.jsx +581 -549
- package/src/zoid/card-fields/index.js +1 -1
- package/src/zoid/card-fields/prerender.jsx +20 -17
- package/src/zoid/card-form/component.js +155 -141
- package/src/zoid/card-form/index.js +1 -1
- package/src/zoid/checkout/component.jsx +314 -282
- package/src/zoid/checkout/config.js +2 -2
- package/src/zoid/checkout/content.js +190 -154
- package/src/zoid/checkout/hacks.js +31 -28
- package/src/zoid/checkout/index.js +2 -2
- package/src/zoid/checkout/props.js +27 -33
- package/src/zoid/installments/component.jsx +83 -70
- package/src/zoid/installments/index.js +1 -1
- package/src/zoid/installments/props.js +1 -1
- package/src/zoid/menu/component.jsx +53 -48
- package/src/zoid/menu/index.js +1 -1
- package/src/zoid/menu/props.js +1 -3
- package/src/zoid/modal/component.jsx +119 -106
- package/src/zoid/modal/index.js +1 -1
- package/src/zoid/modal/props.js +1 -3
- package/src/zoid/payment-fields/component.jsx +215 -191
- package/src/zoid/payment-fields/container.jsx +73 -64
- package/src/zoid/payment-fields/index.js +1 -1
- package/src/zoid/payment-fields/prerender.jsx +16 -14
- package/src/zoid/payment-fields/props.js +6 -6
- package/src/zoid/qr-code/component.jsx +131 -115
- package/src/zoid/qr-code/container.jsx +74 -68
- package/src/zoid/qr-code/index.js +1 -1
- package/src/zoid/qr-code/prerender.jsx +17 -12
- package/src/zoid/qr-code/types.js +2 -2
- package/src/zoid/wallet/component.jsx +298 -260
- package/src/zoid/wallet/container.jsx +73 -64
- package/src/zoid/wallet/index.js +1 -1
- package/src/zoid/wallet/prerender.jsx +14 -14
- package/src/zoid/wallet/props.js +4 -4
- package/src/actions/save/index.js +0 -40
- package/src/interface/actions.js +0 -14
- 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
|
|
5
|
-
import { FUNDING, ENV, type LocaleType } from
|
|
6
|
-
import { node, type ElementNode } from
|
|
7
|
-
import { LOGO_COLOR, LOGO_CLASS } from
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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({
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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
|
-
|
|
98
|
-
if (isBrowser() && isElement(el)) {
|
|
99
|
-
preventClickFocus(el);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
128
|
+
const { Label, WalletLabel, Logo, showWalletMenu } = fundingConfig;
|
|
102
129
|
|
|
103
|
-
|
|
104
|
-
|
|
130
|
+
const clickHandler = (event, opts) => {
|
|
131
|
+
event.preventDefault();
|
|
132
|
+
event.stopPropagation();
|
|
133
|
+
onClick(event, { fundingSource, ...opts });
|
|
134
|
+
};
|
|
105
135
|
|
|
106
|
-
|
|
107
|
-
|
|
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
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
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
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
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
|
|
3
|
+
import { node, type ChildType } from "@krakenjs/jsx-pragmatic/src";
|
|
4
4
|
|
|
5
|
-
export function ControlDesignComponent(experimentId
|
|
6
|
-
|
|
7
|
-
<div data-design-experiment={ experimentId } />
|
|
8
|
-
);
|
|
5
|
+
export function ControlDesignComponent(experimentId: string): ChildType {
|
|
6
|
+
return <div data-design-experiment={experimentId} />;
|
|
9
7
|
}
|