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 / forms / deps.ts
Size: Mime:
import { InputState } from '../inputs/InputState'

/**
 * @todo 1. belongs in input deps?
 * @todo 2. could be as an input method?
 * @todo 3. how to put this at the plugin level?
 */
export function resetInput(inputState: InputState) {
   // To reset textbox
   if (
    inputState.type !== 'button' &&
    inputState.type !== 'label' &&
    inputState.type !== 'select'
  ) {
    if (!inputState.setValue) {
      console.warn('inputState missing setValue')
      console.log(inputState)
      console.log('\n\n\n')
    } else {
      inputState.setValue('')
    }
    // inputState.isValidInput = true
  }

  // To reset groupElements
  if (inputState.elementList && inputState.elementList.length > 0) {
    inputState.elementList.forEach(resetInput)
  }

  if (inputState.type === 'select') {
    inputState.setValue(inputState.label)
  }

  // To reset the 'show password' state
  if (inputState.name === 'password') {
    inputState.type = 'password'
  }
}