@tapcart/mobile-components 0.15.2 → 0.16.1
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/core/button.d.ts +37 -0
- package/dist/components/core/button.d.ts.map +1 -0
- package/dist/components/core/button.js +44 -0
- package/dist/components/core/html.d.ts +15 -0
- package/dist/components/core/html.d.ts.map +1 -0
- package/dist/components/core/html.js +45 -0
- package/dist/components/core/text.d.ts +29 -0
- package/dist/components/core/text.d.ts.map +1 -0
- package/dist/components/core/text.js +88 -0
- package/dist/components/hooks/use-nosto-recommendation.d.ts +4 -0
- package/dist/components/hooks/use-nosto-recommendation.d.ts.map +1 -1
- package/dist/components/hooks/use-nosto-recommendation.js +116 -23
- package/dist/components/hooks/use-nosto-recommendation.queries.d.ts +0 -1
- package/dist/components/hooks/use-nosto-recommendation.queries.d.ts.map +1 -1
- package/dist/components/hooks/use-nosto-recommendation.queries.js +0 -3
- package/dist/components/hooks/use-nosto-recommendation.test.js +168 -171
- package/dist/components/hooks/use-products.d.ts.map +1 -1
- package/dist/components/hooks/use-products.js +24 -4
- package/dist/components/hooks/use-products.test.d.ts +2 -0
- package/dist/components/hooks/use-products.test.d.ts.map +1 -0
- package/dist/components/hooks/use-products.test.js +129 -0
- package/dist/components/hooks/use-search-analytics-open-product.d.ts +3 -2
- package/dist/components/hooks/use-search-analytics-open-product.d.ts.map +1 -1
- package/dist/components/libs/cache/ProductsLocalStorage.d.ts.map +1 -1
- package/dist/components/libs/cache/ProductsLocalStorage.js +32 -0
- package/dist/components/libs/cache/ProductsLocalStorage.test.d.ts +2 -0
- package/dist/components/libs/cache/ProductsLocalStorage.test.d.ts.map +1 -0
- package/dist/components/libs/cache/ProductsLocalStorage.test.js +110 -0
- package/dist/core/index.d.ts +99 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +98 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/lib/get-data.d.ts +27 -0
- package/dist/lib/get-data.d.ts.map +1 -0
- package/dist/lib/get-data.js +65 -0
- package/dist/lib/get-data.test.d.ts +2 -0
- package/dist/lib/get-data.test.d.ts.map +1 -0
- package/dist/lib/get-data.test.js +74 -0
- package/dist/lib/to-html.d.ts +9 -0
- package/dist/lib/to-html.d.ts.map +1 -0
- package/dist/lib/to-html.js +102 -0
- package/dist/styles.css +6 -0
- package/package.json +1 -1
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { act, renderHook, waitFor } from "@testing-library/react";
|
|
12
|
+
import { SWRConfig } from "swr";
|
|
13
|
+
import ProductsLocalStorage from "../libs/cache/ProductsLocalStorage";
|
|
14
|
+
import { useProducts } from "./use-products";
|
|
15
|
+
const productId = "gid://shopify/Product/1";
|
|
16
|
+
const hydratedSellingPlanGroups = {
|
|
17
|
+
edges: [
|
|
18
|
+
{
|
|
19
|
+
node: {
|
|
20
|
+
id: "group-1",
|
|
21
|
+
sellingPlans: {
|
|
22
|
+
edges: [
|
|
23
|
+
{
|
|
24
|
+
node: {
|
|
25
|
+
id: "plan-1",
|
|
26
|
+
priceAdjustments: [
|
|
27
|
+
{ adjustmentValue: { adjustmentPercentage: 10 } },
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
37
|
+
const wrapper = ({ children }) => (_jsx(SWRConfig, Object.assign({ value: {
|
|
38
|
+
provider: () => new Map(),
|
|
39
|
+
dedupingInterval: 0,
|
|
40
|
+
} }, { children: children })));
|
|
41
|
+
describe("useProducts", () => {
|
|
42
|
+
let originalFetch;
|
|
43
|
+
beforeEach(() => {
|
|
44
|
+
originalFetch = global.fetch;
|
|
45
|
+
localStorage.clear();
|
|
46
|
+
jest.restoreAllMocks();
|
|
47
|
+
});
|
|
48
|
+
afterEach(() => {
|
|
49
|
+
global.fetch = originalFetch;
|
|
50
|
+
});
|
|
51
|
+
it("renders the merged cached product when a fetch returns partial selling plans", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
var _a;
|
|
53
|
+
const cache = new ProductsLocalStorage();
|
|
54
|
+
cache.setCacheItem({
|
|
55
|
+
id: productId,
|
|
56
|
+
handle: "subscription-product",
|
|
57
|
+
title: "Cached product",
|
|
58
|
+
sellingPlanGroups: hydratedSellingPlanGroups,
|
|
59
|
+
});
|
|
60
|
+
const fetchMock = jest.fn().mockResolvedValue({
|
|
61
|
+
json: jest.fn().mockResolvedValue([
|
|
62
|
+
{
|
|
63
|
+
id: productId,
|
|
64
|
+
handle: "subscription-product",
|
|
65
|
+
title: "Network product",
|
|
66
|
+
sellingPlanGroups: {
|
|
67
|
+
edges: [
|
|
68
|
+
{
|
|
69
|
+
node: {
|
|
70
|
+
id: "group-1",
|
|
71
|
+
sellingPlans: {
|
|
72
|
+
edges: [{ node: { id: "plan-1" } }],
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
]),
|
|
80
|
+
});
|
|
81
|
+
global.fetch = fetchMock;
|
|
82
|
+
const { result } = renderHook(() => useProducts({
|
|
83
|
+
baseURL: "https://example.test",
|
|
84
|
+
productIds: [productId],
|
|
85
|
+
}), { wrapper });
|
|
86
|
+
yield waitFor(() => expect(fetchMock).toHaveBeenCalled());
|
|
87
|
+
yield waitFor(() => { var _a; return expect((_a = result.current.products[0]) === null || _a === void 0 ? void 0 : _a.title).toBe("Network product"); });
|
|
88
|
+
expect((_a = result.current.products[0]) === null || _a === void 0 ? void 0 : _a.sellingPlanGroups).toEqual(hydratedSellingPlanGroups);
|
|
89
|
+
}));
|
|
90
|
+
it("clears the previous product while a new product identity resolves", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
|
+
let resolveProductB = () => { };
|
|
92
|
+
const productBResponse = new Promise((resolve) => {
|
|
93
|
+
resolveProductB = resolve;
|
|
94
|
+
});
|
|
95
|
+
const fetcher = jest
|
|
96
|
+
.fn()
|
|
97
|
+
.mockResolvedValueOnce([
|
|
98
|
+
{
|
|
99
|
+
id: "gid://shopify/Product/A",
|
|
100
|
+
handle: "product-a",
|
|
101
|
+
title: "Product A",
|
|
102
|
+
},
|
|
103
|
+
])
|
|
104
|
+
.mockReturnValueOnce(productBResponse);
|
|
105
|
+
const { result, rerender } = renderHook(({ productId }) => useProducts({
|
|
106
|
+
baseURL: "https://example.test",
|
|
107
|
+
productIds: [productId],
|
|
108
|
+
fetcher,
|
|
109
|
+
}), {
|
|
110
|
+
initialProps: { productId: "gid://shopify/Product/A" },
|
|
111
|
+
wrapper,
|
|
112
|
+
});
|
|
113
|
+
yield waitFor(() => { var _a; return expect((_a = result.current.products[0]) === null || _a === void 0 ? void 0 : _a.title).toBe("Product A"); });
|
|
114
|
+
rerender({ productId: "gid://shopify/Product/B" });
|
|
115
|
+
expect(result.current.products).toEqual([]);
|
|
116
|
+
expect(result.current.isLoading).toBe(true);
|
|
117
|
+
yield act(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
118
|
+
resolveProductB([
|
|
119
|
+
{
|
|
120
|
+
id: "gid://shopify/Product/B",
|
|
121
|
+
handle: "product-b",
|
|
122
|
+
title: "Product B",
|
|
123
|
+
},
|
|
124
|
+
]);
|
|
125
|
+
yield productBResponse;
|
|
126
|
+
}));
|
|
127
|
+
yield waitFor(() => { var _a; return expect((_a = result.current.products[0]) === null || _a === void 0 ? void 0 : _a.title).toBe("Product B"); });
|
|
128
|
+
}));
|
|
129
|
+
});
|
|
@@ -100,8 +100,9 @@ interface UseSearchAnalyticsImpressionParams {
|
|
|
100
100
|
emitProductImpression?: (payload: EmitProductInteractionPayload) => void;
|
|
101
101
|
surface?: string;
|
|
102
102
|
/**
|
|
103
|
-
* Whether search-analytics is enabled (the
|
|
104
|
-
* flag). Required to gate setup:
|
|
103
|
+
* Whether search-analytics is enabled (the active provider's
|
|
104
|
+
* `search-analytics-<provider>` flag). Required to gate setup:
|
|
105
|
+
* `emitProductImpression` is a truthy no-op
|
|
105
106
|
* when the flag is off, so without this the IntersectionObserver would still
|
|
106
107
|
* be constructed per-card on every search-backed grid. Defaults on for
|
|
107
108
|
* backward compatibility with callers that don't pass it yet.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-search-analytics-open-product.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-search-analytics-open-product.ts"],"names":[],"mappings":"AAIA,UAAU,sBAAsB;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,GAAG,IAAI,CAAC,CAAA;CACrD;AAED,UAAU,6BAA6B;IACrC,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CA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OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,2BAA2B,CAAC,EAC1C,QAAQ,EACR,YAAY,EACZ,qBAAqB,EACrB,MAAM,EACN,OAAsB,GACvB,EAAE,iCAAiC,WAQlB,cAAc,mBA4C/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gCAAgC,CAAC,EAC/C,QAAQ,EACR,YAAY,EACZ,qBAAqB,EACrB,OAAsB,GACvB,EAAE,iCAAiC,gBAKnB,MAAM,UAuBtB;AAED,UAAU,kCAAkC;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,qBAAqB,CAAC,EAAE,CAAC,OAAO,EAAE,6BAA6B,KAAK,IAAI,CAAA;IACxE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB
|
|
1
|
+
{"version":3,"file":"use-search-analytics-open-product.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-search-analytics-open-product.ts"],"names":[],"mappings":"AAIA,UAAU,sBAAsB;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,GAAG,IAAI,CAAC,CAAA;CACrD;AAED,UAAU,6BAA6B;IACrC,MAAM,EAAE,OAAO,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE;QACP,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,SAAS,CAAC,EAAE,MAAM,CAAA;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;KAClB,CAAA;CACF;AAED,UAAU,gBAAgB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,OAA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,EACrB,MAAM,EACN,OAAsB,GACvB,EAAE,iCAAiC,WAQlB,cAAc,mBA4C/B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gCAAgC,CAAC,EAC/C,QAAQ,EACR,YAAY,EACZ,qBAAqB,EACrB,OAAsB,GACvB,EAAE,iCAAiC,gBAKnB,MAAM,UAuBtB;AAED,UAAU,kCAAkC;IAC1C,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,qBAAqB,CAAC,EAAE,CAAC,OAAO,EAAE,6BAA6B,KAAK,IAAI,CAAA;IACxE,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED;;;;;;;;;GASG;AACH,wBAAgB,4BAA4B,CAAC,EAC3C,YAAY,EACZ,qBAAqB,EACrB,OAAsB,EACtB,OAAc,GACf,EAAE,kCAAkC,cAKhB,sBAAsB,GAAG,SAAS,GAAG,IAAI,uBAa7D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProductsLocalStorage.d.ts","sourceRoot":"","sources":["../../../../components/libs/cache/ProductsLocalStorage.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"ProductsLocalStorage.d.ts","sourceRoot":"","sources":["../../../../components/libs/cache/ProductsLocalStorage.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,kBAAkB,CAAA;AA0B7C,KAAK,aAAa,GAAG;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CACnB,CAAA;AAID,MAAM,CAAC,OAAO,OAAO,oBAAqB,SAAQ,cAAc;IAC9D,OAAO,EAAE,MAAM,CAA2B;IAC1C,WAAW,EAAE,MAAM,CAAe;IAElC,aAAa,CAAC,EAAE,EAAE,MAAM;IAIxB,iBAAiB,CAAC,MAAM,EAAE,MAAM;;IAShC,QAAQ,IAAI,aAAa,EAAE;IAiB3B,YAAY,CAAC,EACX,EAAE,EACF,MAAM,GACP,EAAE;QACD,EAAE,CAAC,EAAE,MAAM,CAAA;QACX,MAAM,CAAC,EAAE,MAAM,CAAA;KAChB,GAAG,MAAM,GAAG,IAAI;IAgBjB,aAAa,CAAC,QAAQ,EAAE;QACtB,UAAU,CAAC,EAAE,MAAM,EAAE,CAAA;QACrB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAA;KAC1B,GAAG,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE;IAYrB,YAAY,CACV,OAAO,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EACvC,KAAK,CAAC,EAAE,aAAa,EAAE,EACvB,YAAY,GAAE,OAAc;gBAFT,MAAM;YAAM,MAAM;;IA6EvC,aAAa,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE;;;;IASrD,eAAe,CAAC,WAAW,GAAE,MAAU;IAWvC,UAAU;IAQV,eAAe,CAAC,CAAC,EAAE,GAAG;CASvB"}
|
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
import AppStudioCache from "./AppStudioCache";
|
|
2
2
|
import { getProductGidsFromIds } from "../../../lib/utils";
|
|
3
|
+
// Normalizes a Shopify connection ({ edges: [...] }) or a plain array into an array.
|
|
4
|
+
const normalizeConnection = (value) => Array.isArray(value) ? value : Array.isArray(value === null || value === void 0 ? void 0 : value.edges) ? value.edges : [];
|
|
5
|
+
const isConnection = (value) => Array.isArray(value) || Array.isArray(value === null || value === void 0 ? void 0 : value.edges);
|
|
6
|
+
// Empty connections are authoritative. Non-empty connections are complete only
|
|
7
|
+
// when every nested plan includes the priceAdjustments field requested by PDPs.
|
|
8
|
+
const hasCompleteSellingPlanData = (groups) => {
|
|
9
|
+
if (!isConnection(groups))
|
|
10
|
+
return false;
|
|
11
|
+
return normalizeConnection(groups).every((group) => {
|
|
12
|
+
var _a;
|
|
13
|
+
const groupNode = (_a = group === null || group === void 0 ? void 0 : group.node) !== null && _a !== void 0 ? _a : group;
|
|
14
|
+
if (!isConnection(groupNode === null || groupNode === void 0 ? void 0 : groupNode.sellingPlans))
|
|
15
|
+
return false;
|
|
16
|
+
return normalizeConnection(groupNode.sellingPlans).every((plan) => {
|
|
17
|
+
var _a;
|
|
18
|
+
const planNode = (_a = plan === null || plan === void 0 ? void 0 : plan.node) !== null && _a !== void 0 ? _a : plan;
|
|
19
|
+
return Array.isArray(planNode === null || planNode === void 0 ? void 0 : planNode.priceAdjustments);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
const FRESH_MS = 60 * 1000;
|
|
3
24
|
export default class ProductsLocalStorage extends AppStudioCache {
|
|
4
25
|
getIdCacheKey(id) {
|
|
5
26
|
return `${this.cachePrefix}-data-${id}`;
|
|
@@ -68,6 +89,17 @@ export default class ProductsLocalStorage extends AppStudioCache {
|
|
|
68
89
|
if (cachedProduct) {
|
|
69
90
|
// merge products, keeping populated arrays from cached product
|
|
70
91
|
productToCache = Object.entries(product).reduce((merged, [key, value]) => {
|
|
92
|
+
var _a;
|
|
93
|
+
// Keep the more-complete cached sellingPlanGroups when the incoming
|
|
94
|
+
// payload is partial/unhydrated (missing nested priceAdjustments),
|
|
95
|
+
// e.g. from PLP or carousel fetches. Prevents a shallow payload from
|
|
96
|
+
// poisoning a fully hydrated PDP record.
|
|
97
|
+
if (key === "sellingPlanGroups" &&
|
|
98
|
+
hasCompleteSellingPlanData(cachedProduct[key]) &&
|
|
99
|
+
!hasCompleteSellingPlanData(value) &&
|
|
100
|
+
Date.now() - ((_a = cachedProduct.ct) !== null && _a !== void 0 ? _a : 0) < FRESH_MS) {
|
|
101
|
+
return Object.assign(Object.assign({}, merged), { [key]: cachedProduct[key] });
|
|
102
|
+
}
|
|
71
103
|
// Keep non-empty arrays from cached product if current product has empty array
|
|
72
104
|
if (Array.isArray(value) &&
|
|
73
105
|
value.length === 0 &&
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProductsLocalStorage.test.d.ts","sourceRoot":"","sources":["../../../../components/libs/cache/ProductsLocalStorage.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import ProductsLocalStorage from "./ProductsLocalStorage";
|
|
2
|
+
const productId = "gid://shopify/Product/1";
|
|
3
|
+
const sellingPlanGroups = (price) => ({
|
|
4
|
+
edges: [
|
|
5
|
+
{
|
|
6
|
+
node: {
|
|
7
|
+
id: "group-1",
|
|
8
|
+
sellingPlans: {
|
|
9
|
+
edges: [
|
|
10
|
+
{
|
|
11
|
+
node: {
|
|
12
|
+
id: "plan-1",
|
|
13
|
+
priceAdjustments: [{ adjustmentValue: { price } }],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
});
|
|
22
|
+
const product = (groups) => ({
|
|
23
|
+
id: productId,
|
|
24
|
+
handle: "subscription-product",
|
|
25
|
+
sellingPlanGroups: groups,
|
|
26
|
+
});
|
|
27
|
+
describe("ProductsLocalStorage selling plan merges", () => {
|
|
28
|
+
let storage;
|
|
29
|
+
beforeEach(() => {
|
|
30
|
+
localStorage.clear();
|
|
31
|
+
storage = new ProductsLocalStorage();
|
|
32
|
+
});
|
|
33
|
+
it("keeps hydrated selling plans when an incoming payload is partial", () => {
|
|
34
|
+
storage.setCacheItem(product(sellingPlanGroups("10.00")));
|
|
35
|
+
const merged = storage.setCacheItem(product({
|
|
36
|
+
edges: [
|
|
37
|
+
{
|
|
38
|
+
node: {
|
|
39
|
+
id: "group-1",
|
|
40
|
+
sellingPlans: {
|
|
41
|
+
edges: [{ node: { id: "plan-1" } }],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
}));
|
|
47
|
+
expect(merged.sellingPlanGroups.edges[0].node.sellingPlans.edges[0].node
|
|
48
|
+
.priceAdjustments).toEqual([{ adjustmentValue: { price: "10.00" } }]);
|
|
49
|
+
});
|
|
50
|
+
it("keeps hydrated selling plans when only some incoming plans are hydrated", () => {
|
|
51
|
+
storage.setCacheItem(product(sellingPlanGroups("10.00")));
|
|
52
|
+
const merged = storage.setCacheItem(product({
|
|
53
|
+
edges: [
|
|
54
|
+
{
|
|
55
|
+
node: {
|
|
56
|
+
id: "group-1",
|
|
57
|
+
sellingPlans: {
|
|
58
|
+
edges: [
|
|
59
|
+
{
|
|
60
|
+
node: {
|
|
61
|
+
id: "plan-1",
|
|
62
|
+
priceAdjustments: [
|
|
63
|
+
{ adjustmentValue: { price: "12.00" } },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
{ node: { id: "plan-2" } },
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
}));
|
|
74
|
+
expect(merged.sellingPlanGroups.edges[0].node.sellingPlans.edges).toHaveLength(1);
|
|
75
|
+
expect(merged.sellingPlanGroups.edges[0].node.sellingPlans.edges[0].node
|
|
76
|
+
.priceAdjustments).toEqual([{ adjustmentValue: { price: "10.00" } }]);
|
|
77
|
+
});
|
|
78
|
+
it("accepts an authoritative empty selling plan list", () => {
|
|
79
|
+
storage.setCacheItem(product(sellingPlanGroups("10.00")));
|
|
80
|
+
const merged = storage.setCacheItem(product({ edges: [] }));
|
|
81
|
+
expect(merged.sellingPlanGroups).toEqual({ edges: [] });
|
|
82
|
+
});
|
|
83
|
+
it("replaces cached selling plans with a complete incoming payload", () => {
|
|
84
|
+
storage.setCacheItem(product(sellingPlanGroups("10.00")));
|
|
85
|
+
const merged = storage.setCacheItem(product(sellingPlanGroups("12.00")));
|
|
86
|
+
expect(merged.sellingPlanGroups.edges[0].node.sellingPlans.edges[0].node
|
|
87
|
+
.priceAdjustments).toEqual([{ adjustmentValue: { price: "12.00" } }]);
|
|
88
|
+
});
|
|
89
|
+
it("lets a partial payload win once the cached entry is stale", () => {
|
|
90
|
+
const nowSpy = jest.spyOn(Date, "now");
|
|
91
|
+
nowSpy.mockReturnValue(1000000);
|
|
92
|
+
storage.setCacheItem(product(sellingPlanGroups("10.00")));
|
|
93
|
+
nowSpy.mockReturnValue(1000000 + 61 * 1000);
|
|
94
|
+
const merged = storage.setCacheItem(product({
|
|
95
|
+
edges: [
|
|
96
|
+
{
|
|
97
|
+
node: {
|
|
98
|
+
id: "group-1",
|
|
99
|
+
sellingPlans: {
|
|
100
|
+
edges: [{ node: { id: "plan-1" } }],
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
}));
|
|
106
|
+
expect(merged.sellingPlanGroups.edges[0].node.sellingPlans.edges[0].node
|
|
107
|
+
.priceAdjustments).toBeUndefined();
|
|
108
|
+
nowSpy.mockRestore();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor, } from "../lib/utils";
|
|
2
|
+
export { toHtml } from "../lib/to-html";
|
|
3
|
+
export { getData } from "../lib/get-data";
|
|
4
|
+
export type { DataSource } from "../lib/get-data";
|
|
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
|
+
export type { WishlistEntryMatch } from "../lib/utils";
|
|
7
|
+
export * from "../lib/cart.util";
|
|
8
|
+
export * from "../lib/discountAllocation.util";
|
|
9
|
+
export * from "../lib/variablesCart.util";
|
|
10
|
+
export * from "../lib/isTapcartVersion20.util";
|
|
11
|
+
export * from "../components/contexts/translation-context";
|
|
12
|
+
export * from "../components/hooks/use-collection";
|
|
13
|
+
export * from "../components/hooks/use-infinite-scroll";
|
|
14
|
+
export * from "../components/hooks/swr-retry";
|
|
15
|
+
export * from "../components/hooks/use-infinite-wishlist";
|
|
16
|
+
export * from "../components/hooks/use-recommendations";
|
|
17
|
+
export * from "../components/hooks/use-search-analytics-open-product";
|
|
18
|
+
export * from "../components/hooks/use-products";
|
|
19
|
+
export * from "../components/hooks/use-personalized-cluster-feed";
|
|
20
|
+
export * from "../components/hooks/use-order-details";
|
|
21
|
+
export * from "../components/hooks/use-scroll-direction";
|
|
22
|
+
export * from "../components/hooks/use-sort-filter";
|
|
23
|
+
export * from "../components/hooks/use-product-options";
|
|
24
|
+
export * from "../components/hooks/use-shop";
|
|
25
|
+
export * from "../components/hooks/use-mock-products";
|
|
26
|
+
export * from "../components/hooks/use-block-conditional-rendering";
|
|
27
|
+
export * from "../components/hooks/use-mock-cart";
|
|
28
|
+
export * from "../components/ui/accordion";
|
|
29
|
+
export * from "../components/ui/animate-container";
|
|
30
|
+
export * from "../components/ui/animate-number";
|
|
31
|
+
export * from "../components/ui/apple-pay-button";
|
|
32
|
+
export * from "../components/ui/aspect-ratio";
|
|
33
|
+
export * from "../components/ui/badge";
|
|
34
|
+
export * from "../components/core/button";
|
|
35
|
+
export * from "../components/ui/carousel";
|
|
36
|
+
export * from "../components/ui/checkbox";
|
|
37
|
+
export * from "../components/ui/chip";
|
|
38
|
+
export * from "../components/ui/color-swatch";
|
|
39
|
+
export * from "../components/ui/container";
|
|
40
|
+
export * from "../components/ui/drawer";
|
|
41
|
+
export * from "../components/ui/dropdown";
|
|
42
|
+
export * from "../components/ui/empty-message";
|
|
43
|
+
export * from "../components/ui/fallback-on-condition";
|
|
44
|
+
export * from "../components/ui/favorite";
|
|
45
|
+
export * from "../components/ui/fallback-on-condition";
|
|
46
|
+
export * from "../components/ui/grid";
|
|
47
|
+
export * from "../components/ui/virtual-grid";
|
|
48
|
+
export * from "../components/ui/icon";
|
|
49
|
+
export * from "../components/ui/image";
|
|
50
|
+
export * from "../components/ui/Input/input";
|
|
51
|
+
export * from "../components/ui/label";
|
|
52
|
+
export * from "../components/ui/line-item-text-icons";
|
|
53
|
+
export * from "../components/ui/loading-dots";
|
|
54
|
+
export * from "../components/ui/loading-spinner";
|
|
55
|
+
export * from "../components/ui/money";
|
|
56
|
+
export * from "../components/ui/portal";
|
|
57
|
+
export * from "../components/ui/price";
|
|
58
|
+
export * from "../components/ui/product-card";
|
|
59
|
+
export * from "../components/ui/quantity-picker";
|
|
60
|
+
export * from "../components/ui/quantity-pickerNEW";
|
|
61
|
+
export * from "../components/ui/progress-bar";
|
|
62
|
+
export * from "../components/ui/radio-group";
|
|
63
|
+
export * from "../components/ui/scroll-area";
|
|
64
|
+
export * from "../components/ui/selectors";
|
|
65
|
+
export * from "../components/ui/separator";
|
|
66
|
+
export * from "../components/ui/skeleton";
|
|
67
|
+
export * from "../components/ui/slider";
|
|
68
|
+
export * from "../components/ui/star-rating";
|
|
69
|
+
export * from "../components/ui/subscription";
|
|
70
|
+
export * from "../components/ui/switch";
|
|
71
|
+
export * from "../components/ui/tabs";
|
|
72
|
+
export * from "../components/core/text";
|
|
73
|
+
export * from "../components/ui/textarea";
|
|
74
|
+
export * from "../components/ui/toast";
|
|
75
|
+
export * from "../components/ui/toaster";
|
|
76
|
+
export * from "../components/ui/toggle-group";
|
|
77
|
+
export * from "../components/ui/toggle";
|
|
78
|
+
export * from "../components/ui/use-toast";
|
|
79
|
+
export * from "../components/ui/video";
|
|
80
|
+
export * from "../components/ui/video-enhanced";
|
|
81
|
+
export * from "../components/ui/wishlist";
|
|
82
|
+
export * from "../components/ui/wishlist-select";
|
|
83
|
+
export * from "../components/core/html";
|
|
84
|
+
export * from "../components/hooks/use-shop";
|
|
85
|
+
export * from "../components/libs/sort-filter/search-integration";
|
|
86
|
+
export * from "../components/hooks/use-reviews";
|
|
87
|
+
export * from "../components/hooks/use-style-parent";
|
|
88
|
+
export * from "../components/ui/subcollection-tabs";
|
|
89
|
+
export * from "../components/ui/ProductCard/utils";
|
|
90
|
+
export * from "../lib/price";
|
|
91
|
+
export * from "../components/hooks/use-nosto-recommendation";
|
|
92
|
+
export * from "../components/libs/sort-filter/search-integration";
|
|
93
|
+
export * from "../components/ui/tap";
|
|
94
|
+
export * from "../components/ui/circular-progress";
|
|
95
|
+
export * from "../components/ui/swipeable-list-item";
|
|
96
|
+
export * from "../components/ui/dialog";
|
|
97
|
+
export * from "../components/ui/input-otp";
|
|
98
|
+
export { default as ProductsLocalStorage } from "../components/libs/cache/ProductsLocalStorage";
|
|
99
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,EACd,QAAQ,GACT,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,YAAY,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EACL,qBAAqB,EACrB,6BAA6B,EAC7B,cA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AACzC,cAAc,kCAAkC,CAAA;AAChD,cAAc,yBAAyB,CAAA;AACvC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,mDAAmD,CAAA;AACjE,cAAc,iCAAiC,CAAA;AAC/C,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"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// component exports
|
|
2
|
+
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor, } from "../lib/utils";
|
|
3
|
+
export { toHtml } from "../lib/to-html";
|
|
4
|
+
export { getData } from "../lib/get-data";
|
|
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
|
+
export * from "../lib/cart.util";
|
|
7
|
+
export * from "../lib/discountAllocation.util";
|
|
8
|
+
export * from "../lib/variablesCart.util";
|
|
9
|
+
export * from "../lib/isTapcartVersion20.util";
|
|
10
|
+
export * from "../components/contexts/translation-context";
|
|
11
|
+
export * from "../components/hooks/use-collection";
|
|
12
|
+
export * from "../components/hooks/use-infinite-scroll";
|
|
13
|
+
export * from "../components/hooks/swr-retry";
|
|
14
|
+
export * from "../components/hooks/use-infinite-wishlist";
|
|
15
|
+
export * from "../components/hooks/use-recommendations";
|
|
16
|
+
export * from "../components/hooks/use-search-analytics-open-product";
|
|
17
|
+
export * from "../components/hooks/use-products";
|
|
18
|
+
export * from "../components/hooks/use-personalized-cluster-feed";
|
|
19
|
+
export * from "../components/hooks/use-order-details";
|
|
20
|
+
export * from "../components/hooks/use-scroll-direction";
|
|
21
|
+
export * from "../components/hooks/use-sort-filter";
|
|
22
|
+
export * from "../components/hooks/use-product-options";
|
|
23
|
+
export * from "../components/hooks/use-shop";
|
|
24
|
+
export * from "../components/hooks/use-mock-products";
|
|
25
|
+
export * from "../components/hooks/use-block-conditional-rendering";
|
|
26
|
+
export * from "../components/hooks/use-mock-cart";
|
|
27
|
+
export * from "../components/ui/accordion";
|
|
28
|
+
export * from "../components/ui/animate-container";
|
|
29
|
+
export * from "../components/ui/animate-number";
|
|
30
|
+
export * from "../components/ui/apple-pay-button";
|
|
31
|
+
export * from "../components/ui/aspect-ratio";
|
|
32
|
+
export * from "../components/ui/badge";
|
|
33
|
+
export * from "../components/core/button";
|
|
34
|
+
export * from "../components/ui/carousel";
|
|
35
|
+
export * from "../components/ui/checkbox";
|
|
36
|
+
export * from "../components/ui/chip";
|
|
37
|
+
export * from "../components/ui/color-swatch";
|
|
38
|
+
export * from "../components/ui/container";
|
|
39
|
+
export * from "../components/ui/drawer";
|
|
40
|
+
export * from "../components/ui/dropdown";
|
|
41
|
+
export * from "../components/ui/empty-message";
|
|
42
|
+
export * from "../components/ui/fallback-on-condition";
|
|
43
|
+
export * from "../components/ui/favorite";
|
|
44
|
+
export * from "../components/ui/fallback-on-condition";
|
|
45
|
+
export * from "../components/ui/grid";
|
|
46
|
+
export * from "../components/ui/virtual-grid";
|
|
47
|
+
export * from "../components/ui/icon";
|
|
48
|
+
export * from "../components/ui/image";
|
|
49
|
+
export * from "../components/ui/Input/input";
|
|
50
|
+
export * from "../components/ui/label";
|
|
51
|
+
export * from "../components/ui/line-item-text-icons";
|
|
52
|
+
export * from "../components/ui/loading-dots";
|
|
53
|
+
export * from "../components/ui/loading-spinner";
|
|
54
|
+
export * from "../components/ui/money";
|
|
55
|
+
export * from "../components/ui/portal";
|
|
56
|
+
export * from "../components/ui/price";
|
|
57
|
+
export * from "../components/ui/product-card";
|
|
58
|
+
export * from "../components/ui/quantity-picker";
|
|
59
|
+
// TODO: make this the default quantity picker after new CartLineItem component is released
|
|
60
|
+
export * from "../components/ui/quantity-pickerNEW";
|
|
61
|
+
export * from "../components/ui/progress-bar";
|
|
62
|
+
export * from "../components/ui/radio-group";
|
|
63
|
+
export * from "../components/ui/scroll-area";
|
|
64
|
+
export * from "../components/ui/selectors";
|
|
65
|
+
export * from "../components/ui/separator";
|
|
66
|
+
export * from "../components/ui/skeleton";
|
|
67
|
+
export * from "../components/ui/slider";
|
|
68
|
+
export * from "../components/ui/star-rating";
|
|
69
|
+
export * from "../components/ui/subscription";
|
|
70
|
+
export * from "../components/ui/switch";
|
|
71
|
+
export * from "../components/ui/tabs";
|
|
72
|
+
export * from "../components/core/text";
|
|
73
|
+
export * from "../components/ui/textarea";
|
|
74
|
+
export * from "../components/ui/toast";
|
|
75
|
+
export * from "../components/ui/toaster";
|
|
76
|
+
export * from "../components/ui/toggle-group";
|
|
77
|
+
export * from "../components/ui/toggle";
|
|
78
|
+
export * from "../components/ui/use-toast";
|
|
79
|
+
export * from "../components/ui/video";
|
|
80
|
+
export * from "../components/ui/video-enhanced";
|
|
81
|
+
export * from "../components/ui/wishlist";
|
|
82
|
+
export * from "../components/ui/wishlist-select";
|
|
83
|
+
export * from "../components/core/html";
|
|
84
|
+
export * from "../components/hooks/use-shop";
|
|
85
|
+
export * from "../components/libs/sort-filter/search-integration";
|
|
86
|
+
export * from "../components/hooks/use-reviews";
|
|
87
|
+
export * from "../components/hooks/use-style-parent";
|
|
88
|
+
export * from "../components/ui/subcollection-tabs";
|
|
89
|
+
export * from "../components/ui/ProductCard/utils";
|
|
90
|
+
export * from "../lib/price";
|
|
91
|
+
export * from "../components/hooks/use-nosto-recommendation";
|
|
92
|
+
export * from "../components/libs/sort-filter/search-integration";
|
|
93
|
+
export * from "../components/ui/tap";
|
|
94
|
+
export * from "../components/ui/circular-progress";
|
|
95
|
+
export * from "../components/ui/swipeable-list-item";
|
|
96
|
+
export * from "../components/ui/dialog";
|
|
97
|
+
export * from "../components/ui/input-otp";
|
|
98
|
+
export { default as ProductsLocalStorage } from "../components/libs/cache/ProductsLocalStorage";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor,
|
|
1
|
+
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor, } from "./lib/utils";
|
|
2
|
+
export { toHtml } from "./lib/to-html";
|
|
3
|
+
export { getData } from "./lib/get-data";
|
|
4
|
+
export type { DataSource } from "./lib/get-data";
|
|
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";
|
|
2
6
|
export type { WishlistEntryMatch } from "./lib/utils";
|
|
3
7
|
export * from "./lib/cart.util";
|
|
4
8
|
export * from "./lib/discountAllocation.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,
|
|
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,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,4BAA4B,EAC5B,4BAA4B,EAC5B,OAAO,EACP,kBAAkB,EAClB,gBAAgB,EAChB,SAAS,EACT,gBAAgB,EAChB,uBAAuB,EACvB,gBAAgB,EAChB,wBAAwB,EACxB,yBAAyB,EACzB,gBAAgB,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Ac,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
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
// component exports
|
|
2
|
-
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor,
|
|
2
|
+
export { addItemToWishlist, cn, createCollectionImageMap, cva, formatRelativeTime, getBackgroundAndPaddingStyle, getBackgroundAndSpacingStyle, getBadgesForProductFn, getBorderSidesStyle, getBorderStyle, getColor, } from "./lib/utils";
|
|
3
|
+
export { toHtml } from "./lib/to-html";
|
|
4
|
+
export { getData } from "./lib/get-data";
|
|
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";
|
|
3
6
|
export * from "./lib/cart.util";
|
|
4
7
|
export * from "./lib/discountAllocation.util";
|
|
5
8
|
export * from "./lib/variablesCart.util";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type DataSource = {
|
|
2
|
+
source: string;
|
|
3
|
+
value: string;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* getData — Universal content resolver for V2 blocks.
|
|
7
|
+
*
|
|
8
|
+
* Accepts either:
|
|
9
|
+
* - a static HTML string (typography `content: "text"`) → returned as-is
|
|
10
|
+
* - a DataSource `{ source, value }` (typography `content: "data"`, or a
|
|
11
|
+
* data-source field) → resolved against Tapcart variables
|
|
12
|
+
* - null/undefined (typography `content: "none"`, i.e. no `value`) → null
|
|
13
|
+
*
|
|
14
|
+
* This lets a block render every typography field identically, with no
|
|
15
|
+
* conditional branching on the `content` mode. `content: "none"` returns null
|
|
16
|
+
* (not "") so falsy guards work cleanly and no empty wrapper renders:
|
|
17
|
+
* {getData(variables, field?.value) && (
|
|
18
|
+
* <Html html={getData(variables, field?.value)} />
|
|
19
|
+
* )}
|
|
20
|
+
*
|
|
21
|
+
* Note: a *data-source* that resolves to nothing still returns "" (it was a
|
|
22
|
+
* real binding that came back empty), only an absent value returns null.
|
|
23
|
+
*
|
|
24
|
+
* Never throws — returns empty string on any error.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getData(variables: Record<string, any> | undefined, data: DataSource | string | null | undefined): string | null;
|
|
27
|
+
//# sourceMappingURL=get-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-data.d.ts","sourceRoot":"","sources":["../../lib/get-data.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,OAAO,CACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,EAC1C,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAC3C,MAAM,GAAG,IAAI,CAyCf"}
|