@tapcart/mobile-components 0.7.4 → 0.7.6
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-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/drawer.d.ts +19 -10
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer.js +11 -8
- 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 +8 -25
- package/dist/styles.css +6 -33
- 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
package/dist/lib/price.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
// Return the cheapest available variant for pricing details
|
|
2
|
-
export const getCheapestProductFromVariantsFn = (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 getBadgeForProductFn = (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 getPriceRangesFn(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 getPriceFn(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
|
-
}
|