{"ast":null,"code":"var __assign = this && this.__assign || function () {\n  __assign = Object.assign || function (t) {\n    for (var s, i = 1, n = arguments.length; i < n; i++) {\n      s = arguments[i];\n      for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\n    }\n    return t;\n  };\n  return __assign.apply(this, arguments);\n};\nimport React, { useState, useRef, useEffect } from 'react';\nimport { useSpring, useTransition, animated, config } from '@react-spring/web';\nfunction TextTransition(props) {\n  var _a = props.direction,\n    direction = _a === void 0 ? 'up' : _a,\n    _b = props.inline,\n    inline = _b === void 0 ? false : _b,\n    _c = props.springConfig,\n    springConfig = _c === void 0 ? config.default : _c,\n    _d = props.delay,\n    delay = _d === void 0 ? 0 : _d,\n    className = props.className,\n    style = props.style,\n    _e = props.translateValue,\n    tv = _e === void 0 ? '100%' : _e,\n    children = props.children;\n  var initialRun = useRef(true);\n  var fromTransform = direction === 'down' ? \"-\".concat(tv) : tv;\n  var leaveTransform = direction === 'down' ? tv : \"-\".concat(tv);\n  var transitions = useTransition([children], {\n    enter: {\n      opacity: 1,\n      transform: 'translateY(0%)'\n    },\n    from: {\n      opacity: 0,\n      transform: \"translateY(\".concat(fromTransform, \")\")\n    },\n    leave: {\n      opacity: 0,\n      transform: \"translateY(\".concat(leaveTransform, \")\"),\n      position: 'absolute'\n    },\n    config: springConfig,\n    immediate: initialRun.current,\n    delay: !initialRun.current ? delay : undefined\n  });\n  var _f = useState(0),\n    width = _f[0],\n    setWidth = _f[1];\n  var currentRef = useRef(null);\n  var heightRef = useRef('auto');\n  useEffect(function () {\n    initialRun.current = false;\n    var element = currentRef.current;\n    if (!element) return;\n    var _a = element.getBoundingClientRect(),\n      width = _a.width,\n      height = _a.height;\n    setWidth(width);\n    heightRef.current = height;\n  }, [children, setWidth, currentRef]);\n  var widthTransition = useSpring({\n    to: {\n      width: width\n    },\n    config: springConfig,\n    immediate: initialRun.current,\n    delay: !initialRun.current ? delay : undefined\n  });\n  return React.createElement(animated.div, {\n    className: \"text-transition \".concat(className),\n    style: __assign(__assign(__assign({}, inline && !initialRun.current ? widthTransition : undefined), style), {\n      whiteSpace: inline ? 'nowrap' : 'normal',\n      display: inline ? 'inline-flex' : 'flex',\n      height: heightRef.current\n    })\n  }, transitions(function (styles, item) {\n    return React.createElement(animated.div, {\n      style: __assign({}, styles),\n      ref: item === children ? currentRef : undefined,\n      children: item\n    });\n  }));\n}\nexport default TextTransition;","map":{"version":3,"names":["React","useState","useRef","useEffect","useSpring","useTransition","animated","config","TextTransition","props","_a","direction","_b","inline","_c","springConfig","default","_d","delay","className","style","_e","translateValue","tv","children","initialRun","fromTransform","concat","leaveTransform","transitions","enter","opacity","transform","from","leave","position","immediate","current","undefined","_f","width","setWidth","currentRef","heightRef","element","getBoundingClientRect","height","widthTransition","to","createElement","div","__assign","whiteSpace","display","styles","item","ref"],"sources":["C:\\Users\\user\\Desktop\\05portreact\\node_modules\\react-text-transition\\src\\components\\TextTransition.tsx"],"sourcesContent":["import React, { useState, useRef, useEffect } from 'react';\r\nimport type { CSSProperties, PropsWithChildren } from 'react';\r\n\r\nimport { useSpring, useTransition, animated, config, SpringConfig } from '@react-spring/web';\r\n\r\nexport interface TextTransitionProps {\r\n  className?: string;\r\n  delay?: number;\r\n  direction?: 'up' | 'down';\r\n  inline?: boolean;\r\n  springConfig?: SpringConfig;\r\n  style?: CSSProperties;\r\n  translateValue?: string;\r\n}\r\n\r\nfunction TextTransition(props: PropsWithChildren<TextTransitionProps>) {\r\n  const {\r\n    direction = 'up',\r\n    inline = false,\r\n    springConfig = config.default,\r\n    delay = 0,\r\n    className,\r\n    style,\r\n    translateValue: tv = '100%',\r\n    children,\r\n  } = props;\r\n\r\n  const initialRun = useRef(true);\r\n  const fromTransform = direction === 'down' ? `-${tv}` : tv;\r\n  const leaveTransform = direction === 'down' ? tv : `-${tv}`;\r\n\r\n  const transitions = useTransition([children], {\r\n    enter: { opacity: 1, transform: 'translateY(0%)' },\r\n    from: { opacity: 0, transform: `translateY(${fromTransform})` },\r\n    leave: {\r\n      opacity: 0,\r\n      transform: `translateY(${leaveTransform})`,\r\n      position: 'absolute',\r\n    },\r\n    config: springConfig,\r\n    immediate: initialRun.current,\r\n    delay: !initialRun.current ? delay : undefined,\r\n  });\r\n\r\n  const [width, setWidth] = useState<number>(0);\r\n  const currentRef = useRef<HTMLDivElement>(null);\r\n  const heightRef = useRef<number | string>('auto');\r\n\r\n  useEffect(() => {\r\n    initialRun.current = false;\r\n    const element = currentRef.current;\r\n\r\n    // If element doesn't exist, then do nothing\r\n    if (!element) return;\r\n\r\n    const { width, height } = element.getBoundingClientRect();\r\n\r\n    setWidth(width);\r\n    heightRef.current = height;\r\n  }, [children, setWidth, currentRef]);\r\n\r\n  const widthTransition = useSpring({\r\n    to: { width },\r\n    config: springConfig,\r\n    immediate: initialRun.current,\r\n    delay: !initialRun.current ? delay : undefined,\r\n  });\r\n\r\n  return (\r\n    <animated.div\r\n      className={`text-transition ${className}`}\r\n      style={{\r\n        ...(inline && !initialRun.current ? widthTransition : undefined),\r\n        ...style,\r\n        whiteSpace: inline ? 'nowrap' : 'normal',\r\n        display: inline ? 'inline-flex' : 'flex',\r\n        height: heightRef.current,\r\n      }}\r\n    >\r\n      {transitions((styles, item) => (\r\n        <animated.div\r\n          style={{ ...styles }}\r\n          ref={item === children ? currentRef : undefined}\r\n          children={item}\r\n        />\r\n      ))}\r\n    </animated.div>\r\n  );\r\n}\r\n\r\nexport default TextTransition;\r\n"],"mappings":";;;;;;;;;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,MAAM,EAAEC,SAAS,QAAQ,OAAO;AAG1D,SAASC,SAAS,EAAEC,aAAa,EAAEC,QAAQ,EAAEC,MAAM,QAAsB,mBAAmB;AAY5F,SAASC,cAAcA,CAACC,KAA6C;EAEjE,IAAAC,EAAA,GAQED,KAAK,CAAAE,SARS;IAAhBA,SAAS,GAAAD,EAAA,cAAG,IAAI,GAAAA,EAAA;IAChBE,EAAA,GAOEH,KAAK,CAAAI,MA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