@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
@@ -1,85 +1,101 @@
1
1
  /* @flow */
2
2
  /** @jsx node */
3
- import { LOGO_CLASS } from '@paypal/sdk-logos/src';
4
- import { node, Fragment, type ChildType } from '@krakenjs/jsx-pragmatic/src';
3
+ import { LOGO_CLASS } from "@paypal/sdk-logos/src";
4
+ import { node, Fragment, type ChildType } from "@krakenjs/jsx-pragmatic/src";
5
5
 
6
- import { CLASS } from '../../../constants';
7
- import { BUTTON_SIZE_STYLE } from '../config';
6
+ import { CLASS } from "../../../constants";
7
+ import { BUTTON_SIZE_STYLE } from "../config";
8
8
 
9
- import { type ContentOptions } from './types';
9
+ import { type ContentOptions } from "./types";
10
10
 
11
11
  type DivideLogoAnimationProps = {|
12
- paypalLabelContainerElement : Object,
13
- paypalLogoStartingLeftPosition : string,
14
- designContainer : Object
12
+ paypalLabelContainerElement: Object,
13
+ paypalLogoStartingLeftPosition: string,
14
+ designContainer: Object,
15
15
  |};
16
16
 
17
-
18
17
  export const DIVIDE_LOGO_CONFIG = {
19
- min: BUTTON_SIZE_STYLE.large.minWidth,
20
- max: BUTTON_SIZE_STYLE.huge.maxWidth,
21
- cssUtilClasses: {
22
- DOM_READY: CLASS.DOM_READY,
23
- PAYPAL_LOGO: LOGO_CLASS.LOGO,
24
- PAYPAL_BUTTON_LABEL: CLASS.BUTTON_LABEL,
25
- PAYPAL_LOGO_PP: CLASS.LOGO_PP
26
- }
18
+ min: BUTTON_SIZE_STYLE.large.minWidth,
19
+ max: BUTTON_SIZE_STYLE.huge.maxWidth,
20
+ cssUtilClasses: {
21
+ DOM_READY: CLASS.DOM_READY,
22
+ PAYPAL_LOGO: LOGO_CLASS.LOGO,
23
+ PAYPAL_BUTTON_LABEL: CLASS.BUTTON_LABEL,
24
+ PAYPAL_LOGO_PP: CLASS.LOGO_PP,
25
+ },
27
26
  };
28
27
 
29
28
  // Returns props necessary to render the animation as long as they are valid
30
- export const getDivideLogoProps = function (document : Object, configuration : Object) : DivideLogoAnimationProps | null {
31
- const { PAYPAL_BUTTON_LABEL, PAYPAL_LOGO, PAYPAL_LOGO_PP } = configuration.cssUtilClasses;
32
-
33
- const designContainer = (document && document.querySelector('.personalized-design-container')) || null;
34
- if (!designContainer) {
35
- return null;
36
- }
37
-
38
- // return null if animation should not be played for the button size
39
- const designContainerWidth = designContainer.offsetWidth;
40
- if (designContainerWidth < configuration.min || designContainerWidth > configuration.max) {
41
- return null;
42
- }
43
-
44
- // get the label container that animation will be applied to
45
- const paypalLabelContainerElement = designContainer.querySelector(`.${ PAYPAL_BUTTON_LABEL }`) || null;
46
- if (!paypalLabelContainerElement) {
47
- return null;
48
- }
49
-
50
- // get starting position for element so it doesn't flicker when animation begins
51
- const paypalLogoElement = (paypalLabelContainerElement && paypalLabelContainerElement.querySelector(`.${ PAYPAL_LOGO }.${ PAYPAL_LOGO_PP }`)) || null;
52
- if (!paypalLogoElement) {
53
- return null;
54
- }
55
- const paypalLogoStartingLeftPosition = `${ (paypalLogoElement.offsetLeft / paypalLabelContainerElement.offsetWidth) * 100 }%`;
56
-
57
- return {
58
- paypalLabelContainerElement,
59
- paypalLogoStartingLeftPosition,
60
- designContainer
61
- };
29
+ export const getDivideLogoProps = function (
30
+ document: Object,
31
+ configuration: Object
32
+ ): DivideLogoAnimationProps | null {
33
+ const { PAYPAL_BUTTON_LABEL, PAYPAL_LOGO, PAYPAL_LOGO_PP } =
34
+ configuration.cssUtilClasses;
35
+
36
+ const designContainer =
37
+ (document && document.querySelector(".personalized-design-container")) ||
38
+ null;
39
+ if (!designContainer) {
40
+ return null;
41
+ }
42
+
43
+ // return null if animation should not be played for the button size
44
+ const designContainerWidth = designContainer.offsetWidth;
45
+ if (
46
+ designContainerWidth < configuration.min ||
47
+ designContainerWidth > configuration.max
48
+ ) {
49
+ return null;
50
+ }
51
+
52
+ // get the label container that animation will be applied to
53
+ const paypalLabelContainerElement =
54
+ designContainer.querySelector(`.${PAYPAL_BUTTON_LABEL}`) || null;
55
+ if (!paypalLabelContainerElement) {
56
+ return null;
57
+ }
58
+
59
+ // get starting position for element so it doesn't flicker when animation begins
60
+ const paypalLogoElement =
61
+ (paypalLabelContainerElement &&
62
+ paypalLabelContainerElement.querySelector(
63
+ `.${PAYPAL_LOGO}.${PAYPAL_LOGO_PP}`
64
+ )) ||
65
+ null;
66
+ if (!paypalLogoElement) {
67
+ return null;
68
+ }
69
+ const paypalLogoStartingLeftPosition = `${
70
+ (paypalLogoElement.offsetLeft / paypalLabelContainerElement.offsetWidth) *
71
+ 100
72
+ }%`;
73
+
74
+ return {
75
+ paypalLabelContainerElement,
76
+ paypalLogoStartingLeftPosition,
77
+ designContainer,
78
+ };
62
79
  };
63
80
 
64
- export function getDivideLogoAnimation(designProps : DivideLogoAnimationProps, configuration : Object) : void {
65
- const {
66
- min,
67
- max,
68
- cssUtilClasses: {
69
- DOM_READY,
70
- PAYPAL_LOGO,
71
- PAYPAL_LOGO_PP
72
- }
73
- } = configuration;
74
-
75
- const {
76
- paypalLabelContainerElement,
77
- paypalLogoStartingLeftPosition,
78
- designContainer
79
- } = designProps;
80
-
81
- const designCss = `
82
- .${ DOM_READY } .personalized-design-container img.${ PAYPAL_LOGO }.${ PAYPAL_LOGO_PP }{
81
+ export function getDivideLogoAnimation(
82
+ designProps: DivideLogoAnimationProps,
83
+ configuration: Object
84
+ ): void {
85
+ const {
86
+ min,
87
+ max,
88
+ cssUtilClasses: { DOM_READY, PAYPAL_LOGO, PAYPAL_LOGO_PP },
89
+ } = configuration;
90
+
91
+ const {
92
+ paypalLabelContainerElement,
93
+ paypalLogoStartingLeftPosition,
94
+ designContainer,
95
+ } = designProps;
96
+
97
+ const designCss = `
98
+ .${DOM_READY} .personalized-design-container img.${PAYPAL_LOGO}.${PAYPAL_LOGO_PP}{
83
99
  animation: 3s divide-logo-animation-left-side 2s infinite alternate;
84
100
  }
85
101
 
@@ -90,11 +106,11 @@ export function getDivideLogoAnimation(designProps : DivideLogoAnimationProps, c
90
106
  @keyframes divide-logo-animation-left-side {
91
107
  0% {
92
108
  position: fixed;
93
- left: ${ paypalLogoStartingLeftPosition };
109
+ left: ${paypalLogoStartingLeftPosition};
94
110
  }
95
111
  33% {
96
112
  position: fixed;
97
- left: ${ paypalLogoStartingLeftPosition };
113
+ left: ${paypalLogoStartingLeftPosition};
98
114
  }
99
115
  66% {
100
116
  position: fixed;
@@ -130,35 +146,45 @@ export function getDivideLogoAnimation(designProps : DivideLogoAnimationProps, c
130
146
  }
131
147
  `;
132
148
 
133
- if (paypalLabelContainerElement) {
134
- const style = document.createElement('style');
149
+ if (paypalLabelContainerElement) {
150
+ const style = document.createElement("style");
151
+ paypalLabelContainerElement.appendChild(style);
152
+ style.appendChild(document.createTextNode(designCss));
153
+
154
+ window.addEventListener("resize", () => {
155
+ // Remove animation if size limit broken
156
+ if (
157
+ (designContainer.offsetWidth > max ||
158
+ designContainer.offsetWidth < min) &&
159
+ paypalLabelContainerElement.contains(style)
160
+ ) {
161
+ paypalLabelContainerElement.removeChild(style);
162
+ } else if (
163
+ (designContainer.offsetWidth <= max ||
164
+ designContainer.offsetWidth >= min) &&
165
+ !paypalLabelContainerElement.contains(style)
166
+ ) {
135
167
  paypalLabelContainerElement.appendChild(style);
136
- style.appendChild(document.createTextNode(designCss));
137
-
138
-
139
- window.addEventListener('resize', () => {
140
- // Remove animation if size limit broken
141
- if (
142
- (designContainer.offsetWidth > max || designContainer.offsetWidth < min)
143
- && paypalLabelContainerElement.contains(style)
144
- ) {
145
- paypalLabelContainerElement.removeChild(style);
146
- } else if (
147
- (designContainer.offsetWidth <= max || designContainer.offsetWidth >= min)
148
- && !paypalLabelContainerElement.contains(style)
149
- ) {
150
- paypalLabelContainerElement.appendChild(style);
151
- }
152
- });
153
- }
168
+ }
169
+ });
170
+ }
154
171
  }
155
172
 
156
- export function DivideLogoTextComponent({ designLabelText } : ContentOptions) : ChildType {
157
- return (
158
- <Fragment>
159
- <div class={ 'personalized-label-container' } data-design-experiment='104519'> <span>{designLabelText}</span></div>
160
- <style innerHTML={ `
161
- .${ CLASS.DOM_READY } .personalized-design-container img.${ LOGO_CLASS.LOGO }{
173
+ export function DivideLogoTextComponent({
174
+ designLabelText,
175
+ }: ContentOptions): ChildType {
176
+ return (
177
+ <Fragment>
178
+ <div
179
+ class={"personalized-label-container"}
180
+ data-design-experiment="104519"
181
+ >
182
+ {" "}
183
+ <span>{designLabelText}</span>
184
+ </div>
185
+ <style
186
+ innerHTML={`
187
+ .${CLASS.DOM_READY} .personalized-design-container img.${LOGO_CLASS.LOGO}{
162
188
  position: relative;
163
189
  }
164
190
 
@@ -175,7 +201,9 @@ export function DivideLogoTextComponent({ designLabelText } : ContentOptions) :
175
201
  flex-direction: column;
176
202
  justify-content: space-around;
177
203
  }
178
- ` } />;
179
- </Fragment>
180
- );
204
+ `}
205
+ />
206
+ ;
207
+ </Fragment>
208
+ );
181
209
  }
@@ -1,92 +1,95 @@
1
1
  /* @flow */
2
- import { type ChildType } from '@krakenjs/jsx-pragmatic/src';
2
+ import { type ChildType } from "@krakenjs/jsx-pragmatic/src";
3
3
 
4
- import { type Personalization } from '../props';
4
+ import { type Personalization } from "../props";
5
5
 
6
- import { getDesignScript } from './script';
7
- import { type ButtonDesignOutputParams } from './types';
8
- import { ControlDesignComponent } from './control';
6
+ import { getDesignScript } from "./script";
7
+ import { type ButtonDesignOutputParams } from "./types";
8
+ import { ControlDesignComponent } from "./control";
9
9
  import {
10
- getDivideLogoAnimation,
11
- getDivideLogoProps,
12
- DIVIDE_LOGO_CONFIG,
13
- DivideLogoTextComponent
14
- } from './divideLogoAnimation';
10
+ getDivideLogoAnimation,
11
+ getDivideLogoProps,
12
+ DIVIDE_LOGO_CONFIG,
13
+ DivideLogoTextComponent,
14
+ } from "./divideLogoAnimation";
15
15
  import {
16
- getInlineLabelTextDesign,
17
- getValidInlineLogoTextProps,
18
- INLINE_LOGO_TEXT_CONFIG,
19
- InlineLogoTextComponent
20
- } from './inlineLogoTextDesign';
16
+ getInlineLabelTextDesign,
17
+ getValidInlineLogoTextProps,
18
+ INLINE_LOGO_TEXT_CONFIG,
19
+ InlineLogoTextComponent,
20
+ } from "./inlineLogoTextDesign";
21
21
 
22
- const DESIGN_MAP : Object = {
23
- 'run-divide-logo-animation': {
24
- designFn: getDivideLogoAnimation,
25
- getValidDesignProps: getDivideLogoProps,
26
- designConfig: DIVIDE_LOGO_CONFIG,
27
- ButtonDesignComponent: DivideLogoTextComponent
28
- },
29
- 'run-add-label-text-next-to-logo-design': {
30
- designFn: getInlineLabelTextDesign,
31
- getValidDesignProps: getValidInlineLogoTextProps,
32
- designConfig: INLINE_LOGO_TEXT_CONFIG,
33
- ButtonDesignComponent: InlineLogoTextComponent
34
- }
22
+ const DESIGN_MAP: Object = {
23
+ "run-divide-logo-animation": {
24
+ designFn: getDivideLogoAnimation,
25
+ getValidDesignProps: getDivideLogoProps,
26
+ designConfig: DIVIDE_LOGO_CONFIG,
27
+ ButtonDesignComponent: DivideLogoTextComponent,
28
+ },
29
+ "run-add-label-text-next-to-logo-design": {
30
+ designFn: getInlineLabelTextDesign,
31
+ getValidDesignProps: getValidInlineLogoTextProps,
32
+ designConfig: INLINE_LOGO_TEXT_CONFIG,
33
+ ButtonDesignComponent: InlineLogoTextComponent,
34
+ },
35
35
  };
36
36
 
37
- const CONTROL_MAP : Object = {
38
- 'large-button-design-control': '104519',
39
- 'small-button-design-control': '104530'
37
+ const CONTROL_MAP: Object = {
38
+ "large-button-design-control": "104519",
39
+ "small-button-design-control": "104530",
40
40
  };
41
41
 
42
- export function getButtonDesign(personalization : ?Personalization) : ButtonDesignOutputParams | Object {
42
+ export function getButtonDesign(
43
+ personalization: ?Personalization
44
+ ): ButtonDesignOutputParams | Object {
45
+ // check valid personalization
46
+ if (
47
+ __WEB__ ||
48
+ !personalization ||
49
+ typeof personalization !== "object" ||
50
+ !personalization.buttonDesign
51
+ ) {
52
+ return {};
53
+ }
43
54
 
44
- // check valid personalization
45
- if (
46
- __WEB__
47
- || !personalization
48
- || typeof personalization !== 'object'
49
- || !personalization.buttonDesign
50
- ) {
51
- return {};
52
- }
53
-
54
- const {
55
- buttonDesign: {
56
- id: designId = '',
57
- text: designLabelText = 'Safe and easy way to pay'
58
- } = {}
59
- } = personalization;
55
+ const {
56
+ buttonDesign: {
57
+ id: designId = "",
58
+ text: designLabelText = "Safe and easy way to pay",
59
+ } = {},
60
+ } = personalization;
60
61
 
61
- // Return fragment with data-design-experiment tag for logging
62
- if (CONTROL_MAP[designId]) {
63
- const buttonDesignComponent : ChildType = ControlDesignComponent(CONTROL_MAP[designId]);
62
+ // Return fragment with data-design-experiment tag for logging
63
+ if (CONTROL_MAP[designId]) {
64
+ const buttonDesignComponent: ChildType = ControlDesignComponent(
65
+ CONTROL_MAP[designId]
66
+ );
64
67
 
65
- return {
66
- buttonDesignContainerClass: '',
67
- buttonDesignScript: '',
68
- buttonDesignComponent
69
- };
70
- }
71
-
72
- if (!DESIGN_MAP[designId]) {
73
- return {};
74
- }
68
+ return {
69
+ buttonDesignContainerClass: "",
70
+ buttonDesignScript: "",
71
+ buttonDesignComponent,
72
+ };
73
+ }
75
74
 
76
- const {
77
- designFn,
78
- getValidDesignProps,
79
- designConfig,
80
- ButtonDesignComponent
81
- } = DESIGN_MAP[designId];
75
+ if (!DESIGN_MAP[designId]) {
76
+ return {};
77
+ }
82
78
 
83
- const designContent = { designLabelText };
84
- const buttonDesignScript : string = getDesignScript(designFn, getValidDesignProps, designConfig);
85
- const buttonDesignComponent : ChildType = ButtonDesignComponent(designContent);
79
+ const { designFn, getValidDesignProps, designConfig, ButtonDesignComponent } =
80
+ DESIGN_MAP[designId];
86
81
 
87
- return {
88
- buttonDesignContainerClass: 'personalized-design-container',
89
- buttonDesignScript,
90
- buttonDesignComponent
91
- };
82
+ const designContent = { designLabelText };
83
+ const buttonDesignScript: string = getDesignScript(
84
+ designFn,
85
+ getValidDesignProps,
86
+ designConfig
87
+ );
88
+ const buttonDesignComponent: ChildType = ButtonDesignComponent(designContent);
89
+
90
+ return {
91
+ buttonDesignContainerClass: "personalized-design-container",
92
+ buttonDesignScript,
93
+ buttonDesignComponent,
94
+ };
92
95
  }
@@ -1,72 +1,79 @@
1
1
  /* @flow */
2
2
  /** @jsx node */
3
- import { LOGO_CLASS } from '@paypal/sdk-logos/src';
4
- import { node, Fragment, type ChildType } from '@krakenjs/jsx-pragmatic/src';
3
+ import { LOGO_CLASS } from "@paypal/sdk-logos/src";
4
+ import { node, Fragment, type ChildType } from "@krakenjs/jsx-pragmatic/src";
5
5
 
6
- import { BUTTON_SIZE_STYLE } from '../config';
7
- import { CLASS } from '../../../constants';
6
+ import { BUTTON_SIZE_STYLE } from "../config";
7
+ import { CLASS } from "../../../constants";
8
8
 
9
- import { type ContentOptions } from './types';
9
+ import { type ContentOptions } from "./types";
10
10
 
11
11
  type InlineLogoTextProps = {|
12
- paypalLabelContainerElement : Object,
13
- designContainer : Object
12
+ paypalLabelContainerElement: Object,
13
+ designContainer: Object,
14
14
  |};
15
15
 
16
16
  export const INLINE_LOGO_TEXT_CONFIG = {
17
- cssUtilClasses: {
18
- PAYPAL_LABEL_CONTAINER: CLASS.BUTTON_LABEL,
19
- PAYPAL_LOGO: LOGO_CLASS.LOGO,
20
- DOM_READY: CLASS.DOM_READY
21
- },
22
- min: BUTTON_SIZE_STYLE.large.minWidth,
23
- max: BUTTON_SIZE_STYLE.huge.maxWidth
17
+ cssUtilClasses: {
18
+ PAYPAL_LABEL_CONTAINER: CLASS.BUTTON_LABEL,
19
+ PAYPAL_LOGO: LOGO_CLASS.LOGO,
20
+ DOM_READY: CLASS.DOM_READY,
21
+ },
22
+ min: BUTTON_SIZE_STYLE.large.minWidth,
23
+ max: BUTTON_SIZE_STYLE.huge.maxWidth,
24
24
  };
25
25
 
26
- export const getValidInlineLogoTextProps = function (document : Object, configuration : Object) : InlineLogoTextProps | null {
27
- const { PAYPAL_LABEL_CONTAINER } = configuration.cssUtilClasses;
28
-
29
-
30
- const designContainer = (document && document.querySelector('.personalized-design-container')) || null;
31
- if (!designContainer) {
32
- return null;
33
- }
34
-
35
- // Return null if design does not apply to button size
36
- const designContainerWidth = designContainer.offsetWidth;
37
- if (designContainerWidth < configuration.min || designContainerWidth > configuration.max) {
38
- return null;
39
- }
40
-
41
- // Return null if label element is not valid
42
- const paypalLabelContainerElement = (designContainer && designContainer.querySelector(`.${ PAYPAL_LABEL_CONTAINER }`)) || null;
43
- if (!paypalLabelContainerElement) {
44
- return null;
45
- }
46
-
47
- return {
48
- paypalLabelContainerElement,
49
- designContainer
50
- };
26
+ export const getValidInlineLogoTextProps = function (
27
+ document: Object,
28
+ configuration: Object
29
+ ): InlineLogoTextProps | null {
30
+ const { PAYPAL_LABEL_CONTAINER } = configuration.cssUtilClasses;
31
+
32
+ const designContainer =
33
+ (document && document.querySelector(".personalized-design-container")) ||
34
+ null;
35
+ if (!designContainer) {
36
+ return null;
37
+ }
38
+
39
+ // Return null if design does not apply to button size
40
+ const designContainerWidth = designContainer.offsetWidth;
41
+ if (
42
+ designContainerWidth < configuration.min ||
43
+ designContainerWidth > configuration.max
44
+ ) {
45
+ return null;
46
+ }
47
+
48
+ // Return null if label element is not valid
49
+ const paypalLabelContainerElement =
50
+ (designContainer &&
51
+ designContainer.querySelector(`.${PAYPAL_LABEL_CONTAINER}`)) ||
52
+ null;
53
+ if (!paypalLabelContainerElement) {
54
+ return null;
55
+ }
56
+
57
+ return {
58
+ paypalLabelContainerElement,
59
+ designContainer,
60
+ };
51
61
  };
52
62
 
53
- export const getInlineLabelTextDesign = function (designProps : InlineLogoTextProps, configuration : Object) : void {
54
- const {
55
- min,
56
- max,
57
- cssUtilClasses: {
58
- DOM_READY,
59
- PAYPAL_LOGO
60
- }
61
- } = configuration;
63
+ export const getInlineLabelTextDesign = function (
64
+ designProps: InlineLogoTextProps,
65
+ configuration: Object
66
+ ): void {
67
+ const {
68
+ min,
69
+ max,
70
+ cssUtilClasses: { DOM_READY, PAYPAL_LOGO },
71
+ } = configuration;
62
72
 
63
- const {
64
- paypalLabelContainerElement,
65
- designContainer
66
- } = designProps;
73
+ const { paypalLabelContainerElement, designContainer } = designProps;
67
74
 
68
- const designCss = `
69
- .${ DOM_READY } .personalized-design-container img.${ PAYPAL_LOGO }{
75
+ const designCss = `
76
+ .${DOM_READY} .personalized-design-container img.${PAYPAL_LOGO}{
70
77
  position: fixed;
71
78
  left: 0%;
72
79
  }
@@ -78,34 +85,45 @@ export const getInlineLabelTextDesign = function (designProps : InlineLogoTextPr
78
85
  }
79
86
  `;
80
87
 
81
- if (paypalLabelContainerElement) {
82
- const style = document.createElement('style');
88
+ if (paypalLabelContainerElement) {
89
+ const style = document.createElement("style");
90
+ paypalLabelContainerElement.appendChild(style);
91
+ style.appendChild(document.createTextNode(designCss));
92
+
93
+ window.addEventListener("resize", () => {
94
+ // Remove animation if size limit broken
95
+ if (
96
+ (designContainer.offsetWidth > max ||
97
+ designContainer.offsetWidth < min) &&
98
+ paypalLabelContainerElement.contains(style)
99
+ ) {
100
+ paypalLabelContainerElement.removeChild(style);
101
+ } else if (
102
+ (designContainer.offsetWidth <= max ||
103
+ designContainer.offsetWidth >= min) &&
104
+ !paypalLabelContainerElement.contains(style)
105
+ ) {
83
106
  paypalLabelContainerElement.appendChild(style);
84
- style.appendChild(document.createTextNode(designCss));
85
-
86
- window.addEventListener('resize', () => {
87
- // Remove animation if size limit broken
88
- if (
89
- (designContainer.offsetWidth > max || designContainer.offsetWidth < min)
90
- && paypalLabelContainerElement.contains(style)
91
- ) {
92
- paypalLabelContainerElement.removeChild(style);
93
- } else if (
94
- (designContainer.offsetWidth <= max || designContainer.offsetWidth >= min)
95
- && !paypalLabelContainerElement.contains(style)
96
- ) {
97
- paypalLabelContainerElement.appendChild(style);
98
- }
99
- });
100
- }
107
+ }
108
+ });
109
+ }
101
110
  };
102
111
 
103
- export function InlineLogoTextComponent({ designLabelText } : ContentOptions) : ChildType {
104
- return (
105
- <Fragment>
106
- <div class={ 'personalized-label-container' } data-design-experiment="104519"> <span>{designLabelText}</span></div>
107
- <style innerHTML={ `
108
- .${ CLASS.DOM_READY } .personalized-design-container img.${ LOGO_CLASS.LOGO }{
112
+ export function InlineLogoTextComponent({
113
+ designLabelText,
114
+ }: ContentOptions): ChildType {
115
+ return (
116
+ <Fragment>
117
+ <div
118
+ class={"personalized-label-container"}
119
+ data-design-experiment="104519"
120
+ >
121
+ {" "}
122
+ <span>{designLabelText}</span>
123
+ </div>
124
+ <style
125
+ innerHTML={`
126
+ .${CLASS.DOM_READY} .personalized-design-container img.${LOGO_CLASS.LOGO}{
109
127
  position: relative;
110
128
  }
111
129
 
@@ -122,7 +140,9 @@ export function InlineLogoTextComponent({ designLabelText } : ContentOptions) :
122
140
  flex-direction: column;
123
141
  justify-content: space-around;
124
142
  }
125
- ` } />;
126
- </Fragment>
127
- );
143
+ `}
144
+ />
145
+ ;
146
+ </Fragment>
147
+ );
128
148
  }