{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["import type { FC, ReactElement } from \"react\";\r\nimport { useMemo } from \"react\";\r\nimport ContentLoader from \"react-content-loader\";\r\nimport type { IContentLoaderProps } from \"react-content-loader\";\r\nimport type { IContentPlaceholder } from \"./config/types\";\r\nimport { getLinesProp } from \"./utils/index\";\r\nimport type { IComponentBaseProps } from \"../../types/components/index\";\r\nimport { useCN } from \"../../utils/react/useCN\";\r\nimport \"./style.pcss\";\r\n\r\nconst loaderModule = ContentLoader as FC<IContentLoaderProps> & {\r\n  default?: FC<IContentLoaderProps>;\r\n};\r\n\r\nconst Loader: FC<IContentLoaderProps> = process.env.NODE_ENV === \"test\" && loaderModule.default\r\n  ? loaderModule.default\r\n  : loaderModule;\r\n\r\n/**\r\n * Компонент заглушки\r\n * @returns {ReactElement}\r\n\r\n */\r\nconst ContentPlaceholder: FC<IContentPlaceholder & IComponentBaseProps> = ({\r\n  baseClass = \"contentPlaceholder\",\r\n  children = null,\r\n  extraClasses = {},\r\n  extraAttrs = {},\r\n  speed = 2,\r\n  backgroundColor = \"#ecebeb\",\r\n  foregroundColor = \"#f3f3f3\",\r\n  width = 400,\r\n  height = 264,\r\n  preserveAspectRatio = \"none\",\r\n  lines = 5,\r\n  linesHeight = 40,\r\n  linesBorderRadius = 8,\r\n  linesMargin = 16,\r\n  linesWidth = [ 400, 360, 320, 380, 240 ],\r\n}): ReactElement => {\r\n\r\n  const { getCN } = useCN(baseClass);\r\n\r\n  const linesChildren = useMemo<ReactElement[]>(() => {\n    let offsetY = 0;\n    return new Array(lines)\n      .fill(\"\")\n      .map((_line, index) => {\n        const mb = getLinesProp(linesMargin, index);\n        const height = getLinesProp(linesHeight, index);\n        const width = getLinesProp(linesWidth, index);\n        const br = getLinesProp(linesBorderRadius, index);\n        const y = offsetY;\n        offsetY += height + mb;\n        const lineKey = `line_${y}_${width}_${height}_${br}`;\n        return (\n          <rect className={getCN(\"line\")} key={lineKey} x={0} y={y} rx={br} ry={br} width={width} height={height} />\n        );\n      });\n  }, [ lines, linesMargin, linesBorderRadius, linesWidth, linesHeight ]);\r\n\r\n  return (\r\n    <div className={getCN(\"\", extraClasses)} {...extraAttrs} role={\"progressbar\"}>\r\n      <Loader className={getCN(\"inner\")} speed={speed} backgroundColor={backgroundColor}\r\n        foregroundColor={foregroundColor} preserveAspectRatio={preserveAspectRatio}\r\n        viewBox={`0 0 ${width} ${height}`}>\r\n        {children || linesChildren}\r\n      </Loader>\r\n    </div>\r\n  );\r\n\r\n};\r\n\r\nexport type { IContentPlaceholder };\r\nexport { ContentPlaceholder };\r\n"],"names":["loaderModule","ContentLoader","Loader","process","env","NODE_ENV","default","ContentPlaceholder","baseClass","children","extraClasses","extraAttrs","speed","backgroundColor","foregroundColor","width","height","preserveAspectRatio","lines","linesHeight","linesBorderRadius","linesMargin","linesWidth","getCN","useCN","linesChildren","useMemo","offsetY","Array","fill","map","_line","index","mb","getLinesProp","br","y","lineKey","_jsx","className","x","rx","ry","role","viewBox"],"mappings":"yMAUA,MAAMA,aAAeC,cAIrB,MAAMC,OAAkCC,QAAQC,IAAIC,WAAa,QAAUL,aAAaM,QACpFN,aAAaM,QACbN;;;;;GAOJ,MAAMO,mBAAoE,EACxEC,oBAAY,qBACZC,kBAAW,KACXC,0BAAe,CAAA,EACfC,sBAAa,CAAA,EACbC,YAAQ,EACRC,gCAAkB,UAClBC,gCAAkB,UAClBC,YAAQ,IACRC,cAAS,IACTC,wCAAsB,OACtBC,YAAQ,EACRC,wBAAc,GACdC,oCAAoB,EACpBC,wBAAc,GACdC,sBAAa,CAAE,IAAK,IAAK,IAAK,IAAK,SAGnC,MAAMC,MAAEA,OAAUC,MAAMhB,WAExB,MAAMiB,cAAgBC,QAAwB,KAC5C,IAAIC,QAAU,EACd,OAAO,IAAIC,MAAMV,OACdW,KAAK,IACLC,IAAI,CAACC,MAAOC,SACX,MAAMC,GAAKC,aAAab,YAAaW,OACrC,MAAMhB,OAASkB,aAAaf,YAAaa,OACzC,MA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