@lobehub/ui
Version:
Lobe UI is an open-source UI component library for building AIGC web apps
1 lines • 2.36 kB
Source Map (JSON)
{"version":3,"file":"SkeletonText.mjs","names":[],"sources":["../../../src/base-ui/Skeleton/SkeletonText.tsx"],"sourcesContent":["'use client';\n\nimport { cssVar, cx } from 'antd-style';\nimport { type FC } from 'react';\n\nimport Skeleton from './Skeleton';\nimport { styles } from './style';\nimport type { SkeletonTextProps } from './type';\n\nconst SkeletonText: FC<SkeletonTextProps> = ({\n rows = 1,\n fontSize,\n lineHeight = 1.6,\n gap,\n width,\n className,\n style,\n ...rest\n}) => {\n const rowCount = Math.max(rows, 1);\n const base = fontSize === undefined ? cssVar.fontSize : `${fontSize}px`;\n const rowHeight = `round(calc(${base} * ${1 + (lineHeight - 1) * 0.5}), 1px)`;\n const halfLeading =\n gap === undefined ? `round(calc(${base} * ${(lineHeight - 1) * 0.25}), 1px)` : undefined;\n const widths = Array.isArray(width) ? width : undefined;\n\n const rowWidth = (index: number) => {\n if (widths) return widths[index] ?? widths.at(-1) ?? '100%';\n if (width !== undefined) return width as number | string;\n return index === rowCount - 1 && rowCount > 1 ? '66%' : '100%';\n };\n\n return (\n <div className={cx(styles.text, className)} style={{ gap, ...style }}>\n {Array.from({ length: rowCount }).map((_, index) => (\n <Skeleton\n height={rowHeight}\n key={index}\n style={{ marginBlock: halfLeading }}\n width={rowWidth(index)}\n {...rest}\n />\n ))}\n </div>\n );\n};\n\nSkeletonText.displayName = 'SkeletonText';\n\nexport default SkeletonText;\n"],"mappings":";;;;;;AASA,MAAM,gBAAuC,EAC3C,OAAO,GACP,UACA,aAAa,KACb,KACA,OACA,WACA,OACA,GAAG,WACC;CACJ,MAAM,WAAW,KAAK,IAAI,MAAM,CAAC;CACjC,MAAM,OAAO,aAAa,KAAA,IAAY,OAAO,WAAW,GAAG,SAAS;CACpE,MAAM,YAAY,cAAc,KAAK,KAAK,KAAK,aAAa,KAAK,GAAI;CACrE,MAAM,cACJ,QAAQ,KAAA,IAAY,cAAc,KAAK,MAAM,aAAa,KAAK,IAAK,WAAW,KAAA;CACjF,MAAM,SAAS,MAAM,QAAQ,KAAK,IAAI,QAAQ,KAAA;CAE9C,MAAM,YAAY,UAAkB;EAClC,IAAI,QAAQ,OAAO,OAAO,UAAU,OAAO,GAAG,EAAE,KAAK;EACrD,IAAI,UAAU,KAAA,GAAW,OAAO;EAChC,OAAO,UAAU,WAAW,KAAK,WAAW,IAAI,QAAQ;CAC1D;CAEA,OACE,oBAAC,OAAD;EAAK,WAAW,GAAG,OAAO,MAAM,SAAS;EAAG,OAAO;GAAE;GAAK,GAAG;EAAM;EAChE,UAAA,MAAM,KAAK,EAAE,QAAQ,SAAS,CAAC,CAAC,CAAC,KAAK,GAAG,UACxC,oBAAC,UAAD;GACE,QAAQ;GAER,OAAO,EAAE,aAAa,YAAY;GAClC,OAAO,SAAS,KAAK;GACrB,GAAI;EACL,GAJM,KAIN,CACF;CACE,CAAA;AAET;AAEA,aAAa,cAAc"}