All files / atom/pinInput/src config.js

100% Statements 19/19
100% Branches 14/14
100% Functions 3/3
100% Lines 17/17

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 411x   1x                 1x         1x             1x 98x 68x 56x 43x 43x 43x     1x 48x 48x 48x 2x   48x    
export const BASE_CLASSNAME = 'sui-PinInput'
 
export const SIZES = {
  XXSMALL: 'xxsmall',
  XSMALL: 'xsmall',
  SMALL: 'small',
  MEDIUM: 'medium',
  LARGE: 'large',
  XLARGE: 'xlarge',
  XXLARGE: 'xxlarge'
}
export const STATUS = {
  ERROR: 'error',
  SUCCESS: 'success',
  ALERT: 'alert'
}
export const MASK = {
  NUMBER: '[0-9]',
  ALPHABETIC: '[A-Za-z]',
  ALPHANUMERIC: '[A-Za-z0-9]'
}
 
export const valueChecker =
  ({length = 1, mask}) =>
  (value = '') => {
    if (length === 0 && value === '') return true
    if (value.length !== length) return false
    const matchExpression = `${mask}{${length}}`
    const regex = new RegExp(matchExpression)
    return regex.test(value)
  }
 
export const getValueType = ({value, defaultValue}) => {
  const val = value || defaultValue
  let valueType = typeof val
  if (typeof val === 'object' && val instanceof Array) {
    valueType = 'array'
  }
  return valueType
}