@yuntijs/ui
Version:
☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps
86 lines • 3.75 kB
JavaScript
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
var _excluded = ["className", "icon", "title", "description", "extra", "divider"],
_excluded2 = ["className", "shape", "size"],
_excluded3 = ["children"];
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
import { Icon } from '@lobehub/ui';
import { Avatar, Button, Dropdown, Flex } from 'antd';
import { EllipsisVertical } from 'lucide-react';
import React from 'react';
import Typography from "../../Typography";
import { useStyles } from "./style";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var Paragraph = Typography.Paragraph;
export var ProCardHeader = function ProCardHeader(props) {
var className = props.className,
icon = props.icon,
title = props.title,
description = props.description,
extra = props.extra,
divider = props.divider,
otherProps = _objectWithoutProperties(props, _excluded);
var _useStyles = useStyles({
divider: divider,
iconBg: !(icon !== null && icon !== void 0 && icon.src)
}),
styles = _useStyles.styles,
cx = _useStyles.cx;
var _ref = icon || {},
iconClassName = _ref.className,
_ref$shape = _ref.shape,
shape = _ref$shape === void 0 ? 'square' : _ref$shape,
_ref$size = _ref.size,
size = _ref$size === void 0 ? 72 : _ref$size,
otherIconProps = _objectWithoutProperties(_ref, _excluded2);
var _ref2 = extra || {},
extraChildren = _ref2.children,
otherExtraProps = _objectWithoutProperties(_ref2, _excluded3);
return /*#__PURE__*/_jsxs(Flex, _objectSpread(_objectSpread({
className: cx(styles.root, className),
gap: 20
}, otherProps), {}, {
children: [icon && /*#__PURE__*/_jsx(Flex, {
children: /*#__PURE__*/_jsx(Avatar, _objectSpread({
className: cx(styles.icon, iconClassName),
shape: shape,
size: size
}, otherIconProps))
}), /*#__PURE__*/_jsxs(Flex, {
flex: "1",
vertical: true,
children: [/*#__PURE__*/_jsxs(Flex, {
className: styles.titleBox,
gap: 4,
children: [/*#__PURE__*/_jsx("div", {
className: styles.title,
children: title
}), extra && /*#__PURE__*/_jsx(Flex, {
align: "flex-start",
className: styles.extra,
justify: "flex-end",
onClick: function onClick(e) {
return e.stopPropagation();
},
children: /*#__PURE__*/_jsx(Dropdown, _objectSpread(_objectSpread({}, otherExtraProps), {}, {
children: extraChildren || /*#__PURE__*/_jsx(Button, {
icon: /*#__PURE__*/_jsx(Icon, {
icon: EllipsisVertical
}),
size: "small",
type: "text"
})
}))
})]
}), description && /*#__PURE__*/_jsx(Paragraph, {
className: styles.description,
ellipsis: {
rows: 2
},
children: description
})]
})]
}));
};