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/ui / src / inputs / TextBox / handlers / blurMiddleware.ts
Size: Mime:
import {
  formatPhoneNumber,
  removePhoneNumberFormatting,
} from 'uxui-modules/utils/formatPhoneNumber'
import { TextBoxProps, TextBoxState, TextBoxComponent } from '../typings'

export function blurMiddleware(event: Event, props: TextBoxProps, state: TextBoxState) {
  const { validationType } = props

  /**
   * @todo - this type check should be inside of the method we pass in
   */
  if (validationType === 'telephone') {
    const value = removePhoneNumberFormatting(state.value)
    state.setValue(value)
  }

  console.debug('[input] TextBox.blur')
  console.info('{value, isValid} ', state.value, state.isValid || state.isValidInput)
}