@i-novus/ui-core
Version:
Базовые UI компоненты
26 lines (25 loc) • 1.12 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { Children, cloneElement, forwardRef } from 'react';
import classNames from 'classnames';
import { useConfigProvider } from '../../core';
export const Breadcrumbs = forwardRef((props, ref) => {
const { prefix, className, style, visible = true, children } = props;
const { getPrefix } = useConfigProvider();
const prefixCls = getPrefix(prefix);
if (!visible) {
return null;
}
return (_jsx("div", { ref: ref, className: classNames(className, `${prefixCls}-breadcrumbs`), style: style, children: Children.map(children, (child, i) => {
const crumb = child;
if (crumb && typeof crumb === 'object' && Object.hasOwn(crumb, 'props')) {
const { disabled, ...otherProps } = crumb.props;
const isLast = i === Children.count(children) - 1;
return cloneElement(crumb, {
...otherProps,
disabled: disabled || isLast,
});
}
return null;
}) }));
});
Breadcrumbs.displayName = 'Breadcrumbs';