@tap-payments/apple-pay-button 0.0.55-development → 0.0.57-development

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 (59) hide show
  1. package/build/@types/ApplePayButtonProps.d.ts +129 -0
  2. package/build/@types/ApplePayButtonProps.js +1 -0
  3. package/build/@types/charge.d.ts +57 -0
  4. package/build/@types/charge.js +1 -0
  5. package/build/@types/checkoutProfile.d.ts +194 -0
  6. package/build/@types/checkoutProfile.js +1 -0
  7. package/build/@types/enums.d.ts +71 -0
  8. package/build/@types/enums.js +83 -0
  9. package/build/@types/index.d.ts +6 -233
  10. package/build/@types/index.js +6 -1
  11. package/build/@types/tapLocalisation.d.ts +193 -0
  12. package/build/@types/tapLocalisation.js +1 -0
  13. package/build/@types/tapTheme.d.ts +842 -0
  14. package/build/@types/tapTheme.js +1 -0
  15. package/build/api/app.service.d.ts +1 -1
  16. package/build/api/app.service.js +2 -1
  17. package/build/api/httpClient.d.ts +1 -1
  18. package/build/assets/lottie/Dark_Mode_Loader.json +255 -0
  19. package/build/assets/lottie/Light_Mode_Loader.json +255 -0
  20. package/build/components/ActionButton/ActionButton.d.ts +24 -0
  21. package/build/components/ActionButton/ActionButton.js +61 -0
  22. package/build/components/ActionButton/index.d.ts +2 -0
  23. package/build/components/ActionButton/index.js +2 -0
  24. package/build/components/InitialLoader/InitialLoader.d.ts +9 -0
  25. package/build/components/InitialLoader/InitialLoader.js +29 -0
  26. package/build/components/InitialLoader/index.d.ts +2 -0
  27. package/build/components/InitialLoader/index.js +2 -0
  28. package/build/components/Loader/Loader.d.ts +24 -0
  29. package/build/components/Loader/Loader.js +48 -0
  30. package/build/components/Loader/index.d.ts +2 -0
  31. package/build/components/Loader/index.js +2 -0
  32. package/build/components/PayButton/PayButton.d.ts +15 -0
  33. package/build/components/PayButton/PayButton.js +40 -0
  34. package/build/components/PayButton/index.d.ts +2 -0
  35. package/build/components/PayButton/index.js +2 -0
  36. package/build/components/PayButton/style.d.ts +11 -0
  37. package/build/components/PayButton/style.js +41 -0
  38. package/build/constants/index.d.ts +2 -66
  39. package/build/constants/index.js +2 -66
  40. package/build/features/ApplePayButton/ApplePayButton.js +7 -19
  41. package/build/features/ApplePayButton/style.d.ts +2 -0
  42. package/build/features/ApplePayButton/style.js +12 -0
  43. package/build/hooks/useApplePay.d.ts +87 -7
  44. package/build/hooks/useApplePay.js +93 -12
  45. package/build/hooks/useMerchantApplePay.d.ts +1 -2
  46. package/build/hooks/useMerchantApplePay.js +1 -1
  47. package/build/hooks/useScript.d.ts +3 -1
  48. package/build/hooks/useScript.js +3 -2
  49. package/build/index.d.ts +1 -1
  50. package/build/index.js +1 -1
  51. package/build/utils/config.d.ts +1 -1
  52. package/build/utils/config.js +10 -10
  53. package/build/utils/defaultValues.d.ts +10 -7
  54. package/build/utils/defaultValues.js +1 -1
  55. package/build/utils/index.d.ts +3 -0
  56. package/build/utils/index.js +3 -0
  57. package/build/utils/theme.d.ts +12 -0
  58. package/build/utils/theme.js +61 -0
  59. package/package.json +16 -10
@@ -45,19 +45,29 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
45
45
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
46
  }
47
47
  };
48
- import { useEffect, useState } from 'react';
48
+ import { useCallback, useEffect, useMemo, useState } from 'react';
49
49
  import appService from '../api/app.service';
50
- import { ApplePayVersion, Scope } from '../constants';
51
50
  import { getAxiosGlobalHeaders, setAxiosGlobalHeaders } from '../api/httpClient';
51
+ import { ApplePayVersion } from '../constants';
52
+ import { Scope } from '../@types/enums';
52
53
  import { prepareApplePayRequest } from '../utils/config';
53
54
  import { useMerchantApplePay } from './useMerchantApplePay';
55
+ import { getApplePayPaymentMethod, getDefaultThemeMode, getDefaultValues, getFullThemeMode } from '../utils';
54
56
  export var useApplePay = function (_a) {
55
- var environment = _a.environment, interfaceObj = _a.interface, merchant = _a.merchant, customer = _a.customer, acceptance = _a.acceptance, scope = _a.scope, debug = _a.debug, onError = _a.onError, onSuccess = _a.onSuccess, onCancel = _a.onCancel, onReady = _a.onReady, metaData = _a.metaData, headers = _a.headers, operator = _a.operator, order = _a.order, onOrderCreated = _a.onOrderCreated, integration = _a.integration, transaction = _a.transaction, post = _a.post, redirect = _a.redirect;
56
- var _b = useState(false), loading = _b[0], setLoading = _b[1];
57
- var _c = useState(), profileData = _c[0], setProfile = _c[1];
58
- var _d = useState(false), disabled = _d[0], setDisabled = _d[1];
59
- var _e = useState(), applePayRequestData = _e[0], setApplePayRequestData = _e[1];
60
- var _f = useState(), applePayRequestConfiguration = _f[0], setApplePayRequestConfiguration = _f[1];
57
+ var _b, _c, _d, _e, _f;
58
+ var buttonProps = _a.buttonProps;
59
+ var _g = useState(), applePayRequestData = _g[0], setApplePayRequestData = _g[1];
60
+ var _h = useState(), applePayRequestConfiguration = _h[0], setApplePayRequestConfiguration = _h[1];
61
+ var _j = useState(), profileData = _j[0], setProfile = _j[1];
62
+ var _k = useState(false), disabled = _k[0], setDisabled = _k[1];
63
+ var _l = useState(null), tapTheme = _l[0], setTapTheme = _l[1];
64
+ var _m = useState(), tapLocalization = _m[0], setTapLocalization = _m[1];
65
+ var _o = useState(false), error = _o[0], setError = _o[1];
66
+ var _p = useState(false), success = _p[0], setSuccess = _p[1];
67
+ var _q = useState(false), loading = _q[0], setLoading = _q[1];
68
+ var _r = useState(false), isRounded = _r[0], setIsRounded = _r[1];
69
+ var mappedProps = getDefaultValues(buttonProps);
70
+ var environment = mappedProps.environment, interfaceObj = mappedProps.interface, merchant = mappedProps.merchant, customer = mappedProps.customer, acceptance = mappedProps.acceptance, scope = mappedProps.scope, debug = mappedProps.debug, onError = mappedProps.onError, onSuccess = mappedProps.onSuccess, onCancel = mappedProps.onCancel, onReady = mappedProps.onReady, metaData = mappedProps.metaData, headers = mappedProps.headers, operator = mappedProps.operator, order = mappedProps.order, onOrderCreated = mappedProps.onOrderCreated, integration = mappedProps.integration, transaction = mappedProps.transaction, post = mappedProps.post, redirect = mappedProps.redirect;
61
71
  useMerchantApplePay({
62
72
  isIframeIntegration: integration === 'iframe',
63
73
  onError: onError,
@@ -72,6 +82,48 @@ export var useApplePay = function (_a) {
72
82
  post: post,
73
83
  redirect: redirect
74
84
  });
85
+ var lang = (_c = (_b = mappedProps.interface) === null || _b === void 0 ? void 0 : _b.locale) !== null && _c !== void 0 ? _c : 'en';
86
+ var theme = getDefaultThemeMode((_d = mappedProps.interface) === null || _d === void 0 ? void 0 : _d.theme);
87
+ var isIframeIntegration = buttonProps.integration === 'iframe';
88
+ var applePayPaymentMethodOptions = useMemo(function () {
89
+ if (!profileData)
90
+ return null;
91
+ return getApplePayPaymentMethod(profileData.payment_options.payment_methods || []);
92
+ }, [profileData]);
93
+ var gradientColor = useMemo(function () {
94
+ var _a, _b, _c;
95
+ if (!applePayPaymentMethodOptions)
96
+ return undefined;
97
+ var backgroundColor = (_a = applePayPaymentMethodOptions.button_style.background) === null || _a === void 0 ? void 0 : _a[getFullThemeMode((_b = buttonProps.interface) === null || _b === void 0 ? void 0 : _b.theme, (_c = buttonProps.interface) === null || _c === void 0 ? void 0 : _c.colorStyle)].background_colors;
98
+ if (backgroundColor.length > 1)
99
+ return "linear-gradient(-90deg,".concat(backgroundColor.join(','), ")");
100
+ return backgroundColor[0];
101
+ }, [applePayPaymentMethodOptions, buttonProps]);
102
+ var backgroundColor = useMemo(function () {
103
+ var _a, _b;
104
+ if (!applePayPaymentMethodOptions)
105
+ return undefined;
106
+ return applePayPaymentMethodOptions.button_style.background[getFullThemeMode((_a = buttonProps.interface) === null || _a === void 0 ? void 0 : _a.theme, (_b = buttonProps.interface) === null || _b === void 0 ? void 0 : _b.colorStyle)].base_color;
107
+ }, [applePayPaymentMethodOptions, buttonProps]);
108
+ var titleAsset = useMemo(function () {
109
+ var _a, _b, _c;
110
+ if (!applePayPaymentMethodOptions)
111
+ return undefined;
112
+ var imgSrc = (_a = profileData === null || profileData === void 0 ? void 0 : profileData.payment_options.payment_methods.find(function (method) { return method.name === applePayPaymentMethodOptions.name; })) === null || _a === void 0 ? void 0 : _a.button_style.title_asset;
113
+ var theme = getFullThemeMode((_b = buttonProps.interface) === null || _b === void 0 ? void 0 : _b.theme, (_c = buttonProps.interface) === null || _c === void 0 ? void 0 : _c.colorStyle);
114
+ var titleAsset = (imgSrc === null || imgSrc === void 0 ? void 0 : imgSrc.replace('{theme}', theme).replace('{lang}', lang)) + '.svg';
115
+ return titleAsset;
116
+ }, [
117
+ applePayPaymentMethodOptions,
118
+ lang,
119
+ profileData === null || profileData === void 0 ? void 0 : profileData.payment_options.payment_methods,
120
+ (_e = buttonProps.interface) === null || _e === void 0 ? void 0 : _e.colorStyle,
121
+ (_f = buttonProps.interface) === null || _f === void 0 ? void 0 : _f.theme
122
+ ]);
123
+ var showLoader = useMemo(function () {
124
+ var _a;
125
+ return ((_a = mappedProps.interface) === null || _a === void 0 ? void 0 : _a.loader) !== false;
126
+ }, [mappedProps]);
75
127
  var initialize = function (metaData) { return __awaiter(void 0, void 0, void 0, function () {
76
128
  var merchantProfile, payment_options, headers_1, data, err_1;
77
129
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
@@ -159,9 +211,6 @@ export var useApplePay = function (_a) {
159
211
  }
160
212
  });
161
213
  }); };
162
- useEffect(function () {
163
- initialize(metaData);
164
- }, []);
165
214
  var onApplePayButtonClicked = function () { return __awaiter(void 0, void 0, void 0, function () {
166
215
  var ApplePaySession, session_1;
167
216
  var _a;
@@ -296,11 +345,43 @@ export var useApplePay = function (_a) {
296
345
  return [2];
297
346
  });
298
347
  }); };
348
+ var handleClick = useCallback(function () {
349
+ var _a, _b;
350
+ if (isIframeIntegration) {
351
+ (_a = buttonProps.onClick) === null || _a === void 0 ? void 0 : _a.call(buttonProps, __assign(__assign({}, applePayRequestConfiguration), { applePayRequestData: applePayRequestData }));
352
+ return;
353
+ }
354
+ onApplePayButtonClicked();
355
+ (_b = buttonProps.onClick) === null || _b === void 0 ? void 0 : _b.call(buttonProps);
356
+ }, [applePayRequestConfiguration, applePayRequestData, buttonProps, isIframeIntegration, onApplePayButtonClicked]);
357
+ useEffect(function () {
358
+ initialize(metaData);
359
+ }, []);
360
+ useEffect(function () {
361
+ if (!error)
362
+ return;
363
+ var timer = setTimeout(function () {
364
+ setError(false);
365
+ setLoading(false);
366
+ setIsRounded(false);
367
+ }, 2000);
368
+ return function () { return clearTimeout(timer); };
369
+ }, [error]);
299
370
  return {
371
+ onClick: handleClick,
300
372
  loading: loading,
373
+ isIframeIntegration: isIframeIntegration,
301
374
  onApplePayButtonClicked: onApplePayButtonClicked,
302
375
  disabled: !profileData || disabled || !applePayRequestData,
303
376
  applePayRequestData: applePayRequestData,
304
- applePayRequestConfiguration: applePayRequestConfiguration
377
+ applePayRequestConfiguration: applePayRequestConfiguration,
378
+ mappedProps: mappedProps,
379
+ theme: theme,
380
+ isRounded: isRounded,
381
+ success: success,
382
+ error: error,
383
+ backgroundColor: backgroundColor,
384
+ gradientColor: gradientColor,
385
+ titleAsset: titleAsset
305
386
  };
306
387
  };
@@ -1,5 +1,4 @@
1
- import { Scope } from '../constants';
2
- import { MetaData, ApplePayButtonProps } from '../@types';
1
+ import { MetaData, ApplePayButtonProps, Scope } from '../@types';
3
2
  interface ApplePayRequestData {
4
3
  isIframeIntegration: boolean;
5
4
  onError?: (error: any) => void;
@@ -35,8 +35,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  import * as React from 'react';
38
- import { Scope } from '../constants';
39
38
  import appService from '../api/app.service';
39
+ import { Scope } from '../@types';
40
40
  var EVENT_NAME = 'TAP_BUTTON::APPLE_PAY_ON_PAYMENT_AUTHORIZED';
41
41
  export var useMerchantApplePay = function (_a) {
42
42
  var isIframeIntegration = _a.isIframeIntegration, onError = _a.onError, onSuccess = _a.onSuccess, scope = _a.scope, profileData = _a.profileData, order = _a.order, customer = _a.customer, transaction = _a.transaction, operator = _a.operator, redirect = _a.redirect, post = _a.post;
@@ -1 +1,3 @@
1
- export declare function useScript(src: string, async?: boolean): "error" | "loading" | "ready" | "idle";
1
+ declare type Status = 'ready' | 'loading' | 'idle' | 'error';
2
+ export declare function useScript(src: string, async?: boolean): Status;
3
+ export {};
@@ -15,13 +15,14 @@ export function useScript(src, async) {
15
15
  script.setAttribute('data-status', 'loading');
16
16
  document.body.appendChild(script);
17
17
  var setAttributeFromEvent = function (event) {
18
- script.setAttribute('data-status', event.type === 'load' ? 'ready' : 'error');
18
+ script === null || script === void 0 ? void 0 : script.setAttribute('data-status', event.type === 'load' ? 'ready' : 'error');
19
19
  };
20
20
  script.addEventListener('load', setAttributeFromEvent);
21
21
  script.addEventListener('error', setAttributeFromEvent);
22
22
  }
23
23
  else {
24
- setStatus(script.getAttribute('data-status'));
24
+ var status_1 = script === null || script === void 0 ? void 0 : script.getAttribute('data-status');
25
+ setStatus(status_1);
25
26
  }
26
27
  var setStateFromEvent = function (event) {
27
28
  setStatus(event.type === 'load' ? 'ready' : 'error');
package/build/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  import { ApplePayButtonProps, ApplePayButton, ApplePayRequestData } from './features/ApplePayButton';
2
- import { ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities } from './constants';
2
+ import { ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities } from './@types/enums';
3
3
  export type { ApplePayButtonProps, ApplePayRequestData };
4
4
  export { ApplePayButton, ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities };
package/build/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { ApplePayButton, renderApplePayButton } from './features/ApplePayButton';
2
- import { ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities } from './constants';
2
+ import { ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities } from './@types/enums';
3
3
  export { ApplePayButton, ThemeMode, Scope, SupportedNetworks, Environment, Locale, ButtonType, Edges, MerchantCapabilities };
4
4
  window['TapSDKs'] = {
5
5
  renderApplePayButton: renderApplePayButton,
@@ -1,12 +1,12 @@
1
1
  import { Acceptance, ApplePayButtonProps, ApplePayRequestData, MetaData, PaymentMethod } from '../@types';
2
2
  export declare const validateSupportedNetworks: (supportedNetworksOptions: Acceptance['supportedSchemes'], merchantSupportedNetworks?: Acceptance['supportedSchemes']) => Acceptance['supportedSchemes'];
3
+ export declare const getApplePayPaymentMethod: (paymentMethods: Array<PaymentMethod>) => PaymentMethod;
3
4
  export declare const getApplePayRequest: ({ order, customer, supportedNetworks, merchantCapabilities, countryCode, name }: Pick<ApplePayButtonProps, "order" | "customer"> & {
4
5
  supportedNetworks: Acceptance['supportedSchemes'];
5
6
  merchantCapabilities: ApplePayRequestData['merchantCapabilities'];
6
7
  countryCode: string;
7
8
  name: string;
8
9
  }) => ApplePayRequestData;
9
- export declare const getApplePayPaymentMethod: (paymentMethods: Array<PaymentMethod>) => PaymentMethod;
10
10
  export declare const rsaSetup: (key: string) => (string: string) => string;
11
11
  export declare function generateApplicationHeader(obj: Record<string, string | any>): string;
12
12
  export declare const prepareApplePayRequest: ({ payment_options, merchant, order, customer, acceptance }: Pick<MetaData, 'merchant' | 'payment_options'> & Pick<ApplePayButtonProps, 'order' | 'customer' | 'acceptance'>) => ApplePayRequestData;
@@ -16,6 +16,16 @@ export var validateSupportedNetworks = function (supportedNetworksOptions, merch
16
16
  }
17
17
  return supportedNetworks.map(toLowerCase);
18
18
  };
19
+ export var getApplePayPaymentMethod = function (paymentMethods) {
20
+ var paymentMethod = paymentMethods.find(function (_a) {
21
+ var name = _a.name, payment_type = _a.payment_type;
22
+ return [name, payment_type].some(function (item) { return item.toLowerCase() === 'apple_pay'; });
23
+ });
24
+ if (!paymentMethod) {
25
+ throw new Error('apple_pay is not configured in your payment options');
26
+ }
27
+ return paymentMethod;
28
+ };
19
29
  export var getApplePayRequest = function (_a) {
20
30
  var _b, _c, _d, _e, _f, _g, _h, _j, _k;
21
31
  var order = _a.order, customer = _a.customer, supportedNetworks = _a.supportedNetworks, merchantCapabilities = _a.merchantCapabilities, countryCode = _a.countryCode, name = _a.name;
@@ -36,16 +46,6 @@ export var getApplePayRequest = function (_a) {
36
46
  }
37
47
  };
38
48
  };
39
- export var getApplePayPaymentMethod = function (paymentMethods) {
40
- var paymentMethod = paymentMethods.find(function (_a) {
41
- var name = _a.name, payment_type = _a.payment_type;
42
- return [name, payment_type].some(function (item) { return item.toLowerCase() === 'apple_pay'; });
43
- });
44
- if (!paymentMethod) {
45
- throw new Error('Apple Pay is not configured in your payment options');
46
- }
47
- return paymentMethod;
48
- };
49
49
  export var rsaSetup = function (key) {
50
50
  var rsa = new JSEncrypt();
51
51
  rsa.setPublicKey(key);
@@ -1,10 +1,13 @@
1
1
  import { ApplePayButtonProps } from '../@types';
2
+ import { ThemeMode, Locale, ButtonType, Edges, MerchantCapabilities } from '../@types/enums';
2
3
  export declare const getDefaultValues: (mainObject: ApplePayButtonProps) => {
3
4
  interface: {
4
- locale?: "en" | "ar" | "dynamic" | undefined;
5
- theme?: "dynamic" | "dark" | "light" | undefined;
6
- edges?: "straight" | "curved" | undefined;
7
- type?: "book" | "buy" | "check-out" | "pay" | "plain" | "subscribe" | undefined;
5
+ locale?: Locale | undefined;
6
+ theme?: ThemeMode | undefined;
7
+ edges?: Edges | undefined;
8
+ type?: ButtonType | undefined;
9
+ colorStyle?: import("../@types").ColorStyle | undefined;
10
+ loader?: boolean | undefined;
8
11
  };
9
12
  operator: {
10
13
  publicKey: string;
@@ -13,8 +16,8 @@ export declare const getDefaultValues: (mainObject: ApplePayButtonProps) => {
13
16
  merchant: {
14
17
  id: string;
15
18
  };
16
- scope: "charge" | "authorize" | "taptoken" | "applepaytoken";
17
- environment: "production" | "sandbox" | "beta" | "development" | "staging";
19
+ scope: import("../@types").Scope;
20
+ environment: import("../@types").Environment;
18
21
  customer?: import("../@types").Customer | undefined;
19
22
  acceptance?: import("../@types").Acceptance | undefined;
20
23
  transaction?: {
@@ -66,4 +69,4 @@ export declare const getDefaultValues: (mainObject: ApplePayButtonProps) => {
66
69
  application: string;
67
70
  } | undefined;
68
71
  };
69
- export declare const getMerchantCapabilities: (supportedCards?: Array<string>) => ("supports3DS" | "supportsCredit" | "supportsDebit")[];
72
+ export declare const getMerchantCapabilities: (supportedCards?: Array<string>) => MerchantCapabilities[];
@@ -18,7 +18,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
18
  }
19
19
  return to.concat(ar || Array.prototype.slice.call(from));
20
20
  };
21
- import { ThemeMode, Locale, ButtonType, Edges, MerchantCapabilities } from '../constants';
21
+ import { ThemeMode, Locale, ButtonType, Edges, MerchantCapabilities } from '../@types/enums';
22
22
  export var getDefaultValues = function (mainObject) {
23
23
  var userThemeMode = window.matchMedia('(prefers-color-scheme: light)').matches ? ThemeMode.LIGHT : ThemeMode.DARK;
24
24
  var userLang = navigator.language.toLowerCase().includes(Locale.AR) ? Locale.AR : Locale.EN;
@@ -1 +1,4 @@
1
1
  export * from './html';
2
+ export * from './theme';
3
+ export * from './config';
4
+ export * from './defaultValues';
@@ -1 +1,4 @@
1
1
  export * from './html';
2
+ export * from './theme';
3
+ export * from './config';
4
+ export * from './defaultValues';
@@ -0,0 +1,12 @@
1
+ import { TapThemeResponse } from '../@types';
2
+ import { ColorStyle, FullThemeMode, Locale, ThemeMode } from '../@types/enums';
3
+ import { ApplePayButtonProps } from '..';
4
+ export declare const mappingInterface: (interfaceParam?: ApplePayButtonProps['interface']) => ApplePayButtonProps['interface'];
5
+ export declare const getDefaultThemeMode: (themeMode?: ThemeMode) => ThemeMode;
6
+ export declare const getDefaultLocale: (locale?: Locale) => Locale;
7
+ export declare const getFullThemeMode: (themeMode?: ThemeMode, colorStyle?: ColorStyle) => FullThemeMode;
8
+ export declare const appendColors: (colors: Record<string, string>) => void;
9
+ export declare const getTapThemeValue: ({ tapTheme, value }: {
10
+ tapTheme: TapThemeResponse | null;
11
+ value?: string | undefined;
12
+ }) => string;
@@ -0,0 +1,61 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { ColorStyle, Edges, FullThemeMode, Locale, ThemeMode } from '../@types/enums';
13
+ export var mappingInterface = function (interfaceParam) {
14
+ return __assign(__assign({ edges: Edges.CURVED, colorStyle: ColorStyle.COLORED, loader: true }, interfaceParam), { locale: getDefaultLocale(interfaceParam === null || interfaceParam === void 0 ? void 0 : interfaceParam.locale), theme: getDefaultThemeMode(interfaceParam === null || interfaceParam === void 0 ? void 0 : interfaceParam.theme) });
15
+ };
16
+ export var getDefaultThemeMode = function (themeMode) {
17
+ return themeMode === ThemeMode.DYNAMIC || themeMode === undefined
18
+ ? window.matchMedia('(prefers-color-scheme: dark)').matches
19
+ ? ThemeMode.DARK
20
+ : ThemeMode.LIGHT
21
+ : themeMode;
22
+ };
23
+ export var getDefaultLocale = function (locale) {
24
+ var _a;
25
+ return locale === Locale.DYNAMIC || locale === undefined
26
+ ? (_a = window.navigator.language.split('-')) === null || _a === void 0 ? void 0 : _a[0]
27
+ : locale;
28
+ };
29
+ export var getFullThemeMode = function (themeMode, colorStyle) {
30
+ var themeModeValue = getDefaultThemeMode(themeMode);
31
+ if (themeModeValue === ThemeMode.DARK) {
32
+ return colorStyle === ColorStyle.MONOCHROME ? FullThemeMode.DARK : FullThemeMode.DARK_COLORED;
33
+ }
34
+ else {
35
+ return colorStyle === ColorStyle.MONOCHROME ? FullThemeMode.LIGHT_MONO : FullThemeMode.LIGHT;
36
+ }
37
+ };
38
+ export var appendColors = function (colors) {
39
+ try {
40
+ var root_1 = document.documentElement;
41
+ Object.entries(colors).forEach(function (_a) {
42
+ var key = _a[0], value = _a[1];
43
+ root_1.style.setProperty("--".concat(key), value);
44
+ });
45
+ }
46
+ catch (e) {
47
+ throw e;
48
+ }
49
+ };
50
+ export var getTapThemeValue = function (_a) {
51
+ var tapTheme = _a.tapTheme, value = _a.value;
52
+ if (!tapTheme)
53
+ return '';
54
+ if (!value)
55
+ return '';
56
+ if (value[0] === '#')
57
+ return value;
58
+ var colorsObject = tapTheme === null || tapTheme === void 0 ? void 0 : tapTheme.GlobalValues.Colors;
59
+ var valueFromGlobalColors = colorsObject === null || colorsObject === void 0 ? void 0 : colorsObject[value];
60
+ return valueFromGlobalColors !== null && valueFromGlobalColors !== void 0 ? valueFromGlobalColors : '';
61
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tap-payments/apple-pay-button",
3
- "version": "0.0.55-development",
3
+ "version": "0.0.57-development",
4
4
  "description": "Apple Pay Button React Component",
5
5
  "main": "build/index.js",
6
6
  "module": "build/index.js",
@@ -10,15 +10,15 @@
10
10
  "README.md"
11
11
  ],
12
12
  "scripts": {
13
+ "start": "cross-env NODE_ENV=development webpack serve",
13
14
  "prepare": "npx husky install",
14
15
  "prettier": "prettier --list-different \"src/**/*.{md,mdx,ts,js,tsx,jsx,json}\" *.json *.js",
15
16
  "prettier:fix": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,css,json}\" *.json *.js",
16
17
  "lint": "eslint src --color --ext .js,.jsx,.ts,.tsx,.json",
17
18
  "lint:fix": "eslint src --ext .js,.jsx,.ts,.tsx --fix",
18
- "start": "cross-env NODE_ENV=development webpack serve",
19
- "build": "cross-env NODE_ENV=production webpack",
20
19
  "copy:files": "copyfiles -u 1 src/**/*.css build/",
21
20
  "tsc:alias": "tsc-alias -p tsconfig.json",
21
+ "build": "cross-env NODE_ENV=production webpack",
22
22
  "ts:build": "rm -rf build && tsc && yarn tsc:alias && yarn copy:files",
23
23
  "push": "npm publish --access public --tag development"
24
24
  },
@@ -28,11 +28,24 @@
28
28
  "email": "a.elsharkawy@tap.company"
29
29
  },
30
30
  "license": "ISC",
31
+ "dependencies": {
32
+ "@emotion/react": "^11.11.1",
33
+ "@emotion/styled": "^11.11.0",
34
+ "@mui/material": "^5.14.12",
35
+ "@tap-payments/browser-info": "^1.0.2",
36
+ "axios": "^1.2.2",
37
+ "framer-motion": "^10.16.5",
38
+ "jsencrypt": "^3.3.2",
39
+ "lottie-react": "^2.4.0",
40
+ "react": "^18.2.0",
41
+ "react-dom": "^18.2.0"
42
+ },
31
43
  "devDependencies": {
32
44
  "@babel/core": "^7.18.6",
33
45
  "@babel/preset-env": "^7.18.6",
34
46
  "@babel/preset-react": "^7.18.6",
35
47
  "@babel/preset-typescript": "^7.18.6",
48
+ "@types/applepayjs": "^14.0.3",
36
49
  "@types/crypto-js": "^4.1.1",
37
50
  "@types/react": "^18.0.15",
38
51
  "@types/react-dom": "^18.0.6",
@@ -71,13 +84,6 @@
71
84
  "webpack-dev-server": "^4.9.3",
72
85
  "webpack-merge": "^5.8.0"
73
86
  },
74
- "dependencies": {
75
- "@tap-payments/browser-info": "^1.0.2",
76
- "axios": "^1.2.2",
77
- "jsencrypt": "^3.3.2",
78
- "react": ">=17.0.2",
79
- "react-dom": ">=17.0.2"
80
- },
81
87
  "peerDependencies": {
82
88
  "react": ">=17.0.2",
83
89
  "react-dom": ">=17.0.2"