@tapcart/mobile-components 0.7.19 → 0.7.20

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.
@@ -0,0 +1,9 @@
1
+ import * as React from "react";
2
+ interface HtmlProps {
3
+ className?: any;
4
+ style?: React.CSSProperties;
5
+ html: string;
6
+ }
7
+ declare function Html({ className, style, html }: HtmlProps): import("react/jsx-runtime").JSX.Element;
8
+ export { Html };
9
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../../components/ui/html.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,UAAU,SAAS;IACjB,SAAS,CAAC,EAAE,GAAG,CAAA;IACf,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,IAAI,EAAE,MAAM,CAAA;CACb;AAED,iBAAS,IAAI,CAAC,EAAE,SAAc,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,SAAS,2CAUvD;AAED,OAAO,EAAE,IAAI,EAAE,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import DOMPurify from "dompurify";
3
+ function Html({ className = "", style, html }) {
4
+ const cleanHtml = DOMPurify.sanitize(html);
5
+ return (_jsx("div", { className: className, style: style, dangerouslySetInnerHTML: { __html: cleanHtml } }));
6
+ }
7
+ export { Html };
@@ -0,0 +1,17 @@
1
+ import * as React from "react";
2
+ import { type VariantProps } from "class-variance-authority";
3
+ declare const inputVariants: (props?: ({
4
+ error?: boolean | null | undefined;
5
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
6
+ export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange">, VariantProps<typeof inputVariants> {
7
+ id: string;
8
+ label?: string;
9
+ icon?: string;
10
+ asChild?: boolean;
11
+ value: string;
12
+ placeholder: string;
13
+ onChange: (_: string) => void;
14
+ }
15
+ declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
16
+ export { Input };
17
+ //# sourceMappingURL=input.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../components/ui/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,QAAA,MAAM,aAAa;;mFAalB,CAAA;AAED,MAAM,WAAW,UACf,SAAQ,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,EACnE,YAAY,CAAC,OAAO,aAAa,CAAC;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9B;AAED,QAAA,MAAM,KAAK,qFAkDV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
@@ -0,0 +1,35 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
+ import * as React from "react";
14
+ import { Slot } from "@radix-ui/react-slot";
15
+ import { cva } from "class-variance-authority";
16
+ import { cn } from "../../lib/utils";
17
+ import { Icon } from "./icon";
18
+ const inputVariants = cva("flex h-14 w-full rounded border border-coreColors-dividingLines bg-coreColors-inputBackground px-4 pt-5 pb-2 placeholder-shown:p-4 text-textColors-primaryColor text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-textColors-secondaryColor focus-visible:outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50 focus:border-coreColors-brandColorPrimary peer data-[icon=true]:pr-10", {
19
+ variants: {
20
+ error: {
21
+ true: "border-stateColors-error text-stateColors-error placeholder:text-stateColors-error focus:border-stateColors-error [&+label]:text-stateColors-error",
22
+ false: "",
23
+ },
24
+ },
25
+ defaultVariants: {
26
+ error: false,
27
+ },
28
+ });
29
+ const Input = React.forwardRef((_a, ref) => {
30
+ var { className, error = false, id, type, label, icon, asChild, value, placeholder, onChange } = _a, props = __rest(_a, ["className", "error", "id", "type", "label", "icon", "asChild", "value", "placeholder", "onChange"]);
31
+ const Comp = asChild ? Slot : "div";
32
+ return (_jsxs(Comp, Object.assign({ className: "relative group" }, { children: [_jsx("input", Object.assign({ placeholder: placeholder, value: value, onChange: (e) => onChange(e.target.value), id: id, type: type, className: cn(inputVariants({ error }), className), "data-icon": !!icon, ref: ref }, props)), label ? (_jsx("label", Object.assign({ htmlFor: id, className: "absolute text-[10px] text-textColors-secondaryColor group-active:text-coreColors-brandColorPrimary top-2 z-10 h-4 origin-[0] start-4 opacity-100 peer-placeholder-shown:opacity-0" }, { children: label }))) : null, icon ? (_jsx(Icon, { name: icon, "data-error": error, size: "sm", className: "absolute w-5 aspect-square fill-current text-textColors-secondaryColor top-[18px] z-10 origin-[0] end-4 peer-pr-8 icon data-[error=true]:text-stateColors-error" })) : null] })));
33
+ });
34
+ Input.displayName = "Input";
35
+ export { Input };
@@ -0,0 +1,15 @@
1
+ type Product = any;
2
+ interface PageData {
3
+ products: Product[];
4
+ cursorBlob?: string;
5
+ filtersData: any;
6
+ }
7
+ interface ProductGridItemsProps {
8
+ initialData: PageData;
9
+ loadMoreProducts: (params: any) => Promise<PageData>;
10
+ queryVariables: Record<string, any>;
11
+ config: Record<string, any>;
12
+ }
13
+ declare function ProductGrid({ loadMoreProducts, initialData, queryVariables, config, }: ProductGridItemsProps): import("react/jsx-runtime").JSX.Element;
14
+ export { ProductGrid };
15
+ //# sourceMappingURL=product-grid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product-grid.d.ts","sourceRoot":"","sources":["../../../components/ui/product-grid.tsx"],"names":[],"mappings":"AAkBA,KAAK,OAAO,GAAG,GAAG,CAAA;AAClB,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,GAAG,CAAA;CACjB;AAED,UAAU,qBAAqB;IAC7B,WAAW,EAAE,QAAQ,CAAA;IACrB,gBAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACpD,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5B;AAED,iBAAS,WAAW,CAAC,EACnB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,MAAM,GACP,EAAE,qBAAqB,2CAmCvB;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useInfiniteScroll } from "../hooks/use-infinite-scroll";
4
+ import { ProductCard } from "./product-card";
5
+ const Loader = () => (_jsx("div", Object.assign({ className: "grid-cols-2 lg:grid-cols-3" }, { children: Array(4)
6
+ .fill(0)
7
+ .map((_, index) => (_jsx("div", { className: "aspect-[2/3] animate-pulse bg-neutral-100 dark:bg-neutral-900" }, index))) })));
8
+ function ProductGrid({ loadMoreProducts, initialData, queryVariables, config, }) {
9
+ const { data, error, isLoadingInitialData, isLoadingMore, isEmpty, isReachingEnd, ref, products, } = useInfiniteScroll({
10
+ initialData,
11
+ loadMoreProducts,
12
+ queryVariables,
13
+ });
14
+ if (error)
15
+ return _jsx("div", { children: "Failed to load data" });
16
+ if (isLoadingInitialData)
17
+ return _jsx(Loader, {});
18
+ return (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({ className: "grid-cols-2 lg:grid-cols-3" }, { children: products.map((product, i) => (_jsx(ProductCard, {
19
+ // @ts-expect-error
20
+ product: product, config: config, isLoading: false }, product.handle))) })), isLoadingMore ? _jsx(Loader, {}) : _jsx("div", { ref: ref })] }));
21
+ }
22
+ export { ProductGrid };
package/dist/index.d.ts CHANGED
@@ -52,6 +52,7 @@ export * from "./components/ui/video";
52
52
  export * from "./components/ui/video-enhanced";
53
53
  export * from "./components/ui/wishlist";
54
54
  export * from "./components/ui/wishlist-select";
55
+ export * from "./components/ui/html";
55
56
  export * from "./components/hooks/use-shop";
56
57
  export * from "./components/libs/sort-filter/search-integration";
57
58
  export * from "./components/hooks/use-reviews";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,EAAE,EACF,GAAG,EACH,QAAQ,EACR,4BAA4B,EAC5B,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,eAAe,EACf,cAAc,GACf,MAAM,aAAa,CAAA;AACpB,cAAc,2CAA2C,CAAA;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AA;AAC3D,cAAc,kDAAkD,CAAA;AAChE,cAAc,qBAAqB,CAAA"}
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ export * from "./components/ui/video";
53
53
  export * from "./components/ui/video-enhanced";
54
54
  export * from "./components/ui/wishlist";
55
55
  export * from "./components/ui/wishlist-select";
56
+ export * from "./components/ui/html";
56
57
  export * from "./components/hooks/use-shop";
57
58
  export * from "./components/libs/sort-filter/search-integration";
58
59
  export * from "./components/hooks/use-reviews";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.19",
3
+ "version": "0.7.20",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",
@@ -11,18 +11,6 @@
11
11
  "license": "SEE LICENSE IN LICENSE.md",
12
12
  "author": "Tapcart Inc.",
13
13
  "homepage": "https://tapcart.com",
14
- "scripts": {
15
- "lint": "eslint \"**/*.ts*\"",
16
- "ui:add": "pnpm dlx shadcn-ui@latest add",
17
- "build:styles": "postcss styles/globals.css -o dist/styles.css",
18
- "build:ts": "tsc -p tsconfig.json && tsc-alias",
19
- "build": "pnpm run build:ts && pnpm run build:styles",
20
- "dev:ts": "tsc -w -p tsconfig.json",
21
- "dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
22
- "dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
23
- "test": "jest",
24
- "test:watch": "jest --watch"
25
- },
26
14
  "peerDependencies": {
27
15
  "react": "^17.0.2 || ^18.0.0",
28
16
  "react-dom": "^17.0.2 || ^18.0.0"
@@ -32,19 +20,19 @@
32
20
  "@types/lodash": "4.17.5",
33
21
  "@types/react": "^18.2.0",
34
22
  "@types/react-dom": "^18.2.0",
35
- "app-studio-types": "workspace:*",
36
23
  "autoprefixer": "^10.4.14",
37
24
  "chokidar-cli": "^3.0.0",
38
25
  "concurrently": "^8.2.2",
39
26
  "eslint": "^7.32.0",
40
- "eslint-config-custom": "workspace:*",
41
27
  "jest": "^29.7.0",
42
28
  "postcss": "^8.4.24",
43
29
  "tailwindcss": "^3.3.2",
44
30
  "ts-jest": "^29.2.5",
45
31
  "tsc-alias": "^1.8.10",
46
- "tsconfig": "workspace:*",
47
- "typescript": "^4.5.2"
32
+ "typescript": "^4.5.2",
33
+ "app-studio-types": "0.0.5",
34
+ "eslint-config-custom": "0.0.0",
35
+ "tsconfig": "0.0.0"
48
36
  },
49
37
  "dependencies": {
50
38
  "@radix-ui/react-accordion": "^1.1.2",
@@ -69,6 +57,7 @@
69
57
  "class-variance-authority": "^0.6.0",
70
58
  "clsx": "^1.2.1",
71
59
  "dayjs": "^1.11.13",
60
+ "dompurify": "^3.2.2",
72
61
  "embla-carousel-react": "^8.3.0",
73
62
  "lucide-react": "^0.248.0",
74
63
  "next": "^14.2.5",
@@ -80,5 +69,17 @@
80
69
  "tailwind-merge": "^1.13.2",
81
70
  "tailwindcss-animate": "^1.0.6",
82
71
  "vaul": "0.9.1"
72
+ },
73
+ "scripts": {
74
+ "lint": "eslint \"**/*.ts*\"",
75
+ "ui:add": "pnpm dlx shadcn-ui@latest add",
76
+ "build:styles": "postcss styles/globals.css -o dist/styles.css",
77
+ "build:ts": "tsc -p tsconfig.json && tsc-alias",
78
+ "build": "pnpm run build:ts && pnpm run build:styles",
79
+ "dev:ts": "tsc -w -p tsconfig.json",
80
+ "dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
81
+ "dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
82
+ "test": "jest",
83
+ "test:watch": "jest --watch"
83
84
  }
84
- }
85
+ }
@@ -1,10 +0,0 @@
1
- type Customer = {
2
- isAuthenticated: boolean;
3
- };
4
- type UseCustomerProps = {};
5
- type UseCustomerReturn = {
6
- customer: Customer;
7
- };
8
- export declare const useCustomer: (props: UseCustomerProps | null) => UseCustomerReturn;
9
- export {};
10
- //# sourceMappingURL=use-customer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-customer.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-customer.ts"],"names":[],"mappings":"AAWA,KAAK,QAAQ,GAAG;IACd,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAGD,KAAK,gBAAgB,GAAG,EAAE,CAAA;AAE1B,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,QAAQ,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,WAAW,UACf,gBAAgB,GAAG,IAAI,KAC7B,iBAuBF,CAAA"}
@@ -1,24 +0,0 @@
1
- "use client";
2
- import { useState, useEffect } from "react";
3
- // @ts-ignore -- webbridge-react is not typed (yet)
4
- import { useActions } from "@tapcart/webbridge-react";
5
- export const useCustomer = (props) => {
6
- const [isAuthenticated, setIsAuthenticated] = useState(false);
7
- const [customer, setCustomer] = useState({});
8
- const actions = useActions();
9
- // verify customer
10
- useEffect(() => {
11
- try {
12
- // webbridge method to get customerIdentity
13
- actions.getCustomerIdentity(null, {
14
- onSuccess: (user) => setIsAuthenticated(!!(user === null || user === void 0 ? void 0 : user.email)),
15
- });
16
- }
17
- catch (e) {
18
- console.log("unable to get customer identity ", e);
19
- }
20
- }, [actions]);
21
- return {
22
- customer: Object.assign({ isAuthenticated }, customer),
23
- };
24
- };
@@ -1,6 +0,0 @@
1
- import * as React from "react";
2
- export interface ApplePayButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
3
- }
4
- declare const ApplePayButton: React.ForwardRefExoticComponent<ApplePayButtonProps & React.RefAttributes<HTMLButtonElement>>;
5
- export { ApplePayButton };
6
- //# sourceMappingURL=apple-pay-button.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apple-pay-button.d.ts","sourceRoot":"","sources":["../../../components/ui/apple-pay-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,MAAM,WAAW,mBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;CACtD;AAED,QAAA,MAAM,cAAc,+FAyJnB,CAAA;AAGD,OAAO,EAAE,cAAc,EAAE,CAAA"}
@@ -1,144 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import { jsx as _jsx } from "react/jsx-runtime";
22
- import * as React from "react";
23
- import ApplePayButtonComponent from 'apple-pay-button';
24
- const ApplePayButton = React.forwardRef((_a, ref) => {
25
- var props = __rest(_a, []);
26
- const onClick = () => {
27
- // Define ApplePayPaymentRequest
28
- const applePayRequest = {
29
- countryCode: 'US',
30
- currencyCode: 'USD',
31
- merchantCapabilities: [
32
- "supports3DS"
33
- ],
34
- supportedNetworks: [
35
- "visa",
36
- "masterCard",
37
- "amex",
38
- "discover"
39
- ],
40
- total: {
41
- label: "Merchant Name",
42
- type: "final",
43
- amount: "10.00",
44
- }
45
- };
46
- // Create ApplePaySession
47
- const session = new ApplePaySession(3, applePayRequest);
48
- handleEventsForApplePay(session);
49
- session.begin();
50
- };
51
- const defaultFetcher = (url, body) => fetch(url, {
52
- method: body ? "POST" : "GET",
53
- headers: {
54
- "Content-Type": "application/json",
55
- },
56
- body: body ? JSON.stringify(body) : undefined,
57
- }).then((res) => res.json());
58
- // const fetcher = defaultFetcher
59
- // const { data, error } = useSWR(url ? [url, body] : null, ([url, body]) =>
60
- // fetcher(url, body)
61
- // )
62
- const validateMerchant = (validationURL, merchantIdentifier, domainName, displayName) => __awaiter(void 0, void 0, void 0, function* () {
63
- let url = "http://localhost:3000/3Mo5UakuRa/api/v1/applePay/merchantVerification";
64
- let body = {
65
- validationURL,
66
- merchantIdentifier,
67
- domainName,
68
- displayName
69
- };
70
- return defaultFetcher(url, body);
71
- });
72
- const handleEventsForApplePay = (session) => {
73
- session.onvalidatemerchant = (event) => __awaiter(void 0, void 0, void 0, function* () {
74
- const merchantSession = yield validateMerchant(event.validationURL, "merchantId", "domainName", "displayName");
75
- if (merchantSession) {
76
- session.completeMerchantValidation(merchantSession);
77
- }
78
- else {
79
- console.error("Error during validating merchant");
80
- }
81
- });
82
- session.onpaymentmethodselected = (event) => {
83
- // Define ApplePayPaymentMethodUpdate based on the selected payment method.
84
- // No updates or errors are needed, pass an empty object.
85
- const update = {
86
- newTotal: {
87
- label: "Merchant Name",
88
- type: "final",
89
- amount: "10.00",
90
- }
91
- };
92
- session.completePaymentMethodSelection(update);
93
- };
94
- session.onshippingmethodselected = (event) => {
95
- // Define ApplePayShippingMethodUpdate based on the selected shipping method.
96
- // No updates or errors are needed, pass an empty object.
97
- const update = {
98
- newTotal: {
99
- label: "Merchant Name",
100
- type: "final",
101
- amount: "10.00",
102
- }
103
- };
104
- session.completeShippingMethodSelection(update);
105
- };
106
- session.onshippingcontactselected = (event) => {
107
- // Define ApplePayShippingContactUpdate based on the selected shipping contact.
108
- const update = {
109
- newTotal: {
110
- label: "Merchant Name",
111
- type: "final",
112
- amount: "10.00",
113
- }
114
- };
115
- session.completeShippingContactSelection(update);
116
- };
117
- session.onpaymentauthorized = (event) => __awaiter(void 0, void 0, void 0, function* () {
118
- // Define ApplePayPaymentAuthorizationResult
119
- const paymentData = event.payment;
120
- if (paymentData.token) {
121
- // Forward token to your gateway for processing payment and return result to apple pay session
122
- const result = {
123
- status: ApplePaySession.STATUS_SUCCESS,
124
- };
125
- session.completePayment(result);
126
- }
127
- else {
128
- const result = {
129
- status: ApplePaySession.STATUS_FAILURE,
130
- };
131
- session.completePayment(result);
132
- }
133
- });
134
- session.oncancel = (event) => {
135
- console.log("Session Cancelled.");
136
- };
137
- };
138
- return (_jsx("div", { children: _jsx(ApplePayButtonComponent, { onClick: onClick, style: {
139
- width: '100%',
140
- borderRadius: '8px',
141
- }, type: "continue" }) }));
142
- });
143
- ApplePayButton.displayName = "ApplePayButton";
144
- export { ApplePayButton };