@tap-payments/apple-pay-button 0.0.12-test → 0.0.13-test
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/build/constants/index.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
.apple-pay-button-tap {
|
|
3
|
+
-webkit-appearance: -apple-pay-button;
|
|
2
4
|
display: block;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
width: 100%;
|
|
6
|
+
height: 48px;
|
|
7
|
+
min-height: 30px;
|
|
8
|
+
cursor: pointer;
|
|
7
9
|
}
|
|
10
|
+
.black {
|
|
11
|
+
-apple-pay-button-style: black;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.white {
|
|
15
|
+
-apple-pay-button-style: white;
|
|
16
|
+
}
|
|
17
|
+
.whiteOutline {
|
|
18
|
+
-apple-pay-button-style: white;
|
|
19
|
+
border: solid 1px gray;
|
|
20
|
+
}
|
|
21
|
+
|
|
@@ -2,12 +2,5 @@
|
|
|
2
2
|
import { ApplePayButtonProps } from '../../@types';
|
|
3
3
|
import './ApplePayButton.css';
|
|
4
4
|
export type { ApplePayButtonProps };
|
|
5
|
-
declare global {
|
|
6
|
-
namespace JSX {
|
|
7
|
-
interface IntrinsicElements {
|
|
8
|
-
'apple-pay-button': unknown;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
5
|
export declare function ApplePayButton(props: ApplePayButtonProps): JSX.Element;
|
|
13
6
|
export declare const renderApplePayButton: (props: ApplePayButtonProps, elementId: string) => any;
|
|
@@ -14,12 +14,10 @@ import * as React from 'react';
|
|
|
14
14
|
import { createRoot } from 'react-dom/client';
|
|
15
15
|
import { findOrCreateElementAndInject } from '../../utils';
|
|
16
16
|
import { useApplePay } from '../../hooks/useApplePay';
|
|
17
|
-
import {
|
|
17
|
+
import { ButtonStyle, ButtonType, Locale, Scope } from '../../constants';
|
|
18
18
|
import './ApplePayButton.css';
|
|
19
|
-
import { useScript } from '../../hooks';
|
|
20
19
|
var ApplePay = React.memo(function (_a) {
|
|
21
20
|
var publicKey = _a.publicKey, merchant = _a.merchant, transaction = _a.transaction, billingContact = _a.billingContact, supportedNetworks = _a.supportedNetworks, onCancel = _a.onCancel, onError = _a.onError, onSuccess = _a.onSuccess, onClick = _a.onClick, metaData = _a.metaData, _b = _a.scope, scope = _b === void 0 ? Scope.TapToken : _b, _c = _a.buttonStyle, buttonStyle = _c === void 0 ? ButtonStyle.WhiteOutline : _c, _d = _a.type, type = _d === void 0 ? ButtonType.PLAIN : _d, _e = _a.locale, locale = _e === void 0 ? Locale.EN : _e;
|
|
22
|
-
useScript(ApplePaySDK);
|
|
23
21
|
var _f = useApplePay({
|
|
24
22
|
publicKey: publicKey,
|
|
25
23
|
merchant: merchant,
|
|
@@ -32,10 +30,19 @@ var ApplePay = React.memo(function (_a) {
|
|
|
32
30
|
scope: scope,
|
|
33
31
|
metaData: metaData
|
|
34
32
|
}), loading = _f.loading, onApplePayButtonClicked = _f.onApplePayButtonClicked, disabled = _f.disabled;
|
|
35
|
-
|
|
33
|
+
var ref = React.useRef();
|
|
34
|
+
React.useEffect(function () {
|
|
35
|
+
var _a;
|
|
36
|
+
if (ref.current) {
|
|
37
|
+
(_a = ref.current) === null || _a === void 0 ? void 0 : _a.click();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
return (_jsx("div", { className: "apple-pay-button-tap ".concat(buttonStyle), style: {
|
|
41
|
+
'-apple-pay-button-type': type
|
|
42
|
+
}, onClick: function () {
|
|
36
43
|
onApplePayButtonClicked();
|
|
37
44
|
onClick === null || onClick === void 0 ? void 0 : onClick();
|
|
38
|
-
},
|
|
45
|
+
}, lang: locale }));
|
|
39
46
|
});
|
|
40
47
|
export function ApplePayButton(props) {
|
|
41
48
|
return _jsx(ApplePay, __assign({}, props));
|