Repository URL to install this package:
|
Version:
3.0.0-beta.1 ▾
|
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'
}
}