@tapcart/mobile-components 0.7.2 → 0.7.5
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-destination.d.ts +23 -0
- package/dist/components/hooks/use-destination.d.ts.map +1 -0
- package/dist/components/hooks/use-destination.js +13 -0
- package/dist/components/hooks/use-products.d.ts.map +1 -1
- package/dist/components/hooks/use-products.js +1 -2
- package/dist/components/ui/Input/input.d.ts.map +1 -1
- package/dist/components/ui/Input/input.js +3 -7
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/badge.js +3 -3
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +2 -2
- package/dist/components/ui/carousel.d.ts.map +1 -1
- package/dist/components/ui/carousel.js +2 -2
- package/dist/components/ui/favorite.d.ts.map +1 -1
- package/dist/components/ui/favorite.js +2 -1
- package/dist/components/ui/image.js +2 -2
- package/dist/index.d.ts +1 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -5
- package/dist/lib/utils.d.ts +5 -2
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +10 -27
- package/dist/styles.css +0 -27
- package/package.json +2 -2
- package/dist/components/hooks/use-nosto-recommendation.d.ts +0 -8
- package/dist/components/hooks/use-nosto-recommendation.d.ts.map +0 -1
- package/dist/components/hooks/use-nosto-recommendation.js +0 -105
- package/dist/components/templates/ProductCard/utils.d.ts +0 -78
- package/dist/components/templates/ProductCard/utils.d.ts.map +0 -1
- package/dist/components/templates/ProductCard/utils.js +0 -128
- package/dist/components/templates/ProductGrid/index.d.ts +0 -1
- package/dist/components/templates/ProductGrid/index.d.ts.map +0 -1
- package/dist/components/templates/ProductGrid/index.js +0 -1
- package/dist/components/ui/ProductCard/utils.d.ts +0 -94
- package/dist/components/ui/ProductCard/utils.d.ts.map +0 -1
- package/dist/components/ui/ProductCard/utils.js +0 -148
- package/dist/components/ui/ProductGrid/index.d.ts +0 -1
- package/dist/components/ui/ProductGrid/index.d.ts.map +0 -1
- package/dist/components/ui/ProductGrid/index.js +0 -1
- package/dist/lib/price.d.ts +0 -29
- package/dist/lib/price.d.ts.map +0 -1
- package/dist/lib/price.js +0 -66
- package/dist/tapcart-mobile-components.umd.js +0 -44
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
type OpenProductFn = (arg: {
|
|
2
|
+
productId: string;
|
|
3
|
+
}) => void;
|
|
4
|
+
type OpenCollectionFn = (arg: {
|
|
5
|
+
collectionId: string;
|
|
6
|
+
}) => void;
|
|
7
|
+
type OpenScreenFn = (arg: {
|
|
8
|
+
destination: {
|
|
9
|
+
type: "internal" | "web";
|
|
10
|
+
url: string;
|
|
11
|
+
};
|
|
12
|
+
}) => void;
|
|
13
|
+
type DestinationType = "product" | "collection" | "url" | "app-screen";
|
|
14
|
+
interface UseDestinationProps {
|
|
15
|
+
openProduct: OpenProductFn;
|
|
16
|
+
openCollection: OpenCollectionFn;
|
|
17
|
+
openScreen: OpenScreenFn;
|
|
18
|
+
type: DestinationType;
|
|
19
|
+
location: string;
|
|
20
|
+
}
|
|
21
|
+
export declare const useDestination: ({ openProduct, openCollection, openScreen, type, location, }: UseDestinationProps) => (() => void);
|
|
22
|
+
export {};
|
|
23
|
+
//# sourceMappingURL=use-destination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-destination.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-destination.ts"],"names":[],"mappings":"AAEA,KAAK,aAAa,GAAG,CAAC,GAAG,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,CAAA;AACzD,KAAK,gBAAgB,GAAG,CAAC,GAAG,EAAE;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,KAAK,IAAI,CAAA;AAC/D,KAAK,YAAY,GAAG,CAAC,GAAG,EAAE;IACxB,WAAW,EAAE;QAAE,IAAI,EAAE,UAAU,GAAG,KAAK,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAA;CACvD,KAAK,IAAI,CAAA;AAEV,KAAK,eAAe,GAAG,SAAS,GAAG,YAAY,GAAG,KAAK,GAAG,YAAY,CAAA;AAEtE,UAAU,mBAAmB;IAC3B,WAAW,EAAE,aAAa,CAAA;IAC1B,cAAc,EAAE,gBAAgB,CAAA;IAChC,UAAU,EAAE,YAAY,CAAA;IACxB,IAAI,EAAE,eAAe,CAAA;IACrB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,eAAO,MAAM,cAAc,iEAMxB,mBAAmB,KAAG,CAAC,MAAM,IAAI,CAYnC,CAAA"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export const useDestination = ({ openProduct, openCollection, openScreen, type, location, }) => {
|
|
3
|
+
switch (type) {
|
|
4
|
+
case "product":
|
|
5
|
+
return () => openProduct({ productId: location });
|
|
6
|
+
case "collection":
|
|
7
|
+
return () => openCollection({ collectionId: location });
|
|
8
|
+
case "url":
|
|
9
|
+
return () => openScreen({ destination: { type: "web", url: location } });
|
|
10
|
+
case "app-screen":
|
|
11
|
+
return () => openScreen({ destination: { type: "internal", url: location } });
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -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;
|
|
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;AAE1C,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;CAC9B,CAAA;AACD,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,KAAK,EAAE,GAAG,CAAA;IACV,SAAS,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAAG,iBAAiB,CAyD7E"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import useSWR from "swr";
|
|
3
|
-
import { getProductGidsFromIds } from "../../lib/utils";
|
|
4
3
|
export function useProducts(props) {
|
|
5
4
|
let url = null;
|
|
6
5
|
let body = null;
|
|
@@ -8,7 +7,7 @@ export function useProducts(props) {
|
|
|
8
7
|
const { baseURL, productIds, productHandles, metafields, collection, queryVariables, } = props;
|
|
9
8
|
let queryParams = new URLSearchParams();
|
|
10
9
|
if ((productIds === null || productIds === void 0 ? void 0 : productIds.length) > 0) {
|
|
11
|
-
queryParams.set("ids",
|
|
10
|
+
queryParams.set("ids", productIds.join(","));
|
|
12
11
|
}
|
|
13
12
|
if ((productHandles === null || productHandles === void 0 ? void 0 : productHandles.length) > 0) {
|
|
14
13
|
queryParams.set("handles", productHandles.join(","));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAExD,QAAA,MAAM,KAAK,
|
|
1
|
+
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAExD,QAAA,MAAM,KAAK,qFAmKV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -12,7 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
13
|
import * as React from "react";
|
|
14
14
|
import { inputVariants, useInput } from "./useInput";
|
|
15
|
-
import { cn
|
|
15
|
+
import { cn } from "../../../lib/utils";
|
|
16
16
|
import { Icon } from "../icon";
|
|
17
17
|
const Input = React.forwardRef((_a, ref) => {
|
|
18
18
|
var { className, error = false, id, type, label, asChild, value, onChange, icon, iconUrl, iconPosition = "right", // Default to "right" for backward compatibility
|
|
@@ -32,9 +32,7 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
32
32
|
inputPadding,
|
|
33
33
|
placeholderTextColor,
|
|
34
34
|
});
|
|
35
|
-
return (_jsxs(Comp, Object.assign({ className: "relative flex items-center group" }, { children: [(icon || iconUrl) && iconPosition === "left" && (_jsx(Icon, { name: icon, url: iconUrl, "data-error": error, size: "sm",
|
|
36
|
-
? undefined
|
|
37
|
-
: "coreColors-secondaryIcon", className: cn("flex items-center absolute aspect-square fill-current z-10 icon ", {
|
|
35
|
+
return (_jsxs(Comp, Object.assign({ className: "relative flex items-center group" }, { children: [(icon || iconUrl) && iconPosition === "left" && (_jsx(Icon, { name: icon, url: iconUrl, "data-error": error, size: "sm", className: cn("flex items-center absolute aspect-square fill-current z-10 icon ", {
|
|
38
36
|
"w-5": true,
|
|
39
37
|
"text-stateColors-error": error,
|
|
40
38
|
}), style: {
|
|
@@ -50,9 +48,7 @@ const Input = React.forwardRef((_a, ref) => {
|
|
|
50
48
|
iconPosition === "left" &&
|
|
51
49
|
placeholderTextAlign === "center"
|
|
52
50
|
? undefined
|
|
53
|
-
: inputPaddingLeft, paddingRight: inputPaddingRight, fontFamily: placeholderFont, fontWeight: placeholderFontWeight, fontSize: `${placeholderFontSize}px`, textAlign: placeholderTextAlign, color: placeholderTextColorStyle, textTransform: placeholderUpperCase ? "uppercase" : undefined, borderColor: inputBorderColorStyle, paddingTop: inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.top, paddingBottom: inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.bottom, backgroundColor: inputBgColor }, borderStyle), (label ? { borderRadius: "8px" } : borderRadiusStyle)) })), label ? (_jsx("label", Object.assign({ htmlFor: id, className: cn("absolute text-[10px] text-textColors-secondaryColor group-active:text-coreColors-brandColorPrimary top-2 z-10 h-4 origin-[0] opacity-100 peer-placeholder-shown:opacity-0", iconPosition === "left" ? "start-10" : "start-4") }, { children: label }))) : null, (icon || iconUrl) && iconPosition === "right" && (_jsx(Icon, { name: icon, url: iconUrl, "data-error": error, size: "sm",
|
|
54
|
-
? undefined
|
|
55
|
-
: "coreColors-secondaryIcon", className: cn("flex items-center absolute aspect-square fill-current z-10 icon ", {
|
|
51
|
+
: inputPaddingLeft, paddingRight: inputPaddingRight, fontFamily: placeholderFont, fontWeight: placeholderFontWeight, fontSize: `${placeholderFontSize}px`, textAlign: placeholderTextAlign, color: placeholderTextColorStyle, textTransform: placeholderUpperCase ? "uppercase" : undefined, borderColor: inputBorderColorStyle, paddingTop: inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.top, paddingBottom: inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.bottom, backgroundColor: inputBgColor }, borderStyle), (label ? { borderRadius: "8px" } : borderRadiusStyle)) })), label ? (_jsx("label", Object.assign({ htmlFor: id, className: cn("absolute text-[10px] text-textColors-secondaryColor group-active:text-coreColors-brandColorPrimary top-2 z-10 h-4 origin-[0] opacity-100 peer-placeholder-shown:opacity-0", iconPosition === "left" ? "start-10" : "start-4") }, { children: label }))) : null, (icon || iconUrl) && iconPosition === "right" && (_jsx(Icon, { name: icon, url: iconUrl, "data-error": error, size: "sm", className: cn("flex items-center absolute aspect-square fill-current z-10 icon ", {
|
|
56
52
|
"w-5": true,
|
|
57
53
|
"text-stateColors-error": error,
|
|
58
54
|
}), style: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../../components/ui/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAMjE,QAAA,MAAM,aAAa;;;
|
|
1
|
+
{"version":3,"file":"badge.d.ts","sourceRoot":"","sources":["../../../components/ui/badge.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAMjE,QAAA,MAAM,aAAa;;;mFAoDlB,CAAA;AAED,MAAM,WAAW,UACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAC1C,YAAY,CAAC,OAAO,aAAa,CAAC;IACpC,IAAI,EAAE,YAAY,GAAG,WAAW,CAAA;IAChC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,IAAI,CAAC,EAAE,eAAe,GAAG,WAAW,GAAG,WAAW,CAAA;IAClD,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC/B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC1B;AAED,iBAAS,KAAK,CAAC,EACb,SAAS,EACT,IAAI,EACJ,OAAO,EACP,SAAS,EACT,YAAwB,EACxB,IAAsB,EACtB,IAAmB,EACnB,eAAe,EACf,SAAS,EACT,GAAG,KAAK,EACT,EAAE,UAAU,2CA2CZ;AAED,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -25,7 +25,7 @@ const badgeVariants = cva("inline-flex items-center justify-center gap-1 py-1 px
|
|
|
25
25
|
rounded: "",
|
|
26
26
|
square: "",
|
|
27
27
|
circle: "",
|
|
28
|
-
}
|
|
28
|
+
},
|
|
29
29
|
},
|
|
30
30
|
defaultVariants: {
|
|
31
31
|
cornerRadius: "rounded",
|
|
@@ -62,12 +62,12 @@ const badgeVariants = cva("inline-flex items-center justify-center gap-1 py-1 px
|
|
|
62
62
|
cornerRadius: "circle",
|
|
63
63
|
class: "rounded-2xl",
|
|
64
64
|
},
|
|
65
|
-
]
|
|
65
|
+
],
|
|
66
66
|
});
|
|
67
67
|
function Badge(_a) {
|
|
68
68
|
var { className, icon, iconUrl, alignment, cornerRadius = "rounded", type = "icon-and-text", size = "plp-layout", backgroundColor, fontColor } = _a, props = __rest(_a, ["className", "icon", "iconUrl", "alignment", "cornerRadius", "type", "size", "backgroundColor", "fontColor"]);
|
|
69
69
|
const backgroundColorOverride = backgroundColor ? { backgroundColor } : {};
|
|
70
70
|
const BadgeText = () => (_jsx(Text, Object.assign({ type: size === "plp-layout" ? "body-primary" : "body-secondary", className: "text-productBadging-text", fontColor: fontColor }, { children: props.children })));
|
|
71
|
-
return (_jsx("div", Object.assign({ className: cn(badgeVariants({ alignment, cornerRadius }), className), style: backgroundColorOverride }, props, { children: type === "icon-and-text" ? (_jsxs(_Fragment, { children: [(icon || iconUrl) && (_jsx(Icon, { name: icon, url: iconUrl,
|
|
71
|
+
return (_jsx("div", Object.assign({ className: cn(badgeVariants({ alignment, cornerRadius }), className), style: backgroundColorOverride }, props, { children: type === "icon-and-text" ? (_jsxs(_Fragment, { children: [(icon || iconUrl) && (_jsx(Icon, { name: icon, url: iconUrl, style: fontColor ? { color: fontColor } : {}, size: size === "carousels" ? "xs" : "sm" })), _jsx(BadgeText, {})] })) : type === "icon-only" && icon ? (_jsx(Icon, { name: icon, url: iconUrl, style: fontColor ? { color: fontColor } : {}, size: size === "carousels" ? "xs" : "sm" })) : (_jsx(BadgeText, {})) })));
|
|
72
72
|
}
|
|
73
73
|
export { Badge, badgeVariants };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../components/ui/button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAGL,KAAK,EAEL,SAAS,EAET,oBAAoB,EACrB,MAAM,iBAAiB,CAAA;AAIxB,QAAA,MAAM,cAAc;;;mFAgCnB,CAAA;AAwCD,MAAM,WAAW,WACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,GAAG,SAAS,CAAA;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAChC;AAED,QAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../components/ui/button.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82
|
var { className, labelClassName, labelStyle, variant, size, asChild = false, loading, icon, iconColor, iconStrokeColor, iconPosition, iconSize, iconUrl, iconClassName } = _a, props = __rest(_a, ["className", "labelClassName", "labelStyle", "variant", "size", "asChild", "loading", "icon", "iconColor", "iconStrokeColor", "iconPosition", "iconSize", "iconUrl", "iconClassName"]);
|
|
83
83
|
const Comp = asChild ? Slot : "button";
|
|
84
|
-
const IconButton = () => icon || iconUrl ? (_jsx(Icon, { name: icon, url: iconUrl, size: "sm", style: { color: iconColor
|
|
84
|
+
const IconButton = () => icon || iconUrl ? (_jsx(Icon, { name: icon, url: iconUrl, size: "sm", style: { color: iconColor } })) : null;
|
|
85
85
|
const BasicButton = () => (_jsxs(_Fragment, { children: [icon || iconUrl ? (_jsx(Icon, { name: iconUrl ? undefined : icon, url: iconUrl, size: iconSize || variant === "quickadd" ? "xs" : "sm", className: cn(iconVariants({ variant }), {
|
|
86
86
|
"mr-2": iconPosition === "left",
|
|
87
87
|
"ml-2": iconPosition === "right",
|
|
88
|
-
}, iconClassName),
|
|
88
|
+
}, iconClassName), style: { color: iconColor } })) : null, !loading ? (_jsx(Text, Object.assign({ type: "body-primary", className: cn(labelVariants({ variant }), labelClassName), style: labelStyle }, { children: props.children }))) : (_jsx(_Fragment, {}))] }));
|
|
89
89
|
const LoadingButton = () => (_jsx("div", Object.assign({ className: cn("flex items-center justify-center", size === "icon" ? "h-5" : "h-6") }, { children: _jsx(Icon, { className: cn(iconVariants({ variant }), "h-5 w-5 animate-spin"), name: "loader", style: { color: iconColor } }) })));
|
|
90
90
|
return (_jsx(Comp, Object.assign({ className: cn(buttonVariants({ variant, size }), className, {
|
|
91
91
|
"pointer-events-none": loading,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"carousel.d.ts","sourceRoot":"","sources":["../../../components/ui/carousel.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,gBAAgB,EAAE,EACvB,KA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AA;IACvC,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,WAAW,KAAK,IAAI,CAAA;IACnC,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,KAAK,IAAI,CAAA;CAC/C,CAAA;AA0BD,QAAA,MAAM,QAAQ,6HAsIb,CAAA;AAGD,QAAA,MAAM,eAAe,6GAmBnB,CAAA;AAGF,QAAA,MAAM,YAAY,6GAmBhB,CAAA;AAGF,QAAA,MAAM,gBAAgB,kLA0BpB,CAAA;AAGF,QAAA,MAAM,YAAY,kLA0BhB,CAAA;AAGF,KAAK,iBAAiB,GAAG;IACvB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAA;AAED,QAAA,MAAM,YAAY,iIAuDjB,CAAA;AA8DD,OAAO,EACL,KAAK,WAAW,EAChB,QAAQ,EACR,eAAe,EACf,YAAY,EACZ,gBAAgB,EAChB,YAAY,EACZ,YAAY,GACb,CAAA"}
|
|
@@ -90,7 +90,6 @@ const Carousel = React.forwardRef((_a, ref) => {
|
|
|
90
90
|
.on("reInit", setTweenFactor)
|
|
91
91
|
.on("reInit", tweenScale)
|
|
92
92
|
.on("scroll", tweenScale)
|
|
93
|
-
// @ts-ignore
|
|
94
93
|
.on("slideFocus", tweenScale);
|
|
95
94
|
}, [api, tweenScale]);
|
|
96
95
|
return (_jsx(CarouselContext.Provider, Object.assign({ value: {
|
|
@@ -134,6 +133,7 @@ const CarouselNext = React.forwardRef((_a, ref) => {
|
|
|
134
133
|
});
|
|
135
134
|
CarouselNext.displayName = "CarouselNext";
|
|
136
135
|
const CarouselDots = React.forwardRef((_a, ref) => {
|
|
136
|
+
var _b;
|
|
137
137
|
var { maxDots = 5, dotColor = "var(--coreColors-brandColorPrimary)" } = _a, props = __rest(_a, ["maxDots", "dotColor"]);
|
|
138
138
|
const { api } = useCarousel();
|
|
139
139
|
const [_, setUpdateState] = React.useState(false);
|
|
@@ -151,7 +151,7 @@ const CarouselDots = React.forwardRef((_a, ref) => {
|
|
|
151
151
|
const numberOfSlides = Math.min((api === null || api === void 0 ? void 0 : api.scrollSnapList().length) || 0, maxDots);
|
|
152
152
|
const currentSlide = Math.min((api === null || api === void 0 ? void 0 : api.selectedScrollSnap()) || 0, maxDots - 1);
|
|
153
153
|
if (numberOfSlides > 1) {
|
|
154
|
-
return (_jsx("div", Object.assign({ ref: ref, className: `flex
|
|
154
|
+
return (_jsx("div", Object.assign({ ref: ref, className: `flex ${props.className} ${!((_b = props.className) === null || _b === void 0 ? void 0 : _b.includes("justify-")) ? "justify-center" : ""}`, style: props.style }, { children: Array.from({ length: numberOfSlides }, (_, i) => (_jsx(Button, { className: "mx-1 h-1.5 w-1.5 rounded-full p-0 border-none", style: {
|
|
155
155
|
backgroundColor: dotColor,
|
|
156
156
|
opacity: i === currentSlide ? 1 : 0.5,
|
|
157
157
|
}, "aria-label": `Go to slide ${i + 1}`, onClick: () => api === null || api === void 0 ? void 0 : api.scrollTo(i) }, i))) })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"favorite.d.ts","sourceRoot":"","sources":["../../../components/ui/favorite.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,EAGL,OAAO,EAER,MAAM,iBAAiB,CAAA;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAI3C,QAAA,MAAM,gBAAgB;;;;mFAuBpB,CAAA;AAEF,MAAM,WAAW,aACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,gBAAgB,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,U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AC9B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,UAAU,CAAC,EACP,sBAAsB,GACtB,WAAW,GACX,UAAU,GACV,aAAa,GACb,cAAc,CAAA;IAClB,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB,aAAa,CAAC,EAAE,OAAO,CAAC,OAAO,CAAC,CAAA;CACjC;AAED,QAAA,MAAM,QAAQ,yFA2Db,CAAA;AAGD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAA"}
|
|
@@ -48,8 +48,9 @@ const Favorite = React.forwardRef((_a, forwardedRef) => {
|
|
|
48
48
|
size,
|
|
49
49
|
showBackgroundShadow,
|
|
50
50
|
layoutType,
|
|
51
|
-
}), className), style: Object.assign({}, (showBackground && Object.assign(Object.assign({ borderRadius: `${cornerRadius}px`, backgroundColor: backgroundColor, borderColor: borderColorStyle }, getBorderSidesStyle(borderSides)), getPaddingStyle(borderPadding)))) }, props, { children: _jsx(Icon, { url: iconUrl,
|
|
51
|
+
}), className), style: Object.assign({}, (showBackground && Object.assign(Object.assign({ borderRadius: `${cornerRadius}px`, backgroundColor: backgroundColor, borderColor: borderColorStyle }, getBorderSidesStyle(borderSides)), getPaddingStyle(borderPadding)))) }, props, { children: _jsx(Icon, { url: iconUrl, size: size === "small" ? "xs" : "sm", style: {
|
|
52
52
|
opacity: isPressed ? 0.7 : 1,
|
|
53
|
+
color: selected ? favoriteFillColor : disabledFillColor,
|
|
53
54
|
} }) })));
|
|
54
55
|
});
|
|
55
56
|
Favorite.displayName = "Favorite";
|
|
@@ -168,7 +168,7 @@ export const Image = React.forwardRef((_a, ref) => {
|
|
|
168
168
|
}
|
|
169
169
|
}, [ref]);
|
|
170
170
|
const imgClassName = `opacity-0 transition-opacity duration-500 ease-in-out ${isLoaded ? "opacity-100" : ""}`;
|
|
171
|
-
const wrapperStyle = Object.assign({ aspectRatio: (_b = normalizedProps
|
|
171
|
+
const wrapperStyle = Object.assign({ aspectRatio: (_b = normalizedProps.aspectRatio) === null || _b === void 0 ? void 0 : _b.replace(":", "/") }, imageWrapperStyles);
|
|
172
172
|
const srcSet = generateSrcSet(normalizedProps.src, generateSizes(imageWidths, normalizedProps.aspectRatio, crop), loader, normalizedProps.objectFit === "contain");
|
|
173
173
|
return (_jsxs(_Fragment, { children: [loading === "eager" && (_jsx(ImagePreload, { imgAttributes: {
|
|
174
174
|
srcSet,
|
|
@@ -183,7 +183,7 @@ export const Image = React.forwardRef((_a, ref) => {
|
|
|
183
183
|
// and `sizes` are defined.
|
|
184
184
|
// This bug cannot be reproduced in Chrome or Firefox.
|
|
185
185
|
src: normalizedProps.src, ref: setRefs, style: Object.assign({ objectFit: normalizedProps.objectFit, maxHeight: "100%", height: "100%", width: "100%", borderRadius: `${imageRadius}px` }, passthroughProps.style) }))) : (_jsx("div", { className: "w-full h-full bg-stateColors-skeleton", style: Object.assign({ aspectRatio: aspectRatio && aspectRatio !== "auto"
|
|
186
|
-
? (_c = normalizedProps
|
|
186
|
+
? (_c = normalizedProps.aspectRatio) === null || _c === void 0 ? void 0 : _c.replace(":", "/")
|
|
187
187
|
: "2/3" }, imageWrapperStyles) })) }))] }));
|
|
188
188
|
});
|
|
189
189
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle,
|
|
1
|
+
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, getDestinationHandler, createCollectionImageMap, } from "./lib/utils";
|
|
2
2
|
export * from "./components/hooks/use-collection";
|
|
3
3
|
export * from "./components/hooks/use-infinite-scroll";
|
|
4
4
|
export * from "./components/hooks/use-recommendations";
|
|
@@ -54,9 +54,5 @@ export * from "./components/hooks/use-shop";
|
|
|
54
54
|
export * from "./components/libs/sort-filter/search-integration";
|
|
55
55
|
export * from "./components/hooks/use-reviews";
|
|
56
56
|
export * from "./components/ui/subcollection-tabs";
|
|
57
|
-
export * from "./components/hooks/use-tap";
|
|
58
|
-
export * from "./components/ui/ProductCard/utils";
|
|
59
|
-
export * from "./lib/price";
|
|
60
|
-
export * from "./components/hooks/use-nosto-recommendation";
|
|
61
57
|
export * from "./components/libs/sort-filter/search-integration";
|
|
62
58
|
//# sourceMappingURL=index.d.ts.map
|
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,mBAAmB,EACnB,YAAY,EACZ,yBAAyB,EACzB,4BAA4B,EAC5B,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,
|
|
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,oBAAoB,EACpB,k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cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kDAAkD,CAAA;AAChE,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oCAAoC,CAAA;AAClD,cAAc,kDAAkD,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// component exports
|
|
2
|
-
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle,
|
|
2
|
+
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, getDestinationHandler, createCollectionImageMap, } from "./lib/utils";
|
|
3
3
|
export * from "./components/hooks/use-collection";
|
|
4
4
|
export * from "./components/hooks/use-infinite-scroll";
|
|
5
5
|
export * from "./components/hooks/use-recommendations";
|
|
@@ -55,8 +55,4 @@ export * from "./components/hooks/use-shop";
|
|
|
55
55
|
export * from "./components/libs/sort-filter/search-integration";
|
|
56
56
|
export * from "./components/hooks/use-reviews";
|
|
57
57
|
export * from "./components/ui/subcollection-tabs";
|
|
58
|
-
export * from "./components/hooks/use-tap";
|
|
59
|
-
export * from "./components/ui/ProductCard/utils";
|
|
60
|
-
export * from "./lib/price";
|
|
61
|
-
export * from "./components/hooks/use-nosto-recommendation";
|
|
62
58
|
export * from "./components/libs/sort-filter/search-integration";
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -146,7 +146,6 @@ export declare const mapFlexToAlignment: (flexClass: string) => string;
|
|
|
146
146
|
export declare function getIdFromGid(gid: string | undefined): string;
|
|
147
147
|
export declare function productGidFromId(id: string | null | undefined): string | null;
|
|
148
148
|
export declare function variantGidFromId(id: string | null | undefined): string | null;
|
|
149
|
-
export declare function throttle(fn: Function, wait: number): ((...args: any[]) => void)[];
|
|
150
149
|
export declare function formatRelativeTime(inputDate: Date | string): string;
|
|
151
150
|
export declare const stringRatioToInt: (string: string) => number;
|
|
152
151
|
export declare const getOverlayStyle: (opacity: number) => {
|
|
@@ -172,5 +171,9 @@ type DestinationActions = {
|
|
|
172
171
|
}) => void;
|
|
173
172
|
};
|
|
174
173
|
export declare const getDestinationHandler: (type: "app-screen" | "url" | "product" | "collection" | "none") => ((location: string, actions: DestinationActions) => void) | ((location: string, actions: DestinationActions) => void) | ((location: string, actions: DestinationActions) => void) | ((location: string, actions: DestinationActions) => void) | (() => void);
|
|
175
|
-
export declare
|
|
174
|
+
export declare const createCollectionImageMap: (collections: {
|
|
175
|
+
id: string;
|
|
176
|
+
customImage: boolean;
|
|
177
|
+
image?: string;
|
|
178
|
+
}[]) => Record<string, string>;
|
|
176
179
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAA;AAKvC,MAAM,MAAM,KAAK,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnE,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEz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AAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAI7E;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,IAAI,GAAG,MAAM,UAG1D;AAED,eAAO,MAAM,gBAAgB,WAAY,MAAM,WAQ9C,CAAA;AAED,eAAO,MAAM,eAAe,YAAa,MAAM;;;;;;;CAW9C,CAAA;AAED,KAAK,kBAAkB,GAAG;IACxB,UAAU,EAAE,CAAC,GAAG,EAAE;QAChB,WAAW,EAAE;YAAE,IAAI,EAAE,UAAU,GAAG,KAAK,CAAC;YAAC,GAAG,EAAE,MAAM,CAAA;SAAE,CAAA;KACvD,KAAK,IAAI,CAAA;IACV,WAAW,EAAE,CAAC,GAAG,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACjD,cAAc,EAAE,CAAC,GAAG,EAAE;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;CACxD,CAAA;AAgBD,eAAO,MAAM,qBAAqB,SAC1B,YAAY,GAAG,KAAK,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,iBAdrC,MAAM,WAAW,kBAAkB,yBAE5C,MAAM,WAAW,kBAAkB,yBAI/B,MAAM,WAAW,kBAAkB,yBAEhC,MAAM,WAAW,kBAAkB,yBAS3D,CAAA;AAED,eAAO,MAAM,wBAAwB,gBACtB;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,2BAQpE,CAAA"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clsx } from "clsx";
|
|
2
2
|
import { twMerge } from "tailwind-merge";
|
|
3
|
-
import dayjs from
|
|
4
|
-
import relativeTime from
|
|
3
|
+
import dayjs from "dayjs";
|
|
4
|
+
import relativeTime from "dayjs/plugin/relativeTime";
|
|
5
5
|
export function cn(...inputs) {
|
|
6
6
|
return twMerge(clsx(inputs));
|
|
7
7
|
}
|
|
@@ -149,24 +149,6 @@ export function variantGidFromId(id) {
|
|
|
149
149
|
return id;
|
|
150
150
|
return `gid://shopify/ProductVariant/${id}`;
|
|
151
151
|
}
|
|
152
|
-
// Use to prevent multiple clicks in quick succession
|
|
153
|
-
export function throttle(fn, wait) {
|
|
154
|
-
let throttle = false;
|
|
155
|
-
return [
|
|
156
|
-
function () {
|
|
157
|
-
return throttle;
|
|
158
|
-
},
|
|
159
|
-
function (...args) {
|
|
160
|
-
if (!throttle) {
|
|
161
|
-
fn(...args);
|
|
162
|
-
throttle = true;
|
|
163
|
-
setInterval(() => {
|
|
164
|
-
throttle = false;
|
|
165
|
-
}, wait);
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
];
|
|
169
|
-
}
|
|
170
152
|
export function formatRelativeTime(inputDate) {
|
|
171
153
|
dayjs.extend(relativeTime);
|
|
172
154
|
return dayjs(inputDate).fromNow();
|
|
@@ -202,11 +184,12 @@ const DESTINATION_HANDLERS = {
|
|
|
202
184
|
export const getDestinationHandler = (type) => {
|
|
203
185
|
return DESTINATION_HANDLERS[type];
|
|
204
186
|
};
|
|
205
|
-
export
|
|
206
|
-
return
|
|
207
|
-
if (
|
|
208
|
-
|
|
187
|
+
export const createCollectionImageMap = (collections) => {
|
|
188
|
+
return collections.reduce((imageMap, collection) => {
|
|
189
|
+
if (collection.customImage && collection.image) {
|
|
190
|
+
imageMap[collection.id] = collection.image;
|
|
209
191
|
}
|
|
210
|
-
return
|
|
211
|
-
});
|
|
212
|
-
}
|
|
192
|
+
return imageMap;
|
|
193
|
+
}, {});
|
|
194
|
+
};
|
|
195
|
+
// #endregion =-=-=-= END BLOCK UTILS =-=-=-=
|
package/dist/styles.css
CHANGED
|
@@ -704,9 +704,6 @@ video {
|
|
|
704
704
|
.bottom-2 {
|
|
705
705
|
bottom: 0.5rem;
|
|
706
706
|
}
|
|
707
|
-
.bottom-6 {
|
|
708
|
-
bottom: 1.5rem;
|
|
709
|
-
}
|
|
710
707
|
.bottom-\[18px\] {
|
|
711
708
|
bottom: 18px;
|
|
712
709
|
}
|
|
@@ -725,9 +722,6 @@ video {
|
|
|
725
722
|
.left-4 {
|
|
726
723
|
left: 1rem;
|
|
727
724
|
}
|
|
728
|
-
.left-6 {
|
|
729
|
-
left: 1.5rem;
|
|
730
|
-
}
|
|
731
725
|
.left-\[50\%\] {
|
|
732
726
|
left: 50%;
|
|
733
727
|
}
|
|
@@ -976,9 +970,6 @@ video {
|
|
|
976
970
|
.h-\[42px\] {
|
|
977
971
|
height: 42px;
|
|
978
972
|
}
|
|
979
|
-
.h-\[48px\] {
|
|
980
|
-
height: 48px;
|
|
981
|
-
}
|
|
982
973
|
.h-\[4px\] {
|
|
983
974
|
height: 4px;
|
|
984
975
|
}
|
|
@@ -1057,9 +1048,6 @@ video {
|
|
|
1057
1048
|
.w-\[22px\] {
|
|
1058
1049
|
width: 22px;
|
|
1059
1050
|
}
|
|
1060
|
-
.w-\[327px\] {
|
|
1061
|
-
width: 327px;
|
|
1062
|
-
}
|
|
1063
1051
|
.w-\[40px\] {
|
|
1064
1052
|
width: 40px;
|
|
1065
1053
|
}
|
|
@@ -1596,10 +1584,6 @@ video {
|
|
|
1596
1584
|
.p-\[1px\] {
|
|
1597
1585
|
padding: 1px;
|
|
1598
1586
|
}
|
|
1599
|
-
.\!px-0 {
|
|
1600
|
-
padding-left: 0px !important;
|
|
1601
|
-
padding-right: 0px !important;
|
|
1602
|
-
}
|
|
1603
1587
|
.px-0 {
|
|
1604
1588
|
padding-left: 0px;
|
|
1605
1589
|
padding-right: 0px;
|
|
@@ -1687,9 +1671,6 @@ video {
|
|
|
1687
1671
|
.pr-4 {
|
|
1688
1672
|
padding-right: 1rem;
|
|
1689
1673
|
}
|
|
1690
|
-
.pr-6 {
|
|
1691
|
-
padding-right: 1.5rem;
|
|
1692
|
-
}
|
|
1693
1674
|
.pt-0 {
|
|
1694
1675
|
padding-top: 0px;
|
|
1695
1676
|
}
|
|
@@ -1752,10 +1733,6 @@ video {
|
|
|
1752
1733
|
.text-\[23px\] {
|
|
1753
1734
|
font-size: 23px;
|
|
1754
1735
|
}
|
|
1755
|
-
.text-base {
|
|
1756
|
-
font-size: 1rem;
|
|
1757
|
-
line-height: 1.5rem;
|
|
1758
|
-
}
|
|
1759
1736
|
.text-lg {
|
|
1760
1737
|
font-size: 1.125rem;
|
|
1761
1738
|
line-height: 1.75rem;
|
|
@@ -1950,10 +1927,6 @@ video {
|
|
|
1950
1927
|
.text-textColors-strikethroughPriceText {
|
|
1951
1928
|
color: var(--textColors-strikethroughPriceText);
|
|
1952
1929
|
}
|
|
1953
|
-
.text-white {
|
|
1954
|
-
--tw-text-opacity: 1;
|
|
1955
|
-
color: rgb(255 255 255 / var(--tw-text-opacity));
|
|
1956
|
-
}
|
|
1957
1930
|
.line-through {
|
|
1958
1931
|
text-decoration-line: line-through;
|
|
1959
1932
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapcart/mobile-components",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"style": "dist/styles.css",
|
|
@@ -75,4 +75,4 @@
|
|
|
75
75
|
"tailwindcss-animate": "^1.0.6",
|
|
76
76
|
"vaul": "^0.9.1"
|
|
77
77
|
}
|
|
78
|
-
}
|
|
78
|
+
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Integrations } from "app-studio-types";
|
|
2
|
-
export declare function useNostoRecommendations(integrations: Integrations, baseURL: string, slotId?: null): {
|
|
3
|
-
recommendations: import("app-studio-types").Product[];
|
|
4
|
-
isLoading: boolean;
|
|
5
|
-
error: any;
|
|
6
|
-
isEmpty: boolean;
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=use-nosto-recommendation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-nosto-recommendation.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-nosto-recommendation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AA+E/C,wBAAgB,uBAAuB,CACrC,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,MAAM,EACf,MAAM,OAAO;;;;;EA4Cd"}
|
|
@@ -1,105 +0,0 @@
|
|
|
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 { useState, useEffect } from "react";
|
|
12
|
-
import { useProducts } from "./use-products";
|
|
13
|
-
const getRecommendations = (integrations, slotId = null) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
if (!Array.isArray(integrations))
|
|
15
|
-
return [];
|
|
16
|
-
const nosto = integrations.find((integration) => integration.name === "nosto");
|
|
17
|
-
const url = "https://api.nosto.com/v1/graphql";
|
|
18
|
-
const headers = new Headers({
|
|
19
|
-
"Content-Type": "application/json",
|
|
20
|
-
Authorization: "Basic " + btoa(":" + (nosto === null || nosto === void 0 ? void 0 : nosto.key)),
|
|
21
|
-
});
|
|
22
|
-
// Fetch sessionId
|
|
23
|
-
const sessionBody = JSON.stringify({
|
|
24
|
-
query: `mutation { newSession }`,
|
|
25
|
-
});
|
|
26
|
-
const sessionResponse = yield fetch(url, {
|
|
27
|
-
method: "POST",
|
|
28
|
-
headers: headers,
|
|
29
|
-
body: sessionBody,
|
|
30
|
-
});
|
|
31
|
-
const sessionData = yield sessionResponse.json();
|
|
32
|
-
const sessionId = sessionData.data.newSession;
|
|
33
|
-
// Main recommendation query
|
|
34
|
-
const body = JSON.stringify({
|
|
35
|
-
query: `
|
|
36
|
-
mutation {
|
|
37
|
-
updateSession(
|
|
38
|
-
by: BY_CID
|
|
39
|
-
id: "${sessionId}"
|
|
40
|
-
params: {
|
|
41
|
-
event: { type: VIEWED_PAGE, target: "home" }
|
|
42
|
-
}
|
|
43
|
-
) {
|
|
44
|
-
pages {
|
|
45
|
-
forFrontPage(
|
|
46
|
-
params: {
|
|
47
|
-
isPreview: false
|
|
48
|
-
imageVersion: VERSION_8_400_400
|
|
49
|
-
${slotId ? `slotIds: ["${slotId}"]` : ""}
|
|
50
|
-
}
|
|
51
|
-
) {
|
|
52
|
-
primary {
|
|
53
|
-
productId
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
`,
|
|
60
|
-
});
|
|
61
|
-
const response = yield fetch(url, {
|
|
62
|
-
method: "POST",
|
|
63
|
-
headers: headers,
|
|
64
|
-
mode: "cors",
|
|
65
|
-
body,
|
|
66
|
-
});
|
|
67
|
-
const json = yield response.json();
|
|
68
|
-
return json;
|
|
69
|
-
});
|
|
70
|
-
export function useNostoRecommendations(integrations, baseURL, slotId = null) {
|
|
71
|
-
var _a, _b, _c, _d;
|
|
72
|
-
const [nostoData, setNostoData] = useState(null);
|
|
73
|
-
const [isLoading, setIsLoading] = useState(true);
|
|
74
|
-
const [error, setError] = useState(null);
|
|
75
|
-
useEffect(() => {
|
|
76
|
-
function fetchNostoData() {
|
|
77
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
78
|
-
try {
|
|
79
|
-
const result = yield getRecommendations(integrations, slotId);
|
|
80
|
-
setNostoData(result);
|
|
81
|
-
}
|
|
82
|
-
catch (err) {
|
|
83
|
-
console.error("Error fetching recommendations:", err);
|
|
84
|
-
setError(err);
|
|
85
|
-
}
|
|
86
|
-
finally {
|
|
87
|
-
setIsLoading(false);
|
|
88
|
-
}
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
fetchNostoData();
|
|
92
|
-
}, [integrations, slotId]);
|
|
93
|
-
const productIds = ((_d = (_c = (_b = (_a = nostoData === null || nostoData === void 0 ? void 0 : nostoData.data) === null || _a === void 0 ? void 0 : _a.updateSession) === null || _b === void 0 ? void 0 : _b.pages) === null || _c === void 0 ? void 0 : _c.forFrontPage) === null || _d === void 0 ? void 0 : _d.flatMap((page) => page.primary).filter((item) => item && item.productId).map((item) => item.productId)) || [];
|
|
94
|
-
const { products, error: productsError, isLoading: productsLoading, } = useProducts({
|
|
95
|
-
productIds,
|
|
96
|
-
baseURL,
|
|
97
|
-
productHandles: [],
|
|
98
|
-
});
|
|
99
|
-
return {
|
|
100
|
-
recommendations: products,
|
|
101
|
-
isLoading: isLoading || productsLoading,
|
|
102
|
-
error: error || productsError,
|
|
103
|
-
isEmpty: products.length === 0,
|
|
104
|
-
};
|
|
105
|
-
}
|