import {fromJS} from 'immutable';

export default function extendProps({defaultProps, customProps, component, propsDefinition, createSetAtomProp, setAtomProp}) {
  const override = {}

  if (propsDefinition.onChange && propsDefinition.value)
    override.onChange = createSetAtomProp('value', propsDefinition.value.type.name)

  const enhanceOld = component.enhanceComponentLibraryDefaults
    ? component.enhanceComponentLibraryDefaults(override, setAtomProp)
    : override

  const enhanceBluekit = component.enhanceBluekitDefaults
    ? component.enhanceBluekitDefaults(enhanceOld, setAtomProp)
    : enhanceOld

  const extendOld = component.extendComponentLibraryProps
    ? component.extendComponentLibraryProps(enhanceBluekit, setAtomProp)
    : enhanceBluekit

  const extendBluekit = component.extendBluekitProps
    ? component.extendBluekitProps(extendOld, setAtomProp)
    : extendOld

  return fromJS(defaultProps).mergeDeep(customProps, fromJS(extendBluekit))
}

@@ -200,24 +200,29 @@
 inition.
+get('
 onChange
  && prop
@@ -213,16 +213,18 @@
 onChange
+')
  && prop
@@ -235,21 +235,28 @@
 inition.
+get('
 value
+')
 )%0A    ov
@@ -320,23 +320,40 @@
 ion.
-value.type.
+getIn(%5B'value', 'type', '
 name
+'%5D)
 )%0A%0A 

Fix on change value