@tapcart/mobile-components 0.8.53 → 0.8.55
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/dist/components/hooks/use-infinite-scroll.d.ts +1 -4
- package/dist/components/hooks/use-infinite-scroll.d.ts.map +1 -1
- package/dist/components/hooks/use-infinite-scroll.js +5 -23
- package/dist/components/ui/apple-pay-button.d.ts +2 -1
- package/dist/components/ui/apple-pay-button.d.ts.map +1 -1
- package/dist/components/ui/apple-pay-button.js +4 -1
- package/package.json +1 -2
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ReadonlyURLSearchParams } from "next/navigation";
|
|
2
2
|
import { Product } from "app-studio-types";
|
|
3
|
-
import { SearchConfig } from "@tapcart/search-client";
|
|
4
3
|
interface PageData {
|
|
5
4
|
products: Product[];
|
|
6
5
|
cursorBlob?: string;
|
|
@@ -17,10 +16,8 @@ interface UseInfiniteScrollProps {
|
|
|
17
16
|
productLimit: number;
|
|
18
17
|
threshold?: number;
|
|
19
18
|
interval?: number;
|
|
20
|
-
integrations?: SearchConfig[];
|
|
21
19
|
customFetcher?: (...args: any[]) => Promise<any>;
|
|
22
20
|
customGetKey?: (pageIndex: number, previousPageData: any | null, ...args: any[]) => any;
|
|
23
|
-
getProduct: (handle?: string, id?: string) => Promise<Product | undefined>;
|
|
24
21
|
}
|
|
25
22
|
interface UseInfiniteScrollReturn {
|
|
26
23
|
data: PageData[] | undefined;
|
|
@@ -36,6 +33,6 @@ interface UseInfiniteScrollReturn {
|
|
|
36
33
|
}
|
|
37
34
|
export declare const formatSearchParamsAsNextQueryVariables: (searchParams: ReadonlyURLSearchParams) => {};
|
|
38
35
|
declare const constructURL: (apiURL: string) => string;
|
|
39
|
-
declare const useInfiniteScroll: ({ initialData, queryVariables: queryVariableProps, direction, productLimit, threshold, interval,
|
|
36
|
+
declare const useInfiniteScroll: ({ initialData, queryVariables: queryVariableProps, direction, productLimit, threshold, interval, customFetcher, customGetKey, }: UseInfiniteScrollProps) => UseInfiniteScrollReturn;
|
|
40
37
|
export { useInfiniteScroll, constructURL };
|
|
41
38
|
//# sourceMappingURL=use-infinite-scroll.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-infinite-scroll.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-infinite-scroll.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAmB,MAAM,iBAAiB,CAAA;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"use-infinite-scroll.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-infinite-scroll.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,uBAAuB,EAAmB,MAAM,iBAAiB,CAAA;AAE1E,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE1C,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,GAAG,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;CACxC;AAED,UAAU,sBAAsB;IAC9B,WAAW,EAAE,QAAQ,CAAA;IACrB,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,SAAS,EAAE,UAAU,GAAG,YAAY,CAAA;IACpC,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,aAAa,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAChD,YAAY,CAAC,EAAE,CACb,SAAS,EAAE,MAAM,EACjB,gBAAgB,EAAE,GAAG,GAAG,IAAI,EAC5B,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,GAAG,CAAA;CACT;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,QAAQ,EAAE,GAAG,SAAS,CAAA;IAC5B,KAAK,EAAE,GAAG,CAAA;IACV,oBAAoB,EAAE,OAAO,CAAA;IAC7B,aAAa,EAAE,OAAO,GAAG,SAAS,CAAA;IAClC,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,OAAO,CAAA;IACtB,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,KAAK,IAAI,CAAA;IAChD,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,SAAS,EAAE,OAAO,CAAA;IAClB,YAAY,EAAE,OAAO,CAAA;CACtB;AAED,eAAO,MAAM,sCAAsC,iBACnC,uBAAuB,OAsBtC,CAAA;AAED,QAAA,MAAM,YAAY,WAAY,MAAM,WAGnC,CAAA;AAED,QAAA,MAAM,iBAAiB,oIASpB,sBAAsB,KAAG,uBA8H3B,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -13,8 +13,6 @@ import useSWRInfinite from "swr/infinite";
|
|
|
13
13
|
import { useInView } from "react-intersection-observer";
|
|
14
14
|
import { useSearchParams } from "next/navigation";
|
|
15
15
|
import { throttle } from "lodash";
|
|
16
|
-
import { getSearchClientFromIntegrations, } from "@tapcart/search-client";
|
|
17
|
-
const searchClientMap = {};
|
|
18
16
|
export const formatSearchParamsAsNextQueryVariables = (searchParams) => {
|
|
19
17
|
const formattedParams = {};
|
|
20
18
|
if (!searchParams)
|
|
@@ -44,23 +42,10 @@ const constructURL = (apiURL) => {
|
|
|
44
42
|
return url.toString();
|
|
45
43
|
};
|
|
46
44
|
const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, direction = "vertical", productLimit = Infinity, threshold = 0.01, interval = 33, // ~2 frames
|
|
47
|
-
|
|
45
|
+
customFetcher, customGetKey, }) => {
|
|
48
46
|
var _a, _b, _c, _d, _e, _f;
|
|
49
47
|
const searchParams = useSearchParams();
|
|
50
48
|
const productCount = useRef(0);
|
|
51
|
-
const mapKey = JSON.stringify({ integrations, queryVariableProps });
|
|
52
|
-
let searchClient;
|
|
53
|
-
if (mapKey in searchClientMap) {
|
|
54
|
-
searchClient = searchClientMap[mapKey];
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
searchClient = getSearchClientFromIntegrations({
|
|
58
|
-
configs: integrations,
|
|
59
|
-
queryParams: queryVariableProps,
|
|
60
|
-
getProduct,
|
|
61
|
-
});
|
|
62
|
-
searchClientMap[mapKey] = searchClient;
|
|
63
|
-
}
|
|
64
49
|
const { ref, inView } = useInView({
|
|
65
50
|
rootMargin: direction === "vertical" ? "600px" : "0px 420px 0px 0px",
|
|
66
51
|
threshold: threshold,
|
|
@@ -78,8 +63,8 @@ integrations = [], customFetcher, customGetKey, getProduct, }) => {
|
|
|
78
63
|
return null;
|
|
79
64
|
return Object.assign(Object.assign({}, queryVariables), { cursorBlob: previousPageData.pageData.cursorBlob });
|
|
80
65
|
};
|
|
81
|
-
if (customGetKey
|
|
82
|
-
getKey = customGetKey
|
|
66
|
+
if (customGetKey) {
|
|
67
|
+
getKey = customGetKey;
|
|
83
68
|
}
|
|
84
69
|
let fetcher = (body) => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
70
|
const res = yield fetch(constructURL(initialData.apiURL), {
|
|
@@ -89,8 +74,8 @@ integrations = [], customFetcher, customGetKey, getProduct, }) => {
|
|
|
89
74
|
const data = yield res.json();
|
|
90
75
|
return data;
|
|
91
76
|
});
|
|
92
|
-
if (customFetcher
|
|
93
|
-
fetcher = customFetcher
|
|
77
|
+
if (customFetcher) {
|
|
78
|
+
fetcher = customFetcher;
|
|
94
79
|
}
|
|
95
80
|
const { data, error, size, setSize, isLoading, isValidating, } = useSWRInfinite((pageIndex, previousPageData) => getKey(pageIndex, previousPageData, queryVariables), fetcher, {
|
|
96
81
|
revalidateFirstPage: false,
|
|
@@ -99,9 +84,6 @@ integrations = [], customFetcher, customGetKey, getProduct, }) => {
|
|
|
99
84
|
productCount.current += (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data[size - 1]) === null || _a === void 0 ? void 0 : _a.products) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
100
85
|
const hasMore = () => {
|
|
101
86
|
var _a, _b;
|
|
102
|
-
if (searchClient) {
|
|
103
|
-
return searchClient.getHasMore();
|
|
104
|
-
}
|
|
105
87
|
return (_b = (_a = data === null || data === void 0 ? void 0 : data[size - 1]) === null || _a === void 0 ? void 0 : _a.pageData) === null || _b === void 0 ? void 0 : _b.cursorBlob;
|
|
106
88
|
};
|
|
107
89
|
const isLoadingInitialData = !data && !error;
|
|
@@ -24,6 +24,7 @@ export interface ApplePayButtonProps extends React.ButtonHTMLAttributes<HTMLButt
|
|
|
24
24
|
padding?: string | undefined;
|
|
25
25
|
boxSizing?: string | undefined;
|
|
26
26
|
};
|
|
27
|
+
isReactNative?: boolean;
|
|
27
28
|
onClick?: () => void;
|
|
28
29
|
onPaymentAuthorized?: (paymentData: ApplePayJS.ApplePayPayment) => Promise<boolean>;
|
|
29
30
|
onPaymentMethodSelected?: (paymentMethod: ApplePayJS.ApplePayPaymentMethod) => Promise<ApplePayJS.ApplePayPaymentMethodUpdate>;
|
|
@@ -32,7 +33,7 @@ export interface ApplePayButtonProps extends React.ButtonHTMLAttributes<HTMLButt
|
|
|
32
33
|
onPaymentCancelled?: (event?: ApplePayJS.Event) => void;
|
|
33
34
|
}
|
|
34
35
|
declare const ApplePayButton: {
|
|
35
|
-
({ displayName, amount, requiredBillingContactFields, requiredShippingContactFields, startSessionURL, startSessionCacheBypass, appId, domainName, countryCode, currencyCode, merchantCapabilities, supportedNetworks, buttonType, buttonStyle, applePayButtonStyle, onClick, onPaymentAuthorized, onPaymentMethodSelected, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }: ApplePayButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
({ displayName, amount, requiredBillingContactFields, requiredShippingContactFields, startSessionURL, startSessionCacheBypass, appId, domainName, countryCode, currencyCode, merchantCapabilities, supportedNetworks, buttonType, buttonStyle, applePayButtonStyle, isReactNative, onClick, onPaymentAuthorized, onPaymentMethodSelected, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }: ApplePayButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
36
37
|
displayName: string;
|
|
37
38
|
};
|
|
38
39
|
export { ApplePayButton };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apple-pay-button.d.ts","sourceRoot":"","sources":["../../../components/ui/apple-pay-button.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,MAAM,MAAM,kBAAkB,GAC1B,OAAO,GACP,WAAW,GACX,MAAM,GACN,KAAK,GACL,WAAW,GACX,UAAU,GACV,YAAY,GACZ,QAAQ,GACR,OAAO,GACP,KAAK,GACL,QAAQ,GACR,MAAM,GACN,QAAQ,GACR,WAAW,GACX,SAAS,GACT,KAAK,GACL,QAAQ,CAAA;AAEZ,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,OAAO,GAAG,eAAe,CAAA;AAErE,MAAM,WAAW,mBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC;IACrD,WAAW,EAAE,MAAM,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,4BAA4B,CAAC,EAAE,UAAU,CAAC,oBAAoB,EAAE,CAAA;IAChE,6BAA6B,CAAC,EAAE,UAAU,CAAC,oBAAoB,EAAE,CAAA;IACjE,eAAe,EAAE,MAAM,CAAA;IACvB,uBAAuB,EAAE,OAAO,CAAA;IAChC,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAA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AO,CAAA;IACvB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,mBAAmB,CAAC,EAAE,CACpB,WAAW,EAAE,UAAU,CAAC,eAAe,KACpC,OAAO,CAAC,OAAO,CAAC,CAAA;IACrB,uBAAuB,CAAC,EAAE,CACxB,aAAa,EAAE,UAAU,CAAC,qBAAqB,KAC5C,OAAO,CAAC,UAAU,CAAC,2BAA2B,CAAC,CAAA;IACpD,yBAAyB,CAAC,EAAE,CAC1B,eAAe,EAAE,UAAU,CAAC,sBAAsB,KAC/C,OAAO,CAAC,UAAU,CAAC,4BAA4B,CAAC,CAAA;IACrD,wBAAwB,CAAC,EAAE,CACzB,cAAc,EAAE,UAAU,CAAC,sBAAsB,KAC9C,OAAO,CAAC,UAAU,CAAC,4BAA4B,CAAC,CAAA;IACrD,kBAAkB,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,KAAK,KAAK,IAAI,CAAA;CACxD;AAED,QAAA,MAAM,cAAc;0ZAuBjB,mBAAmB;;CAoLrB,CAAA;AAID,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -10,11 +10,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
12
|
import ApplePayButtonComponent from "apple-pay-button";
|
|
13
|
-
const ApplePayButton = ({ displayName, amount, requiredBillingContactFields = ["name", "postalAddress", "phone", "email"], requiredShippingContactFields = ["name", "postalAddress", "phone", "email"], startSessionURL, startSessionCacheBypass = false, appId, domainName, countryCode = "US", currencyCode = "USD", merchantCapabilities = ["supports3DS"], supportedNetworks = ["visa", "masterCard", "amex", "discover"], buttonType = "plain", buttonStyle = "white-outline", applePayButtonStyle, onClick, onPaymentAuthorized, onPaymentMethodSelected, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }) => {
|
|
13
|
+
const ApplePayButton = ({ displayName, amount, requiredBillingContactFields = ["name", "postalAddress", "phone", "email"], requiredShippingContactFields = ["name", "postalAddress", "phone", "email"], startSessionURL, startSessionCacheBypass = false, appId, domainName, countryCode = "US", currencyCode = "USD", merchantCapabilities = ["supports3DS"], supportedNetworks = ["visa", "masterCard", "amex", "discover"], buttonType = "plain", buttonStyle = "white-outline", applePayButtonStyle, isReactNative = false, onClick, onPaymentAuthorized, onPaymentMethodSelected, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }) => {
|
|
14
14
|
const onClickHandler = () => {
|
|
15
15
|
if (onClick !== undefined) {
|
|
16
16
|
onClick();
|
|
17
17
|
}
|
|
18
|
+
if (isReactNative) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
18
21
|
const applePayRequest = {
|
|
19
22
|
countryCode,
|
|
20
23
|
currencyCode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapcart/mobile-components",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.55",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/styles.css",
|
|
@@ -73,7 +73,6 @@
|
|
|
73
73
|
"@tabler/icons-react": "^3.2.0",
|
|
74
74
|
"@tanstack/react-virtual": "^3.13.6",
|
|
75
75
|
"@tapcart/app-studio-sdk": "^2.1.2",
|
|
76
|
-
"@tapcart/search-client": "workspace:*",
|
|
77
76
|
"apple-pay-button": "^1.1.7",
|
|
78
77
|
"class-variance-authority": "^0.6.0",
|
|
79
78
|
"clsx": "^1.2.1",
|