@paypal/checkout-components 5.0.245 → 5.0.246
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 +5 -4
- package/src/interface/button.js +1 -8
- package/src/interface/card-fields.js +2 -1
- package/src/lib/security.js +3 -0
- package/src/types.js +2 -1
- package/src/ui/buttons/button.jsx +13 -3
- package/src/ui/buttons/menu-button/menu-button.jsx +7 -2
- package/src/zoid/card-fields/component.jsx +97 -4
- package/src/zoid/card-fields/prerender.jsx +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paypal/checkout-components",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.246",
|
|
4
4
|
"description": "PayPal Checkout components, for integrating checkout products.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"debug": "cross-env NODE_ENV=debug",
|
|
13
13
|
"delete-size": "rm dist/size.* dist/report.html",
|
|
14
14
|
"demo": "serve ./demo -l 1337",
|
|
15
|
-
"dev": "npm run check-node-version && babel-node $(npm bin)/webpack-dev-server --config webpack.config.dev.js --port 9001 --host localhost.paypal.com --open demo/dev/index.htm --https --hot=false",
|
|
15
|
+
"dev": "npm run check-node-version && babel-node $(npm bin)/webpack-dev-server --config webpack.config.dev.js --port 9001 --host localhost.paypal.com --open demo/dev/index.htm --https --hot=false --static './'",
|
|
16
16
|
"eslint-find-rules": "eslint-find-rules --current .eslintrc.js --unused --plugin",
|
|
17
17
|
"flow": "flow",
|
|
18
18
|
"flow-typed": "rm -rf flow-typed && flow-typed install && rm flow-typed/npm/puppeteer_*",
|
|
@@ -25,11 +25,12 @@
|
|
|
25
25
|
"preversion": "./scripts/preversion.sh",
|
|
26
26
|
"reinstall": "rimraf flow-typed && rimraf node_modules && npm install && flow-typed install",
|
|
27
27
|
"release": "./scripts/publish.sh",
|
|
28
|
+
"start": "npm run webpack -- --progress --watch",
|
|
28
29
|
"test": "npm run jest-ssr && npm run karma && npm run jest-screenshot",
|
|
29
30
|
"typecheck": "npm run flow-typed && npm run flow",
|
|
30
31
|
"version": "./scripts/version.sh",
|
|
31
|
-
"webpack": "babel-node $(npm bin)/webpack
|
|
32
|
-
"webpack-size": "
|
|
32
|
+
"webpack": "babel-node $(npm bin)/webpack",
|
|
33
|
+
"webpack-size": "npm run webpack -- --config webpack.config.size",
|
|
33
34
|
"prepare": "husky install"
|
|
34
35
|
},
|
|
35
36
|
"files": [
|
package/src/interface/button.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
|
|
3
|
-
import { isPayPalDomain } from '@paypal/sdk-client/src';
|
|
4
3
|
import { PopupOpenError as _PopupOpenError, destroy as zoidDestroy, destroyComponents } from '@krakenjs/zoid/src';
|
|
5
4
|
|
|
6
5
|
import type { LazyExport, LazyProtectedExport } from '../types';
|
|
7
|
-
import { allowIframe as _allowIframe } from '../lib';
|
|
6
|
+
import { allowIframe as _allowIframe, protectedExport } from '../lib';
|
|
8
7
|
import { getCheckoutComponent, type CheckoutComponent } from '../zoid/checkout';
|
|
9
8
|
import { getButtonsComponent, type ButtonsComponent } from '../zoid/buttons';
|
|
10
9
|
import { getCardFormComponent, type CardFormComponent } from '../zoid/card-form';
|
|
@@ -15,12 +14,6 @@ import { Buttons as _ButtonsTemplate } from '../ui/buttons';
|
|
|
15
14
|
import { getQRCodeComponent, type QRCodeComponent } from '../zoid/qr-code';
|
|
16
15
|
import { getModalComponent, type ModalComponent } from '../zoid/modal/component';
|
|
17
16
|
|
|
18
|
-
function protectedExport<T>(xport : T) : ?T {
|
|
19
|
-
if (isPayPalDomain()) {
|
|
20
|
-
return xport;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
17
|
export const Buttons : LazyExport<ButtonsComponent> = {
|
|
25
18
|
__get__: () => getButtonsComponent()
|
|
26
19
|
};
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
import type { LazyExport } from '../types';
|
|
4
4
|
import { getCardFieldsComponent, type CardFieldsComponent } from '../zoid/card-fields/component';
|
|
5
|
+
import { protectedExport } from '../lib';
|
|
5
6
|
|
|
6
7
|
export const CardFields : LazyExport<CardFieldsComponent> = {
|
|
7
|
-
__get__: () => getCardFieldsComponent()
|
|
8
|
+
__get__: () => protectedExport(getCardFieldsComponent())
|
|
8
9
|
};
|
package/src/lib/security.js
CHANGED
package/src/types.js
CHANGED
|
@@ -99,8 +99,18 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
99
99
|
preventClickFocus(el);
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
|
|
103
|
+
function getAriaLabel() : string {
|
|
104
|
+
let labelText = typeof fundingConfig.labelText === 'function' ? fundingConfig.labelText({ content, fundingEligibility }) : (fundingConfig.labelText || fundingSource);
|
|
105
|
+
|
|
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;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const labelText = getAriaLabel();
|
|
104
114
|
|
|
105
115
|
const logoNode = (
|
|
106
116
|
<Logo
|
|
@@ -253,7 +263,7 @@ export function Button({ fundingSource, style, multiple, locale, env, fundingEli
|
|
|
253
263
|
<Spinner />
|
|
254
264
|
</div>
|
|
255
265
|
|
|
256
|
-
{ shouldShowWalletMenu ? <MenuButton textColor={ textColor } /> : null }
|
|
266
|
+
{ shouldShowWalletMenu ? <MenuButton textColor={ textColor } content={ content } /> : null }
|
|
257
267
|
</div>
|
|
258
268
|
);
|
|
259
269
|
}
|
|
@@ -5,10 +5,12 @@ import { node, type ChildType, Style } from '@krakenjs/jsx-pragmatic/src';
|
|
|
5
5
|
|
|
6
6
|
import { ATTRIBUTE, TEXT_COLOR } from '../../../constants';
|
|
7
7
|
import { Chevron } from '../../chevron';
|
|
8
|
+
import type { ContentType } from '../../../types';
|
|
8
9
|
|
|
9
10
|
import css from './menu-button.scoped.scss';
|
|
10
11
|
|
|
11
|
-
export function MenuButton({ textColor = TEXT_COLOR.BLACK } : {| textColor? : $Values<typeof TEXT_COLOR
|
|
12
|
+
export function MenuButton({ textColor = TEXT_COLOR.BLACK, content } : {| textColor? : $Values<typeof TEXT_COLOR>, content : ?ContentType |} = { }) : ChildType {
|
|
13
|
+
const labelText = content?.moreOptions;
|
|
12
14
|
return (
|
|
13
15
|
<Style css={ css }>
|
|
14
16
|
<div
|
|
@@ -16,7 +18,10 @@ export function MenuButton({ textColor = TEXT_COLOR.BLACK } : {| textColor? : $V
|
|
|
16
18
|
[ATTRIBUTE.MENU]: true
|
|
17
19
|
} }
|
|
18
20
|
tabindex='0'
|
|
19
|
-
class='menu-button'
|
|
21
|
+
class='menu-button'
|
|
22
|
+
role='button'
|
|
23
|
+
aria-label={ labelText }
|
|
24
|
+
aria-haspopup='menu'>
|
|
20
25
|
<Chevron color={ textColor } />
|
|
21
26
|
</div>
|
|
22
27
|
</Style>
|
|
@@ -21,7 +21,8 @@ const CARD_FIELD_TYPE = {
|
|
|
21
21
|
NUMBER: 'number',
|
|
22
22
|
CVV: 'cvv',
|
|
23
23
|
EXPIRY: 'expiry',
|
|
24
|
-
NAME: 'name'
|
|
24
|
+
NAME: 'name',
|
|
25
|
+
POSTAL: 'postal'
|
|
25
26
|
};
|
|
26
27
|
|
|
27
28
|
type CardFieldsProps = {|
|
|
@@ -44,6 +45,8 @@ type CardFieldsProps = {|
|
|
|
44
45
|
commit : boolean,
|
|
45
46
|
vault : boolean,
|
|
46
47
|
branded? : boolean,
|
|
48
|
+
minLength?: number,
|
|
49
|
+
maxLength?: number,
|
|
47
50
|
|
|
48
51
|
createOrder : () => ZalgoPromise<string> | string,
|
|
49
52
|
onApprove : ({| returnUrl : string |}, {| redirect : (?CrossDomainWindowType, ?string) => ZalgoPromise<void> |}) => ?ZalgoPromise<void>,
|
|
@@ -62,14 +65,20 @@ type CardFieldProps = {|
|
|
|
62
65
|
export type CardFieldComponent = ZoidComponent<CardFieldProps>;
|
|
63
66
|
|
|
64
67
|
type CardFieldsExports = {|
|
|
65
|
-
submit : () => ZalgoPromise<void
|
|
68
|
+
submit : () => ZalgoPromise<void>,
|
|
69
|
+
setAttribute : () => ZalgoPromise<void>,
|
|
70
|
+
removeAttribute : () => ZalgoPromise<void>,
|
|
71
|
+
addClass : () => ZalgoPromise<void>,
|
|
72
|
+
removeClass : () => ZalgoPromise<void>,
|
|
73
|
+
getState : () => ZalgoPromise<Object>
|
|
66
74
|
|};
|
|
67
75
|
|
|
68
76
|
type CardFieldsChildren = {|
|
|
69
77
|
NumberField : CardFieldComponent,
|
|
70
78
|
CVVField : CardFieldComponent,
|
|
71
79
|
ExpiryField : CardFieldComponent,
|
|
72
|
-
NameField : CardFieldComponent
|
|
80
|
+
NameField : CardFieldComponent,
|
|
81
|
+
PostalCodeField: CardFieldComponent
|
|
73
82
|
|};
|
|
74
83
|
|
|
75
84
|
const url = () => `${ getPayPalDomain() }${ __PAYPAL_CHECKOUT__.__URI__.__CARD_FIELD__ }`;
|
|
@@ -110,6 +119,30 @@ export const getCardFieldsComponent : () => CardFieldsComponent = memoize(() : C
|
|
|
110
119
|
|
|
111
120
|
prerenderTemplate,
|
|
112
121
|
|
|
122
|
+
exports: {
|
|
123
|
+
setAttribute: {
|
|
124
|
+
type: 'function'
|
|
125
|
+
},
|
|
126
|
+
removeAttribute: {
|
|
127
|
+
type: 'function'
|
|
128
|
+
},
|
|
129
|
+
addClass: {
|
|
130
|
+
type: 'function'
|
|
131
|
+
},
|
|
132
|
+
removeClass: {
|
|
133
|
+
type: 'function'
|
|
134
|
+
},
|
|
135
|
+
clear: {
|
|
136
|
+
type: 'function'
|
|
137
|
+
},
|
|
138
|
+
focus: {
|
|
139
|
+
type: 'function'
|
|
140
|
+
},
|
|
141
|
+
setMessage: {
|
|
142
|
+
type: 'function'
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
|
|
113
146
|
props: {
|
|
114
147
|
type: {
|
|
115
148
|
type: 'string',
|
|
@@ -197,6 +230,18 @@ export const getCardFieldsComponent : () => CardFieldsComponent = memoize(() : C
|
|
|
197
230
|
}
|
|
198
231
|
},
|
|
199
232
|
|
|
233
|
+
minLength: {
|
|
234
|
+
type: 'number',
|
|
235
|
+
required: false,
|
|
236
|
+
value: ({props}) => props.minLength
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
maxLength: {
|
|
240
|
+
type: 'number',
|
|
241
|
+
required: false,
|
|
242
|
+
value: ({props}) => props.maxLength
|
|
243
|
+
},
|
|
244
|
+
|
|
200
245
|
fundingEligibility: {
|
|
201
246
|
type: 'object',
|
|
202
247
|
value: ({ props }) => props.parent.props.fundingEligibility
|
|
@@ -250,6 +295,7 @@ export const getCardFieldsComponent : () => CardFieldsComponent = memoize(() : C
|
|
|
250
295
|
const CVVField = genericCardField(CARD_FIELD_TYPE.CVV);
|
|
251
296
|
const ExpiryField = genericCardField(CARD_FIELD_TYPE.EXPIRY);
|
|
252
297
|
const NameField = genericCardField(CARD_FIELD_TYPE.NAME);
|
|
298
|
+
const PostalCodeField = genericCardField(CARD_FIELD_TYPE.POSTAL);
|
|
253
299
|
|
|
254
300
|
const CardFields = create({
|
|
255
301
|
tag: 'paypal-card-fields',
|
|
@@ -278,14 +324,49 @@ export const getCardFieldsComponent : () => CardFieldsComponent = memoize(() : C
|
|
|
278
324
|
NumberField,
|
|
279
325
|
CVVField,
|
|
280
326
|
ExpiryField,
|
|
281
|
-
NameField
|
|
327
|
+
NameField,
|
|
328
|
+
PostalCodeField
|
|
282
329
|
};
|
|
283
330
|
},
|
|
284
331
|
|
|
285
332
|
exports: {
|
|
286
333
|
submit: {
|
|
287
334
|
type: 'function'
|
|
335
|
+
},
|
|
336
|
+
setAttribute: {
|
|
337
|
+
type: 'function'
|
|
338
|
+
},
|
|
339
|
+
removeAttribute: {
|
|
340
|
+
type: 'function'
|
|
341
|
+
},
|
|
342
|
+
addClass: {
|
|
343
|
+
type: 'function'
|
|
344
|
+
},
|
|
345
|
+
removeClass: {
|
|
346
|
+
type: 'function'
|
|
347
|
+
},
|
|
348
|
+
clear: {
|
|
349
|
+
type: 'function'
|
|
350
|
+
},
|
|
351
|
+
focus: {
|
|
352
|
+
type: 'function'
|
|
353
|
+
},
|
|
354
|
+
getState: {
|
|
355
|
+
type: 'function'
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
|
|
359
|
+
eligible: () => {
|
|
360
|
+
const fundingEligibility = getRefinedFundingEligibility();
|
|
361
|
+
if (fundingEligibility?.card?.eligible) {
|
|
362
|
+
return {
|
|
363
|
+
eligible: true
|
|
364
|
+
};
|
|
288
365
|
}
|
|
366
|
+
return {
|
|
367
|
+
eligible: false,
|
|
368
|
+
reason: 'card payments are not eligible'
|
|
369
|
+
};
|
|
289
370
|
},
|
|
290
371
|
|
|
291
372
|
props: {
|
|
@@ -365,6 +446,18 @@ export const getCardFieldsComponent : () => CardFieldsComponent = memoize(() : C
|
|
|
365
446
|
queryParam: true
|
|
366
447
|
},
|
|
367
448
|
|
|
449
|
+
minLength: {
|
|
450
|
+
type: 'number',
|
|
451
|
+
required: false,
|
|
452
|
+
value: ({props}) => props.minLength
|
|
453
|
+
},
|
|
454
|
+
|
|
455
|
+
maxLength: {
|
|
456
|
+
type: 'number',
|
|
457
|
+
required: false,
|
|
458
|
+
value: ({props}) => props.maxLength
|
|
459
|
+
},
|
|
460
|
+
|
|
368
461
|
fundingEligibility: {
|
|
369
462
|
type: 'object',
|
|
370
463
|
value: getRefinedFundingEligibility
|