File size: 2,084 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
{
  "type": "composition",
  "npmDependencies": [],
  "fileDependencies": [],
  "id": "checkbox-card",
  "file": {
    "name": "checkbox-card.tsx",
    "content": "import { CheckboxCard as ChakraCheckboxCard } from \"@chakra-ui/react\"\nimport * as React from \"react\"\n\nexport interface CheckboxCardProps extends ChakraCheckboxCard.RootProps {\n  icon?: React.ReactElement\n  label?: React.ReactNode\n  description?: React.ReactNode\n  addon?: React.ReactNode\n  indicator?: React.ReactNode | null\n  indicatorPlacement?: \"start\" | \"end\" | \"inside\"\n  inputProps?: React.InputHTMLAttributes<HTMLInputElement>\n}\n\nexport const CheckboxCard = React.forwardRef<\n  HTMLInputElement,\n  CheckboxCardProps\n>(function CheckboxCard(props, ref) {\n  const {\n    inputProps,\n    label,\n    description,\n    icon,\n    addon,\n    indicator = <ChakraCheckboxCard.Indicator />,\n    indicatorPlacement = \"end\",\n    ...rest\n  } = props\n\n  const hasContent = label || description || icon\n  const ContentWrapper = indicator ? ChakraCheckboxCard.Content : React.Fragment\n\n  return (\n    <ChakraCheckboxCard.Root {...rest}>\n      <ChakraCheckboxCard.HiddenInput ref={ref} {...inputProps} />\n      <ChakraCheckboxCard.Control>\n        {indicatorPlacement === \"start\" && indicator}\n        {hasContent && (\n          <ContentWrapper>\n            {icon}\n            {label && (\n              <ChakraCheckboxCard.Label>{label}</ChakraCheckboxCard.Label>\n            )}\n            {description && (\n              <ChakraCheckboxCard.Description>\n                {description}\n              </ChakraCheckboxCard.Description>\n            )}\n            {indicatorPlacement === \"inside\" && indicator}\n          </ContentWrapper>\n        )}\n        {indicatorPlacement === \"end\" && indicator}\n      </ChakraCheckboxCard.Control>\n      {addon && <ChakraCheckboxCard.Addon>{addon}</ChakraCheckboxCard.Addon>}\n    </ChakraCheckboxCard.Root>\n  )\n})\n\nexport const CheckboxCardIndicator = ChakraCheckboxCard.Indicator\n"
  },
  "component": "CheckboxCard"
}