@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.
Files changed (185) hide show
  1. package/README.md +8 -0
  2. package/__sdk__.js +72 -76
  3. package/dist/button.js +1 -1
  4. package/globals.js +28 -30
  5. package/package.json +6 -4
  6. package/src/constants/button.js +37 -36
  7. package/src/constants/class.js +32 -30
  8. package/src/constants/index.js +3 -3
  9. package/src/constants/misc.js +14 -12
  10. package/src/declarations.js +19 -19
  11. package/src/funding/applepay/config.jsx +51 -50
  12. package/src/funding/applepay/index.js +1 -1
  13. package/src/funding/applepay/style.scoped.scss +1 -1
  14. package/src/funding/applepay/template.jsx +16 -11
  15. package/src/funding/bancontact/config.jsx +48 -37
  16. package/src/funding/bancontact/index.js +1 -2
  17. package/src/funding/blik/config.jsx +48 -37
  18. package/src/funding/blik/index.js +1 -2
  19. package/src/funding/boleto/config.jsx +50 -39
  20. package/src/funding/boleto/index.js +1 -2
  21. package/src/funding/card/amex/config.js +9 -8
  22. package/src/funding/card/amex/index.js +1 -2
  23. package/src/funding/card/config.jsx +246 -177
  24. package/src/funding/card/discover/config.js +9 -7
  25. package/src/funding/card/discover/index.js +1 -2
  26. package/src/funding/card/elo/config.js +6 -7
  27. package/src/funding/card/elo/index.js +1 -2
  28. package/src/funding/card/hiper/config.js +9 -7
  29. package/src/funding/card/hiper/index.js +1 -2
  30. package/src/funding/card/index.js +1 -1
  31. package/src/funding/card/jcb/config.js +6 -7
  32. package/src/funding/card/jcb/index.js +1 -2
  33. package/src/funding/card/mastercard/config.js +9 -7
  34. package/src/funding/card/mastercard/index.js +1 -2
  35. package/src/funding/card/visa/config.js +9 -7
  36. package/src/funding/card/visa/index.js +1 -2
  37. package/src/funding/common.jsx +242 -216
  38. package/src/funding/config.js +212 -65
  39. package/src/funding/content.jsx +1946 -337
  40. package/src/funding/credit/config.jsx +74 -57
  41. package/src/funding/credit/index.js +1 -2
  42. package/src/funding/eps/config.jsx +45 -37
  43. package/src/funding/eps/index.js +1 -2
  44. package/src/funding/funding.js +193 -100
  45. package/src/funding/giropay/config.jsx +48 -38
  46. package/src/funding/giropay/index.js +1 -2
  47. package/src/funding/ideal/config.jsx +48 -37
  48. package/src/funding/ideal/index.js +1 -2
  49. package/src/funding/index.js +2 -2
  50. package/src/funding/itau/config.jsx +41 -41
  51. package/src/funding/itau/index.js +1 -1
  52. package/src/funding/maxima/config.jsx +25 -19
  53. package/src/funding/maxima/index.js +1 -2
  54. package/src/funding/mercadopago/config.jsx +48 -37
  55. package/src/funding/mercadopago/index.js +1 -2
  56. package/src/funding/multibanco/config.jsx +50 -39
  57. package/src/funding/multibanco/index.js +1 -2
  58. package/src/funding/mybank/config.jsx +48 -37
  59. package/src/funding/mybank/index.js +1 -2
  60. package/src/funding/oxxo/config.jsx +50 -39
  61. package/src/funding/oxxo/index.js +1 -2
  62. package/src/funding/p24/config.jsx +45 -37
  63. package/src/funding/p24/index.js +1 -2
  64. package/src/funding/paidy/config.jsx +50 -39
  65. package/src/funding/paidy/index.js +1 -1
  66. package/src/funding/paylater/config.jsx +118 -111
  67. package/src/funding/paylater/index.js +1 -2
  68. package/src/funding/paypal/config.jsx +44 -46
  69. package/src/funding/paypal/index.js +1 -2
  70. package/src/funding/paypal/style.scoped.scss +80 -74
  71. package/src/funding/paypal/template.jsx +450 -354
  72. package/src/funding/payu/config.jsx +50 -39
  73. package/src/funding/payu/index.js +1 -1
  74. package/src/funding/satispay/config.jsx +50 -39
  75. package/src/funding/satispay/index.js +1 -1
  76. package/src/funding/sepa/config.jsx +19 -13
  77. package/src/funding/sepa/index.js +1 -2
  78. package/src/funding/sofort/config.jsx +48 -37
  79. package/src/funding/sofort/index.js +1 -2
  80. package/src/funding/trustly/config.jsx +50 -39
  81. package/src/funding/trustly/index.js +1 -2
  82. package/src/funding/venmo/config.jsx +80 -75
  83. package/src/funding/venmo/index.js +1 -2
  84. package/src/funding/venmo/style.scoped.scss +30 -32
  85. package/src/funding/venmo/template.jsx +56 -57
  86. package/src/funding/verkkopankki/config.jsx +50 -39
  87. package/src/funding/verkkopankki/index.js +1 -1
  88. package/src/funding/wechatpay/config.jsx +48 -37
  89. package/src/funding/wechatpay/index.js +1 -2
  90. package/src/funding/zimpler/config.jsx +19 -13
  91. package/src/funding/zimpler/index.js +1 -2
  92. package/src/interface/button.js +60 -44
  93. package/src/interface/card-fields.js +11 -8
  94. package/src/interface/fields.js +7 -4
  95. package/src/interface/marks.js +4 -4
  96. package/src/interface/payment-fields.js +7 -4
  97. package/src/interface/wallet.js +4 -4
  98. package/src/lib/errors.js +7 -7
  99. package/src/lib/index.js +5 -5
  100. package/src/lib/isRTLLanguage.js +3 -3
  101. package/src/lib/perceived-latency-instrumentation.js +54 -36
  102. package/src/lib/security.js +21 -17
  103. package/src/lib/session.js +39 -35
  104. package/src/marks/component.jsx +114 -65
  105. package/src/marks/index.js +1 -2
  106. package/src/marks/template.jsx +79 -65
  107. package/src/types.js +48 -48
  108. package/src/ui/buttons/button.jsx +311 -249
  109. package/src/ui/buttons/buttonDesigns/control.jsx +3 -5
  110. package/src/ui/buttons/buttonDesigns/divideLogoAnimation.jsx +127 -99
  111. package/src/ui/buttons/buttonDesigns/index.js +78 -75
  112. package/src/ui/buttons/buttonDesigns/inlineLogoTextDesign.jsx +102 -82
  113. package/src/ui/buttons/buttonDesigns/script.jsx +24 -18
  114. package/src/ui/buttons/buttonDesigns/types.js +6 -7
  115. package/src/ui/buttons/buttons.jsx +318 -212
  116. package/src/ui/buttons/config.js +62 -59
  117. package/src/ui/buttons/content.jsx +304 -119
  118. package/src/ui/buttons/index.js +1 -1
  119. package/src/ui/buttons/menu-button/index.js +1 -1
  120. package/src/ui/buttons/menu-button/menu-button.jsx +29 -22
  121. package/src/ui/buttons/menu-button/menu-button.scoped.scss +16 -17
  122. package/src/ui/buttons/poweredBy.jsx +23 -23
  123. package/src/ui/buttons/props.js +680 -529
  124. package/src/ui/buttons/script.jsx +182 -160
  125. package/src/ui/buttons/spinner.jsx +4 -6
  126. package/src/ui/buttons/style.jsx +15 -14
  127. package/src/ui/buttons/styles/base.js +24 -16
  128. package/src/ui/buttons/styles/button.js +24 -22
  129. package/src/ui/buttons/styles/color.js +118 -118
  130. package/src/ui/buttons/styles/custom.js +30 -24
  131. package/src/ui/buttons/styles/index.js +1 -1
  132. package/src/ui/buttons/styles/labels.js +17 -13
  133. package/src/ui/buttons/styles/page.js +3 -3
  134. package/src/ui/buttons/styles/responsive.js +226 -118
  135. package/src/ui/buttons/tagline.jsx +53 -54
  136. package/src/ui/chevron.jsx +27 -16
  137. package/src/ui/index.js +3 -3
  138. package/src/ui/loading.jsx +25 -18
  139. package/src/ui/text/index.js +1 -1
  140. package/src/ui/text/style.scoped.scss +25 -26
  141. package/src/ui/text/text.jsx +42 -20
  142. package/src/ui/tracking.jsx +18 -11
  143. package/src/zoid/buttons/component.jsx +836 -684
  144. package/src/zoid/buttons/container.jsx +140 -107
  145. package/src/zoid/buttons/index.js +1 -1
  146. package/src/zoid/buttons/prerender.jsx +84 -64
  147. package/src/zoid/buttons/util.js +355 -254
  148. package/src/zoid/card-fields/component.jsx +581 -549
  149. package/src/zoid/card-fields/index.js +1 -1
  150. package/src/zoid/card-fields/prerender.jsx +20 -17
  151. package/src/zoid/card-form/component.js +155 -141
  152. package/src/zoid/card-form/index.js +1 -1
  153. package/src/zoid/checkout/component.jsx +314 -282
  154. package/src/zoid/checkout/config.js +2 -2
  155. package/src/zoid/checkout/content.js +190 -154
  156. package/src/zoid/checkout/hacks.js +31 -28
  157. package/src/zoid/checkout/index.js +2 -2
  158. package/src/zoid/checkout/props.js +27 -33
  159. package/src/zoid/installments/component.jsx +83 -70
  160. package/src/zoid/installments/index.js +1 -1
  161. package/src/zoid/installments/props.js +1 -1
  162. package/src/zoid/menu/component.jsx +53 -48
  163. package/src/zoid/menu/index.js +1 -1
  164. package/src/zoid/menu/props.js +1 -3
  165. package/src/zoid/modal/component.jsx +119 -106
  166. package/src/zoid/modal/index.js +1 -1
  167. package/src/zoid/modal/props.js +1 -3
  168. package/src/zoid/payment-fields/component.jsx +215 -191
  169. package/src/zoid/payment-fields/container.jsx +73 -64
  170. package/src/zoid/payment-fields/index.js +1 -1
  171. package/src/zoid/payment-fields/prerender.jsx +16 -14
  172. package/src/zoid/payment-fields/props.js +6 -6
  173. package/src/zoid/qr-code/component.jsx +131 -115
  174. package/src/zoid/qr-code/container.jsx +74 -68
  175. package/src/zoid/qr-code/index.js +1 -1
  176. package/src/zoid/qr-code/prerender.jsx +17 -12
  177. package/src/zoid/qr-code/types.js +2 -2
  178. package/src/zoid/wallet/component.jsx +298 -260
  179. package/src/zoid/wallet/container.jsx +73 -64
  180. package/src/zoid/wallet/index.js +1 -1
  181. package/src/zoid/wallet/prerender.jsx +14 -14
  182. package/src/zoid/wallet/props.js +4 -4
  183. package/src/actions/save/index.js +0 -40
  184. package/src/interface/actions.js +0 -14
  185. package/src/lib/getLogoCDNExperiment.js +0 -25
@@ -2,199 +2,223 @@
2
2
  /** @jsx node */
3
3
  /* eslint max-lines: 0 */
4
4
 
5
- import { node, dom } from '@krakenjs/jsx-pragmatic/src';
6
- import { getLogger, getPayPalDomainRegex, getSDKMeta, getPayPalDomain, getClientID,
7
- getCorrelationID, getSessionID, getEnv, getBuyerCountry, getLocale, getPartnerAttributionID } from '@paypal/sdk-client/src';
8
- import { create, type ZoidComponent } from '@krakenjs/zoid/src';
9
- import { inlineMemoize, uniqueID } from '@krakenjs/belter/src';
10
-
11
- import { storageState, sessionState } from '../../lib';
12
-
13
- import { type PaymentFieldsProps } from './props';
14
- import { PaymentFieldsPrerender } from './prerender';
15
- import { PaymentFieldsContainer } from './container';
5
+ import { node, dom } from "@krakenjs/jsx-pragmatic/src";
6
+ import {
7
+ getLogger,
8
+ getPayPalDomainRegex,
9
+ getSDKMeta,
10
+ getPayPalDomain,
11
+ getClientID,
12
+ getCorrelationID,
13
+ getSessionID,
14
+ getEnv,
15
+ getBuyerCountry,
16
+ getLocale,
17
+ getPartnerAttributionID,
18
+ } from "@paypal/sdk-client/src";
19
+ import { create, type ZoidComponent } from "@krakenjs/zoid/src";
20
+ import { inlineMemoize, uniqueID } from "@krakenjs/belter/src";
21
+
22
+ import { storageState, sessionState } from "../../lib";
23
+
24
+ import { type PaymentFieldsProps } from "./props";
25
+ import { PaymentFieldsPrerender } from "./prerender";
26
+ import { PaymentFieldsContainer } from "./container";
16
27
 
17
28
  export type PaymentFieldsComponent = ZoidComponent<PaymentFieldsProps>;
18
29
 
19
- export function getPaymentFieldsComponent() : PaymentFieldsComponent {
20
- return inlineMemoize(getPaymentFieldsComponent, () => {
21
- return create({
22
- tag: 'paypal-fields',
23
- url: () => `${ getPayPalDomain() }${ __PAYPAL_CHECKOUT__.__URI__.__PAYMENT_FIELDS__ }`,
24
-
25
- domain: getPayPalDomainRegex(),
26
-
27
- autoResize: {
28
- width: false,
29
- height: true,
30
- element: 'body'
31
- },
32
-
33
- dimensions: {
34
- width: '100%',
35
- height: '300px'
36
- },
37
-
38
- logger: getLogger(),
39
-
40
- containerTemplate: ({ props, doc, uid, frame, prerenderFrame, event }) => {
41
- return (
42
- <PaymentFieldsContainer uid={ uid } frame={ frame } prerenderFrame={ prerenderFrame } event={ event } nonce={ props.nonce } />
43
- ).render(dom({ doc }));
44
- },
45
-
46
- prerenderTemplate: ({ props, doc }) => {
47
- return (
48
- <PaymentFieldsPrerender nonce={ props.nonce } />
49
- ).render(dom({ doc }));
50
- },
51
-
52
- attributes: {
53
- iframe: {
54
- scrolling: 'no'
55
- }
56
- },
57
-
58
- props: {
59
-
60
- fields: {
61
- type: 'object',
62
- queryParam: true,
63
- required: false,
64
- decorate: ({ value }) => value,
65
- default: () => ({})
66
- },
67
-
68
- style: {
69
- type: 'object',
70
- queryParam: true,
71
- required: false,
72
- decorate: ({ value }) => value,
73
- default: () => ({})
74
- },
75
-
76
- sdkMeta: {
77
- type: 'string',
78
- queryParam: true,
79
- sendToChild: false,
80
- value: getSDKMeta
81
- },
82
-
83
- clientID: {
84
- type: 'string',
85
- queryParam: true,
86
- value: getClientID
87
- },
88
-
89
- fundingSource: {
90
- type: 'string',
91
- queryParam: true,
92
- required: true
93
- },
94
-
95
- correlationID: {
96
- type: 'string',
97
- required: false,
98
- value: getCorrelationID
99
- },
100
-
101
- sessionID: {
102
- type: 'string',
103
- value: getSessionID,
104
- queryParam: true,
105
- required: false
106
- },
107
-
108
- fieldsSessionID: {
109
- type: 'string',
110
- value: uniqueID,
111
- queryParam: true
112
- },
113
-
114
- env: {
115
- type: 'string',
116
- queryParam: true,
117
- value: getEnv
118
- },
119
-
120
- onInit: {
121
- type: 'function',
122
- required: false
123
- },
124
-
125
- onError: {
126
- type: 'function',
127
- required: false
128
- },
129
-
130
- onContinue: {
131
- type: 'function',
132
- required: false
133
- },
134
-
135
- onClose: {
136
- type: 'function',
137
- required: false
138
- },
139
-
140
- showActionButtons: {
141
- type: 'boolean',
142
- queryParam: true,
143
- required: false
144
- },
145
-
146
- onFieldsClose: {
147
- type: 'function',
148
- required: false
149
- },
150
-
151
- buyerCountry: {
152
- type: 'string',
153
- queryParam: true,
154
- required: false,
155
- default: getBuyerCountry
156
- },
157
-
158
- locale: {
159
- type: 'object',
160
- queryParam: 'locale.x',
161
- allowDelegate: true,
162
- queryValue({ value }) : string {
163
- // $FlowFixMe
164
- const { lang, country } = value;
165
- return `${ lang }_${ country }`;
166
- },
167
- value: getLocale
168
- },
169
-
170
- country: {
171
- type: 'object',
172
- queryParam: 'country.x',
173
- allowDelegate: true,
174
- queryValue({ value }) : string {
175
- // $FlowFixMe
176
- const { country } = value;
177
- return country;
178
- },
179
- value: getLocale
180
- },
181
-
182
- storageState: {
183
- type: 'object',
184
- value: () => storageState
185
- },
186
-
187
- sessionState: {
188
- type: 'object',
189
- value: () => sessionState
190
- },
191
-
192
- partnerAttributionID: {
193
- type: 'string',
194
- required: false,
195
- value: getPartnerAttributionID
196
- }
197
- }
198
- });
30
+ export function getPaymentFieldsComponent(): PaymentFieldsComponent {
31
+ return inlineMemoize(getPaymentFieldsComponent, () => {
32
+ return create({
33
+ tag: "paypal-fields",
34
+ url: () =>
35
+ `${getPayPalDomain()}${__PAYPAL_CHECKOUT__.__URI__.__PAYMENT_FIELDS__}`,
36
+
37
+ domain: getPayPalDomainRegex(),
38
+
39
+ autoResize: {
40
+ width: false,
41
+ height: true,
42
+ element: "body",
43
+ },
44
+
45
+ dimensions: {
46
+ width: "100%",
47
+ height: "300px",
48
+ },
49
+
50
+ logger: getLogger(),
51
+
52
+ containerTemplate: ({
53
+ props,
54
+ doc,
55
+ uid,
56
+ frame,
57
+ prerenderFrame,
58
+ event,
59
+ }) => {
60
+ return (
61
+ <PaymentFieldsContainer
62
+ uid={uid}
63
+ frame={frame}
64
+ prerenderFrame={prerenderFrame}
65
+ event={event}
66
+ nonce={props.nonce}
67
+ />
68
+ ).render(dom({ doc }));
69
+ },
70
+
71
+ prerenderTemplate: ({ props, doc }) => {
72
+ return (<PaymentFieldsPrerender nonce={props.nonce} />).render(
73
+ dom({ doc })
74
+ );
75
+ },
76
+
77
+ attributes: {
78
+ iframe: {
79
+ scrolling: "no",
80
+ },
81
+ },
82
+
83
+ props: {
84
+ fields: {
85
+ type: "object",
86
+ queryParam: true,
87
+ required: false,
88
+ decorate: ({ value }) => value,
89
+ default: () => ({}),
90
+ },
91
+
92
+ style: {
93
+ type: "object",
94
+ queryParam: true,
95
+ required: false,
96
+ decorate: ({ value }) => value,
97
+ default: () => ({}),
98
+ },
99
+
100
+ sdkMeta: {
101
+ type: "string",
102
+ queryParam: true,
103
+ sendToChild: false,
104
+ value: getSDKMeta,
105
+ },
106
+
107
+ clientID: {
108
+ type: "string",
109
+ queryParam: true,
110
+ value: getClientID,
111
+ },
112
+
113
+ fundingSource: {
114
+ type: "string",
115
+ queryParam: true,
116
+ required: true,
117
+ },
118
+
119
+ correlationID: {
120
+ type: "string",
121
+ required: false,
122
+ value: getCorrelationID,
123
+ },
124
+
125
+ sessionID: {
126
+ type: "string",
127
+ value: getSessionID,
128
+ queryParam: true,
129
+ required: false,
130
+ },
131
+
132
+ fieldsSessionID: {
133
+ type: "string",
134
+ value: uniqueID,
135
+ queryParam: true,
136
+ },
137
+
138
+ env: {
139
+ type: "string",
140
+ queryParam: true,
141
+ value: getEnv,
142
+ },
143
+
144
+ onInit: {
145
+ type: "function",
146
+ required: false,
147
+ },
148
+
149
+ onError: {
150
+ type: "function",
151
+ required: false,
152
+ },
153
+
154
+ onContinue: {
155
+ type: "function",
156
+ required: false,
157
+ },
158
+
159
+ onClose: {
160
+ type: "function",
161
+ required: false,
162
+ },
163
+
164
+ showActionButtons: {
165
+ type: "boolean",
166
+ queryParam: true,
167
+ required: false,
168
+ },
169
+
170
+ onFieldsClose: {
171
+ type: "function",
172
+ required: false,
173
+ },
174
+
175
+ buyerCountry: {
176
+ type: "string",
177
+ queryParam: true,
178
+ required: false,
179
+ default: getBuyerCountry,
180
+ },
181
+
182
+ locale: {
183
+ type: "object",
184
+ queryParam: "locale.x",
185
+ allowDelegate: true,
186
+ queryValue({ value }): string {
187
+ // $FlowFixMe
188
+ const { lang, country } = value;
189
+ return `${lang}_${country}`;
190
+ },
191
+ value: getLocale,
192
+ },
193
+
194
+ country: {
195
+ type: "object",
196
+ queryParam: "country.x",
197
+ allowDelegate: true,
198
+ queryValue({ value }): string {
199
+ // $FlowFixMe
200
+ const { country } = value;
201
+ return country;
202
+ },
203
+ value: getLocale,
204
+ },
205
+
206
+ storageState: {
207
+ type: "object",
208
+ value: () => storageState,
209
+ },
210
+
211
+ sessionState: {
212
+ type: "object",
213
+ value: () => sessionState,
214
+ },
215
+
216
+ partnerAttributionID: {
217
+ type: "string",
218
+ required: false,
219
+ value: getPartnerAttributionID,
220
+ },
221
+ },
199
222
  });
223
+ });
200
224
  }
@@ -1,66 +1,75 @@
1
1
  /* @flow */
2
2
  /** @jsx node */
3
3
 
4
- import { destroyElement, toCSS, type EventEmitterType } from '@krakenjs/belter/src';
5
- import { node, type ChildType } from '@krakenjs/jsx-pragmatic/src';
6
- import { EVENT } from '@krakenjs/zoid/src';
4
+ import {
5
+ destroyElement,
6
+ toCSS,
7
+ type EventEmitterType,
8
+ } from "@krakenjs/belter/src";
9
+ import { node, type ChildType } from "@krakenjs/jsx-pragmatic/src";
10
+ import { EVENT } from "@krakenjs/zoid/src";
7
11
 
8
12
  const CLASS = {
9
- VISIBLE: 'visible',
10
- INVISIBLE: 'invisible',
11
- COMPONENT_FRAME: 'component-frame',
12
- PRERENDER_FRAME: 'prerender-frame'
13
+ VISIBLE: "visible",
14
+ INVISIBLE: "invisible",
15
+ COMPONENT_FRAME: "component-frame",
16
+ PRERENDER_FRAME: "prerender-frame",
13
17
  };
14
18
 
15
19
  type PaymentFieldsContainerOptions = {|
16
- uid : string,
17
- frame : ?HTMLIFrameElement,
18
- prerenderFrame : ?HTMLIFrameElement,
19
- event : EventEmitterType,
20
- nonce? : ?string
20
+ uid: string,
21
+ frame: ?HTMLIFrameElement,
22
+ prerenderFrame: ?HTMLIFrameElement,
23
+ event: EventEmitterType,
24
+ nonce?: ?string,
21
25
  |};
22
26
 
23
- export function PaymentFieldsContainer({ uid, frame, prerenderFrame, event, nonce } : PaymentFieldsContainerOptions) : ?ChildType {
24
-
25
- if (!frame || !prerenderFrame) {
26
- throw new Error(`Expected frame and prerenderframe`);
27
- }
28
-
29
- frame.classList.add(CLASS.COMPONENT_FRAME);
30
- prerenderFrame.classList.add(CLASS.PRERENDER_FRAME);
31
-
32
- frame.classList.add(CLASS.INVISIBLE);
33
- prerenderFrame.classList.add(CLASS.VISIBLE);
34
-
35
- event.on(EVENT.RENDERED, () => {
36
- prerenderFrame.classList.remove(CLASS.VISIBLE);
37
- prerenderFrame.classList.add(CLASS.INVISIBLE);
38
-
39
- frame.classList.remove(CLASS.INVISIBLE);
40
- frame.classList.add(CLASS.VISIBLE);
41
-
42
- setTimeout(() => {
43
- destroyElement(prerenderFrame);
44
- }, 1000);
27
+ export function PaymentFieldsContainer({
28
+ uid,
29
+ frame,
30
+ prerenderFrame,
31
+ event,
32
+ nonce,
33
+ }: PaymentFieldsContainerOptions): ?ChildType {
34
+ if (!frame || !prerenderFrame) {
35
+ throw new Error(`Expected frame and prerenderframe`);
36
+ }
37
+
38
+ frame.classList.add(CLASS.COMPONENT_FRAME);
39
+ prerenderFrame.classList.add(CLASS.PRERENDER_FRAME);
40
+
41
+ frame.classList.add(CLASS.INVISIBLE);
42
+ prerenderFrame.classList.add(CLASS.VISIBLE);
43
+
44
+ event.on(EVENT.RENDERED, () => {
45
+ prerenderFrame.classList.remove(CLASS.VISIBLE);
46
+ prerenderFrame.classList.add(CLASS.INVISIBLE);
47
+
48
+ frame.classList.remove(CLASS.INVISIBLE);
49
+ frame.classList.add(CLASS.VISIBLE);
50
+
51
+ setTimeout(() => {
52
+ destroyElement(prerenderFrame);
53
+ }, 1000);
54
+ });
55
+
56
+ const setupAutoResize = (el) => {
57
+ event.on(EVENT.RESIZE, ({ width: newWidth, height: newHeight }) => {
58
+ if (typeof newWidth === "number") {
59
+ el.style.width = toCSS(newWidth);
60
+ }
61
+
62
+ if (typeof newHeight === "number") {
63
+ el.style.height = toCSS(newHeight);
64
+ }
45
65
  });
66
+ };
46
67
 
47
- const setupAutoResize = (el) => {
48
- event.on(EVENT.RESIZE, ({ width: newWidth, height: newHeight }) => {
49
- if (typeof newWidth === 'number') {
50
- el.style.width = toCSS(newWidth);
51
- }
52
-
53
- if (typeof newHeight === 'number') {
54
- el.style.height = toCSS(newHeight);
55
- }
56
- });
57
- };
58
-
59
- const element = (
60
- <div id={ uid } onRender={ setupAutoResize }>
61
- <style nonce={ nonce }>
62
- {`
63
- #${ uid } {
68
+ const element = (
69
+ <div id={uid} onRender={setupAutoResize}>
70
+ <style nonce={nonce}>
71
+ {`
72
+ #${uid} {
64
73
  position: relative;
65
74
  display: inline-block;
66
75
  width: 100%;
@@ -73,18 +82,18 @@ export function PaymentFieldsContainer({ uid, frame, prerenderFrame, event, nonc
73
82
  }
74
83
 
75
84
  @media only screen and (min-width: 0px) {
76
- #${ uid } {
85
+ #${uid} {
77
86
  min-height: 91px;
78
87
  }
79
88
  }
80
89
 
81
90
  @media only screen and (min-width: 600px) {
82
- #${ uid } {
91
+ #${uid} {
83
92
  min-height: 91px;
84
93
  }
85
94
  }
86
95
 
87
- #${ uid } > iframe {
96
+ #${uid} > iframe {
88
97
  position: absolute;
89
98
  top: 0;
90
99
  left: 0;
@@ -92,30 +101,30 @@ export function PaymentFieldsContainer({ uid, frame, prerenderFrame, event, nonc
92
101
  height: 100%;
93
102
  }
94
103
 
95
- #${ uid } > iframe.${ CLASS.COMPONENT_FRAME } {
104
+ #${uid} > iframe.${CLASS.COMPONENT_FRAME} {
96
105
  z-index: 100;
97
106
  }
98
107
 
99
- #${ uid } > iframe.${ CLASS.PRERENDER_FRAME } {
108
+ #${uid} > iframe.${CLASS.PRERENDER_FRAME} {
100
109
  transition: opacity .2s linear;
101
110
  z-index: 200;
102
111
  }
103
112
 
104
- #${ uid } > iframe.${ CLASS.VISIBLE } {
113
+ #${uid} > iframe.${CLASS.VISIBLE} {
105
114
  opacity: 1;
106
115
  }
107
116
 
108
- #${ uid } > iframe.${ CLASS.INVISIBLE } {
117
+ #${uid} > iframe.${CLASS.INVISIBLE} {
109
118
  opacity: 0;
110
119
  pointer-events: none;
111
120
  }
112
121
  `}
113
- </style>
122
+ </style>
114
123
 
115
- <node el={ frame } />
116
- <node el={ prerenderFrame } />
117
- </div>
118
- );
124
+ <node el={frame} />
125
+ <node el={prerenderFrame} />
126
+ </div>
127
+ );
119
128
 
120
- return element;
129
+ return element;
121
130
  }
@@ -1,3 +1,3 @@
1
1
  /* @flow */
2
2
 
3
- export * from './component';
3
+ export * from "./component";
@@ -1,19 +1,21 @@
1
1
  /* @flow */
2
2
  /** @jsx node */
3
3
 
4
- import { node, type ChildType } from '@krakenjs/jsx-pragmatic/src';
4
+ import { node, type ChildType } from "@krakenjs/jsx-pragmatic/src";
5
5
 
6
6
  type PrerenderedPaymentFieldsProps = {|
7
- nonce : ?string
7
+ nonce: ?string,
8
8
  |};
9
9
 
10
- export function PaymentFieldsPrerender({ nonce } : PrerenderedPaymentFieldsProps) : ChildType {
11
- return (
12
- <html>
13
- <body>
14
- <style
15
- nonce={ nonce }
16
- innerHTML={ `
10
+ export function PaymentFieldsPrerender({
11
+ nonce,
12
+ }: PrerenderedPaymentFieldsProps): ChildType {
13
+ return (
14
+ <html>
15
+ <body>
16
+ <style
17
+ nonce={nonce}
18
+ innerHTML={`
17
19
  html, body {
18
20
  padding: 0;
19
21
  margin: 0;
@@ -26,9 +28,9 @@ export function PaymentFieldsPrerender({ nonce } : PrerenderedPaymentFieldsProps
26
28
  position: relative;
27
29
  overflow: hidden;
28
30
  }
29
- ` }
30
- />
31
- </body>
32
- </html>
33
- );
31
+ `}
32
+ />
33
+ </body>
34
+ </html>
35
+ );
34
36
  }