UNPKG

@chakra-ui/input

Version:

A React component for input text field

1 lines 2.33 kB
{"version":3,"sources":["../src/input.tsx"],"sourcesContent":["import { FormControlOptions, useFormControl } from \"@chakra-ui/form-control\"\nimport {\n chakra,\n forwardRef,\n omitThemingProps,\n ThemingProps,\n useMultiStyleConfig,\n HTMLChakraProps,\n} from \"@chakra-ui/system\"\nimport { cx } from \"@chakra-ui/shared-utils\"\n\ninterface InputOptions {\n /**\n * The border color when the input is focused. Use color keys in `theme.colors`\n * @example\n * focusBorderColor = \"blue.500\"\n */\n focusBorderColor?: string\n /**\n * The border color when the input is invalid. Use color keys in `theme.colors`\n * @example\n * errorBorderColor = \"red.500\"\n */\n errorBorderColor?: string\n /**\n * The native HTML `size` attribute to be passed to the `input`\n */\n htmlSize?: number\n}\n\ntype Omitted = \"disabled\" | \"required\" | \"readOnly\" | \"size\"\n\nexport interface InputProps\n extends Omit<HTMLChakraProps<\"input\">, Omitted>,\n InputOptions,\n ThemingProps<\"Input\">,\n FormControlOptions {}\n\n/**\n * Input\n *\n * Element that allows users enter single valued data.\n *\n * @see Docs https://chakra-ui.com/docs/components/input\n */\nexport const Input = forwardRef<InputProps, \"input\">(function Input(\n props,\n ref,\n) {\n const { htmlSize, ...rest } = props\n\n const styles = useMultiStyleConfig(\"Input\", rest)\n const ownProps = omitThemingProps(rest)\n const input = useFormControl<HTMLInputElement>(ownProps)\n const _className = cx(\"chakra-input\", props.className)\n\n return (\n <chakra.input\n size={htmlSize}\n {...input}\n __css={styles.field}\n ref={ref}\n className={_className}\n />\n )\n})\n\nInput.displayName = \"Input\"\n\n// This is used in `input-group.tsx`\nInput.id = \"Input\"\n"],"mappings":";;;AAAA,SAA6B,sBAAsB;AACnD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,OAEK;AACP,SAAS,UAAU;AAgDf;AAZG,IAAM,QAAQ,WAAgC,SAASA,OAC5D,OACA,KACA;AACA,QAAM,EAAE,UAAU,GAAG,KAAK,IAAI;AAE9B,QAAM,SAAS,oBAAoB,SAAS,IAAI;AAChD,QAAM,WAAW,iBAAiB,IAAI;AACtC,QAAM,QAAQ,eAAiC,QAAQ;AACvD,QAAM,aAAa,GAAG,gBAAgB,MAAM,SAAS;AAErD,SACE;AAAA,IAAC,OAAO;AAAA,IAAP;AAAA,MACC,MAAM;AAAA,MACL,GAAG;AAAA,MACJ,OAAO,OAAO;AAAA,MACd;AAAA,MACA,WAAW;AAAA;AAAA,EACb;AAEJ,CAAC;AAED,MAAM,cAAc;AAGpB,MAAM,KAAK;","names":["Input"]}