@tapcart/mobile-components 0.8.40 → 0.8.42

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":"use-block-conditional-rendering.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditional-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAGb,MAAM,kBAAkB,CAAA;AAczB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,GAAG,CAAA;IACpB,iBAAiB,EAAE,GAAG,CAAA;CACvB,UACO,YAAY;;;CA6NrB,CAAA"}
1
+ {"version":3,"file":"use-block-conditional-rendering.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditional-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAGb,MAAM,kBAAkB,CAAA;AAczB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,GAAG,CAAA;IACpB,iBAAiB,EAAE,GAAG,CAAA;CACvB,UACO,YAAY;;;CA8NrB,CAAA"}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ export declare function useStyleParent(partialStyles: Partial<CSSStyleDeclaration>): import("react").RefObject<HTMLElement | null>;
3
+ //# sourceMappingURL=use-style-parent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-style-parent.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-style-parent.ts"],"names":[],"mappings":";AAGA,wBAAgB,cAAc,CAAC,aAAa,EAAE,OAAO,CAAC,mBAAmB,CAAC,iDAgBzE"}
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { useRef, useEffect } from "react";
3
+ export function useStyleParent(partialStyles) {
4
+ const ref = useRef(null);
5
+ useEffect(() => {
6
+ const el = ref.current;
7
+ if (!el || !el.parentElement)
8
+ return;
9
+ const parent = el.parentElement;
10
+ if (!parent)
11
+ return;
12
+ for (const [key, value] of Object.entries(partialStyles)) {
13
+ // @ts-ignore: dynamic style keys
14
+ parent.style[key] = value;
15
+ }
16
+ }, [partialStyles]);
17
+ return ref;
18
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../components/ui/icon.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAEL,eAAe,EAwChB,MAAM,qBAAqB,CAAA;AAI5B,QAAA,MAAM,YAAY;;;mFAiBjB,CAAA;AA8DD,MAAM,WAAW,SACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,EACzD,YAAY,CAAC,OAAO,YAAY,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B;AA0HD,iBAAS,IAAI,CAAC,EACZ,SAAS,EACT,IAAI,EACJ,IAAW,EACX,KAAK,EACL,GAAG,EACH,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,cAAc,EACd,GAAG,KAAK,EACT,EAAE,SAAS,2CAoBX;AAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE,CAAA"}
1
+ {"version":3,"file":"icon.d.ts","sourceRoot":"","sources":["../../../components/ui/icon.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,EAEL,eAAe,EAwChB,MAAM,qBAAqB,CAAA;AAI5B,QAAA,MAAM,YAAY;;;mFAiBjB,CAAA;AA8DD,MAAM,WAAW,SACf,SAAQ,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,OAAO,CAAC,EACzD,YAAY,CAAC,OAAO,YAAY,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B;AAyLD,iBAAS,IAAI,CAAC,EACZ,SAAS,EACT,IAAI,EACJ,IAAW,EACX,KAAK,EACL,GAAG,EACH,SAAS,EACT,kBAAkB,EAClB,WAAW,EACX,WAAW,EACX,cAAc,EACd,GAAG,KAAK,EACT,EAAE,SAAS,2CAoBX;AAED,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,eAAe,EAAE,CAAA"}
@@ -94,50 +94,87 @@ const TablerIcon = ({ name, size }) => {
94
94
  const CustomIcon = ({ url, size, color, strokeColor, strokeWidth, fillColor, fillPercentage, secondaryFillColor, }) => {
95
95
  return (_jsx(ReactSVG, { src: url, beforeInjection: (svg) => {
96
96
  svg.setAttribute("style", `width: ${sizeMapping[size]}px; height: ${sizeMapping[size]}px`);
97
+ const uniqueId = crypto.randomUUID();
98
+ const fillGradientId = `fill-gradient-${uniqueId}`;
99
+ const strokeGradientId = `stroke-gradient-${uniqueId}`;
100
+ const percentage = Math.min(Math.max(fillPercentage, 0), 1);
101
+ let defs = svg.querySelector("defs");
102
+ if (!defs) {
103
+ defs = document.createElementNS("http://www.w3.org/2000/svg", "defs");
104
+ svg.prepend(defs);
105
+ }
106
+ if (percentage > 0 && percentage < 1) {
107
+ const fillGradient = document.createElementNS("http://www.w3.org/2000/svg", "linearGradient");
108
+ fillGradient.setAttribute("id", fillGradientId);
109
+ fillGradient.setAttribute("x1", "0%");
110
+ fillGradient.setAttribute("y1", "0%");
111
+ fillGradient.setAttribute("x2", "100%");
112
+ fillGradient.setAttribute("y2", "0%");
113
+ const fillStop1 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
114
+ fillStop1.setAttribute("offset", `${percentage * 100}%`);
115
+ fillStop1.setAttribute("stop-color", color || fillColor || "currentColor");
116
+ fillGradient.appendChild(fillStop1);
117
+ const fillStop2 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
118
+ fillStop2.setAttribute("offset", `${percentage * 100}%`);
119
+ fillStop2.setAttribute("stop-color", secondaryFillColor || "transparent");
120
+ fillGradient.appendChild(fillStop2);
121
+ defs.appendChild(fillGradient);
122
+ const strokeGradient = document.createElementNS("http://www.w3.org/2000/svg", "linearGradient");
123
+ strokeGradient.setAttribute("id", strokeGradientId);
124
+ strokeGradient.setAttribute("x1", "0%");
125
+ strokeGradient.setAttribute("y1", "0%");
126
+ strokeGradient.setAttribute("x2", "100%");
127
+ strokeGradient.setAttribute("y2", "0%");
128
+ const strokeStop1 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
129
+ strokeStop1.setAttribute("offset", `${percentage * 100}%`);
130
+ strokeStop1.setAttribute("stop-color", color || strokeColor || fillColor || "currentColor");
131
+ strokeGradient.appendChild(strokeStop1);
132
+ const strokeStop2 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
133
+ strokeStop2.setAttribute("offset", `${percentage * 100}%`);
134
+ strokeStop2.setAttribute("stop-color", secondaryFillColor || "transparent");
135
+ strokeGradient.appendChild(strokeStop2);
136
+ defs.appendChild(strokeGradient);
137
+ }
97
138
  const paths = svg.querySelectorAll("path");
98
139
  paths.forEach((path) => {
99
- if (color) {
100
- if (path.hasAttribute("fill") && fillPercentage === 1) {
101
- path.setAttribute("fill", color);
140
+ if (path.hasAttribute("fill") &&
141
+ path.getAttribute("fill") !== "none") {
142
+ if (percentage === 1) {
143
+ path.setAttribute("fill", color ||
144
+ fillColor ||
145
+ path.getAttribute("fill") ||
146
+ "currentColor");
102
147
  }
103
- path.setAttribute("stroke", color);
104
- }
105
- else {
106
- if (fillColor &&
107
- path.hasAttribute("fill") &&
108
- fillPercentage === 1) {
109
- path.setAttribute("fill", fillColor);
148
+ else if (percentage === 0) {
149
+ path.setAttribute("fill", secondaryFillColor || "transparent");
110
150
  }
111
- if (strokeColor) {
112
- path.setAttribute("stroke", strokeColor);
151
+ else {
152
+ path.setAttribute("fill", `url(#${fillGradientId})`);
113
153
  }
114
154
  }
115
- if (path.hasAttribute("stroke")) {
116
- path.setAttribute("stroke-width", strokeWidthMapping[size].toString());
117
- }
118
- if (strokeWidth != null && path.hasAttribute("stroke")) {
119
- path.setAttribute("stroke-width", strokeWidth.toString());
155
+ if (path.hasAttribute("stroke") &&
156
+ path.getAttribute("stroke") !== "none") {
157
+ if (percentage === 1) {
158
+ path.setAttribute("stroke", color ||
159
+ strokeColor ||
160
+ path.getAttribute("stroke") ||
161
+ "currentColor");
162
+ }
163
+ else if (percentage === 0) {
164
+ path.setAttribute("stroke", secondaryFillColor || "transparent");
165
+ }
166
+ else {
167
+ path.setAttribute("stroke", `url(#${strokeGradientId})`);
168
+ }
120
169
  }
121
- // Create a gradient fill based on the fillPercentage
122
- if (fillPercentage && fillPercentage > 0 && fillPercentage < 1) {
123
- const percentage = Math.min(Math.max(fillPercentage, 0), 1);
124
- const gradientId = `gradient-${Math.random()}`;
125
- const gradient = document.createElementNS("http://www.w3.org/2000/svg", "linearGradient");
126
- gradient.setAttribute("id", gradientId);
127
- gradient.setAttribute("x1", "0%");
128
- gradient.setAttribute("y1", "0%");
129
- gradient.setAttribute("x2", "100%");
130
- gradient.setAttribute("y2", "0%");
131
- const stop1 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
132
- stop1.setAttribute("offset", `${percentage * 100}%`);
133
- stop1.setAttribute("stop-color", color || fillColor || "currentColor");
134
- gradient.appendChild(stop1);
135
- const stop2 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
136
- stop2.setAttribute("offset", `${percentage * 100}%`);
137
- stop2.setAttribute("stop-color", secondaryFillColor || "transparent"); // Use secondary fill color
138
- gradient.appendChild(stop2);
139
- svg.appendChild(gradient);
140
- path.setAttribute("fill", `url(#${gradientId})`);
170
+ if (path.hasAttribute("stroke") &&
171
+ path.getAttribute("stroke") !== "none") {
172
+ if (strokeWidth != null) {
173
+ path.setAttribute("stroke-width", strokeWidth.toString());
174
+ }
175
+ else {
176
+ path.setAttribute("stroke-width", strokeWidthMapping[size].toString());
177
+ }
141
178
  }
142
179
  });
143
180
  } }));
@@ -2,7 +2,7 @@
2
2
  import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
3
  import React, { useState, useEffect, useCallback, useRef, } from "react";
4
4
  // @ts-ignore -- webbridge-react is not typed (yet)
5
- import { useActions } from "@tapcart/webbridge-react";
5
+ import { useActions } from "@tapcart/app-studio-sdk";
6
6
  // Shared manager for all instances of the hook
7
7
  const tapManager = (() => {
8
8
  const elements = new Map();
package/dist/index.d.ts CHANGED
@@ -69,6 +69,7 @@ export * from "./components/ui/html";
69
69
  export * from "./components/hooks/use-shop";
70
70
  export * from "./components/libs/sort-filter/search-integration";
71
71
  export * from "./components/hooks/use-reviews";
72
+ export * from "./components/hooks/use-style-parent";
72
73
  export * from "./components/ui/subcollection-tabs";
73
74
  export * from "./components/ui/ProductCard/utils";
74
75
  export * from "./lib/price";
@@ -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,cAAc,EACd,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,qBAAqB,EACrB,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,eAAe,EACf,cAAc,EACd,SAAS,EACT,4BAA4B,EAC5B,gBAAgB,GACjB,MAAM,aAAa,CAAA;AACpB,cAAc,iBAAiB,CAAA;AAC/B,cAAc,2CAA2C,CAAA;AACzD,cAAc,mCAAmC,CAAA;AACjD,cAAc,wCAAwC,CAAA;AACtD,cAAc,0CAA0C,CAAA;AACxD,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,oDAAoD,CAAA;AAClE,cAAc,kCAAkC,CAAA;AAChD,cAAc,2BAA2B,CAAA;AACzC,cAAc,mCAAmC,CAAA;AACjD,cAAc,gCAAgC,CAAA;AAC9C,cAAc,kCAAkC,CAAA;AAChD,cAAc,8BAA8B,CAAA;AAC5C,cAAc,uBAAuB,CAAA;AACrC,cAAc,wBAAwB,CAAA;AACtC,cAAc,0BAA0B,CAAA;AACxC,cAAc,0BAA0B,CAA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rC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,0BAA0B,CAAA;AACxC,cAAc,iCAAiC,CAAA;AAC/C,cAAc,sBAAsB,CAAA;AACpC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kDAAkD,CAAA;AAChE,cAAc,gCAAgC,CAAA;AAC9C,cAAc,qCAAqC,CAAA;AACnD,cAAc,oCAAoC,CAAA;AAClD,cAAc,mCAAmC,CAAA;AACjD,cAAc,aAAa,CAAA;AAC3B,cAAc,6CAA6C,CAAA;AAC3D,cAAc,kDAAkD,CAAA;AAChE,cAAc,qBAAqB,CAAA;AACnC,cAAc,mCAAmC,CAAA;AACjD,cAAc,qCAAqC,CAAA;AACnD,cAAc,wBAAwB,CAAA"}
package/dist/index.js CHANGED
@@ -70,6 +70,7 @@ export * from "./components/ui/html";
70
70
  export * from "./components/hooks/use-shop";
71
71
  export * from "./components/libs/sort-filter/search-integration";
72
72
  export * from "./components/hooks/use-reviews";
73
+ export * from "./components/hooks/use-style-parent";
73
74
  export * from "./components/ui/subcollection-tabs";
74
75
  export * from "./components/ui/ProductCard/utils";
75
76
  export * from "./lib/price";
@@ -39,10 +39,39 @@ export type CalculatedData = {
39
39
  };
40
40
  export declare const DEFAULT_CALCULATED_DATA: CalculatedData;
41
41
  export declare const getCalculatedCartData: (cart: EnrichedCart) => CalculatedData;
42
- export declare const getCartItemKey: (variantId: string, sellingPlanId?: string, attributes?: {
43
- [key: string]: string;
44
- } | {
45
- key: string;
46
- value: string;
47
- }[] | undefined) => string;
42
+ export declare const getUniqueCartItemID: (options: {
43
+ variantId: string;
44
+ sellingPlanId?: string | undefined;
45
+ attributes?: {
46
+ [key: string]: string;
47
+ } | {
48
+ key: string;
49
+ value: string;
50
+ }[] | undefined;
51
+ discounts?: string[] | {
52
+ discountedAmount?: {
53
+ amount: string;
54
+ currencyCode: string;
55
+ } | undefined;
56
+ amount?: number | undefined;
57
+ title: string;
58
+ targetType?: string | undefined;
59
+ type?: string | undefined;
60
+ code?: string | undefined;
61
+ }[] | {
62
+ amount: number;
63
+ code: string;
64
+ title?: string | undefined;
65
+ type: string;
66
+ readOnly?: boolean | undefined;
67
+ }[] | {
68
+ discountedAmount: {
69
+ amount: string;
70
+ currencyCode: string;
71
+ };
72
+ targetType: string;
73
+ code?: string | undefined;
74
+ title?: string | undefined;
75
+ }[] | undefined;
76
+ }) => string;
48
77
  //# sourceMappingURL=cart.util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"cart.util.d.ts","sourceRoot":"","sources":["../../lib/cart.util.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,6BAA6B,EAE7B,cAAc,EACf,MAAM,kBAAkB,CAAA;AAGzB,eAAO,MAAM,eAAe;cAKhB,MAAM;aACP,cAAc;;0BAEH;YAChB,gBAAgB,CAAC,EAAE;gBACjB,MAAM,EAAE,MAAM,CAAA;gBACd,YAAY,EAAE,MAAM,CAAA;aACrB,CAAA;YACD,KAAK,EAAE;gBACL,MAAM,EAAE,MAAM,CAAA;gBACd,YAAY,EAAE,MAAM,CAAA;aACrB,CAAA;YACD,cAAc,CAAC,EAAE;gBACf,MAAM,EAAE,MAAM,CAAA;gBACd,YAAY,EAAE,MAAM,CAAA;aACrB,CAAA;SACF,EAAE;;;;;;;CAgCN,CAAA;AA2CD,eAAO,MAAM,oBAAoB,SAAU,MAAM,QAAQ,YAAY,YAMpE,CAAA;AAED,eAAO,MAAM,kBAAkB,SAAU,MAAM,QAAQ,YAAY,YAMlE,CAAA;AAoHD,MAAM,MAAM,cAAc,GAAG;IAC3B,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,oBAAo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IAC5B,gBAAgB,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,cAUrC,CAAA;AAED,eAAO,MAAM,qBAAqB,SAAU,YAAY,KAAG,cA8B1D,CAAA;AAGD,eAAO,MAAM,mBAAmB;eACnB,MAAM;;;;;aAEG,MAAM;eAAS,MAAM;;;;oBAIN,MAAM;0BAAgB,MAAM;;;eAElD,MAAM;;;;;gBAML,MAAM;cACR,MAAM;;cAEN,MAAM;;;0BAIM;YAAE,MAAM,EAAE,MAAM,CAAC;YAAC,YAAY,EAAE,MAAM,CAAA;SAAE;oBAC9C,MAAM;;;;YAsCzB,CAAA"}
@@ -28,12 +28,12 @@ export const getVariantPrice = ({ quantity, variant, sellingPlanAllocation = { p
28
28
  const getOrderLevelDiscounts = (cart) => {
29
29
  var _a;
30
30
  const discountMap = (_a = cart.discountAllocations) === null || _a === void 0 ? void 0 : _a.filter((discount) => discount.targetType !== "SHIPPING_LINE").reduce((acc, discount) => {
31
- var _a;
31
+ var _a, _b;
32
32
  const code = ((_a = discount.code) !== null && _a !== void 0 ? _a : "unknown").toUpperCase();
33
33
  if (!acc[code]) {
34
34
  acc[code] = 0;
35
35
  }
36
- acc[code] += parseFloat(discount.discountedAmount.amount);
36
+ acc[code] += parseFloat(((_b = discount === null || discount === void 0 ? void 0 : discount.discountedAmount) === null || _b === void 0 ? void 0 : _b.amount) || "0");
37
37
  return acc;
38
38
  }, {});
39
39
  if (!discountMap)
@@ -53,11 +53,14 @@ const getShippingDiscounts = (cart) => {
53
53
  var _a;
54
54
  if (!(cart === null || cart === void 0 ? void 0 : cart.discountAllocations))
55
55
  return [];
56
- return (_a = cart.discountAllocations) === null || _a === void 0 ? void 0 : _a.filter((discount) => discount.targetType === "SHIPPING_LINE").map((discount) => ({
57
- amount: discount.discountedAmount.amount,
58
- code: discount.code,
59
- type: discount.targetType,
60
- }));
56
+ return (_a = cart.discountAllocations) === null || _a === void 0 ? void 0 : _a.filter((discount) => discount.targetType === "SHIPPING_LINE").map((discount) => {
57
+ var _a;
58
+ return ({
59
+ amount: (_a = discount === null || discount === void 0 ? void 0 : discount.discountedAmount) === null || _a === void 0 ? void 0 : _a.amount,
60
+ code: discount === null || discount === void 0 ? void 0 : discount.code,
61
+ type: discount === null || discount === void 0 ? void 0 : discount.targetType,
62
+ });
63
+ });
61
64
  };
62
65
  export const isOrderLevelDiscount = (code, cart) => {
63
66
  const orderLevelDiscounts = getOrderLevelDiscounts(cart);
@@ -187,11 +190,29 @@ export const getCalculatedCartData = (cart) => {
187
190
  totalSavedAmount,
188
191
  };
189
192
  };
190
- export const getCartItemKey = (variantId, sellingPlanId, attributes) => {
191
- const key = `${getIdFromGid(variantId)}:${sellingPlanId || "no-plan"}:${Array.isArray(attributes)
192
- ? attributes === null || attributes === void 0 ? void 0 : attributes.map((attr) => `${attr.key}-${attr.value}`).join("-")
193
+ // Until the actual CartItem ID is available via webbridge, we use this unique identifier
194
+ export const getUniqueCartItemID = (options) => {
195
+ const { variantId, sellingPlanId, attributes, discounts } = options;
196
+ const attributesString = Array.isArray(attributes)
197
+ ? attributes === null || attributes === void 0 ? void 0 : attributes.map((attr) => `${attr.key}-${attr.value}`).sort().reverse().join("-")
193
198
  : Object.entries(attributes || {})
199
+ .sort()
200
+ .reverse()
194
201
  .map(([key, value]) => `${key}-${value}`)
195
- .join("-")}`;
202
+ .join("-");
203
+ const discountsString = discounts
204
+ ? Array.isArray(discounts) && typeof discounts[0] === "string"
205
+ ? discounts.join("-")
206
+ : discounts
207
+ .map((discount) => {
208
+ var _a;
209
+ const amount = parseFloat(((_a = discount.discountedAmount) === null || _a === void 0 ? void 0 : _a.amount) || discount.amount || "0");
210
+ const title = discount.title || "";
211
+ const code = discount.code || "";
212
+ return `${amount}-${title || code}`;
213
+ })
214
+ .join("-")
215
+ : "";
216
+ const key = `${getIdFromGid(variantId)}~~~~${sellingPlanId ? getIdFromGid(sellingPlanId) : "no-plan"}~~~~${attributesString}${discountsString ? "~~~~" + discountsString : ""}`;
196
217
  return key;
197
218
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.8.40",
3
+ "version": "0.8.42",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",
@@ -72,7 +72,7 @@
72
72
  "@radix-ui/react-toggle-group": "^1.0.4",
73
73
  "@tabler/icons-react": "^3.2.0",
74
74
  "@tanstack/react-virtual": "^3.13.6",
75
- "@tapcart/webbridge-react": "^1.15.0",
75
+ "@tapcart/app-studio-sdk": "^2.0.0",
76
76
  "apple-pay-button": "^1.1.7",
77
77
  "class-variance-authority": "^0.6.0",
78
78
  "clsx": "^1.2.1",