1 line
8.2 KiB
JSON
1 line
8.2 KiB
JSON
|
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport raf from \"rc-util/es/raf\";\nimport React, { useEffect, useRef, useState } from 'react';\nvar useIndicator = function useIndicator(options) {\n var activeTabOffset = options.activeTabOffset,\n horizontal = options.horizontal,\n rtl = options.rtl,\n _options$indicator = options.indicator,\n indicator = _options$indicator === void 0 ? {} : _options$indicator;\n var size = indicator.size,\n _indicator$align = indicator.align,\n align = _indicator$align === void 0 ? 'center' : _indicator$align;\n var _useState = useState(),\n _useState2 = _slicedToArray(_useState, 2),\n inkStyle = _useState2[0],\n setInkStyle = _useState2[1];\n var inkBarRafRef = useRef();\n var getLength = React.useCallback(function (origin) {\n if (typeof size === 'function') {\n return size(origin);\n }\n if (typeof size === 'number') {\n return size;\n }\n return origin;\n }, [size]);\n\n // Delay set ink style to avoid remove tab blink\n function cleanInkBarRaf() {\n raf.cancel(inkBarRafRef.current);\n }\n useEffect(function () {\n var newInkStyle = {};\n if (activeTabOffset) {\n if (horizontal) {\n newInkStyle.width = getLength(activeTabOffset.width);\n var key = rtl ? 'right' : 'left';\n if (align === 'start') {\n newInkStyle[key] = activeTabOffset[key];\n }\n if (align === 'center') {\n newInkStyle[key] = activeTabOffset[key] + activeTabOffset.width / 2;\n newInkStyle.transform = rtl ? 'translateX(50%)' : 'translateX(-50%)';\n }\n if (align === 'end') {\n newInkStyle[key] = activeTabOffset[key] + activeTabOffset.width;\n newInkStyle.transform = 'translateX(-100%)';\n }\n } else {\n newInkStyle.height = getLength(activeTabOffset.height);\n if (align === 'start') {\n newInkStyle.top = activeTabOffset.top;\n }\n if (align === 'center') {\n newInkStyle.top = activeTabOffset.top + activeTabOffset.height / 2;\n newInkStyle.transform = 'translateY(-50%)';\n }\n if (align === 'end') {\n newInkStyle.top = activeTabOffset.top + activeTabOffset.height;\n newInkStyle.transform = 'translateY(-100%)';\n }\n }\n }\n cleanInkBarRaf();\n inkBarRafRef.current = raf(function () {\n setInkStyle(newInkStyle);\n });\n return cleanInkBarRaf;\n }, [activeTabOffset, horizontal, rtl, align, getLength]);\n return {\n style: inkStyle\n };\n};\nexport default useIndicator;","map":{"version":3,"names":["_slicedToArray","raf","React","useEffect","useRef","useState","useIndicator","options","activeTabOffset","horizontal","rtl","_options$indicator","indicator","size","_indicator$align","align","_useState","_useState2","inkStyle","setInkStyle","inkBarRafRef","getLength","useCallback","origin","cleanInkBarRaf","cancel","current","newInkStyle","width","key","transform","height","top","style"],"sources":["C:/Users/Аришина)/source/repos/PromoCursed/node_modules/rc-tabs/es/hooks/useIndicator.js"],"sourcesContent":["import _slicedToArray from \"@babel/runtime/helpers/esm/slicedToArray\";\nimport raf from \"rc-util/es/raf\";\nimport React, { useEffect, useRef, useState } from 'react';\nvar useIndicator = function useIndicator(options) {\n var activeTabOffset = options.activeTabOffset,\n horizontal = options.horizontal,\n rtl = options.rtl,\n _options$indicator = options.indicator,\n indicator = _options$indicator === void 0 ? {} : _options$indicator;\n var size = indicator.size,\n _indicator$align = indicator.align,\n align = _indicator$align === void 0 ? 'center' : _indicator$align;\n var _useState = useState(),\n _useState2 = _slicedToArray(_useState, 2),\n inkStyle = _useState2[0],\n setInkStyle = _useState2[1];\n var inkBarRafRef = useRef();\n var getLength = React.useCallback(function (origin) {\n if (typeof size === 'function') {\n retu
|