|
|
@ -8,7 +8,8 @@ import { |
|
|
filter, |
|
|
filter, |
|
|
reduce, |
|
|
reduce, |
|
|
cloneDeep, |
|
|
cloneDeep, |
|
|
includes |
|
|
includes, |
|
|
|
|
|
last |
|
|
} from "lodash/fp"; |
|
|
} from "lodash/fp"; |
|
|
import { types, expandPropsDefinition } from "./types"; |
|
|
import { types, expandPropsDefinition } from "./types"; |
|
|
import { assign } from "lodash"; |
|
|
import { assign } from "lodash"; |
|
|
@ -74,9 +75,13 @@ export const getComponentInfo = (allComponents, comp, stack=[], subComponentProp |
|
|
if(isRootComponent(component)) { |
|
|
if(isRootComponent(component)) { |
|
|
subComponentProps = subComponentProps||{}; |
|
|
subComponentProps = subComponentProps||{}; |
|
|
const p = createProps(cname, component.props, subComponentProps); |
|
|
const p = createProps(cname, component.props, subComponentProps); |
|
|
|
|
|
const rootProps = createProps(cname, component.props); |
|
|
const inheritedProps = []; |
|
|
const inheritedProps = []; |
|
|
|
|
|
const targetComponent = stack.length > 0 |
|
|
|
|
|
? last(stack) |
|
|
|
|
|
: component; |
|
|
if(stack.length > 0) { |
|
|
if(stack.length > 0) { |
|
|
const targetComponent = stack[0]; |
|
|
|
|
|
for(let prop in subComponentProps) { |
|
|
for(let prop in subComponentProps) { |
|
|
const hasProp = pipe(targetComponent.props, [ |
|
|
const hasProp = pipe(targetComponent.props, [ |
|
|
keys, |
|
|
keys, |
|
|
@ -88,24 +93,27 @@ export const getComponentInfo = (allComponents, comp, stack=[], subComponentProp |
|
|
} |
|
|
} |
|
|
const unsetProps = pipe(p.props, [ |
|
|
const unsetProps = pipe(p.props, [ |
|
|
keys, |
|
|
keys, |
|
|
filter(k => !includes(k)(keys(subComponentProps))) |
|
|
filter(k => !includes(k)(keys(subComponentProps)) && k !== "_component") |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
const fullProps = cloneDeep(p.props); |
|
|
|
|
|
fullProps._component = targetComponent.name; |
|
|
|
|
|
|
|
|
return ({ |
|
|
return ({ |
|
|
propsDefinition:expandPropsDefinition(component.props), |
|
|
propsDefinition:expandPropsDefinition(component.props), |
|
|
inheritedProps, |
|
|
inheritedProps, |
|
|
rootDefaultProps: p.props, |
|
|
rootDefaultProps: rootProps.props, |
|
|
unsetProps, |
|
|
unsetProps, |
|
|
fullProps: p.props, |
|
|
fullProps: fullProps, |
|
|
errors: p.errors, |
|
|
errors: p.errors, |
|
|
component: stack.length > 0 ? stack[0] : component, |
|
|
component: targetComponent, |
|
|
rootComponent: component |
|
|
rootComponent: component |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
return getComponentInfo( |
|
|
return getComponentInfo( |
|
|
allComponents, |
|
|
allComponents, |
|
|
component.inherits, |
|
|
component.inherits, |
|
|
[...stack, component], |
|
|
[component, ...stack], |
|
|
{...component.props, ...subComponentProps}); |
|
|
{...component.props, ...subComponentProps}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|