@tapcart/mobile-components 0.12.0 → 0.12.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.
@@ -22,6 +22,7 @@ interface ProgressBarProps {
22
22
  start: number;
23
23
  end: number;
24
24
  increment?: number;
25
+ valueFormatter?: (value: number) => string | number;
25
26
  textStyle?: {
26
27
  color?: string;
27
28
  fontSize?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"progress-bar.d.ts","sourceRoot":"","sources":["../../../components/ui/progress-bar.tsx"],"names":[],"mappings":"AACA,OAAO,KAAoD,MAAM,OAAO,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAGhD,UAAU,gBAAgB;IACxB,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,CAAC,EAAE,UAAU,CAAC,OAAO,cAAc,CAAC,CAAA;IAC/C,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,eAAe,CAAC,EAAE,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAA;IACpD;;;;;;;;OAQG;IACH,gBAAgB,CAAC,EAAE;QACjB,KAAK,EAAE,MAAM,CAAA;QACb,GAAG,EAAE,MAAM,CAAA;QAEX,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE;YACV,KAAK,CAAC,EAAE,MAAM,CAAA;YACd,QAAQ,CAAC,EAAE,MAAM,CAAA;YACjB,UAAU,CAAC,EAAE,MAAM,CAAA;SACpB,CAAA;QACD,WAAW,CAAC,EAAE;YACZ,eAAe,CAAC,EAAE,MAAM,CAAA;YACxB,IAAI,CAAC,EAAE,MAAM,CAAA;SACd,CAAA;QACD,cAAc,CAAC,EAAE,OAAO,CAAA;KACzB,C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AgO3C,CAAA;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
@@ -120,12 +120,14 @@ const ProgressBar = ({ progress, borderStyle, emptyColor, corners, fillColor, an
120
120
  // Calculate the marker size for positioning adjustments
121
121
  const markerSize = ((_a = milestoneMarkers === null || milestoneMarkers === void 0 ? void 0 : milestoneMarkers.markerStyle) === null || _a === void 0 ? void 0 : _a.size) || 4;
122
122
  milestonePositions.forEach(({ value, position }) => {
123
+ var _a, _b;
123
124
  const isAnimating = animateMarkers && animatedMarkers.includes(position);
125
+ const markerLabel = (_b = (_a = milestoneMarkers === null || milestoneMarkers === void 0 ? void 0 : milestoneMarkers.valueFormatter) === null || _a === void 0 ? void 0 : _a.call(milestoneMarkers, value)) !== null && _b !== void 0 ? _b : Math.round(value);
124
126
  markers.push(_jsxs("div", Object.assign({ className: "absolute", style: {
125
127
  left: `${position}%`,
126
128
  top: "50%",
127
129
  transform: "translateY(-50%)",
128
- } }, { children: [_jsx("div", { className: "rounded-full bg-gray-300 transform -translate-x-1/2 opacity-50", style: Object.assign({ zIndex: 2, width: `${markerSize}px`, height: `${markerSize}px` }, milestoneMarkers === null || milestoneMarkers === void 0 ? void 0 : milestoneMarkers.markerStyle) }), _jsx("div", Object.assign({ className: "text-xs text-gray-500 transform -translate-x-1/2 transition-all opacity-50", style: Object.assign({ position: "absolute", top: `${height + 8}px`, whiteSpace: "nowrap", transform: "translateX(-50%)", transition: "transform 0.3s ease, font-weight 0.3s ease" }, milestoneMarkers === null || milestoneMarkers === void 0 ? void 0 : milestoneMarkers.textStyle) }, { children: Math.round(value) }))] }), `milestone-${value}`));
130
+ } }, { children: [_jsx("div", { className: "rounded-full bg-gray-300 transform -translate-x-1/2 opacity-50", style: Object.assign({ zIndex: 2, width: `${markerSize}px`, height: `${markerSize}px` }, milestoneMarkers === null || milestoneMarkers === void 0 ? void 0 : milestoneMarkers.markerStyle) }), _jsx("div", Object.assign({ className: "text-xs text-gray-500 transform -translate-x-1/2 transition-all opacity-50", style: Object.assign({ position: "absolute", top: `${height + 8}px`, whiteSpace: "nowrap", transform: "translateX(-50%)", transition: "transform 0.3s ease, font-weight 0.3s ease" }, milestoneMarkers === null || milestoneMarkers === void 0 ? void 0 : milestoneMarkers.textStyle) }, { children: markerLabel }))] }), `milestone-${value}`));
129
131
  });
130
132
  return markers;
131
133
  }, [milestonePositions, milestoneMarkers, animatedMarkers, height]);
@@ -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;AA4FD,eAAO,MAAM,6BAA6B,SAClC,MAAM,QACN,SAAS,GAAG,IAAI,YAUvB,CAAA;AAED,eAAO,MAAM,2BAA2B,SAChC,MAAM,QACN,SAAS,GAAG,IAAI,YAUvB,CAAA;AAqLD,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"}
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;AAoMD,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"}
@@ -139,6 +139,7 @@ const getCompareAtPriceDifference = (cart) => {
139
139
  */
140
140
  let itemPrice = (item === null || item === void 0 ? void 0 : item.price) || 0;
141
141
  let itemCompareAtPrice = (item === null || item === void 0 ? void 0 : item.compareAtPrice) || 0;
142
+ const quantity = (item === null || item === void 0 ? void 0 : item.quantity) || 1;
142
143
  /**
143
144
  * Subscription price details
144
145
  */
@@ -147,16 +148,24 @@ const getCompareAtPriceDifference = (cart) => {
147
148
  ((_e = (_d = (_c = item === null || item === void 0 ? void 0 : item.sellingPlanAllocation) === null || _c === void 0 ? void 0 : _c.priceAdjustments[0]) === null || _d === void 0 ? void 0 : _d.perDeliveryPrice) === null || _e === void 0 ? void 0 : _e.amount) ||
148
149
  ((_h = (_g = (_f = item === null || item === void 0 ? void 0 : item.sellingPlanAllocation) === null || _f === void 0 ? void 0 : _f.priceAdjustments[0]) === null || _g === void 0 ? void 0 : _g.price) === null || _h === void 0 ? void 0 : _h.amount) ||
149
150
  0;
150
- const { compareAtPrice } = getSubscriptionPriceDetails({
151
- quantity: (item === null || item === void 0 ? void 0 : item.quantity) || 1,
152
- sellingPlanAllocation: item === null || item === void 0 ? void 0 : item.sellingPlanAllocation,
153
- });
154
- if (compareAtPrice && compareAtPrice > itemPrice) {
155
- itemCompareAtPrice = compareAtPrice;
151
+ // Only use selling plan's compareAtPrice if variant doesn't have one
152
+ // This ensures we show savings vs the original retail price, not vs the subscription price
153
+ if (!itemCompareAtPrice) {
154
+ const { compareAtPrice } = getSubscriptionPriceDetails({
155
+ quantity,
156
+ sellingPlanAllocation: item === null || item === void 0 ? void 0 : item.sellingPlanAllocation,
157
+ });
158
+ // getSubscriptionPriceDetails returns a total (already multiplied by quantity)
159
+ // So we need to calculate the savings directly without multiplying again
160
+ if (compareAtPrice && compareAtPrice > itemPrice * quantity) {
161
+ return acc + (compareAtPrice - itemPrice * quantity);
162
+ }
163
+ return acc;
156
164
  }
157
165
  }
166
+ // For variant compareAtPrice, it's a unit price, so multiply by quantity
158
167
  if (itemPrice && itemCompareAtPrice && itemCompareAtPrice > itemPrice) {
159
- return (acc + (itemCompareAtPrice * (item === null || item === void 0 ? void 0 : item.quantity) - itemPrice * (item === null || item === void 0 ? void 0 : item.quantity)));
168
+ return acc + (itemCompareAtPrice * quantity - itemPrice * quantity);
160
169
  }
161
170
  return acc;
162
171
  }, 0);
@@ -216,14 +225,21 @@ const getTotalCompareAtPrice = (cart) => {
216
225
  * Subscription price details
217
226
  */
218
227
  if (((_b = (_a = item === null || item === void 0 ? void 0 : item.sellingPlanAllocation) === null || _a === void 0 ? void 0 : _a.priceAdjustments) === null || _b === void 0 ? void 0 : _b.length) > 0) {
219
- const { compareAtPrice } = getSubscriptionPriceDetails({
220
- quantity: (item === null || item === void 0 ? void 0 : item.quantity) || 1,
221
- sellingPlanAllocation: item === null || item === void 0 ? void 0 : item.sellingPlanAllocation,
222
- });
223
- if (compareAtPrice) {
224
- itemCompareAtPrice = compareAtPrice;
228
+ // Only use selling plan's compareAtPrice if variant doesn't have one
229
+ // This ensures we show savings vs the original retail price, not vs the subscription price
230
+ if (!(item === null || item === void 0 ? void 0 : item.compareAtPrice)) {
231
+ const { compareAtPrice } = getSubscriptionPriceDetails({
232
+ quantity,
233
+ sellingPlanAllocation: item === null || item === void 0 ? void 0 : item.sellingPlanAllocation,
234
+ });
235
+ // getSubscriptionPriceDetails returns a total (already multiplied by quantity)
236
+ // So return it directly without multiplying again
237
+ if (compareAtPrice) {
238
+ return acc + compareAtPrice;
239
+ }
225
240
  }
226
241
  }
242
+ // For variant compareAtPrice, it's a unit price, so multiply by quantity
227
243
  return acc + itemCompareAtPrice * quantity;
228
244
  }, 0);
229
245
  };
@@ -597,8 +597,8 @@ describe("cart-provider.util", () => {
597
597
  },
598
598
  ] });
599
599
  const result = getVariablesCalculatedCartData(subscriptionCart);
600
- expect(result.totalCompareAtPrice).toBe(10); // Using actual item price * quantity since subscription logic uses price as compareAtPrice when no compareAtPrice exists
601
- expect(result.salesAmount).toBe(1.5); // (10-8.5) * 1 = 1.5 for subscription pricing
600
+ expect(result.totalCompareAtPrice).toBe(15); // Using variant's compareAtPrice (15) instead of selling plan's compareAtPrice (10)
601
+ expect(result.salesAmount).toBe(6.5); // (15-8.5) * 1 = 6.5 - savings vs variant's retail price
602
602
  });
603
603
  it("should handle mixed discounts and gift cards", () => {
604
604
  const mixedCart = Object.assign(Object.assign({}, baseCartData), { items: [
package/dist/styles.css CHANGED
@@ -1984,9 +1984,6 @@ video {
1984
1984
  .pr-1 {
1985
1985
  padding-right: 0.25rem;
1986
1986
  }
1987
- .pr-10 {
1988
- padding-right: 2.5rem;
1989
- }
1990
1987
  .pr-2 {
1991
1988
  padding-right: 0.5rem;
1992
1989
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.12.0",
3
+ "version": "0.12.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",