File size: 1,160 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
{
  "type": "composition",
  "npmDependencies": [],
  "fileDependencies": [],
  "id": "pin-input",
  "file": {
    "name": "pin-input.tsx",
    "content": "import { PinInput as ChakraPinInput, Group } from \"@chakra-ui/react\"\nimport * as React from \"react\"\n\nexport interface PinInputProps extends ChakraPinInput.RootProps {\n  rootRef?: React.RefObject<HTMLDivElement | null>\n  count?: number\n  inputProps?: React.InputHTMLAttributes<HTMLInputElement>\n  attached?: boolean\n}\n\nexport const PinInput = React.forwardRef<HTMLInputElement, PinInputProps>(\n  function PinInput(props, ref) {\n    const { count = 4, inputProps, rootRef, attached, ...rest } = props\n    return (\n      <ChakraPinInput.Root ref={rootRef} {...rest}>\n        <ChakraPinInput.HiddenInput ref={ref} {...inputProps} />\n        <ChakraPinInput.Control>\n          <Group attached={attached}>\n            {Array.from({ length: count }).map((_, index) => (\n              <ChakraPinInput.Input key={index} index={index} />\n            ))}\n          </Group>\n        </ChakraPinInput.Control>\n      </ChakraPinInput.Root>\n    )\n  },\n)\n"
  },
  "component": "PinInput"
}