Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
!((() => {
let isTooDeep = false
const text = ensureSingleChild(this.props.children)
React.Children.forEach(text.props.children, (child) => {
if (child.props) {
React.Children.forEach(child.props.children, (grandChild) => {
// currently we don't support node trees deeper than 2 levels
// truncation will still occur on their text content, but their actual node structure will be lost
if (grandChild.props) {
isTooDeep = true
}
})
}
})
return isTooDeep
})()),
`[TruncateText] Some children are too deep in the node tree and will not render.`
renderContent () {
let content = ComponentIdentifier.pick(Position.Content, this.props.children)
if (!content) {
content = ensureSingleChild(this.props.children)
}
if (content) {
content = safeCloneElement(content, {
ref: el => { this._content = el },
style: {
...content.props.style,
...this.state.style
},
className: classnames({
[styles.root]: true,
[content.props.className]: content.props.className // eslint-disable-line react/prop-types
}),
[Position.contentLocatorAttribute]: this._id
})
renderChildren () {
return safeCloneElement(ensureSingleChild(this.props.children), {
'aria-hidden': !this.props.in ? true : null
})
}
render () {
const content = ensureSingleChild(this.props.children, {
ref: this.contentRef
})
const classes = classnames({
[styles.root]: true,
[styles[this.props.placement]]: true,
[styles.fullscreen]: this.props.fullscreen
})
const props = {
...omitProps(this.props, Mask.propTypes),
className: classes,
ref: this.handleElementRef
}
if (typeof this.props.onClick === 'function') {
)
} else if (typeof children === 'function') {
return children(
{
focused: hasFocus,
getTriggerProps: (props) => {
return {
...triggerProps,
...props
}
}
}
)
} else {
return ensureSingleChild(this.props.children, triggerProps)
}
}
const { maxLines, children } = this.props
return (
<span> {
this._ref = el
}}
>
{children && (
truncatedElement ? null : (
<span> {this._stage = el}}>
{ensureSingleChild(children)}
</span>
)
)}
{truncatedElement}
</span>
)
}
}
componentDidMount () {
const { children } = this.props
if (children) {
this.checkChildren()
this._text = ensureSingleChild(children)
this.truncate()
if (this.props.debounce === 0) {
this._resizeListener = addResizeListener(this._ref, this.update)
} else {
this._debounced = debounce(this.update, this.props.debounce, { leading: true, trailing: true })
this._resizeListener = addResizeListener(this._ref, this._debounced)
}
}
}
render () {
return ensureSingleChild(this.props.children)
}
}