{"version":3,"file":"Skeleton.mjs","names":[],"sources":["../../../src/skeleton/Skeleton.tsx"],"sourcesContent":["/*!\n *\n *  Copyright (c) \"Neo4j\"\n *  Neo4j Sweden AB [http://neo4j.com]\n *\n *  This file is part of Neo4j.\n *\n *  Neo4j is free software: you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation, either version 3 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with this program.  If not, see <http://www.gnu.org/licenses/>.\n */\nimport classNames from 'classnames';\nimport type React from 'react';\n\nimport { type PolymorphicCommonProps } from '../_common/types';\nimport { ConditionalWrap } from '../conditional-wrap';\n\ntype SkeletonProps = {\n  /** Shape of the skeleton */\n  shape?: 'circular' | 'rectangular';\n  /** Height of the skeleton */\n  height?: string;\n  /** Width of the skeleton */\n  width?: string;\n  /** Content displayed inside the skeleton. Size is inherited from the children if height or width are not provided. */\n  children?: React.ReactNode;\n  /** What background the skeleton is placed on. */\n  onBackground?: 'weak' | 'default';\n  /** Whether the skeleton is loading */\n  isLoading?: boolean;\n};\n\nexport const Skeleton = <T extends React.ElementType = 'div'>({\n  as,\n  shape = 'rectangular',\n  className,\n  style,\n  height,\n  width,\n  isLoading = true,\n  children,\n  htmlAttributes,\n  onBackground = 'default',\n  ref,\n  ...restProps\n}: PolymorphicCommonProps<T, SkeletonProps>) => {\n  const Component: React.ElementType = as ?? 'div';\n  const classes = classNames(\n    `ndl-skeleton ndl-skeleton-${shape}`,\n    onBackground && `ndl-skeleton-${onBackground}`,\n    className,\n  );\n\n  return (\n    <ConditionalWrap\n      shouldWrap={isLoading}\n      wrap={(children) => (\n        <Component\n          ref={ref}\n          className={classes}\n          style={{\n            ...style,\n            height,\n            width,\n          }}\n          aria-busy={true}\n          tabIndex={-1}\n          {...restProps}\n          {...htmlAttributes}\n        >\n          <div\n            aria-hidden={isLoading}\n            className=\"ndl-skeleton-content\"\n            tabIndex={-1}\n          >\n            {children}\n          </div>\n        </Component>\n      )}\n    >\n      {children}\n    </ConditionalWrap>\n  );\n};\n\nSkeleton.displayName = 'Skeleton';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CE;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;;AAXF,MAAa,YAAiD,SAad;CAbc,IAAA,EAC5D,IACA,QAAQ,eACR,WACA,OACA,QACA,OACA,YAAY,MACZ,UACA,gBACA,eAAe,WACf,QAAA,MACG,YAAA,yBAAA,MAAA,SAAA;CAEH,MAAM,YAA+B,OAAA,QAAA,OAAA,KAAA,IAAA,KAAM;CAC3C,MAAM,UAAU,WACd,6BAA6B,SAC7B,gBAAgB,gBAAgB,gBAChC,SACF;CAEA,OACE,oBAAC,iBAAD;EACE,YAAY;EACZ,OAAO,aACL,oBAAC,WAAA,eAAA,eAAA,eAAA;GACM;GACL,WAAW;GACX,OAAA,eAAA,eAAA,CAAA,GACK,KAAA,GAAA,CAAA,GAAA;IACH;IACA;GACF,CAAA;GACA,aAAW;GACX,UAAU;EACN,GAAA,SAAA,GACA,cAAA,GAAA,CAAA,GAAA,EAAA,UAEJ,oBAAC,OAAD;GACE,eAAa;GACb,WAAU;GACV,UAAU;GAET;EACE,CAAA,EAAA,CACI,CAAA;EAGZ;CACc,CAAA;AAErB;AAEA,SAAS,cAAc"}