![JAR search and dependency download from the Maven repository](/logo.png)
components.widgets.Tree.TreeNodes.BaseNode.BaseNode.jsx Maven / Gradle / Ivy
import React from 'react'
import PropTypes from 'prop-types'
import has from 'lodash/has'
// fns
import { Badge } from '../../../../snippets/Badge/Badge'
import { isBadgeRightPosition, resolveBadgeProps } from '../../../../snippets/Badge/utils'
import { splitSearchText } from '../../until'
import { Shape } from '../../../../snippets/Badge/enums'
function BaseNode({
prefixCls,
imageFieldId,
labelFieldId,
badge,
valueFieldId,
searchValue,
searchKeys,
data,
filter,
}) {
const {
fieldId: badgeFieldId,
position: badgePosition,
} = badge || {}
const labelStyle = {
order: isBadgeRightPosition(badgePosition) ? 0 : 1,
}
return (
{[
has(data, imageFieldId) && (
),
has(data, labelFieldId) && (
{searchKeys.includes(data[valueFieldId]) && searchValue
? splitSearchText(data[labelFieldId], searchValue, filter)
: data[labelFieldId]}
),
(badge && has(data, badgeFieldId)) && (
),
]}
)
}
BaseNode.propTypes = {
prefixCls: PropTypes.string,
imageFieldId: PropTypes.string,
labelFieldId: PropTypes.string,
badge: PropTypes.object,
valueFieldId: PropTypes.string,
searchValue: PropTypes.string,
searchKeys: PropTypes.string,
data: PropTypes.object,
filter: PropTypes.any,
}
export default BaseNode
© 2015 - 2025 Weber Informatics LLC | Privacy Policy