@tapcart/mobile-components 0.7.45 → 0.7.47
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-click-outside.d.ts +3 -0
- package/dist/components/hooks/use-click-outside.d.ts.map +1 -0
- package/dist/components/hooks/use-click-outside.js +16 -0
- package/dist/components/hooks/use-infinite-scroll.d.ts +3 -1
- package/dist/components/hooks/use-infinite-scroll.d.ts.map +1 -1
- package/dist/components/hooks/use-infinite-scroll.js +15 -6
- package/dist/components/hooks/use-mock-cart.d.ts +61 -0
- package/dist/components/hooks/use-mock-cart.d.ts.map +1 -0
- package/dist/components/hooks/use-mock-cart.js +93 -0
- package/dist/components/hooks/use-outside-click.d.ts +4 -0
- package/dist/components/hooks/use-outside-click.d.ts.map +1 -0
- package/dist/components/hooks/use-outside-click.js +16 -0
- package/dist/components/ui/apple-pay-button.d.ts +29 -0
- package/dist/components/ui/apple-pay-button.d.ts.map +1 -0
- package/dist/components/ui/apple-pay-button.js +144 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/styles.css +9 -0
- package/package.json +21 -19
- package/dist/components/ThemeProvider.d.ts +0 -3
- package/dist/components/ThemeProvider.d.ts.map +0 -1
- package/dist/components/ThemeProvider.js +0 -18
- package/dist/components/ThemeToggle.d.ts +0 -2
- package/dist/components/ThemeToggle.d.ts.map +0 -1
- package/dist/components/ThemeToggle.js +0 -8
- package/dist/components/hooks/use-block-conditionals.d.ts +0 -2
- package/dist/components/hooks/use-block-conditionals.d.ts.map +0 -1
- package/dist/components/hooks/use-block-conditionals.js +0 -2
- package/dist/components/ui/input.d.ts +0 -17
- package/dist/components/ui/input.d.ts.map +0 -1
- package/dist/components/ui/input.js +0 -35
- package/dist/components/ui/product-grid.d.ts +0 -15
- package/dist/components/ui/product-grid.d.ts.map +0 -1
- package/dist/components/ui/product-grid.js +0 -22
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-click-outside.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-click-outside.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAE,IAAI,CAa5F"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export function useClickOutside(ref, callback) {
|
|
4
|
+
React.useEffect(() => {
|
|
5
|
+
const handleClickOutside = (event) => {
|
|
6
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
7
|
+
callback();
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
11
|
+
return () => {
|
|
12
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
13
|
+
};
|
|
14
|
+
}, [ref, callback]);
|
|
15
|
+
}
|
|
16
|
+
;
|
|
@@ -16,6 +16,8 @@ interface UseInfiniteScrollProps {
|
|
|
16
16
|
queryVariables: Record<string, any>;
|
|
17
17
|
direction: "vertical" | "horizontal";
|
|
18
18
|
productLimit: number;
|
|
19
|
+
threshold?: number;
|
|
20
|
+
interval?: number;
|
|
19
21
|
}
|
|
20
22
|
interface UseInfiniteScrollReturn {
|
|
21
23
|
data: PageData[] | undefined;
|
|
@@ -31,6 +33,6 @@ interface UseInfiniteScrollReturn {
|
|
|
31
33
|
}
|
|
32
34
|
export declare const formatSearchParamsAsNextQueryVariables: (searchParams: ReadonlyURLSearchParams) => {};
|
|
33
35
|
declare const constructURL: (apiURL: string) => string;
|
|
34
|
-
declare const useInfiniteScroll: ({ initialData, queryVariables: queryVariableProps, direction, productLimit, }: UseInfiniteScrollProps) => UseInfiniteScrollReturn;
|
|
36
|
+
declare const useInfiniteScroll: ({ initialData, queryVariables: queryVariableProps, direction, productLimit, threshold, interval, }: UseInfiniteScrollProps) => UseInfiniteScrollReturn;
|
|
35
37
|
export { useInfiniteScroll, constructURL };
|
|
36
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;
|
|
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;AAG1E,UAAU,OAAO;IACf,MAAM,EAAE,MAAM,CAAA;CAEf;AAED,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;AAOD,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;CAClB;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,uGAOpB,sBAAsB,KAAG,uBAmH3B,CAAA;AAED,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -12,6 +12,7 @@ import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
|
12
12
|
import useSWRInfinite from "swr/infinite";
|
|
13
13
|
import { useInView } from "react-intersection-observer";
|
|
14
14
|
import { useSearchParams } from "next/navigation";
|
|
15
|
+
import { throttle } from "lodash";
|
|
15
16
|
export const formatSearchParamsAsNextQueryVariables = (searchParams) => {
|
|
16
17
|
const formattedParams = {};
|
|
17
18
|
if (!searchParams)
|
|
@@ -40,13 +41,13 @@ const constructURL = (apiURL) => {
|
|
|
40
41
|
const url = new URL(apiURL);
|
|
41
42
|
return url.toString();
|
|
42
43
|
};
|
|
43
|
-
const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, direction = "vertical", productLimit = Infinity, }) => {
|
|
44
|
+
const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, direction = "vertical", productLimit = Infinity, threshold = 0.8, interval = 300, }) => {
|
|
44
45
|
var _a, _b, _c, _d, _e;
|
|
45
46
|
const searchParams = useSearchParams();
|
|
46
47
|
const productCount = useRef(0);
|
|
47
48
|
const { ref, inView } = useInView({
|
|
48
49
|
rootMargin: direction === "vertical" ? "600px" : "0px 420px 0px 0px",
|
|
49
|
-
threshold:
|
|
50
|
+
threshold: threshold,
|
|
50
51
|
});
|
|
51
52
|
const queryVariables = useMemo(() => {
|
|
52
53
|
const formattedParams = formatSearchParamsAsNextQueryVariables(searchParams);
|
|
@@ -85,17 +86,25 @@ const useInfiniteScroll = ({ initialData, queryVariables: queryVariableProps, di
|
|
|
85
86
|
const isReachingEnd = isEmpty || isEndPointer;
|
|
86
87
|
const isRefreshing = isValidating && data && data.length === size;
|
|
87
88
|
const loadMore = useCallback(() => {
|
|
88
|
-
if (isLoadingMore || isReachingEnd || isRefreshing)
|
|
89
|
+
if (isLoading || isLoadingMore || isReachingEnd || isRefreshing)
|
|
89
90
|
return;
|
|
90
91
|
if (productCount.current >= productLimit)
|
|
91
92
|
return;
|
|
92
93
|
setSize(size + 1);
|
|
93
|
-
}, [
|
|
94
|
+
}, [
|
|
95
|
+
isLoading,
|
|
96
|
+
isLoadingMore,
|
|
97
|
+
isReachingEnd,
|
|
98
|
+
isRefreshing,
|
|
99
|
+
productLimit,
|
|
100
|
+
setSize,
|
|
101
|
+
]);
|
|
102
|
+
const throttleLoadMore = useMemo(() => throttle(loadMore, interval), [loadMore, interval]);
|
|
94
103
|
useEffect(() => {
|
|
95
104
|
if (inView) {
|
|
96
|
-
|
|
105
|
+
throttleLoadMore();
|
|
97
106
|
}
|
|
98
|
-
}, [inView,
|
|
107
|
+
}, [inView, throttleLoadMore]);
|
|
99
108
|
return {
|
|
100
109
|
data,
|
|
101
110
|
error,
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Product } from "app-studio-types";
|
|
2
|
+
type UseMockCartParams = {
|
|
3
|
+
apiUrl: string;
|
|
4
|
+
appId: string;
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
limit?: number;
|
|
7
|
+
};
|
|
8
|
+
export declare const useMockCart: ({ apiUrl, appId, enabled, limit, }: UseMockCartParams) => {
|
|
9
|
+
error: {
|
|
10
|
+
message: string;
|
|
11
|
+
};
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
cart: {};
|
|
14
|
+
} | {
|
|
15
|
+
error: any;
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
cart: {
|
|
18
|
+
subtotal: number;
|
|
19
|
+
items: {
|
|
20
|
+
discounts: Record<string, string | number>[];
|
|
21
|
+
productId: string;
|
|
22
|
+
quantity: number;
|
|
23
|
+
variantId: string;
|
|
24
|
+
productDetails: Product;
|
|
25
|
+
variantDetails: import("app-studio-types").ProductVariant;
|
|
26
|
+
cost: {
|
|
27
|
+
totalAmount: {
|
|
28
|
+
amount: string;
|
|
29
|
+
currencyCode: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
sellingPlanAllocation: {
|
|
33
|
+
priceAdjustments: {
|
|
34
|
+
perDeliveryPrice: {
|
|
35
|
+
amount: number;
|
|
36
|
+
currencyCode: string;
|
|
37
|
+
};
|
|
38
|
+
price: {
|
|
39
|
+
amount: number;
|
|
40
|
+
currencyCode: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
sellingPlan: {
|
|
44
|
+
id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
recurringDeliveries: boolean;
|
|
47
|
+
};
|
|
48
|
+
} | undefined;
|
|
49
|
+
}[];
|
|
50
|
+
attributes: {
|
|
51
|
+
key: string;
|
|
52
|
+
value: string;
|
|
53
|
+
}[];
|
|
54
|
+
currency: string;
|
|
55
|
+
discounts: string[];
|
|
56
|
+
id: string;
|
|
57
|
+
note: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=use-mock-cart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-mock-cart.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-mock-cart.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAqF1C,KAAK,iBAAiB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,eAAO,MAAM,WAAW,uCAKrB,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+BnB,CAAA"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getIdFromGid } from "../../lib/utils";
|
|
3
|
+
import { useProducts } from "./use-products";
|
|
4
|
+
const cartMock = {
|
|
5
|
+
attributes: [{ key: "tapcart_id", value: "123" }],
|
|
6
|
+
currency: "USD",
|
|
7
|
+
discounts: ["10_OFF_ORDER"],
|
|
8
|
+
id: "456?key=789",
|
|
9
|
+
items: [],
|
|
10
|
+
note: "this is a mock cart",
|
|
11
|
+
subtotal: 0,
|
|
12
|
+
};
|
|
13
|
+
const transformCart = ({ products, cartOrigin = cartMock, }) => {
|
|
14
|
+
let subtotal = cartOrigin.subtotal;
|
|
15
|
+
const items = products.map((product, i) => {
|
|
16
|
+
const variant = product.variants[0];
|
|
17
|
+
const price = parseInt(variant.price.amount);
|
|
18
|
+
const productId = getIdFromGid(product.id);
|
|
19
|
+
const variantId = getIdFromGid(variant.id);
|
|
20
|
+
const discounts = [];
|
|
21
|
+
const cost = {
|
|
22
|
+
totalAmount: {
|
|
23
|
+
amount: price.toString(),
|
|
24
|
+
currencyCode: "USD",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
subtotal += price;
|
|
28
|
+
let sellingPlanAllocation;
|
|
29
|
+
if (i === 0) {
|
|
30
|
+
const discount = price / 10;
|
|
31
|
+
subtotal -= discount;
|
|
32
|
+
discounts.push({
|
|
33
|
+
amount: parseInt(variant.price.amount) / 10,
|
|
34
|
+
code: "10_OFF_PRODUCT",
|
|
35
|
+
type: "code",
|
|
36
|
+
});
|
|
37
|
+
sellingPlanAllocation = {
|
|
38
|
+
priceAdjustments: {
|
|
39
|
+
perDeliveryPrice: {
|
|
40
|
+
amount: price,
|
|
41
|
+
currencyCode: "USD",
|
|
42
|
+
},
|
|
43
|
+
price: {
|
|
44
|
+
amount: price,
|
|
45
|
+
currencyCode: "USD",
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
sellingPlan: {
|
|
49
|
+
id: "gid://shopify/SellingPlan/123",
|
|
50
|
+
name: "Delivery every 30 Days",
|
|
51
|
+
recurringDeliveries: true,
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
discounts,
|
|
57
|
+
productId,
|
|
58
|
+
quantity: 1,
|
|
59
|
+
variantId,
|
|
60
|
+
productDetails: product,
|
|
61
|
+
variantDetails: variant,
|
|
62
|
+
cost,
|
|
63
|
+
sellingPlanAllocation,
|
|
64
|
+
};
|
|
65
|
+
});
|
|
66
|
+
return Object.assign(Object.assign({}, cartOrigin), { subtotal,
|
|
67
|
+
items });
|
|
68
|
+
};
|
|
69
|
+
export const useMockCart = ({ apiUrl, appId, enabled = true, limit = 1, }) => {
|
|
70
|
+
const { products, error: productsError, isLoading: productsLoading, } = useProducts({
|
|
71
|
+
productIds: [],
|
|
72
|
+
productHandles: [],
|
|
73
|
+
baseURL: apiUrl,
|
|
74
|
+
queryVariables: {
|
|
75
|
+
appId,
|
|
76
|
+
limit,
|
|
77
|
+
},
|
|
78
|
+
mock: enabled,
|
|
79
|
+
onlyAvailableProducts: true,
|
|
80
|
+
});
|
|
81
|
+
if (!enabled)
|
|
82
|
+
return {
|
|
83
|
+
error: { message: "cart mock skipped" },
|
|
84
|
+
isLoading: false,
|
|
85
|
+
cart: {},
|
|
86
|
+
};
|
|
87
|
+
const cart = transformCart({ products });
|
|
88
|
+
return {
|
|
89
|
+
error: productsError,
|
|
90
|
+
isLoading: productsLoading,
|
|
91
|
+
cart,
|
|
92
|
+
};
|
|
93
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-outside-click.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-outside-click.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,QAAA,MAAM,eAAe,QAAS,MAAM,SAAS,CAAC,WAAW,CAAC,YAAY,MAAM,IAAI,SAa/E,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
const useClickOutside = (ref, callback) => {
|
|
4
|
+
React.useEffect(() => {
|
|
5
|
+
const handleClickOutside = (event) => {
|
|
6
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
7
|
+
callback();
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
11
|
+
return () => {
|
|
12
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
13
|
+
};
|
|
14
|
+
}, [ref, callback]);
|
|
15
|
+
};
|
|
16
|
+
export default useClickOutside;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/// <reference types="applepayjs" />
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
export type ApplePayButtonType = "plain" | "add-money" | "book" | "buy" | "check-out" | "continue" | "contribute" | "donate" | "order" | "pay" | "reload" | "rent" | "set-up" | "subscribe" | "support" | "tip" | "top-up";
|
|
4
|
+
export type ApplePayButtonStyle = "black" | "white" | "white-outline";
|
|
5
|
+
export interface ApplePayButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
6
|
+
displayName: string;
|
|
7
|
+
amount: number;
|
|
8
|
+
requiredBillingContactFields?: ApplePayJS.ApplePayContactField[];
|
|
9
|
+
requiredShippingContactFields?: ApplePayJS.ApplePayContactField[];
|
|
10
|
+
startSessionURL: string;
|
|
11
|
+
appId: string;
|
|
12
|
+
domainName: string;
|
|
13
|
+
countryCode?: string;
|
|
14
|
+
currencyCode?: string;
|
|
15
|
+
merchantCapabilities?: ApplePayJS.ApplePayMerchantCapability[];
|
|
16
|
+
supportedNetworks?: string[];
|
|
17
|
+
buttonType?: ApplePayButtonType;
|
|
18
|
+
buttonStyle?: ApplePayButtonStyle;
|
|
19
|
+
onPaymentAuthorized?: (paymentData: ApplePayJS.ApplePayPayment) => Promise<void>;
|
|
20
|
+
onShippingContactSelected?: (shippingContact: ApplePayJS.ApplePayPaymentContact) => Promise<ApplePayJS.ApplePayShippingMethodUpdate>;
|
|
21
|
+
onShippingMethodSelected?: (shippingMethod: ApplePayJS.ApplePayShippingMethod) => ApplePayJS.ApplePayShippingMethodUpdate;
|
|
22
|
+
onPaymentCancelled?: () => void;
|
|
23
|
+
}
|
|
24
|
+
declare const ApplePayButton: {
|
|
25
|
+
({ displayName, amount, requiredBillingContactFields, requiredShippingContactFields, startSessionURL, appId, domainName, countryCode, currencyCode, merchantCapabilities, supportedNetworks, buttonType, buttonStyle, onPaymentAuthorized, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }: ApplePayButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
displayName: string;
|
|
27
|
+
};
|
|
28
|
+
export { ApplePayButton };
|
|
29
|
+
//# sourceMappingURL=apple-pay-button.d.ts.map
|
|
@@ -0,0 +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,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,MAAM,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,oBAAoB,CAAC,EAAE,UAAU,CAAC,0BAA0B,EAAE,CAAA;IAC9D,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B,UAAU,CAAC,EAAE,kBAAkB,CAAA;IAC/B,WAAW,CAAC,EAAE,mBAAmB,CAAA;IACjC,mBAAmB,CAAC,EAAE,CACpB,WAAW,EAAE,UAAU,CAAC,eAAe,KACpC,OAAO,CAAC,IAAI,CAAC,CAAA;IAClB,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,UAAU,CAAC,4BAA4B,CAAA;IAC5C,kBAAkB,CAAC,EAAE,MAAM,IAAI,CAAA;CAChC;AAED,QAAA,MAAM,cAAc;2TAkBjB,mBAAmB;;CAyLrB,CAAA;AAID,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import ApplePayButtonComponent from "apple-pay-button";
|
|
14
|
+
const ApplePayButton = ({ displayName, amount, requiredBillingContactFields = ["name", "postalAddress", "phone", "email"], requiredShippingContactFields = ["name", "postalAddress", "phone", "email"], startSessionURL, appId, domainName, countryCode = "US", currencyCode = "USD", merchantCapabilities = ["supports3DS"], supportedNetworks = ["visa", "masterCard", "amex", "discover"], buttonType = "plain", buttonStyle = "white-outline", onPaymentAuthorized, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }) => {
|
|
15
|
+
const [paymentDataResult, setPaymentDataResult] = React.useState("");
|
|
16
|
+
const onClick = () => {
|
|
17
|
+
const applePayRequest = {
|
|
18
|
+
countryCode,
|
|
19
|
+
currencyCode,
|
|
20
|
+
merchantCapabilities,
|
|
21
|
+
supportedNetworks,
|
|
22
|
+
total: {
|
|
23
|
+
label: displayName,
|
|
24
|
+
type: "final",
|
|
25
|
+
amount: amount.toString(),
|
|
26
|
+
},
|
|
27
|
+
requiredShippingContactFields,
|
|
28
|
+
requiredBillingContactFields,
|
|
29
|
+
};
|
|
30
|
+
const session = new ApplePaySession(3, applePayRequest);
|
|
31
|
+
handleEventsForApplePay(session);
|
|
32
|
+
session.begin();
|
|
33
|
+
};
|
|
34
|
+
const defaultFetcher = (url, body) => fetch(url, {
|
|
35
|
+
method: body ? "POST" : "GET",
|
|
36
|
+
headers: {
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
},
|
|
39
|
+
body: body ? JSON.stringify(body) : undefined,
|
|
40
|
+
}).then((res) => res.json());
|
|
41
|
+
const validateMerchant = (validationURL, appId, domainName, displayName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
let url = startSessionURL;
|
|
43
|
+
let body = {
|
|
44
|
+
validationURL,
|
|
45
|
+
appId,
|
|
46
|
+
domainName,
|
|
47
|
+
displayName,
|
|
48
|
+
};
|
|
49
|
+
console.log("request body", body);
|
|
50
|
+
const response = yield defaultFetcher(url, body);
|
|
51
|
+
return response.data;
|
|
52
|
+
});
|
|
53
|
+
const handleEventsForApplePay = (session) => {
|
|
54
|
+
session.onvalidatemerchant = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
55
|
+
const response = yield validateMerchant(event.validationURL, appId, domainName, displayName);
|
|
56
|
+
if (response) {
|
|
57
|
+
session.completeMerchantValidation(response);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
console.error("Error during validating merchant");
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
session.onpaymentmethodselected = (event) => {
|
|
64
|
+
const update = {
|
|
65
|
+
newTotal: {
|
|
66
|
+
label: displayName,
|
|
67
|
+
type: "final",
|
|
68
|
+
amount: amount.toString(),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
session.completePaymentMethodSelection(update);
|
|
72
|
+
};
|
|
73
|
+
session.onshippingmethodselected = (event) => {
|
|
74
|
+
const shippingMethod = event.shippingMethod;
|
|
75
|
+
let update = {
|
|
76
|
+
newTotal: {
|
|
77
|
+
label: displayName,
|
|
78
|
+
type: "final",
|
|
79
|
+
amount: amount.toString(),
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
if (onShippingMethodSelected) {
|
|
83
|
+
update = onShippingMethodSelected(shippingMethod);
|
|
84
|
+
}
|
|
85
|
+
session.completeShippingMethodSelection(update);
|
|
86
|
+
};
|
|
87
|
+
session.onshippingcontactselected = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
+
const shippingContact = event.shippingContact;
|
|
89
|
+
let update = {
|
|
90
|
+
newTotal: {
|
|
91
|
+
label: displayName,
|
|
92
|
+
type: "final",
|
|
93
|
+
amount: amount.toString(),
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
if (onShippingContactSelected) {
|
|
97
|
+
update = yield onShippingContactSelected(shippingContact);
|
|
98
|
+
}
|
|
99
|
+
session.completeShippingContactSelection(update);
|
|
100
|
+
});
|
|
101
|
+
session.onpaymentauthorized = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
const paymentData = event.payment;
|
|
103
|
+
try {
|
|
104
|
+
if (onPaymentAuthorized) {
|
|
105
|
+
yield onPaymentAuthorized(paymentData);
|
|
106
|
+
}
|
|
107
|
+
if (paymentData.token) {
|
|
108
|
+
const paymentDataJson = JSON.stringify(paymentData.token, null, 2);
|
|
109
|
+
console.log("paymentData", paymentDataJson);
|
|
110
|
+
setPaymentDataResult(paymentDataJson);
|
|
111
|
+
const result = {
|
|
112
|
+
status: ApplePaySession.STATUS_SUCCESS,
|
|
113
|
+
};
|
|
114
|
+
session.completePayment(result);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
const result = {
|
|
118
|
+
status: ApplePaySession.STATUS_FAILURE,
|
|
119
|
+
};
|
|
120
|
+
session.completePayment(result);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
console.error("Payment authorization failed:", error);
|
|
125
|
+
const result = {
|
|
126
|
+
status: ApplePaySession.STATUS_FAILURE,
|
|
127
|
+
};
|
|
128
|
+
session.completePayment(result);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
session.oncancel = (event) => {
|
|
132
|
+
if (onPaymentCancelled) {
|
|
133
|
+
onPaymentCancelled();
|
|
134
|
+
}
|
|
135
|
+
console.log("Session Cancelled.");
|
|
136
|
+
};
|
|
137
|
+
};
|
|
138
|
+
return (_jsxs("div", { children: [_jsx("div", Object.assign({ className: "flex flex-row justify-center items-center pt-40" }, { children: _jsx(ApplePayButtonComponent, { onClick: onClick, style: {
|
|
139
|
+
height: "48px",
|
|
140
|
+
borderRadius: "4px",
|
|
141
|
+
}, type: buttonType, buttonStyle: buttonStyle }) })), _jsx("div", Object.assign({ className: "w-100 overflow-auto" }, { children: _jsx("pre", Object.assign({ className: "whitespace-pre-wrap break-words" }, { children: paymentDataResult })) }))] }));
|
|
142
|
+
};
|
|
143
|
+
ApplePayButton.displayName = "ApplePayButton";
|
|
144
|
+
export { ApplePayButton };
|
package/dist/index.d.ts
CHANGED
|
@@ -11,7 +11,9 @@ export * from "./components/hooks/use-product-options";
|
|
|
11
11
|
export * from "./components/hooks/use-shop";
|
|
12
12
|
export * from "./components/hooks/use-mock-products";
|
|
13
13
|
export * from "./components/hooks/use-block-conditional-rendering";
|
|
14
|
+
export * from "./components/hooks/use-mock-cart";
|
|
14
15
|
export * from "./components/ui/accordion";
|
|
16
|
+
export * from "./components/ui/apple-pay-button";
|
|
15
17
|
export * from "./components/ui/aspect-ratio";
|
|
16
18
|
export * from "./components/ui/badge";
|
|
17
19
|
export * from "./components/ui/button";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,cAAc,EACd,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,EACd,SAAS,EACT,4BAA4B,GAC7B,MAAM,aAAa,CAAA;AACpB,cAAc,2CAA2C,CAAA;AACzD,cAAc,mCAAmC,CAAA;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AAc,0BAA0B,CAAA;AACxC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sBAAsB,CAAA;AACpC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kDAAkD,CAAA;AAChE,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,aAAa,CAAA;AAC3B,cAAc,6CAA6C,CAAA;AAC3D,cAAc,kDAAkD,CAAA;AAChE,cAAc,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -12,7 +12,9 @@ export * from "./components/hooks/use-product-options";
|
|
|
12
12
|
export * from "./components/hooks/use-shop";
|
|
13
13
|
export * from "./components/hooks/use-mock-products";
|
|
14
14
|
export * from "./components/hooks/use-block-conditional-rendering";
|
|
15
|
+
export * from "./components/hooks/use-mock-cart";
|
|
15
16
|
export * from "./components/ui/accordion";
|
|
17
|
+
export * from "./components/ui/apple-pay-button";
|
|
16
18
|
export * from "./components/ui/aspect-ratio";
|
|
17
19
|
export * from "./components/ui/badge";
|
|
18
20
|
export * from "./components/ui/button";
|
package/dist/styles.css
CHANGED
|
@@ -1373,6 +1373,9 @@ video {
|
|
|
1373
1373
|
.self-center {
|
|
1374
1374
|
align-self: center;
|
|
1375
1375
|
}
|
|
1376
|
+
.overflow-auto {
|
|
1377
|
+
overflow: auto;
|
|
1378
|
+
}
|
|
1376
1379
|
.overflow-hidden {
|
|
1377
1380
|
overflow: hidden;
|
|
1378
1381
|
}
|
|
@@ -1399,6 +1402,9 @@ video {
|
|
|
1399
1402
|
.whitespace-nowrap {
|
|
1400
1403
|
white-space: nowrap;
|
|
1401
1404
|
}
|
|
1405
|
+
.whitespace-pre-wrap {
|
|
1406
|
+
white-space: pre-wrap;
|
|
1407
|
+
}
|
|
1402
1408
|
.break-words {
|
|
1403
1409
|
overflow-wrap: break-word;
|
|
1404
1410
|
}
|
|
@@ -1758,6 +1764,9 @@ video {
|
|
|
1758
1764
|
.pt-4 {
|
|
1759
1765
|
padding-top: 1rem;
|
|
1760
1766
|
}
|
|
1767
|
+
.pt-40 {
|
|
1768
|
+
padding-top: 10rem;
|
|
1769
|
+
}
|
|
1761
1770
|
.pt-5 {
|
|
1762
1771
|
padding-top: 1.25rem;
|
|
1763
1772
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapcart/mobile-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.47",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/styles.css",
|
|
@@ -11,43 +11,31 @@
|
|
|
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:silent": "jest --silent",
|
|
25
|
-
"test:watch": "jest --watch"
|
|
26
|
-
},
|
|
27
14
|
"peerDependencies": {
|
|
28
15
|
"react": "^17.0.2 || ^18.0.0",
|
|
29
16
|
"react-dom": "^17.0.2 || ^18.0.0"
|
|
30
17
|
},
|
|
31
18
|
"devDependencies": {
|
|
19
|
+
"@types/applepayjs": "^14.0.9",
|
|
32
20
|
"@types/jest": "^29.5.14",
|
|
33
21
|
"@types/lodash": "4.17.5",
|
|
34
22
|
"@types/react": "^18.2.0",
|
|
35
23
|
"@types/react-dom": "^18.2.0",
|
|
36
|
-
"app-studio-types": "workspace:*",
|
|
37
24
|
"autoprefixer": "^10.4.14",
|
|
38
25
|
"chokidar-cli": "^3.0.0",
|
|
39
26
|
"concurrently": "^8.2.2",
|
|
40
27
|
"eslint": "^7.32.0",
|
|
41
|
-
"eslint-config-custom": "workspace:*",
|
|
42
28
|
"jest": "^29.7.0",
|
|
43
29
|
"jest-environment-jsdom": "^29.7.0",
|
|
44
30
|
"postcss": "^8.4.24",
|
|
45
31
|
"tailwindcss": "^3.3.2",
|
|
46
32
|
"ts-jest": "^29.2.5",
|
|
47
33
|
"tsc-alias": "^1.8.10",
|
|
48
|
-
"tsconfig": "workspace:*",
|
|
49
34
|
"typescript": "^4.5.2",
|
|
50
|
-
"@testing-library/react-hooks": "^8.0.1"
|
|
35
|
+
"@testing-library/react-hooks": "^8.0.1",
|
|
36
|
+
"app-studio-types": "0.0.6",
|
|
37
|
+
"tsconfig": "0.0.0",
|
|
38
|
+
"eslint-config-custom": "0.0.0"
|
|
51
39
|
},
|
|
52
40
|
"dependencies": {
|
|
53
41
|
"@radix-ui/react-accordion": "^1.1.2",
|
|
@@ -69,6 +57,7 @@
|
|
|
69
57
|
"@radix-ui/react-toggle-group": "^1.0.4",
|
|
70
58
|
"@tabler/icons-react": "^3.2.0",
|
|
71
59
|
"@tapcart/webbridge-react": "^1.13.0",
|
|
60
|
+
"apple-pay-button": "^1.1.7",
|
|
72
61
|
"class-variance-authority": "^0.6.0",
|
|
73
62
|
"clsx": "^1.2.1",
|
|
74
63
|
"dayjs": "^1.11.13",
|
|
@@ -85,5 +74,18 @@
|
|
|
85
74
|
"tailwind-merge": "^1.13.2",
|
|
86
75
|
"tailwindcss-animate": "^1.0.6",
|
|
87
76
|
"vaul": "0.9.1"
|
|
77
|
+
},
|
|
78
|
+
"scripts": {
|
|
79
|
+
"lint": "eslint \"**/*.ts*\"",
|
|
80
|
+
"ui:add": "pnpm dlx shadcn-ui@latest add",
|
|
81
|
+
"build:styles": "postcss styles/globals.css -o dist/styles.css",
|
|
82
|
+
"build:ts": "tsc -p tsconfig.json && tsc-alias",
|
|
83
|
+
"build": "pnpm run build:ts && pnpm run build:styles",
|
|
84
|
+
"dev:ts": "tsc -w -p tsconfig.json",
|
|
85
|
+
"dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
|
|
86
|
+
"dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
|
|
87
|
+
"test": "jest",
|
|
88
|
+
"test:silent": "jest --silent",
|
|
89
|
+
"test:watch": "jest --watch"
|
|
88
90
|
}
|
|
89
|
-
}
|
|
91
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../components/ThemeProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,2CAEvE"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
|
15
|
-
export function ThemeProvider(_a) {
|
|
16
|
-
var { children } = _a, props = __rest(_a, ["children"]);
|
|
17
|
-
return _jsx(NextThemesProvider, Object.assign({}, props, { children: children }));
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeToggle.d.ts","sourceRoot":"","sources":["../../components/ThemeToggle.tsx"],"names":[],"mappings":"AAOA,wBAAgB,WAAW,4CAc1B"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useTheme } from "next-themes";
|
|
4
|
-
import { Button } from "../components/ui/button";
|
|
5
|
-
export function ThemeToggle() {
|
|
6
|
-
const { setTheme, theme } = useTheme();
|
|
7
|
-
return (_jsxs(Button, Object.assign({ variant: "ghost", size: "sm", onClick: () => setTheme(theme === "light" ? "dark" : "light") }, { children: [_jsx("div", { className: "rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" }), _jsx("div", { className: "absolute rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" }), _jsx("span", Object.assign({ className: "sr-only" }, { children: "Toggle theme" }))] })));
|
|
8
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-block-conditionals.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditionals.ts"],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,35 +0,0 @@
|
|
|
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 };
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,22 +0,0 @@
|
|
|
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 };
|