@tapcart/mobile-components 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/hooks/use-infinite-scroll.d.ts +3 -1
- package/dist/components/hooks/use-infinite-scroll.d.ts.map +1 -1
- package/dist/components/hooks/use-infinite-scroll.js +34 -11
- package/dist/components/hooks/use-nosto-recommendation.d.ts +8 -0
- package/dist/components/hooks/use-nosto-recommendation.d.ts.map +1 -0
- package/dist/components/hooks/use-nosto-recommendation.js +105 -0
- package/dist/components/hooks/use-products.d.ts +3 -1
- package/dist/components/hooks/use-products.d.ts.map +1 -1
- package/dist/components/hooks/use-products.js +21 -6
- package/dist/components/hooks/use-reviews.d.ts +27 -0
- package/dist/components/hooks/use-reviews.d.ts.map +1 -0
- package/dist/components/hooks/use-reviews.js +130 -0
- package/dist/components/templates/ProductCard/utils.d.ts +78 -0
- package/dist/components/templates/ProductCard/utils.d.ts.map +1 -0
- package/dist/components/templates/ProductCard/utils.js +128 -0
- package/dist/components/templates/ProductGrid/index.d.ts +1 -0
- package/dist/components/templates/ProductGrid/index.d.ts.map +1 -0
- package/dist/components/templates/ProductGrid/index.js +1 -0
- package/dist/components/ui/Input/input.d.ts +1 -1
- package/dist/components/ui/Input/input.d.ts.map +1 -1
- package/dist/components/ui/Input/input.js +23 -5
- package/dist/components/ui/Input/types.d.ts +3 -2
- package/dist/components/ui/Input/types.d.ts.map +1 -1
- package/dist/components/ui/Input/useInput.d.ts +2 -2
- package/dist/components/ui/Input/useInput.d.ts.map +1 -1
- package/dist/components/ui/Input/useInput.js +24 -10
- package/dist/components/ui/ProductCard/utils.d.ts +94 -0
- package/dist/components/ui/ProductCard/utils.d.ts.map +1 -0
- package/dist/components/ui/ProductCard/utils.js +148 -0
- package/dist/components/ui/ProductGrid/index.d.ts +1 -0
- package/dist/components/ui/ProductGrid/index.d.ts.map +1 -0
- package/dist/components/ui/ProductGrid/index.js +1 -0
- package/dist/components/ui/accordion.d.ts +3 -1
- package/dist/components/ui/accordion.d.ts.map +1 -1
- package/dist/components/ui/accordion.js +2 -2
- package/dist/components/ui/button.d.ts +2 -2
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/carousel.d.ts +1 -0
- package/dist/components/ui/carousel.d.ts.map +1 -1
- package/dist/components/ui/carousel.js +62 -2
- package/dist/components/ui/chip.d.ts +2 -2
- package/dist/components/ui/icon.d.ts +4 -1
- package/dist/components/ui/icon.d.ts.map +1 -1
- package/dist/components/ui/icon.js +35 -8
- package/dist/components/ui/image.d.ts.map +1 -1
- package/dist/components/ui/image.js +3 -3
- package/dist/components/ui/radio-group.d.ts +2 -2
- package/dist/components/ui/scroll-area.d.ts +1 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.js +2 -2
- package/dist/components/ui/toast.d.ts +2 -2
- package/dist/components/ui/toggle-group.d.ts +2 -2
- package/dist/components/ui/toggle.d.ts +2 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/lib/price.d.ts +29 -0
- package/dist/lib/price.d.ts.map +1 -0
- package/dist/lib/price.js +66 -0
- package/dist/lib/utils.d.ts +18 -0
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +44 -1
- package/dist/styles.css +201 -727
- package/dist/tapcart-mobile-components.umd.js +44 -0
- package/package.json +4 -3
- package/dist/components/templates/product-card.d.ts +0 -33
- package/dist/components/templates/product-card.d.ts.map +0 -1
- package/dist/components/templates/product-card.js +0 -42
- package/dist/components/templates/product-grid.d.ts +0 -14
- package/dist/components/templates/product-grid.d.ts.map +0 -1
- package/dist/components/templates/product-grid.js +0 -22
- 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
- package/dist/components/ui/select.d.ts +0 -14
- package/dist/components/ui/select.d.ts.map +0 -1
- package/dist/components/ui/select.js +0 -59
|
@@ -16,7 +16,9 @@ import useEmblaCarousel from "embla-carousel-react";
|
|
|
16
16
|
import { ArrowLeft, ArrowRight } from "lucide-react";
|
|
17
17
|
import { cn } from "../../lib/utils";
|
|
18
18
|
import { Button } from "../../components/ui/button";
|
|
19
|
+
const TWEEN_FACTOR_BASE = 0.1;
|
|
19
20
|
const CarouselContext = React.createContext(null);
|
|
21
|
+
const numberWithinRange = (number, min, max) => Math.min(Math.max(number, min), max);
|
|
20
22
|
function useCarousel() {
|
|
21
23
|
const context = React.useContext(CarouselContext);
|
|
22
24
|
if (!context) {
|
|
@@ -25,8 +27,9 @@ function useCarousel() {
|
|
|
25
27
|
return context;
|
|
26
28
|
}
|
|
27
29
|
const Carousel = React.forwardRef((_a, ref) => {
|
|
28
|
-
var { orientation = "horizontal", opts, setApi, plugins, className, children, slidesInView } = _a, props = __rest(_a, ["orientation", "opts", "setApi", "plugins", "className", "children", "slidesInView"]);
|
|
30
|
+
var { orientation = "horizontal", tween = false, opts, setApi, plugins, className, children, slidesInView } = _a, props = __rest(_a, ["orientation", "tween", "opts", "setApi", "plugins", "className", "children", "slidesInView"]);
|
|
29
31
|
const [carouselRef, api] = useEmblaCarousel(Object.assign(Object.assign({}, opts), { axis: orientation === "horizontal" ? "x" : "y" }), plugins);
|
|
32
|
+
const { setTweenNodes, setTweenFactor, tweenScale } = useTween();
|
|
30
33
|
const [canScrollPrev, setCanScrollPrev] = React.useState(false);
|
|
31
34
|
const [canScrollNext, setCanScrollNext] = React.useState(false);
|
|
32
35
|
const onSelect = React.useCallback((api) => {
|
|
@@ -65,7 +68,7 @@ const Carousel = React.forwardRef((_a, ref) => {
|
|
|
65
68
|
setApi(api);
|
|
66
69
|
}, [api, setApi]);
|
|
67
70
|
React.useEffect(() => {
|
|
68
|
-
if (!api) {
|
|
71
|
+
if (!api || tween) {
|
|
69
72
|
return;
|
|
70
73
|
}
|
|
71
74
|
onSelect(api);
|
|
@@ -76,6 +79,20 @@ const Carousel = React.forwardRef((_a, ref) => {
|
|
|
76
79
|
api === null || api === void 0 ? void 0 : api.off("select", onSelect);
|
|
77
80
|
};
|
|
78
81
|
}, [api, onSelect]);
|
|
82
|
+
React.useEffect(() => {
|
|
83
|
+
if (!api || !tween)
|
|
84
|
+
return;
|
|
85
|
+
setTweenNodes(api);
|
|
86
|
+
setTweenFactor(api);
|
|
87
|
+
tweenScale(api);
|
|
88
|
+
api
|
|
89
|
+
.on("reInit", setTweenNodes)
|
|
90
|
+
.on("reInit", setTweenFactor)
|
|
91
|
+
.on("reInit", tweenScale)
|
|
92
|
+
.on("scroll", tweenScale)
|
|
93
|
+
// @ts-ignore
|
|
94
|
+
.on("slideFocus", tweenScale);
|
|
95
|
+
}, [api, tweenScale]);
|
|
79
96
|
return (_jsx(CarouselContext.Provider, Object.assign({ value: {
|
|
80
97
|
carouselRef,
|
|
81
98
|
api: api,
|
|
@@ -144,4 +161,47 @@ const CarouselDots = React.forwardRef((_a, ref) => {
|
|
|
144
161
|
}
|
|
145
162
|
});
|
|
146
163
|
CarouselDots.displayName = "CarouselDots";
|
|
164
|
+
const useTween = () => {
|
|
165
|
+
const tweenFactor = React.useRef(0);
|
|
166
|
+
const tweenNodes = React.useRef([]);
|
|
167
|
+
const setTweenNodes = React.useCallback((emblaApi) => {
|
|
168
|
+
tweenNodes.current = emblaApi.slideNodes();
|
|
169
|
+
}, []);
|
|
170
|
+
const setTweenFactor = React.useCallback((emblaApi) => {
|
|
171
|
+
tweenFactor.current = TWEEN_FACTOR_BASE * emblaApi.scrollSnapList().length;
|
|
172
|
+
}, []);
|
|
173
|
+
const tweenScale = React.useCallback((emblaApi, eventName) => {
|
|
174
|
+
const engine = emblaApi.internalEngine();
|
|
175
|
+
const scrollProgress = emblaApi.scrollProgress();
|
|
176
|
+
const slidesInView = emblaApi.slidesInView();
|
|
177
|
+
const isScrollEvent = eventName === "scroll";
|
|
178
|
+
emblaApi.scrollSnapList().forEach((scrollSnap, snapIndex) => {
|
|
179
|
+
let diffToTarget = scrollSnap - scrollProgress;
|
|
180
|
+
const slidesInSnap = engine.slideRegistry[snapIndex];
|
|
181
|
+
slidesInSnap.forEach((slideIndex) => {
|
|
182
|
+
if (isScrollEvent && !slidesInView.includes(slideIndex))
|
|
183
|
+
return;
|
|
184
|
+
if (engine.options.loop) {
|
|
185
|
+
engine.slideLooper.loopPoints.forEach((loopItem) => {
|
|
186
|
+
const target = loopItem.target();
|
|
187
|
+
if (slideIndex === loopItem.index && target !== 0) {
|
|
188
|
+
const sign = Math.sign(target);
|
|
189
|
+
if (sign === -1) {
|
|
190
|
+
diffToTarget = scrollSnap - (1 + scrollProgress);
|
|
191
|
+
}
|
|
192
|
+
if (sign === 1) {
|
|
193
|
+
diffToTarget = scrollSnap + (1 - scrollProgress);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
const tweenValue = 1 - Math.abs(diffToTarget * tweenFactor.current);
|
|
199
|
+
const scale = numberWithinRange(tweenValue, 0, 1).toString();
|
|
200
|
+
const tweenNode = tweenNodes.current[slideIndex];
|
|
201
|
+
tweenNode.style.transform = `scale(${scale})`;
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
}, []);
|
|
205
|
+
return { setTweenNodes, setTweenFactor, tweenScale };
|
|
206
|
+
};
|
|
147
207
|
export { Carousel, CarouselContent, CarouselItem, CarouselPrevious, CarouselNext, CarouselDots, };
|
|
@@ -2,7 +2,7 @@ import { type VariantProps } from "class-variance-authority";
|
|
|
2
2
|
import React from "react";
|
|
3
3
|
declare const chipVariants: (props?: ({
|
|
4
4
|
variant?: "secondary" | "primary" | null | undefined;
|
|
5
|
-
direction?: "
|
|
5
|
+
direction?: "vertical" | "horizontal" | null | undefined;
|
|
6
6
|
iconPosition?: "left" | "right" | "default" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
8
8
|
type ChipProps = React.ComponentPropsWithoutRef<"div"> & VariantProps<typeof chipVariants> & {
|
|
@@ -13,7 +13,7 @@ type ChipProps = React.ComponentPropsWithoutRef<"div"> & VariantProps<typeof chi
|
|
|
13
13
|
};
|
|
14
14
|
declare const Chip: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & VariantProps<(props?: ({
|
|
15
15
|
variant?: "secondary" | "primary" | null | undefined;
|
|
16
|
-
direction?: "
|
|
16
|
+
direction?: "vertical" | "horizontal" | null | undefined;
|
|
17
17
|
iconPosition?: "left" | "right" | "default" | null | undefined;
|
|
18
18
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & {
|
|
19
19
|
icon?: React.ElementType<any> | undefined;
|
|
@@ -8,9 +8,12 @@ declare const iconVariants: (props?: ({
|
|
|
8
8
|
export interface IconProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "color">, VariantProps<typeof iconVariants> {
|
|
9
9
|
name?: string | null;
|
|
10
10
|
url?: string | null;
|
|
11
|
+
color?: string | null;
|
|
11
12
|
fillColor?: string | null;
|
|
13
|
+
secondaryFillColor?: string;
|
|
12
14
|
strokeColor?: string | null;
|
|
15
|
+
fillPercentage?: number | null;
|
|
13
16
|
}
|
|
14
|
-
declare function Icon({ className, name, size, color, url, fillColor, strokeColor, ...props }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare function Icon({ className, name, size, color, url, fillColor, secondaryFillColor, strokeColor, fillPercentage, ...props }: IconProps): import("react/jsx-runtime").JSX.Element;
|
|
15
18
|
export { Icon, iconVariants, IconPencilMinus };
|
|
16
19
|
//# sourceMappingURL=icon.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../components/ui/icon.tsx"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B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B;AAyFD,iBAAS,IAAI,CAAC,EACZ,SAAS,EACT,IAAI,EACJ,IAAW,EACX,KAAK,EACL,GAAG,EACH,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,GAAG,KAAK,EACT,EAAE,SAAS,2CAmBX;AAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE,CAAA"}
|
|
@@ -87,27 +87,54 @@ const TablerIcon = ({ name, size }) => {
|
|
|
87
87
|
const IconComponent = icons[name];
|
|
88
88
|
return IconComponent ? (_jsx(IconComponent, { size: sizeMapping[size], strokeWidth: strokeWidthMapping[size] })) : null;
|
|
89
89
|
};
|
|
90
|
-
const CustomIcon = ({ url, size, color, fillColor,
|
|
90
|
+
const CustomIcon = ({ url, size, color, strokeColor, fillColor, fillPercentage, secondaryFillColor }) => {
|
|
91
91
|
return (_jsx(ReactSVG, { src: url, beforeInjection: (svg) => {
|
|
92
92
|
svg.setAttribute("style", `width: ${sizeMapping[size]}px; height: ${sizeMapping[size]}px`);
|
|
93
93
|
const paths = svg.querySelectorAll("path");
|
|
94
94
|
paths.forEach((path) => {
|
|
95
95
|
if (color) {
|
|
96
|
-
if (path.hasAttribute("fill"))
|
|
96
|
+
if (path.hasAttribute("fill") && fillPercentage === 1) {
|
|
97
97
|
path.setAttribute("fill", color);
|
|
98
|
-
|
|
99
|
-
|
|
98
|
+
}
|
|
99
|
+
path.setAttribute("stroke", color);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
if (fillColor && path.hasAttribute("fill") && fillPercentage === 1) {
|
|
103
|
+
path.setAttribute("fill", fillColor);
|
|
104
|
+
}
|
|
105
|
+
if (strokeColor) {
|
|
106
|
+
path.setAttribute("stroke", strokeColor);
|
|
107
|
+
}
|
|
100
108
|
}
|
|
101
109
|
if (path.hasAttribute("stroke")) {
|
|
102
110
|
path.setAttribute("stroke-width", strokeWidthMapping[size].toString());
|
|
103
111
|
}
|
|
104
|
-
|
|
105
|
-
|
|
112
|
+
// Create a gradient fill based on the fillPercentage
|
|
113
|
+
if (fillPercentage && fillPercentage > 0 && fillPercentage < 1) {
|
|
114
|
+
const percentage = Math.min(Math.max(fillPercentage, 0), 1);
|
|
115
|
+
const gradientId = `gradient-${Math.random()}`;
|
|
116
|
+
const gradient = document.createElementNS("http://www.w3.org/2000/svg", "linearGradient");
|
|
117
|
+
gradient.setAttribute("id", gradientId);
|
|
118
|
+
gradient.setAttribute("x1", "0%");
|
|
119
|
+
gradient.setAttribute("y1", "0%");
|
|
120
|
+
gradient.setAttribute("x2", "100%");
|
|
121
|
+
gradient.setAttribute("y2", "0%");
|
|
122
|
+
const stop1 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
|
|
123
|
+
stop1.setAttribute("offset", `${percentage * 100}%`);
|
|
124
|
+
stop1.setAttribute("stop-color", color || fillColor || "currentColor");
|
|
125
|
+
gradient.appendChild(stop1);
|
|
126
|
+
const stop2 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
|
|
127
|
+
stop2.setAttribute("offset", `${percentage * 100}%`);
|
|
128
|
+
stop2.setAttribute("stop-color", secondaryFillColor || "transparent"); // Use secondary fill color
|
|
129
|
+
gradient.appendChild(stop2);
|
|
130
|
+
svg.appendChild(gradient);
|
|
131
|
+
path.setAttribute("fill", `url(#${gradientId})`);
|
|
132
|
+
}
|
|
106
133
|
});
|
|
107
134
|
} }));
|
|
108
135
|
};
|
|
109
136
|
function Icon(_a) {
|
|
110
|
-
var { className, name, size = "md", color, url, fillColor, strokeColor } = _a, props = __rest(_a, ["className", "name", "size", "color", "url", "fillColor", "strokeColor"]);
|
|
111
|
-
return (_jsxs("div", Object.assign({ className: cn(iconVariants({ size, color, className
|
|
137
|
+
var { className, name, size = "md", color, url, fillColor, secondaryFillColor, strokeColor, fillPercentage } = _a, props = __rest(_a, ["className", "name", "size", "color", "url", "fillColor", "secondaryFillColor", "strokeColor", "fillPercentage"]);
|
|
138
|
+
return (_jsxs("div", Object.assign({ className: cn(iconVariants({ size, color }), className) }, props, { children: [url ? (_jsx(CustomIcon, { url: url, size: size, color: color, fillColor: fillColor, secondaryFillColor: secondaryFillColor, strokeColor: strokeColor, fillPercentage: fillPercentage || (color || fillColor ? 1 : 0) })) : (_jsx(TablerIcon, { name: name, size: size })), props.children] })));
|
|
112
139
|
}
|
|
113
140
|
export { Icon, iconVariants, IconPencilMinus };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../components/ui/image.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,KAAK,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAkC1D,KAAK,aAAa,GAAG;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;IACrB,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAUD,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,SAAS,CAAC,KAAK,CAAC,CAAA;IACtB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,IAAI,CAAA;IACX,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,MAAM,MAAM,MAAM,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,MAAM,CAAA;AAKrD,KAAK,IAAI,GAAG,QAAQ,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAI1D,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,qBAAqB,CAAC,KAAK,CAAC,GAChE,qBAAqB,CAAA;AAEvB,KAAK,qBAAqB,GAAG;IAC3B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AI,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC,EACpE,MAAM,GAAE,MAAsB,EAC9B,WAAW,UAAQ,GAClB,MAAM,CAiBR;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,6BAA0B,EAC/B,SAAS,EAAE,MAAM,EACjB,aAAa,EAAE,MAAM,EACrB,aAAa,EAAE,MAAM,GACpB,MAAM,EAAE,CAUV;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAIzE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,WAAW,CAAC,EAAE,MAAM,EAAE,EACtB,WAAW,CAAC,EAAE,MAAM,EACpB,IAAI,GAAE,IAAe,GAEnB;IACE,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;IAC1B,IAAI,EAAE,IAAI,CAAA;CACX,EAAE,GACH,SAAS,CAUZ"}
|
|
@@ -168,14 +168,14 @@ 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.aspectRatio) === null || _b === void 0 ? void 0 : _b.replace(":", "/") }, imageWrapperStyles);
|
|
171
|
+
const wrapperStyle = Object.assign({ aspectRatio: (_b = normalizedProps === null || normalizedProps === void 0 ? void 0 : 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,
|
|
175
175
|
sizes,
|
|
176
176
|
fetchPriority: normalizedProps.fetchPriority,
|
|
177
177
|
src: normalizedProps.src || "",
|
|
178
|
-
} })), _jsx("div", Object.assign({ className: "relative bg-stateColors-skeleton border-transparent", style: wrapperStyle }, { children: !hasError && normalizedProps.src ? (_jsx("img", Object.assign({}, passthroughProps, { fetchPriority: normalizedProps.fetchPriority, alt: normalizedProps.alt, decoding: decoding, height: normalizedProps.height, loading: loading, srcSet: srcSet, width: normalizedProps.width, className: imgClassName, onLoad: handleImageLoad, onError: handleImageError, sizes: sizes,
|
|
178
|
+
} })), _jsx("div", Object.assign({ className: "relative bg-stateColors-skeleton border-transparent", style: Object.assign({ borderRadius: `${imageRadius}px` }, wrapperStyle) }, { children: !hasError && normalizedProps.src ? (_jsx("img", Object.assign({}, passthroughProps, { fetchPriority: normalizedProps.fetchPriority, alt: normalizedProps.alt, decoding: decoding, height: normalizedProps.height, loading: loading, srcSet: srcSet, width: normalizedProps.width, className: imgClassName, onLoad: handleImageLoad, onError: handleImageError, sizes: sizes,
|
|
179
179
|
// `src` needs to come after `sizes` and `srcSet` because React updates
|
|
180
180
|
// attributes in order. If we keep `src` the first one, Safari will
|
|
181
181
|
// immediately start to fetch `src`, before `sizes` and `srcSet` are even
|
|
@@ -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.aspectRatio) === null || _c === void 0 ? void 0 : _c.replace(":", "/")
|
|
186
|
+
? (_c = normalizedProps === null || normalizedProps === void 0 ? void 0 : normalizedProps.aspectRatio) === null || _c === void 0 ? void 0 : _c.replace(":", "/")
|
|
187
187
|
: "2/3" }, imageWrapperStyles) })) }))] }));
|
|
188
188
|
});
|
|
189
189
|
/**
|
|
@@ -12,10 +12,10 @@ export interface RadioGroupItemProps {
|
|
|
12
12
|
value: string;
|
|
13
13
|
}
|
|
14
14
|
declare const radiogroupItemVariants: (props?: ({
|
|
15
|
-
variant?: "
|
|
15
|
+
variant?: "default" | "selected" | "deactivated" | null | undefined;
|
|
16
16
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
17
17
|
declare const RadioGroupItem: React.ForwardRefExoticComponent<Omit<RadioGroupPrimitive.RadioGroupItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & RadioGroupItemProps & VariantProps<(props?: ({
|
|
18
|
-
variant?: "
|
|
18
|
+
variant?: "default" | "selected" | "deactivated" | null | undefined;
|
|
19
19
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLButtonElement>>;
|
|
20
20
|
export { RadioGroup, RadioGroupItem, radiogroupItemVariants };
|
|
21
21
|
//# sourceMappingURL=radio-group.d.ts.map
|
|
@@ -3,6 +3,7 @@ import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
|
|
|
3
3
|
type Orientation = "horizontal" | "vertical";
|
|
4
4
|
declare const ScrollArea: React.ForwardRefExoticComponent<Omit<ScrollAreaPrimitive.ScrollAreaProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
5
5
|
wrapperClass?: string | undefined;
|
|
6
|
+
scrollbar: boolean;
|
|
6
7
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
7
8
|
declare const ScrollBar: React.ForwardRefExoticComponent<Omit<ScrollAreaPrimitive.ScrollAreaScrollbarProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
8
9
|
orientation?: Orientation | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scroll-area.d.ts","sourceRoot":"","sources":["../../../components/ui/scroll-area.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,mBAAmB,MAAM,6BAA6B,CAAA;AAIlE,KAAK,WAAW,GAAG,YAAY,GAAG,UAAU,CAAA;AAE5C,QAAA,MAAM,UAAU;;
|
|
1
|
+
{"version":3,"file":"scroll-area.d.ts","sourceRoot":"","sources":["../../../components/ui/scroll-area.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,mBAAmB,MAAM,6BAA6B,CAAA;AAIlE,KAAK,WAAW,GAAG,YAAY,GAAG,UAAU,CAAA;AAE5C,QAAA,MAAM,UAAU;;eAID,OAAO;wCAcpB,CAAA;AAGF,QAAA,MAAM,SAAS;;wCAuBb,CAAA;AAGF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA"}
|
|
@@ -15,8 +15,8 @@ import * as React from "react";
|
|
|
15
15
|
import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
|
|
16
16
|
import { cn } from "../../lib/utils";
|
|
17
17
|
const ScrollArea = React.forwardRef((_a, ref) => {
|
|
18
|
-
var { className, wrapperClass, children } = _a, props = __rest(_a, ["className", "wrapperClass", "children"]);
|
|
19
|
-
return (_jsxs(ScrollAreaPrimitive.Root, Object.assign({ ref: ref, className: cn("relative overflow-hidden", className) }, props, { children: [_jsx(ScrollAreaPrimitive.Viewport, Object.assign({ className: "h-full w-full rounded-[inherit]" }, { children: _jsx("div", Object.assign({ className: cn("flex w-max", wrapperClass) }, { children: children })) })), _jsx(ScrollBar, {}), _jsx(ScrollAreaPrimitive.Corner, {})] })));
|
|
18
|
+
var { className, wrapperClass, scrollbar = true, children } = _a, props = __rest(_a, ["className", "wrapperClass", "scrollbar", "children"]);
|
|
19
|
+
return (_jsxs(ScrollAreaPrimitive.Root, Object.assign({ ref: ref, className: cn("relative overflow-hidden", className) }, props, { children: [_jsx(ScrollAreaPrimitive.Viewport, Object.assign({ className: "h-full w-full rounded-[inherit]" }, { children: _jsx("div", Object.assign({ className: cn("flex w-max", wrapperClass) }, { children: children })) })), _jsx(ScrollBar, { className: scrollbar ? "" : "hidden" }), _jsx(ScrollAreaPrimitive.Corner, {})] })));
|
|
20
20
|
});
|
|
21
21
|
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
|
22
22
|
const ScrollBar = React.forwardRef((_a, ref) => {
|
|
@@ -4,14 +4,14 @@ import { type VariantProps } from "class-variance-authority";
|
|
|
4
4
|
declare const ToastProvider: React.FC<ToastPrimitives.ToastProviderProps>;
|
|
5
5
|
declare const ToastViewport: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastViewportProps & React.RefAttributes<HTMLOListElement>, "ref"> & React.RefAttributes<HTMLOListElement>>;
|
|
6
6
|
declare const Toast: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastProps & React.RefAttributes<HTMLLIElement>, "ref"> & VariantProps<(props?: ({
|
|
7
|
-
variant?: "
|
|
7
|
+
variant?: "default" | "error" | "warning" | "success" | null | undefined;
|
|
8
8
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLLIElement>>;
|
|
9
9
|
declare const ToastAction: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastActionProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
10
10
|
declare const ToastClose: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastCloseProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
11
11
|
declare const ToastTitle: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastTitleProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
12
12
|
type ToastType = "default" | "warning" | "error" | "success";
|
|
13
13
|
declare const ToastDescription: React.ForwardRefExoticComponent<Omit<ToastPrimitives.ToastDescriptionProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
|
|
14
|
-
type?: "
|
|
14
|
+
type?: "default" | "error" | "warning" | "success" | undefined;
|
|
15
15
|
icon?: boolean | undefined;
|
|
16
16
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
17
17
|
type ToastProps = React.ComponentPropsWithoutRef<typeof Toast>;
|
|
@@ -3,11 +3,11 @@ import * as ToggleGroupPrimitive from "@radix-ui/react-toggle-group";
|
|
|
3
3
|
import { VariantProps } from "class-variance-authority";
|
|
4
4
|
declare const ToggleGroup: React.ForwardRefExoticComponent<((Omit<ToggleGroupPrimitive.ToggleGroupSingleProps & React.RefAttributes<HTMLDivElement>, "ref"> | Omit<ToggleGroupPrimitive.ToggleGroupMultipleProps & React.RefAttributes<HTMLDivElement>, "ref">) & VariantProps<(props?: ({
|
|
5
5
|
variant?: "default" | "outline" | null | undefined;
|
|
6
|
-
size?: "
|
|
6
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string>) & React.RefAttributes<HTMLDivElement>>;
|
|
8
8
|
declare const ToggleGroupItem: React.ForwardRefExoticComponent<Omit<ToggleGroupPrimitive.ToggleGroupItemProps & React.RefAttributes<HTMLButtonElement>, "ref"> & VariantProps<(props?: ({
|
|
9
9
|
variant?: "default" | "outline" | null | undefined;
|
|
10
|
-
size?: "
|
|
10
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
11
11
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLButtonElement>>;
|
|
12
12
|
export { ToggleGroup, ToggleGroupItem };
|
|
13
13
|
//# sourceMappingURL=toggle-group.d.ts.map
|
|
@@ -3,11 +3,11 @@ import * as TogglePrimitive from "@radix-ui/react-toggle";
|
|
|
3
3
|
import { type VariantProps } from "class-variance-authority";
|
|
4
4
|
declare const toggleVariants: (props?: ({
|
|
5
5
|
variant?: "default" | "outline" | null | undefined;
|
|
6
|
-
size?: "
|
|
6
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
8
8
|
declare const Toggle: React.ForwardRefExoticComponent<Omit<TogglePrimitive.ToggleProps & React.RefAttributes<HTMLButtonElement>, "ref"> & VariantProps<(props?: ({
|
|
9
9
|
variant?: "default" | "outline" | null | undefined;
|
|
10
|
-
size?: "
|
|
10
|
+
size?: "default" | "sm" | "lg" | null | undefined;
|
|
11
11
|
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & React.RefAttributes<HTMLButtonElement>>;
|
|
12
12
|
export { Toggle, toggleVariants };
|
|
13
13
|
//# sourceMappingURL=toggle.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, stringRatioToInt, getOverlayStyle, } from "./lib/utils";
|
|
1
|
+
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttle, getDestinationHandler, getProductGidsFromIds, } 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";
|
|
5
5
|
export * from "./components/hooks/use-products";
|
|
6
6
|
export * from "./components/hooks/use-scroll-direction";
|
|
7
7
|
export * from "./components/hooks/use-sort-filter";
|
|
8
|
+
export * from "./components/hooks/use-product-options";
|
|
9
|
+
export * from "./components/hooks/use-shop";
|
|
10
|
+
export * from "./components/hooks/use-tap";
|
|
8
11
|
export * from "./components/ui/accordion";
|
|
9
12
|
export * from "./components/ui/aspect-ratio";
|
|
10
13
|
export * from "./components/ui/badge";
|
|
@@ -46,10 +49,14 @@ export * from "./components/ui/toggle";
|
|
|
46
49
|
export * from "./components/ui/use-toast";
|
|
47
50
|
export * from "./components/ui/video";
|
|
48
51
|
export * from "./components/ui/wishlist";
|
|
49
|
-
export * from "./components/hooks/use-product-options";
|
|
50
52
|
export * from "./components/ui/wishlist-select";
|
|
51
53
|
export * from "./components/hooks/use-shop";
|
|
52
54
|
export * from "./components/libs/sort-filter/search-integration";
|
|
55
|
+
export * from "./components/hooks/use-reviews";
|
|
53
56
|
export * from "./components/ui/subcollection-tabs";
|
|
54
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
|
+
export * from "./components/libs/sort-filter/search-integration";
|
|
55
62
|
//# 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,gBAAgB,EAChB,eAAe,
|
|
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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AwB,CAAA;AACtC,cAAc,sBAAsB,CAAA;AACpC,cAAc,sBAAsB,CAAA;AACpC,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,4BAA4B,CAAA;AAC1C,cAAc,mCAAmC,CAAA;AACjD,cAAc,aAAa,CAAA;AAC3B,cAAc,6CAA6C,CAAA;AAC3D,cAAc,kDAAkD,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
// component exports
|
|
2
|
-
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, stringRatioToInt, getOverlayStyle, } from "./lib/utils";
|
|
2
|
+
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttle, getDestinationHandler, getProductGidsFromIds, } 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";
|
|
6
6
|
export * from "./components/hooks/use-products";
|
|
7
7
|
export * from "./components/hooks/use-scroll-direction";
|
|
8
8
|
export * from "./components/hooks/use-sort-filter";
|
|
9
|
+
export * from "./components/hooks/use-product-options";
|
|
10
|
+
export * from "./components/hooks/use-shop";
|
|
11
|
+
export * from "./components/hooks/use-tap";
|
|
9
12
|
export * from "./components/ui/accordion";
|
|
10
13
|
export * from "./components/ui/aspect-ratio";
|
|
11
14
|
export * from "./components/ui/badge";
|
|
@@ -47,9 +50,13 @@ export * from "./components/ui/toggle";
|
|
|
47
50
|
export * from "./components/ui/use-toast";
|
|
48
51
|
export * from "./components/ui/video";
|
|
49
52
|
export * from "./components/ui/wishlist";
|
|
50
|
-
export * from "./components/hooks/use-product-options";
|
|
51
53
|
export * from "./components/ui/wishlist-select";
|
|
52
54
|
export * from "./components/hooks/use-shop";
|
|
53
55
|
export * from "./components/libs/sort-filter/search-integration";
|
|
56
|
+
export * from "./components/hooks/use-reviews";
|
|
54
57
|
export * from "./components/ui/subcollection-tabs";
|
|
55
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
|
+
export * from "./components/libs/sort-filter/search-integration";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ProductVariant, Product } from "app-studio-types";
|
|
2
|
+
type Badge = {
|
|
3
|
+
verticalPosition: "below" | "bottom" | "top";
|
|
4
|
+
priority: number;
|
|
5
|
+
tags: string[];
|
|
6
|
+
excludeTags: string[];
|
|
7
|
+
text?: string;
|
|
8
|
+
color?: string;
|
|
9
|
+
backgroundColor?: string;
|
|
10
|
+
};
|
|
11
|
+
type BadgeConfig = {
|
|
12
|
+
[key in "below" | "bottom" | "top"]?: Badge[];
|
|
13
|
+
};
|
|
14
|
+
export declare const getCheapestProductFromVariants: (productVariants: ProductVariant[]) => ProductVariant;
|
|
15
|
+
export declare const getBadgeForProduct: (badgeConfig?: BadgeConfig, productTags?: string[]) => Badge | undefined;
|
|
16
|
+
export declare function getPriceRanges(product: Product): {
|
|
17
|
+
price: number;
|
|
18
|
+
isSale: boolean;
|
|
19
|
+
priceHigh?: number | undefined;
|
|
20
|
+
compareAtPrice?: number | undefined;
|
|
21
|
+
compareAtPriceHigh?: number | undefined;
|
|
22
|
+
};
|
|
23
|
+
export declare function getPrice(product: Product): {
|
|
24
|
+
price: number;
|
|
25
|
+
compareAtPrice: number;
|
|
26
|
+
isSale: boolean;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=price.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"price.d.ts","sourceRoot":"","sources":["../../lib/price.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAG1D,KAAK,KAAK,GAAG;IACX,gBAAgB,EAAE,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAA;IAC5C,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,WAAW,EAAE,MAAM,EAAE,CAAA;IAErB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,eAAe,CAAC,EAAE,MAAM,CAAA;CACzB,CAAA;AAGD,KAAK,WAAW,GAAG;KAChB,GAAG,IAAI,OAAO,GAAG,QAAQ,GAAG,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE;CAC9C,CAAA;AAGD,eAAO,MAAM,8BAA8B,oBACxB,cAAc,EAAE,mBAelC,CAAA;AAED,eAAO,MAAM,kBAAkB,iBAChB,WAAW,gBACX,MAAM,EAAE,KACpB,KAAK,GAAG,SAqBV,CAAA;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,OAAO;WAsBpC,MAAM;YACL,OAAO;;;;EAclB;AAED,wBAAgB,QAAQ,CAAC,OAAO,EAAE,OAAO;;;;EAQxC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// Return the cheapest available variant for pricing details
|
|
2
|
+
export const getCheapestProductFromVariants = (productVariants) => {
|
|
3
|
+
const availableVariants = productVariants.filter((variant) => variant.availableForSale);
|
|
4
|
+
// Use pricing from in-stock variants only. If all are out of stock use all variants.
|
|
5
|
+
const activeVariants = availableVariants.length
|
|
6
|
+
? availableVariants
|
|
7
|
+
: productVariants;
|
|
8
|
+
return activeVariants.reduce((lowest, current) => {
|
|
9
|
+
return parseFloat(current.price.amount) < parseFloat(lowest.price.amount)
|
|
10
|
+
? current
|
|
11
|
+
: lowest;
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
export const getBadgeForProduct = (badgeConfig = {}, productTags = []) => {
|
|
15
|
+
const badgePositions = ["below", "bottom", "top"];
|
|
16
|
+
const badgesCombined = [];
|
|
17
|
+
const addBadgesToCombined = (badgePosition) => {
|
|
18
|
+
var _a;
|
|
19
|
+
return (_a = badgeConfig[badgePosition]) === null || _a === void 0 ? void 0 : _a.forEach((badge) => badgesCombined.push(Object.assign(Object.assign({}, badge), { verticalPosition: badgePosition })));
|
|
20
|
+
};
|
|
21
|
+
badgePositions.forEach(addBadgesToCombined);
|
|
22
|
+
badgesCombined.sort((a, b) => a.priority - b.priority);
|
|
23
|
+
let productBadge = badgesCombined.find((badge) => {
|
|
24
|
+
if (productTags.includes(badge.tags[0])) {
|
|
25
|
+
if (productTags.includes(badge.excludeTags[0]))
|
|
26
|
+
return false;
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
return false;
|
|
30
|
+
});
|
|
31
|
+
return productBadge;
|
|
32
|
+
};
|
|
33
|
+
export function getPriceRanges(product) {
|
|
34
|
+
const { minVariantPrice: minPrice, maxVariantPrice: maxPrice } = product.priceRange;
|
|
35
|
+
const { minVariantPrice: minCompareAt, maxVariantPrice: maxCompareAt } = product.compareAtPriceRange;
|
|
36
|
+
const floatMinPrice = parseFloat(minPrice.amount);
|
|
37
|
+
const floatMaxPrice = minPrice.amount !== maxPrice.amount && parseFloat(maxPrice.amount);
|
|
38
|
+
const floatMinCompareAt = minCompareAt && parseFloat(minCompareAt.amount);
|
|
39
|
+
const floatMaxCompareAt = minCompareAt.amount !== maxCompareAt.amount &&
|
|
40
|
+
parseFloat(maxCompareAt.amount);
|
|
41
|
+
const isSale = product.variants.some((variant) => {
|
|
42
|
+
return (variant.compareAtPrice &&
|
|
43
|
+
parseFloat(variant.price.amount) <
|
|
44
|
+
parseFloat(variant.compareAtPrice.amount));
|
|
45
|
+
});
|
|
46
|
+
const formattedPrice = {
|
|
47
|
+
price: floatMinPrice,
|
|
48
|
+
isSale,
|
|
49
|
+
};
|
|
50
|
+
if (floatMaxPrice)
|
|
51
|
+
formattedPrice.priceHigh = floatMaxPrice;
|
|
52
|
+
if (floatMinCompareAt)
|
|
53
|
+
formattedPrice.compareAtPrice = floatMinCompareAt;
|
|
54
|
+
if (floatMaxCompareAt)
|
|
55
|
+
formattedPrice.compareAtPriceHigh = floatMaxCompareAt;
|
|
56
|
+
return formattedPrice;
|
|
57
|
+
}
|
|
58
|
+
export function getPrice(product) {
|
|
59
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
60
|
+
return {
|
|
61
|
+
price: parseFloat((_b = (_a = product.variants[0]) === null || _a === void 0 ? void 0 : _a.price) === null || _b === void 0 ? void 0 : _b.amount),
|
|
62
|
+
compareAtPrice: parseFloat((_d = (_c = product.variants[0]) === null || _c === void 0 ? void 0 : _c.compareAtPrice) === null || _d === void 0 ? void 0 : _d.amount),
|
|
63
|
+
isSale: parseFloat((_f = (_e = product.variants[0]) === null || _e === void 0 ? void 0 : _e.price) === null || _f === void 0 ? void 0 : _f.amount) <
|
|
64
|
+
parseFloat((_h = (_g = product.variants[0]) === null || _g === void 0 ? void 0 : _g.compareAtPrice) === null || _h === void 0 ? void 0 : _h.amount),
|
|
65
|
+
};
|
|
66
|
+
}
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -146,6 +146,8 @@ 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
|
+
export declare function formatRelativeTime(inputDate: Date | string): string;
|
|
149
151
|
export declare const stringRatioToInt: (string: string) => number;
|
|
150
152
|
export declare const getOverlayStyle: (opacity: number) => {
|
|
151
153
|
position: string;
|
|
@@ -155,4 +157,20 @@ export declare const getOverlayStyle: (opacity: number) => {
|
|
|
155
157
|
bottom: number;
|
|
156
158
|
backgroundColor: string;
|
|
157
159
|
};
|
|
160
|
+
type DestinationActions = {
|
|
161
|
+
openScreen: (arg: {
|
|
162
|
+
destination: {
|
|
163
|
+
type: "internal" | "web";
|
|
164
|
+
url: string;
|
|
165
|
+
};
|
|
166
|
+
}) => void;
|
|
167
|
+
openProduct: (arg: {
|
|
168
|
+
productId: string;
|
|
169
|
+
}) => void;
|
|
170
|
+
openCollection: (arg: {
|
|
171
|
+
collectionId: string;
|
|
172
|
+
}) => void;
|
|
173
|
+
};
|
|
174
|
+
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 function getProductGidsFromIds(ids: string[]): string[];
|
|
158
176
|
//# 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;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],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