@tapcart/mobile-components 0.7.62 → 0.7.64

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.
Files changed (38) hide show
  1. package/dist/components/hooks/use-click-outside.d.ts +6 -0
  2. package/dist/components/hooks/use-click-outside.d.ts.map +1 -0
  3. package/dist/components/hooks/use-click-outside.js +15 -0
  4. package/dist/components/hooks/use-outside-click.d.ts +7 -0
  5. package/dist/components/hooks/use-outside-click.d.ts.map +1 -0
  6. package/dist/components/hooks/use-outside-click.js +16 -0
  7. package/dist/components/hooks/use-tap.d.ts +8 -0
  8. package/dist/components/hooks/use-tap.d.ts.map +1 -0
  9. package/dist/components/hooks/use-tap.js +100 -0
  10. package/dist/components/ui/Input/input.d.ts +1 -1
  11. package/dist/components/ui/Input/input.d.ts.map +1 -1
  12. package/dist/components/ui/Input/input.js +12 -12
  13. package/dist/components/ui/Input/useInput.d.ts +0 -2
  14. package/dist/components/ui/Input/useInput.d.ts.map +1 -1
  15. package/dist/components/ui/Input/useInput.js +1 -1
  16. package/dist/components/ui/apple-pay-button.d.ts +2 -1
  17. package/dist/components/ui/apple-pay-button.d.ts.map +1 -1
  18. package/dist/components/ui/apple-pay-button.js +8 -4
  19. package/dist/components/ui/radio-group.d.ts.map +1 -1
  20. package/dist/components/ui/radio-group.js +6 -2
  21. package/dist/components/ui/selectors.d.ts.map +1 -1
  22. package/dist/components/ui/selectors.js +7 -3
  23. package/dist/components/ui/tap.d.ts.map +1 -1
  24. package/dist/components/ui/tap.js +12 -2
  25. package/dist/styles.css +3 -0
  26. package/package.json +21 -21
  27. package/dist/components/libs/cart/calculated-cart-values.util.d.ts +0 -16
  28. package/dist/components/libs/cart/calculated-cart-values.util.d.ts.map +0 -1
  29. package/dist/components/libs/cart/calculated-cart-values.util.js +0 -144
  30. package/dist/components/libs/cart/calculated-cart-values.util.test.d.ts +0 -2
  31. package/dist/components/libs/cart/calculated-cart-values.util.test.d.ts.map +0 -1
  32. package/dist/components/libs/cart/calculated-cart-values.util.test.js +0 -150
  33. package/dist/components/libs/cart/calculatedCartValues.util.d.ts +0 -1
  34. package/dist/components/libs/cart/calculatedCartValues.util.d.ts.map +0 -1
  35. package/dist/components/libs/cart/calculatedCartValues.util.js +0 -1
  36. package/dist/lib/cart.util copy.d.ts +0 -1
  37. package/dist/lib/cart.util copy.d.ts.map +0 -1
  38. package/dist/lib/cart.util copy.js +0 -1
@@ -0,0 +1,6 @@
1
+ import React from "react"
2
+ export declare function useClickOutside(
3
+ ref: React.RefObject<HTMLElement>,
4
+ callback: () => void
5
+ ): void
6
+ //# sourceMappingURL=use-click-outside.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-click-outside.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-click-outside.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAE,IAAI,CAa5F"}
@@ -0,0 +1,15 @@
1
+ "use client"
2
+ import React from "react"
3
+ export function useClickOutside(ref, callback) {
4
+ React.useEffect(() => {
5
+ const handleClickOutside = (event) => {
6
+ if (ref.current && !ref.current.contains(event.target)) {
7
+ callback()
8
+ }
9
+ }
10
+ document.addEventListener("mousedown", handleClickOutside)
11
+ return () => {
12
+ document.removeEventListener("mousedown", handleClickOutside)
13
+ }
14
+ }, [ref, callback])
15
+ }
@@ -0,0 +1,7 @@
1
+ import React from "react"
2
+ declare const useClickOutside: (
3
+ ref: React.RefObject<HTMLElement>,
4
+ callback: () => void
5
+ ) => void
6
+ export default useClickOutside
7
+ //# sourceMappingURL=use-outside-click.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-outside-click.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-outside-click.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,QAAA,MAAM,eAAe,QAAS,MAAM,SAAS,CAAC,WAAW,CAAC,YAAY,MAAM,IAAI,SAa/E,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use client"
2
+ import React from "react"
3
+ const useClickOutside = (ref, callback) => {
4
+ React.useEffect(() => {
5
+ const handleClickOutside = (event) => {
6
+ if (ref.current && !ref.current.contains(event.target)) {
7
+ callback()
8
+ }
9
+ }
10
+ document.addEventListener("mousedown", handleClickOutside)
11
+ return () => {
12
+ document.removeEventListener("mousedown", handleClickOutside)
13
+ }
14
+ }, [ref, callback])
15
+ }
16
+ export default useClickOutside
@@ -0,0 +1,8 @@
1
+ import React from "react"
2
+ declare const useTap: (tapThreshold?: number) => {
3
+ onTap: (handler: (event: any) => void) => (event: any) => void
4
+ isPressed: boolean
5
+ ref: React.MutableRefObject<null>
6
+ }
7
+ export { useTap }
8
+ //# sourceMappingURL=use-tap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tap.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-tap.ts"],"names":[],"mappings":"AACA,OAAO,KAAmD,MAAM,OAAO,CAAA;AAuFvE,QAAA,MAAM,MAAM;6BAuBkC,GAAG,KAAK,IAAI,aACvC,GAAG;;;CAerB,CAAA;AAED,OAAO,EAAE,MAAM,EAAE,CAAA"}
@@ -0,0 +1,100 @@
1
+ "use client"
2
+ import { useState, useEffect, useCallback, useRef } from "react"
3
+ // Shared manager for all instances of the hook
4
+ const tapManager = (() => {
5
+ const elements = new Map()
6
+ let isListening = false
7
+ const startListening = () => {
8
+ if (isListening) return
9
+ const handleTouchStart = (e) => {
10
+ const touch = e.touches[0]
11
+ elements.forEach((data, el) => {
12
+ if (el.contains(touch.target)) {
13
+ data.touchStarted = true
14
+ data.touchMoved = false
15
+ data.startPosition = { x: touch.clientX, y: touch.clientY }
16
+ // Don't set isPressed here, wait to determine if it's a tap or drag
17
+ }
18
+ })
19
+ }
20
+ const handleTouchMove = (e) => {
21
+ const touch = e.touches[0]
22
+ elements.forEach((data, el) => {
23
+ if (data.touchStarted) {
24
+ const deltaX = Math.abs(touch.clientX - data.startPosition.x)
25
+ const deltaY = Math.abs(touch.clientY - data.startPosition.y)
26
+ if (deltaX > data.tapThreshold || deltaY > data.tapThreshold) {
27
+ data.touchMoved = true
28
+ data.setIsPressed(false)
29
+ }
30
+ }
31
+ })
32
+ }
33
+ const handleTouchEnd = () => {
34
+ elements.forEach((data) => {
35
+ if (data.touchStarted) {
36
+ data.touchStarted = false
37
+ if (!data.touchMoved) {
38
+ // It's a tap, set isPressed briefly
39
+ data.setIsPressed(true)
40
+ setTimeout(() => data.setIsPressed(false), 100)
41
+ }
42
+ }
43
+ })
44
+ }
45
+ document.addEventListener("touchstart", (e) => handleTouchStart(e), {
46
+ passive: true,
47
+ })
48
+ document.addEventListener("touchmove", (e) => handleTouchMove(e), {
49
+ passive: true,
50
+ })
51
+ document.addEventListener("touchend", () => handleTouchEnd(), {
52
+ passive: true,
53
+ })
54
+ isListening = true
55
+ }
56
+ return {
57
+ register: (el, data) => {
58
+ elements.set(el, data)
59
+ startListening()
60
+ },
61
+ unregister: (el) => {
62
+ elements.delete(el)
63
+ },
64
+ elements,
65
+ }
66
+ })()
67
+ const useTap = (tapThreshold = 10) => {
68
+ const [isPressed, setIsPressed] = useState(false)
69
+ const elementRef = useRef(null)
70
+ useEffect(() => {
71
+ const element = elementRef.current
72
+ if (!element) return
73
+ const data = {
74
+ touchStarted: false,
75
+ touchMoved: false,
76
+ startPosition: { x: 0, y: 0 },
77
+ setIsPressed,
78
+ tapThreshold,
79
+ }
80
+ tapManager.register(element, data)
81
+ return () => {
82
+ tapManager.unregister(element)
83
+ }
84
+ }, [tapThreshold])
85
+ const onTap = useCallback((handler) => {
86
+ return (event) => {
87
+ const data = tapManager.elements.get(elementRef.current)
88
+ if (!data) return
89
+ if (event.type === "touchend" && !data.touchMoved) {
90
+ handler(event)
91
+ } else if (event.type === "click" && !data.touchStarted) {
92
+ handler(event)
93
+ setIsPressed(true)
94
+ setTimeout(() => setIsPressed(false), 100)
95
+ }
96
+ }
97
+ }, [])
98
+ return { onTap, isPressed, ref: elementRef }
99
+ }
100
+ export { useTap }
@@ -1,5 +1,5 @@
1
- import * as React from "react";
2
1
  import { InputProps } from "../../../components/ui/Input/types";
2
+ import * as React from "react";
3
3
  declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
4
4
  export { Input };
5
5
  //# sourceMappingURL=input.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAMxD,QAAA,MAAM,KAAK,qFAqLV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
1
+ {"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AACxD,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAS9B,QAAA,MAAM,KAAK,qFAqLV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
@@ -11,10 +11,10 @@ var __rest = (this && this.__rest) || function (s, e) {
11
11
  };
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import * as React from "react";
14
- import { inputVariants, useInput } from "./useInput";
15
14
  import { cn } from "../../../lib/utils";
16
- import { Icon } from "../icon";
17
15
  import { getTextTranslation, useTranslation, } from "../../contexts/translation-context";
16
+ import { Icon } from "../icon";
17
+ import { inputVariants, useInput } from "./useInput";
18
18
  const Input = React.forwardRef((_a, ref) => {
19
19
  var { className, error = false, id, type, label, labelStyle, asChild, value, onChange, icon, iconUrl, iconPosition = "right", // Default to "right" for backward compatibility
20
20
  iconColor, placeholder, placeholderFont, placeholderFontWeight, placeholderFontSize, placeholderTextAlign, placeholderTextColor, placeholderUpperCase, inputPadding, backgroundColor, borderRadius, inputBorderColor, borderSides, inputSpacing, inputActiveBorderColor } = _a, // New prop for active border color
@@ -51,20 +51,20 @@ const Input = React.forwardRef((_a, ref) => {
51
51
  bottom: iconBottomPadding,
52
52
  color: iconColorStyle,
53
53
  } })), _jsx("style", { children: `
54
- .custom-placeholder-value::placeholder {
55
- color: ${placeholderTextColorStyle};
56
- }
57
- .custom-placeholder-value {
58
- border-color: ${inputBorderColorStyle};
59
- }
60
- .custom-placeholder-value:focus {
61
- border-color: ${inputActiveBorderColorStyle};
62
- }
54
+ #${id}::placeholder {
55
+ color: ${placeholderTextColorStyle};
56
+ }
57
+ #${id} {
58
+ border-color: ${inputBorderColorStyle};
59
+ }
60
+ #${id}:focus {
61
+ border-color: ${inputActiveBorderColorStyle};
62
+ }
63
63
  ` }), _jsx("input", Object.assign({ placeholder: translatedPlaceholder || placeholder, value: value, onChange: (e) => onChange(e.target.value), id: id, type: type, className: cn(inputVariants({ error, hasLabel: !!label }), className, "custom-placeholder-value"), "data-icon": !!icon, ref: ref }, props, { style: Object.assign(Object.assign({ paddingLeft: iconUrl &&
64
64
  iconPosition === "left" &&
65
65
  placeholderTextAlign === "center"
66
66
  ? undefined
67
- : inputPaddingLeft, paddingRight: inputPaddingRight, fontFamily: placeholderFont, fontWeight: placeholderFontWeight, fontSize: `${placeholderFontSize}px`, textAlign: placeholderTextAlign, color: placeholderTextColorStyle, textTransform: placeholderUpperCase ? "uppercase" : undefined, paddingTop: inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.top, paddingBottom: inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.bottom, backgroundColor: inputBgColor }, borderStyle), (label ? { borderRadius: "8px" } : borderRadiusStyle)) })), label ? (_jsx("label", Object.assign({ htmlFor: id, style: labelTextStyle, className: cn("absolute text-[10px] text-textColors-secondaryColor group-active:text-coreColors-brandColorPrimary top-2 z-10 h-4 origin-[0] opacity-100 peer-placeholder-shown:opacity-0", iconPosition === "left" ? "start-10" : "start-4") }, { children: label }))) : null, (icon || iconUrl) && iconPosition === "right" && (_jsx(Icon, { name: icon, url: iconUrl, "data-error": error, size: "sm", className: cn("flex items-center absolute aspect-square fill-current z-10 icon ", {
67
+ : inputPaddingLeft, paddingRight: inputPaddingRight, fontFamily: placeholderFont, fontWeight: placeholderFontWeight, fontSize: `${placeholderFontSize}px`, textAlign: placeholderTextAlign, color: placeholderTextColorStyle, textTransform: placeholderUpperCase ? "uppercase" : undefined, paddingTop: inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.top, paddingBottom: inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.bottom, backgroundColor: inputBgColor }, borderStyle), borderRadiusStyle) })), label ? (_jsx("label", Object.assign({ htmlFor: id, style: labelTextStyle, className: cn("absolute text-[10px] text-textColors-secondaryColor group-active:text-coreColors-brandColorPrimary top-2 z-10 h-4 origin-[0] opacity-100 peer-placeholder-shown:opacity-0", iconPosition === "left" ? "start-10" : "start-4") }, { children: label }))) : null, (icon || iconUrl) && iconPosition === "right" && (_jsx(Icon, { name: icon, url: iconUrl, "data-error": error, size: "sm", className: cn("flex items-center absolute aspect-square fill-current z-10 icon ", {
68
68
  "w-5": true,
69
69
  "text-stateColors-error": error,
70
70
  }), style: {
@@ -26,8 +26,6 @@ export declare const useInput: (props: Pick<InputProps, "asChild" | "icon" | "ic
26
26
  };
27
27
  borderRadiusStyle: {
28
28
  borderRadius: string;
29
- } | {
30
- borderRadius?: undefined;
31
29
  };
32
30
  iconLeftPadding: string;
33
31
  iconRightPadding: string;
@@ -1 +1 @@
1
- {"version":3,"file":"useInput.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/useInput.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAGxD,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,eAAO,MAAM,aAAa;;;mFAkBzB,CAAA;AAED,eAAO,MAAM,QAAQ,UACZ,KACL,UAAU,EACR,SAAS,GACT,MAAM,GACN,SAAS,GACT,cAAc,GACd,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,cAAc,GACd,kBAAkB,GAClB,wBAAwB,GACxB,aAAa,GACb,cAAc,GACd,cAAc,GACd,sBAAsB,GACtB,YAAY,CACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6FF,CAAA"}
1
+ {"version":3,"file":"useInput.d.ts","sourceRoot":"","sources":["../../../../components/ui/Input/useInput.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAA;AAGxD,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,KAAK,CAAA;AACnC,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC,eAAO,MAAM,aAAa;;;mFAkBzB,CAAA;AAED,eAAO,MAAM,QAAQ,UACZ,KACL,UAAU,EACR,SAAS,GACT,MAAM,GACN,SAAS,GACT,cAAc,GACd,WAAW,GACX,WAAW,GACX,iBAAiB,GACjB,cAAc,GACd,kBAAkB,GAClB,wBAAwB,GACxB,aAAa,GACb,cAAc,GACd,cAAc,GACd,sBAAsB,GACtB,YAAY,CACf;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6FF,CAAA"}
@@ -48,7 +48,7 @@ export const useInput = (props) => {
48
48
  };
49
49
  const borderRadiusStyle = borderRadius
50
50
  ? { borderRadius: `${borderRadius}px` }
51
- : {};
51
+ : { borderRadius: "8px" };
52
52
  const iconLeftPadding = (inputPadding === null || inputPadding === void 0 ? void 0 : inputPadding.left) !== undefined
53
53
  ? `${inputPadding.left}px`
54
54
  : `${DEFAULT_X_PADDING}px`;
@@ -25,12 +25,13 @@ export interface ApplePayButtonProps extends React.ButtonHTMLAttributes<HTMLButt
25
25
  boxSizing?: string | undefined;
26
26
  };
27
27
  onPaymentAuthorized?: (paymentData: ApplePayJS.ApplePayPayment) => Promise<boolean>;
28
+ onPaymentMethodSelected?: (paymentMethod: ApplePayJS.ApplePayPaymentMethod) => Promise<ApplePayJS.ApplePayPaymentMethodUpdate>;
28
29
  onShippingContactSelected?: (shippingContact: ApplePayJS.ApplePayPaymentContact) => Promise<ApplePayJS.ApplePayShippingMethodUpdate>;
29
30
  onShippingMethodSelected?: (shippingMethod: ApplePayJS.ApplePayShippingMethod) => Promise<ApplePayJS.ApplePayShippingMethodUpdate>;
30
31
  onPaymentCancelled?: (event?: ApplePayJS.Event) => void;
31
32
  }
32
33
  declare const ApplePayButton: {
33
- ({ displayName, amount, requiredBillingContactFields, requiredShippingContactFields, startSessionURL, startSessionCacheBypass, appId, domainName, countryCode, currencyCode, merchantCapabilities, supportedNetworks, buttonType, buttonStyle, applePayButtonStyle, onPaymentAuthorized, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }: ApplePayButtonProps): import("react/jsx-runtime").JSX.Element;
34
+ ({ displayName, amount, requiredBillingContactFields, requiredShippingContactFields, startSessionURL, startSessionCacheBypass, appId, domainName, countryCode, currencyCode, merchantCapabilities, supportedNetworks, buttonType, buttonStyle, applePayButtonStyle, onPaymentAuthorized, onPaymentMethodSelected, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }: ApplePayButtonProps): import("react/jsx-runtime").JSX.Element;
34
35
  displayName: string;
35
36
  };
36
37
  export { ApplePayButton };
@@ -1 +1 @@
1
- {"version":3,"file":"apple-pay-button.d.ts","sourceRoot":"","sources":["../../../components/ui/apple-pay-button.tsx"],"names":[],"mappings":";AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAG9B,MAAM,MAAM,kBAAkB,GAC1B,OAAO,GACP,WAAW,GACX,MAAM,GACN,KAAK,GAC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  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  import ApplePayButtonComponent from "apple-pay-button";
13
- const ApplePayButton = ({ displayName, amount, requiredBillingContactFields = ["name", "postalAddress", "phone", "email"], requiredShippingContactFields = ["name", "postalAddress", "phone", "email"], startSessionURL, startSessionCacheBypass = false, appId, domainName, countryCode = "US", currencyCode = "USD", merchantCapabilities = ["supports3DS"], supportedNetworks = ["visa", "masterCard", "amex", "discover"], buttonType = "plain", buttonStyle = "white-outline", applePayButtonStyle, onPaymentAuthorized, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }) => {
13
+ const ApplePayButton = ({ displayName, amount, requiredBillingContactFields = ["name", "postalAddress", "phone", "email"], requiredShippingContactFields = ["name", "postalAddress", "phone", "email"], startSessionURL, startSessionCacheBypass = false, appId, domainName, countryCode = "US", currencyCode = "USD", merchantCapabilities = ["supports3DS"], supportedNetworks = ["visa", "masterCard", "amex", "discover"], buttonType = "plain", buttonStyle = "white-outline", applePayButtonStyle, onPaymentAuthorized, onPaymentMethodSelected, onShippingContactSelected, onShippingMethodSelected, onPaymentCancelled, }) => {
14
14
  const onClick = () => {
15
15
  const applePayRequest = {
16
16
  countryCode,
@@ -59,16 +59,20 @@ const ApplePayButton = ({ displayName, amount, requiredBillingContactFields = ["
59
59
  console.error("Error during validating merchant");
60
60
  }
61
61
  });
62
- session.onpaymentmethodselected = (event) => {
63
- const update = {
62
+ session.onpaymentmethodselected = (event) => __awaiter(void 0, void 0, void 0, function* () {
63
+ const paymentMethod = event.paymentMethod;
64
+ let update = {
64
65
  newTotal: {
65
66
  label: displayName,
66
67
  type: "final",
67
68
  amount: amount.toString(),
68
69
  },
69
70
  };
71
+ if (onPaymentMethodSelected) {
72
+ update = yield onPaymentMethodSelected(paymentMethod);
73
+ }
70
74
  session.completePaymentMethodSelection(update);
71
- };
75
+ });
72
76
  session.onshippingmethodselected = (event) => __awaiter(void 0, void 0, void 0, function* () {
73
77
  const shippingMethod = event.shippingMethod;
74
78
  let update = {
@@ -1 +1 @@
1
- {"version":3,"file":"radio-group.d.ts","sourceRoot":"","sources":["../../../components/ui/radio-group.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,mBAAmB,MAAM,6BAA6B,CAAA;AAElE,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAKjE,QAAA,MAAM,UAAU,+JAWd,CAAA;AAGF,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAA;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,QAAA,MAAM,sBAAsB;;mFAc3B,CAAA;AAuCD,QAAA,MAAM,cAAc;;8HAgGnB,CAAA;AAGD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,sBAAsB,EAAE,CAAA"}
1
+ {"version":3,"file":"radio-group.d.ts","sourceRoot":"","sources":["../../../components/ui/radio-group.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,mBAAmB,MAAM,6BAA6B,CAAA;AAElE,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAOjE,QAAA,MAAM,UAAU,+JAWd,CAAA;AAGF,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,QAAQ,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAA;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;CACd;AAED,QAAA,MAAM,sBAAsB;;mFAc3B,CAAA;AAuCD,QAAA,MAAM,cAAc;;8HAkGnB,CAAA;AAGD,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,sBAAsB,EAAE,CAAA"}
@@ -17,6 +17,8 @@ import { cva } from "class-variance-authority";
17
17
  import { cn } from "../../lib/utils";
18
18
  import { Icon } from "./icon";
19
19
  import { Text } from "./text";
20
+ import { useTap } from "./tap";
21
+ import { useMergeRefs } from "../hooks/use-merge-refs";
20
22
  const RadioGroup = React.forwardRef((_a, ref) => {
21
23
  var { className } = _a, props = __rest(_a, ["className"]);
22
24
  return (_jsx(RadioGroupPrimitive.Root, Object.assign({ className: cn("grid gap-4", className) }, props, { ref: ref })));
@@ -36,8 +38,10 @@ const radiogroupItemVariants = cva("grid grid-cols-[auto,auto,1fr] gap-2 items-s
36
38
  });
37
39
  const RadioGroupItemLabels = ({ key, label, numberAmount, subtext, }) => (_jsxs("div", Object.assign({ className: "col-span-2" }, { children: [_jsxs("div", Object.assign({ className: "flex flex-row items-start" }, { children: [_jsx(Text, Object.assign({ type: "body-primary", className: "group-disabled:text-stateColors-disabled mr-2" }, { children: label })), numberAmount ? (_jsx(Text, Object.assign({ type: "body-primary", className: "text-textColors-secondaryColor group-disabled:text-stateColors-disabled" }, { children: `(${numberAmount})` }))) : null] })), subtext ? (_jsx(Text, Object.assign({ type: "body-secondary", className: "group-disabled:text-stateColors-disabled mt-2" }, { children: subtext }))) : null] })));
38
40
  const RadioGroupItem = React.forwardRef((_a, ref) => {
39
- var { value, label = "", subtext, numberAmount = 0, onSelect, onClick, selected = false, className, variant = "default", key } = _a, props = __rest(_a, ["value", "label", "subtext", "numberAmount", "onSelect", "onClick", "selected", "className", "variant", "key"]);
40
- return (_jsx("div", Object.assign({ className: cn(radiogroupItemVariants({ variant }), className) }, { children: variant === "deactivated" ? (_jsxs(_Fragment, { children: [_jsx(Icon, { name: "circle-off", size: "md", className: "text-stateColors-disabled" }), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] })) : (_jsx(RadioGroupPrimitive.Item, Object.assign({ ref: ref, value: value, onSelect: onSelect, checked: selected, onClick: onClick, className: cn("flex items-center justify-center active:opacity-70", className) }, props, { children: selected || variant === "selected" ? (_jsxs("div", Object.assign({ className: "grid grid-cols-[auto,auto,1fr] gap-2 items-start group" }, { children: [_jsx(Icon, { name: "circle-dot-filled", size: "md", className: "text-coreColors-brandColorPrimary z-10" }), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] }))) : (_jsxs("div", Object.assign({ className: "grid grid-cols-[auto,auto,1fr] gap-2 items-start group" }, { children: [_jsxs("div", Object.assign({ className: "grid" }, { children: [_jsx(RadioGroupPrimitive.Indicator, Object.assign({ className: "flex items-center justify-center col-start-1 row-start-1" }, { children: _jsx(Icon, { name: "circle-dot-filled", size: "md", className: "text-coreColors-brandColorPrimary z-10" }) })), _jsx("div", Object.assign({ className: "flex items-center justify-center col-start-1 row-start-1" }, { children: _jsx(Icon, { name: "circle", size: "md", className: "col-start-1 row-start-1 text-coreColors-secondaryIcon items-center z-1" }) }))] })), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] }))) }))) })));
41
+ var { value, label = "", subtext, numberAmount = 0, onSelect = () => { }, onClick = () => { }, selected = false, className, variant = "default", key } = _a, props = __rest(_a, ["value", "label", "subtext", "numberAmount", "onSelect", "onClick", "selected", "className", "variant", "key"]);
42
+ const { onTap, ref: tapRef } = useTap();
43
+ const mergedRef = useMergeRefs(ref, tapRef);
44
+ return (_jsx("div", Object.assign({ className: cn(radiogroupItemVariants({ variant }), className) }, { children: variant === "deactivated" ? (_jsxs(_Fragment, { children: [_jsx(Icon, { name: "circle-off", size: "md", className: "text-stateColors-disabled" }), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] })) : (_jsx(RadioGroupPrimitive.Item, Object.assign({ ref: mergedRef, value: value, onSelect: onSelect, checked: selected, onClick: onTap(onClick), className: cn("flex items-center justify-center active:opacity-70", className) }, props, { children: selected || variant === "selected" ? (_jsxs("div", Object.assign({ className: "grid grid-cols-[auto,auto,1fr] gap-2 items-start group" }, { children: [_jsx(Icon, { name: "circle-dot-filled", size: "md", className: "text-coreColors-brandColorPrimary z-10" }), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] }))) : (_jsxs("div", Object.assign({ className: "grid grid-cols-[auto,auto,1fr] gap-2 items-start group" }, { children: [_jsxs("div", Object.assign({ className: "grid" }, { children: [_jsx(RadioGroupPrimitive.Indicator, Object.assign({ className: "flex items-center justify-center col-start-1 row-start-1" }, { children: _jsx(Icon, { name: "circle-dot-filled", size: "md", className: "text-coreColors-brandColorPrimary z-10" }) })), _jsx("div", Object.assign({ className: "flex items-center justify-center col-start-1 row-start-1" }, { children: _jsx(Icon, { name: "circle", size: "md", className: "col-start-1 row-start-1 text-coreColors-secondaryIcon items-center z-1" }) }))] })), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] }))) }))) })));
41
45
  });
42
46
  RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
43
47
  export { RadioGroup, RadioGroupItem, radiogroupItemVariants };
@@ -1 +1 @@
1
- {"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../components/ui/selectors.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,QAAA,MAAM,iBAAiB;;;mFAiBtB,CAAA;AACD,KAAK,cAAc,GAAG,KAAK,CAAC,wBAAwB,CAAC,QAAQ,CAAC,GAC5D,YAAY,CAAC,OAAO,iBAAiB,CAAC,GAAG;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB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M,CAAA;IACd,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,SAAS,CAAA;CAClE,CAAA;AAEH,QAAA,MAAM,SAAS;;;;;;;;;eAHA,MAAM,iBAAiB,CAAC,iBAAiB,CAAC,GAAG,SAAS;2CA6CpE,CAAA;AACD,KAAK,sBAAsB,GAAG;IAC5B,QAAQ,EACJ,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE,GACpC,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,CAAA;IACtC,YAAY,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAA;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AACD,QAAA,MAAM,iBAAiB,EAAE,KAAK,CAAC,EAAE,CAAC,sBAAsB,CA+CvD,CAAA;AAID,OAAO,EAAE,iBAAiB,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAA"}
@@ -15,6 +15,8 @@ import * as React from "react";
15
15
  import { cva } from "class-variance-authority";
16
16
  import { cn } from "../../lib/utils";
17
17
  import { Text } from "./text";
18
+ import { useTap } from "./tap";
19
+ import { useMergeRefs } from "../hooks/use-merge-refs";
18
20
  const selectorsVariants = cva("flex py-2 px-4 whitespace-nowrap bg-coreColors-pageColor flex-row justify-center outline outline-1 rounded text-textColors-primaryColor outline-coreColors-dividingLines items-center", {
19
21
  variants: {
20
22
  selected: {
@@ -31,12 +33,14 @@ const selectorsVariants = cva("flex py-2 px-4 whitespace-nowrap bg-coreColors-pa
31
33
  },
32
34
  });
33
35
  const Selectors = React.forwardRef((_a, ref) => {
34
- var { label, selected, disabled = false, disabledClick = true, className, onSelect, children } = _a, props = __rest(_a, ["label", "selected", "disabled", "disabledClick", "className", "onSelect", "children"]);
35
- return (_jsx("button", Object.assign({ disabled: disabled && disabledClick, onClick: onSelect, className: cn(selectorsVariants({
36
+ var { label, selected, disabled = false, disabledClick = true, className, onSelect = () => { }, children } = _a, props = __rest(_a, ["label", "selected", "disabled", "disabledClick", "className", "onSelect", "children"]);
37
+ const { onTap, ref: tapRef } = useTap();
38
+ const mergedRef = useMergeRefs(ref, tapRef);
39
+ return (_jsx("button", Object.assign({ disabled: disabled && disabledClick, onClick: onTap(onSelect), className: cn(selectorsVariants({
36
40
  selected: selected,
37
41
  className,
38
42
  disabled,
39
- }), "group", className), ref: ref }, props, { children: children ? (children) : (_jsx(Text, Object.assign({ type: "body-primary", color: "text-textColors-primaryColor" }, { children: label }))) })));
43
+ }), "group", className), ref: mergedRef }, props, { children: children ? (children) : (_jsx(Text, Object.assign({ type: "body-primary", color: "text-textColors-primaryColor" }, { children: label }))) })));
40
44
  });
41
45
  const SelectorContainer = ({ children, containerRef, className, height = "42px", }) => {
42
46
  const [showFadeLeft, setShowFadeLeft] = React.useState(false);
@@ -1 +1 @@
1
- {"version":3,"file":"tap.d.ts","sourceRoot":"","sources":["../../../components/ui/tap.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAMZ,SAAS,EACV,MAAM,OAAO,CAAA;AAyFd,QAAA,MAAM,MAAM;6BAyBU,GAAG,KAAK,IAAI,aACb,GAAG;;;CAmBvB,CAAA;AAED,UAAU,QAAQ;IAChB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,QAAA,MAAM,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAuC3B,CAAA;AAED,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAA"}
1
+ {"version":3,"file":"tap.d.ts","sourceRoot":"","sources":["../../../components/ui/tap.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,EAMZ,SAAS,EACV,MAAM,OAAO,CAAA;AAyFd,QAAA,MAAM,MAAM;6BAyBU,GAAG,KAAK,IAAI,aACb,GAAG;;;CA2BvB,CAAA;AAED,UAAU,QAAQ;IAChB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,QAAA,MAAM,GAAG,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAuC3B,CAAA;AAED,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAA"}
@@ -92,11 +92,21 @@ const useTap = (tapThreshold = 10) => {
92
92
  return;
93
93
  if (event.type === "touchend" && !data.touchMoved) {
94
94
  handler(event);
95
- (_a = webbridgeActions.action) === null || _a === void 0 ? void 0 : _a.call(webbridgeActions, "trigger/haptic");
95
+ try {
96
+ (_a = webbridgeActions.action) === null || _a === void 0 ? void 0 : _a.call(webbridgeActions, "trigger/haptic");
97
+ }
98
+ catch (e) {
99
+ console.error(e);
100
+ }
96
101
  }
97
102
  else if (event.type === "click" && !data.touchStarted) {
98
103
  handler(event);
99
- (_b = webbridgeActions.action) === null || _b === void 0 ? void 0 : _b.call(webbridgeActions, "trigger/haptic");
104
+ try {
105
+ (_b = webbridgeActions.action) === null || _b === void 0 ? void 0 : _b.call(webbridgeActions, "trigger/haptic");
106
+ }
107
+ catch (e) {
108
+ console.error(e);
109
+ }
100
110
  setIsPressed(true);
101
111
  setTimeout(() => setIsPressed(false), 100);
102
112
  }
package/dist/styles.css CHANGED
@@ -1010,6 +1010,9 @@ video {
1010
1010
  .h-\[4px\] {
1011
1011
  height: 4px;
1012
1012
  }
1013
+ .h-\[56px\] {
1014
+ height: 56px;
1015
+ }
1013
1016
  .h-\[80vh\] {
1014
1017
  height: 80vh;
1015
1018
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.62",
3
+ "version": "0.7.64",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",
@@ -11,20 +11,6 @@
11
11
  "license": "SEE LICENSE IN LICENSE.md",
12
12
  "author": "Tapcart Inc.",
13
13
  "homepage": "https://tapcart.com",
14
- "scripts": {
15
- "clean": "rm -rf dist node_modules",
16
- "lint": "eslint \"**/*.ts*\"",
17
- "ui:add": "pnpm dlx shadcn-ui@latest add",
18
- "build:styles": "postcss styles/globals.css -o dist/styles.css",
19
- "build:ts": "tsc -p tsconfig.json && tsc-alias",
20
- "build": "pnpm run build:ts && pnpm run build:styles",
21
- "dev:ts": "tsc -w -p tsconfig.json",
22
- "dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
23
- "dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
24
- "test": "jest",
25
- "test:silent": "jest --silent",
26
- "test:watch": "jest --watch"
27
- },
28
14
  "peerDependencies": {
29
15
  "react": "^17.0.2 || ^18.0.0",
30
16
  "react-dom": "^17.0.2 || ^18.0.0"
@@ -37,20 +23,20 @@
37
23
  "@types/pluralize": "^0.0.33",
38
24
  "@types/react": "^18.2.0",
39
25
  "@types/react-dom": "^18.2.0",
40
- "app-studio-types": "workspace:*",
41
26
  "autoprefixer": "^10.4.14",
42
27
  "chokidar-cli": "^3.0.0",
43
28
  "concurrently": "^8.2.2",
44
29
  "eslint": "^7.32.0",
45
- "eslint-config-custom": "workspace:*",
46
30
  "jest": "^29.7.0",
47
31
  "jest-environment-jsdom": "^29.7.0",
48
32
  "postcss": "^8.4.24",
49
33
  "tailwindcss": "^3.3.2",
50
34
  "ts-jest": "^29.2.5",
51
35
  "tsc-alias": "^1.8.10",
52
- "tsconfig": "workspace:*",
53
- "typescript": "^4.5.2"
36
+ "typescript": "^4.5.2",
37
+ "app-studio-types": "0.0.7",
38
+ "tsconfig": "0.0.0",
39
+ "eslint-config-custom": "0.0.0"
54
40
  },
55
41
  "dependencies": {
56
42
  "@radix-ui/react-accordion": "^1.1.2",
@@ -71,7 +57,7 @@
71
57
  "@radix-ui/react-toggle": "^1.0.3",
72
58
  "@radix-ui/react-toggle-group": "^1.0.4",
73
59
  "@tabler/icons-react": "^3.2.0",
74
- "@tapcart/webbridge-react": "^1.14.2",
60
+ "@tapcart/webbridge-react": "^1.15.0",
75
61
  "apple-pay-button": "^1.1.7",
76
62
  "class-variance-authority": "^0.6.0",
77
63
  "clsx": "^1.2.1",
@@ -90,5 +76,19 @@
90
76
  "tailwind-merge": "^1.13.2",
91
77
  "tailwindcss-animate": "^1.0.6",
92
78
  "vaul": "0.9.1"
79
+ },
80
+ "scripts": {
81
+ "clean": "rm -rf dist node_modules",
82
+ "lint": "eslint \"**/*.ts*\"",
83
+ "ui:add": "pnpm dlx shadcn-ui@latest add",
84
+ "build:styles": "postcss styles/globals.css -o dist/styles.css",
85
+ "build:ts": "tsc -p tsconfig.json && tsc-alias",
86
+ "build": "pnpm run build:ts && pnpm run build:styles",
87
+ "dev:ts": "tsc -w -p tsconfig.json",
88
+ "dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
89
+ "dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
90
+ "test": "jest",
91
+ "test:silent": "jest --silent",
92
+ "test:watch": "jest --watch"
93
93
  }
94
- }
94
+ }
@@ -1,16 +0,0 @@
1
- import { EnrichedCart, CartCalculatedDiscount, CartCalculatedAppliedGiftCard } from "app-studio-types";
2
- export declare const isOrderLevelDiscount: (code: string, cart: EnrichedCart) => boolean;
3
- export declare const isLineItemDiscount: (code: string, cart: EnrichedCart) => boolean;
4
- export type CalculatedData = {
5
- orderAndLineItemDiscounts: CartCalculatedDiscount[];
6
- appliedGiftCards: CartCalculatedAppliedGiftCard[];
7
- isFreeShipping: boolean;
8
- discountsTotalAmount: number;
9
- giftCardsTotalAmount: number;
10
- salesAmount: number;
11
- totalCompareAtPrice: number;
12
- totalDiscountedPrice: number;
13
- };
14
- export declare const DEFAULT_CALCULATED_DATA: CalculatedData;
15
- export declare const getData: (cart: EnrichedCart) => CalculatedData;
16
- //# sourceMappingURL=calculated-cart-values.util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"calculated-cart-values.util.d.ts","sourceRoot":"","sources":["../../../../components/libs/cart/calculated-cart-values.util.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,6BAA6B,EAC9B,MAAM,kBAAkB,CAAA;AAuCzB,eAAO,MAAM,oBAAoB,SAAU,MAAM,QAAQ,YAAY,YAGpE,CAAA;AAED,eAAO,MAAM,kBAAkB,SAAU,MAAM,QAAQ,YAAY,YAGlE,CAAA;AAgGD,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,oBAAoB,EAAE,MAAM,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,cASrC,CAAA;AAED,eAAO,MAAM,OAAO,SAAU,YAAY,KAAG,cA4B5C,CAAA"}
@@ -1,144 +0,0 @@
1
- const getOrderLevelDiscounts = (cart) => {
2
- var _a;
3
- const discountMap = (_a = cart.discountAllocations) === null || _a === void 0 ? void 0 : _a.filter((discount) => discount.targetType !== "SHIPPING_LINE").reduce((acc, discount) => {
4
- var _a;
5
- const code = (_a = discount.code) !== null && _a !== void 0 ? _a : "unknown";
6
- if (!acc[code]) {
7
- acc[code] = 0;
8
- }
9
- acc[code] += parseFloat(discount.discountedAmount.amount);
10
- return acc;
11
- }, {});
12
- if (!discountMap)
13
- return [];
14
- return Object.entries(discountMap)
15
- .map(([code, amount]) => ({
16
- id: code,
17
- amount,
18
- name: `Discount - ${code}`,
19
- type: "ORDER_LEVEL",
20
- }))
21
- .filter((discount) => cart.discounts.includes(discount.id));
22
- };
23
- const getShippingDiscounts = (cart) => {
24
- var _a;
25
- if (!(cart === null || cart === void 0 ? void 0 : cart.discountAllocations))
26
- return [];
27
- return (_a = cart.discountAllocations) === null || _a === void 0 ? void 0 : _a.filter((discount) => discount.targetType === "SHIPPING_LINE").map((discount) => ({
28
- amount: discount.discountedAmount.amount,
29
- code: discount.code,
30
- type: discount.targetType,
31
- }));
32
- };
33
- export const isOrderLevelDiscount = (code, cart) => {
34
- const orderLevelDiscounts = getOrderLevelDiscounts(cart);
35
- return orderLevelDiscounts.some((discount) => discount.id === code);
36
- };
37
- export const isLineItemDiscount = (code, cart) => {
38
- const lineItemDiscounts = getLineItemDiscounts(cart);
39
- return lineItemDiscounts.some((discount) => discount.id === code);
40
- };
41
- const getAppliedGiftCards = (cart) => {
42
- var _a;
43
- return (_a = cart.appliedGiftCards) === null || _a === void 0 ? void 0 : _a.map((giftCard) => ({
44
- id: giftCard.id,
45
- amount: +giftCard.amountUsed.amount,
46
- name: `Gift Card - ${giftCard.lastCharacters}`,
47
- }));
48
- };
49
- const getSalesAmount = (cart) => {
50
- var _a;
51
- return (_a = cart.items) === null || _a === void 0 ? void 0 : _a.reduce((acc, item) => {
52
- var _a, _b, _c, _d;
53
- const compareAtPrice = +(((_b = (_a = item.variantDetails) === null || _a === void 0 ? void 0 : _a.compareAtPrice) === null || _b === void 0 ? void 0 : _b.amount) || 0);
54
- const price = +(((_d = (_c = item.variantDetails) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.amount) || 0);
55
- const quantity = item.quantity || 1;
56
- if (compareAtPrice && compareAtPrice > price) {
57
- return acc + (compareAtPrice - price) * quantity;
58
- }
59
- return acc;
60
- }, 0);
61
- };
62
- const getLineItemDiscounts = (cart) => {
63
- var _a, _b;
64
- const discountMap = (_a = cart.items) === null || _a === void 0 ? void 0 : _a.reduce((acc, item) => {
65
- var _a;
66
- (_a = item === null || item === void 0 ? void 0 : item.discounts) === null || _a === void 0 ? void 0 : _a.forEach((discount) => {
67
- const code = discount === null || discount === void 0 ? void 0 : discount.code;
68
- if (!code)
69
- return;
70
- if (!acc[code]) {
71
- acc[code] = { amount: 0, type: discount.type };
72
- }
73
- acc[code].amount += discount.amount;
74
- });
75
- return acc;
76
- }, {});
77
- if (!discountMap)
78
- return [];
79
- return (_b = Object.entries(discountMap)) === null || _b === void 0 ? void 0 : _b.map(([code, { amount, type }]) => ({
80
- id: code,
81
- name: `Discount - ${code}`,
82
- amount,
83
- type,
84
- })).filter((discount) => cart.discounts.includes(discount.id));
85
- };
86
- const getDiscountsTotalAmount = (orderAndLineItemDiscounts) => {
87
- return orderAndLineItemDiscounts === null || orderAndLineItemDiscounts === void 0 ? void 0 : orderAndLineItemDiscounts.reduce((acc, discount) => acc + +discount.amount, 0);
88
- };
89
- const getGiftCardsTotalAmount = (appliedGiftCards) => {
90
- return appliedGiftCards === null || appliedGiftCards === void 0 ? void 0 : appliedGiftCards.reduce((acc, giftCard) => acc + +giftCard.amount, 0);
91
- };
92
- const getTotalCompareAtPrice = (cart) => {
93
- var _a;
94
- return (_a = cart.items) === null || _a === void 0 ? void 0 : _a.reduce((acc, item) => {
95
- var _a, _b, _c, _d;
96
- const compareAtPrice = ((_b = (_a = item.variantDetails) === null || _a === void 0 ? void 0 : _a.compareAtPrice) === null || _b === void 0 ? void 0 : _b.amount) ||
97
- ((_d = (_c = item.variantDetails) === null || _c === void 0 ? void 0 : _c.price) === null || _d === void 0 ? void 0 : _d.amount);
98
- const quantity = item.quantity || 1;
99
- return acc + +(compareAtPrice || 0) * quantity;
100
- }, 0);
101
- };
102
- const getTotalDiscountedPrice = (totalCompareAtPrice, discountsTotalAmount, salesAmount, giftCardsTotalAmount) => {
103
- const total = (totalCompareAtPrice === undefined || isNaN(totalCompareAtPrice)
104
- ? 0
105
- : totalCompareAtPrice) -
106
- (discountsTotalAmount === undefined || isNaN(discountsTotalAmount)
107
- ? 0
108
- : discountsTotalAmount) -
109
- (salesAmount === undefined || isNaN(salesAmount) ? 0 : salesAmount) -
110
- (giftCardsTotalAmount === undefined || isNaN(giftCardsTotalAmount)
111
- ? 0
112
- : giftCardsTotalAmount);
113
- return isNaN(total) ? 0 : total;
114
- };
115
- export const DEFAULT_CALCULATED_DATA = {
116
- orderAndLineItemDiscounts: [],
117
- appliedGiftCards: [],
118
- isFreeShipping: false,
119
- discountsTotalAmount: 0,
120
- salesAmount: 0,
121
- giftCardsTotalAmount: 0,
122
- totalCompareAtPrice: 0,
123
- totalDiscountedPrice: 0,
124
- };
125
- export const getData = (cart) => {
126
- const orderAndLineItemDiscounts = getOrderLevelDiscounts(cart).concat(getLineItemDiscounts(cart));
127
- const appliedGiftCards = getAppliedGiftCards(cart);
128
- const isFreeShipping = getShippingDiscounts(cart).length > 0;
129
- const discountsTotalAmount = getDiscountsTotalAmount(orderAndLineItemDiscounts);
130
- const giftCardsTotalAmount = getGiftCardsTotalAmount(appliedGiftCards);
131
- const salesAmount = getSalesAmount(cart);
132
- const totalCompareAtPrice = getTotalCompareAtPrice(cart);
133
- const totalDiscountedPrice = getTotalDiscountedPrice(totalCompareAtPrice, discountsTotalAmount, salesAmount, giftCardsTotalAmount);
134
- return {
135
- orderAndLineItemDiscounts,
136
- appliedGiftCards,
137
- isFreeShipping,
138
- discountsTotalAmount,
139
- giftCardsTotalAmount,
140
- salesAmount,
141
- totalCompareAtPrice,
142
- totalDiscountedPrice,
143
- };
144
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=calculated-cart-values.util.test.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"calculated-cart-values.util.test.d.ts","sourceRoot":"","sources":["../../../../components/libs/cart/calculated-cart-values.util.test.ts"],"names":[],"mappings":""}
@@ -1,150 +0,0 @@
1
- import { getData } from "./calculated-cart-values.util";
2
- import { DiscountApplicationTargetType } from "app-studio-types";
3
- const baseCartData = {
4
- id: "cart123",
5
- subtotal: 100.0,
6
- currency: "USD",
7
- discounts: [],
8
- attributes: [],
9
- note: "",
10
- items: [],
11
- discountAllocations: [],
12
- appliedGiftCards: [],
13
- delivery: {
14
- addresses: [],
15
- },
16
- deliveryGroups: [],
17
- cost: {
18
- subtotalAmount: { amount: "0", currencyCode: "" },
19
- totalAmount: { amount: "0", currencyCode: "" },
20
- totalTaxAmount: { amount: "0", currencyCode: "" },
21
- },
22
- };
23
- describe("cart-provider.util", () => {
24
- describe("getData", () => {
25
- it("should calculate order level discounts correctly", () => {
26
- const mockCart = Object.assign(Object.assign({}, baseCartData), { discounts: ["DISCOUNT10"], items: [], discountAllocations: [
27
- {
28
- targetType: DiscountApplicationTargetType.LineItem,
29
- discountedAmount: { amount: "10.00", currencyCode: "USD" },
30
- code: "DISCOUNT10",
31
- },
32
- ], appliedGiftCards: [], deliveryGroups: [] });
33
- const result = getData(mockCart);
34
- expect(result.orderAndLineItemDiscounts).toHaveLength(1);
35
- expect(result.orderAndLineItemDiscounts[0]).toEqual({
36
- id: "DISCOUNT10",
37
- amount: 10,
38
- name: "Discount - DISCOUNT10",
39
- type: "ORDER_LEVEL",
40
- });
41
- });
42
- it("should calculate gift cards correctly", () => {
43
- const mockCart = Object.assign(Object.assign({}, baseCartData), { discounts: [], items: [], discountAllocations: [], appliedGiftCards: [
44
- {
45
- id: "giftcard1",
46
- amountUsed: { amount: "25.00", currencyCode: "USD" },
47
- balance: { amount: "75.00", currencyCode: "USD" },
48
- lastCharacters: "1234",
49
- presentmentAmountUsed: { amount: "25.00", currencyCode: "USD" },
50
- },
51
- ], deliveryGroups: [] });
52
- const result = getData(mockCart);
53
- expect(result.appliedGiftCards).toHaveLength(1);
54
- expect(result.appliedGiftCards[0]).toEqual({
55
- id: "giftcard1",
56
- amount: 25,
57
- name: "Gift Card - 1234",
58
- });
59
- });
60
- it("should calculate sales amount correctly", () => {
61
- const mockCart = Object.assign(Object.assign({}, baseCartData), { discounts: [], items: [
62
- {
63
- id: "line1",
64
- quantity: 2,
65
- productId: "prod1",
66
- variantId: "var1",
67
- productDetails: {},
68
- variantDetails: {
69
- compareAtPrice: { amount: "20.00", currencyCode: "USD" },
70
- price: { amount: "15.00", currencyCode: "USD" },
71
- },
72
- discounts: [],
73
- cost: { totalAmount: { amount: "30.00", currencyCode: "USD" } },
74
- },
75
- ], discountAllocations: [], appliedGiftCards: [], deliveryGroups: [] });
76
- const result = getData(mockCart);
77
- expect(result.salesAmount).toBe(10); // (20-15) * 2
78
- });
79
- it("should detect free shipping", () => {
80
- const mockCart = Object.assign(Object.assign({}, baseCartData), { discounts: [], items: [], discountAllocations: [
81
- {
82
- targetType: DiscountApplicationTargetType.ShippingLine,
83
- discountedAmount: { amount: "5.00", currencyCode: "USD" },
84
- code: "FREESHIP",
85
- },
86
- ], appliedGiftCards: [], deliveryGroups: [] });
87
- const result = getData(mockCart);
88
- expect(result.isFreeShipping).toBe(true);
89
- });
90
- it("should calculate total discounted price correctly", () => {
91
- const mockCart = Object.assign(Object.assign({}, baseCartData), { discounts: ["DISCOUNT10"], items: [
92
- {
93
- id: "line1",
94
- quantity: 1,
95
- productId: "prod1",
96
- variantId: "var1",
97
- productDetails: {},
98
- variantDetails: {
99
- compareAtPrice: { amount: "100.00", currencyCode: "USD" },
100
- price: { amount: "80.00", currencyCode: "USD" },
101
- },
102
- discounts: [
103
- {
104
- amount: 10,
105
- type: "LINE_ITEM",
106
- code: "DISCOUNT10",
107
- },
108
- ],
109
- cost: { totalAmount: { amount: "80.00", currencyCode: "USD" } },
110
- },
111
- {
112
- id: "line2",
113
- quantity: 1,
114
- productId: "prod2",
115
- variantId: "var2",
116
- productDetails: {},
117
- variantDetails: {
118
- compareAtPrice: { amount: "100.00", currencyCode: "USD" },
119
- price: { amount: "80.00", currencyCode: "USD" },
120
- },
121
- discounts: [
122
- {
123
- amount: 10,
124
- type: "LINE_ITEM",
125
- code: "DISCOUNT10",
126
- },
127
- ],
128
- cost: { totalAmount: { amount: "80.00", currencyCode: "USD" } },
129
- },
130
- ], discountAllocations: [
131
- {
132
- targetType: DiscountApplicationTargetType.LineItem,
133
- discountedAmount: { amount: "10.00", currencyCode: "USD" },
134
- code: "DISCOUNT10",
135
- },
136
- ], appliedGiftCards: [
137
- {
138
- id: "giftcard1",
139
- amountUsed: { amount: "5.00", currencyCode: "USD" },
140
- balance: { amount: "95.00", currencyCode: "USD" },
141
- lastCharacters: "1234",
142
- presentmentAmountUsed: { amount: "5.00", currencyCode: "USD" },
143
- },
144
- ], deliveryGroups: [] });
145
- const result = getData(mockCart);
146
- // 100 (compare) - 10 (discount) - 20 (sale) - 5 (gift card) = 65
147
- expect(result.totalDiscountedPrice).toBe(125);
148
- });
149
- });
150
- });
@@ -1 +0,0 @@
1
- //# sourceMappingURL=calculatedCartValues.util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"calculatedCartValues.util.d.ts","sourceRoot":"","sources":["../../../../components/libs/cart/calculatedCartValues.util.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";
@@ -1 +0,0 @@
1
- //# sourceMappingURL=cart.util%20copy.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cart.util copy.d.ts","sourceRoot":"","sources":["../../lib/cart.util copy.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- "use strict";