@tapcart/mobile-components 0.7.50 → 0.7.51
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/hooks/use-block-conditional-rendering.d.ts.map +1 -1
- package/dist/components/hooks/use-block-conditional-rendering.js +36 -55
- package/dist/components/hooks/use-customer.d.ts +10 -0
- package/dist/components/hooks/use-customer.d.ts.map +1 -0
- package/dist/components/hooks/use-customer.js +24 -0
- package/dist/components/hooks/use-order-details.d.ts.map +1 -1
- package/dist/components/hooks/use-order-details.js +4 -2
- package/dist/lib/utils.d.ts +0 -2
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +0 -54
- package/package.json +1 -1
- package/dist/components/ThemeProvider.d.ts +0 -3
- package/dist/components/ThemeProvider.d.ts.map +0 -1
- package/dist/components/ThemeProvider.js +0 -18
- package/dist/components/ThemeToggle.d.ts +0 -2
- package/dist/components/ThemeToggle.d.ts.map +0 -1
- package/dist/components/ThemeToggle.js +0 -8
- package/dist/components/hooks/use-block-conditionals.d.ts +0 -2
- package/dist/components/hooks/use-block-conditionals.d.ts.map +0 -1
- package/dist/components/hooks/use-block-conditionals.js +0 -2
- package/dist/components/ui/input.d.ts +0 -17
- package/dist/components/ui/input.d.ts.map +0 -1
- package/dist/components/ui/input.js +0 -35
- package/dist/components/ui/product-grid.d.ts +0 -15
- package/dist/components/ui/product-grid.d.ts.map +0 -1
- package/dist/components/ui/product-grid.js +0 -22
|
@@ -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;
|
|
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;AAezB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,UACO,YAAY;;;CAyJrB,CAAA"}
|
|
@@ -16,11 +16,11 @@ import { useCollection } from "./use-collection";
|
|
|
16
16
|
import { useSearchParams } from "next/navigation";
|
|
17
17
|
//@ts-expect-error
|
|
18
18
|
import { useVariables } from "@tapcart/webbridge-react";
|
|
19
|
-
import { gidFromId, countNumberOfTagsInState, getEnvState, shouldShowBlock,
|
|
19
|
+
import { gidFromId, countNumberOfTagsInState, getEnvState, shouldShowBlock, } from "../../lib/utils";
|
|
20
20
|
export const useBlockConditionalRendering = (_props, _block) => {
|
|
21
|
-
var _a, _b, _c, _d, _e;
|
|
22
|
-
const
|
|
23
|
-
|
|
21
|
+
var _a, _b, _c, _d, _e, _f;
|
|
22
|
+
const _g = ((_a = _block === null || _block === void 0 ? void 0 : _block.visibilityConditions) === null || _a === void 0 ? void 0 : _a.conditions) || {}, { enabled: isEnabled = false, exclude: isInverse = false } = _g, restOfProps = __rest(_g, ["enabled", "exclude"]);
|
|
23
|
+
let shouldShow = true;
|
|
24
24
|
const blockState = restOfProps;
|
|
25
25
|
const { appId = "", apiUrl = "" } = _props;
|
|
26
26
|
const searchParams = useSearchParams();
|
|
@@ -29,7 +29,7 @@ export const useBlockConditionalRendering = (_props, _block) => {
|
|
|
29
29
|
const customerVariables = variables === null || variables === void 0 ? void 0 : variables.customer;
|
|
30
30
|
// locale is provided in this form en_US
|
|
31
31
|
const [language, country] = ((_b = deviceVariables === null || deviceVariables === void 0 ? void 0 : deviceVariables.locale) === null || _b === void 0 ? void 0 : _b.split("_")) || [];
|
|
32
|
-
const productId = (_c = searchParams
|
|
32
|
+
const productId = (_c = searchParams.get("productId")) !== null && _c !== void 0 ? _c : undefined;
|
|
33
33
|
const location = {
|
|
34
34
|
country: country || "US",
|
|
35
35
|
language: language || "en",
|
|
@@ -45,7 +45,7 @@ export const useBlockConditionalRendering = (_props, _block) => {
|
|
|
45
45
|
};
|
|
46
46
|
}), [blockProductMetafields]);
|
|
47
47
|
// Fetch product if productId is present
|
|
48
|
-
const { products, error: useProductsError, isLoading:
|
|
48
|
+
const { products, error: useProductsError, isLoading: useProductsLoading, } = useProducts(productId !== undefined && isEnabled
|
|
49
49
|
? {
|
|
50
50
|
productIds: [gidFromId(productId)],
|
|
51
51
|
baseURL: apiUrl,
|
|
@@ -68,9 +68,9 @@ export const useBlockConditionalRendering = (_props, _block) => {
|
|
|
68
68
|
.map((m) => `${m.namespace}.${m.key}`)
|
|
69
69
|
.join(",")
|
|
70
70
|
: undefined, [collectionMetafieldsQuery]);
|
|
71
|
-
const collectionId = (_d = searchParams
|
|
72
|
-
const collectionHandle = (_e = searchParams
|
|
73
|
-
const { specificCollection = {}, error: useCollectionError, loading:
|
|
71
|
+
const collectionId = (_d = searchParams.get("collectionId")) !== null && _d !== void 0 ? _d : undefined;
|
|
72
|
+
const collectionHandle = (_e = searchParams.get("collectionHandle")) !== null && _e !== void 0 ? _e : undefined;
|
|
73
|
+
const { specificCollection = {}, error: useCollectionError, loading: useCollectionLoading, } = useCollection({
|
|
74
74
|
appId,
|
|
75
75
|
apiUrl,
|
|
76
76
|
collectionId,
|
|
@@ -78,61 +78,42 @@ export const useBlockConditionalRendering = (_props, _block) => {
|
|
|
78
78
|
language: location === null || location === void 0 ? void 0 : location.language,
|
|
79
79
|
metafields: memoizedMetafields,
|
|
80
80
|
});
|
|
81
|
-
// Combine loading states
|
|
82
|
-
const isLoading = isProductsLoading || isCollectionLoading;
|
|
83
81
|
if (useProductsError || useCollectionError) {
|
|
84
82
|
console.error("Unable to load products in conditional block rendering hook: ", useProductsError !== null && useProductsError !== void 0 ? useProductsError : useCollectionError);
|
|
85
83
|
}
|
|
86
|
-
// Build context for condition evaluation
|
|
87
|
-
const context = {
|
|
88
|
-
location,
|
|
89
|
-
products,
|
|
90
|
-
collection: specificCollection,
|
|
91
|
-
customer: customerVariables,
|
|
92
|
-
blockState,
|
|
93
|
-
};
|
|
94
|
-
console.log({ context, blockState, conditions });
|
|
95
|
-
let shouldShow = true;
|
|
96
|
-
const blockConditionalsIsEnabled = conditionalsV1IsEnabled || conditionalsV2IsEnabled;
|
|
97
|
-
const blockHasTags = countNumberOfTagsInState(blockState) > 0;
|
|
98
|
-
const product = products.length === 1 ? products[0] : undefined;
|
|
99
|
-
const envState = getEnvState({
|
|
100
|
-
location,
|
|
101
|
-
product,
|
|
102
|
-
collection: specificCollection,
|
|
103
|
-
customer: customerVariables,
|
|
104
|
-
});
|
|
105
84
|
try {
|
|
106
|
-
if
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
85
|
+
// if block has tags
|
|
86
|
+
if (((_f = _block.visibilityConditions) === null || _f === void 0 ? void 0 : _f.conditions) !== undefined && isEnabled) {
|
|
87
|
+
const blockHasTags = countNumberOfTagsInState(blockState) > 0;
|
|
88
|
+
if (blockHasTags) {
|
|
89
|
+
const product = products.length === 1 ? products[0] : undefined;
|
|
90
|
+
const envState = getEnvState({
|
|
91
|
+
location,
|
|
92
|
+
product,
|
|
93
|
+
collection: specificCollection,
|
|
94
|
+
customer: customerVariables,
|
|
95
|
+
});
|
|
96
|
+
//@ts-expect-errors
|
|
97
|
+
const shouldShowPreInverse = shouldShowBlock(envState, blockState);
|
|
98
|
+
// TODO: Currently negation of properties is not available but is required for migration of certain merchants
|
|
99
|
+
// This code is to be removed and updated when inverse feature is available for all blocks
|
|
100
|
+
// If exclude tag is applied then block should show inversely
|
|
101
|
+
if (isInverse) {
|
|
102
|
+
shouldShow = !shouldShowPreInverse;
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
shouldShow = shouldShowPreInverse;
|
|
125
106
|
}
|
|
126
107
|
}
|
|
127
108
|
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
shouldShow
|
|
109
|
+
// if conditionals is disabled, show the block.
|
|
110
|
+
if (!isEnabled) {
|
|
111
|
+
return { shouldShow: true, isLoading: false };
|
|
131
112
|
}
|
|
113
|
+
return { shouldShow, isLoading: useProductsLoading || useCollectionLoading };
|
|
132
114
|
}
|
|
133
115
|
catch (e) {
|
|
134
|
-
console.error("
|
|
135
|
-
shouldShow
|
|
116
|
+
console.error("conditionals error: ", e);
|
|
117
|
+
return { shouldShow: true, isLoading: false };
|
|
136
118
|
}
|
|
137
|
-
return { shouldShow, isLoading };
|
|
138
119
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type Customer = {
|
|
2
|
+
isAuthenticated: boolean;
|
|
3
|
+
};
|
|
4
|
+
type UseCustomerProps = {};
|
|
5
|
+
type UseCustomerReturn = {
|
|
6
|
+
customer: Customer;
|
|
7
|
+
};
|
|
8
|
+
export declare const useCustomer: (props: UseCustomerProps | null) => UseCustomerReturn;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=use-customer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-customer.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-customer.ts"],"names":[],"mappings":"AAWA,KAAK,QAAQ,GAAG;IACd,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAGD,KAAK,gBAAgB,GAAG,EAAE,CAAA;AAE1B,KAAK,iBAAiB,GAAG;IACvB,QAAQ,EAAE,QAAQ,CAAA;CACnB,CAAA;AAED,eAAO,MAAM,WAAW,UACf,gBAAgB,GAAG,IAAI,KAC7B,iBAuBF,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useEffect } from "react";
|
|
3
|
+
// @ts-ignore -- webbridge-react is not typed (yet)
|
|
4
|
+
import { useActions } from "@tapcart/webbridge-react";
|
|
5
|
+
export const useCustomer = (props) => {
|
|
6
|
+
const [isAuthenticated, setIsAuthenticated] = useState(false);
|
|
7
|
+
const [customer, setCustomer] = useState({});
|
|
8
|
+
const actions = useActions();
|
|
9
|
+
// verify customer
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
try {
|
|
12
|
+
// webbridge method to get customerIdentity
|
|
13
|
+
actions.getCustomerIdentity(null, {
|
|
14
|
+
onSuccess: (user) => setIsAuthenticated(!!(user === null || user === void 0 ? void 0 : user.email)),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
catch (e) {
|
|
18
|
+
console.log("unable to get customer identity ", e);
|
|
19
|
+
}
|
|
20
|
+
}, [actions]);
|
|
21
|
+
return {
|
|
22
|
+
customer: Object.assign({ isAuthenticated }, customer),
|
|
23
|
+
};
|
|
24
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-order-details.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-order-details.ts"],"names":[],"mappings":"AAMA,KAAK,oBAAoB,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAClC,CAAA;
|
|
1
|
+
{"version":3,"file":"use-order-details.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-order-details.ts"],"names":[],"mappings":"AAMA,KAAK,oBAAoB,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,KAAK,iBAAiB,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAClC,CAAA;AA2JD,wBAAgB,eAAe,CAAC,EAC9B,SAAS,EACT,MAAM,EACN,KAAK,EACL,QAAQ,EACR,OAAO,EACP,IAAY,GACb,EAAE,oBAAoB,GAAG,iBAAiB,CA0C1C"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { getIdFromGid } from "../../lib/utils";
|
|
3
3
|
import { useProducts } from "./use-products";
|
|
4
4
|
import { useEffect, useMemo, useState } from "react";
|
|
5
|
-
const getSellingPlan = (lineItems, productGid) => {
|
|
5
|
+
const getSellingPlan = (lineItems = [], productGid) => {
|
|
6
6
|
var _a, _b;
|
|
7
7
|
const productId = getIdFromGid(productGid);
|
|
8
8
|
const item = lineItems.find((item) => { var _a, _b; return ((_b = (_a = item === null || item === void 0 ? void 0 : item.variant) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.id) === productId; });
|
|
@@ -40,7 +40,9 @@ const updateLineDetails = (line, products, checkoutData) => {
|
|
|
40
40
|
return;
|
|
41
41
|
line.title = product.title;
|
|
42
42
|
line.vendor = product.vendor;
|
|
43
|
-
|
|
43
|
+
if (checkoutData && checkoutData.lineItems) {
|
|
44
|
+
line.sellingPlan = getSellingPlan(checkoutData.lineItems, line.productId);
|
|
45
|
+
}
|
|
44
46
|
const productVariant = findVariantById(product.variants, line.merchandiseId);
|
|
45
47
|
if (productVariant) {
|
|
46
48
|
updateLineWithVariantDetails(line, productVariant);
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -247,6 +247,4 @@ export declare const isMetafield: (obj: any) => obj is ConditionalSelectorMetafi
|
|
|
247
247
|
export declare const isArrayOfUserSelectedTags: (arr: any[]) => arr is UserSelectedTag[];
|
|
248
248
|
export declare const isArrayOfMetafields: (arr: any[]) => arr is ConditionalSelectorMetafield[];
|
|
249
249
|
export declare const shouldShowBlock: (envState: ConditionalSelectorValues, blockState: ConditionalSelectorValues) => boolean;
|
|
250
|
-
export declare const evaluateConditions: (group: any, context: any) => boolean;
|
|
251
|
-
export declare const evaluateSingleCondition: (condition: any, context: any) => boolean;
|
|
252
250
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/lib/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../lib/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,4BAA4B,EAC5B,yBAAyB,EACzB,UAAU,EACV,eAAe,EACf,OAAO,EACP,QAAQ,EACR,gBAAgB,EACjB,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,UAAU,EAAQ,MAAM,MAAM,CAAA;AAMvC,MAAM,MAAM,KAAK,GAAG;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnE,wBAAgB,EAAE,CAAC,GAAG,MAAM,EAAE,UAAU,EAAE,UAEzC;AAED,eAAO,MAAM,eAAe,UAc3B,CAAA;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,CAAA;AAMjE,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAA;AAI9C,eAAO,MAAM,QAAQ,gBAAiB,KAAK,GAAG,SAAS,uBAUtD,CAAA;AAED,KAAK,UAAU,GAAG,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAA;AAC7D,KAAK,WAAW,GAAG,UAAU,EAAE,CAAA;AAE/B,eAAO,MAAM,mBAAmB;;;;;;;;;;;;CAU/B,CAAA;AAED,KAAK,iBAAiB,G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M,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAA;AAErD,eAAO,MAAM,WAAW;cAMZ,QAAQ;;;;;;;;;;;;;;;;;;;;;;;CAuDnB,CAAA;AAED,eAAO,MAAM,iBAAiB,QAAS,GAAG,2BAC+B,CAAA;AAEzE,eAAO,MAAM,WAAW,QAAS,GAAG,wCACO,CAAA;AAE3C,eAAO,MAAM,yBAAyB,QAC/B,GAAG,EAAE,6BAGX,CAAA;AAED,eAAO,MAAM,mBAAmB,QACzB,GAAG,EAAE,0CAGX,CAAA;AA6BD,eAAO,MAAM,eAAe,aAChB,yBAAyB,cACvB,yBAAyB,YAoDtC,CAAA"}
|
package/dist/lib/utils.js
CHANGED
|
@@ -480,58 +480,4 @@ export const shouldShowBlock = (envState, blockState) => {
|
|
|
480
480
|
}
|
|
481
481
|
return hasMatchingMetafields || hasMatchingTags;
|
|
482
482
|
};
|
|
483
|
-
// Helper to evaluate v2 conditions
|
|
484
|
-
export const evaluateConditions = (group, context) => {
|
|
485
|
-
const { logic = "OR", conditions = [] } = group;
|
|
486
|
-
console.log("Evaluating group:", { logic, conditions });
|
|
487
|
-
const results = conditions.map((condition) => {
|
|
488
|
-
if (condition.logic) {
|
|
489
|
-
return evaluateConditions(condition, context); // Nested group
|
|
490
|
-
}
|
|
491
|
-
else {
|
|
492
|
-
const result = evaluateSingleCondition(condition, context);
|
|
493
|
-
console.log("Evaluated condition:", { condition, result });
|
|
494
|
-
return result;
|
|
495
|
-
}
|
|
496
|
-
});
|
|
497
|
-
console.log("Results:", { results, logic });
|
|
498
|
-
switch (logic) {
|
|
499
|
-
case "AND":
|
|
500
|
-
return results.every(Boolean);
|
|
501
|
-
case "OR":
|
|
502
|
-
return results.some(Boolean);
|
|
503
|
-
case "NOT":
|
|
504
|
-
return !results.some(Boolean);
|
|
505
|
-
default:
|
|
506
|
-
throw new Error(`Unsupported logic operator: ${logic}`);
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
// Helper to evaluate a single condition
|
|
510
|
-
export const evaluateSingleCondition = (condition, context) => {
|
|
511
|
-
const { type, operator, value } = condition;
|
|
512
|
-
const contextValue = context[type];
|
|
513
|
-
if (!contextValue) {
|
|
514
|
-
return false; // If the context doesn't have the required type, return false
|
|
515
|
-
}
|
|
516
|
-
switch (operator) {
|
|
517
|
-
case "equals":
|
|
518
|
-
if (Array.isArray(contextValue)) {
|
|
519
|
-
// Handle arrays of UserSelectedTag or ConditionalSelectorMetafield
|
|
520
|
-
return contextValue.some((item) => item.value === value);
|
|
521
|
-
}
|
|
522
|
-
else {
|
|
523
|
-
return contextValue === value;
|
|
524
|
-
}
|
|
525
|
-
case "contains":
|
|
526
|
-
if (Array.isArray(contextValue)) {
|
|
527
|
-
// Handle arrays of UserSelectedTag or ConditionalSelectorMetafield
|
|
528
|
-
return contextValue.some((item) => item.value === value);
|
|
529
|
-
}
|
|
530
|
-
else {
|
|
531
|
-
return contextValue.includes(value);
|
|
532
|
-
}
|
|
533
|
-
default:
|
|
534
|
-
throw new Error(`Unsupported operator: ${operator}`);
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
483
|
// --- End (Block conditional rendering util functions) ----
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeProvider.d.ts","sourceRoot":"","sources":["../../components/ThemeProvider.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAE3D,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,kBAAkB,2CAEvE"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
-
var t = {};
|
|
4
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
-
t[p] = s[p];
|
|
6
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
-
t[p[i]] = s[p[i]];
|
|
10
|
-
}
|
|
11
|
-
return t;
|
|
12
|
-
};
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { ThemeProvider as NextThemesProvider } from "next-themes";
|
|
15
|
-
export function ThemeProvider(_a) {
|
|
16
|
-
var { children } = _a, props = __rest(_a, ["children"]);
|
|
17
|
-
return _jsx(NextThemesProvider, Object.assign({}, props, { children: children }));
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ThemeToggle.d.ts","sourceRoot":"","sources":["../../components/ThemeToggle.tsx"],"names":[],"mappings":"AAOA,wBAAgB,WAAW,4CAc1B"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useTheme } from "next-themes";
|
|
4
|
-
import { Button } from "../components/ui/button";
|
|
5
|
-
export function ThemeToggle() {
|
|
6
|
-
const { setTheme, theme } = useTheme();
|
|
7
|
-
return (_jsxs(Button, Object.assign({ variant: "ghost", size: "sm", onClick: () => setTheme(theme === "light" ? "dark" : "light") }, { children: [_jsx("div", { className: "rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" }), _jsx("div", { className: "absolute rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" }), _jsx("span", Object.assign({ className: "sr-only" }, { children: "Toggle theme" }))] })));
|
|
8
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-block-conditionals.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditionals.ts"],"names":[],"mappings":""}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { type VariantProps } from "class-variance-authority";
|
|
3
|
-
declare const inputVariants: (props?: ({
|
|
4
|
-
error?: boolean | null | undefined;
|
|
5
|
-
} & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
|
|
6
|
-
export interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "onChange">, VariantProps<typeof inputVariants> {
|
|
7
|
-
id: string;
|
|
8
|
-
label?: string;
|
|
9
|
-
icon?: string;
|
|
10
|
-
asChild?: boolean;
|
|
11
|
-
value: string;
|
|
12
|
-
placeholder: string;
|
|
13
|
-
onChange: (_: string) => void;
|
|
14
|
-
}
|
|
15
|
-
declare const Input: React.ForwardRefExoticComponent<InputProps & React.RefAttributes<HTMLInputElement>>;
|
|
16
|
-
export { Input };
|
|
17
|
-
//# sourceMappingURL=input.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"input.d.ts","sourceRoot":"","sources":["../../../components/ui/input.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,QAAA,MAAM,aAAa;;mFAalB,CAAA;AAED,MAAM,WAAW,UACf,SAAQ,IAAI,CAAC,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,EAAE,UAAU,CAAC,EACnE,YAAY,CAAC,OAAO,aAAa,CAAC;IACpC,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC9B;AAED,QAAA,MAAM,KAAK,qFAkDV,CAAA;AAGD,OAAO,EAAE,KAAK,EAAE,CAAA"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
-
import * as React from "react";
|
|
14
|
-
import { Slot } from "@radix-ui/react-slot";
|
|
15
|
-
import { cva } from "class-variance-authority";
|
|
16
|
-
import { cn } from "../../lib/utils";
|
|
17
|
-
import { Icon } from "./icon";
|
|
18
|
-
const inputVariants = cva("flex h-14 w-full rounded border border-coreColors-dividingLines bg-coreColors-inputBackground px-4 pt-5 pb-2 placeholder-shown:p-4 text-textColors-primaryColor text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-textColors-secondaryColor focus-visible:outline-none focus-visible:ring-0 disabled:cursor-not-allowed disabled:opacity-50 focus:border-coreColors-brandColorPrimary peer data-[icon=true]:pr-10", {
|
|
19
|
-
variants: {
|
|
20
|
-
error: {
|
|
21
|
-
true: "border-stateColors-error text-stateColors-error placeholder:text-stateColors-error focus:border-stateColors-error [&+label]:text-stateColors-error",
|
|
22
|
-
false: "",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
defaultVariants: {
|
|
26
|
-
error: false,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
const Input = React.forwardRef((_a, ref) => {
|
|
30
|
-
var { className, error = false, id, type, label, icon, asChild, value, placeholder, onChange } = _a, props = __rest(_a, ["className", "error", "id", "type", "label", "icon", "asChild", "value", "placeholder", "onChange"]);
|
|
31
|
-
const Comp = asChild ? Slot : "div";
|
|
32
|
-
return (_jsxs(Comp, Object.assign({ className: "relative group" }, { children: [_jsx("input", Object.assign({ placeholder: placeholder, value: value, onChange: (e) => onChange(e.target.value), id: id, type: type, className: cn(inputVariants({ error }), className), "data-icon": !!icon, ref: ref }, props)), label ? (_jsx("label", Object.assign({ htmlFor: id, className: "absolute text-[10px] text-textColors-secondaryColor group-active:text-coreColors-brandColorPrimary top-2 z-10 h-4 origin-[0] start-4 opacity-100 peer-placeholder-shown:opacity-0" }, { children: label }))) : null, icon ? (_jsx(Icon, { name: icon, "data-error": error, size: "sm", className: "absolute w-5 aspect-square fill-current text-textColors-secondaryColor top-[18px] z-10 origin-[0] end-4 peer-pr-8 icon data-[error=true]:text-stateColors-error" })) : null] })));
|
|
33
|
-
});
|
|
34
|
-
Input.displayName = "Input";
|
|
35
|
-
export { Input };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
type Product = any;
|
|
2
|
-
interface PageData {
|
|
3
|
-
products: Product[];
|
|
4
|
-
cursorBlob?: string;
|
|
5
|
-
filtersData: any;
|
|
6
|
-
}
|
|
7
|
-
interface ProductGridItemsProps {
|
|
8
|
-
initialData: PageData;
|
|
9
|
-
loadMoreProducts: (params: any) => Promise<PageData>;
|
|
10
|
-
queryVariables: Record<string, any>;
|
|
11
|
-
config: Record<string, any>;
|
|
12
|
-
}
|
|
13
|
-
declare function ProductGrid({ loadMoreProducts, initialData, queryVariables, config, }: ProductGridItemsProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
-
export { ProductGrid };
|
|
15
|
-
//# sourceMappingURL=product-grid.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"product-grid.d.ts","sourceRoot":"","sources":["../../../components/ui/product-grid.tsx"],"names":[],"mappings":"AAkBA,KAAK,OAAO,GAAG,GAAG,CAAA;AAClB,UAAU,QAAQ;IAChB,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,GAAG,CAAA;CACjB;AAED,UAAU,qBAAqB;IAC7B,WAAW,EAAE,QAAQ,CAAA;IACrB,gBAAgB,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAA;IACpD,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5B;AAED,iBAAS,WAAW,CAAC,EACnB,gBAAgB,EAChB,WAAW,EACX,cAAc,EACd,MAAM,GACP,EAAE,qBAAqB,2CAmCvB;AAED,OAAO,EAAE,WAAW,EAAE,CAAA"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useInfiniteScroll } from "../hooks/use-infinite-scroll";
|
|
4
|
-
import { ProductCard } from "./product-card";
|
|
5
|
-
const Loader = () => (_jsx("div", Object.assign({ className: "grid-cols-2 lg:grid-cols-3" }, { children: Array(4)
|
|
6
|
-
.fill(0)
|
|
7
|
-
.map((_, index) => (_jsx("div", { className: "aspect-[2/3] animate-pulse bg-neutral-100 dark:bg-neutral-900" }, index))) })));
|
|
8
|
-
function ProductGrid({ loadMoreProducts, initialData, queryVariables, config, }) {
|
|
9
|
-
const { data, error, isLoadingInitialData, isLoadingMore, isEmpty, isReachingEnd, ref, products, } = useInfiniteScroll({
|
|
10
|
-
initialData,
|
|
11
|
-
loadMoreProducts,
|
|
12
|
-
queryVariables,
|
|
13
|
-
});
|
|
14
|
-
if (error)
|
|
15
|
-
return _jsx("div", { children: "Failed to load data" });
|
|
16
|
-
if (isLoadingInitialData)
|
|
17
|
-
return _jsx(Loader, {});
|
|
18
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", Object.assign({ className: "grid-cols-2 lg:grid-cols-3" }, { children: products.map((product, i) => (_jsx(ProductCard, {
|
|
19
|
-
// @ts-expect-error
|
|
20
|
-
product: product, config: config, isLoading: false }, product.handle))) })), isLoadingMore ? _jsx(Loader, {}) : _jsx("div", { ref: ref })] }));
|
|
21
|
-
}
|
|
22
|
-
export { ProductGrid };
|