@paypal/checkout-components 5.0.241-kitty → 5.0.242
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/dist/button.js +1 -1
- package/package.json +2 -2
- package/src/constants/misc.js +10 -11
- package/src/funding/common.jsx +1 -2
- package/src/funding/paypal/style.scoped.scss +0 -8
- package/src/funding/paypal/template.jsx +26 -98
- package/src/types.js +2 -10
- package/src/ui/buttons/button.jsx +8 -11
- package/src/ui/buttons/buttons.jsx +1 -2
- package/src/ui/buttons/props.js +5 -7
- package/src/zoid/buttons/component.jsx +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paypal/checkout-components",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.242",
|
|
4
4
|
"description": "PayPal Checkout components, for integrating checkout products.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"@paypal/common-components": "^1.0.33",
|
|
95
95
|
"@paypal/funding-components": "^1.0.27",
|
|
96
96
|
"@paypal/sdk-client": "^4.0.166",
|
|
97
|
-
"@paypal/sdk-constants": "1.0.
|
|
97
|
+
"@paypal/sdk-constants": "^1.0.123",
|
|
98
98
|
"@paypal/sdk-logos": "^2.0.0"
|
|
99
99
|
},
|
|
100
100
|
"lint-staged": {
|
package/src/constants/misc.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
|
|
3
3
|
export const ATTRIBUTE = {
|
|
4
|
-
BUTTON:
|
|
5
|
-
FUNDING_SOURCE:
|
|
6
|
-
PAYMENT_METHOD_ID:
|
|
7
|
-
INSTRUMENT_ID:
|
|
8
|
-
INSTRUMENT_TYPE:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
PAY_NOW: ('data-pay-now' : 'data-pay-now')
|
|
4
|
+
BUTTON: ('data-button' : 'data-button'),
|
|
5
|
+
FUNDING_SOURCE: ('data-funding-source' : 'data-funding-source'),
|
|
6
|
+
PAYMENT_METHOD_ID: ('data-payment-method-id' : 'data-payment-method-id'),
|
|
7
|
+
INSTRUMENT_ID: ('data-instrument-id' : 'data-instrument-id'),
|
|
8
|
+
INSTRUMENT_TYPE: ('data-instrument-type' : 'data-instrument-type'),
|
|
9
|
+
VERSION: ('data-paypal-smart-button-version' : 'data-paypal-smart-button-version'),
|
|
10
|
+
CARD: ('data-card' : 'data-card'),
|
|
11
|
+
MENU: ('data-menu' : 'data-menu'),
|
|
12
|
+
OPTIONAL: ('optional' : 'optional'),
|
|
13
|
+
PAY_NOW: ('data-pay-now' : 'data-pay-now')
|
|
15
14
|
};
|
|
16
15
|
|
|
17
16
|
export const DEFAULT = ('default' : 'default');
|
package/src/funding/common.jsx
CHANGED
|
@@ -81,8 +81,7 @@ export type WalletLabelOptions = {|
|
|
|
81
81
|
vault : boolean,
|
|
82
82
|
nonce? : ?string,
|
|
83
83
|
textColor : $Values<typeof TEXT_COLOR>,
|
|
84
|
-
fundingSource : $Values<typeof FUNDING
|
|
85
|
-
showPayLabel : boolean
|
|
84
|
+
fundingSource : $Values<typeof FUNDING>
|
|
86
85
|
|};
|
|
87
86
|
|
|
88
87
|
export type TagOptions = {|
|
|
@@ -234,87 +234,8 @@ export function WalletLabelOld(opts : WalletLabelOptions) : ?ChildType {
|
|
|
234
234
|
);
|
|
235
235
|
}
|
|
236
236
|
|
|
237
|
-
function ShowPayLabel(opts) : ?ChildType {
|
|
238
|
-
const {instrument, content, payNow, textColor, logo, label } = opts;
|
|
239
|
-
|
|
240
|
-
return (
|
|
241
|
-
<div class='show-pay-label'>
|
|
242
|
-
<div class='pay-label' optional={ 2 }>
|
|
243
|
-
<Space />
|
|
244
|
-
{
|
|
245
|
-
(instrument && content)
|
|
246
|
-
? <Text>{ payNow ? content.payNow : content.payWith }</Text>
|
|
247
|
-
: <Text><PlaceHolder chars={ 7 } color={ textColor } /></Text>
|
|
248
|
-
}
|
|
249
|
-
<Space />
|
|
250
|
-
</div>
|
|
251
|
-
<div class='logo' optional={ 1 }>
|
|
252
|
-
{
|
|
253
|
-
(instrument && logo)
|
|
254
|
-
? logo
|
|
255
|
-
: <Text><PlaceHolder chars={ 4 } color={ textColor } /></Text>
|
|
256
|
-
}
|
|
257
|
-
</div>
|
|
258
|
-
<div class='label'>
|
|
259
|
-
<Space />
|
|
260
|
-
{
|
|
261
|
-
(instrument && label)
|
|
262
|
-
? <Text>{ label }</Text>
|
|
263
|
-
: <Text><PlaceHolder chars={ 6 } color={ textColor } /></Text>
|
|
264
|
-
}
|
|
265
|
-
</div>
|
|
266
|
-
</div>
|
|
267
|
-
);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function NoPayLabel(opts) : ?ChildType {
|
|
271
|
-
const { instrument, textColor, logo, label, content } = opts;
|
|
272
|
-
|
|
273
|
-
return (
|
|
274
|
-
<div class='no-pay-label'>
|
|
275
|
-
{
|
|
276
|
-
instrument?.secondaryInstruments?.[0]
|
|
277
|
-
? (
|
|
278
|
-
<div class='balance'>
|
|
279
|
-
<Text>{ content?.balance } &</Text>
|
|
280
|
-
<Space />
|
|
281
|
-
</div>
|
|
282
|
-
)
|
|
283
|
-
: null
|
|
284
|
-
}
|
|
285
|
-
{
|
|
286
|
-
(instrument?.type === "balance")
|
|
287
|
-
? (
|
|
288
|
-
<div class='paypal-balance'>
|
|
289
|
-
<Text>{ content?.payPalBalance }</Text>
|
|
290
|
-
</div>
|
|
291
|
-
)
|
|
292
|
-
: (
|
|
293
|
-
<div class='no-paypal-balance'>
|
|
294
|
-
<div class='fi-logo' optional={ 1 }>
|
|
295
|
-
{
|
|
296
|
-
(instrument && logo)
|
|
297
|
-
? logo
|
|
298
|
-
: <Text><PlaceHolder chars={ 4 } color={ textColor } /></Text>
|
|
299
|
-
}
|
|
300
|
-
</div>
|
|
301
|
-
<div class='label'>
|
|
302
|
-
<Space />
|
|
303
|
-
{
|
|
304
|
-
(instrument && label)
|
|
305
|
-
? <Text>{ label }</Text>
|
|
306
|
-
: <Text><PlaceHolder chars={ 6 } color={ textColor } /></Text>
|
|
307
|
-
}
|
|
308
|
-
</div>
|
|
309
|
-
</div>
|
|
310
|
-
)
|
|
311
|
-
}
|
|
312
|
-
</div>
|
|
313
|
-
);
|
|
314
|
-
}
|
|
315
|
-
|
|
316
237
|
export function WalletLabel(opts : WalletLabelOptions) : ?ChildType {
|
|
317
|
-
const { logoColor, instrument, content, commit, vault, textColor, fundingSource
|
|
238
|
+
const { logoColor, instrument, content, commit, vault, textColor, fundingSource } = opts;
|
|
318
239
|
|
|
319
240
|
if (instrument && !instrument.type) {
|
|
320
241
|
return WalletLabelOld(opts);
|
|
@@ -384,24 +305,31 @@ export function WalletLabel(opts : WalletLabelOptions) : ?ChildType {
|
|
|
384
305
|
)
|
|
385
306
|
: null
|
|
386
307
|
}
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
308
|
+
|
|
309
|
+
<div class='pay-label' optional={ 2 }>
|
|
310
|
+
<Space />
|
|
311
|
+
{
|
|
312
|
+
(instrument && content)
|
|
313
|
+
? <Text>{ payNow ? content.payNow : content.payWith }</Text>
|
|
314
|
+
: <Text><PlaceHolder chars={ 7 } color={ textColor } /></Text>
|
|
315
|
+
}
|
|
316
|
+
<Space />
|
|
317
|
+
</div>
|
|
318
|
+
<div class='logo' optional={ 1 }>
|
|
319
|
+
{
|
|
320
|
+
(instrument && logo)
|
|
321
|
+
? logo
|
|
322
|
+
: <Text><PlaceHolder chars={ 4 } color={ textColor } /></Text>
|
|
323
|
+
}
|
|
324
|
+
</div>
|
|
325
|
+
<div class='label'>
|
|
326
|
+
<Space />
|
|
327
|
+
{
|
|
328
|
+
(instrument && label)
|
|
329
|
+
? <Text>{ label }</Text>
|
|
330
|
+
: <Text><PlaceHolder chars={ 6 } color={ textColor } /></Text>
|
|
331
|
+
}
|
|
332
|
+
</div>
|
|
405
333
|
</div>
|
|
406
334
|
</Style>
|
|
407
335
|
);
|
package/src/types.js
CHANGED
|
@@ -2,12 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { CARD, WALLET_INSTRUMENT } from '@paypal/sdk-constants/src';
|
|
4
4
|
|
|
5
|
-
export type SecondaryInstruments = {|
|
|
6
|
-
type : string,
|
|
7
|
-
label : string,
|
|
8
|
-
instrumentID : string
|
|
9
|
-
|};
|
|
10
|
-
|
|
11
5
|
export type WalletInstrument = {|
|
|
12
6
|
type? : $Values<typeof WALLET_INSTRUMENT>,
|
|
13
7
|
label? : string,
|
|
@@ -16,8 +10,7 @@ export type WalletInstrument = {|
|
|
|
16
10
|
tokenID? : string,
|
|
17
11
|
vendor? : $Values<typeof CARD>,
|
|
18
12
|
oneClick : boolean,
|
|
19
|
-
branded : boolean
|
|
20
|
-
secondaryInstruments? : SecondaryInstruments
|
|
13
|
+
branded : boolean
|
|
21
14
|
|};
|
|
22
15
|
|
|
23
16
|
export type WalletPaymentType = {|
|
|
@@ -45,8 +38,7 @@ export type ContentType = {|
|
|
|
45
38
|
credit : string,
|
|
46
39
|
payWith : string,
|
|
47
40
|
payLater : string,
|
|
48
|
-
flex : string
|
|
49
|
-
payPalBalance: string
|
|
41
|
+
flex : string
|
|
50
42
|
|};
|
|
51
43
|
|
|
52
44
|
export type Experiment = {|
|
|
@@ -41,12 +41,11 @@ type IndividualButtonProps = {|
|
|
|
41
41
|
vault : boolean,
|
|
42
42
|
merchantFundingSource : ?$Values<typeof FUNDING>,
|
|
43
43
|
instrument : ?WalletInstrument,
|
|
44
|
-
experience? : string
|
|
45
|
-
showPayLabel : boolean
|
|
44
|
+
experience? : string
|
|
46
45
|
|};
|
|
47
46
|
|
|
48
47
|
export function Button({ fundingSource, style, multiple, locale, env, fundingEligibility, i, nonce, flow, vault,
|
|
49
|
-
userIDToken, personalization, onClick = noop, content, tagline, commit, experiment, instrument, experience
|
|
48
|
+
userIDToken, personalization, onClick = noop, content, tagline, commit, experiment, instrument, experience } : IndividualButtonProps) : ElementNode {
|
|
50
49
|
|
|
51
50
|
const { custom, layout, shape } = style;
|
|
52
51
|
const inlineExperience = experience === EXPERIENCE.INLINE && custom && custom.label;
|
|
@@ -175,7 +174,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
175
174
|
|
|
176
175
|
if (
|
|
177
176
|
WalletLabel &&
|
|
178
|
-
|
|
177
|
+
flow === BUTTON_FLOW.PURCHASE &&
|
|
179
178
|
(instrument || (__WEB__ && userIDToken && (fundingSource === FUNDING.PAYPAL || fundingSource === FUNDING.VENMO)))
|
|
180
179
|
) {
|
|
181
180
|
labelNode = (
|
|
@@ -190,7 +189,6 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
190
189
|
vault={ vault }
|
|
191
190
|
textColor={ textColor }
|
|
192
191
|
fundingSource={ fundingSource }
|
|
193
|
-
showPayLabel={ showPayLabel }
|
|
194
192
|
/>
|
|
195
193
|
);
|
|
196
194
|
|
|
@@ -220,12 +218,11 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
220
218
|
<div
|
|
221
219
|
role='link'
|
|
222
220
|
{ ...{
|
|
223
|
-
[ ATTRIBUTE.BUTTON ]:
|
|
224
|
-
[ ATTRIBUTE.FUNDING_SOURCE ]:
|
|
225
|
-
[ ATTRIBUTE.PAYMENT_METHOD_ID ]:
|
|
226
|
-
[ ATTRIBUTE.INSTRUMENT_ID ]:
|
|
227
|
-
[ ATTRIBUTE.INSTRUMENT_TYPE ]:
|
|
228
|
-
[ ATTRIBUTE.SECONDARY_INSTRUMENT_TYPE ]: instrument?.secondaryInstruments ? instrument.secondaryInstruments[0].type : null
|
|
221
|
+
[ ATTRIBUTE.BUTTON ]: true,
|
|
222
|
+
[ ATTRIBUTE.FUNDING_SOURCE ]: fundingSource,
|
|
223
|
+
[ ATTRIBUTE.PAYMENT_METHOD_ID ]: instrument ? instrument.tokenID : null,
|
|
224
|
+
[ ATTRIBUTE.INSTRUMENT_ID ]: instrument ? instrument.instrumentID : null,
|
|
225
|
+
[ ATTRIBUTE.INSTRUMENT_TYPE ]: instrument ? instrument.type : null
|
|
229
226
|
} }
|
|
230
227
|
class={ [
|
|
231
228
|
CLASS.BUTTON,
|
|
@@ -104,7 +104,7 @@ export function Buttons(props : ButtonsProps) : ElementNode {
|
|
|
104
104
|
const { onClick = noop } = props;
|
|
105
105
|
const { wallet, fundingSource, style, locale, remembered, env, fundingEligibility, platform, commit, vault,
|
|
106
106
|
nonce, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, personalization, userIDToken, content, flow, experiment, applePaySupport,
|
|
107
|
-
supportsPopups, supportedNativeBrowser, experience
|
|
107
|
+
supportsPopups, supportedNativeBrowser, experience } = normalizeButtonProps(props);
|
|
108
108
|
const { custom, layout, shape, tagline } = style;
|
|
109
109
|
|
|
110
110
|
const inlineExperience = experience === EXPERIENCE.INLINE && custom && custom.label && custom.label.length !== 0;
|
|
@@ -192,7 +192,6 @@ export function Buttons(props : ButtonsProps) : ElementNode {
|
|
|
192
192
|
vault={ vault }
|
|
193
193
|
instrument={ instruments[source] }
|
|
194
194
|
experience={ experience }
|
|
195
|
-
showPayLabel={ showPayLabel }
|
|
196
195
|
/>
|
|
197
196
|
))
|
|
198
197
|
}
|
package/src/ui/buttons/props.js
CHANGED
|
@@ -393,8 +393,7 @@ export type RenderButtonProps = {|
|
|
|
393
393
|
applePaySupport : boolean,
|
|
394
394
|
supportsPopups : boolean,
|
|
395
395
|
supportedNativeBrowser : boolean,
|
|
396
|
-
experience : string
|
|
397
|
-
showPayLabel : boolean
|
|
396
|
+
experience : string
|
|
398
397
|
|};
|
|
399
398
|
|
|
400
399
|
export type PrerenderDetails = {|
|
|
@@ -430,6 +429,7 @@ export type ButtonProps = {|
|
|
|
430
429
|
remember : ($ReadOnlyArray<$Values<typeof FUNDING>>) => void,
|
|
431
430
|
clientID : string,
|
|
432
431
|
sessionID : string,
|
|
432
|
+
buttonLocation : string,
|
|
433
433
|
buttonSessionID : string,
|
|
434
434
|
onShippingChange : ?OnShippingChange,
|
|
435
435
|
onShippingAddressChange : ?OnShippingAddressChange,
|
|
@@ -489,8 +489,7 @@ export type ButtonPropsInputs = {
|
|
|
489
489
|
applePaySupport : boolean,
|
|
490
490
|
supportsPopups : boolean,
|
|
491
491
|
supportedNativeBrowser : boolean,
|
|
492
|
-
experience : string
|
|
493
|
-
showPayLabel : boolean
|
|
492
|
+
experience : string
|
|
494
493
|
};
|
|
495
494
|
|
|
496
495
|
export const DEFAULT_STYLE = {
|
|
@@ -660,8 +659,7 @@ export function normalizeButtonProps(props : ?ButtonPropsInputs) : RenderButtonP
|
|
|
660
659
|
applePaySupport = false,
|
|
661
660
|
supportsPopups = false,
|
|
662
661
|
supportedNativeBrowser = false,
|
|
663
|
-
experience = ''
|
|
664
|
-
showPayLabel
|
|
662
|
+
experience = ''
|
|
665
663
|
} = props;
|
|
666
664
|
|
|
667
665
|
const { country, lang } = locale;
|
|
@@ -704,5 +702,5 @@ export function normalizeButtonProps(props : ?ButtonPropsInputs) : RenderButtonP
|
|
|
704
702
|
|
|
705
703
|
return { clientID, fundingSource, style, locale, remembered, env, fundingEligibility, platform, clientAccessToken,
|
|
706
704
|
buttonSessionID, commit, sessionID, nonce, components, onShippingChange, onShippingAddressChange, onShippingOptionsChange, personalization, content, wallet, flow,
|
|
707
|
-
experiment, vault, userIDToken, applePay, applePaySupport, supportsPopups, supportedNativeBrowser, experience
|
|
705
|
+
experiment, vault, userIDToken, applePay, applePaySupport, supportsPopups, supportedNativeBrowser, experience };
|
|
708
706
|
}
|
|
@@ -386,6 +386,12 @@ export const getButtonsComponent : () => ButtonsComponent = memoize(() => {
|
|
|
386
386
|
queryParam: true
|
|
387
387
|
},
|
|
388
388
|
|
|
389
|
+
buttonLocation: {
|
|
390
|
+
type: 'string',
|
|
391
|
+
value: () => window.location.hostname,
|
|
392
|
+
queryParam: false
|
|
393
|
+
},
|
|
394
|
+
|
|
389
395
|
buttonSessionID: {
|
|
390
396
|
type: 'string',
|
|
391
397
|
value: uniqueID,
|