@paypal/checkout-components 5.0.245 → 5.0.246-alpha.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypal/checkout-components",
3
- "version": "5.0.245",
3
+ "version": "5.0.246-alpha.0",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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 --progress",
32
- "webpack-size": "babel-node $(npm bin)/webpack --progress --config webpack.config.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": [
@@ -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
  };
@@ -21,3 +21,6 @@ export function allowIframe() : boolean {
21
21
 
22
22
  return false;
23
23
  }
24
+
25
+ // $FlowIssue
26
+ export const protectedExport = (unprotectedExport) => (isPayPalDomain() ? unprotectedExport : undefined);
@@ -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
@@ -8,7 +8,7 @@ type PrerenderedCardProps = {|
8
8
  height : ?number
9
9
  |};
10
10
 
11
- const DEFAULT_HEIGHT = 30;
11
+ const DEFAULT_HEIGHT = 78;
12
12
 
13
13
  export function CardPrerender({ nonce, height } : PrerenderedCardProps) : ChildType {
14
14
  return (