UNPKG

acud

Version:

acg react 组件库

108 lines • 4.53 kB
import _extends from "@babel/runtime/helpers/esm/extends"; import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; var __rest = this && this.__rest || function (s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; }; import * as React from 'react'; // import LoadingOutlined from '@ant-design/icons/LoadingOutlined'; // import ExclamationCircleFilled from '@ant-design/icons/ExclamationCircleFilled'; // import CloseCircleFilled from '@ant-design/icons/CloseCircleFilled'; // import CheckCircleFilled from '@ant-design/icons/CheckCircleFilled'; // import InfoCircleFilled from '@ant-design/icons/InfoCircleFilled'; // import CloseOutlined from '@ant-design/icons/CloseOutlined'; import FilledSuccess from "acud-icon/es/icons/FilledSuccess"; import FilledWarn from "acud-icon/es/icons/FilledWarn"; import FilledInfo from "acud-icon/es/icons/FilledInfo"; import FilledError from "acud-icon/es/icons/FilledError"; import CloseOutlined from "acud-icon/es/icons/OutlinedClose"; import { Notice } from 'rc-notification'; import classNames from 'classnames'; import { ConfigContext } from '../config-provider'; // export const TypeIcon = { // info: <InfoCircleFilled />, // success: <CheckCircleFilled />, // error: <CloseCircleFilled />, // warning: <ExclamationCircleFilled />, // loading: <LoadingOutlined />, // }; export function getCloseIcon(prefixCls, closeIcon) { return closeIcon || /*#__PURE__*/React.createElement("span", { className: "".concat(prefixCls, "-close-x") }, /*#__PURE__*/React.createElement(CloseOutlined, { className: "".concat(prefixCls, "-close-icon") })); } var typeToIcon = { success: FilledSuccess, info: FilledInfo, error: FilledError, warning: FilledWarn }; export function PureContent(_ref) { var prefixCls = _ref.prefixCls, icon = _ref.icon, type = _ref.type, message = _ref.message, description = _ref.description, btn = _ref.btn; var iconNode = null; if (icon) { iconNode = /*#__PURE__*/React.createElement("span", { className: "".concat(prefixCls, "-icon") }, icon); } else if (type) { iconNode = /*#__PURE__*/React.createElement(typeToIcon[type] || null, { className: classNames("".concat(prefixCls, "-icon"), "".concat(prefixCls, "-icon-").concat(type)) }); } return /*#__PURE__*/React.createElement("div", { className: classNames(_defineProperty({}, "".concat(prefixCls, "-with-icon"), iconNode)), role: "alert" }, iconNode, /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-message") }, message), /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-description") }, description), btn && /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-btn") }, btn)); } /** @private Internal Component. Do not use in your production. */ export default function PurePanel(props) { var staticPrefixCls = props.prefixCls, className = props.className, icon = props.icon, type = props.type, message = props.message, description = props.description, btn = props.btn, _props$closable = props.closable, closable = _props$closable === void 0 ? true : _props$closable, closeIcon = props.closeIcon, restProps = __rest(props, ["prefixCls", "className", "icon", "type", "message", "description", "btn", "closable", "closeIcon"]); var _React$useContext = React.useContext(ConfigContext), getPrefixCls = _React$useContext.getPrefixCls; var prefixCls = staticPrefixCls || getPrefixCls('notification'); var noticePrefixCls = "".concat(prefixCls, "-notice"); // const [, hashId] = useStyle(prefixCls); return /*#__PURE__*/React.createElement(Notice, _extends({}, restProps, { prefixCls: prefixCls, className: classNames(className, "".concat(noticePrefixCls, "-pure-panel")), eventKey: "pure", duration: null, closable: closable, closeIcon: getCloseIcon(prefixCls, closeIcon), content: /*#__PURE__*/React.createElement(PureContent, { prefixCls: noticePrefixCls, icon: icon, type: type, message: message, description: description, btn: btn }) })); }