@tapcart/mobile-components 0.19.0 → 0.20.0
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/ui/__tests__/drawer-glass-inset.test.d.ts +2 -0
- package/dist/components/ui/__tests__/drawer-glass-inset.test.d.ts.map +1 -0
- package/dist/components/ui/__tests__/drawer-glass-inset.test.js +84 -0
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/drawer.js +6 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/lib/loyalty.util.d.ts +28 -0
- package/dist/lib/loyalty.util.d.ts.map +1 -0
- package/dist/lib/loyalty.util.js +37 -0
- package/dist/lib/loyalty.util.test.d.ts +2 -0
- package/dist/lib/loyalty.util.test.d.ts.map +1 -0
- package/dist/lib/loyalty.util.test.js +57 -0
- package/dist/styles.css +47 -5
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drawer-glass-inset.test.d.ts","sourceRoot":"","sources":["../../../../components/ui/__tests__/drawer-glass-inset.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as fs from "fs";
|
|
3
|
+
import * as path from "path";
|
|
4
|
+
import { render, screen } from "@testing-library/react";
|
|
5
|
+
import { Drawer, DrawerContentBase } from "../drawer";
|
|
6
|
+
// A bottom sheet portals to <body> and pins itself with `position: fixed;
|
|
7
|
+
// bottom: 0`, so it lives OUTSIDE #tc-vgsl and never receives the frame
|
|
8
|
+
// clearance that element carries. Its bottom cushion is therefore the only
|
|
9
|
+
// thing keeping content off an overlay bottom bar (iOS Liquid Glass).
|
|
10
|
+
//
|
|
11
|
+
// `pb-safe` alone is just env(safe-area-inset-bottom) - the home indicator,
|
|
12
|
+
// not the bar. `tc-pb-frame` is the glass-gated rule in styles/globals.css
|
|
13
|
+
// that raises the cushion to max(env(safe-area-inset-bottom),
|
|
14
|
+
// --tc-frame-bottom). jsdom does not evaluate the cascade, so this asserts the
|
|
15
|
+
// contract the stylesheet keys off; the geometry itself is proven in the
|
|
16
|
+
// browser A/B (qa-evidence/glass-sheet-insets).
|
|
17
|
+
describe("DrawerContentBase bottom-overlay clearance", () => {
|
|
18
|
+
it("carries both the legacy safe cushion and the glass frame cushion", () => {
|
|
19
|
+
render(_jsx(Drawer, Object.assign({ open: true }, { children: _jsx(DrawerContentBase, { children: "content" }) })));
|
|
20
|
+
const sheet = screen.getByTestId("drawer-content");
|
|
21
|
+
expect(sheet.className).toContain("pb-safe");
|
|
22
|
+
expect(sheet.className).toContain("tc-pb-frame");
|
|
23
|
+
});
|
|
24
|
+
it("keeps the cushion when a caller passes its own className", () => {
|
|
25
|
+
render(_jsx(Drawer, Object.assign({ open: true }, { children: _jsx(DrawerContentBase, Object.assign({ className: "bg-red-500" }, { children: "content" })) })));
|
|
26
|
+
const sheet = screen.getByTestId("drawer-content");
|
|
27
|
+
expect(sheet.className).toContain("tc-pb-frame");
|
|
28
|
+
expect(sheet.className).toContain("bg-red-500");
|
|
29
|
+
});
|
|
30
|
+
// FORWARD GUARD, not proof of the glass fix: this assertion is already green
|
|
31
|
+
// on the pre-fix component, because `bottom-0` predates it. It exists to go
|
|
32
|
+
// red if someone later moves the clearance out of padding and into `bottom`.
|
|
33
|
+
it("stays anchored to the bottom edge instead of floating above the bar", () => {
|
|
34
|
+
// The clearance must live in padding, not in `bottom`: the sheet surface
|
|
35
|
+
// keeps bleeding to the physical bottom edge the way a native sheet does,
|
|
36
|
+
// and only its CONTENT is lifted. A `bottom` offset would leave a strip of
|
|
37
|
+
// backdrop under the sheet.
|
|
38
|
+
render(_jsx(Drawer, Object.assign({ open: true }, { children: _jsx(DrawerContentBase, { children: "content" }) })));
|
|
39
|
+
const sheet = screen.getByTestId("drawer-content");
|
|
40
|
+
expect(sheet.className).toContain("bottom-0");
|
|
41
|
+
expect(sheet.style.bottom).toBe("");
|
|
42
|
+
});
|
|
43
|
+
// The two assertions above only pin the class NAME. jest has no CSS
|
|
44
|
+
// transform and the component imports no stylesheet, so deleting or renaming
|
|
45
|
+
// the rule in styles/globals.css would leave them green while the clearance
|
|
46
|
+
// silently stopped existing. This closes that drift: it reads the AUTHORED
|
|
47
|
+
// stylesheet (styles/globals.css) and checks a rule really is keyed to the
|
|
48
|
+
// class the component emits, with the right variable in it.
|
|
49
|
+
//
|
|
50
|
+
// Source, not dist/: dist/styles.css is gitignored and only exists after a
|
|
51
|
+
// build, so asserting against it would make this test pass or fail on build
|
|
52
|
+
// state rather than on the committed CSS. The build step for this file is
|
|
53
|
+
// postcss with no selector rewriting, so source and shipped agree - but the
|
|
54
|
+
// guard is on the input, and a transform that ever changed that would slip
|
|
55
|
+
// past it.
|
|
56
|
+
it("has a stylesheet rule keyed to the class the component emits", () => {
|
|
57
|
+
render(_jsx(Drawer, Object.assign({ open: true }, { children: _jsx(DrawerContentBase, { children: "content" }) })));
|
|
58
|
+
const emitted = screen
|
|
59
|
+
.getByTestId("drawer-content")
|
|
60
|
+
.className.split(/\s+/)
|
|
61
|
+
.find((c) => c === "tc-pb-frame");
|
|
62
|
+
expect(emitted).toBe("tc-pb-frame");
|
|
63
|
+
const css = fs
|
|
64
|
+
.readFileSync(path.join(__dirname, "../../../styles/globals.css"), "utf8")
|
|
65
|
+
// Comments in this file quote CSS ("pin themselves with position: fixed;
|
|
66
|
+
// bottom: 0"), which would otherwise be read as declarations below.
|
|
67
|
+
.replace(/\/\*[\s\S]*?\*\//g, "");
|
|
68
|
+
// Whole selector token: a substring match would still find the class
|
|
69
|
+
// inside a renamed `.tc-pb-frame-something`, which is exactly the drift
|
|
70
|
+
// this test exists to catch.
|
|
71
|
+
const selector = new RegExp(`\\.${emitted}(?![\\w-])`);
|
|
72
|
+
const rule = css
|
|
73
|
+
.split("}")
|
|
74
|
+
.map((block) => block + "}")
|
|
75
|
+
.find((block) => selector.test(block) && block.includes("padding-bottom"));
|
|
76
|
+
expect(rule).toBeDefined();
|
|
77
|
+
// Glass-gated, and reading the frame inset rather than a hardcoded value.
|
|
78
|
+
expect(rule).toContain("tc-glass");
|
|
79
|
+
expect(rule).toContain("--tc-frame-bottom");
|
|
80
|
+
// Clearance lives in padding, never in `bottom`. Anchored to a declaration
|
|
81
|
+
// start so it does not also match the `bottom` inside `padding-bottom`.
|
|
82
|
+
expect(rule).not.toMatch(/[;{]\s*bottom:/);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -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;C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ASrB,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,WAAW,EACX,iBAAiB,EACjB,YAAY,GACb,CAAA"}
|
|
@@ -51,7 +51,12 @@ const DrawerContentBase = React.forwardRef((_a, ref) => {
|
|
|
51
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: Object.assign(Object.assign({}, baseStyles), style), className: cn(
|
|
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(
|
|
55
|
+
// tc-pb-frame: bottom-overlay (iOS Liquid Glass) clearance. The
|
|
56
|
+
// sheet is viewport-anchored, so it never inherits #tc-vgsl's
|
|
57
|
+
// --tc-frame-bottom padding; see styles/globals.css. Inert off
|
|
58
|
+
// glass, where pb-safe alone stays authoritative.
|
|
59
|
+
"fixed inset-x-0 bottom-0 z-50 flex h-auto flex-col rounded-t-2xl bg-coreColors-modalBackground pb-safe tc-pb-frame", 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
60
|
});
|
|
56
61
|
DrawerContentBase.displayName = "DrawerContentBase";
|
|
57
62
|
const DrawerHeaderBase = (_a) => {
|
package/dist/core/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type { DataSource } from "../lib/get-data";
|
|
|
5
5
|
export { getDestinationHandler, getEnabledWishlistIntegration, getGridSpacing, getIdFromGid, getInputPlaceholderTextProps, getLoyaltyButtonProps, getMarginStyle, getOverlayStyle, getPaddingStyle, getProductGidsFromIds, getSpaceBetween, getTextStyle, getVariantGidsFromIds, getVerticalAlignment, getVerticalAlignmentStyle, getWishlistAddItemNavigation, isFavoriteIntegrationEnabled, isVideo, mapFlexToAlignment, parsePhoneNumber, pluralize, productGidFromId, removeItemFromWishlists, stringRatioToInt, supportedVideoExtensions, supportsMultipleWishlists, throttleFunction, variantGidFromId, formatFrequency, formatPrice, shareContent, } from "../lib/utils";
|
|
6
6
|
export type { WishlistEntryMatch } from "../lib/utils";
|
|
7
7
|
export * from "../lib/cart.util";
|
|
8
|
+
export * from "../lib/loyalty.util";
|
|
8
9
|
export * from "../lib/discountAllocation.util";
|
|
9
10
|
export * from "../lib/variablesCart.util";
|
|
10
11
|
export * from "../lib/isTapcartVersion20.util";
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../core/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,EAAE,EACF,wBAAwB,EACxB,GAAG,EACH,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,E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CAAA;AACzC,cAAc,kCAAkC,CAAA;AAChD,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,mDAAmD,CAAA;AACjE,cAAc,iCAAiC,CAAA;AAC/C,cAAc,mCAAmC,CAAA;AACjD,cAAc,sCAAsC,CAAA;AACpD,cAAc,qCAAqC,CAAA;AACnD,cAAc,oCAAoC,CAAA;AAClD,cAAc,cAAc,CAAA;AAC5B,cAAc,8CAA8C,CAAA;AAC5D,cAAc,mDAAmD,CAAA;AACjE,cAAc,sBAAsB,CAAA;AACpC,cAAc,oCAAoC,CAAA;AAClD,cAAc,sCAAsC,CAAA;AACpD,cAAc,yBAAyB,CAAA;AACvC,cAAc,4BAA4B,CAAA;AAC1C,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,+CAA+C,CAAA"}
|
package/dist/core/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { toHtml } from "../lib/to-html";
|
|
|
4
4
|
export { getData } from "../lib/get-data";
|
|
5
5
|
export { getDestinationHandler, getEnabledWishlistIntegration, getGridSpacing, getIdFromGid, getInputPlaceholderTextProps, getLoyaltyButtonProps, getMarginStyle, getOverlayStyle, getPaddingStyle, getProductGidsFromIds, getSpaceBetween, getTextStyle, getVariantGidsFromIds, getVerticalAlignment, getVerticalAlignmentStyle, getWishlistAddItemNavigation, isFavoriteIntegrationEnabled, isVideo, mapFlexToAlignment, parsePhoneNumber, pluralize, productGidFromId, removeItemFromWishlists, stringRatioToInt, supportedVideoExtensions, supportsMultipleWishlists, throttleFunction, variantGidFromId, formatFrequency, formatPrice, shareContent, } from "../lib/utils";
|
|
6
6
|
export * from "../lib/cart.util";
|
|
7
|
+
export * from "../lib/loyalty.util";
|
|
7
8
|
export * from "../lib/discountAllocation.util";
|
|
8
9
|
export * from "../lib/variablesCart.util";
|
|
9
10
|
export * from "../lib/isTapcartVersion20.util";
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export type { DataSource } from "./lib/get-data";
|
|
|
5
5
|
export { getDestinationHandler, getEnabledWishlistIntegration, getGridSpacing, getIdFromGid, getInputPlaceholderTextProps, getLoyaltyButtonProps, getMarginStyle, getOverlayStyle, getPaddingStyle, getProductGidsFromIds, getSpaceBetween, getTextStyle, getVariantGidsFromIds, getVerticalAlignment, getVerticalAlignmentStyle, getWishlistAddItemNavigation, isFavoriteIntegrationEnabled, isVideo, mapFlexToAlignment, parsePhoneNumber, pluralize, productGidFromId, removeItemFromWishlists, stringRatioToInt, supportedVideoExtensions, supportsMultipleWishlists, throttleFunction, variantGidFromId, formatFrequency, formatPrice, shareContent, } from "./lib/utils";
|
|
6
6
|
export type { WishlistEntryMatch } from "./lib/utils";
|
|
7
7
|
export * from "./lib/cart.util";
|
|
8
|
+
export * from "./lib/loyalty.util";
|
|
8
9
|
export * from "./lib/discountAllocation.util";
|
|
9
10
|
export * from "./lib/variablesCart.util";
|
|
10
11
|
export * from "./lib/isTapcartVersion20.util";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,EAAE,EACF,wBAAwB,EACxB,GAAG,EACH,kBAAkB,EAClB,4BAA4B,EAC5B,4BAA4B,EAC5B,qBAAqB,EACrB,mBAAmB,EACnB,cAAc,EACd,QAAQ,GACT,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAA;AACxC,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,cAAc,EACd,YAAY,EACZ,4BAA4B,EAC5B,qBAAqB,EACrB,cAAc,EACd,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,YAAY,EACZ,qBAAqB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,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;AACtC,cAAc,2BAA2B,CAAA;AACzC,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,8CAA8C,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { toHtml } from "./lib/to-html";
|
|
|
4
4
|
export { getData } from "./lib/get-data";
|
|
5
5
|
export { getDestinationHandler, getEnabledWishlistIntegration, getGridSpacing, getIdFromGid, getInputPlaceholderTextProps, getLoyaltyButtonProps, getMarginStyle, getOverlayStyle, getPaddingStyle, getProductGidsFromIds, getSpaceBetween, getTextStyle, getVariantGidsFromIds, getVerticalAlignment, getVerticalAlignmentStyle, getWishlistAddItemNavigation, isFavoriteIntegrationEnabled, isVideo, mapFlexToAlignment, parsePhoneNumber, pluralize, productGidFromId, removeItemFromWishlists, stringRatioToInt, supportedVideoExtensions, supportsMultipleWishlists, throttleFunction, variantGidFromId, formatFrequency, formatPrice, shareContent, } from "./lib/utils";
|
|
6
6
|
export * from "./lib/cart.util";
|
|
7
|
+
export * from "./lib/loyalty.util";
|
|
7
8
|
export * from "./lib/discountAllocation.util";
|
|
8
9
|
export * from "./lib/variablesCart.util";
|
|
9
10
|
export * from "./lib/isTapcartVersion20.util";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
type CartAttribute = {
|
|
2
|
+
key: string;
|
|
3
|
+
value: string;
|
|
4
|
+
};
|
|
5
|
+
type CartLineItem = {
|
|
6
|
+
attributes?: Record<string, string> | CartAttribute[];
|
|
7
|
+
};
|
|
8
|
+
type Cart = {
|
|
9
|
+
items?: CartLineItem[];
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Points the shopper can still spend: the provider balance less anything
|
|
13
|
+
* already committed to reward lines in the cart.
|
|
14
|
+
*
|
|
15
|
+
* Yotpo deducts nothing at redemption time for free-product rewards, because
|
|
16
|
+
* loyalty-core sends `delay_points_deduction: true`. Their balance keeps
|
|
17
|
+
* reporting the pre-redemption figure until the order reaches them, and their
|
|
18
|
+
* Create Redemption endpoint checks sufficiency against that same unmoved
|
|
19
|
+
* number, so it approves every repeat. The cart is the only record of what has
|
|
20
|
+
* been claimed, via the attributes the adapter stamps on each reward line.
|
|
21
|
+
*
|
|
22
|
+
* Counted once per line, never multiplied by quantity: `_swell_points_used` is
|
|
23
|
+
* the cost of one redemption, and raising a line's quantity in the cart creates
|
|
24
|
+
* no second redemption to charge for.
|
|
25
|
+
*/
|
|
26
|
+
export declare const getSpendableLoyaltyPoints: (balance?: number, cart?: Cart) => number | undefined;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=loyalty.util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loyalty.util.d.ts","sourceRoot":"","sources":["../../lib/loyalty.util.ts"],"names":[],"mappings":"AAAA,KAAK,aAAa,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnD,KAAK,YAAY,GAAG;IAOlB,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,aAAa,EAAE,CAAA;CACtD,CAAA;AAED,KAAK,IAAI,GAAG;IACV,KAAK,CAAC,EAAE,YAAY,EAAE,CAAA;CACvB,CAAA;AAUD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,aAC1B,MAAM,SACT,IAAI,KACV,MAAM,GAAG,SAgBX,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
const readAttribute = (attributes, key) => {
|
|
2
|
+
var _a;
|
|
3
|
+
return Array.isArray(attributes)
|
|
4
|
+
? (_a = attributes.find((attribute) => (attribute === null || attribute === void 0 ? void 0 : attribute.key) === key)) === null || _a === void 0 ? void 0 : _a.value
|
|
5
|
+
: attributes === null || attributes === void 0 ? void 0 : attributes[key];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Points the shopper can still spend: the provider balance less anything
|
|
9
|
+
* already committed to reward lines in the cart.
|
|
10
|
+
*
|
|
11
|
+
* Yotpo deducts nothing at redemption time for free-product rewards, because
|
|
12
|
+
* loyalty-core sends `delay_points_deduction: true`. Their balance keeps
|
|
13
|
+
* reporting the pre-redemption figure until the order reaches them, and their
|
|
14
|
+
* Create Redemption endpoint checks sufficiency against that same unmoved
|
|
15
|
+
* number, so it approves every repeat. The cart is the only record of what has
|
|
16
|
+
* been claimed, via the attributes the adapter stamps on each reward line.
|
|
17
|
+
*
|
|
18
|
+
* Counted once per line, never multiplied by quantity: `_swell_points_used` is
|
|
19
|
+
* the cost of one redemption, and raising a line's quantity in the cart creates
|
|
20
|
+
* no second redemption to charge for.
|
|
21
|
+
*/
|
|
22
|
+
export const getSpendableLoyaltyPoints = (balance, cart) => {
|
|
23
|
+
var _a;
|
|
24
|
+
// Loyalty data arrives after the first render, so the balance is briefly
|
|
25
|
+
// absent. Hand that back untouched rather than coercing it: the blocks render
|
|
26
|
+
// nothing for undefined, which is what they showed before this calculation
|
|
27
|
+
// existed. Any number here would invent a balance the shopper does not have.
|
|
28
|
+
if (balance == null)
|
|
29
|
+
return undefined;
|
|
30
|
+
const committed = ((_a = cart === null || cart === void 0 ? void 0 : cart.items) !== null && _a !== void 0 ? _a : []).reduce((total, item) => {
|
|
31
|
+
const attributes = item === null || item === void 0 ? void 0 : item.attributes;
|
|
32
|
+
if (!readAttribute(attributes, "_swell_redemption_id"))
|
|
33
|
+
return total;
|
|
34
|
+
return (total + (Number(readAttribute(attributes, "_swell_points_used")) || 0));
|
|
35
|
+
}, 0);
|
|
36
|
+
return Math.max(0, balance - committed);
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loyalty.util.test.d.ts","sourceRoot":"","sources":["../../lib/loyalty.util.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { getSpendableLoyaltyPoints } from "./loyalty.util";
|
|
2
|
+
const rewardLine = (redemptionId, pointsUsed) => ({
|
|
3
|
+
attributes: {
|
|
4
|
+
_swell_redemption_id: redemptionId,
|
|
5
|
+
_swell_points_used: pointsUsed,
|
|
6
|
+
_swell_redemption_token: "tok",
|
|
7
|
+
_swell_discount_type: "product",
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
const paidLine = { attributes: {} };
|
|
11
|
+
describe("getSpendableLoyaltyPoints", () => {
|
|
12
|
+
it("returns the balance when the cart holds no reward lines", () => {
|
|
13
|
+
expect(getSpendableLoyaltyPoints(2592, { items: [paidLine] })).toBe(2592);
|
|
14
|
+
});
|
|
15
|
+
it("reads the array attribute shape identically", () => {
|
|
16
|
+
// `cart.lines[]` and the enriched cart from useCart() keep Shopify's array
|
|
17
|
+
// form, while the SDK normalizes `cart.items[]` into a keyed object. Both
|
|
18
|
+
// must produce the same answer, or passing the wrong cart silently reports
|
|
19
|
+
// zero committed and the over-redemption bug returns.
|
|
20
|
+
const asObject = { items: [rewardLine("1", "1000")] };
|
|
21
|
+
const asArray = {
|
|
22
|
+
items: [
|
|
23
|
+
{
|
|
24
|
+
attributes: [
|
|
25
|
+
{ key: "_swell_redemption_id", value: "1" },
|
|
26
|
+
{ key: "_swell_points_used", value: "1000" },
|
|
27
|
+
],
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
expect(getSpendableLoyaltyPoints(2592, asArray)).toBe(getSpendableLoyaltyPoints(2592, asObject));
|
|
32
|
+
expect(getSpendableLoyaltyPoints(2592, asArray)).toBe(1592);
|
|
33
|
+
});
|
|
34
|
+
it("subtracts a single reward line", () => {
|
|
35
|
+
const cart = { items: [rewardLine("1", "1000"), paidLine] };
|
|
36
|
+
expect(getSpendableLoyaltyPoints(2592, cart)).toBe(1592);
|
|
37
|
+
});
|
|
38
|
+
it("subtracts every reward line, including the same reward twice", () => {
|
|
39
|
+
const cart = { items: [rewardLine("1", "1000"), rewardLine("2", "1000")] };
|
|
40
|
+
expect(getSpendableLoyaltyPoints(2592, cart)).toBe(592);
|
|
41
|
+
});
|
|
42
|
+
it("ignores a reward line whose points cost is missing", () => {
|
|
43
|
+
// The adapter writes `_swell_points_used` from `reward?.pointsCost`, so a
|
|
44
|
+
// reward with no cost leaves the attribute off the line entirely.
|
|
45
|
+
const cart = { items: [{ attributes: { _swell_redemption_id: "1" } }] };
|
|
46
|
+
expect(getSpendableLoyaltyPoints(2592, cart)).toBe(2592);
|
|
47
|
+
});
|
|
48
|
+
it("returns undefined before loyalty data has loaded", () => {
|
|
49
|
+
// The blocks render nothing for undefined, which is what they showed before
|
|
50
|
+
// this calculation existed.
|
|
51
|
+
expect(getSpendableLoyaltyPoints(undefined, undefined)).toBeUndefined();
|
|
52
|
+
});
|
|
53
|
+
it("clamps at zero rather than going negative", () => {
|
|
54
|
+
const cart = { items: [rewardLine("1", "1000"), rewardLine("2", "1000")] };
|
|
55
|
+
expect(getSpendableLoyaltyPoints(600, cart)).toBe(0);
|
|
56
|
+
});
|
|
57
|
+
});
|
package/dist/styles.css
CHANGED
|
@@ -2336,6 +2336,10 @@ video {
|
|
|
2336
2336
|
--tw-bg-opacity: 1;
|
|
2337
2337
|
background-color: rgb(254 226 226 / var(--tw-bg-opacity, 1));
|
|
2338
2338
|
}
|
|
2339
|
+
.bg-red-500 {
|
|
2340
|
+
--tw-bg-opacity: 1;
|
|
2341
|
+
background-color: rgb(239 68 68 / var(--tw-bg-opacity, 1));
|
|
2342
|
+
}
|
|
2339
2343
|
.bg-stateColors-disabled {
|
|
2340
2344
|
background-color: var(--stateColors-disabled);
|
|
2341
2345
|
}
|
|
@@ -3395,10 +3399,17 @@ body::-webkit-scrollbar {
|
|
|
3395
3399
|
* home indicator) dedupe instead of double-counting.
|
|
3396
3400
|
*/
|
|
3397
3401
|
|
|
3398
|
-
/* SLIM SCOPE — bottom-overlay iOS adapter only. Top-edge, cutout
|
|
3399
|
-
--tc-content-*
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
+
/* SLIM SCOPE — bottom-overlay iOS adapter only. Top-edge, cutout and the
|
|
3403
|
+
generalized --tc-content-* var API are deferred to Insets V2. Everything here
|
|
3404
|
+
is inert unless the shell reports an overlay bottom bar (.tc-glass; see the
|
|
3405
|
+
gated block below).
|
|
3406
|
+
|
|
3407
|
+
Drawer clearance is NO LONGER part of that deferral. #3407 deferred "drawer
|
|
3408
|
+
APIs" on the rationale that they had zero consumers; that rationale expired
|
|
3409
|
+
once bottom sheets were found painting behind the bar on 22 block templates
|
|
3410
|
+
plus the quickadd and wishlist modals. What landed is one narrow utility
|
|
3411
|
+
class (.tc-pb-frame, at the end of this file) consumed by DrawerContentBase —
|
|
3412
|
+
NOT the generalized drawer var API, which stays deferred. */
|
|
3402
3413
|
|
|
3403
3414
|
/* --tc-bar-bottom is @property-registered so the hide-on-scroll bar collapse
|
|
3404
3415
|
animates smoothly (300ms native bar). */
|
|
@@ -3457,6 +3468,38 @@ body::-webkit-scrollbar {
|
|
|
3457
3468
|
var(--tc-bar-bottom, 0px)
|
|
3458
3469
|
);
|
|
3459
3470
|
}
|
|
3471
|
+
|
|
3472
|
+
/* Bottom cushion for VIEWPORT-ANCHORED overlays (bottom sheets / drawers).
|
|
3473
|
+
These portal to <body> and pin themselves with `position: fixed; bottom: 0`,
|
|
3474
|
+
so they sit outside #tc-vgsl and never receive the frame clearance it carries
|
|
3475
|
+
(--tc-frame-bottom-gated on the native path, --tc-frame-bottom in web mode;
|
|
3476
|
+
see apps/tapcart-ssr-app/app/layout.tsx). Under an overlay bottom bar their
|
|
3477
|
+
last row of content therefore paints behind the bar.
|
|
3478
|
+
|
|
3479
|
+
This rule reads the NON-gated --tc-frame-bottom on purpose. #tc-vgsl needs
|
|
3480
|
+
the gated variant so it goes IACVT-invalid and collapses to 0 on a shell that
|
|
3481
|
+
never wrote --tc-safe-bottom, leaving the legacy RN bridge authoritative over
|
|
3482
|
+
the same element. Nothing competes for this padding, and the injection script
|
|
3483
|
+
writes --tc-safe-bottom and --tc-bar-bottom-glass together, so under .tc-glass
|
|
3484
|
+
the two variants are equal anyway; the non-gated one additionally keeps the
|
|
3485
|
+
env()/--rn-* fallback chain alive.
|
|
3486
|
+
|
|
3487
|
+
The sheet's own surface should keep bleeding to the physical bottom edge
|
|
3488
|
+
(native sheets do), so the clearance goes into padding and lifts the CONTENT
|
|
3489
|
+
instead of floating the whole sheet. max() against the pre-PR env() cushion
|
|
3490
|
+
keeps the two from double-counting when the bar hides on scroll and
|
|
3491
|
+
--tc-frame-bottom collapses to the safe area.
|
|
3492
|
+
|
|
3493
|
+
Gated on .tc-glass: on every non-glass shell this rule never matches and the
|
|
3494
|
+
element's existing `pb-safe` stays byte-for-byte authoritative.
|
|
3495
|
+
|
|
3496
|
+
Specificity note: this is (0,4,0), well above a Tailwind pb-* utility, and
|
|
3497
|
+
tailwind-merge does not treat `tc-pb-frame` as a padding-bottom conflict. A
|
|
3498
|
+
caller passing `pb-0`/`p-0` to DrawerContentBase would therefore keep the
|
|
3499
|
+
cushion under glass and lose it everywhere else. No caller does today. */
|
|
3500
|
+
:root.tc-platform-ios.tc-glass .tc-pb-frame {
|
|
3501
|
+
padding-bottom: max(env(safe-area-inset-bottom), var(--tc-frame-bottom, 0px));
|
|
3502
|
+
}
|
|
3460
3503
|
.file\:border-0::file-selector-button {
|
|
3461
3504
|
border-width: 0px;
|
|
3462
3505
|
}
|
|
@@ -3949,4 +3992,3 @@ body::-webkit-scrollbar {
|
|
|
3949
3992
|
.\[\&_p\]\:text-stateColors-disabled p {
|
|
3950
3993
|
color: var(--stateColors-disabled);
|
|
3951
3994
|
}
|
|
3952
|
-
|