@tapcart/mobile-components 0.7.47 → 0.7.48

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.
@@ -0,0 +1,3 @@
1
+ import { ThemeProviderProps } from "next-themes/dist/types";
2
+ export declare function ThemeProvider({ children, ...props }: ThemeProviderProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=ThemeProvider.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,18 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ export declare function ThemeToggle(): import("react/jsx-runtime").JSX.Element;
2
+ //# sourceMappingURL=ThemeToggle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeToggle.d.ts","sourceRoot":"","sources":["../../components/ThemeToggle.tsx"],"names":[],"mappings":"AAOA,wBAAgB,WAAW,4CAc1B"}
@@ -0,0 +1,8 @@
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 +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;AAezB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,UACO,YAAY;;;CAyJrB,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;AAgBzB,eAAO,MAAM,4BAA4B,WAC/B;IACN,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACf,UACO,YAAY;;;CAuMrB,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, } from "../../lib/utils";
19
+ import { gidFromId, countNumberOfTagsInState, getEnvState, shouldShowBlock, evaluateConditions, } from "../../lib/utils";
20
20
  export const useBlockConditionalRendering = (_props, _block) => {
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;
21
+ var _a, _b, _c, _d, _e;
22
+ const _f = ((_a = _block === null || _block === void 0 ? void 0 : _block.visibilityConditions) === null || _a === void 0 ? void 0 : _a.conditions) || {}, { enabled: conditionalsV1IsEnabled = false, exclude: isInverse = false } = _f, restOfProps = __rest(_f, ["enabled", "exclude"]);
23
+ const { _version = 1, conditions, enabled: conditionalsV2IsEnabled = false, } = (_block === null || _block === void 0 ? void 0 : _block.visibilityConditions) || {};
24
24
  const blockState = restOfProps;
25
25
  const { appId = "", apiUrl = "" } = _props;
26
26
  const searchParams = useSearchParams();
@@ -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: useProductsLoading, } = useProducts(productId !== undefined && isEnabled
48
+ const { products, error: useProductsError, isLoading: isProductsLoading, } = useProducts(productId !== undefined && conditionalsV1IsEnabled
49
49
  ? {
50
50
  productIds: [gidFromId(productId)],
51
51
  baseURL: apiUrl,
@@ -70,7 +70,7 @@ export const useBlockConditionalRendering = (_props, _block) => {
70
70
  : undefined, [collectionMetafieldsQuery]);
71
71
  const collectionId = (_d = searchParams.get("collectionId")) !== null && _d !== void 0 ? _d : undefined;
72
72
  const collectionHandle = (_e = searchParams.get("collectionHandle")) !== null && _e !== void 0 ? _e : undefined;
73
- const { specificCollection = {}, error: useCollectionError, loading: useCollectionLoading, } = useCollection({
73
+ const { specificCollection = {}, error: useCollectionError, loading: isCollectionLoading, } = useCollection({
74
74
  appId,
75
75
  apiUrl,
76
76
  collectionId,
@@ -78,42 +78,81 @@ 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;
81
83
  if (useProductsError || useCollectionError) {
82
84
  console.error("Unable to load products in conditional block rendering hook: ", useProductsError !== null && useProductsError !== void 0 ? useProductsError : useCollectionError);
83
85
  }
86
+ // Build context for condition evaluation
87
+ const context = {
88
+ location,
89
+ products,
90
+ collection: specificCollection,
91
+ customer: customerVariables,
92
+ };
93
+ console.log({ context, blockState, conditions });
94
+ let shouldShow = true;
95
+ const blockConditionalsIsEnabled = conditionalsV1IsEnabled || conditionalsV2IsEnabled;
84
96
  try {
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;
97
+ // if (blockConditionalsIsEnabled) {
98
+ // if (_version === 2) {
99
+ // // Evaluate v2 conditions
100
+ // shouldShow = evaluateConditions(conditions, context)
101
+ // } else {
102
+ // // Evaluate v1 conditions
103
+ // const blockHasTags = countNumberOfTagsInState(blockState) > 0
104
+ // if (blockHasTags) {
105
+ // const product = products.length === 1 ? products[0] : undefined
106
+ // const envState = getEnvState({
107
+ // location,
108
+ // product,
109
+ // collection: specificCollection as Collection,
110
+ // customer: customerVariables,
111
+ // })
112
+ // //@ts-expect-errors envState typing doesn't match
113
+ // const shouldShowPreInverse = shouldShowBlock(envState, blockState)
114
+ // // TODO: Currently negation of properties is not available but is required for migration of certain merchants
115
+ // // This code is to be removed and updated when inverse feature is available for all blocks
116
+ // // If exclude tag is applied then block should show inversely
117
+ // if (isInverse) {
118
+ // shouldShow = !shouldShowPreInverse
119
+ // } else {
120
+ // shouldShow = shouldShowPreInverse
121
+ // }
122
+ // }
123
+ // }
124
+ // } else {
125
+ // // If visibility conditions are disabled, always show the block
126
+ // shouldShow = true
127
+ // }
128
+ if (blockConditionalsIsEnabled) {
129
+ const product = products.length === 1 ? products[0] : undefined;
130
+ const envState = getEnvState({
131
+ location,
132
+ product,
133
+ collection: specificCollection,
134
+ customer: customerVariables,
135
+ });
136
+ if (_version === 2) {
137
+ //@ts-expect-error
138
+ shouldShow = evaluateConditions(conditions, envState);
139
+ }
140
+ else {
141
+ const blockHasTags = countNumberOfTagsInState(blockState) > 0;
142
+ if (blockHasTags) {
143
+ //@ts-expect-error
144
+ const shouldShowPreInverse = shouldShowBlock(envState, blockState);
145
+ shouldShow = isInverse ? !shouldShowPreInverse : shouldShowPreInverse;
106
146
  }
107
147
  }
108
148
  }
109
- // if conditionals is disabled, show the block.
110
- if (!isEnabled) {
111
- return { shouldShow: true, isLoading: false };
149
+ else {
150
+ shouldShow = true;
112
151
  }
113
- return { shouldShow, isLoading: useProductsLoading || useCollectionLoading };
114
152
  }
115
153
  catch (e) {
116
- console.error("conditionals error: ", e);
117
- return { shouldShow: true, isLoading: false };
154
+ console.error("Error evaluating block visibility conditions:", e);
155
+ shouldShow = true; // Fallback to showing the block
118
156
  }
157
+ return { shouldShow, isLoading };
119
158
  };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=use-block-conditionals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-block-conditionals.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-block-conditionals.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ export {};
@@ -0,0 +1,17 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,35 @@
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 };
@@ -0,0 +1,15 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,22 @@
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 };
@@ -247,4 +247,7 @@ 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 evaluateSingleCondition: (condition: any, context: any) => boolean;
251
+ export declare const evaluateCondition: (condition: any, envState: ConditionalSelectorValues) => any;
252
+ export declare const evaluateConditions: (conditionsObj: any, envState: ConditionalSelectorValues) => boolean;
250
253
  //# sourceMappingURL=utils.d.ts.map
@@ -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,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAA;AAEpD,MAAM,MAAM,OAAO,GAAG;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,UAAU,mBAAmB;IAC3B,SAAS,EAAE,iBAAiB,CAAA;I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C/B,GAAG,EAAE,6BAGX,CAAA;AAED,eAAO,MAAM,mBAAmB,QACzB,GAAG,EAAE,0CAGX,CAAA;AA6BD,eAAO,MAAM,eAAe,aAChB,yBAAyB,cACvB,yBAAyB,YAoDtC,CAAA;AA0BD,eAAO,MAAM,uBAAuB,cACvB,GAAG,WACL,GAAG,KACX,OAYF,CAAA;AAED,eAAO,MAAM,iBAAiB,cACjB,GAAG,YACJ,yBAAyB,QAgBpC,CAAA;AAED,eAAO,MAAM,kBAAkB,kBACd,GAAG,YACR,yBAAyB,KAClC,OAgBF,CAAA"}
package/dist/lib/utils.js CHANGED
@@ -480,4 +480,70 @@ 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: any, context: any): boolean => {
485
+ // const { logic = "OR", conditions = [] } = group
486
+ // const results = conditions.map(
487
+ // (condition: any) =>
488
+ // condition.logic
489
+ // ? evaluateConditions(condition, context) // Nested group
490
+ // : evaluateSingleCondition(condition, context) // Single condition
491
+ // )
492
+ // console.log({ results, logic })
493
+ // switch (logic) {
494
+ // case "AND":
495
+ // return results.every(Boolean)
496
+ // case "OR":
497
+ // return results.some(Boolean)
498
+ // case "NOT":
499
+ // return !results.some(Boolean)
500
+ // default:
501
+ // throw new Error(`Unsupported logic operator: ${logic}`)
502
+ // }
503
+ // }
504
+ // Helper to evaluate a single condition
505
+ export const evaluateSingleCondition = (condition, context) => {
506
+ const { type, operator, value } = condition;
507
+ const contextValue = context[type];
508
+ switch (operator) {
509
+ case "equals":
510
+ return contextValue === value;
511
+ case "contains":
512
+ return Array.isArray(contextValue) && contextValue.includes(value);
513
+ default:
514
+ throw new Error(`Unsupported operator: ${operator}`);
515
+ }
516
+ };
517
+ export const evaluateCondition = (condition, envState) => {
518
+ var _a;
519
+ const { type, operator, value } = condition;
520
+ const envValues =
521
+ // @ts-expect-error
522
+ ((_a = envState[type]) === null || _a === void 0 ? void 0 : _a.map((item) => item.value)) || [];
523
+ switch (operator) {
524
+ case "equals":
525
+ return envValues.includes(value);
526
+ case "contains":
527
+ return envValues.some((envValue) => envValue.includes(value));
528
+ default:
529
+ console.warn(`Unknown operator: ${operator}`);
530
+ return false;
531
+ }
532
+ };
533
+ export const evaluateConditions = (conditionsObj, envState) => {
534
+ const { logic, conditions } = conditionsObj;
535
+ if (!conditions || conditions.length === 0)
536
+ return true;
537
+ const results = conditions.map((condition) => {
538
+ if (condition.conditions) {
539
+ // Nested condition group (AND/OR)
540
+ return evaluateConditions(condition, envState);
541
+ }
542
+ else {
543
+ // Single condition check
544
+ return evaluateCondition(condition, envState);
545
+ }
546
+ });
547
+ return logic === "AND" ? results.every(Boolean) : results.some(Boolean);
548
+ };
483
549
  // --- End (Block conditional rendering util functions) ----
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.47",
3
+ "version": "0.7.48",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",
@@ -11,6 +11,19 @@
11
11
  "license": "SEE LICENSE IN LICENSE.md",
12
12
  "author": "Tapcart Inc.",
13
13
  "homepage": "https://tapcart.com",
14
+ "scripts": {
15
+ "lint": "eslint \"**/*.ts*\"",
16
+ "ui:add": "pnpm dlx shadcn-ui@latest add",
17
+ "build:styles": "postcss styles/globals.css -o dist/styles.css",
18
+ "build:ts": "tsc -p tsconfig.json && tsc-alias",
19
+ "build": "pnpm run build:ts && pnpm run build:styles",
20
+ "dev:ts": "tsc -w -p tsconfig.json",
21
+ "dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
22
+ "dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
23
+ "test": "jest",
24
+ "test:silent": "jest --silent",
25
+ "test:watch": "jest --watch"
26
+ },
14
27
  "peerDependencies": {
15
28
  "react": "^17.0.2 || ^18.0.0",
16
29
  "react-dom": "^17.0.2 || ^18.0.0"
@@ -21,21 +34,21 @@
21
34
  "@types/lodash": "4.17.5",
22
35
  "@types/react": "^18.2.0",
23
36
  "@types/react-dom": "^18.2.0",
37
+ "app-studio-types": "workspace:*",
24
38
  "autoprefixer": "^10.4.14",
25
39
  "chokidar-cli": "^3.0.0",
26
40
  "concurrently": "^8.2.2",
27
41
  "eslint": "^7.32.0",
42
+ "eslint-config-custom": "workspace:*",
28
43
  "jest": "^29.7.0",
29
44
  "jest-environment-jsdom": "^29.7.0",
30
45
  "postcss": "^8.4.24",
31
46
  "tailwindcss": "^3.3.2",
32
47
  "ts-jest": "^29.2.5",
33
48
  "tsc-alias": "^1.8.10",
49
+ "tsconfig": "workspace:*",
34
50
  "typescript": "^4.5.2",
35
- "@testing-library/react-hooks": "^8.0.1",
36
- "app-studio-types": "0.0.6",
37
- "tsconfig": "0.0.0",
38
- "eslint-config-custom": "0.0.0"
51
+ "@testing-library/react-hooks": "^8.0.1"
39
52
  },
40
53
  "dependencies": {
41
54
  "@radix-ui/react-accordion": "^1.1.2",
@@ -74,18 +87,5 @@
74
87
  "tailwind-merge": "^1.13.2",
75
88
  "tailwindcss-animate": "^1.0.6",
76
89
  "vaul": "0.9.1"
77
- },
78
- "scripts": {
79
- "lint": "eslint \"**/*.ts*\"",
80
- "ui:add": "pnpm dlx shadcn-ui@latest add",
81
- "build:styles": "postcss styles/globals.css -o dist/styles.css",
82
- "build:ts": "tsc -p tsconfig.json && tsc-alias",
83
- "build": "pnpm run build:ts && pnpm run build:styles",
84
- "dev:ts": "tsc -w -p tsconfig.json",
85
- "dev:styles": "npx tailwindcss -i styles/globals.css -o dist/styles.css --watch",
86
- "dev": "concurrently \"pnpm run dev:ts\" \"pnpm run dev:styles\"",
87
- "test": "jest",
88
- "test:silent": "jest --silent",
89
- "test:watch": "jest --watch"
90
90
  }
91
- }
91
+ }
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- export declare function useClickOutside(ref: React.RefObject<HTMLElement>, callback: () => void): void;
3
- //# sourceMappingURL=use-click-outside.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-click-outside.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-click-outside.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,wBAAgB,eAAe,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAE,IAAI,CAa5F"}
@@ -1,16 +0,0 @@
1
- "use client";
2
- import React from 'react';
3
- export function useClickOutside(ref, callback) {
4
- React.useEffect(() => {
5
- const handleClickOutside = (event) => {
6
- if (ref.current && !ref.current.contains(event.target)) {
7
- callback();
8
- }
9
- };
10
- document.addEventListener('mousedown', handleClickOutside);
11
- return () => {
12
- document.removeEventListener('mousedown', handleClickOutside);
13
- };
14
- }, [ref, callback]);
15
- }
16
- ;
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- declare const useClickOutside: (ref: React.RefObject<HTMLElement>, callback: () => void) => void;
3
- export default useClickOutside;
4
- //# sourceMappingURL=use-outside-click.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-outside-click.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-outside-click.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,QAAA,MAAM,eAAe,QAAS,MAAM,SAAS,CAAC,WAAW,CAAC,YAAY,MAAM,IAAI,SAa/E,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -1,16 +0,0 @@
1
- "use client";
2
- import React from 'react';
3
- const useClickOutside = (ref, callback) => {
4
- React.useEffect(() => {
5
- const handleClickOutside = (event) => {
6
- if (ref.current && !ref.current.contains(event.target)) {
7
- callback();
8
- }
9
- };
10
- document.addEventListener('mousedown', handleClickOutside);
11
- return () => {
12
- document.removeEventListener('mousedown', handleClickOutside);
13
- };
14
- }, [ref, callback]);
15
- };
16
- export default useClickOutside;