Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
initialValue: null, // Anything.
invalid: {}, // index of invalid values.
meta: null, // Anything.
savedProgress: 0, // Percentage Number 0-99.
savedValue: null,
isSaving: false, // Bool.
isTouched: false,
valid: {}, // index of valid values.
value: null, // Anything.
}
export const resetFields = fields => mergeWith(pick(fields, defaultState))
export const getDragCount = get('dragCount')
export const setFocus = mergeWith({ blur: false, focus: true, isTouched: true })
export const setClose = resetFields(['blur', 'focus'])
export const saving = set('isSaving', true)
export const isNewValue = (state, payload) => (!isUndefined(payload) && payload !== state.value)
export const setValue = overBranch(isNewValue, setIn('value'))
export const touched = overBranch(negate(get('isTouched')), set('isTouched', true))
export const changeReducer = flow(setValue, touched)
export const blurReducer = flow(
changeReducer,
resetFields(['dragCount', 'focus']),
set('blur', true),
)
export const closeReducer = flow(setClose, touched)
export const resetFields = fields => mergeWith(pick(fields, defaultState))