@tapcart/mobile-components 0.7.29 → 0.7.31
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/ThemeProvider.d.ts +3 -0
- package/dist/components/ThemeProvider.d.ts.map +1 -0
- package/dist/components/ThemeProvider.js +18 -0
- package/dist/components/ThemeToggle.d.ts +2 -0
- package/dist/components/ThemeToggle.d.ts.map +1 -0
- package/dist/components/ThemeToggle.js +8 -0
- package/dist/components/hooks/use-products.d.ts.map +1 -1
- package/dist/components/hooks/use-recommendations.d.ts.map +1 -1
- package/dist/components/hooks/use-recommendations.js +3 -1
- package/dist/components/hooks/use-reviews.d.ts +1 -0
- package/dist/components/hooks/use-reviews.d.ts.map +1 -1
- package/dist/components/hooks/use-reviews.js +39 -0
- package/dist/components/ui/input.d.ts +17 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +35 -0
- package/dist/components/ui/price.js +1 -1
- package/dist/components/ui/product-grid.d.ts +15 -0
- package/dist/components/ui/product-grid.d.ts.map +1 -0
- package/dist/components/ui/product-grid.js +22 -0
- package/dist/styles.css +3 -0
- package/package.json +1 -1
- package/dist/components/hooks/use-customer.d.ts +0 -10
- package/dist/components/hooks/use-customer.d.ts.map +0 -1
- package/dist/components/hooks/use-customer.js +0 -24
- package/dist/components/ui/apple-pay-button.d.ts +0 -24
- package/dist/components/ui/apple-pay-button.d.ts.map +0 -1
- package/dist/components/ui/apple-pay-button.js +0 -121
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ThemeToggle.d.ts","sourceRoot":"","sources":["../../components/ThemeToggle.tsx"],"names":[],"mappings":"AAOA,wBAAgB,WAAW,4CAc1B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-products.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-products.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAI1C,KAAK,GAAG,GAAG,MAAM,CAAA;AACjB,KAAK,cAAc,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AACxD,KAAK,gBAAgB,GAAG;IACtB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,cAAc,EAAE,MAAM,EAAE,CAAA;IACxB,OAAO,EAAE,GAAG,CAAA;IACZ,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,KAAK,OAAO,CAAC,GAAG,CAAC,CAAA;IAC1E,UAAU,CAAC,EAAE,cAAc,EAAE,CAAA;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAChC,CAAA;AACD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AA8BD,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,
|
|
1
|
+
{"version":3,"file":"use-products.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-products.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAI1C,KAAK,GAAG,GAAG,MAAM,CAAA;AACjB,KAAK,cAAc,GAAG;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IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;CACX;AAOD,QAAA,MAAM,kBAAkB,+BAGrB,sBAAsB,KAAG,
|
|
1
|
+
{"version":3,"file":"use-recommendations.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-recommendations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAKtD,UAAU,sBAAsB;IAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;CACX;AAOD,QAAA,MAAM,kBAAkB,+BAGrB,sBAAsB,KAAG,uBAkC3B,CAAA;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
|
|
@@ -6,6 +6,7 @@ const constructURL = (apiURL) => {
|
|
|
6
6
|
return url.toString();
|
|
7
7
|
};
|
|
8
8
|
const useRecommendations = ({ queryVariables, apiURL }) => {
|
|
9
|
+
var _a;
|
|
9
10
|
const searchParams = useSearchParams();
|
|
10
11
|
const recommendation = (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get('recommendation')) || "*";
|
|
11
12
|
const fetcher = (body) => fetch(constructURL(apiURL), {
|
|
@@ -20,9 +21,10 @@ const useRecommendations = ({ queryVariables, apiURL }) => {
|
|
|
20
21
|
revalidateOnFocus: false,
|
|
21
22
|
revalidateOnReconnect: false,
|
|
22
23
|
});
|
|
24
|
+
const collections = (_a = data === null || data === void 0 ? void 0 : data.collections) === null || _a === void 0 ? void 0 : _a.filter((obj) => obj.handle !== 'empty-collection');
|
|
23
25
|
return {
|
|
24
26
|
products: data === null || data === void 0 ? void 0 : data.products,
|
|
25
|
-
collections:
|
|
27
|
+
collections: recommendation === "*" ? [] : collections,
|
|
26
28
|
searches: data === null || data === void 0 ? void 0 : data.searches,
|
|
27
29
|
isLoading: isLoading,
|
|
28
30
|
error: error
|
|
@@ -18,6 +18,7 @@ type UseReviewsReturn = {
|
|
|
18
18
|
data: ReviewSummaryData | ReviewMetaData | ReviewSearchData | null;
|
|
19
19
|
error: any;
|
|
20
20
|
isLoading: boolean;
|
|
21
|
+
reviewsMockData?: any;
|
|
21
22
|
};
|
|
22
23
|
export declare function useReviews(props: UseReviewsProps | null): UseReviewsReturn;
|
|
23
24
|
type UseReviewsInfiniteReturn = UseReviewsReturn & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-reviews.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-reviews.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGtF,KAAK,eAAe,GAAG;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,QAAQ,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;IAC5C,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;IAClB,MAAM,EAAE,CAAC,MAAM,CAAC,CAAC;IACjB,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,MAAM,GAAG,QAAQ,GAAG,eAAe,CAAC;IACjF,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAA;AAED,KAAK,g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ACjD,GAAG,EAAE,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;CACtC,CAAA;AAGD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,wBAAwB,CAyI1F"}
|
|
@@ -3,6 +3,44 @@ import { useCallback, useEffect, useRef } from "react";
|
|
|
3
3
|
import useSWR from "swr";
|
|
4
4
|
import useSWRInfinite from "swr/infinite";
|
|
5
5
|
import { useInView } from 'react-intersection-observer';
|
|
6
|
+
const reviewsMockData = [
|
|
7
|
+
{
|
|
8
|
+
"id": "dabbba8a-1188-4423-8aa2-1789dca7d67c",
|
|
9
|
+
"score": 4,
|
|
10
|
+
"title": "Headline",
|
|
11
|
+
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...",
|
|
12
|
+
"date": "2024-10-10T00:00:00.000Z",
|
|
13
|
+
"verified": false,
|
|
14
|
+
"user": {
|
|
15
|
+
"userId": null,
|
|
16
|
+
"displayName": "Name"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "aab7ea91-1b88-43e8-93a9-111f833c756c",
|
|
21
|
+
"score": 4,
|
|
22
|
+
"title": "Headline",
|
|
23
|
+
"content": "",
|
|
24
|
+
"date": "2024-08-10T00:00:00.000Z",
|
|
25
|
+
"verified": false,
|
|
26
|
+
"user": {
|
|
27
|
+
"userId": null,
|
|
28
|
+
"displayName": "Name"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
"id": "4c3ab875-5598-498f-ae3b-72bf00f4fe04",
|
|
33
|
+
"score": 4,
|
|
34
|
+
"title": "Headline",
|
|
35
|
+
"content": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua...",
|
|
36
|
+
"date": "2024-08-08T00:00:00.000Z",
|
|
37
|
+
"verified": false,
|
|
38
|
+
"user": {
|
|
39
|
+
"userId": null,
|
|
40
|
+
"displayName": "Name"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
];
|
|
6
44
|
export function useReviews(props) {
|
|
7
45
|
let url = null;
|
|
8
46
|
if (props) {
|
|
@@ -52,6 +90,7 @@ export function useReviews(props) {
|
|
|
52
90
|
data: data || {},
|
|
53
91
|
error,
|
|
54
92
|
isLoading: !data && !error,
|
|
93
|
+
reviewsMockData,
|
|
55
94
|
};
|
|
56
95
|
}
|
|
57
96
|
export function useReviewsInfinite(props) {
|
|
@@ -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 };
|
|
@@ -7,7 +7,7 @@ function Price({ price, priceHigh, priceRanges = false, isSale = false, compareA
|
|
|
7
7
|
const ProductPrice = () => {
|
|
8
8
|
const priceStyles = (!isSale || !compareAtPrice) ? standardStyles : saleStyles;
|
|
9
9
|
const colorClass = isSale ? 'text-textColors-salePriceText' : 'text-textColors-priceText';
|
|
10
|
-
return (_jsx(Text, Object.assign({ className: `${colorClass} flex-shrink-0 w-full`, style: { fontSize: `${fontSize}px` } }, { children: _jsxs("span", Object.assign({ className: "flex-grow min-w-[fit-content] break-all" }, { children: [_jsx(Money, { price: price, currency: currency, locale: locale, styles: priceStyles, hideZeroCents: hideZeroCents }), priceRanges && priceHigh !== undefined && _jsx(Spacer, {}), priceRanges && priceHigh !== undefined && (_jsx(Money, { price: priceHigh, currency: currency, locale: locale, styles: priceStyles, hideZeroCents: hideZeroCents }))] })) })));
|
|
10
|
+
return (_jsx(Text, Object.assign({ className: `${colorClass} flex-shrink-0 max-w-full`, style: { fontSize: `${fontSize}px` } }, { children: _jsxs("span", Object.assign({ className: "flex-grow min-w-[fit-content] break-all" }, { children: [_jsx(Money, { price: price, currency: currency, locale: locale, styles: priceStyles, hideZeroCents: hideZeroCents }), priceRanges && priceHigh !== undefined && _jsx(Spacer, {}), priceRanges && priceHigh !== undefined && (_jsx(Money, { price: priceHigh, currency: currency, locale: locale, styles: priceStyles, hideZeroCents: hideZeroCents }))] })) })));
|
|
11
11
|
};
|
|
12
12
|
const StrikeThroughPrice = () => {
|
|
13
13
|
if (!isSale || !compareAtPrice)
|
|
@@ -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/styles.css
CHANGED
package/package.json
CHANGED
|
@@ -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,24 +0,0 @@
|
|
|
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
|
-
startSessionURL: string;
|
|
9
|
-
appId: string;
|
|
10
|
-
domainName: string;
|
|
11
|
-
countryCode?: string;
|
|
12
|
-
currencyCode?: string;
|
|
13
|
-
merchantCapabilities?: ApplePayJS.ApplePayMerchantCapability[];
|
|
14
|
-
supportedNetworks?: string[];
|
|
15
|
-
buttonType?: ApplePayButtonType;
|
|
16
|
-
buttonStyle?: ApplePayButtonStyle;
|
|
17
|
-
onPaymentAuthorized?: (paymentData: ApplePayJS.ApplePayPayment) => void;
|
|
18
|
-
}
|
|
19
|
-
declare const ApplePayButton: {
|
|
20
|
-
({ displayName, amount, startSessionURL, appId, domainName, countryCode, currencyCode, merchantCapabilities, supportedNetworks, buttonType, buttonStyle, onPaymentAuthorized, }: ApplePayButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
-
displayName: string;
|
|
22
|
-
};
|
|
23
|
-
export { ApplePayButton };
|
|
24
|
-
//# 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,MAAM,kBAAkB,GAAG,OAAO,GAAG,WAAW,GAAG,MAAM,GAAG,KAAK,GAAG,WAAW,GAAG,UAAU,GAAG,YAAY,GAAG,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,WAAW,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE3N,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,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,UAAU,CAAC,0BAA0B,EAAE,CAAC;IAC/D,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC7B,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,WAAW,CAAC,EAAE,mBAAmB,CAAC;IAClC,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,eAAe,KAAK,IAAI,CAAC;CACzE;AAED,QAAA,MAAM,cAAc;qLAcf,mBAAmB;;CA2IvB,CAAA;AAID,OAAO,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -1,121 +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
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
import * as React from "react";
|
|
12
|
-
import ApplePayButtonComponent from 'apple-pay-button';
|
|
13
|
-
const ApplePayButton = ({ displayName, amount, startSessionURL, appId, domainName, countryCode = 'US', currencyCode = 'USD', merchantCapabilities = ["supports3DS"], supportedNetworks = ["visa", "masterCard", "amex", "discover"], buttonType = 'plain', buttonStyle = 'white-outline', onPaymentAuthorized, }) => {
|
|
14
|
-
const [paymentDataResult, setPaymentDataResult] = React.useState("");
|
|
15
|
-
const onClick = () => {
|
|
16
|
-
const applePayRequest = {
|
|
17
|
-
countryCode,
|
|
18
|
-
currencyCode,
|
|
19
|
-
merchantCapabilities,
|
|
20
|
-
supportedNetworks,
|
|
21
|
-
total: {
|
|
22
|
-
label: displayName,
|
|
23
|
-
type: "final",
|
|
24
|
-
amount: amount.toString(),
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
const session = new ApplePaySession(3, applePayRequest);
|
|
28
|
-
handleEventsForApplePay(session);
|
|
29
|
-
session.begin();
|
|
30
|
-
};
|
|
31
|
-
const defaultFetcher = (url, body) => fetch(url, {
|
|
32
|
-
method: body ? "POST" : "GET",
|
|
33
|
-
headers: {
|
|
34
|
-
"Content-Type": "application/json",
|
|
35
|
-
},
|
|
36
|
-
body: body ? JSON.stringify(body) : undefined,
|
|
37
|
-
}).then((res) => res.json());
|
|
38
|
-
const validateMerchant = (validationURL, appId, domainName, displayName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
39
|
-
let url = startSessionURL;
|
|
40
|
-
let body = {
|
|
41
|
-
validationURL,
|
|
42
|
-
appId,
|
|
43
|
-
domainName,
|
|
44
|
-
displayName
|
|
45
|
-
};
|
|
46
|
-
console.log("request body", body);
|
|
47
|
-
const response = yield defaultFetcher(url, body);
|
|
48
|
-
return response.data;
|
|
49
|
-
});
|
|
50
|
-
const handleEventsForApplePay = (session) => {
|
|
51
|
-
session.onvalidatemerchant = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
const response = yield validateMerchant(event.validationURL, appId, domainName, displayName);
|
|
53
|
-
if (response) {
|
|
54
|
-
session.completeMerchantValidation(response);
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
console.error("Error during validating merchant");
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
session.onpaymentmethodselected = (event) => {
|
|
61
|
-
const update = {
|
|
62
|
-
newTotal: {
|
|
63
|
-
label: displayName,
|
|
64
|
-
type: "final",
|
|
65
|
-
amount: amount.toString(),
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
session.completePaymentMethodSelection(update);
|
|
69
|
-
};
|
|
70
|
-
session.onshippingmethodselected = (event) => {
|
|
71
|
-
const update = {
|
|
72
|
-
newTotal: {
|
|
73
|
-
label: displayName,
|
|
74
|
-
type: "final",
|
|
75
|
-
amount: amount.toString(),
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
session.completeShippingMethodSelection(update);
|
|
79
|
-
};
|
|
80
|
-
session.onshippingcontactselected = (event) => {
|
|
81
|
-
const update = {
|
|
82
|
-
newTotal: {
|
|
83
|
-
label: displayName,
|
|
84
|
-
type: "final",
|
|
85
|
-
amount: amount.toString(),
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
session.completeShippingContactSelection(update);
|
|
89
|
-
};
|
|
90
|
-
session.onpaymentauthorized = (event) => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
-
const paymentData = event.payment;
|
|
92
|
-
if (onPaymentAuthorized) { // Call the callback if provided
|
|
93
|
-
onPaymentAuthorized(paymentData);
|
|
94
|
-
}
|
|
95
|
-
if (paymentData.token) {
|
|
96
|
-
const paymentDataJson = JSON.stringify(paymentData.token, null, 2);
|
|
97
|
-
console.log("paymentData", paymentDataJson);
|
|
98
|
-
setPaymentDataResult(paymentDataJson);
|
|
99
|
-
const result = {
|
|
100
|
-
status: ApplePaySession.STATUS_SUCCESS,
|
|
101
|
-
};
|
|
102
|
-
session.completePayment(result);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
const result = {
|
|
106
|
-
status: ApplePaySession.STATUS_FAILURE,
|
|
107
|
-
};
|
|
108
|
-
session.completePayment(result);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
session.oncancel = (event) => {
|
|
112
|
-
console.log("Session Cancelled.");
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
return (_jsxs("div", { children: [_jsx("div", Object.assign({ className: "flex flex-row justify-center items-center pt-40" }, { children: _jsx(ApplePayButtonComponent, { onClick: onClick, style: {
|
|
116
|
-
height: "48px",
|
|
117
|
-
borderRadius: '4px',
|
|
118
|
-
}, 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 })) }))] }));
|
|
119
|
-
};
|
|
120
|
-
ApplePayButton.displayName = "ApplePayButton";
|
|
121
|
-
export { ApplePayButton };
|