@tapcart/mobile-components 0.1.42 → 0.1.43

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,25 @@
1
+ import { type VariantProps } from "class-variance-authority";
2
+ import React from "react";
3
+ declare const chipVariants: (props?: ({
4
+ variant?: "secondary" | "primary" | null | undefined;
5
+ direction?: "horizontal" | "vertical" | null | undefined;
6
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string;
7
+ type ChipProps = React.ComponentPropsWithoutRef<'div'> & VariantProps<typeof chipVariants> & {
8
+ icon?: React.ElementType;
9
+ iconPosition?: 'left' | 'right';
10
+ onClose?: () => void;
11
+ };
12
+ declare const Chip: React.ForwardRefExoticComponent<Omit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref"> & VariantProps<(props?: ({
13
+ variant?: "secondary" | "primary" | null | undefined;
14
+ direction?: "horizontal" | "vertical" | null | undefined;
15
+ } & import("class-variance-authority/dist/types").ClassProp) | undefined) => string> & {
16
+ icon?: React.ElementType<any> | undefined;
17
+ iconPosition?: "left" | "right" | undefined;
18
+ onClose?: (() => void) | undefined;
19
+ } & React.RefAttributes<HTMLDivElement>>;
20
+ type MultipleChipsProps = {
21
+ children: React.ReactElement<ChipProps>[];
22
+ };
23
+ declare const MultipleChips: React.FC<MultipleChipsProps>;
24
+ export { Chip, MultipleChips };
25
+ //# sourceMappingURL=chip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chip.d.ts","sourceRoot":"","sources":["../../../components/ui/chip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIlE,OAAO,KAAmB,MAAM,OAAO,CAAA;AAEvC,QAAA,MAAM,YAAY;;;mFAkBjB,CAAC;AAEF,KAAK,SAAS,GAAG,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,GAAG;IAC3F,IAAI,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAEF,QAAA,MAAM,IAAI;;;;;;qBAHQ,IAAI;wCA0BrB,CAAC;AAGF,KAAK,kBAAkB,GAAG;IACxB,QAAQ,EAAE,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,EAAE,CAAC;CAC3C,CAAC;AAEF,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAa/C,CAAC;AAEF,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,47 @@
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 { cva } from "class-variance-authority";
14
+ import { cn } from "../../lib/utils";
15
+ import React, { useState } from "react";
16
+ const chipVariants = cva("inline-flex items-center justify-center rounded-[4px] border border-dividingLines text-sm font-medium transition-colors", {
17
+ variants: {
18
+ variant: {
19
+ primary: "bg-coreColors-pageColor text-textColors-primaryColor",
20
+ secondary: "bg-coreColors-pageColor text-textColors-secondaryColor",
21
+ },
22
+ direction: {
23
+ horizontal: "flex-row",
24
+ vertical: "flex-col",
25
+ },
26
+ },
27
+ defaultVariants: {
28
+ variant: "primary",
29
+ direction: "horizontal",
30
+ },
31
+ });
32
+ const Chip = React.forwardRef((_a, ref) => {
33
+ var { className, variant, direction, children, icon: Icon, iconPosition = 'left', onClose } = _a, props = __rest(_a, ["className", "variant", "direction", "children", "icon", "iconPosition", "onClose"]);
34
+ const [visible, setVisible] = useState(true);
35
+ if (!visible)
36
+ return null;
37
+ const handleIconClick = () => {
38
+ setVisible(false);
39
+ onClose === null || onClose === void 0 ? void 0 : onClose();
40
+ };
41
+ return (_jsxs("div", Object.assign({ ref: ref, className: cn(chipVariants({ variant, direction }), "p-2 space-x-2", className) }, props, { children: [Icon && iconPosition === 'left' && _jsx(Icon, { className: "mr-2 h-4 w-4 cursor-pointer", onClick: handleIconClick }), children, Icon && iconPosition === 'right' && _jsx(Icon, { className: "ml-2 h-4 w-4 cursor-pointer", onClick: handleIconClick })] })));
42
+ });
43
+ Chip.displayName = 'Chip';
44
+ const MultipleChips = ({ children }) => {
45
+ return (_jsxs("div", Object.assign({ className: "relative mt-2 mb-4" }, { children: [_jsx("div", Object.assign({ className: "flex space-x-2 overflow-x-auto no-scrollbar" }, { children: children.map((chip, index) => (_jsx("div", Object.assign({ className: "shrink-0" }, { children: chip }), index))) })), _jsx("div", { className: "fade-right" })] })));
46
+ };
47
+ export { Chip, MultipleChips };
package/dist/globals.css CHANGED
@@ -647,6 +647,12 @@ video {
647
647
  .pointer-events-auto {
648
648
  pointer-events: auto;
649
649
  }
650
+ .\!visible {
651
+ visibility: visible !important;
652
+ }
653
+ .visible {
654
+ visibility: visible;
655
+ }
650
656
  .fixed {
651
657
  position: fixed;
652
658
  }
@@ -708,6 +714,15 @@ video {
708
714
  .-mt-4 {
709
715
  margin-top: -1rem;
710
716
  }
717
+ .mb-4 {
718
+ margin-bottom: 1rem;
719
+ }
720
+ .ml-2 {
721
+ margin-left: 0.5rem;
722
+ }
723
+ .mr-2 {
724
+ margin-right: 0.5rem;
725
+ }
711
726
  .mt-2 {
712
727
  margin-top: 0.5rem;
713
728
  }
@@ -886,6 +901,9 @@ video {
886
901
  .grid-cols-4 {
887
902
  grid-template-columns: repeat(4, minmax(0, 1fr));
888
903
  }
904
+ .flex-row {
905
+ flex-direction: row;
906
+ }
889
907
  .flex-col {
890
908
  flex-direction: column;
891
909
  }
@@ -914,6 +932,11 @@ video {
914
932
  .gap-y-\[7px\] {
915
933
  row-gap: 7px;
916
934
  }
935
+ .space-x-2 > :not([hidden]) ~ :not([hidden]) {
936
+ --tw-space-x-reverse: 0;
937
+ margin-right: calc(0.5rem * var(--tw-space-x-reverse));
938
+ margin-left: calc(0.5rem * calc(1 - var(--tw-space-x-reverse)));
939
+ }
917
940
  .space-x-4 > :not([hidden]) ~ :not([hidden]) {
918
941
  --tw-space-x-reverse: 0;
919
942
  margin-right: calc(1rem * var(--tw-space-x-reverse));
@@ -927,6 +950,9 @@ video {
927
950
  .overflow-hidden {
928
951
  overflow: hidden;
929
952
  }
953
+ .overflow-x-auto {
954
+ overflow-x: auto;
955
+ }
930
956
  .truncate {
931
957
  overflow: hidden;
932
958
  text-overflow: ellipsis;
@@ -938,6 +964,9 @@ video {
938
964
  .rounded {
939
965
  border-radius: 0.25rem;
940
966
  }
967
+ .rounded-\[4px\] {
968
+ border-radius: 4px;
969
+ }
941
970
  .rounded-\[inherit\] {
942
971
  border-radius: inherit;
943
972
  }
@@ -1007,6 +1036,9 @@ video {
1007
1036
  .bg-buttonColors-secondaryFill {
1008
1037
  background-color: var(--buttonColors-secondaryFill);
1009
1038
  }
1039
+ .bg-coreColors-pageColor {
1040
+ background-color: var(--coreColors-pageColor);
1041
+ }
1010
1042
  .bg-destructive {
1011
1043
  background-color: hsl(var(--destructive));
1012
1044
  }
@@ -1035,6 +1067,9 @@ video {
1035
1067
  .p-1 {
1036
1068
  padding: 0.25rem;
1037
1069
  }
1070
+ .p-2 {
1071
+ padding: 0.5rem;
1072
+ }
1038
1073
  .p-4 {
1039
1074
  padding: 1rem;
1040
1075
  }
@@ -1188,6 +1223,12 @@ video {
1188
1223
  .text-secondary-foreground {
1189
1224
  color: hsl(var(--secondary-foreground));
1190
1225
  }
1226
+ .text-textColors-primaryColor {
1227
+ color: var(--textColors-primaryColor);
1228
+ }
1229
+ .text-textColors-secondaryColor {
1230
+ color: var(--textColors-secondaryColor);
1231
+ }
1191
1232
  .underline-offset-4 {
1192
1233
  text-underline-offset: 4px;
1193
1234
  }
@@ -1257,7 +1298,14 @@ video {
1257
1298
  animation-duration: 200ms;
1258
1299
  }
1259
1300
  /* Hide scrollbar for Chrome, Safari and Opera */
1301
+ .no-scrollbar *::-webkit-scrollbar {
1302
+ display: none;
1303
+ }
1260
1304
  /* Hide scrollbar for IE, Edge and Firefox */
1305
+ .no-scrollbar * {
1306
+ -ms-overflow-style: none; /* IE and Edge */
1307
+ scrollbar-width: none; /* Firefox */
1308
+ }
1261
1309
  .container {
1262
1310
  padding-right: 16px;
1263
1311
  padding-left: 16px;
package/dist/index.d.ts CHANGED
@@ -19,6 +19,7 @@ export * from "./components/ui/switch";
19
19
  export * from "./components/ui/scroll-area";
20
20
  export * from "./components/ui/toast";
21
21
  export * from "./components/ui/toaster";
22
+ export * from "./components/ui/chip";
22
23
  export * from "./components/ui/use-toast";
23
24
  export * from "./components/ThemeToggle";
24
25
  export { ThemeProvider } from "./components/ThemeProvider";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.tsx"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.tsx"],"names":[],"mappings":"AAGA,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,sBAAsB,CAAA;AACpC,cAAc,uBAAuB,CAAA;AACrC,cAAc,2BAA2B,CAAA;AACzC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,wBAAwB,CAAA;AACtC,cAAc,8BAA8B,CAAA;AAC5C,cAAc,wBAAwB,CAAA;AACtC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA;AACrC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA;AACpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,0BAA0B,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ export * from "./components/ui/switch";
20
20
  export * from "./components/ui/scroll-area";
21
21
  export * from "./components/ui/toast";
22
22
  export * from "./components/ui/toaster";
23
+ export * from "./components/ui/chip";
23
24
  export * from "./components/ui/use-toast";
24
25
  export * from "./components/ThemeToggle";
25
26
  export { ThemeProvider } from "./components/ThemeProvider";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.1.42",
3
+ "version": "0.1.43",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.esm.js",
6
6
  "types": "dist/index.d.ts",
@@ -15,7 +15,6 @@
15
15
  "scripts": {
16
16
  "lint": "eslint \"**/*.ts*\"",
17
17
  "ui:add": "pnpm dlx shadcn-ui@latest add",
18
- "build:styles": "postcss styles/globals.css -o dist/styles.css",
19
18
  "build:ts": "tsc -p tsconfig.json",
20
19
  "build": "pnpm run build:ts && pnpm run build:styles",
21
20
  "build:sdk": "tsc && node scripts/build-css.js"
@@ -1,32 +0,0 @@
1
- /// <reference types="react" />
2
- type ProductCardProps = {
3
- product: {
4
- variants: {
5
- compare_at_price: number | null;
6
- price: number;
7
- }[];
8
- images: {
9
- src: string;
10
- }[];
11
- title: string;
12
- tags: string[];
13
- };
14
- className?: string;
15
- quickAdd: (e: React.MouseEvent<HTMLButtonElement>, product: any) => void;
16
- openProduct: (e: React.MouseEvent<HTMLDivElement>, product: any) => void;
17
- imageRatio: "1:1" | "2:3" | "4:5";
18
- imageFit: "fit" | "fill";
19
- theme: {
20
- textColors: {
21
- priceProduct: string;
22
- productTitle: string;
23
- };
24
- font: {
25
- productTitle: string;
26
- productPrice: string;
27
- };
28
- };
29
- };
30
- declare const ProductCard: React.FC<ProductCardProps>;
31
- export default ProductCard;
32
- //# sourceMappingURL=product-card.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"product-card.d.ts","sourceRoot":"","sources":["../../../components/ui/product-card.tsx"],"names":[],"mappings":";AAGA,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE;QACP,QAAQ,EAAE;YAAE,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;YAAC,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC/D,MAAM,EAAE;YAAE,GAAG,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1B,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,EAAE,CAAC;KAChB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACzE,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACzE,UAAU,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;IAClC,QAAQ,EAAE,KAAK,GAAG,MAAM,CAAC;IACzB,KAAK,EAAE;QACL,UAAU,EAAE;YACV,YAAY,EAAE,MAAM,CAAC;YACrB,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC;QACF,IAAI,EAAE;YACJ,YAAY,EAAE,MAAM,CAAC;YACrB,YAAY,EAAE,MAAM,CAAC;SACtB,CAAC;KACH,CAAC;CACH,CAAC;AAEF,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA0E3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,22 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { Button, AspectRatio, Text, Badge, Loading } from "@tapcart/mobile-components";
3
- import { useEffect, useState } from "react";
4
- const ProductCard = ({ product, className, quickAdd, openProduct, imageRatio, imageFit, theme, }) => {
5
- const [loading, setLoading] = useState(true);
6
- useEffect(() => {
7
- // Simulate loading
8
- const timer = setTimeout(() => setLoading(false), 1000);
9
- return () => clearTimeout(timer);
10
- }, []);
11
- const variant = product.variants[0];
12
- const aspectRatio = {
13
- "1:1": 1,
14
- "2:3": 2 / 3,
15
- "4:5": 4 / 5,
16
- }[imageRatio];
17
- if (loading) {
18
- return _jsx(Loading, {});
19
- }
20
- return (_jsxs("div", Object.assign({ className: `${className}`, onClick: (e) => openProduct(e, product) }, { children: [_jsxs(AspectRatio, Object.assign({ ratio: aspectRatio }, { children: [_jsx("img", { className: `w-full h-full object-${imageFit} rounded-t-lg`, src: product.images[0].src, alt: product.title }), product.tags.includes("SUMMER") && (_jsx(Badge, Object.assign({ variant: "secondary", className: "absolute bottom-[15px] rounded-none bg-[#e2fe9f] pointer-events-none" }, { children: "SUMMER" })))] })), _jsx(Button, Object.assign({ variant: "quickadd", size: "sm", onClick: (e) => quickAdd(e, product) }, { children: "+ Quick add" })), _jsx(Text, Object.assign({ className: `text-xs mt-[8px] ${theme.font.productTitle}`, style: { color: theme.textColors.productTitle } }, { children: product.title })), _jsxs("div", Object.assign({ className: "flex mt-[4px]" }, { children: [variant.compare_at_price && (_jsxs(Text, Object.assign({ className: `text-sm mr-[8px] line-through text-red-500 ${theme.font.productPrice}` }, { children: ["$", variant.compare_at_price] }))), _jsxs(Text, Object.assign({ className: `text-sm ${theme.font.productPrice}`, style: { color: theme.textColors.priceProduct } }, { children: ["$", variant.price] }))] }))] })));
21
- };
22
- export default ProductCard;