@difizen/mana-react
Version:
114 lines • 6.49 kB
JavaScript
var _excluded = ["prefixCls", "className", "icon", "type", "message", "description", "btn", "closable", "closeIcon", "className"];
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
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; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
import CheckCircleFilled from '@ant-design/icons/CheckCircleFilled';
import CloseCircleFilled from '@ant-design/icons/CloseCircleFilled';
import CloseOutlined from '@ant-design/icons/CloseOutlined';
import ExclamationCircleFilled from '@ant-design/icons/ExclamationCircleFilled';
import InfoCircleFilled from '@ant-design/icons/InfoCircleFilled';
import LoadingOutlined from '@ant-design/icons/LoadingOutlined';
import classNames from 'classnames';
import { Notice } from 'rc-notification';
import * as React from 'react';
import { NOTIFICATION_PREFIX_CLS } from "./protocol";
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
export var TypeIcon = {
info: /*#__PURE__*/_jsx(InfoCircleFilled, {}),
success: /*#__PURE__*/_jsx(CheckCircleFilled, {}),
error: /*#__PURE__*/_jsx(CloseCircleFilled, {}),
warning: /*#__PURE__*/_jsx(ExclamationCircleFilled, {}),
loading: /*#__PURE__*/_jsx(LoadingOutlined, {})
};
export function getCloseIcon(prefixCls, closeIcon) {
if (closeIcon === null || closeIcon === false) {
return null;
}
return closeIcon || /*#__PURE__*/_jsx(CloseOutlined, {
className: "".concat(prefixCls, "-close-icon")
});
}
var typeToIcon = {
success: CheckCircleFilled,
info: InfoCircleFilled,
error: CloseCircleFilled,
warning: ExclamationCircleFilled
};
export var PureContent = function PureContent(props) {
var prefixCls = props.prefixCls,
icon = props.icon,
type = props.type,
message = props.message,
description = props.description,
btn = props.btn,
_props$role = props.role,
role = _props$role === void 0 ? 'alert' : _props$role;
var iconNode = null;
if (icon) {
iconNode = /*#__PURE__*/_jsx("span", {
className: "".concat(prefixCls, "-icon"),
children: icon
});
} else if (type) {
iconNode = /*#__PURE__*/React.createElement(typeToIcon[type] || null, {
className: classNames("".concat(prefixCls, "-icon"), "".concat(prefixCls, "-icon-").concat(type))
});
}
return /*#__PURE__*/_jsxs("div", {
className: classNames(_defineProperty({}, "".concat(prefixCls, "-with-icon"), iconNode)),
role: role,
children: [iconNode, /*#__PURE__*/_jsx("div", {
className: "".concat(prefixCls, "-message"),
children: message
}), /*#__PURE__*/_jsx("div", {
className: "".concat(prefixCls, "-description"),
children: description
}), btn && /*#__PURE__*/_jsx("div", {
className: "".concat(prefixCls, "-btn"),
children: btn
})]
});
};
/** @private Internal Component. Do not use in your production. */
var PurePanel = function PurePanel(props) {
var _props$prefixCls = props.prefixCls,
prefixCls = _props$prefixCls === void 0 ? NOTIFICATION_PREFIX_CLS : _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,
notificationClassName = props.className,
restProps = _objectWithoutProperties(props, _excluded);
return /*#__PURE__*/_jsx("div", {
className: classNames("".concat(prefixCls, "-pure-panel"), className),
children: /*#__PURE__*/_jsx(Notice, _objectSpread(_objectSpread({}, restProps), {}, {
prefixCls: prefixCls,
eventKey: "pure",
duration: null,
closable: closable,
className: classNames({
notificationClassName: notificationClassName
}),
closeIcon: getCloseIcon(NOTIFICATION_PREFIX_CLS, closeIcon),
content: /*#__PURE__*/_jsx(PureContent, {
prefixCls: prefixCls,
icon: icon,
type: type,
message: message,
description: description,
btn: btn
})
}))
});
};
export default PurePanel;