@tapcart/mobile-components 0.8.61 → 0.8.62
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 +4 -0
- package/dist/components/hooks/use-order-details.d.ts.map +1 -1
- package/dist/components/hooks/use-order-details.js +192 -8
- package/dist/components/libs/cache/ProductsLocalStorage.d.ts +1 -0
- package/dist/components/libs/cache/ProductsLocalStorage.d.ts.map +1 -1
- package/dist/components/libs/cache/ProductsLocalStorage.js +26 -2
- package/dist/components/ui/chip.d.ts +2 -0
- package/dist/components/ui/chip.d.ts.map +1 -1
- package/dist/components/ui/chip.js +11 -6
- package/dist/components/ui/quantity-pickerNEW.d.ts.map +1 -1
- package/dist/components/ui/quantity-pickerNEW.js +2 -4
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +2 -1
- package/dist/lib/variablesCart.util.d.ts.map +1 -1
- package/dist/lib/variablesCart.util.js +18 -8
- package/dist/lib/variablesCart.util.test.js +24 -0
- package/dist/styles.css +40 -0
- package/package.json +1 -1
|
@@ -9,6 +9,10 @@ type UseOrderDetailsProps = {
|
|
|
9
9
|
type UseProductsReturn = {
|
|
10
10
|
orderDetails: Record<string, any>;
|
|
11
11
|
};
|
|
12
|
+
export declare const transformOrderDetails: (order: Record<string, any>) => {
|
|
13
|
+
orderDetails: Record<string, any>;
|
|
14
|
+
checkoutData: Record<string, any>;
|
|
15
|
+
};
|
|
12
16
|
export declare function useOrderDetails({ variables, apiUrl, appId, language, country, mock, }: UseOrderDetailsProps): UseProductsReturn;
|
|
13
17
|
export {};
|
|
14
18
|
//# sourceMappingURL=use-order-details.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-order-details.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-order-details.ts"],"names":[],"mappings":"AAKA,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;
|
|
1
|
+
{"version":3,"file":"use-order-details.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-order-details.ts"],"names":[],"mappings":"AAKA,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;AAwLD,eAAO,MAAM,qBAAqB,UACzB,OAAO,MAAM,EAAE,GAAG,CAAC;kBACT,OAAO,MAAM,EAAE,GAAG,CAAC;kBAAgB,OAAO,MAAM,EAAE,GAAG,CAAC;CAuNxE,CAAA;AAED,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAY,GACb,EAAE,oBAAoB,GAAG,iBAAiB,CA4D1C"}
|
|
@@ -135,10 +135,189 @@ const updateLineDetails = (line, product) => {
|
|
|
135
135
|
line.sellingPlan = (_k = (_j = product.sellingPlanAllocation) === null || _j === void 0 ? void 0 : _j.sellingPlan) === null || _k === void 0 ? void 0 : _k.name;
|
|
136
136
|
line.variantName = (_l = product.variant) === null || _l === void 0 ? void 0 : _l.title;
|
|
137
137
|
};
|
|
138
|
+
export const transformOrderDetails = (order) => {
|
|
139
|
+
var _a;
|
|
140
|
+
// Helper function to safely parse amounts
|
|
141
|
+
const parseAmount = (amount) => {
|
|
142
|
+
if (typeof amount === "number")
|
|
143
|
+
return amount;
|
|
144
|
+
if (typeof amount === "string")
|
|
145
|
+
return parseFloat(amount) || 0;
|
|
146
|
+
return 0;
|
|
147
|
+
};
|
|
148
|
+
// Transform line items to cart lines
|
|
149
|
+
const cartLines = (order.lineItems || []).map((lineItem) => {
|
|
150
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
|
|
151
|
+
const variant = lineItem.variant || {};
|
|
152
|
+
const product = variant.product || {};
|
|
153
|
+
return {
|
|
154
|
+
image: {
|
|
155
|
+
lg: ((_a = variant.image) === null || _a === void 0 ? void 0 : _a.url) || ((_b = lineItem.image) === null || _b === void 0 ? void 0 : _b.url),
|
|
156
|
+
altText: ((_c = variant.image) === null || _c === void 0 ? void 0 : _c.altText) || ((_d = lineItem.image) === null || _d === void 0 ? void 0 : _d.altText),
|
|
157
|
+
},
|
|
158
|
+
discounts: (lineItem.discountAllocations || []).map((allocation) => {
|
|
159
|
+
var _a, _b, _c, _d, _e;
|
|
160
|
+
return ({
|
|
161
|
+
amount: allocation.allocatedAmount || {
|
|
162
|
+
amount: 0,
|
|
163
|
+
currencyCode: ((_a = lineItem.originalTotalPrice) === null || _a === void 0 ? void 0 : _a.currencyCode) ||
|
|
164
|
+
order.currency ||
|
|
165
|
+
"USD",
|
|
166
|
+
},
|
|
167
|
+
title: ((_b = allocation.discountApplication) === null || _b === void 0 ? void 0 : _b.title) || "Discount",
|
|
168
|
+
value: ((_d = (_c = allocation.discountApplication) === null || _c === void 0 ? void 0 : _c.value) === null || _d === void 0 ? void 0 : _d.percentage) || 0,
|
|
169
|
+
valueType: "percentage",
|
|
170
|
+
applicationType: (((_e = allocation.discountApplication) === null || _e === void 0 ? void 0 : _e.type) || "automatic").toLowerCase(),
|
|
171
|
+
});
|
|
172
|
+
}),
|
|
173
|
+
price: {
|
|
174
|
+
amount: parseAmount(((_e = lineItem.discountedTotalPrice) === null || _e === void 0 ? void 0 : _e.amount) ||
|
|
175
|
+
((_f = lineItem.finalLinePrice) === null || _f === void 0 ? void 0 : _f.amount)),
|
|
176
|
+
currencyCode: ((_g = lineItem.discountedTotalPrice) === null || _g === void 0 ? void 0 : _g.currencyCode) ||
|
|
177
|
+
((_h = lineItem.finalLinePrice) === null || _h === void 0 ? void 0 : _h.currencyCode) ||
|
|
178
|
+
((_j = lineItem.originalTotalPrice) === null || _j === void 0 ? void 0 : _j.currencyCode) ||
|
|
179
|
+
order.currency ||
|
|
180
|
+
"USD",
|
|
181
|
+
},
|
|
182
|
+
productId: ((_k = variant.product) === null || _k === void 0 ? void 0 : _k.id) || lineItem.productId,
|
|
183
|
+
merchandiseId: variant.id || lineItem.merchandiseId,
|
|
184
|
+
title: lineItem.title || product.title || "Unknown Product",
|
|
185
|
+
quantity: lineItem.quantity || 1,
|
|
186
|
+
uniqueId: crypto.randomUUID(),
|
|
187
|
+
vendor: product.vendor || lineItem.vendor || "Unknown",
|
|
188
|
+
compareAtPrice: {
|
|
189
|
+
amount: parseAmount(((_l = lineItem.originalTotalPrice) === null || _l === void 0 ? void 0 : _l.amount) ||
|
|
190
|
+
((_m = lineItem.compareAtPrice) === null || _m === void 0 ? void 0 : _m.amount)),
|
|
191
|
+
currencyCode: ((_o = lineItem.originalTotalPrice) === null || _o === void 0 ? void 0 : _o.currencyCode) ||
|
|
192
|
+
((_p = lineItem.compareAtPrice) === null || _p === void 0 ? void 0 : _p.currencyCode) ||
|
|
193
|
+
order.currency ||
|
|
194
|
+
"USD",
|
|
195
|
+
},
|
|
196
|
+
variantName: variant.title || lineItem.variantTitle || "Default",
|
|
197
|
+
};
|
|
198
|
+
});
|
|
199
|
+
const orderDetails = {
|
|
200
|
+
paymentMethods: [
|
|
201
|
+
{
|
|
202
|
+
type: "direct",
|
|
203
|
+
details: {
|
|
204
|
+
lastFourDigits: "****",
|
|
205
|
+
brand: "PAYMENT",
|
|
206
|
+
currency: order.currency || order.currencyCode || "USD",
|
|
207
|
+
amount: order.totalAmount || ((_a = order.totalPrice) === null || _a === void 0 ? void 0 : _a.amount) || "0",
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
cart: {
|
|
212
|
+
token: order.id || order.token,
|
|
213
|
+
lines: cartLines,
|
|
214
|
+
price: {
|
|
215
|
+
subtotal: order.subtotalAmount ||
|
|
216
|
+
order.subtotalPrice ||
|
|
217
|
+
order.currentSubtotalPrice,
|
|
218
|
+
orderLevelDiscounts: [],
|
|
219
|
+
shippingLevelDiscounts: [],
|
|
220
|
+
total: order.totalAmount || order.totalPrice || order.currentTotalPrice,
|
|
221
|
+
taxes: order.taxAmount || order.totalTax || order.currentTotalTax,
|
|
222
|
+
shipping: order.shippingAmount ||
|
|
223
|
+
order.totalShippingPrice ||
|
|
224
|
+
order.currentTotalShippingPrice,
|
|
225
|
+
oldShipping: order.shippingAmount ||
|
|
226
|
+
order.totalShippingPrice ||
|
|
227
|
+
order.currentTotalShippingPrice,
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
id: order.id,
|
|
231
|
+
};
|
|
232
|
+
// Helper to wrap price fields as { amount, currencyCode }
|
|
233
|
+
const wrapMoney = (amount, currencyCode) => ({
|
|
234
|
+
amount: typeof amount === "string" ? parseFloat(amount) : amount !== null && amount !== void 0 ? amount : 0,
|
|
235
|
+
currencyCode: currencyCode || order.currency || order.currencyCode || "USD",
|
|
236
|
+
});
|
|
237
|
+
// Transform checkout data (minimal for price/line updates)
|
|
238
|
+
const subtotal = order.subtotalAmount || order.subtotalPrice || order.currentSubtotalPrice;
|
|
239
|
+
const total = order.totalAmount || order.totalPrice || order.currentTotalPrice;
|
|
240
|
+
const taxes = order.taxAmount || order.totalTax || order.currentTotalTax;
|
|
241
|
+
const shipping = order.shippingAmount ||
|
|
242
|
+
order.totalShippingPrice ||
|
|
243
|
+
order.currentTotalShippingPrice;
|
|
244
|
+
const currencyCode = order.currency || order.currencyCode || "USD";
|
|
245
|
+
const checkoutData = {
|
|
246
|
+
shippingLine: {
|
|
247
|
+
price: wrapMoney(shipping, currencyCode),
|
|
248
|
+
},
|
|
249
|
+
discountApplications: (order.discountApplications || []).map((app) => ({
|
|
250
|
+
type: app.type || "AUTOMATIC",
|
|
251
|
+
title: app.title || "Discount",
|
|
252
|
+
allocationMethod: app.allocationMethod || "ACROSS",
|
|
253
|
+
targetType: app.targetType || "LINE_ITEM",
|
|
254
|
+
targetSelection: app.targetSelection || "ALL",
|
|
255
|
+
value: app.value || { percentage: 0 },
|
|
256
|
+
})),
|
|
257
|
+
subtotalPrice: wrapMoney(subtotal, currencyCode),
|
|
258
|
+
lineItems: (order.lineItems || []).map((lineItem) => {
|
|
259
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
260
|
+
const variant = lineItem.variant || {};
|
|
261
|
+
const product = variant.product || {};
|
|
262
|
+
const currencyCode = ((_a = lineItem.discountedTotalPrice) === null || _a === void 0 ? void 0 : _a.currencyCode) ||
|
|
263
|
+
((_b = lineItem.originalTotalPrice) === null || _b === void 0 ? void 0 : _b.currencyCode) ||
|
|
264
|
+
order.currency ||
|
|
265
|
+
order.currencyCode ||
|
|
266
|
+
"USD";
|
|
267
|
+
// Calculate finalLinePrice with full-discount logic
|
|
268
|
+
let finalLinePriceAmount = parseAmount((_d = (_c = lineItem.discountedTotalPrice) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : (_e = lineItem.finalLinePrice) === null || _e === void 0 ? void 0 : _e.amount);
|
|
269
|
+
if (Array.isArray(lineItem.discountAllocations) &&
|
|
270
|
+
lineItem.discountAllocations.length > 0) {
|
|
271
|
+
const totalDiscount = lineItem.discountAllocations.reduce((sum, discount) => { var _a; return sum + parseAmount((_a = discount.allocatedAmount) === null || _a === void 0 ? void 0 : _a.amount); }, 0);
|
|
272
|
+
const original = parseAmount((_f = lineItem.originalTotalPrice) === null || _f === void 0 ? void 0 : _f.amount);
|
|
273
|
+
if (totalDiscount >= original && original > 0) {
|
|
274
|
+
finalLinePriceAmount = 0;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return {
|
|
278
|
+
properties: lineItem.customAttributes || lineItem.properties || [],
|
|
279
|
+
finalLinePrice: wrapMoney(finalLinePriceAmount, currencyCode),
|
|
280
|
+
variant: {
|
|
281
|
+
title: variant.title || lineItem.variantTitle,
|
|
282
|
+
untranslatedTitle: variant.title || lineItem.variantTitle,
|
|
283
|
+
product: {
|
|
284
|
+
type: product.type || "",
|
|
285
|
+
vendor: product.vendor || lineItem.vendor || "Unknown",
|
|
286
|
+
id: ((_g = product.id) === null || _g === void 0 ? void 0 : _g.split("/").pop()) ||
|
|
287
|
+
((_h = lineItem.productId) === null || _h === void 0 ? void 0 : _h.split("/").pop()),
|
|
288
|
+
untranslatedTitle: lineItem.title || product.title,
|
|
289
|
+
title: lineItem.title || product.title,
|
|
290
|
+
url: `/products/${product.handle || ""}`,
|
|
291
|
+
},
|
|
292
|
+
id: ((_j = variant.id) === null || _j === void 0 ? void 0 : _j.split("/").pop()) ||
|
|
293
|
+
((_k = lineItem.variantId) === null || _k === void 0 ? void 0 : _k.split("/").pop()),
|
|
294
|
+
price: wrapMoney(((_l = variant.price) === null || _l === void 0 ? void 0 : _l.amount) || ((_m = lineItem.price) === null || _m === void 0 ? void 0 : _m.amount), currencyCode),
|
|
295
|
+
image: {
|
|
296
|
+
src: ((_o = variant.image) === null || _o === void 0 ? void 0 : _o.url) || ((_p = lineItem.image) === null || _p === void 0 ? void 0 : _p.url),
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
discountAllocations: (lineItem.discountAllocations || []).map((allocation) => {
|
|
300
|
+
var _a, _b;
|
|
301
|
+
return ({
|
|
302
|
+
amount: wrapMoney((_a = allocation.allocatedAmount) === null || _a === void 0 ? void 0 : _a.amount, ((_b = allocation.allocatedAmount) === null || _b === void 0 ? void 0 : _b.currencyCode) || currencyCode),
|
|
303
|
+
discountApplication: allocation.discountApplication || {},
|
|
304
|
+
});
|
|
305
|
+
}),
|
|
306
|
+
quantity: lineItem.quantity || 1,
|
|
307
|
+
title: lineItem.title || product.title,
|
|
308
|
+
id: ((_q = variant.id) === null || _q === void 0 ? void 0 : _q.split("/").pop()) || ((_r = lineItem.variantId) === null || _r === void 0 ? void 0 : _r.split("/").pop()),
|
|
309
|
+
};
|
|
310
|
+
}),
|
|
311
|
+
totalPrice: wrapMoney(total, currencyCode),
|
|
312
|
+
totalTax: wrapMoney(taxes, currencyCode),
|
|
313
|
+
};
|
|
314
|
+
return { orderDetails, checkoutData };
|
|
315
|
+
};
|
|
138
316
|
export function useOrderDetails({ variables, apiUrl, appId, language, country, mock = false, }) {
|
|
139
317
|
const [orderDetails, setOrderDetails] = useState({});
|
|
318
|
+
const orderVariables = useMemo(() => (variables === null || variables === void 0 ? void 0 : variables.order) ? transformOrderDetails(variables.order) : variables, [variables]);
|
|
140
319
|
const { products } = useProducts({
|
|
141
|
-
productIds: useMemo(() => { var _a, _b; return
|
|
320
|
+
productIds: useMemo(() => { var _a, _b; return !mock ? getProductIds((_b = (_a = orderVariables === null || orderVariables === void 0 ? void 0 : orderVariables.orderDetails) === null || _a === void 0 ? void 0 : _a.cart) === null || _b === void 0 ? void 0 : _b.lines) : []; }, [mock, orderVariables]),
|
|
142
321
|
productHandles: [],
|
|
143
322
|
baseURL: apiUrl,
|
|
144
323
|
queryVariables: {
|
|
@@ -151,23 +330,28 @@ export function useOrderDetails({ variables, apiUrl, appId, language, country, m
|
|
|
151
330
|
useEffect(() => {
|
|
152
331
|
var _a, _b;
|
|
153
332
|
if (products.length > 0) {
|
|
154
|
-
const updatedOrderDetails = Object.assign({},
|
|
333
|
+
const updatedOrderDetails = Object.assign({}, orderVariables === null || orderVariables === void 0 ? void 0 : orderVariables.orderDetails);
|
|
155
334
|
if (mock) {
|
|
156
335
|
updateOrderDetails(updatedOrderDetails, products);
|
|
157
336
|
}
|
|
158
337
|
else {
|
|
159
338
|
(_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, index) => {
|
|
160
|
-
if (
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
updateLineDetails(line,
|
|
339
|
+
if (orderVariables.checkoutData &&
|
|
340
|
+
orderVariables.checkoutData.lineItems &&
|
|
341
|
+
orderVariables.checkoutData.lineItems.length > 0) {
|
|
342
|
+
updateLineDetails(line, orderVariables.checkoutData.lineItems[index]);
|
|
164
343
|
}
|
|
165
344
|
});
|
|
166
|
-
updateCartPriceDetails(updatedOrderDetails,
|
|
345
|
+
updateCartPriceDetails(updatedOrderDetails, orderVariables.checkoutData);
|
|
167
346
|
}
|
|
168
347
|
setOrderDetails(updatedOrderDetails);
|
|
169
348
|
}
|
|
170
|
-
}, [
|
|
349
|
+
}, [
|
|
350
|
+
products,
|
|
351
|
+
mock,
|
|
352
|
+
orderVariables === null || orderVariables === void 0 ? void 0 : orderVariables.orderDetails,
|
|
353
|
+
orderVariables === null || orderVariables === void 0 ? void 0 : orderVariables.checkoutData,
|
|
354
|
+
]);
|
|
171
355
|
return {
|
|
172
356
|
orderDetails,
|
|
173
357
|
};
|
|
@@ -36,6 +36,7 @@ export default class ProductsLocalStorage extends AppStudioCache {
|
|
|
36
36
|
} | undefined)[];
|
|
37
37
|
expireCacheData(numNewItems?: number): void;
|
|
38
38
|
clearCache(): void;
|
|
39
|
+
isQuotaExceeded(e: any): any;
|
|
39
40
|
}
|
|
40
41
|
export {};
|
|
41
42
|
//# sourceMappingURL=ProductsLocalStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductsLocalStorage.d.ts","sourceRoot":"","sources":["../../../../components/libs/cache/ProductsLocalStorage.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAE7C,KAAK,aAAa,GAAG;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,cAAc;IAC9D,OAAO,EAAE,MAAM,CAA2B;IAC1C,WAAW,EAAE,MAAM,CAAe;IAElC,aAAa,CAAC,EAAE,EAAE,MAAM;IAIxB,iBAAiB,CAAC,MAAM,EAAE,MAAM;;IAShC,QAAQ,IAAI,aAAa,EAAE;IAiB3B,YAAY,CAAC,EACX,EAAE,EACF,MAAM,GACP,EAAE;QACD,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,GAAG,MAAM,GAAG,IAAI;IAajB,aAAa,CAAC,QAAQ,EAAE;QACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;QACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;KAC1B,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE;IASrB,YAAY,CACV,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EACvC,KAAK,CAAC,EAAE,aAAa,EAAE,EACvB,YAAY,GAAE,OAAc;gBAFT,MAAM;YAAM,MAAM;;
|
|
1
|
+
{"version":3,"file":"ProductsLocalStorage.d.ts","sourceRoot":"","sources":["../../../../components/libs/cache/ProductsLocalStorage.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAE7C,KAAK,aAAa,GAAG;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,cAAc;IAC9D,OAAO,EAAE,MAAM,CAA2B;IAC1C,WAAW,EAAE,MAAM,CAAe;IAElC,aAAa,CAAC,EAAE,EAAE,MAAM;IAIxB,iBAAiB,CAAC,MAAM,EAAE,MAAM;;IAShC,QAAQ,IAAI,aAAa,EAAE;IAiB3B,YAAY,CAAC,EACX,EAAE,EACF,MAAM,GACP,EAAE;QACD,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,GAAG,MAAM,GAAG,IAAI;IAajB,aAAa,CAAC,QAAQ,EAAE;QACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;QACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;KAC1B,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE;IASrB,YAAY,CACV,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EACvC,KAAK,CAAC,EAAE,aAAa,EAAE,EACvB,YAAY,GAAE,OAAc;gBAFT,MAAM;YAAM,MAAM;;IAiEvC,aAAa,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE;;;;IASrD,eAAe,CAAC,WAAW,GAAE,MAAU;IAWvC,UAAU;IAQV,eAAe,CAAC,CAAC,EAAE,GAAG;CASvB"}
|
|
@@ -74,8 +74,25 @@ export default class ProductsLocalStorage extends AppStudioCache {
|
|
|
74
74
|
return Object.assign(Object.assign({}, merged), { [key]: value });
|
|
75
75
|
}, cachedProduct);
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
try {
|
|
78
|
+
localStorage.setItem(this.getIdCacheKey(productToCache.id), JSON.stringify(Object.assign(Object.assign({}, productToCache), { ct: Date.now() })));
|
|
79
|
+
localStorage.setItem(this.getHandleCacheKey(productToCache.handle), productToCache.id);
|
|
80
|
+
}
|
|
81
|
+
catch (err) {
|
|
82
|
+
if (this.isQuotaExceeded(err)) {
|
|
83
|
+
this.expireCacheData(10);
|
|
84
|
+
try {
|
|
85
|
+
localStorage.setItem(this.getIdCacheKey(productToCache.id), JSON.stringify(Object.assign(Object.assign({}, productToCache), { ct: Date.now() })));
|
|
86
|
+
localStorage.setItem(this.getHandleCacheKey(productToCache.handle), productToCache.id);
|
|
87
|
+
}
|
|
88
|
+
catch (err) {
|
|
89
|
+
console.warn("ProductsLocalStorage: quota exceeded, item not cached", err);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
console.error("ProductsLocalStorage: error setting cache item", err);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
79
96
|
return productToCache;
|
|
80
97
|
}
|
|
81
98
|
setCacheItems(items) {
|
|
@@ -102,4 +119,11 @@ export default class ProductsLocalStorage extends AppStudioCache {
|
|
|
102
119
|
localStorage.removeItem(this.getHandleCacheKey(item.handle));
|
|
103
120
|
});
|
|
104
121
|
}
|
|
122
|
+
isQuotaExceeded(e) {
|
|
123
|
+
return (e &&
|
|
124
|
+
(e.code === 22 ||
|
|
125
|
+
e.code === 1014 ||
|
|
126
|
+
e.name === "QuotaExceededError" ||
|
|
127
|
+
e.name === "NS_ERROR_DOM_QUOTA_REACHED"));
|
|
128
|
+
}
|
|
105
129
|
}
|
|
@@ -10,6 +10,7 @@ type ChipProps = React.ComponentPropsWithoutRef<"div"> & VariantProps<typeof chi
|
|
|
10
10
|
iconColor?: string;
|
|
11
11
|
iconPosition?: "left" | "right";
|
|
12
12
|
iconUrl?: string;
|
|
13
|
+
readOnly?: boolean;
|
|
13
14
|
onChipClick?: () => void;
|
|
14
15
|
onIconClick?: () => void;
|
|
15
16
|
loading?: boolean;
|
|
@@ -23,6 +24,7 @@ declare const Chip: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps
|
|
|
23
24
|
iconColor?: string | undefined;
|
|
24
25
|
iconPosition?: "left" | "right" | undefined;
|
|
25
26
|
iconUrl?: string | undefined;
|
|
27
|
+
readOnly?: boolean | undefined;
|
|
26
28
|
onChipClick?: (() => void) | undefined;
|
|
27
29
|
onIconClick?: (() => void) | undefined;
|
|
28
30
|
loading?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chip.d.ts","sourceRoot":"","sources":["../../../components/ui/chip.tsx"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,KAAsC,MAAM,OAAO,CAAA;AAI1D,QAAA,MAAM,YAAY;;;;mFAwBjB,CAAA;AAED,KAAK,SAAS,GAAG,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,GACpD,YAAY,CAAC,OAAO,YAAY,CAAC,GAAG;IAClC,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAEH,QAAA,MAAM,IAAI
|
|
1
|
+
{"version":3,"file":"chip.d.ts","sourceRoot":"","sources":["../../../components/ui/chip.tsx"],"names":[],"mappings":"AACA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAEjE,OAAO,KAAsC,MAAM,OAAO,CAAA;AAI1D,QAAA,MAAM,YAAY;;;;mFAwBjB,CAAA;AAED,KAAK,SAAS,GAAG,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,GACpD,YAAY,CAAC,OAAO,YAAY,CAAC,GAAG;IAClC,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,IAAI,CAAA;IACxB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAEH,QAAA,MAAM,IAAI;;;;;;;;;;yBALc,IAAI;yBACJ,IAAI;;wCAgF3B,CAAA;AAGD,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAA;IACzC,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAC3B,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;CAC9C,CAAA;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAoD/C,CAAA;AAED,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,KAAK,SAAS,EAAE,KAAK,kBAAkB,EAAE,CAAA"}
|
|
@@ -10,7 +10,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
}
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
14
|
import { cva } from "class-variance-authority";
|
|
15
15
|
import { cn } from "../../lib/utils";
|
|
16
16
|
import React, { useState, useEffect } from "react";
|
|
@@ -39,7 +39,7 @@ const chipVariants = cva("inline-flex items-center justify-center rounded border
|
|
|
39
39
|
},
|
|
40
40
|
});
|
|
41
41
|
const Chip = React.forwardRef((_a, ref) => {
|
|
42
|
-
var { className, variant, direction, children, iconPosition, iconColor = "coreColors-secondaryIcon", iconUrl, loading = false, onChipClick, onIconClick } = _a, props = __rest(_a, ["className", "variant", "direction", "children", "iconPosition", "iconColor", "iconUrl", "loading", "onChipClick", "onIconClick"]);
|
|
42
|
+
var { className, variant, direction, children, iconPosition, iconColor = "coreColors-secondaryIcon", iconUrl, readOnly = false, loading = false, onChipClick, onIconClick } = _a, props = __rest(_a, ["className", "variant", "direction", "children", "iconPosition", "iconColor", "iconUrl", "readOnly", "loading", "onChipClick", "onIconClick"]);
|
|
43
43
|
const handleOnClick = () => {
|
|
44
44
|
onChipClick === null || onChipClick === void 0 ? void 0 : onChipClick();
|
|
45
45
|
};
|
|
@@ -47,9 +47,14 @@ const Chip = React.forwardRef((_a, ref) => {
|
|
|
47
47
|
onIconClick === null || onIconClick === void 0 ? void 0 : onIconClick();
|
|
48
48
|
};
|
|
49
49
|
const ChipIcon = ({ className }) => iconUrl ? (_jsx(Icon, { url: iconUrl, size: "xs", color: iconColor, className: className })) : (_jsx(Icon, { name: "square-x-filled", color: iconColor, className: className }));
|
|
50
|
-
return (_jsxs("div", Object.assign({ onClick: loading ? undefined : handleOnClick,
|
|
50
|
+
return (_jsxs("div", Object.assign({ onClick: loading ? undefined : handleOnClick, onKeyDown: (e) => {
|
|
51
|
+
if ((e.key === "Enter" || e.key === " ") && !loading) {
|
|
52
|
+
e.preventDefault();
|
|
53
|
+
handleOnClick();
|
|
54
|
+
}
|
|
55
|
+
}, tabIndex: loading ? -1 : 0, role: "button", ref: ref, className: cn(chipVariants({ variant, direction, iconPosition }), className, {
|
|
51
56
|
relative: loading,
|
|
52
|
-
}) }, props, { children: [iconPosition === "left" && (_jsx("button", Object.assign({ onClick: loading ? undefined : handleIconClick, className: "h-full flex items-center justify-center pl-2" }, { children: _jsx(ChipIcon, { className: "mr-2 h-4 w-4 cursor-pointer" }) }))), children, iconPosition === "right" && (_jsx("button", Object.assign({ onClick: loading ? undefined : handleIconClick, className: "h-full flex items-center justify-center pr-2" }, { children: _jsx(ChipIcon, { className: "ml-2 h-4 w-4 cursor-pointer" }) }))), _jsx(LoadingDots, { show: loading, size: 1, iconColor: iconColor })] })));
|
|
57
|
+
}) }, props, { children: [iconPosition === "left" && !readOnly && (_jsx("button", Object.assign({ onClick: loading ? undefined : handleIconClick, className: "h-full flex items-center justify-center pl-2" }, { children: _jsx(ChipIcon, { className: "mr-2 h-4 w-4 cursor-pointer" }) }))), children, iconPosition === "right" && !readOnly && (_jsx("button", Object.assign({ onClick: loading ? undefined : handleIconClick, className: "h-full flex items-center justify-center pr-2" }, { children: _jsx(ChipIcon, { className: "ml-2 h-4 w-4 cursor-pointer" }) }))), readOnly && _jsx(_Fragment, { children: "\u00A0\u00A0" }), _jsx(LoadingDots, { show: loading, size: 1, iconColor: iconColor })] })));
|
|
53
58
|
});
|
|
54
59
|
Chip.displayName = "Chip";
|
|
55
60
|
const MultipleChips = ({ children, containerRef, style, }) => {
|
|
@@ -65,10 +70,10 @@ const MultipleChips = ({ children, containerRef, style, }) => {
|
|
|
65
70
|
window.addEventListener("resize", handleResize);
|
|
66
71
|
checkOverflow();
|
|
67
72
|
return () => window.removeEventListener("resize", handleResize);
|
|
68
|
-
}, []);
|
|
73
|
+
}, [checkOverflow]);
|
|
69
74
|
useEffect(() => {
|
|
70
75
|
checkOverflow();
|
|
71
|
-
}, [children]);
|
|
76
|
+
}, [children, checkOverflow]);
|
|
72
77
|
return (_jsxs("div", Object.assign({ className: "relative no-scrollbar" }, { children: [_jsx("div", Object.assign({ ref: containerRef, className: "flex overflow-x-auto overflow-y-hidden", onScroll: checkOverflow, style: style }, { children: children.map((chip, index) => (_jsx("div", Object.assign({ className: cn("shrink-0", {
|
|
73
78
|
"mr-2": index < children.length - 1,
|
|
74
79
|
}) }, { children: chip }), index))) })), showFadeLeft && (_jsx("div", { className: "absolute top-0 left-0 w-8 h-full pointer-events-none bg-fade-left" })), showFadeRight && (_jsx("div", { className: "absolute top-0 right-0 w-8 h-full pointer-events-none bg-fade-right" }))] })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quantity-pickerNEW.d.ts","sourceRoot":"","sources":["../../../components/ui/quantity-pickerNEW.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"quantity-pickerNEW.d.ts","sourceRoot":"","sources":["../../../components/ui/quantity-pickerNEW.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAM9B,MAAM,WAAW,sBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IAC5C,eAAe,EAAE,MAAM,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,YAAY,EAAE,OAAO,CAAA;IACrB,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,eAAe,EAAE,KAAK,CAAC,iBAAiB,CAAA;IACxC,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IAC/B,gBAAgB,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;IACrC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAChC,WAAW,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,GAAG,CAAC,EAAE,MAAM,CAAA;CACb;AAwED,QAAA,MAAM,iBAAiB,+FAoLtB,CAAA;AAID,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -14,11 +14,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
14
14
|
import * as React from "react";
|
|
15
15
|
import { cn } from "../../lib/utils";
|
|
16
16
|
import { Icon } from "./icon";
|
|
17
|
-
import { useTap } from "./tap";
|
|
18
17
|
import { LoadingDots } from "./loading-dots";
|
|
19
18
|
import debounce from "lodash/debounce";
|
|
20
19
|
const IconButton = ({ iconUrl, iconColor, handler, className, style, disabled }) => {
|
|
21
|
-
const { onTap, isPressed, ref: tapRef } = useTap();
|
|
22
20
|
const [isButtonPressed, setIsButtonPressed] = React.useState(false);
|
|
23
21
|
// Handle press state manually for the invisible button
|
|
24
22
|
const handleMouseDown = React.useCallback(() => {
|
|
@@ -31,8 +29,8 @@ const IconButton = ({ iconUrl, iconColor, handler, className, style, disabled })
|
|
|
31
29
|
// Calculate the visual styles for the button
|
|
32
30
|
const visualButtonStyle = Object.assign({}, style);
|
|
33
31
|
return (_jsxs("div", Object.assign({ className: "relative h-7 w-7", style: { touchAction: "manipulation" } }, { children: [_jsx("div", Object.assign({ className: cn("absolute inset-0 flex items-center justify-center bg-stateColors-skeleton border border-coreColors-dividingLines", className, disabled ? "opacity-50" : ""), style: visualButtonStyle, "aria-hidden": "true" }, { children: _jsx(Icon, { url: iconUrl, size: "sm", strokeColor: iconColor, strokeWidth: 4, style: {
|
|
34
|
-
opacity:
|
|
35
|
-
} }) })), _jsx("button", { onClick:
|
|
32
|
+
opacity: isButtonPressed ? 0.7 : 1,
|
|
33
|
+
} }) })), _jsx("button", { onClick: handler, onMouseDown: handleMouseDown, onMouseUp: handleMouseUp, onMouseLeave: handleMouseUp, onTouchStart: handleMouseDown, onTouchEnd: handleMouseUp, onTouchCancel: handleMouseUp, className: "absolute cursor-pointer", style: {
|
|
36
34
|
top: "-8px",
|
|
37
35
|
right: "-8px",
|
|
38
36
|
bottom: "-8px",
|
package/dist/lib/utils.d.ts.map
CHAN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AE,EAAE,MAAM,UAGnC;AAED,eAAO,MAAM,wBAAwB,UAAW,yBAAyB,WAOxE,CAAA;AAkHD,KAAK,QAAQ,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA;AAExE,eAAO,MAAM,WAAW;cAMZ,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;CA4DnB,CAAA;AAED,eAAO,MAAM,iBAAiB,QAAS,GAAG,2BAC+B,CAAA;AAEzE,eAAO,MAAM,WAAW,QAAS,GAAG,wCACO,CAAA;AAE3C,eAAO,MAAM,yBAAyB,QAC/B,GAAG,EAAE,6BAGX,CAAA;AAED,eAAO,MAAM,mBAAmB,QACzB,GAAG,EAAE,0CAGX,CAAA;AA6BD,eAAO,MAAM,eAAe,aAChB,yBAAyB,cACvB,yBAAyB,YAoDtC,CAAA;AAGD,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE,GAAG,CAAA;CACX,CAAA;AAED,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE,KAAK,GAAG,IAAI,GAAG,KAAK,CAAA;IAC3B,UAAU,EAAE,CAAC,SAAS,GAAG,UAAU,CAAC,EAAE,CAAA;CACvC,CAAA;AAoDD,eAAO,MAAM,kBAAkB,UACtB,UAAU,WACR,GAAG,KACX,OAyBF,CAAA"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -182,10 +182,11 @@ export const mapFlexToAlignment = (flexClass) => {
|
|
|
182
182
|
return "";
|
|
183
183
|
};
|
|
184
184
|
export function getIdFromGid(gid) {
|
|
185
|
+
var _a;
|
|
185
186
|
if (!gid)
|
|
186
187
|
return "";
|
|
187
188
|
const arr = gid.split("/");
|
|
188
|
-
return arr[arr.length - 1] || "";
|
|
189
|
+
return ((_a = arr[arr.length - 1]) === null || _a === void 0 ? void 0 : _a.split("?")[0]) || "";
|
|
189
190
|
}
|
|
190
191
|
export function productGidFromId(id) {
|
|
191
192
|
if (!id)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"variablesCart.util.d.ts","sourceRoot":"","sources":["../../lib/variablesCart.util.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,6BAA6B,EAO9B,MAAM,kBAAkB,CAAA;AAEzB,eAAO,MAAM,2BAA2B;;cAM5B,MAAM;;0BAEI;YAChB,gBAAgB,CAAC,EAAE,MAAM,CAAA;YACzB,KAAK,EAAE,MAAM,CAAA;YACb,cAAc,CAAC,EAAE,MAAM,CAAA;SACxB,EAAE;;;;;;CAyBN,CAAA;
|
|
1
|
+
{"version":3,"file":"variablesCart.util.d.ts","sourceRoot":"","sources":["../../lib/variablesCart.util.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,sBAAsB,EACtB,6BAA6B,EAO9B,MAAM,kBAAkB,CAAA;AAEzB,eAAO,MAAM,2BAA2B;;cAM5B,MAAM;;0BAEI;YAChB,gBAAgB,CAAC,EAAE,MAAM,CAAA;YACzB,KAAK,EAAE,MAAM,CAAA;YACb,cAAc,CAAC,EAAE,MAAM,CAAA;SACxB,EAAE;;;;;;CAyBN,CAAA;AA4FD,eAAO,MAAM,6BAA6B,SAClC,MAAM,QACN,SAAS,GAAG,IAAI,YAUvB,CAAA;AAED,eAAO,MAAM,2BAA2B,SAChC,MAAM,QACN,SAAS,GAAG,IAAI,YAUvB,CAAA;AAoLD,MAAM,MAAM,uBAAuB,GAAG;IACpC,yBAAyB,EAAE,sBAAsB,EAAE,CAAA;IACnD,gBAAgB,EAAE,6BAA6B,EAAE,CAAA;IACjD,cAAc,EAAE,OAAO,CAAA;IACvB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,WAAW,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,oBAAoB,EAAE,MAAM,CAAA;IAC5B,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,iCAAiC,EAAE,uBAU/C,CAAA;AAED,eAAO,MAAM,8BAA8B,SACnC,SAAS,GAAG,IAAI,KACrB,uBAmCF,CAAA"}
|
|
@@ -32,11 +32,12 @@ const getOrderLevelDiscounts = (cart) => {
|
|
|
32
32
|
const discountAllocations = cart === null || cart === void 0 ? void 0 : cart.discountAllocations;
|
|
33
33
|
if (!discountAllocations)
|
|
34
34
|
return [];
|
|
35
|
+
// We'll build a map of code -> { amount, isAutomatic }
|
|
35
36
|
const discountMap = discountAllocations
|
|
36
37
|
.filter((discount) => discount.targetType !== DiscountApplicationTargetType.ShippingLine)
|
|
37
38
|
.reduce((acc, discount) => {
|
|
38
|
-
var _a, _b, _c, _d, _e, _f;
|
|
39
|
-
//
|
|
39
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
40
|
+
// Figure out the code for this discount
|
|
40
41
|
let code = "unknown";
|
|
41
42
|
if (discount.code) {
|
|
42
43
|
code = ((discount === null || discount === void 0 ? void 0 : discount.code) || "").toUpperCase();
|
|
@@ -44,25 +45,34 @@ const getOrderLevelDiscounts = (cart) => {
|
|
|
44
45
|
else if ((_b = (_a = discount.kind) === null || _a === void 0 ? void 0 : _a.manual) === null || _b === void 0 ? void 0 : _b.code) {
|
|
45
46
|
code = (((_d = (_c = discount === null || discount === void 0 ? void 0 : discount.kind) === null || _c === void 0 ? void 0 : _c.manual) === null || _d === void 0 ? void 0 : _d.code) || "").toUpperCase();
|
|
46
47
|
}
|
|
48
|
+
else if ((_f = (_e = discount.kind) === null || _e === void 0 ? void 0 : _e.automatic) === null || _f === void 0 ? void 0 : _f.title) {
|
|
49
|
+
code = (((_h = (_g = discount === null || discount === void 0 ? void 0 : discount.kind) === null || _g === void 0 ? void 0 : _g.automatic) === null || _h === void 0 ? void 0 : _h.title) || "").toUpperCase();
|
|
50
|
+
}
|
|
51
|
+
// Determine if this discount is automatic
|
|
52
|
+
const isAutomatic = Boolean((_j = discount.kind) === null || _j === void 0 ? void 0 : _j.automatic);
|
|
47
53
|
if (!acc[code]) {
|
|
48
|
-
acc[code] = 0;
|
|
54
|
+
acc[code] = { amount: 0, isAutomatic };
|
|
49
55
|
}
|
|
50
|
-
//
|
|
51
|
-
if ((
|
|
52
|
-
acc[code] += parseFloat(((
|
|
56
|
+
// Add the amount for this discount
|
|
57
|
+
if ((_k = discount.discountedAmount) === null || _k === void 0 ? void 0 : _k.amount) {
|
|
58
|
+
acc[code].amount += parseFloat(((_l = discount === null || discount === void 0 ? void 0 : discount.discountedAmount) === null || _l === void 0 ? void 0 : _l.amount) || "0");
|
|
53
59
|
}
|
|
54
60
|
else if (discount.amount) {
|
|
55
|
-
acc[code] += parseFloat(String(discount.amount));
|
|
61
|
+
acc[code].amount += parseFloat(String(discount.amount));
|
|
56
62
|
}
|
|
63
|
+
// If any instance of this code is automatic, mark it as automatic
|
|
64
|
+
acc[code].isAutomatic = acc[code].isAutomatic || isAutomatic;
|
|
57
65
|
return acc;
|
|
58
66
|
}, {});
|
|
59
67
|
if (!discountMap)
|
|
60
68
|
return [];
|
|
61
|
-
|
|
69
|
+
// Only set readOnly to true if the discount is automatic
|
|
70
|
+
return Object.entries(discountMap).map(([code, { amount, isAutomatic }]) => ({
|
|
62
71
|
id: code,
|
|
63
72
|
amount: amount,
|
|
64
73
|
name: `Discount - ${code}`,
|
|
65
74
|
type: "ORDER_LEVEL",
|
|
75
|
+
readOnly: isAutomatic,
|
|
66
76
|
}));
|
|
67
77
|
};
|
|
68
78
|
const getShippingDiscounts = (cart) => {
|
|
@@ -37,6 +37,30 @@ describe("cart-provider.util", () => {
|
|
|
37
37
|
amount: 10,
|
|
38
38
|
name: "Discount - DISCOUNT10",
|
|
39
39
|
type: "ORDER_LEVEL",
|
|
40
|
+
readOnly: false,
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
it("should calculate readonly discounts correctly", () => {
|
|
44
|
+
const mockCart = Object.assign(Object.assign({}, baseCartData), { discounts: ["DISCOUNT10"], items: [], discountAllocations: [
|
|
45
|
+
{
|
|
46
|
+
targetType: DiscountApplicationTargetType.LineItem,
|
|
47
|
+
discountedAmount: { amount: "10.00", currencyCode: "USD" },
|
|
48
|
+
code: "DISCOUNT10",
|
|
49
|
+
kind: {
|
|
50
|
+
automatic: {
|
|
51
|
+
title: "Discount - DISCOUNT10",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
] });
|
|
56
|
+
const result = getVariablesCalculatedCartData(mockCart);
|
|
57
|
+
expect(result.orderAndLineItemDiscounts).toHaveLength(1);
|
|
58
|
+
expect(result.orderAndLineItemDiscounts[0]).toEqual({
|
|
59
|
+
id: "DISCOUNT10",
|
|
60
|
+
amount: 10,
|
|
61
|
+
name: "Discount - DISCOUNT10",
|
|
62
|
+
type: "ORDER_LEVEL",
|
|
63
|
+
readOnly: true,
|
|
40
64
|
});
|
|
41
65
|
});
|
|
42
66
|
it("should calculate gift cards correctly", () => {
|
package/dist/styles.css
CHANGED
|
@@ -790,6 +790,9 @@ video {
|
|
|
790
790
|
.z-30 {
|
|
791
791
|
z-index: 30;
|
|
792
792
|
}
|
|
793
|
+
.z-40 {
|
|
794
|
+
z-index: 40;
|
|
795
|
+
}
|
|
793
796
|
.z-50 {
|
|
794
797
|
z-index: 50;
|
|
795
798
|
}
|
|
@@ -844,6 +847,10 @@ video {
|
|
|
844
847
|
margin-top: 0.75rem;
|
|
845
848
|
margin-bottom: 0.75rem;
|
|
846
849
|
}
|
|
850
|
+
.my-4 {
|
|
851
|
+
margin-top: 1rem;
|
|
852
|
+
margin-bottom: 1rem;
|
|
853
|
+
}
|
|
847
854
|
.my-auto {
|
|
848
855
|
margin-top: auto;
|
|
849
856
|
margin-bottom: auto;
|
|
@@ -1583,6 +1590,9 @@ video {
|
|
|
1583
1590
|
.rounded-sm {
|
|
1584
1591
|
border-radius: calc(var(--radius) - 4px);
|
|
1585
1592
|
}
|
|
1593
|
+
.rounded-xl {
|
|
1594
|
+
border-radius: 0.75rem;
|
|
1595
|
+
}
|
|
1586
1596
|
.rounded-b-lg {
|
|
1587
1597
|
border-bottom-right-radius: var(--radius);
|
|
1588
1598
|
border-bottom-left-radius: var(--radius);
|
|
@@ -1871,6 +1881,10 @@ video {
|
|
|
1871
1881
|
padding-left: 1.25rem;
|
|
1872
1882
|
padding-right: 1.25rem;
|
|
1873
1883
|
}
|
|
1884
|
+
.px-6 {
|
|
1885
|
+
padding-left: 1.5rem;
|
|
1886
|
+
padding-right: 1.5rem;
|
|
1887
|
+
}
|
|
1874
1888
|
.px-8 {
|
|
1875
1889
|
padding-left: 2rem;
|
|
1876
1890
|
padding-right: 2rem;
|
|
@@ -1883,6 +1897,10 @@ video {
|
|
|
1883
1897
|
padding-top: 0.25rem;
|
|
1884
1898
|
padding-bottom: 0.25rem;
|
|
1885
1899
|
}
|
|
1900
|
+
.py-12 {
|
|
1901
|
+
padding-top: 3rem;
|
|
1902
|
+
padding-bottom: 3rem;
|
|
1903
|
+
}
|
|
1886
1904
|
.py-2 {
|
|
1887
1905
|
padding-top: 0.5rem;
|
|
1888
1906
|
padding-bottom: 0.5rem;
|
|
@@ -2157,6 +2175,10 @@ video {
|
|
|
2157
2175
|
.text-productBadging-text {
|
|
2158
2176
|
color: var(--productBadging-text);
|
|
2159
2177
|
}
|
|
2178
|
+
.text-red-600 {
|
|
2179
|
+
--tw-text-opacity: 1;
|
|
2180
|
+
color: rgb(220 38 38 / var(--tw-text-opacity, 1));
|
|
2181
|
+
}
|
|
2160
2182
|
.text-stateColors-disabled {
|
|
2161
2183
|
color: var(--stateColors-disabled);
|
|
2162
2184
|
}
|
|
@@ -2314,6 +2336,10 @@ video {
|
|
|
2314
2336
|
.ring-offset-background {
|
|
2315
2337
|
--tw-ring-offset-color: hsl(var(--background));
|
|
2316
2338
|
}
|
|
2339
|
+
.blur {
|
|
2340
|
+
--tw-blur: blur(8px);
|
|
2341
|
+
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
2342
|
+
}
|
|
2317
2343
|
.drop-shadow-\[0_3px_1px_0_rgba\(0\2c 0\2c 0\2c 1\)\] {
|
|
2318
2344
|
--tw-drop-shadow: drop-shadow(0 3px 1px 0 rgba(0,0,0,1));
|
|
2319
2345
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
@@ -2321,6 +2347,11 @@ video {
|
|
|
2321
2347
|
.filter {
|
|
2322
2348
|
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
|
2323
2349
|
}
|
|
2350
|
+
.backdrop-blur-md {
|
|
2351
|
+
--tw-backdrop-blur: blur(12px);
|
|
2352
|
+
-webkit-backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
|
|
2353
|
+
backdrop-filter: var(--tw-backdrop-blur) var(--tw-backdrop-brightness) var(--tw-backdrop-contrast) var(--tw-backdrop-grayscale) var(--tw-backdrop-hue-rotate) var(--tw-backdrop-invert) var(--tw-backdrop-opacity) var(--tw-backdrop-saturate) var(--tw-backdrop-sepia);
|
|
2354
|
+
}
|
|
2324
2355
|
.transition {
|
|
2325
2356
|
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, -webkit-backdrop-filter;
|
|
2326
2357
|
transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
|
|
@@ -2583,6 +2614,15 @@ body::-webkit-scrollbar {
|
|
|
2583
2614
|
border-color: var(--coreColors-brandColorPrimary);
|
|
2584
2615
|
}
|
|
2585
2616
|
|
|
2617
|
+
.hover\:bg-gray-100:hover {
|
|
2618
|
+
--tw-bg-opacity: 1;
|
|
2619
|
+
background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
|
|
2620
|
+
}
|
|
2621
|
+
|
|
2622
|
+
.hover\:opacity-90:hover {
|
|
2623
|
+
opacity: 0.9;
|
|
2624
|
+
}
|
|
2625
|
+
|
|
2586
2626
|
.focus\:border-coreColors-brandColorPrimary:focus {
|
|
2587
2627
|
border-color: var(--coreColors-brandColorPrimary);
|
|
2588
2628
|
}
|