@tapcart/mobile-components 0.7.39 → 0.7.41
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-order-details.d.ts +14 -0
- package/dist/components/hooks/use-order-details.d.ts.map +1 -0
- package/dist/components/hooks/use-order-details.js +146 -0
- package/dist/components/ui/switch.d.ts +3 -1
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/switch.js +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +8 -3
- package/dist/styles.css +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
type UseOrderDetailsProps = {
|
|
2
|
+
variables: Record<string, any>;
|
|
3
|
+
apiUrl: string;
|
|
4
|
+
appId: string;
|
|
5
|
+
language: string;
|
|
6
|
+
country: string;
|
|
7
|
+
mock?: boolean;
|
|
8
|
+
};
|
|
9
|
+
type UseProductsReturn = {
|
|
10
|
+
orderDetails: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
export declare function useOrderDetails({ variables, apiUrl, appId, language, country, mock, }: UseOrderDetailsProps): UseProductsReturn;
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=use-order-details.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-order-details.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-order-details.ts"],"names":[],"mappings":"AAMA,KAAK,oBAAoB,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAClC,CAAA;AAyJD,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAY,GACb,EAAE,oBAAoB,GAAG,iBAAiB,CA0C1C"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { getIdFromGid } from "../../lib/utils";
|
|
3
|
+
import { useProducts } from "./use-products";
|
|
4
|
+
import { useEffect, useMemo, useState } from "react";
|
|
5
|
+
const getSellingPlan = (lineItems, productGid) => {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
const productId = getIdFromGid(productGid);
|
|
8
|
+
const item = lineItems.find((item) => { var _a, _b; return ((_b = (_a = item === null || item === void 0 ? void 0 : item.variant) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.id) === productId; });
|
|
9
|
+
if (!item) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return (_b = (_a = item === null || item === void 0 ? void 0 : item.sellingPlanAllocation) === null || _a === void 0 ? void 0 : _a.sellingPlan) === null || _b === void 0 ? void 0 : _b.name;
|
|
13
|
+
};
|
|
14
|
+
const getSalesAmount = (lines) => {
|
|
15
|
+
return lines === null || lines === void 0 ? void 0 : lines.reduce((acc, line) => {
|
|
16
|
+
const sale = line.sale ? parseFloat(line.sale) : 0;
|
|
17
|
+
return acc + sale * line.quantity;
|
|
18
|
+
}, 0);
|
|
19
|
+
};
|
|
20
|
+
const getSubtotal = (lines) => {
|
|
21
|
+
return lines === null || lines === void 0 ? void 0 : lines.reduce((acc, line) => {
|
|
22
|
+
const price = parseFloat(line.compareAtPrice ? line.compareAtPrice.amount : line.price.amount);
|
|
23
|
+
return acc + price * line.quantity;
|
|
24
|
+
}, 0);
|
|
25
|
+
};
|
|
26
|
+
const findProductById = (products, productId) => products.find((product) => product.id === productId);
|
|
27
|
+
const findVariantById = (variants, merchandiseId) => variants.find((variant) => variant.id === merchandiseId);
|
|
28
|
+
const calculateSale = (compareAtPrice, price) => parseFloat(compareAtPrice) - parseFloat(price);
|
|
29
|
+
const updateLineWithVariantDetails = (line, variant) => {
|
|
30
|
+
var _a;
|
|
31
|
+
line.compareAtPrice = variant.compareAtPrice;
|
|
32
|
+
line.variantName = variant.title;
|
|
33
|
+
line.sale = ((_a = variant.compareAtPrice) === null || _a === void 0 ? void 0 : _a.amount)
|
|
34
|
+
? calculateSale(variant.compareAtPrice.amount, variant.price.amount)
|
|
35
|
+
: 0;
|
|
36
|
+
};
|
|
37
|
+
const updateLineDetails = (line, products, checkoutData) => {
|
|
38
|
+
const product = findProductById(products, line.productId);
|
|
39
|
+
if (!product)
|
|
40
|
+
return;
|
|
41
|
+
line.title = product.title;
|
|
42
|
+
line.vendor = product.vendor;
|
|
43
|
+
line.sellingPlan = getSellingPlan(checkoutData.lineItems, line.productId);
|
|
44
|
+
const productVariant = findVariantById(product.variants, line.merchandiseId);
|
|
45
|
+
if (productVariant) {
|
|
46
|
+
updateLineWithVariantDetails(line, productVariant);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const getProductIds = (lines) => lines === null || lines === void 0 ? void 0 : lines.map((line) => line.productId);
|
|
50
|
+
const calculateCompareAtPrice = (variant) => {
|
|
51
|
+
var _a, _b, _c, _d;
|
|
52
|
+
return ({
|
|
53
|
+
amount: (_b = (_a = variant === null || variant === void 0 ? void 0 : variant.compareAtPrice) === null || _a === void 0 ? void 0 : _a.amount) !== null && _b !== void 0 ? _b : parseFloat(variant === null || variant === void 0 ? void 0 : variant.price.amount) + 20,
|
|
54
|
+
currencyCode: (_d = (_c = variant === null || variant === void 0 ? void 0 : variant.compareAtPrice) === null || _c === void 0 ? void 0 : _c.currencyCode) !== null && _d !== void 0 ? _d : "USD",
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
const createPaymentMethods = () => [
|
|
58
|
+
{ details: { currency: "USD", amount: 20 }, type: "giftCard" },
|
|
59
|
+
];
|
|
60
|
+
const createCartLines = (product, variant, compareAtPrice) => {
|
|
61
|
+
var _a, _b;
|
|
62
|
+
return [
|
|
63
|
+
{
|
|
64
|
+
title: product.title,
|
|
65
|
+
merchandiseId: variant.id,
|
|
66
|
+
vendor: product.vendor,
|
|
67
|
+
sellingPlan: "Subscription every 2 weeks",
|
|
68
|
+
image: {
|
|
69
|
+
lg: (_a = product.featuredImage) === null || _a === void 0 ? void 0 : _a.url,
|
|
70
|
+
altText: (_b = product.featuredImage) === null || _b === void 0 ? void 0 : _b.altText,
|
|
71
|
+
},
|
|
72
|
+
quantity: 1,
|
|
73
|
+
price: variant === null || variant === void 0 ? void 0 : variant.price,
|
|
74
|
+
compareAtPrice,
|
|
75
|
+
variantName: variant.title,
|
|
76
|
+
sale: calculateSale(compareAtPrice.amount, variant.price.amount),
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
};
|
|
80
|
+
const calculateCartPrice = (variant, lines) => {
|
|
81
|
+
var _a;
|
|
82
|
+
const subtotal = (_a = calculateCompareAtPrice(variant)) === null || _a === void 0 ? void 0 : _a.amount;
|
|
83
|
+
const salesAmount = getSalesAmount(lines);
|
|
84
|
+
const discounts = [
|
|
85
|
+
{
|
|
86
|
+
amount: { currencyCode: "USD", amount: 5.0 },
|
|
87
|
+
title: "WELCOME20",
|
|
88
|
+
valueType: "percentage",
|
|
89
|
+
value: 15,
|
|
90
|
+
applicationType: "code",
|
|
91
|
+
},
|
|
92
|
+
];
|
|
93
|
+
const taxes = { amount: 5.0, currencyCode: "USD" };
|
|
94
|
+
const shipping = { amount: 0, currencyCode: "USD" };
|
|
95
|
+
const total = {
|
|
96
|
+
amount: subtotal -
|
|
97
|
+
salesAmount -
|
|
98
|
+
discounts[0].amount.amount -
|
|
99
|
+
20 + // Payment method amount
|
|
100
|
+
taxes.amount,
|
|
101
|
+
currencyCode: "USD",
|
|
102
|
+
};
|
|
103
|
+
return { subtotal, salesAmount, discounts, taxes, shipping, total };
|
|
104
|
+
};
|
|
105
|
+
const updateOrderDetails = (orderDetails, products) => {
|
|
106
|
+
const product = products[0];
|
|
107
|
+
const variant = product.variants[0];
|
|
108
|
+
const compareAtPrice = calculateCompareAtPrice(variant);
|
|
109
|
+
orderDetails.paymentMethods = createPaymentMethods();
|
|
110
|
+
orderDetails.cart = {
|
|
111
|
+
lines: createCartLines(product, variant, compareAtPrice),
|
|
112
|
+
};
|
|
113
|
+
orderDetails.cart.price = calculateCartPrice(variant, orderDetails.cart.lines);
|
|
114
|
+
};
|
|
115
|
+
export function useOrderDetails({ variables, apiUrl, appId, language, country, mock = false, }) {
|
|
116
|
+
const [orderDetails, setOrderDetails] = useState({});
|
|
117
|
+
const { products } = useProducts({
|
|
118
|
+
productIds: useMemo(() => { var _a, _b; return (!mock ? getProductIds((_b = (_a = variables === null || variables === void 0 ? void 0 : variables.orderDetails) === null || _a === void 0 ? void 0 : _a.cart) === null || _b === void 0 ? void 0 : _b.lines) : []); }, [mock, variables]),
|
|
119
|
+
productHandles: [],
|
|
120
|
+
baseURL: apiUrl,
|
|
121
|
+
queryVariables: {
|
|
122
|
+
language,
|
|
123
|
+
country,
|
|
124
|
+
appId,
|
|
125
|
+
},
|
|
126
|
+
mock,
|
|
127
|
+
});
|
|
128
|
+
useEffect(() => {
|
|
129
|
+
var _a, _b, _c, _d;
|
|
130
|
+
if (products.length > 0) {
|
|
131
|
+
const updatedOrderDetails = Object.assign({}, variables === null || variables === void 0 ? void 0 : variables.orderDetails);
|
|
132
|
+
if (mock) {
|
|
133
|
+
updateOrderDetails(updatedOrderDetails, products);
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
(_b = (_a = updatedOrderDetails === null || updatedOrderDetails === void 0 ? void 0 : updatedOrderDetails.cart) === null || _a === void 0 ? void 0 : _a.lines) === null || _b === void 0 ? void 0 : _b.forEach((line) => updateLineDetails(line, products, variables.checkoutData));
|
|
137
|
+
updatedOrderDetails.cart.price.salesAmount = getSalesAmount((_c = updatedOrderDetails === null || updatedOrderDetails === void 0 ? void 0 : updatedOrderDetails.cart) === null || _c === void 0 ? void 0 : _c.lines);
|
|
138
|
+
updatedOrderDetails.cart.price.subtotal = getSubtotal((_d = updatedOrderDetails === null || updatedOrderDetails === void 0 ? void 0 : updatedOrderDetails.cart) === null || _d === void 0 ? void 0 : _d.lines);
|
|
139
|
+
}
|
|
140
|
+
setOrderDetails(updatedOrderDetails);
|
|
141
|
+
}
|
|
142
|
+
}, [products, products, mock, variables === null || variables === void 0 ? void 0 : variables.orderDetails]);
|
|
143
|
+
return {
|
|
144
|
+
orderDetails,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
3
|
-
declare const Switch: React.ForwardRefExoticComponent<Omit<SwitchPrimitives.SwitchProps & React.RefAttributes<HTMLButtonElement>, "ref"> &
|
|
3
|
+
declare const Switch: React.ForwardRefExoticComponent<Omit<SwitchPrimitives.SwitchProps & React.RefAttributes<HTMLButtonElement>, "ref"> & {
|
|
4
|
+
thumbProps?: Omit<SwitchPrimitives.SwitchThumbProps & React.RefAttributes<HTMLSpanElement>, "ref"> | undefined;
|
|
5
|
+
} & React.RefAttributes<HTMLButtonElement>>;
|
|
4
6
|
export { Switch };
|
|
5
7
|
//# sourceMappingURL=switch.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../components/ui/switch.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAA;AAI1D,QAAA,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"switch.d.ts","sourceRoot":"","sources":["../../../components/ui/switch.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,gBAAgB,MAAM,wBAAwB,CAAA;AAI1D,QAAA,MAAM,MAAM;;2CAsBV,CAAA;AAGF,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -15,8 +15,8 @@ import * as React from "react";
|
|
|
15
15
|
import * as SwitchPrimitives from "@radix-ui/react-switch";
|
|
16
16
|
import { cn } from "../../lib/utils";
|
|
17
17
|
const Switch = React.forwardRef((_a, ref) => {
|
|
18
|
-
var { className, onClick } = _a, props = __rest(_a, ["className", "onClick"]);
|
|
19
|
-
return (_jsx(SwitchPrimitives.Root, Object.assign({ onClick: onClick, className: cn("peer inline-flex h-8 w-14 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-stateColors-success data-[state=unchecked]:bg-stateColors-disabled", className) }, props, { ref: ref }, { children: _jsx(SwitchPrimitives.Thumb, { className: cn("pointer-events-none block h-7 w-7 rounded-full bg-coreColors-pageColor drop-shadow-[0_3px_1px_0_rgba(0,0,0,1)] ring-0 transition-transform data-[state=checked]:translate-x-6 data-[state=unchecked]:translate-x-0") }) })));
|
|
18
|
+
var { className, onClick, thumbProps = {} } = _a, props = __rest(_a, ["className", "onClick", "thumbProps"]);
|
|
19
|
+
return (_jsx(SwitchPrimitives.Root, Object.assign({ onClick: onClick, className: cn("peer inline-flex h-8 w-14 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-stateColors-success data-[state=unchecked]:bg-stateColors-disabled", className) }, props, { ref: ref }, { children: _jsx(SwitchPrimitives.Thumb, Object.assign({ className: cn("pointer-events-none block h-7 w-7 rounded-full bg-coreColors-pageColor drop-shadow-[0_3px_1px_0_rgba(0,0,0,1)] ring-0 transition-transform data-[state=checked]:translate-x-6 data-[state=unchecked]:translate-x-0") }, thumbProps)) })));
|
|
20
20
|
});
|
|
21
21
|
Switch.displayName = SwitchPrimitives.Root.displayName;
|
|
22
22
|
export { Switch };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, createCollectionImageMap, isFavoriteIntegrationEnabled, getSpaceBetween, getGridSpacing, } from "./lib/utils";
|
|
1
|
+
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, createCollectionImageMap, isFavoriteIntegrationEnabled, getSpaceBetween, getGridSpacing, pluralize, } from "./lib/utils";
|
|
2
2
|
export * from "./components/contexts/translation-context";
|
|
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
|
+
export * from "./components/hooks/use-order-details";
|
|
7
8
|
export * from "./components/hooks/use-scroll-direction";
|
|
8
9
|
export * from "./components/hooks/use-sort-filter";
|
|
9
10
|
export * from "./components/hooks/use-product-options";
|
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,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,eAAe,EACf,cAAc,
|
|
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,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,eAAe,EACf,cAAc,EACd,SAAS,GACV,MAAM,aAAa,CAAA;AACpB,cAAc,2CAA2C,CAAA;AACzD,cAAc,mCAAmC,CAAA;AACjD,cAAc,wCAAwC,CAAA;AACtD,cAAc,wCAAwC,CAAA;AACtD,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sCAAsC,CAAA;AACpD,cAAc,yCAAyC,CAAA;AACvD,cAAc,oCAAoC,CAAA;AAClD,cAAc,wCAAwC,CAAA;AACtD,cAAc,6BAA6B,CAAA;AAC3C,cAAc,sCAAsC,CAAA;AACpD,cAAc,2BAA2B,CAAA;AACzC,cAAc,8BAA8B,CAAA;AAC5C,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C,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,aAAa,CAAA;AAC3B,cAAc,6CAA6C,CAAA;AAC3D,cAAc,kDAAkD,CAAA;AAChE,cAAc,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// component exports
|
|
2
|
-
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, createCollectionImageMap, isFavoriteIntegrationEnabled, getSpaceBetween, getGridSpacing, } from "./lib/utils";
|
|
2
|
+
export { cn, cva, getColor, getBackgroundAndPaddingStyle, getBorderSidesStyle, getTextStyle, getVerticalAlignmentStyle, getBackgroundAndSpacingStyle, getIdFromGid, productGidFromId, variantGidFromId, getPaddingStyle, getMarginStyle, getVerticalAlignment, mapFlexToAlignment, formatRelativeTime, stringRatioToInt, getOverlayStyle, throttleFunction, getDestinationHandler, getProductGidsFromIds, createCollectionImageMap, isFavoriteIntegrationEnabled, getSpaceBetween, getGridSpacing, pluralize, } from "./lib/utils";
|
|
3
3
|
export * from "./components/contexts/translation-context";
|
|
4
4
|
export * from "./components/hooks/use-collection";
|
|
5
5
|
export * from "./components/hooks/use-infinite-scroll";
|
|
6
6
|
export * from "./components/hooks/use-recommendations";
|
|
7
7
|
export * from "./components/hooks/use-products";
|
|
8
|
+
export * from "./components/hooks/use-order-details";
|
|
8
9
|
export * from "./components/hooks/use-scroll-direction";
|
|
9
10
|
export * from "./components/hooks/use-sort-filter";
|
|
10
11
|
export * from "./components/hooks/use-product-options";
|
package/dist/lib/utils.d.ts
CHANGED
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,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAA;AAMvC,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,UAEzC;AAED,eAAO,MAAM,eAAe,UAc3B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAA;AAMjE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAA;AAI9C,eAAO,MAAM,QAAQ,gBAAiB,KAAK,GAAG,SAAS,uBAUtD,CAAA;AAED,KAAK,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAC7D,KAAK,WAAW,GAAG,UAAU,EAAE,CAAA;AAE/B,eAAO,MAAM,mBAAmB;;;;;;;;;;;;CAU/B,CAAA;AAED,KAAK,iBAAiB,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEpD,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,UAAU,mBAAmB;IAC3B,SAAS,EAAE,iBAAiB,CAAA;IAC5B,OAAO,EAAE,OAAO,CAAA;CACjB;AAED,eAAO,MAAM,yBAAyB,wBACf,mBAAmB;;;;;;;;;;;;CAcz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;CACxD,CAAA;AAmBD,eAAO,MAAM,qBAAqB,SAC1B,YAAY,GAAG,KAAK,GAAG,SAAS,GAAG,YAAY,GAAG,MAAM,iBAjBrC,MAAM,WAAW,kBAAkB,yBAE5C,MAAM,WAAW,kBAAkB,yBAO/B,MAAM,WAAW,kBAAkB,yBAEhC,MAAM,WAAW,kBAAkB,yBAS3D,CAAA;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,YAOlD;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;AAED,eAAO,MAAM,4BAA4B,yCAOxC,CAAA;AAED,eAAO,MAAM,SAAS,SACd,MAAM,UACJ,MAAM,cACF,OAAO,WAGpB,CAAA"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { clsx } from "clsx";
|
|
2
|
-
import { twMerge } from "tailwind-merge";
|
|
3
2
|
import dayjs from "dayjs";
|
|
4
3
|
import relativeTime from "dayjs/plugin/relativeTime";
|
|
4
|
+
import { twMerge } from "tailwind-merge";
|
|
5
5
|
import Pluralize from "pluralize";
|
|
6
6
|
export function cn(...inputs) {
|
|
7
7
|
return twMerge(clsx(inputs));
|
|
@@ -65,7 +65,10 @@ export const getSpaceBetween = (gap) => {
|
|
|
65
65
|
return { gap: `${gap}px` };
|
|
66
66
|
};
|
|
67
67
|
export const getGridSpacing = (spacing) => {
|
|
68
|
-
return {
|
|
68
|
+
return {
|
|
69
|
+
columnGap: `${spacing.horizontalGap}px`,
|
|
70
|
+
rowGap: `${spacing.verticalGap}px`,
|
|
71
|
+
};
|
|
69
72
|
};
|
|
70
73
|
export const getPaddingStyle = (padding) => {
|
|
71
74
|
if (!padding)
|
|
@@ -239,7 +242,9 @@ export const createCollectionImageMap = (collections) => {
|
|
|
239
242
|
}, {});
|
|
240
243
|
};
|
|
241
244
|
export const isFavoriteIntegrationEnabled = (integrations) => {
|
|
242
|
-
return integrations.some(integration => (integration.name === "tapcart-wishlist" ||
|
|
245
|
+
return integrations.some((integration) => (integration.name === "tapcart-wishlist" ||
|
|
246
|
+
integration.name === "swym") &&
|
|
247
|
+
integration.enabled);
|
|
243
248
|
};
|
|
244
249
|
export const pluralize = (word, count, inclusive) => {
|
|
245
250
|
return Pluralize(word, count, inclusive);
|
package/dist/styles.css
CHANGED
|
@@ -909,6 +909,9 @@ video {
|
|
|
909
909
|
.hidden {
|
|
910
910
|
display: none;
|
|
911
911
|
}
|
|
912
|
+
.aspect-\[2\/3\] {
|
|
913
|
+
aspect-ratio: 2/3;
|
|
914
|
+
}
|
|
912
915
|
.aspect-productImages {
|
|
913
916
|
aspect-ratio: var(--productImage-aspectRatio);
|
|
914
917
|
}
|
|
@@ -1026,6 +1029,9 @@ video {
|
|
|
1026
1029
|
.w-1\/3 {
|
|
1027
1030
|
width: 33.333333%;
|
|
1028
1031
|
}
|
|
1032
|
+
.w-1\/4 {
|
|
1033
|
+
width: 25%;
|
|
1034
|
+
}
|
|
1029
1035
|
.w-10 {
|
|
1030
1036
|
width: 2.5rem;
|
|
1031
1037
|
}
|
|
@@ -1047,6 +1053,12 @@ video {
|
|
|
1047
1053
|
.w-2\/3 {
|
|
1048
1054
|
width: 66.666667%;
|
|
1049
1055
|
}
|
|
1056
|
+
.w-2\/5 {
|
|
1057
|
+
width: 40%;
|
|
1058
|
+
}
|
|
1059
|
+
.w-3\/4 {
|
|
1060
|
+
width: 75%;
|
|
1061
|
+
}
|
|
1050
1062
|
.w-4 {
|
|
1051
1063
|
width: 1rem;
|
|
1052
1064
|
}
|