@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.
- package/README.md +8 -0
- package/__sdk__.js +72 -76
- package/dist/button.js +1 -1
- package/globals.js +28 -30
- package/package.json +6 -4
- package/src/constants/button.js +37 -36
- package/src/constants/class.js +32 -30
- package/src/constants/index.js +3 -3
- package/src/constants/misc.js +14 -12
- package/src/declarations.js +19 -19
- package/src/funding/applepay/config.jsx +51 -50
- package/src/funding/applepay/index.js +1 -1
- package/src/funding/applepay/style.scoped.scss +1 -1
- package/src/funding/applepay/template.jsx +16 -11
- package/src/funding/bancontact/config.jsx +48 -37
- package/src/funding/bancontact/index.js +1 -2
- package/src/funding/blik/config.jsx +48 -37
- package/src/funding/blik/index.js +1 -2
- package/src/funding/boleto/config.jsx +50 -39
- package/src/funding/boleto/index.js +1 -2
- package/src/funding/card/amex/config.js +9 -8
- package/src/funding/card/amex/index.js +1 -2
- package/src/funding/card/config.jsx +246 -177
- package/src/funding/card/discover/config.js +9 -7
- package/src/funding/card/discover/index.js +1 -2
- package/src/funding/card/elo/config.js +6 -7
- package/src/funding/card/elo/index.js +1 -2
- package/src/funding/card/hiper/config.js +9 -7
- package/src/funding/card/hiper/index.js +1 -2
- package/src/funding/card/index.js +1 -1
- package/src/funding/card/jcb/config.js +6 -7
- package/src/funding/card/jcb/index.js +1 -2
- package/src/funding/card/mastercard/config.js +9 -7
- package/src/funding/card/mastercard/index.js +1 -2
- package/src/funding/card/visa/config.js +9 -7
- package/src/funding/card/visa/index.js +1 -2
- package/src/funding/common.jsx +242 -216
- package/src/funding/config.js +212 -65
- package/src/funding/content.jsx +1946 -337
- package/src/funding/credit/config.jsx +74 -57
- package/src/funding/credit/index.js +1 -2
- package/src/funding/eps/config.jsx +45 -37
- package/src/funding/eps/index.js +1 -2
- package/src/funding/funding.js +193 -100
- package/src/funding/giropay/config.jsx +48 -38
- package/src/funding/giropay/index.js +1 -2
- package/src/funding/ideal/config.jsx +48 -37
- package/src/funding/ideal/index.js +1 -2
- package/src/funding/index.js +2 -2
- package/src/funding/itau/config.jsx +41 -41
- package/src/funding/itau/index.js +1 -1
- package/src/funding/maxima/config.jsx +25 -19
- package/src/funding/maxima/index.js +1 -2
- package/src/funding/mercadopago/config.jsx +48 -37
- package/src/funding/mercadopago/index.js +1 -2
- package/src/funding/multibanco/config.jsx +50 -39
- package/src/funding/multibanco/index.js +1 -2
- package/src/funding/mybank/config.jsx +48 -37
- package/src/funding/mybank/index.js +1 -2
- package/src/funding/oxxo/config.jsx +50 -39
- package/src/funding/oxxo/index.js +1 -2
- package/src/funding/p24/config.jsx +45 -37
- package/src/funding/p24/index.js +1 -2
- package/src/funding/paidy/config.jsx +50 -39
- package/src/funding/paidy/index.js +1 -1
- package/src/funding/paylater/config.jsx +118 -111
- package/src/funding/paylater/index.js +1 -2
- package/src/funding/paypal/config.jsx +44 -46
- package/src/funding/paypal/index.js +1 -2
- package/src/funding/paypal/style.scoped.scss +80 -74
- package/src/funding/paypal/template.jsx +450 -354
- package/src/funding/payu/config.jsx +50 -39
- package/src/funding/payu/index.js +1 -1
- package/src/funding/satispay/config.jsx +50 -39
- package/src/funding/satispay/index.js +1 -1
- package/src/funding/sepa/config.jsx +19 -13
- package/src/funding/sepa/index.js +1 -2
- package/src/funding/sofort/config.jsx +48 -37
- package/src/funding/sofort/index.js +1 -2
- package/src/funding/trustly/config.jsx +50 -39
- package/src/funding/trustly/index.js +1 -2
- package/src/funding/venmo/config.jsx +80 -75
- package/src/funding/venmo/index.js +1 -2
- package/src/funding/venmo/style.scoped.scss +30 -32
- package/src/funding/venmo/template.jsx +56 -57
- package/src/funding/verkkopankki/config.jsx +50 -39
- package/src/funding/verkkopankki/index.js +1 -1
- package/src/funding/wechatpay/config.jsx +48 -37
- package/src/funding/wechatpay/index.js +1 -2
- package/src/funding/zimpler/config.jsx +19 -13
- package/src/funding/zimpler/index.js +1 -2
- package/src/interface/button.js +60 -44
- package/src/interface/card-fields.js +11 -8
- package/src/interface/fields.js +7 -4
- package/src/interface/marks.js +4 -4
- package/src/interface/payment-fields.js +7 -4
- package/src/interface/wallet.js +4 -4
- package/src/lib/errors.js +7 -7
- package/src/lib/index.js +5 -5
- package/src/lib/isRTLLanguage.js +3 -3
- package/src/lib/perceived-latency-instrumentation.js +54 -36
- package/src/lib/security.js +21 -17
- package/src/lib/session.js +39 -35
- package/src/marks/component.jsx +114 -65
- package/src/marks/index.js +1 -2
- package/src/marks/template.jsx +79 -65
- package/src/types.js +48 -48
- package/src/ui/buttons/button.jsx +311 -249
- package/src/ui/buttons/buttonDesigns/control.jsx +3 -5
- package/src/ui/buttons/buttonDesigns/divideLogoAnimation.jsx +127 -99
- package/src/ui/buttons/buttonDesigns/index.js +78 -75
- package/src/ui/buttons/buttonDesigns/inlineLogoTextDesign.jsx +102 -82
- package/src/ui/buttons/buttonDesigns/script.jsx +24 -18
- package/src/ui/buttons/buttonDesigns/types.js +6 -7
- package/src/ui/buttons/buttons.jsx +318 -212
- package/src/ui/buttons/config.js +62 -59
- package/src/ui/buttons/content.jsx +304 -119
- package/src/ui/buttons/index.js +1 -1
- package/src/ui/buttons/menu-button/index.js +1 -1
- package/src/ui/buttons/menu-button/menu-button.jsx +29 -22
- package/src/ui/buttons/menu-button/menu-button.scoped.scss +16 -17
- package/src/ui/buttons/poweredBy.jsx +23 -23
- package/src/ui/buttons/props.js +680 -529
- package/src/ui/buttons/script.jsx +182 -160
- package/src/ui/buttons/spinner.jsx +4 -6
- package/src/ui/buttons/style.jsx +15 -14
- package/src/ui/buttons/styles/base.js +24 -16
- package/src/ui/buttons/styles/button.js +24 -22
- package/src/ui/buttons/styles/color.js +118 -118
- package/src/ui/buttons/styles/custom.js +30 -24
- package/src/ui/buttons/styles/index.js +1 -1
- package/src/ui/buttons/styles/labels.js +17 -13
- package/src/ui/buttons/styles/page.js +3 -3
- package/src/ui/buttons/styles/responsive.js +226 -118
- package/src/ui/buttons/tagline.jsx +53 -54
- package/src/ui/chevron.jsx +27 -16
- package/src/ui/index.js +3 -3
- package/src/ui/loading.jsx +25 -18
- package/src/ui/text/index.js +1 -1
- package/src/ui/text/style.scoped.scss +25 -26
- package/src/ui/text/text.jsx +42 -20
- package/src/ui/tracking.jsx +18 -11
- package/src/zoid/buttons/component.jsx +836 -684
- package/src/zoid/buttons/container.jsx +140 -107
- package/src/zoid/buttons/index.js +1 -1
- package/src/zoid/buttons/prerender.jsx +84 -64
- package/src/zoid/buttons/util.js +355 -254
- package/src/zoid/card-fields/component.jsx +581 -549
- package/src/zoid/card-fields/index.js +1 -1
- package/src/zoid/card-fields/prerender.jsx +20 -17
- package/src/zoid/card-form/component.js +155 -141
- package/src/zoid/card-form/index.js +1 -1
- package/src/zoid/checkout/component.jsx +314 -282
- package/src/zoid/checkout/config.js +2 -2
- package/src/zoid/checkout/content.js +190 -154
- package/src/zoid/checkout/hacks.js +31 -28
- package/src/zoid/checkout/index.js +2 -2
- package/src/zoid/checkout/props.js +27 -33
- package/src/zoid/installments/component.jsx +83 -70
- package/src/zoid/installments/index.js +1 -1
- package/src/zoid/installments/props.js +1 -1
- package/src/zoid/menu/component.jsx +53 -48
- package/src/zoid/menu/index.js +1 -1
- package/src/zoid/menu/props.js +1 -3
- package/src/zoid/modal/component.jsx +119 -106
- package/src/zoid/modal/index.js +1 -1
- package/src/zoid/modal/props.js +1 -3
- package/src/zoid/payment-fields/component.jsx +215 -191
- package/src/zoid/payment-fields/container.jsx +73 -64
- package/src/zoid/payment-fields/index.js +1 -1
- package/src/zoid/payment-fields/prerender.jsx +16 -14
- package/src/zoid/payment-fields/props.js +6 -6
- package/src/zoid/qr-code/component.jsx +131 -115
- package/src/zoid/qr-code/container.jsx +74 -68
- package/src/zoid/qr-code/index.js +1 -1
- package/src/zoid/qr-code/prerender.jsx +17 -12
- package/src/zoid/qr-code/types.js +2 -2
- package/src/zoid/wallet/component.jsx +298 -260
- package/src/zoid/wallet/container.jsx +73 -64
- package/src/zoid/wallet/index.js +1 -1
- package/src/zoid/wallet/prerender.jsx +14 -14
- package/src/zoid/wallet/props.js +4 -4
- package/src/actions/save/index.js +0 -40
- package/src/interface/actions.js +0 -14
- package/src/lib/getLogoCDNExperiment.js +0 -25
|
@@ -1,176 +1,198 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
/** @jsx node */
|
|
3
3
|
|
|
4
|
-
import { node, type ElementNode } from
|
|
5
|
-
|
|
6
|
-
export function getComponentScript() : () => void {
|
|
7
|
-
|
|
8
|
-
/* istanbul ignore next */
|
|
9
|
-
return () => {
|
|
10
|
-
|
|
11
|
-
const ATTRIBUTE = {
|
|
12
|
-
OPTIONAL: 'optional'
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const CLASS = {
|
|
16
|
-
HIDDEN: 'hidden',
|
|
17
|
-
DOM_READY: 'dom-ready'
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const SELECTOR = {
|
|
21
|
-
OPTIONAL: `[${ ATTRIBUTE.OPTIONAL }]`
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const TAG = {
|
|
25
|
-
STYLE: 'style'
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
function once(handler : Function) : Function {
|
|
29
|
-
let called = false;
|
|
30
|
-
return (...args) => {
|
|
31
|
-
if (!called) {
|
|
32
|
-
called = true;
|
|
33
|
-
handler(...args);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function debounce(handler : Function, time : number = 50) : Function {
|
|
39
|
-
let timeout;
|
|
40
|
-
return (...args) => {
|
|
41
|
-
clearTimeout(timeout);
|
|
42
|
-
timeout = setTimeout(() => {
|
|
43
|
-
handler(...args);
|
|
44
|
-
}, time);
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// eslint-disable-next-line flowtype/no-mutable-array
|
|
49
|
-
function toArray<T>(item) : Array<T> {
|
|
50
|
-
// $FlowFixMe[method-unbinding]
|
|
51
|
-
return Array.prototype.slice.call(item);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
function elementArray(elements : HTMLCollection<HTMLElement> | NodeList<HTMLElement> | $ReadOnlyArray<HTMLElement>) : $ReadOnlyArray<HTMLElement> {
|
|
55
|
-
return toArray(elements).filter(el => {
|
|
56
|
-
return el.tagName.toLowerCase() !== TAG.STYLE;
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function getElements(selector, parent) : $ReadOnlyArray<HTMLElement> {
|
|
61
|
-
parent = parent || document;
|
|
62
|
-
return elementArray(parent.querySelectorAll(selector));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function getParent(element : HTMLElement) : HTMLElement {
|
|
66
|
-
// $FlowFixMe
|
|
67
|
-
return element.parentElement;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
function showElement(el : HTMLElement) {
|
|
71
|
-
el.classList.remove(CLASS.HIDDEN);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function hideElement(el : HTMLElement) {
|
|
75
|
-
el.classList.add(CLASS.HIDDEN);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
function sum(arr : $ReadOnlyArray<number>) : number {
|
|
79
|
-
let result = 0;
|
|
80
|
-
for (const item of arr) {
|
|
81
|
-
result += item;
|
|
82
|
-
}
|
|
83
|
-
return result;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function unique<T>(arr : $ReadOnlyArray<T>) : $ReadOnlyArray<T> {
|
|
87
|
-
const result = [];
|
|
4
|
+
import { node, type ElementNode } from "@krakenjs/jsx-pragmatic/src";
|
|
88
5
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function getAllChildren(element : HTMLElement) : $ReadOnlyArray<HTMLElement> {
|
|
99
|
-
return elementArray(element.children);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
function getOptionalIndex(element : HTMLElement) : number {
|
|
103
|
-
return parseInt(element.getAttribute(ATTRIBUTE.OPTIONAL) || 0, 10);
|
|
104
|
-
}
|
|
6
|
+
export function getComponentScript(): () => void {
|
|
7
|
+
/* istanbul ignore next */
|
|
8
|
+
return () => {
|
|
9
|
+
const ATTRIBUTE = {
|
|
10
|
+
OPTIONAL: "optional",
|
|
11
|
+
};
|
|
105
12
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
13
|
+
const CLASS = {
|
|
14
|
+
HIDDEN: "hidden",
|
|
15
|
+
DOM_READY: "dom-ready",
|
|
16
|
+
};
|
|
109
17
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
18
|
+
const SELECTOR = {
|
|
19
|
+
OPTIONAL: `[${ATTRIBUTE.OPTIONAL}]`,
|
|
20
|
+
};
|
|
113
21
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
});
|
|
118
|
-
}
|
|
22
|
+
const TAG = {
|
|
23
|
+
STYLE: "style",
|
|
24
|
+
};
|
|
119
25
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
26
|
+
function once(handler: Function): Function {
|
|
27
|
+
let called = false;
|
|
28
|
+
return (...args) => {
|
|
29
|
+
if (!called) {
|
|
30
|
+
called = true;
|
|
31
|
+
handler(...args);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function debounce(handler: Function, time: number = 50): Function {
|
|
37
|
+
let timeout;
|
|
38
|
+
return (...args) => {
|
|
39
|
+
clearTimeout(timeout);
|
|
40
|
+
timeout = setTimeout(() => {
|
|
41
|
+
handler(...args);
|
|
42
|
+
}, time);
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// eslint-disable-next-line flowtype/no-mutable-array
|
|
47
|
+
function toArray<T>(item): Array<T> {
|
|
48
|
+
// $FlowFixMe[method-unbinding]
|
|
49
|
+
return Array.prototype.slice.call(item);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function elementArray(
|
|
53
|
+
elements:
|
|
54
|
+
| HTMLCollection<HTMLElement>
|
|
55
|
+
| NodeList<HTMLElement>
|
|
56
|
+
| $ReadOnlyArray<HTMLElement>
|
|
57
|
+
): $ReadOnlyArray<HTMLElement> {
|
|
58
|
+
return toArray(elements).filter((el) => {
|
|
59
|
+
return el.tagName.toLowerCase() !== TAG.STYLE;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function getElements(selector, parent): $ReadOnlyArray<HTMLElement> {
|
|
64
|
+
parent = parent || document;
|
|
65
|
+
return elementArray(parent.querySelectorAll(selector));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function getParent(element: HTMLElement): HTMLElement {
|
|
69
|
+
// $FlowFixMe
|
|
70
|
+
return element.parentElement;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function showElement(el: HTMLElement) {
|
|
74
|
+
el.classList.remove(CLASS.HIDDEN);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function hideElement(el: HTMLElement) {
|
|
78
|
+
el.classList.add(CLASS.HIDDEN);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function sum(arr: $ReadOnlyArray<number>): number {
|
|
82
|
+
let result = 0;
|
|
83
|
+
for (const item of arr) {
|
|
84
|
+
result += item;
|
|
85
|
+
}
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function unique<T>(arr: $ReadOnlyArray<T>): $ReadOnlyArray<T> {
|
|
90
|
+
const result = [];
|
|
91
|
+
|
|
92
|
+
for (const el of arr) {
|
|
93
|
+
if (result.indexOf(el) === -1) {
|
|
94
|
+
result.push(el);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function getAllChildren(element: HTMLElement): $ReadOnlyArray<HTMLElement> {
|
|
102
|
+
return elementArray(element.children);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function getOptionalIndex(element: HTMLElement): number {
|
|
106
|
+
return parseInt(element.getAttribute(ATTRIBUTE.OPTIONAL) || 0, 10);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function getElementsTotalWidth(
|
|
110
|
+
elements: $ReadOnlyArray<HTMLElement>
|
|
111
|
+
): number {
|
|
112
|
+
return sum(elements.map((child) => child.offsetWidth));
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function getOptionalParents(): $ReadOnlyArray<HTMLElement> {
|
|
116
|
+
return unique(
|
|
117
|
+
getElements(SELECTOR.OPTIONAL).map(getParent).filter(Boolean)
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function getOptionalChildren(
|
|
122
|
+
parent: HTMLElement
|
|
123
|
+
): $ReadOnlyArray<HTMLElement> {
|
|
124
|
+
return toArray(getElements(SELECTOR.OPTIONAL, parent)).sort(
|
|
125
|
+
(first, second) => {
|
|
126
|
+
return getOptionalIndex(first) - getOptionalIndex(second);
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const children = getOptionalParents().map((optionalParent) => {
|
|
132
|
+
const allChildren = getAllChildren(optionalParent);
|
|
133
|
+
const optionalChildren = getOptionalChildren(optionalParent);
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
optionalParent,
|
|
137
|
+
allChildren,
|
|
138
|
+
optionalChildren,
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
function toggleOptionals() {
|
|
143
|
+
for (const {
|
|
144
|
+
optionalParent,
|
|
145
|
+
allChildren,
|
|
146
|
+
optionalChildren,
|
|
147
|
+
} of children) {
|
|
148
|
+
const parentWidth = optionalParent.offsetWidth;
|
|
149
|
+
let usedWidth =
|
|
150
|
+
getElementsTotalWidth(allChildren) -
|
|
151
|
+
getElementsTotalWidth(optionalChildren);
|
|
152
|
+
|
|
153
|
+
for (const optionalChild of optionalChildren) {
|
|
154
|
+
usedWidth += optionalChild.offsetWidth;
|
|
155
|
+
|
|
156
|
+
if (usedWidth > parentWidth) {
|
|
157
|
+
hideElement(optionalChild);
|
|
158
|
+
} else {
|
|
159
|
+
showElement(optionalChild);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const setDomReady = once(
|
|
166
|
+
debounce(() => {
|
|
167
|
+
window.addEventListener("resize", toggleOptionals);
|
|
168
|
+
setTimeout(toggleOptionals);
|
|
169
|
+
if (document.body) {
|
|
170
|
+
document.body.classList.add(CLASS.DOM_READY);
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
);
|
|
147
174
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if (document.body) {
|
|
152
|
-
document.body.classList.add(CLASS.DOM_READY);
|
|
153
|
-
}
|
|
154
|
-
}));
|
|
155
|
-
|
|
156
|
-
const load = () => {
|
|
157
|
-
toggleOptionals();
|
|
158
|
-
setDomReady();
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
toggleOptionals();
|
|
162
|
-
document.addEventListener('DOMContentLoaded', load);
|
|
163
|
-
window.addEventListener('load', load);
|
|
164
|
-
window.addEventListener('resize', load);
|
|
175
|
+
const load = () => {
|
|
176
|
+
toggleOptionals();
|
|
177
|
+
setDomReady();
|
|
165
178
|
};
|
|
179
|
+
|
|
180
|
+
toggleOptionals();
|
|
181
|
+
document.addEventListener("DOMContentLoaded", load);
|
|
182
|
+
window.addEventListener("load", load);
|
|
183
|
+
window.addEventListener("resize", load);
|
|
184
|
+
};
|
|
166
185
|
}
|
|
167
186
|
|
|
168
187
|
type ScriptProps = {|
|
|
169
|
-
|
|
188
|
+
nonce: ?string,
|
|
170
189
|
|};
|
|
171
190
|
|
|
172
|
-
export function Script({ nonce }
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
191
|
+
export function Script({ nonce }: ScriptProps): ElementNode {
|
|
192
|
+
return (
|
|
193
|
+
<script
|
|
194
|
+
nonce={nonce}
|
|
195
|
+
innerHTML={`(${getComponentScript().toString()})()`}
|
|
196
|
+
/>
|
|
197
|
+
);
|
|
176
198
|
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
/** @jsx node */
|
|
3
3
|
|
|
4
|
-
import { node, type ElementNode } from
|
|
4
|
+
import { node, type ElementNode } from "@krakenjs/jsx-pragmatic/src";
|
|
5
5
|
|
|
6
|
-
import { CLASS } from
|
|
6
|
+
import { CLASS } from "../../constants";
|
|
7
7
|
|
|
8
|
-
export function Spinner()
|
|
9
|
-
|
|
10
|
-
<div class={ CLASS.SPINNER } />
|
|
11
|
-
);
|
|
8
|
+
export function Spinner(): ?ElementNode {
|
|
9
|
+
return <div class={CLASS.SPINNER} />;
|
|
12
10
|
}
|
package/src/ui/buttons/style.jsx
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
/** @jsx node */
|
|
3
3
|
|
|
4
|
-
import { node, type ElementNode } from
|
|
5
|
-
import { type FundingEligibilityType } from
|
|
4
|
+
import { node, type ElementNode } from "@krakenjs/jsx-pragmatic/src";
|
|
5
|
+
import { type FundingEligibilityType } from "@paypal/sdk-constants/src";
|
|
6
6
|
|
|
7
|
-
import { type ButtonStyle } from
|
|
8
|
-
import { componentStyle } from
|
|
7
|
+
import { type ButtonStyle } from "./props";
|
|
8
|
+
import { componentStyle } from "./styles";
|
|
9
9
|
|
|
10
10
|
type StyleProps = {|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
style: ButtonStyle,
|
|
12
|
+
nonce: string,
|
|
13
|
+
fundingEligibility: FundingEligibilityType,
|
|
14
14
|
|};
|
|
15
15
|
|
|
16
|
-
export function Style({
|
|
16
|
+
export function Style({
|
|
17
|
+
style,
|
|
18
|
+
nonce,
|
|
19
|
+
fundingEligibility,
|
|
20
|
+
}: StyleProps): ElementNode {
|
|
21
|
+
const { custom = { label: undefined, css: undefined }, height } = style;
|
|
22
|
+
const css = componentStyle({ custom, height, fundingEligibility });
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
const css = componentStyle({ custom, height, fundingEligibility });
|
|
20
|
-
|
|
21
|
-
return (
|
|
22
|
-
<style nonce={ nonce } innerHTML={ css } />
|
|
23
|
-
);
|
|
24
|
+
return <style nonce={nonce} innerHTML={css} />;
|
|
24
25
|
}
|
|
@@ -1,23 +1,31 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
|
|
3
|
-
import { type FundingEligibilityType } from
|
|
3
|
+
import { type FundingEligibilityType } from "@paypal/sdk-constants/src";
|
|
4
4
|
|
|
5
|
-
import type { CustomStyle } from
|
|
5
|
+
import type { CustomStyle } from "../../../types";
|
|
6
6
|
|
|
7
|
-
import { pageStyle } from
|
|
8
|
-
import { buttonStyle } from
|
|
9
|
-
import { labelStyle } from
|
|
10
|
-
import { buttonResponsiveStyle } from
|
|
11
|
-
import { buttonColorStyle } from
|
|
12
|
-
import { customStyle } from
|
|
7
|
+
import { pageStyle } from "./page";
|
|
8
|
+
import { buttonStyle } from "./button";
|
|
9
|
+
import { labelStyle } from "./labels";
|
|
10
|
+
import { buttonResponsiveStyle } from "./responsive";
|
|
11
|
+
import { buttonColorStyle } from "./color";
|
|
12
|
+
import { customStyle } from "./custom";
|
|
13
13
|
|
|
14
|
-
export function componentStyle({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
export function componentStyle({
|
|
15
|
+
custom,
|
|
16
|
+
height,
|
|
17
|
+
fundingEligibility,
|
|
18
|
+
}: {|
|
|
19
|
+
custom?: ?CustomStyle,
|
|
20
|
+
height?: ?number,
|
|
21
|
+
fundingEligibility: FundingEligibilityType,
|
|
22
|
+
|}): string {
|
|
23
|
+
return `
|
|
24
|
+
${pageStyle}
|
|
25
|
+
${buttonStyle}
|
|
26
|
+
${buttonColorStyle}
|
|
27
|
+
${labelStyle}
|
|
28
|
+
${buttonResponsiveStyle({ height, fundingEligibility })}
|
|
29
|
+
${customStyle({ custom })}
|
|
22
30
|
`;
|
|
23
31
|
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/* @flow */
|
|
2
2
|
|
|
3
|
-
import { ENV } from
|
|
4
|
-
import { LOGO_CLASS } from
|
|
3
|
+
import { ENV } from "@paypal/sdk-constants/src";
|
|
4
|
+
import { LOGO_CLASS } from "@paypal/sdk-logos/src";
|
|
5
5
|
|
|
6
|
-
import { CLASS } from
|
|
6
|
+
import { CLASS } from "../../../constants";
|
|
7
7
|
|
|
8
8
|
const MIN_VAULT_BUTTON_WIDTH = 250;
|
|
9
9
|
|
|
10
10
|
export const buttonStyle = `
|
|
11
11
|
|
|
12
|
-
.${
|
|
12
|
+
.${CLASS.CONTAINER} {
|
|
13
13
|
display: block;
|
|
14
14
|
white-space: nowrap;
|
|
15
15
|
margin: 0;
|
|
@@ -25,7 +25,7 @@ export const buttonStyle = `
|
|
|
25
25
|
box-sizing: border-box;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
.${
|
|
28
|
+
.${CLASS.BUTTON} {
|
|
29
29
|
border: 1px solid transparent;
|
|
30
30
|
border-radius: 0 3px 3px 0;
|
|
31
31
|
position: relative;
|
|
@@ -37,22 +37,22 @@ export const buttonStyle = `
|
|
|
37
37
|
overflow: hidden;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
.${
|
|
40
|
+
.${CLASS.BUTTON} * {
|
|
41
41
|
cursor: pointer;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
.${
|
|
44
|
+
.${CLASS.CONTAINER}.${CLASS.ENV}-${ENV.TEST} .${CLASS.TEXT} {
|
|
45
45
|
font-family: Arial !important;
|
|
46
46
|
background: rgba(0, 0, 0, 0.5) !important;
|
|
47
47
|
color: transparent !important;
|
|
48
48
|
text-shadow: none !important;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.${
|
|
51
|
+
.${CLASS.CARD} {
|
|
52
52
|
cursor: pointer;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
.${
|
|
55
|
+
.${LOGO_CLASS.LOGO} {
|
|
56
56
|
padding: 0;
|
|
57
57
|
display: inline-block;
|
|
58
58
|
background: none;
|
|
@@ -60,25 +60,25 @@ export const buttonStyle = `
|
|
|
60
60
|
width: auto;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
.${
|
|
63
|
+
.${CLASS.TEXT}, .${CLASS.SPACE} {
|
|
64
64
|
display: inline-block;
|
|
65
65
|
white-space: pre;
|
|
66
66
|
vertical-align: top;
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
.${
|
|
69
|
+
.${CLASS.BUTTON} > .${CLASS.BUTTON_LABEL} {
|
|
70
70
|
position: relative;
|
|
71
71
|
top: 50%;
|
|
72
72
|
transform: translateY(-50%);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
.${
|
|
75
|
+
.${CLASS.BUTTON} > .${CLASS.BUTTON_LABEL} * {
|
|
76
76
|
vertical-align: middle;
|
|
77
77
|
height: 100%;
|
|
78
78
|
text-align: left;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
.${
|
|
81
|
+
.${CLASS.TAGLINE} {
|
|
82
82
|
max-width: 100%;
|
|
83
83
|
font-size: initial;
|
|
84
84
|
font-weight: normal;
|
|
@@ -87,7 +87,7 @@ export const buttonStyle = `
|
|
|
87
87
|
width: auto;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
.${
|
|
90
|
+
.${CLASS.BUTTON} .${CLASS.SPINNER} {
|
|
91
91
|
position: absolute;
|
|
92
92
|
height: 40px;
|
|
93
93
|
width: 40px;
|
|
@@ -98,10 +98,10 @@ export const buttonStyle = `
|
|
|
98
98
|
border: 3px solid rgba(0, 0, 0, .2);
|
|
99
99
|
border-top-color: rgba(33, 128, 192, 0.8);
|
|
100
100
|
border-radius: 100%;
|
|
101
|
-
animation: ${
|
|
101
|
+
animation: ${CLASS.SPINNER}-rotation .7s infinite linear;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
@keyframes ${
|
|
104
|
+
@keyframes ${CLASS.SPINNER}-rotation {
|
|
105
105
|
from {
|
|
106
106
|
transform: translateX(-50%) translateY(-50%) rotate(0deg);
|
|
107
107
|
}
|
|
@@ -110,24 +110,26 @@ export const buttonStyle = `
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
.${
|
|
113
|
+
.${CLASS.BUTTON} .${CLASS.SPINNER} {
|
|
114
114
|
display: none !important;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
.${
|
|
117
|
+
.${CLASS.BUTTON}.${CLASS.LOADING} * {
|
|
118
118
|
display: none !important;
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
.${
|
|
121
|
+
.${CLASS.BUTTON}.${CLASS.LOADING} .${CLASS.SPINNER} {
|
|
122
122
|
display: block !important;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
-
.${
|
|
125
|
+
.${CLASS.CONTAINER} .${CLASS.VAULT_HEADER} {
|
|
126
126
|
margin-top: 10px;
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
@media only screen and (max-width: ${
|
|
130
|
-
.${
|
|
129
|
+
@media only screen and (max-width: ${MIN_VAULT_BUTTON_WIDTH - 1}px) {
|
|
130
|
+
.${CLASS.CONTAINER} .${CLASS.BUTTON_ROW}.${CLASS.WALLET}.${
|
|
131
|
+
CLASS.WALLET_MENU
|
|
132
|
+
} .${CLASS.BUTTON} {
|
|
131
133
|
border-top-right-radius: 4px;
|
|
132
134
|
border-bottom-right-radius: 4px;
|
|
133
135
|
width: 100%;
|