@tapcart/mobile-components 0.7.22 → 0.7.24

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 React from 'react';
2
+ export declare function useClickOutside(ref: React.RefObject<HTMLElement>, callback: () => void): void;
3
+ //# sourceMappingURL=use-click-outside.d.ts.map
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,16 @@
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
+ ;
@@ -0,0 +1,4 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,16 @@
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;
@@ -1 +1 @@
1
- {"version":3,"file":"use-recommendations.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-recommendations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAKtD,UAAU,sBAAsB;IAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;CACX;AAOD,QAAA,MAAM,kBAAkB,+BAGrB,sBAAsB,KAAG,uBAsC3B,CAAA;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
1
+ {"version":3,"file":"use-recommendations.d.ts","sourceRoot":"","sources":["../../../components/hooks/use-recommendations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAKtD,UAAU,sBAAsB;IAC9B,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACnC,MAAM,EAAE,MAAM,CAAA;CACf;AAED,UAAU,uBAAuB;IAC/B,QAAQ,EAAE,OAAO,EAAE,CAAA;IACnB,WAAW,EAAE,UAAU,EAAE,CAAA;IACzB,QAAQ,EAAE,MAAM,EAAE,CAAA;IAClB,SAAS,EAAE,OAAO,CAAA;IAClB,KAAK,EAAE,GAAG,CAAA;CACX;AAOD,QAAA,MAAM,kBAAkB,+BAGrB,sBAAsB,KAAG,uBAiC3B,CAAA;AAED,OAAO,EAAE,kBAAkB,EAAE,CAAA"}
@@ -7,27 +7,24 @@ const constructURL = (apiURL) => {
7
7
  };
8
8
  const useRecommendations = ({ queryVariables, apiURL }) => {
9
9
  const searchParams = useSearchParams();
10
- const recommendation = searchParams.get('recommendation');
11
- const shouldFetch = recommendation && recommendation.trim().length > 0;
12
- //To remove when pageState data is available to block tempaltes
10
+ const recommendation = (searchParams === null || searchParams === void 0 ? void 0 : searchParams.get('recommendation')) || "*";
11
+ const isBestSeller = recommendation === "*";
13
12
  const fetcher = (body) => fetch(constructURL(apiURL), {
14
13
  method: "POST",
15
14
  body: JSON.stringify(body),
16
15
  }).then((res) => res.json());
17
- const { data, error, isLoading } = useSWR(shouldFetch
18
- ? {
19
- appId: queryVariables.appId,
20
- query: recommendation,
21
- language: queryVariables.language,
22
- }
23
- : null, fetcher, {
16
+ const { data, error, isLoading } = useSWR({
17
+ appId: queryVariables.appId,
18
+ query: recommendation,
19
+ language: queryVariables.language,
20
+ }, fetcher, {
24
21
  revalidateOnFocus: false,
25
22
  revalidateOnReconnect: false,
26
23
  });
27
24
  return {
28
25
  products: data === null || data === void 0 ? void 0 : data.products,
29
26
  collections: data === null || data === void 0 ? void 0 : data.collections,
30
- searches: data === null || data === void 0 ? void 0 : data.searches,
27
+ searches: isBestSeller ? [] : data === null || data === void 0 ? void 0 : data.searches,
31
28
  isLoading: isLoading,
32
29
  error: error
33
30
  };
@@ -3,6 +3,7 @@ import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
3
3
  type Orientation = "horizontal" | "vertical";
4
4
  declare const ScrollArea: React.ForwardRefExoticComponent<Omit<ScrollAreaPrimitive.ScrollAreaProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
5
5
  wrapperClass?: string | undefined;
6
+ wrapperStyle?: React.CSSProperties | undefined;
6
7
  scrollbar: boolean;
7
8
  } & React.RefAttributes<HTMLDivElement>>;
8
9
  declare const ScrollBar: React.ForwardRefExoticComponent<Omit<ScrollAreaPrimitive.ScrollAreaScrollbarProps & React.RefAttributes<HTMLDivElement>, "ref"> & {
@@ -1 +1 @@
1
- {"version":3,"file":"scroll-area.d.ts","sourceRoot":"","sources":["../../../components/ui/scroll-area.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,mBAAmB,MAAM,6BAA6B,CAAA;AAIlE,KAAK,WAAW,GAAG,YAAY,GAAG,UAAU,CAAA;AAE5C,QAAA,MAAM,UAAU;;eAID,OAAO;wCAcpB,CAAA;AAGF,QAAA,MAAM,SAAS;;wCAuBb,CAAA;AAGF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA"}
1
+ {"version":3,"file":"scroll-area.d.ts","sourceRoot":"","sources":["../../../components/ui/scroll-area.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,KAAK,mBAAmB,MAAM,6BAA6B,CAAA;AAIlE,KAAK,WAAW,GAAG,YAAY,GAAG,UAAU,CAAA;AAE5C,QAAA,MAAM,UAAU;;;eAKD,OAAO;wCA4BrB,CAAA;AAGD,QAAA,MAAM,SAAS;;wCAuBb,CAAA;AAGF,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,CAAA"}
@@ -15,8 +15,8 @@ import * as React from "react";
15
15
  import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
16
16
  import { cn } from "../../lib/utils";
17
17
  const ScrollArea = React.forwardRef((_a, ref) => {
18
- var { className, wrapperClass, scrollbar = true, children } = _a, props = __rest(_a, ["className", "wrapperClass", "scrollbar", "children"]);
19
- return (_jsxs(ScrollAreaPrimitive.Root, Object.assign({ ref: ref, className: cn("relative overflow-hidden", className) }, props, { children: [_jsx(ScrollAreaPrimitive.Viewport, Object.assign({ className: "h-full w-full rounded-[inherit]" }, { children: _jsx("div", Object.assign({ className: cn("flex w-max", wrapperClass) }, { children: children })) })), _jsx(ScrollBar, { className: scrollbar ? "" : "hidden" }), _jsx(ScrollAreaPrimitive.Corner, {})] })));
18
+ var { className, wrapperClass, wrapperStyle, scrollbar = true, children } = _a, props = __rest(_a, ["className", "wrapperClass", "wrapperStyle", "scrollbar", "children"]);
19
+ return (_jsxs(ScrollAreaPrimitive.Root, Object.assign({ ref: ref, className: cn("relative overflow-hidden", className) }, props, { children: [_jsx(ScrollAreaPrimitive.Viewport, Object.assign({ className: "h-full w-full rounded-[inherit]" }, { children: _jsx("div", Object.assign({ className: cn("flex w-max", wrapperClass), style: wrapperStyle }, { children: children })) })), _jsx(ScrollBar, { className: scrollbar ? "" : "hidden" }), _jsx(ScrollAreaPrimitive.Corner, {})] })));
20
20
  });
21
21
  ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
22
22
  const ScrollBar = React.forwardRef((_a, ref) => {
package/dist/styles.css CHANGED
@@ -847,6 +847,9 @@ video {
847
847
  .mr-4 {
848
848
  margin-right: 1rem;
849
849
  }
850
+ .mr-8 {
851
+ margin-right: 2rem;
852
+ }
850
853
  .mt-0 {
851
854
  margin-top: 0px;
852
855
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.22",
3
+ "version": "0.7.24",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",
@@ -30,9 +30,9 @@
30
30
  "ts-jest": "^29.2.5",
31
31
  "tsc-alias": "^1.8.10",
32
32
  "typescript": "^4.5.2",
33
- "tsconfig": "0.0.0",
33
+ "app-studio-types": "0.0.5",
34
34
  "eslint-config-custom": "0.0.0",
35
- "app-studio-types": "0.0.5"
35
+ "tsconfig": "0.0.0"
36
36
  },
37
37
  "dependencies": {
38
38
  "@radix-ui/react-accordion": "^1.1.2",
@@ -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 };