@tapcart/mobile-components 0.7.85 → 0.7.86

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,14 @@
1
1
  import React from "react";
2
2
  type AnimationType = "slideUp";
3
3
  interface AnimateContainerProps {
4
- show: boolean;
5
4
  children: React.ReactNode;
6
5
  type: AnimationType;
7
6
  duration?: number;
8
7
  className?: string;
9
- skipInitAnimation?: boolean;
8
+ isLoading?: boolean;
9
+ hasData?: boolean;
10
10
  }
11
- export declare function AnimateContainer({ show, children, type, duration, className, skipInitAnimation, }: AnimateContainerProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function AnimateContainer({ children, type, duration, className, isLoading, hasData, }: AnimateContainerProps): import("react/jsx-runtime").JSX.Element;
12
12
  export declare function SlideUp(props: Omit<AnimateContainerProps, "type">): import("react/jsx-runtime").JSX.Element;
13
13
  export {};
14
14
  //# 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,SAAS,CAAA;AAgB9B,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,IAAI,EAAE,aAAa,CAAA;IACnB,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,IAAI,EACJ,QAAc,EACd,SAAS,EACT,SAAS,EACT,OAAO,GACR,EAAE,qBAAqB,2CAoCvB;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,qBAAqB,EAAE,MAAM,CAAC,2CAEjE"}
@@ -6,24 +6,26 @@ const ANIMATIONS = {
6
6
  slideUp: {
7
7
  enter: "animate-slide-down",
8
8
  exit: "animate-slide-up",
9
- needsHeight: true,
9
+ isHeight: true,
10
10
  },
11
11
  };
12
- export function AnimateContainer({ show, children, type, duration = 300, className, skipInitAnimation = false, }) {
12
+ export function AnimateContainer({ children, type, duration = 300, className, isLoading, hasData, }) {
13
13
  const contentRef = useRef(null);
14
- const prevHeight = useRef(0);
15
- const [shouldAnimate, setShouldAnimate] = useState(!skipInitAnimation);
16
14
  const animation = ANIMATIONS[type];
15
+ const [prevData, setPrevData] = useState(hasData);
16
+ const [shouldAnimate, setShouldAnimate] = useState(false);
17
17
  useEffect(() => {
18
- if (contentRef.current && animation.needsHeight) {
18
+ if (contentRef.current && animation.isHeight) {
19
19
  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
20
  }
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 })));
21
+ if (isLoading)
22
+ return;
23
+ if (prevData !== hasData) {
24
+ setShouldAnimate(true);
25
+ setPrevData(hasData);
26
+ }
27
+ }, [hasData, isLoading, animation.isHeight]);
28
+ return (_jsx("div", Object.assign({ ref: contentRef, className: cn("overflow-hidden", shouldAnimate && (hasData ? animation.enter : animation.exit), className), style: { animationDuration: `${duration}ms` } }, { children: children })));
27
29
  }
28
30
  export function SlideUp(props) {
29
31
  return _jsx(AnimateContainer, Object.assign({}, props, { type: "slideUp" }));
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.86",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "style": "dist/styles.css",