@tapcart/mobile-components 0.4.8 → 0.4.9

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/README.md ADDED
@@ -0,0 +1,228 @@
1
+ <img src="https://camo.githubusercontent.com/142e2209c9496438237cf85ced995885cd1e0b92638604537670c2febf3fae28/68747470733a2f2f73746f726167652e676f6f676c65617069732e636f6d2f746170636172742d61737365742d75706c6f6164732d70726f642f64782d6769746875622e706e67" alt="" data-canonical-src="https://storage.googleapis.com/tapcart-asset-uploads-prod/dx-github.png" style="max-width: 100%;">
2
+
3
+ [@tapcart/mobile-components](https://www.npmjs.com/package/@tapcart/mobile-components)
4
+
5
+ # @tapcart/mobile-components
6
+ ### Build the next-gen shopper experience for Tapcart's core product, the mobile app.
7
+
8
+ | Status | Owner | Help |
9
+ | ------ | ----------- | ----------- |
10
+ | Active | @tapcart/mobile-components | dev@tapcart.com |
11
+
12
+ # About this repo
13
+ The tapcart/mobile-components repository is a component library made up of all the code components that drive our app experience.
14
+
15
+ # Installation using NPM
16
+ ### Install into your React.js project
17
+ `npm install @tapcart/mobile-components`
18
+
19
+ # Usage
20
+ **Easy. Cake. Done.**
21
+
22
+ ```
23
+ import {
24
+ Button,
25
+ Input,
26
+ Accordion,
27
+ AccordionContent,
28
+ AccordionItem,
29
+ AccordionTrigger,
30
+ AspectRatio,
31
+ Switch,
32
+ Label,
33
+ Separator,
34
+ Badge,
35
+ Video,
36
+ ScrollArea,
37
+ Text,
38
+ Toast,
39
+ Toaster,
40
+ useToast,
41
+ Icon,
42
+ Container,
43
+ Grid,
44
+ ToggleGroup,
45
+ ToggleGroupItem,
46
+ } from "@tapcart/mobile-components";
47
+
48
+ <Video>
49
+ <source src="https://assets.tapcart.com/image-block/video/FhEjfK4zD2_6614803b487c620032dc21c4.mp4" />
50
+ </Video>
51
+
52
+ <Separator />
53
+
54
+ <Container variant="spaced">
55
+ <Input placeholder="Search for products" type="email"></Input>
56
+ </Container>
57
+
58
+ <Separator />
59
+
60
+ <Accordion type="single" collapsible className="w-full">
61
+ <AccordionItem value="item-1">
62
+ <Container>
63
+ <AccordionTrigger>
64
+ <div className="flex">
65
+ <Icon>
66
+ <svg
67
+ width="15"
68
+ height="18"
69
+ viewBox="0 0 15 18"
70
+ fill="none"
71
+ xmlns="http://www.w3.org/2000/svg"
72
+ >
73
+ <path
74
+ d="M7.3 8.14a4.08 4.08 0 0 1-4.07-4.07C3.23 1.83 5.05 0 7.3 0s4.07 1.83 4.07 4.07A4.08 4.08 0 0 1 7.3 8.14Zm0-6.64a2.57 2.57 0 1 0 0 5.14 2.57 2.57 0 1 0 0-5.14ZM12.88 17.69H1.72c-.95 0-1.72-.77-1.72-1.72 0-3.54 2.88-6.42 6.42-6.42h1.76c3.54 0 6.42 2.88 6.42 6.42 0 .95-.77 1.72-1.72 1.72Zm-6.46-6.64a4.93 4.93 0 0 0-4.92 4.92c0 .12.1.22.22.22h11.16c.12 0 .22-.1.22-.22a4.93 4.93 0 0 0-4.92-4.92H6.42Z"
75
+ fill="currentColor"
76
+ ></path>
77
+ </svg>
78
+ </Icon>
79
+ Product details
80
+ </div>
81
+ </AccordionTrigger>
82
+ <AccordionContent>
83
+ <img src="https://assets.tapcart.com/pdp/images/FhEjfK4zD2_6629470724b8221a7b750a97.png" />
84
+ </AccordionContent>
85
+ </Container>
86
+ </AccordionItem>
87
+ <AccordionItem value="item-2">
88
+ <Container>
89
+ <AccordionTrigger>
90
+ <div className="flex">
91
+ <Icon>
92
+ <svg
93
+ width="18"
94
+ height="17"
95
+ viewBox="0 0 18 17"
96
+ fill="none"
97
+ xmlns="http://www.w3.org/2000/svg"
98
+ >
99
+ <path
100
+ d="M6.61 13.22c-1.77 0-3.43-.69-4.67-1.94A6.567 6.567 0 0 1 0 6.61c0-1.76.69-3.43 1.94-4.67A6.533 6.533 0 0 1 6.61 0c1.77 0 3.43.69 4.67 1.94a6.567 6.567 0 0 1 1.94 4.67c0 1.76-.69 3.43-1.94 4.67a6.567 6.567 0 0 1-4.67 1.94Zm0-11.72C5.24 1.5 3.96 2.03 3 3c-.97.97-1.5 2.25-1.5 3.61 0 1.36.53 2.65 1.5 3.61.96.97 2.25 1.5 3.61 1.5 1.36 0 2.65-.53 3.61-1.5.97-.97 1.5-2.25 1.5-3.61 0-1.36-.53-2.65-1.5-3.61-.96-.97-2.25-1.5-3.61-1.5ZM16.4 16.15c-.19 0-.38-.07-.53-.22l-3.18-3.18a.754.754 0 0 1 0-1.06c.29-.29.77-.29 1.06 0l3.18 3.18c.29.29.29.77 0 1.06-.15.15-.34.22-.53.22Z"
101
+ fill="currentColor"
102
+ ></path>
103
+ </svg>
104
+ </Icon>
105
+ Size Guide
106
+ </div>
107
+ </AccordionTrigger>
108
+ <AccordionContent>
109
+ Yes. It comes with default styles that matches the other
110
+ components&apos; aesthetic.
111
+ </AccordionContent>
112
+ </Container>
113
+ </AccordionItem>
114
+ </Accordion>
115
+
116
+ {/*Aspect Ratio+ scroll area Example*/}
117
+ <Container>
118
+ <Text className="py-2 font-medium">New Drop Collection</Text>
119
+ </Container>
120
+
121
+ <ScrollArea>
122
+ {Products.map((product) => (
123
+ <ProductCard
124
+ className="w-[138px] mr-[7px]"
125
+ key={product.id}
126
+ product={product}
127
+ quickAdd={quickAdd}
128
+ openProduct={clickProduct}
129
+ switchVariant={switchVariant}
130
+ carousel={false}
131
+ ></ProductCard>
132
+ ))}
133
+ </ScrollArea>
134
+
135
+ <Separator className="my-[15px]" />
136
+
137
+ <div className="container flex items-center space-x-2">
138
+ <ToggleGroup
139
+ onValueChange={(e) => changeGrid(e)}
140
+ type="single"
141
+ defaultValue="2">
142
+ <ToggleGroupItem value="1" aria-label="Toggle bold">
143
+ <Icon>
144
+ <svg
145
+ xmlns="http://www.w3.org/2000/svg"
146
+ width="24"
147
+ height="24"
148
+ viewBox="0 0 24 24"
149
+ fill="none"
150
+ stroke="currentColor"
151
+ stroke-width="2"
152
+ stroke-linecap="round"
153
+ stroke-linejoin="round"
154
+ className="lucide lucide-rows-2">
155
+ <rect width="18" height="18" x="3" y="3" rx="2" />
156
+ <path d="M3 12h18" />
157
+ </svg>
158
+ </Icon>
159
+ </ToggleGroupItem>
160
+ <ToggleGroupItem value="2" aria-label="Toggle italic">
161
+ <Icon>
162
+ <svg
163
+ xmlns="http://www.w3.org/2000/svg"
164
+ width="24"
165
+ height="24"
166
+ viewBox="0 0 24 24"
167
+ fill="none"
168
+ stroke="currentColor"
169
+ stroke-width="2"
170
+ stroke-linecap="round"
171
+ stroke-linejoin="round"
172
+ className="lucide lucide-columns-3"
173
+ >
174
+ <rect width="18" height="18" x="3" y="3" rx="2" />
175
+ <path d="M9 3v18" />
176
+ <path d="M15 3v18" />
177
+ </svg>
178
+ </Icon>
179
+ </ToggleGroupItem>
180
+ <ToggleGroupItem value="3" aria-label="Toggle underline">
181
+ <Icon>
182
+ <svg
183
+ xmlns="http://www.w3.org/2000/svg"
184
+ width="24"
185
+ height="24"
186
+ viewBox="0 0 24 24"
187
+ fill="none"
188
+ stroke="currentColor"
189
+ stroke-width="2"
190
+ stroke-linecap="round"
191
+ stroke-linejoin="round"
192
+ className="lucide lucide-columns-3">
193
+ <rect width="18" height="18" x="3" y="3" rx="2" />
194
+ <path d="M9 3v18" />
195
+ <path d="M15 3v18" />
196
+ </svg>
197
+ </Icon>
198
+ </ToggleGroupItem>
199
+ </ToggleGroup>
200
+ </div>
201
+
202
+ <Separator className="my-[15px]" />
203
+
204
+ <Grid columns={grid} className="">
205
+ {Products.map((product) => (
206
+ <ProductCard
207
+ key={product.id}
208
+ className="w-full"
209
+ product={product}
210
+ quickAdd={quickAdd}
211
+ openProduct={clickProduct}
212
+ switchVariant={switchVariant}
213
+ carousel={true}
214
+ ></ProductCard>
215
+ ))}
216
+ </Grid>
217
+ ```
218
+
219
+ # Licenses
220
+ Copyright (c) 2017-present Tapcart Inc.
221
+
222
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
223
+
224
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
225
+
226
+ The rights granted above may only be exercised to develop and distribute applications that integrate or interoperate with Tapcart software or services, and in the case of external, stand-alone applications that do not embed directly inside Tapcart, the rights granted above may only be exercised to develop and distribute applications that are dissimilar and visually distinct from Tapcart products and services, as determined by Tapcart in its sole discretion.
227
+
228
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -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
+ }
@@ -91,7 +91,7 @@ Carousel.displayName = "Carousel";
91
91
  const CarouselContent = React.forwardRef((_a, ref) => {
92
92
  var { className } = _a, props = __rest(_a, ["className"]);
93
93
  const { carouselRef, orientation } = useCarousel();
94
- return (_jsx("div", Object.assign({ ref: carouselRef, className: "overflow-hidden" }, { children: _jsx("div", Object.assign({ ref: ref, className: cn("flex", orientation === "horizontal" ? "-ml-4" : "-mt-4 flex-col", className) }, props)) })));
94
+ return (_jsx("div", Object.assign({ ref: carouselRef, className: "overflow-hidden" }, { children: _jsx("div", Object.assign({ ref: ref, className: cn("flex", orientation === "horizontal" ? "" : "-mt-4 flex-col", className) }, props)) })));
95
95
  });
96
96
  CarouselContent.displayName = "CarouselContent";
97
97
  const CarouselItem = React.forwardRef((_a, ref) => {
@@ -9,6 +9,7 @@ export interface FavoriteProps extends React.ButtonHTMLAttributes<HTMLButtonElem
9
9
  onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
10
10
  icon?: string;
11
11
  showBackground?: boolean;
12
+ cornerRadius?: number;
12
13
  }
13
14
  declare const Favorite: React.ForwardRefExoticComponent<FavoriteProps & React.RefAttributes<HTMLButtonElement>>;
14
15
  export { Favorite, favoriteVariants };
@@ -1 +1 @@
1
- {"version":3,"file":"favorite.d.ts","sourceRoot":"","sources":["../../../components/ui/favorite.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAKjE,QAAA,MAAM,gBAAgB;;;mFAkBrB,CAAA;AAED,MAAM,WAAW,aACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,gBAAgB,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,QAAA,MAAM,QAAQ,yFAuBb,CAAA;AAGD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAA"}
1
+ {"version":3,"file":"favorite.d.ts","sourceRoot":"","sources":["../../../components/ui/favorite.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAKjE,QAAA,MAAM,gBAAgB;;;mFAkBrB,CAAA;AAED,MAAM,WAAW,aACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EACnD,YAAY,CAAC,OAAO,gBAAgB,CAAC;IACvC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,cAAc,CAAC,EAAE,OAAO,CAAA;IACxB,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED,QAAA,MAAM,QAAQ,yFA2Bb,CAAA;AAGD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAA"}
@@ -31,11 +31,13 @@ const favoriteVariants = cva("flex p-2 gap-2 rounded-[4px] shadow-buttonColors-p
31
31
  },
32
32
  });
33
33
  const Favorite = React.forwardRef((_a, ref) => {
34
- var { className, size = "small", selected = false, onClick, icon = "heart-filled", showBackground = true } = _a, props = __rest(_a, ["className", "size", "selected", "onClick", "icon", "showBackground"]);
34
+ var { className, size = "small", selected = false, onClick, icon = "heart-filled", showBackground = true, cornerRadius = 0 } = _a, props = __rest(_a, ["className", "size", "selected", "onClick", "icon", "showBackground", "cornerRadius"]);
35
35
  return (_jsx("button", Object.assign({ onClick: onClick, ref: ref, className: cn(favoriteVariants({
36
36
  size,
37
37
  showBackground
38
- }), className) }, props, { children: _jsx(Icon, { name: icon, color: selected ? "stateColors-favorites" : "stateColors-disabled", size: size === "small" ? "xs" : "sm" }) })));
38
+ }), className), style: {
39
+ borderRadius: `${cornerRadius}px`,
40
+ } }, props, { children: _jsx(Icon, { name: icon, color: selected ? "stateColors-favorites" : "stateColors-disabled", size: size === "small" ? "xs" : "sm" }) })));
39
41
  });
40
42
  Favorite.displayName = "Favorite";
41
43
  export { Favorite, favoriteVariants };
@@ -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 };
@@ -1 +1 @@
1
- {"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../components/ui/product-card.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAO9B,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAG1C,KAAK,MAAM,GAAG;IACZ,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,YAAY,CAAC,EAAE;QACb,OAAO,EAAE,OAAO,CAAA;QAChB,YAAY,EAAE,MAAM,CAAA;QACpB,iBAAiB,EAAE,OAAO,CAAA;KAC3B,CAAA;IACD,KAAK,CAAC,EAAE;QACN,OAAO,EAAE,OAAO,CAAA;QAChB,QAAQ,EAAE,MAAM,CAAA;QAChB,aAAa,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,IAAI,CAAA;KAClD,CAAA;IACD,YAAY,CAAC,EAAE;QACb,OAAO,EAAE,OAAO,CAAA;QAChB,QAAQ,EAAE,MAAM,CAAA;QAChB,SAAS,EAAE,OAAO,CAAA;QAClB,aAAa,EAAE,MAAM,CAAA;QACrB,QAAQ,EAAE,OAAO,CAAA;KAClB,CAAA;IACD,QAAQ,CAAC,EAAE;QACT,OAAO,EAAE,OAAO,CAAA;QAChB,QAAQ,EAAE,MAAM,CAAA;QAChB,SAAS,EAAE,OAAO,CAAA;QAClB,aAAa,E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}
@@ -134,7 +134,7 @@ const productCardFavoriteVariants = cva("absolute ", {
134
134
  },
135
135
  });
136
136
  const ProductCard = ({ config, tapcartData, product, isLoading, favorited, onFavoriteClick, onQuickAdd, openProduct, className, }) => {
137
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17;
137
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18;
138
138
  const { variants, images, title, tags } = product;
139
139
  // Select the variant that has the lowest price that is available or just the lowest price if none are available
140
140
  let searchVariants = variants.filter((variant) => variant.available);
@@ -194,7 +194,7 @@ const ProductCard = ({ config, tapcartData, product, isLoading, favorited, onFav
194
194
  borderBottomRightRadius: `${((_h = config.quickAdd) === null || _h === void 0 ? void 0 : _h.enabled) ? "0" : config.productImage.cornerRadius}px`,
195
195
  } }, { children: [imageSwipeEnabled ? (_jsx(Carousel, Object.assign({ className: "w-full max-w-xs overflow-hidden relative" }, { children: _jsxs("div", Object.assign({ className: "relative" }, { children: [_jsx(CarouselContent, Object.assign({ className: "" }, { children: product.images.map((image, index) => {
196
196
  var _a, _b, _c, _d;
197
- return (_jsx(CarouselItem, Object.assign({ className: "pl-0" }, { children: _jsx(Image, { alt: product.title, aspectRatio: (_b = (_a = tapcartData.theme) === null || _a === void 0 ? void 0 : _a.productImages) === null || _b === void 0 ? void 0 : _b.aspectRatio, data: image, sizes: sizes, objectFit: (_d = (_c = tapcartData.theme) === null || _c === void 0 ? void 0 : _c.productImages) === null || _d === void 0 ? void 0 : _d.scaling }) })));
197
+ return (_jsx(CarouselItem, Object.assign({ className: "pl-0" }, { children: _jsx(Image, { alt: product.title, aspectRatio: (_b = (_a = tapcartData.theme) === null || _a === void 0 ? void 0 : _a.productImages) === null || _b === void 0 ? void 0 : _b.aspectRatio, data: image, sizes: sizes, objectFit: (_d = (_c = tapcartData.theme) === null || _c === void 0 ? void 0 : _c.productImages) === null || _d === void 0 ? void 0 : _d.scaling }) }), `${product.title}-${image.url}`));
198
198
  }) })), _jsx(CarouselDots, { className: "absolute left-0 w-full bottom-2" })] })) }))) : (_jsx(Image, { alt: product.title, aspectRatio: (_k = (_j = tapcartData.theme) === null || _j === void 0 ? void 0 : _j.productImages) === null || _k === void 0 ? void 0 : _k.aspectRatio, data: product.featuredImage || product.images[0], sizes: sizes, objectFit: (_m = (_l = tapcartData.theme) === null || _l === void 0 ? void 0 : _l.productImages) === null || _m === void 0 ? void 0 : _m.scaling })), aboveBadge && product.availableForSale && (_jsx(Badge, Object.assign({ size: "plp-layout", className: cn(productCardBadgeVariants({
199
199
  verticalPosition: aboveBadge.verticalPosition,
200
200
  horizontalPosition: aboveBadge.horizontalPosition,
@@ -243,6 +243,6 @@ const ProductCard = ({ config, tapcartData, product, isLoading, favorited, onFav
243
243
  onFavoriteClick === null || onFavoriteClick === void 0 ? void 0 : onFavoriteClick(e, product);
244
244
  }, size: "small", icon: ((_15 = (_14 = config.favoritesIcon) === null || _14 === void 0 ? void 0 : _14.icon) === null || _15 === void 0 ? void 0 : _15.type) === "internal"
245
245
  ? (_17 = (_16 = config.favoritesIcon) === null || _16 === void 0 ? void 0 : _16.icon) === null || _17 === void 0 ? void 0 : _17.url
246
- : undefined }) })))] }))] }))] })) })));
246
+ : undefined, cornerRadius: (_18 = config.favoritesIcon) === null || _18 === void 0 ? void 0 : _18.cornerRadius }) })))] }))] }))] })) })));
247
247
  };
248
248
  export { ProductCard };
@@ -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 };
package/dist/styles.css CHANGED
@@ -794,9 +794,6 @@ video {
794
794
  margin-top: auto;
795
795
  margin-bottom: auto;
796
796
  }
797
- .-ml-4 {
798
- margin-left: -1rem;
799
- }
800
797
  .-mt-4 {
801
798
  margin-top: -1rem;
802
799
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.4.8",
3
+ "version": "0.4.9",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",