All files / components/inputs/TextArea index.ts

0% Statements 0/12
0% Branches 0/4
0% Functions 0/3
0% Lines 0/12

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62                                                                                                                           
import React, { ChangeEvent, FocusEvent, ForwardedRef } from "react"
import TextArea from "./TextArea"
import { prepareComponent } from "@bluframe/grapple"
 
export interface Props {
  className?: string
  cols?: number
  defaultValue?: string
  disabled?: boolean
  error?: boolean
  errorText?: string
  infoText?: string
  inputId?: string
  isExpanded?: boolean
  isFullBorder?: boolean
  label?: React.ReactNode
  // eslint-disable-next-line no-unused-vars
  onBlur?: (event: FocusEvent) => void
  // eslint-disable-next-line no-unused-vars
  onChange?: (event: ChangeEvent) => void
  name: string
  placeholder?: string
  ref?: ForwardedRef<HTMLTextAreaElement>
  required?: boolean
  rows?: number
  success?: boolean
  successText?: string
  type?: string
  value?: string
}
 
export interface ComponentProps extends Props {
  labelId?: string
}
 
const usePrepareComponent = (props: Props): ComponentProps => {
  const labelId = props.inputId && `${props.inputId}-label`
 
  const onBlur = (event: FocusEvent) => {
    Iif (props.onBlur) {
      props.onBlur(event)
    }
  }
 
  const onChange = (event: ChangeEvent) => {
    Iif (props.onChange) {
      props.onChange(event)
    }
  }
 
  return {
    ...props,
    labelId,
    onBlur,
    onChange
  }
}
 
export default prepareComponent<Props, ComponentProps>(usePrepareComponent)(
  TextArea
)