@paypal/checkout-components 5.0.205 → 5.0.206
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/CHANGELOG.md +7 -0
- package/dist/button.js +1 -1
- package/package.json +1 -1
- package/src/constants/button.js +4 -0
- package/src/ui/buttons/button.jsx +7 -5
- package/src/ui/buttons/buttons.jsx +24 -6
- package/src/ui/buttons/props.js +5 -5
- package/src/ui/buttons/styles/custom.js +12 -1
- package/src/zoid/buttons/component.jsx +6 -3
package/package.json
CHANGED
package/src/constants/button.js
CHANGED
|
@@ -8,7 +8,7 @@ import { LOGO_COLOR, LOGO_CLASS } from '@paypal/sdk-logos/src';
|
|
|
8
8
|
import { noop, preventClickFocus, isBrowser, isElement } from 'belter/src';
|
|
9
9
|
|
|
10
10
|
import type { ContentType, Wallet, Experiment, WalletInstrument } from '../../types';
|
|
11
|
-
import { ATTRIBUTE, CLASS, BUTTON_COLOR, BUTTON_NUMBER, TEXT_COLOR, BUTTON_FLOW } from '../../constants';
|
|
11
|
+
import { ATTRIBUTE, CLASS, BUTTON_COLOR, BUTTON_NUMBER, EXPERIENCE, TEXT_COLOR, BUTTON_FLOW } from '../../constants';
|
|
12
12
|
import { getFundingConfig } from '../../funding';
|
|
13
13
|
import { DesignExperimentLabel } from '../../funding/paypal/template';
|
|
14
14
|
|
|
@@ -39,12 +39,13 @@ type IndividualButtonProps = {|
|
|
|
39
39
|
vault : boolean,
|
|
40
40
|
merchantFundingSource : ?$Values<typeof FUNDING>,
|
|
41
41
|
instrument : ?WalletInstrument,
|
|
42
|
-
|
|
42
|
+
experience? : string
|
|
43
43
|
|};
|
|
44
44
|
|
|
45
45
|
export function Button({ fundingSource, style, multiple, locale, env, fundingEligibility, i, nonce, flow, vault,
|
|
46
|
-
userIDToken, personalization, onClick = noop, content, tagline, commit, experiment, instrument,
|
|
46
|
+
userIDToken, personalization, onClick = noop, content, tagline, commit, experiment, instrument, experience } : IndividualButtonProps) : ElementNode {
|
|
47
47
|
|
|
48
|
+
const inlineExperience = experience === EXPERIENCE.INLINE;
|
|
48
49
|
const fundingConfig = getFundingConfig()[fundingSource];
|
|
49
50
|
|
|
50
51
|
if (!fundingConfig) {
|
|
@@ -130,7 +131,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
130
131
|
personalization={ personalization }
|
|
131
132
|
tagline={ tagline }
|
|
132
133
|
content={ content }
|
|
133
|
-
custom={
|
|
134
|
+
custom={ inlineExperience ? custom : null }
|
|
134
135
|
experiment={ experiment }
|
|
135
136
|
/>
|
|
136
137
|
);
|
|
@@ -199,6 +200,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
199
200
|
<div
|
|
200
201
|
class={ [
|
|
201
202
|
CLASS.BUTTON_ROW,
|
|
203
|
+
inlineExperience && fundingSource === FUNDING.CARD ? CLASS.CUSTOM : '',
|
|
202
204
|
`${ CLASS.NUMBER }-${ i }`,
|
|
203
205
|
`${ CLASS.LAYOUT }-${ layout }`,
|
|
204
206
|
`${ CLASS.SHAPE }-${ shape }`,
|
|
@@ -223,7 +225,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
223
225
|
} }
|
|
224
226
|
class={ [
|
|
225
227
|
CLASS.BUTTON,
|
|
226
|
-
|
|
228
|
+
inlineExperience && fundingSource === FUNDING.CARD ? CLASS.CUSTOM : '',
|
|
227
229
|
`${ CLASS.NUMBER }-${ i }`,
|
|
228
230
|
`${ CLASS.LAYOUT }-${ layout }`,
|
|
229
231
|
`${ CLASS.SHAPE }-${ shape }`,
|
|
@@ -6,7 +6,7 @@ import { FUNDING, WALLET_INSTRUMENT } from '@paypal/sdk-constants/src';
|
|
|
6
6
|
import { noop } from 'belter/src';
|
|
7
7
|
|
|
8
8
|
import type { Wallet, WalletInstrument } from '../../types';
|
|
9
|
-
import { CLASS, BUTTON_NUMBER, BUTTON_LAYOUT, BUTTON_FLOW } from '../../constants';
|
|
9
|
+
import { CLASS, BUTTON_NUMBER, BUTTON_LAYOUT, BUTTON_FLOW, EXPERIENCE } from '../../constants';
|
|
10
10
|
import { determineEligibleFunding, isWalletFundingEligible } from '../../funding';
|
|
11
11
|
import { ValidationError } from '../../lib';
|
|
12
12
|
|
|
@@ -97,10 +97,12 @@ export function validateButtonProps(props : ButtonPropsInputs) {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
export function Buttons(props : ButtonsProps) : ElementNode {
|
|
100
|
-
const { onClick = noop
|
|
100
|
+
const { onClick = noop } = props;
|
|
101
101
|
const { wallet, fundingSource, style, locale, remembered, env, fundingEligibility, platform, commit, vault,
|
|
102
|
-
nonce, components, onShippingChange, personalization, userIDToken, content, flow, experiment, applePaySupport,
|
|
102
|
+
nonce, components, onShippingChange, personalization, userIDToken, content, flow, experiment, applePaySupport,
|
|
103
|
+
supportsPopups, supportedNativeBrowser, experience } = normalizeButtonProps(props);
|
|
103
104
|
const { layout, shape, tagline } = style;
|
|
105
|
+
const inlineExperience = experience === EXPERIENCE.INLINE;
|
|
104
106
|
|
|
105
107
|
let fundingSources = determineEligibleFunding({ fundingSource, layout, remembered, platform, fundingEligibility, components, onShippingChange, flow, wallet, applePaySupport, supportsPopups, supportedNativeBrowser, experiment });
|
|
106
108
|
const multiple = fundingSources.length > 1;
|
|
@@ -110,7 +112,11 @@ export function Buttons(props : ButtonsProps) : ElementNode {
|
|
|
110
112
|
}
|
|
111
113
|
|
|
112
114
|
if (fundingSources.indexOf(FUNDING.CARD) !== -1) {
|
|
113
|
-
|
|
115
|
+
if (inlineExperience) {
|
|
116
|
+
fundingSources = [ FUNDING.CARD, ...fundingSources.filter(src => src !== FUNDING.CARD) ];
|
|
117
|
+
} else {
|
|
118
|
+
fundingSources = [ ...fundingSources.filter(src => src !== FUNDING.CARD), FUNDING.CARD ];
|
|
119
|
+
}
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
const instruments = getWalletInstruments({ wallet, fundingSources, layout, onShippingChange });
|
|
@@ -121,6 +127,18 @@ export function Buttons(props : ButtonsProps) : ElementNode {
|
|
|
121
127
|
);
|
|
122
128
|
|
|
123
129
|
const { buttonDesignScript = '' } = getButtonDesign(personalization);
|
|
130
|
+
const index = (i) => {
|
|
131
|
+
if (!inlineExperience) {
|
|
132
|
+
return i;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// InlineXO: Need to change color indexing because we bring Cards to the top
|
|
136
|
+
if (i === 0) {
|
|
137
|
+
return fundingSources.length - 1;
|
|
138
|
+
} else {
|
|
139
|
+
return i - 1;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
124
142
|
|
|
125
143
|
return (
|
|
126
144
|
<div class={ [
|
|
@@ -142,7 +160,7 @@ export function Buttons(props : ButtonsProps) : ElementNode {
|
|
|
142
160
|
fundingSources.map((source, i) => (
|
|
143
161
|
<Button
|
|
144
162
|
content={ content }
|
|
145
|
-
i={ i }
|
|
163
|
+
i={ index(i) }
|
|
146
164
|
style={ style }
|
|
147
165
|
merchantFundingSource={ fundingSource }
|
|
148
166
|
fundingSource={ source }
|
|
@@ -162,7 +180,7 @@ export function Buttons(props : ButtonsProps) : ElementNode {
|
|
|
162
180
|
flow={ flow }
|
|
163
181
|
vault={ vault }
|
|
164
182
|
instrument={ instruments[source] }
|
|
165
|
-
|
|
183
|
+
experience={ experience }
|
|
166
184
|
/>
|
|
167
185
|
))
|
|
168
186
|
}
|
package/src/ui/buttons/props.js
CHANGED
|
@@ -264,7 +264,7 @@ export type RenderButtonProps = {|
|
|
|
264
264
|
applePaySupport : boolean,
|
|
265
265
|
supportsPopups : boolean,
|
|
266
266
|
supportedNativeBrowser : boolean,
|
|
267
|
-
|
|
267
|
+
experience : string
|
|
268
268
|
|};
|
|
269
269
|
|
|
270
270
|
export type PrerenderDetails = {|
|
|
@@ -313,7 +313,7 @@ export type ButtonProps = {|
|
|
|
313
313
|
applePay : ApplePaySessionConfigRequest,
|
|
314
314
|
meta : {||},
|
|
315
315
|
renderedButtons : $ReadOnlyArray<$Values<typeof FUNDING>>,
|
|
316
|
-
|
|
316
|
+
experience : string
|
|
317
317
|
|};
|
|
318
318
|
|
|
319
319
|
// eslint-disable-next-line flowtype/require-exact-type
|
|
@@ -351,7 +351,7 @@ export type ButtonPropsInputs = {
|
|
|
351
351
|
applePaySupport : boolean,
|
|
352
352
|
supportsPopups : boolean,
|
|
353
353
|
supportedNativeBrowser : boolean,
|
|
354
|
-
|
|
354
|
+
experience : string
|
|
355
355
|
};
|
|
356
356
|
|
|
357
357
|
export const DEFAULT_STYLE = {
|
|
@@ -497,7 +497,7 @@ export function normalizeButtonProps(props : ?ButtonPropsInputs) : RenderButtonP
|
|
|
497
497
|
applePaySupport = false,
|
|
498
498
|
supportsPopups = false,
|
|
499
499
|
supportedNativeBrowser = false,
|
|
500
|
-
|
|
500
|
+
experience = ''
|
|
501
501
|
} = props;
|
|
502
502
|
|
|
503
503
|
const { country, lang } = locale;
|
|
@@ -540,5 +540,5 @@ export function normalizeButtonProps(props : ?ButtonPropsInputs) : RenderButtonP
|
|
|
540
540
|
|
|
541
541
|
return { clientID, fundingSource, style, locale, remembered, env, fundingEligibility, platform, clientAccessToken,
|
|
542
542
|
buttonSessionID, commit, sessionID, nonce, components, onShippingChange, personalization, content, wallet, flow,
|
|
543
|
-
experiment, vault, userIDToken, applePay, applePaySupport, supportsPopups, supportedNativeBrowser,
|
|
543
|
+
experiment, vault, userIDToken, applePay, applePaySupport, supportsPopups, supportedNativeBrowser, experience };
|
|
544
544
|
}
|
|
@@ -10,11 +10,22 @@ export const customStyle = ({ custom } : {| custom? : CustomStyle |}) : string =
|
|
|
10
10
|
|
|
11
11
|
const { css } = custom || {};
|
|
12
12
|
|
|
13
|
+
let heightStyle = '';
|
|
14
|
+
let marginStyle = '';
|
|
13
15
|
let style = Object.keys(css).reduce((acc, key) => {
|
|
16
|
+
if (key === 'height') {
|
|
17
|
+
heightStyle = `
|
|
18
|
+
height: ${ css[key] };
|
|
19
|
+
max-height: ${ css[key] };
|
|
20
|
+
`;
|
|
21
|
+
} else if (key.indexOf('margin') !== -1) {
|
|
22
|
+
marginStyle = `${ key }: ${ css[key] };`;
|
|
23
|
+
}
|
|
24
|
+
|
|
14
25
|
acc += `${ key }: ${ css[key] };`;
|
|
15
26
|
return acc;
|
|
16
27
|
}, '');
|
|
17
|
-
style = `.${ CLASS.BUTTON }.${ CLASS.CUSTOM } { ${ style } } `;
|
|
28
|
+
style = `.${ CLASS.BUTTON }.${ CLASS.CUSTOM } { ${ style } } .${ CLASS.BUTTON_ROW }.${ CLASS.CUSTOM } { ${ heightStyle + marginStyle }}`;
|
|
18
29
|
|
|
19
30
|
return style;
|
|
20
31
|
};
|
|
@@ -16,6 +16,7 @@ import { node, dom } from 'jsx-pragmatic/src';
|
|
|
16
16
|
import { getSessionID, storageState, sessionState } from '../../lib';
|
|
17
17
|
import { normalizeButtonStyle, type ButtonProps } from '../../ui/buttons/props';
|
|
18
18
|
import { isFundingEligible } from '../../funding';
|
|
19
|
+
import { EXPERIENCE } from '../../constants';
|
|
19
20
|
|
|
20
21
|
import { containerTemplate } from './container';
|
|
21
22
|
import { PrerenderedButtons } from './prerender';
|
|
@@ -597,13 +598,15 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
|
|
|
597
598
|
value: applePaySession
|
|
598
599
|
},
|
|
599
600
|
|
|
600
|
-
|
|
601
|
+
experience: {
|
|
601
602
|
queryParam: true,
|
|
602
603
|
required: false,
|
|
603
|
-
type: '
|
|
604
|
+
type: 'string',
|
|
604
605
|
value: ({ props }) => {
|
|
605
606
|
const { style: { custom }, fundingEligibility } = props;
|
|
606
|
-
|
|
607
|
+
const isInlineXO = (custom && (custom.label || custom.css)) && fundingEligibility[FUNDING.CARD]?.eligible;
|
|
608
|
+
|
|
609
|
+
return isInlineXO ? EXPERIENCE.INLINE : '';
|
|
607
610
|
}
|
|
608
611
|
},
|
|
609
612
|
|