ice.fo.utils
Version:
28 lines (24 loc) • 809 B
JavaScript
import _startCase from 'lodash/startCase';
import getComponentNameForDocProp from './getComponentNameForDocProp';
import getComponentPropsForDocProp from './getComponentPropsForDocProp';
export default function buildPropsRenderTree(props, values, rootProps) {
return Object.entries(props).reduce((result, [key, item]) => {
if (item.doc && item.doc.hidden) {
return result;
}
const component = getComponentNameForDocProp(item);
result.push({
component,
fieldName: key,
fieldType: item.type,
props: {
...getComponentPropsForDocProp(component, item, key, values[key], rootProps || props),
id: key,
label: _startCase(key),
value: values[key],
description: item.description,
},
});
return result;
}, []);
}