@tapcart/mobile-components 0.7.85 → 0.7.87

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.
@@ -1,14 +1,20 @@
1
1
  import React from "react";
2
- type AnimationType = "slideUp";
2
+ type AnimationType = "slide" | "fade";
3
+ interface AnimationConfig {
4
+ enter: string;
5
+ exit: string;
6
+ isHeight: boolean;
7
+ }
8
+ export declare const Animations: Record<AnimationType, AnimationConfig>;
3
9
  interface AnimateContainerProps {
4
- show: boolean;
5
10
  children: React.ReactNode;
6
- type: AnimationType;
11
+ animations: AnimationConfig[];
7
12
  duration?: number;
8
13
  className?: string;
9
- skipInitAnimation?: boolean;
14
+ isLoading?: boolean;
15
+ hasData?: boolean;
10
16
  }
11
- export declare function AnimateContainer({ show, children, type, duration, className, skipInitAnimation, }: AnimateContainerProps): import("react/jsx-runtime").JSX.Element;
17
+ export declare function AnimateContainer({ children, animations, duration, className, isLoading, hasData, }: AnimateContainerProps): import("react/jsx-runtime").JSX.Element;
12
18
  export declare function SlideUp(props: Omit<AnimateContainerProps, "type">): import("react/jsx-runtime").JSX.Element;
13
19
  export {};
14
20
  //# sourceMappingURL=animate-container.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"animate-container.d.ts","sourceRoot":"","sources":["../../../components/ui/animate-container.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAG1D,KAAK,aAAa,GAAG,SAAS,CAAA;AAgB9B,UAAU,qBAAqB;IAC7B,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,IAAI,EAAE,aAAa,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,QAAc,EACd,SAAS,EACT,iBAAyB,GAC1B,EAAE,qBAAqB,2CAkCvB;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,2CAEjE"}
1
+ {"version":3,"file":"animate-container.d.ts","sourceRoot":"","sources":["../../../components/ui/animate-container.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAsC,MAAM,OAAO,CAAA;AAG1D,KAAK,aAAa,GAAG,OAAO,GAAG,MAAM,CAAA;AAErC,UAAU,eAAe;IACvB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,aAAa,EAAE,eAAe,CAW7D,CAAA;AAED,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,UAAU,EAAE,eAAe,EAAE,CAAA;IAC7B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,UAAU,EACV,QAAc,EACd,SAAS,EACT,SAAS,EACT,OAAO,GACR,EAAE,qBAAqB,2CAyCvB;AAGD,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,2CAEjE"}
@@ -2,29 +2,44 @@
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useState, useEffect, useRef } from "react";
4
4
  import { cn } from "../../lib/utils";
5
- const ANIMATIONS = {
6
- slideUp: {
5
+ export const Animations = {
6
+ slide: {
7
7
  enter: "animate-slide-down",
8
8
  exit: "animate-slide-up",
9
- needsHeight: true,
9
+ isHeight: true,
10
+ },
11
+ fade: {
12
+ enter: "animate-fadeIn",
13
+ exit: "animate-fadeOut",
14
+ isHeight: false,
10
15
  },
11
16
  };
12
- export function AnimateContainer({ show, children, type, duration = 300, className, skipInitAnimation = false, }) {
17
+ export function AnimateContainer({ children, animations, duration = 300, className, isLoading, hasData, }) {
13
18
  const contentRef = useRef(null);
14
- const prevHeight = useRef(0);
15
- const [shouldAnimate, setShouldAnimate] = useState(!skipInitAnimation);
16
- const animation = ANIMATIONS[type];
19
+ const [prevData, setPrevData] = useState(hasData !== null && hasData !== void 0 ? hasData : false);
20
+ const [shouldAnimate, setShouldAnimate] = useState(false);
17
21
  useEffect(() => {
18
- if (contentRef.current && animation.needsHeight) {
22
+ if (contentRef.current &&
23
+ (animations === null || animations === void 0 ? void 0 : animations.some((animation) => animation.isHeight))) {
19
24
  contentRef.current.style.setProperty("--content-height", `${contentRef.current.scrollHeight}px`);
20
- if (!skipInitAnimation || prevHeight.current !== 0) {
21
- prevHeight.current = contentRef.current.scrollHeight;
22
- setShouldAnimate(true);
23
- }
24
25
  }
25
- }, [show, skipInitAnimation, animation.needsHeight]);
26
- return (_jsx("div", Object.assign({ ref: contentRef, className: cn("overflow-hidden", shouldAnimate && (show ? animation.enter : animation.exit), className), style: { animationDuration: `${duration}ms` } }, { children: children })));
26
+ if (isLoading)
27
+ return;
28
+ if (prevData !== hasData) {
29
+ setShouldAnimate(true);
30
+ setPrevData(hasData !== null && hasData !== void 0 ? hasData : false);
31
+ }
32
+ }, [hasData, isLoading, animations, prevData]);
33
+ const getAnimationClasses = () => {
34
+ if (!shouldAnimate)
35
+ return "";
36
+ return animations
37
+ .map((animation) => (hasData ? animation.enter : animation.exit))
38
+ .join(" ");
39
+ };
40
+ return (_jsx("div", Object.assign({ ref: contentRef, className: cn("overflow-hidden", getAnimationClasses(), className), style: { animationDuration: `${duration}ms` } }, { children: children })));
27
41
  }
42
+ // TO REMOVE
28
43
  export function SlideUp(props) {
29
- return _jsx(AnimateContainer, Object.assign({}, props, { type: "slideUp" }));
44
+ return _jsx(AnimateContainer, Object.assign({}, props, { animations: [Animations.slide] }));
30
45
  }
@@ -24,7 +24,7 @@ const RadioGroup = React.forwardRef((_a, ref) => {
24
24
  return (_jsx(RadioGroupPrimitive.Root, Object.assign({ className: cn("grid gap-4", className) }, props, { ref: ref })));
25
25
  });
26
26
  RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
27
- const radiogroupItemVariants = cva("grid grid-cols-[auto,auto,1fr] gap-2 items-start group", {
27
+ const radiogroupItemVariants = cva("grid grid-cols-[auto,auto,1fr] gap-2 items-center group", {
28
28
  variants: {
29
29
  variant: {
30
30
  default: "",
@@ -36,12 +36,12 @@ const radiogroupItemVariants = cva("grid grid-cols-[auto,auto,1fr] gap-2 items-s
36
36
  variant: "default",
37
37
  },
38
38
  });
39
- const RadioGroupItemLabels = ({ key, label, numberAmount, subtext, }) => (_jsxs("div", Object.assign({ className: "col-span-2" }, { children: [_jsxs("div", Object.assign({ className: "flex flex-row items-start" }, { children: [_jsx(Text, Object.assign({ type: "body-primary", className: "group-disabled:text-stateColors-disabled mr-2" }, { children: label })), numberAmount ? (_jsx(Text, Object.assign({ type: "body-primary", className: "text-textColors-secondaryColor group-disabled:text-stateColors-disabled" }, { children: `(${numberAmount})` }))) : null] })), subtext ? (_jsx(Text, Object.assign({ type: "body-secondary", className: "group-disabled:text-stateColors-disabled mt-2" }, { children: subtext }))) : null] })));
39
+ const RadioGroupItemLabels = ({ key, label, numberAmount, subtext, }) => (_jsxs("div", Object.assign({ className: "col-span-2" }, { children: [_jsxs("div", Object.assign({ className: "flex flex-row items-center" }, { children: [_jsx(Text, Object.assign({ type: "body-primary", className: "group-disabled:text-stateColors-disabled mr-2" }, { children: label })), numberAmount ? (_jsx(Text, Object.assign({ type: "body-primary", className: "text-textColors-secondaryColor group-disabled:text-stateColors-disabled" }, { children: `(${numberAmount})` }))) : null] })), subtext ? (_jsx(Text, Object.assign({ type: "body-secondary", className: "group-disabled:text-stateColors-disabled mt-1" }, { children: subtext }))) : null] })));
40
40
  const RadioGroupItem = React.forwardRef((_a, ref) => {
41
41
  var { value, label = "", subtext, numberAmount = 0, onSelect = () => { }, onClick = () => { }, selected = false, className, variant = "default", key } = _a, props = __rest(_a, ["value", "label", "subtext", "numberAmount", "onSelect", "onClick", "selected", "className", "variant", "key"]);
42
42
  const { onTap, ref: tapRef } = useTap();
43
43
  const mergedRef = useMergeRefs(ref, tapRef);
44
- return (_jsx("div", Object.assign({ className: cn(radiogroupItemVariants({ variant }), className) }, { children: variant === "deactivated" ? (_jsxs(_Fragment, { children: [_jsx(Icon, { name: "circle-off", size: "md", className: "text-stateColors-disabled" }), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] })) : (_jsx(RadioGroupPrimitive.Item, Object.assign({ ref: mergedRef, value: value, onSelect: onSelect, checked: selected, onClick: onTap(onClick), className: cn("flex items-center justify-center active:opacity-70", className) }, props, { children: selected || variant === "selected" ? (_jsxs("div", Object.assign({ className: "grid grid-cols-[auto,auto,1fr] gap-2 items-start group" }, { children: [_jsx(Icon, { name: "circle-dot-filled", size: "md", className: "text-coreColors-brandColorPrimary z-10" }), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] }))) : (_jsxs("div", Object.assign({ className: "grid grid-cols-[auto,auto,1fr] gap-2 items-start group" }, { children: [_jsxs("div", Object.assign({ className: "grid" }, { children: [_jsx(RadioGroupPrimitive.Indicator, Object.assign({ className: "flex items-center justify-center col-start-1 row-start-1" }, { children: _jsx(Icon, { name: "circle-dot-filled", size: "md", className: "text-coreColors-brandColorPrimary z-10" }) })), _jsx("div", Object.assign({ className: "flex items-center justify-center col-start-1 row-start-1" }, { children: _jsx(Icon, { name: "circle", size: "md", className: "col-start-1 row-start-1 text-coreColors-secondaryIcon items-center z-1" }) }))] })), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] }))) }))) })));
44
+ return (_jsx("div", Object.assign({ className: cn(radiogroupItemVariants({ variant }), className) }, { children: variant === "deactivated" ? (_jsxs(_Fragment, { children: [_jsx(Icon, { name: "circle-off", size: "md", className: "text-stateColors-disabled" }), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] })) : (_jsx(RadioGroupPrimitive.Item, Object.assign({ ref: mergedRef, value: value, onSelect: onSelect, checked: selected, onClick: onTap(onClick), className: cn("flex items-center justify-center active:opacity-70", className) }, props, { children: selected || variant === "selected" ? (_jsxs("div", Object.assign({ className: "grid grid-cols-[auto,auto,1fr] gap-2 items-center group" }, { children: [_jsx(Icon, { name: "circle-dot-filled", size: "md", className: "text-coreColors-brandColorPrimary z-10" }), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] }))) : (_jsxs("div", Object.assign({ className: "grid grid-cols-[auto,auto,1fr] gap-2 items-center group" }, { children: [_jsxs("div", Object.assign({ className: "grid" }, { children: [_jsx(RadioGroupPrimitive.Indicator, Object.assign({ className: "flex items-center justify-center col-start-1 row-start-1" }, { children: _jsx(Icon, { name: "circle-dot-filled", size: "md", className: "text-coreColors-brandColorPrimary z-10" }) })), _jsx("div", Object.assign({ className: "flex items-center justify-center col-start-1 row-start-1" }, { children: _jsx(Icon, { name: "circle", size: "md", className: "col-start-1 row-start-1 text-coreColors-secondaryIcon items-center z-1" }) }))] })), _jsx(RadioGroupItemLabels, { label: label, numberAmount: numberAmount, subtext: subtext }, key)] }))) }))) })));
45
45
  });
46
46
  RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
47
47
  export { RadioGroup, RadioGroupItem, radiogroupItemVariants };
package/dist/styles.css CHANGED
@@ -902,6 +902,12 @@ video {
902
902
  -webkit-box-orient: vertical;
903
903
  -webkit-line-clamp: 2;
904
904
  }
905
+ .line-clamp-3 {
906
+ overflow: hidden;
907
+ display: -webkit-box;
908
+ -webkit-box-orient: vertical;
909
+ -webkit-line-clamp: 3;
910
+ }
905
911
  .block {
906
912
  display: block;
907
913
  }
@@ -1224,6 +1230,12 @@ video {
1224
1230
  .animate-bounce {
1225
1231
  animation: bounce 1s infinite;
1226
1232
  }
1233
+ .animate-fadeIn {
1234
+ animation: fadeIn .3s ease-in-out;
1235
+ }
1236
+ .animate-fadeOut {
1237
+ animation: fadeOut .3s ease-in-out;
1238
+ }
1227
1239
  @keyframes pulse {
1228
1240
 
1229
1241
  50% {
@@ -1244,7 +1256,7 @@ video {
1244
1256
  }
1245
1257
  }
1246
1258
  .animate-slide-down {
1247
- animation: slide-down 0.2s ease-out;
1259
+ animation: slide-down 0.3s ease-in-out;
1248
1260
  }
1249
1261
  @keyframes slide-up {
1250
1262
 
@@ -1257,7 +1269,7 @@ video {
1257
1269
  }
1258
1270
  }
1259
1271
  .animate-slide-up {
1260
- animation: slide-up 0.2s ease-out;
1272
+ animation: slide-up 0.3s ease-in-out;
1261
1273
  }
1262
1274
  @keyframes spin {
1263
1275
 
@@ -2214,6 +2226,9 @@ video {
2214
2226
  transform: translate3d(var(--tw-exit-translate-x, 0), var(--tw-exit-translate-y, 0), 0) scale3d(var(--tw-exit-scale, 1), var(--tw-exit-scale, 1), var(--tw-exit-scale, 1)) rotate(var(--tw-exit-rotate, 0));
2215
2227
  }
2216
2228
  }
2229
+ .fade-in {
2230
+ --tw-enter-opacity: 0;
2231
+ }
2217
2232
  .duration-150 {
2218
2233
  animation-duration: 150ms;
2219
2234
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapcart/mobile-components",
3
- "version": "0.7.85",
3
+ "version": "0.7.87",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",