src/actions.js
function getDefaultedValue ({inputValue, previousValue, bunsenId, renderModel, mergeDefaults}) {
  const isInputValueEmpty = isEmptyValue(inputValue)

  if (previousValue !== undefined) {
    return inputValue
  }

  const resolveRef = schemaFromRef(renderModel.definitions)
  const defaultValue = getDefaults(inputValue, bunsenId, renderModel, resolveRef)
  const hasDefaults = defaultValue !== undefined
  const isUpdatingAll = bunsenId === null

  const shouldApplyDefaults = isInputValueEmpty && hasDefaults ||
    !isInputValueEmpty && hasDefaults && isUpdatingAll && mergeDefaults
  const shouldClear = isInputValueEmpty && isUpdatingAll && !hasDefaults

  if (shouldApplyDefaults) {
    const schema = findSchema(renderModel, bunsenId, resolveRef)
    return schema.type === 'object' ? _.defaults({}, inputValue, defaultValue) : defaultValue
  } else if (shouldClear) {
    return {}
  }

  return inputValue
}
function getDefaultedValue ({inputValue, previousValue, bunsenId, renderModel, mergeDefaults}) {
  const isInputValueEmpty = isEmptyValue(inputValue)

  if (previousValue !== undefined) {
    return inputValue
  }

  const resolveRef = schemaFromRef(renderModel.definitions)
  const defaultValue = getDefaults(inputValue, bunsenId, renderModel, resolveRef)
  const hasDefaults = defaultValue !== undefined
  const isUpdatingAll = bunsenId === null

  const shouldApplyDefaults = isInputValueEmpty && hasDefaults ||
    !isInputValueEmpty && hasDefaults && isUpdatingAll && mergeDefaults
  const shouldClear = isInputValueEmpty && isUpdatingAll && !hasDefaults

  if (shouldApplyDefaults) {
    const schema = findSchema(renderModel, bunsenId, resolveRef)
    return schema.type === 'object' ? _.defaults({}, inputValue, defaultValue) : defaultValue
  } else if (shouldClear) {
    return {}
  }

  return inputValue
}
function getDefaultedValue ( { inputValue , previousValue , bunsenId , renderModel , mergeDefaults } ) { const isInputValueEmpty = isEmptyValue ( inputValue ) if ( previousValue !== undefined ) { return inputValue } const resolveRef = schemaFromRef ( renderModel . definitions ) const defaultValue = getDefaults ( inputValue , bunsenId , renderModel , resolveRef ) const hasDefaults = defaultValue !== undefined const isUpdatingAll = bunsenId === null const shouldApplyDefaults = isInputValueEmpty && hasDefaults || ! isInputValueEmpty && hasDefaults && isUpdatingAll && mergeDefaults const shouldClear = isInputValueEmpty && isUpdatingAll && ! hasDefaults if ( shouldApplyDefaults ) { const schema = findSchema ( renderModel , bunsenId , resolveRef ) return schema . type === 'object' ? _ . defaults ( { } , inputValue , defaultValue ) : defaultValue } else if ( shouldClear ) { return { } } return inputValue }
Returns the default value for the given model

@param {Object} inputValue - form value at the given bunsen path
@param {Object} previousValue - the previous form value at the given bunsen path
@param {String} bunsenId - the bunsen path id
@param {Object} renderModel - the bunsen model without conditions
@param {Boolean} mergeDefaults - whether to force a default value on a non-empty value
 /* eslint-disable complexity
Returns the default value for the given model