All files / atom/pinInput/src/reducer actions.js

100% Statements 17/17
66.66% Branches 2/3
100% Functions 8/8
100% Lines 9/9

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      273x   22x 5x 13x 198x 22x 7x 6x   1x                      
import {MASK} from '../config.js'
import PIN_INPUT_ACTION_TYPES from './actionTypes.js'
 
const act = (actionType, payload = {}) => ({actionType, payload})
 
const setKey = ({event, onChange}) => act(PIN_INPUT_ACTION_TYPES.SET_PIN_INPUT_KEY, {event, onChange})
const setValue = ({innerValue}) => act(PIN_INPUT_ACTION_TYPES.SET_PIN_INPUT_VALUE, {innerValue})
const setFocus = ({focusPosition}) => act(PIN_INPUT_ACTION_TYPES.SET_PIN_INPUT_FOCUS, {focusPosition})
const setElement = ({node}) => act(PIN_INPUT_ACTION_TYPES.SET_PIN_INPUT_ELEMENT, {node})
const removeElement = ({node}) => act(PIN_INPUT_ACTION_TYPES.REMOVE_PIN_INPUT_ELEMENT, {node})
const setMask = ({mask = MASK.NUMBER}) => act(PIN_INPUT_ACTION_TYPES.SET_PIN_INPUT_MASK, {mask})
const setDisabled = ({disabled = false}) => act(PIN_INPUT_ACTION_TYPES.SET_PIN_INPUT_DISABLED, {disabled})
 
const actions = {
  setKey,
  setValue,
  setFocus,
  setElement,
  removeElement,
  setMask,
  setDisabled
}
 
export default actions