UNPKG

zent

Version:

一套前端设计语言和基于React的实现

28 lines (27 loc) 1.28 kB
import { __assign, __rest } from "tslib"; import { jsx as _jsx } from "react/jsx-runtime"; import { useMemo } from 'react'; import cx from 'classnames'; import { Icon } from '../icon'; import { Alert } from '../alert'; var promptTypePropsMap = { warning: { type: 'warning', }, strongHint: { type: 'warning', style: { background: '#f7f7f7' }, }, weakHint: { icon: _jsx(Icon, { type: "help-circle", style: { color: '#c5c5c5' } }, void 0), style: { background: '#f7f7f7' }, }, }; export var Prompt = function (_a) { var title = _a.title, _b = _a.style, style = _b === void 0 ? {} : _b, _c = _a.type, type = _c === void 0 ? 'warning' : _c, className = _a.className, _d = _a.closable, closable = _d === void 0 ? true : _d, resetProps = __rest(_a, ["title", "style", "type", "className", "closable"]); var alertProps = useMemo(function () { return promptTypePropsMap[type] || {}; }, [type]); var _e = alertProps.style, promptStyle = _e === void 0 ? {} : _e; var promptClassName = cx('zent-prompt', className); return (_jsx(Alert, __assign({ className: promptClassName }, alertProps, resetProps, { closable: closable, style: __assign(__assign({}, style), promptStyle) }), void 0)); }; export default Prompt;