UNPKG

@nex-ui/react

Version:

🎉 A beautiful, modern, and reliable React component library.

93 lines (90 loc) • 2.94 kB
"use client"; import { jsxs, Fragment, jsx } from 'react/jsx-runtime'; import { useDefaultProps } from '../utils/useDefaultProps.mjs'; import { useStyles } from '../utils/useStyles.mjs'; import { useSlotClasses } from '../utils/useSlotClasses.mjs'; import { useSlot } from '../utils/useSlot.mjs'; import { cardHeaderRecipe } from '../../theme/recipes/card.mjs'; const slots = [ 'root', 'content', 'title', 'subtitle' ]; const CardHeader = (inProps)=>{ const props = useDefaultProps({ name: 'CardHeader', props: inProps }); const { title, subtitle, avatar, action, children, slotProps, classNames, ...remainingProps } = props; const styles = useStyles({ ownerState: props, name: 'CardHeader', recipe: cardHeaderRecipe }); const slotClasses = useSlotClasses({ name: 'CardHeader', slots, classNames }); const [CardHeaderRoot, getCardHeaderRootProps] = useSlot({ style: styles.root, elementType: 'div', externalForwardedProps: remainingProps, classNames: slotClasses.root }); const [CardContent, getCardContentProps] = useSlot({ elementType: 'div', style: styles.content, externalSlotProps: slotProps?.content, classNames: slotClasses.content }); const [CardTitle, getCardTitleProps] = useSlot({ style: styles.title, elementType: 'div', externalSlotProps: slotProps?.title, classNames: slotClasses.title, additionalProps: { children: title } }); const [CardSubtitle, getCardSubtitleProps] = useSlot({ style: styles.subtitle, elementType: 'div', classNames: slotClasses.subtitle, externalSlotProps: slotProps?.subtitle, additionalProps: { children: subtitle } }); let node = children; if (!children) { node = /*#__PURE__*/ jsxs(Fragment, { children: [ avatar, title && subtitle ? /*#__PURE__*/ jsxs(CardContent, { ...getCardContentProps(), children: [ /*#__PURE__*/ jsx(CardTitle, { ...getCardTitleProps() }), /*#__PURE__*/ jsx(CardSubtitle, { ...getCardSubtitleProps() }) ] }) : title ? /*#__PURE__*/ jsx(CardTitle, { ...getCardTitleProps() }) : subtitle ? /*#__PURE__*/ jsx(CardSubtitle, { ...getCardSubtitleProps() }) : null, action ] }); } return /*#__PURE__*/ jsx(CardHeaderRoot, { ...getCardHeaderRootProps(), children: node }); }; CardHeader.displayName = 'CardHeader'; export { CardHeader };