@tapcart/mobile-components 0.8.26 → 0.8.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-block-conditional-rendering.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditional-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAGb,MAAM,kBAAkB,CAAA;AAczB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,GAAG,CAAA;IACpB,iBAAiB,EAAE,GAAG,CAAA;CACvB,UACO,YAAY;;;
|
|
1
|
+
{"version":3,"file":"use-block-conditional-rendering.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditional-rendering.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,YAAY,EAGb,MAAM,kBAAkB,CAAA;AAczB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,GAAG,CAAA;IACpB,iBAAiB,EAAE,GAAG,CAAA;CACvB,UACO,YAAY;;;CAiNrB,CAAA"}
|
|
@@ -35,13 +35,28 @@ export const useBlockConditionalRendering = (_props, _block) => {
|
|
|
35
35
|
let blockProductMetafields = useMemo(() => blockState && blockState.productMetafield
|
|
36
36
|
? blockState.productMetafield
|
|
37
37
|
: [], [blockState]);
|
|
38
|
-
const productMetafieldsQuery = useMemo(() =>
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
const productMetafieldsQuery = useMemo(() => {
|
|
39
|
+
var _a;
|
|
40
|
+
if (conditionalsV1IsEnabled && (blockState === null || blockState === void 0 ? void 0 : blockState.productMetafield)) {
|
|
41
|
+
return blockState.productMetafield;
|
|
42
|
+
}
|
|
43
|
+
if (conditionalsV2IsEnabled && ((_a = _block === null || _block === void 0 ? void 0 : _block.visibilityConditions) === null || _a === void 0 ? void 0 : _a.conditions)) {
|
|
44
|
+
const extractProductMetafields = (conditions) => {
|
|
45
|
+
return conditions.reduce((acc, condition) => {
|
|
46
|
+
if (condition.type === 'productMetafield' && condition.value) {
|
|
47
|
+
acc.push(condition.value);
|
|
48
|
+
}
|
|
49
|
+
if (condition.conditions) {
|
|
50
|
+
acc.push(...extractProductMetafields(condition.conditions));
|
|
51
|
+
}
|
|
52
|
+
return acc;
|
|
53
|
+
}, []);
|
|
54
|
+
};
|
|
55
|
+
//@ts-expect-error: conditions typing mismatch
|
|
56
|
+
return extractProductMetafields(blockState.conditions || []);
|
|
57
|
+
}
|
|
58
|
+
return [];
|
|
59
|
+
}, [blockState, conditionalsV1IsEnabled, conditionalsV2IsEnabled, _block === null || _block === void 0 ? void 0 : _block.visibilityConditions]);
|
|
45
60
|
// Fetch product if productId is present
|
|
46
61
|
const { products, error: useProductsError, isLoading: isProductsLoading, } = useProducts({
|
|
47
62
|
productIds: productId !== undefined ? [gidFromId(productId)] : [],
|
|
@@ -53,9 +68,28 @@ export const useBlockConditionalRendering = (_props, _block) => {
|
|
|
53
68
|
country,
|
|
54
69
|
},
|
|
55
70
|
});
|
|
56
|
-
const blockCollectionMetafields = useMemo(() =>
|
|
57
|
-
|
|
58
|
-
|
|
71
|
+
const blockCollectionMetafields = useMemo(() => {
|
|
72
|
+
var _a;
|
|
73
|
+
if (conditionalsV1IsEnabled && (blockState === null || blockState === void 0 ? void 0 : blockState.collectionMetafield)) {
|
|
74
|
+
return blockState.collectionMetafield;
|
|
75
|
+
}
|
|
76
|
+
if (conditionalsV2IsEnabled && ((_a = _block === null || _block === void 0 ? void 0 : _block.visibilityConditions) === null || _a === void 0 ? void 0 : _a.conditions)) {
|
|
77
|
+
const extractCollectionMetafields = (conditions) => {
|
|
78
|
+
return conditions.reduce((acc, condition) => {
|
|
79
|
+
if (condition.type === 'collectionMetafield' && condition.value) {
|
|
80
|
+
acc.push(condition.value);
|
|
81
|
+
}
|
|
82
|
+
if (condition.conditions) {
|
|
83
|
+
acc.push(...extractCollectionMetafields(condition.conditions));
|
|
84
|
+
}
|
|
85
|
+
return acc;
|
|
86
|
+
}, []);
|
|
87
|
+
};
|
|
88
|
+
//@ts-expect-error: conditions typing mismatch
|
|
89
|
+
return extractCollectionMetafields(blockState.conditions || []);
|
|
90
|
+
}
|
|
91
|
+
return [];
|
|
92
|
+
}, [blockState, conditionalsV1IsEnabled, conditionalsV2IsEnabled, _block === null || _block === void 0 ? void 0 : _block.visibilityConditions]);
|
|
59
93
|
const collectionMetafieldsQuery = useMemo(() => blockCollectionMetafields.map((item) => {
|
|
60
94
|
// these are the fields used in the query.
|
|
61
95
|
return {
|
|
@@ -17,8 +17,8 @@ function SubCollectionTabs({ subCollections, useActions, }) {
|
|
|
17
17
|
})), [subCollections]);
|
|
18
18
|
useEffect(() => {
|
|
19
19
|
// Set initial active tab based on URL params
|
|
20
|
-
const collectionId = searchParams.get("collectionId");
|
|
21
|
-
const collectionHandle = searchParams.get("collectionHandle");
|
|
20
|
+
const collectionId = searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("collectionId");
|
|
21
|
+
const collectionHandle = searchParams === null || searchParams === void 0 ? void 0 : searchParams.get("collectionHandle");
|
|
22
22
|
const initialIndex = subCollections.findIndex((cat) => (collectionId && getIdFromGid(cat.id) === collectionId) ||
|
|
23
23
|
(collectionHandle && cat.handle === collectionHandle));
|
|
24
24
|
setActiveTab(initialIndex !== -1 ? initialIndex : null);
|