= {
defaultExpanded: true,
};
render() {
const { className, children, props, rest } = this.restProps(x => {
const {
headerContent,
headerActions,
headerFormat,
teaserContent,
summaryContent,
footerContent,
footerActions,
footerFormat,
shadow,
} = x;
return {
headerContent,
headerActions,
headerFormat,
teaserContent,
summaryContent,
footerContent,
footerActions,
footerFormat,
shadow,
};
});
const panelClassName = this.wxr.classNames(
'CommonPanel',
{
shadow: props.shadow === true,
collapsible: rest.collapsible,
},
className,
);
return (
{this.renderContent(props.teaserContent, 'body', 'teaser')}
{children}
{this.renderContent(props.summaryContent, 'body', 'summary')}
);
}
private renderContent(
content: CommonPannelContent,
section: CommonPanelContentSection,
sectionType?: CommonPanelContentType,
) {
return (
content && (
{content instanceof Function ? content(this) : content}
)
);
}
private renderActions(actions: {}, section: CommonPanelContentSection) {
if (React.isValidElement(actions)) {
if (actions.type === CommonPanelActions) {
return React.cloneElement(actions, { section });
}
return actions;
}
if (actions instanceof Function) {
return actions(this);
}
return (
{Array.isArray(actions) ? (
actions.map((x, i) => )
) : (
)}
);
}
private renderHeaderFooter(
content: CommonPannelContent | undefined,
actions: any,
section: CommonPanelContentSection,
formatter: (section: any) => any = x => x,
) {
return this.wxr.renderConditional(content != null || actions != null, () =>
formatter(
{content && this.renderContent(content, section)}
{actions && this.renderActions(actions, section)}
,
),
);
}
}