@chatui/core
Version:
The React library for Chatbot UI
44 lines • 1.83 kB
JavaScript
import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["className", "title", "level", "highlight", "desc", "onClick", "ellipsis", "rightIcon", "children"];
import React from 'react';
import clsx from 'clsx';
import { Icon } from '../Icon';
import { Text } from '../Text';
import { Flex, FlexItem } from '../Flex';
export var KvItem = function KvItem(props) {
var className = props.className,
title = props.title,
level = props.level,
highlight = props.highlight,
desc = props.desc,
onClick = props.onClick,
_props$ellipsis = props.ellipsis,
ellipsis = _props$ellipsis === void 0 ? !!onClick : _props$ellipsis,
_props$rightIcon = props.rightIcon,
rightIcon = _props$rightIcon === void 0 ? onClick ? 'chevron-right' : undefined : _props$rightIcon,
children = props.children,
other = _objectWithoutProperties(props, _excluded);
var isString = typeof children === 'string';
return /*#__PURE__*/React.createElement("div", _extends({
className: clsx('KvItem', className),
"data-level": level,
"data-highlight": highlight,
onClick: onClick,
role: "item"
}, other), /*#__PURE__*/React.createElement(Flex, {
className: "KvItem-content",
alignItems: ellipsis ? 'center' : undefined
}, /*#__PURE__*/React.createElement(Text, {
className: "KvItem-title",
truncate: true
}, title), /*#__PURE__*/React.createElement(FlexItem, {
className: "KvItem-main"
}, isString ? /*#__PURE__*/React.createElement(Text, {
truncate: ellipsis
}, children) : children), rightIcon && /*#__PURE__*/React.createElement(Icon, {
type: rightIcon
})), desc && /*#__PURE__*/React.createElement("div", {
className: "KvItem-desc"
}, desc));
};