Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
@skava/forms / src / new-forms / plugins / TextAreaPlugin.tsx
Size: Mime:
import * as React from 'react'
import { observer } from 'xmobx/mobx-react'
import { errorMessageFor, isValid } from '../../validators'
import { InputProps } from '../inputs'
import { InputState } from '../inputs/InputState'
import { Value } from '../typings'

@observer
export class TextAreaPlugin extends React.Component<InputProps> {
  static isSatisfiedByProps(props: { type: string }): boolean {
    return ['textarea'].includes(props.type)
  }

  static defaultState = (inputState: InputState) => {
    return {
      validator: (value: Value) =>
        isValid(value as string) || errorMessageFor('required'),
    }
  }

  render() {
    const { ref, className, ...props } = this.props
    return <textarea className={className} {...props} />
  }
}