UNPKG

koval-ui

Version:

React components collection with minimalistic design. Supports theming, layout, and input validation.

1 lines 2.95 kB
{"version":3,"file":"SkeletonAction.cjs","sources":["../../../../src/lib/Skeleton/SkeletonAction.tsx"],"sourcesContent":["import type {ReactNode} from 'react';\nimport {useMemo, forwardRef} from 'react';\nimport classNames from 'classnames';\nimport {useLocalTheme} from 'css-vars-hook';\n\nimport type {DataAttributes, LibraryProps} from '@/internal/LibraryAPI';\nimport {useLinkRefs} from '@/internal/hooks/useLinkRefs.ts';\n\nimport classes from './Skeleton.module.css';\nimport {SkeletonShape} from './SkeletonShape.tsx';\nimport type {SkeletonProps} from './SkeletonTypes.ts';\nimport {normalizeUnit} from './normalizeUnit.ts';\n\nexport type Props = DataAttributes &\n LibraryProps &\n SkeletonProps & {\n children?: ReactNode;\n double?: boolean;\n };\n\nexport const SkeletonAction = forwardRef<HTMLDivElement, Props>(\n (\n {\n children,\n className,\n width = 'fluid',\n height = 'fluid',\n marginY = 24,\n marginX = 0,\n double = false,\n ...nativeProps\n },\n ref\n ) => {\n const {LocalRoot, ref: innerRef} = useLocalTheme<HTMLDivElement>();\n useLinkRefs(ref, innerRef);\n const theme = useMemo(\n () => ({\n width: normalizeUnit(width),\n height: normalizeUnit(height),\n 'margin-y': marginY,\n 'margin-x': marginX,\n }),\n [height, marginX, marginY, width]\n );\n return (\n <LocalRoot\n {...nativeProps}\n className={classNames(classes.skeletonAction, className)}\n theme={theme}>\n <SkeletonShape className={classes.skeletonButton} height={36} />\n {double && <SkeletonShape className={classes.skeletonButton} height={36} />}\n </LocalRoot>\n );\n }\n);\n\nSkeletonAction.displayName = 'SkeletonAction';\n"],"names":["SkeletonAction","forwardRef","children","className","width","height","marginY","marginX","double","nativeProps","ref","LocalRoot","innerRef","useLocalTheme","useLinkRefs","theme","useMemo","normalizeUnit","jsxs","classNames","classes","jsx","SkeletonShape"],"mappings":"mWAoBaA,EAAiBC,EAAA,WAC1B,CACI,CACI,SAAAC,EACA,UAAAC,EACA,MAAAC,EAAQ,QACR,OAAAC,EAAS,QACT,QAAAC,EAAU,GACV,QAAAC,EAAU,EACV,OAAAC,EAAS,GACT,GAAGC,GAEPC,IACC,CACD,KAAM,CAAC,UAAAC,EAAW,IAAKC,CAAA,EAAYC,EAAAA,cAA8B,EACjEC,EAAA,YAAYJ,EAAKE,CAAQ,EACzB,MAAMG,EAAQC,EAAA,QACV,KAAO,CACH,MAAOC,gBAAcb,CAAK,EAC1B,OAAQa,gBAAcZ,CAAM,EAC5B,WAAYC,EACZ,WAAYC,CAAA,GAEhB,CAACF,EAAQE,EAASD,EAASF,CAAK,CACpC,EAEI,OAAAc,EAAA,KAACP,EAAA,CACI,GAAGF,EACJ,UAAWU,EAAWC,UAAQ,eAAgBjB,CAAS,EACvD,MAAAY,EACA,SAAA,CAAAM,EAAA,IAACC,EAAc,cAAA,CAAA,UAAWF,EAAQ,QAAA,eAAgB,OAAQ,GAAI,EAC7DZ,GAAWa,EAAAA,IAAAC,EAAAA,cAAA,CAAc,UAAWF,EAAAA,QAAQ,eAAgB,OAAQ,EAAI,CAAA,CAAA,CAAA,CAC7E,CAAA,CAGZ,EAEApB,EAAe,YAAc"}