reactive-dialogs
Version:
Renders interactive dialog based JSX components to Reactive Card JSON on the server and in the browser.
22 lines (16 loc) • 541 B
text/typescript
/* eslint-disable prefer-destructuring */
function cloneElement(element, props, ...children) {
props = { ...element.props, ...(props || {}) }
props.children = (children.length === 0 && props.children
? props.children
: children
).filter(Boolean)
if (props.children.length === 0) {
props.children = element.props.children || []
}
if (props.children.length === 1 && Array.isArray(props.children[0])) {
props.children = props.children[0]
}
return { type: element.type, props }
}
export default cloneElement