@tapcart/mobile-components 0.8.10 → 0.8.12

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.
@@ -1 +1 @@
1
- {"version":3,"file":"drawer.d.ts","sourceRoot":"","sources":["../../../components/ui/drawer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,MAAM,IAAI,eAAe,EAAE,MAAM,MAAM,CAAA;AAKhD,KAAK,kBAAkB,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,GAAG;IACnE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,WAAW,CAAA;CAC3B,CAAA;AAED,KAAK,gBAAgB,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,GAAG;IACjE,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,QAAA,MAAM,aAAa,8BAA0D,CAAA;AAG7E,QAAA,MAAM,YAAY;iCAAgC,iBAAiB;;CAgBlE,CAAA;AAGD,QAAA,MAAM,WAAW,4BAAsD,CAAA;AAGvE,KAAK,WAAW,GAAG,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,IAAI,CAAC,GAAG;IACrE,YAAY,CAAC,EAAE,WAAW,CAAA;CAC3B,CAAA;AAED,QAAA,MAAM,MAAM;0CAAyC,WAAW;;CAS/D,CAAA;AAOD,QAAA,MAAM,aAAa;;wCAYlB,CAAA;AAWD,QAAA,MAAM,iBAAiB;;;;;;wCA0CtB,CAAA;AA0BD,QAAA,MAAM,YAAY;8BAGf,MAAM,cAAc,CAAC,cAAc,CAAC;;CAQtC,CAAA;AAGD,QAAA,MAAM,iBAAiB,qLASrB,CAAA;AAGF,KAAK,iBAAiB,GAAG;IACvB,YAAY,CAA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W,CAAA;CAC3B,CAAA;AAED,QAAA,MAAM,MAAM;0CAAyC,WAAW;;CAS/D,CAAA;AAOD,QAAA,MAAM,aAAa;;wCAYlB,CAAA;AAWD,QAAA,MAAM,iBAAiB;;;;;;wCA2CtB,CAAA;AA0BD,QAAA,MAAM,YAAY;8BAGf,MAAM,cAAc,CAAC,cAAc,CAAC;;CAQtC,CAAA;AAGD,QAAA,MAAM,iBAAiB,qLASrB,CAAA;AAGF,KAAK,iBAAiB,GAAG;IACvB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAA;CACjD,CAAA;AAED,QAAA,MAAM,YAAY,0DAKf,iBAAiB,4CA8BnB,CAAA;AAED,QAAA,MAAM,aAAa,sCAIhB,MAAM,cAAc,CAAC,cAAc,CAAC,4CAMtC,CAAA;AAED,OAAO,EACL,MAAM,EACN,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,YAAY,GACb,CAAA"}
@@ -47,11 +47,11 @@ const DrawerOverlay = React.forwardRef((_a, ref) => {
47
47
  });
48
48
  DrawerOverlay.displayName = "DrawerOverlay";
49
49
  const DrawerContentBase = React.forwardRef((_a, ref) => {
50
- var { className, children, hideBackdrop = false, backdropHexColor, isSheet = false, onAnimationEnd, containerRef, maxHeight } = _a, props = __rest(_a, ["className", "children", "hideBackdrop", "backdropHexColor", "isSheet", "onAnimationEnd", "containerRef", "maxHeight"]);
51
- const styles = isSheet
50
+ var { className, children, hideBackdrop = false, backdropHexColor, isSheet = false, onAnimationEnd, containerRef, maxHeight, style } = _a, props = __rest(_a, ["className", "children", "hideBackdrop", "backdropHexColor", "isSheet", "onAnimationEnd", "containerRef", "maxHeight", "style"]);
51
+ const baseStyles = isSheet
52
52
  ? { height: "calc(100dvh - 112px)" }
53
53
  : { maxHeight: maxHeight || "calc(100dvh - 112px)" };
54
- return (_jsxs(DrawerPortal, Object.assign({ containerRef: containerRef }, { children: [hideBackdrop ? null : (_jsx(DrawerOverlay, { backdropHexColor: backdropHexColor })), _jsxs(DrawerPrimitive.Content, Object.assign({ ref: ref, style: styles, className: cn("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-2xl bg-coreColors-modalBackground", className) }, props, { "data-testid": "drawer-content" }, { children: [_jsx("div", { className: "mx-auto mb-2 mt-2 h-[4px] w-[40px] rounded-full bg-coreColors-dividingLines" }), children] }))] })));
54
+ return (_jsxs(DrawerPortal, Object.assign({ containerRef: containerRef }, { children: [hideBackdrop ? null : (_jsx(DrawerOverlay, { backdropHexColor: backdropHexColor })), _jsxs(DrawerPrimitive.Content, Object.assign({ ref: ref, style: Object.assign(Object.assign({}, baseStyles), style), className: cn("fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-2xl bg-coreColors-modalBackground", className) }, props, { "data-testid": "drawer-content" }, { children: [_jsx("div", { className: "mx-auto mb-2 mt-2 h-[4px] w-[40px] rounded-full bg-coreColors-dividingLines" }), children] }))] })));
55
55
  });
56
56
  DrawerContentBase.displayName = "DrawerContentBase";
57
57
  const DrawerHeaderBase = (_a) => {
@@ -66,7 +66,7 @@ function ImagePreload({ imgAttributes }) {
66
66
  */
67
67
  export const Image = React.forwardRef((_a, ref) => {
68
68
  var _b, _c;
69
- var { alt, aspectRatio, crop = "center", data, decoding = "async", height = "auto", loader = shopifyLoader, loading = "lazy", sizes, src, imageWrapperStyles, imageRadius, srcSetOptions = {
69
+ var { alt, aspectRatio, crop = "center", data, decoding = "async", height = "auto", loader = shopifyLoader, loading = "eager", sizes, src, imageWrapperStyles, imageRadius, srcSetOptions = {
70
70
  intervals: 15,
71
71
  startingWidth: 100,
72
72
  incrementSize: 100,
@@ -145,7 +145,7 @@ const getTotalDiscountedPrice = (totalCompareAtPrice, discountsTotalAmount, sale
145
145
  (giftCardsTotalAmount === undefined || isNaN(giftCardsTotalAmount)
146
146
  ? 0
147
147
  : giftCardsTotalAmount);
148
- return isNaN(total) ? 0 : total;
148
+ return isNaN(total) ? 0 : Math.max(0, total);
149
149
  };
150
150
  const getTotalSavedAmount = (cart) => {
151
151
  const salesAmount = getSalesAmount(cart);
@@ -147,5 +147,78 @@ describe("cart-provider.util", () => {
147
147
  // 100 (compare) - 10 (discount) - 20 (sale) - 5 (gift card) = 65
148
148
  expect(result.totalDiscountedPrice).toBe(125);
149
149
  });
150
+ it("should never return negative or NaN values for totalDiscountedPrice", () => {
151
+ // Test case 1: Normal case with valid data
152
+ const normalCart = Object.assign(Object.assign({}, baseCartData), { items: [
153
+ {
154
+ id: "line1",
155
+ quantity: 1,
156
+ productId: "prod1",
157
+ variantId: "var1",
158
+ productDetails: {},
159
+ variantDetails: {
160
+ compareAtPrice: { amount: "100.00", currencyCode: "USD" },
161
+ price: { amount: "80.00", currencyCode: "USD" },
162
+ },
163
+ discounts: [],
164
+ cost: { totalAmount: { amount: "80.00", currencyCode: "USD" } },
165
+ },
166
+ ] });
167
+ let result = getCalculatedCartData(normalCart);
168
+ expect(result.totalDiscountedPrice).not.toBeLessThan(0);
169
+ expect(isNaN(result.totalDiscountedPrice)).toBe(false);
170
+ // Test case 2: Edge case with extreme discounts that exceed item price
171
+ const extremeDiscountCart = Object.assign(Object.assign({}, baseCartData), { items: [
172
+ {
173
+ id: "line1",
174
+ quantity: 1,
175
+ productId: "prod1",
176
+ variantId: "var1",
177
+ productDetails: {},
178
+ variantDetails: {
179
+ compareAtPrice: { amount: "50.00", currencyCode: "USD" },
180
+ price: { amount: "20.00", currencyCode: "USD" },
181
+ },
182
+ discounts: [
183
+ {
184
+ amount: 100,
185
+ type: "LINE_ITEM",
186
+ code: "HUGE_DISCOUNT",
187
+ },
188
+ ],
189
+ cost: { totalAmount: { amount: "20.00", currencyCode: "USD" } },
190
+ },
191
+ ], discountAllocations: [
192
+ {
193
+ targetType: DiscountApplicationTargetType.LineItem,
194
+ discountedAmount: { amount: "100.00", currencyCode: "USD" },
195
+ code: "HUGE_DISCOUNT",
196
+ },
197
+ ] });
198
+ result = getCalculatedCartData(extremeDiscountCart);
199
+ expect(result.totalDiscountedPrice).not.toBeLessThan(0);
200
+ expect(isNaN(result.totalDiscountedPrice)).toBe(false);
201
+ // Test case 3: Edge case with missing price data
202
+ const missingDataCart = Object.assign(Object.assign({}, baseCartData), { items: [
203
+ {
204
+ id: "line1",
205
+ quantity: 1,
206
+ productId: "prod1",
207
+ variantId: "var1",
208
+ productDetails: {},
209
+ variantDetails: {
210
+ compareAtPrice: { amount: "", currencyCode: "USD" },
211
+ price: { amount: null, currencyCode: "USD" }, // Null amount
212
+ },
213
+ discounts: [],
214
+ cost: {
215
+ totalAmount: { amount: undefined, currencyCode: "USD" },
216
+ },
217
+ },
218
+ ] });
219
+ result = getCalculatedCartData(missingDataCart);
220
+ expect(result.totalDiscountedPrice).not.toBeLessThan(0);
221
+ expect(isNaN(result.totalDiscountedPrice)).toBe(false);
222
+ });
150
223
  });
151
224
  });
package/dist/styles.css CHANGED
@@ -980,6 +980,9 @@ video {
980
980
  .h-2\.5 {
981
981
  height: 0.625rem;
982
982
  }
983
+ .h-20 {
984
+ height: 5rem;
985
+ }
983
986
  .h-24 {
984
987
  height: 6rem;
985
988
  }
@@ -1013,6 +1016,9 @@ video {
1013
1016
  .h-\[1px\] {
1014
1017
  height: 1px;
1015
1018
  }
1019
+ .h-\[20vh\] {
1020
+ height: 20vh;
1021
+ }
1016
1022
  .h-\[22px\] {
1017
1023
  height: 22px;
1018
1024
  }
@@ -1088,6 +1094,9 @@ video {
1088
1094
  .w-2\/5 {
1089
1095
  width: 40%;
1090
1096
  }
1097
+ .w-20 {
1098
+ width: 5rem;
1099
+ }
1091
1100
  .w-3\/4 {
1092
1101
  width: 75%;
1093
1102
  }
@@ -1118,6 +1127,9 @@ video {
1118
1127
  .w-\[40px\] {
1119
1128
  width: 40px;
1120
1129
  }
1130
+ .w-\[54px\] {
1131
+ width: 54px;
1132
+ }
1121
1133
  .w-auto {
1122
1134
  width: auto;
1123
1135
  }
@@ -1390,6 +1402,9 @@ video {
1390
1402
  .gap-2 {
1391
1403
  gap: 0.5rem;
1392
1404
  }
1405
+ .gap-2\.5 {
1406
+ gap: 0.625rem;
1407
+ }
1393
1408
  .gap-4 {
1394
1409
  gap: 1rem;
1395
1410
  }
@@ -1443,6 +1458,9 @@ video {
1443
1458
  .self-start {
1444
1459
  align-self: flex-start;
1445
1460
  }
1461
+ .self-end {
1462
+ align-self: flex-end;
1463
+ }
1446
1464
  .self-center {
1447
1465
  align-self: center;
1448
1466
  }
@@ -1810,6 +1828,9 @@ video {
1810
1828
  .pl-2 {
1811
1829
  padding-left: 0.5rem;
1812
1830
  }
1831
+ .pl-3 {
1832
+ padding-left: 0.75rem;
1833
+ }
1813
1834
  .pl-4 {
1814
1835
  padding-left: 1rem;
1815
1836
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.8.10",
3
+ "version": "0.8.12",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",