UNPKG

drip-table

Version:

A tiny and powerful enterprise-class solution for building tables.

104 lines (97 loc) 4.82 kB
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } /* * This file is part of the drip-table project. * @link : https://drip-table.jd.com/ * @author : Emil Zhai (root@derzh.com) * @modifier : Emil Zhai (root@derzh.com) * @copyright: Copyright (c) 2021 JD Network Technology Co., Ltd. */ import "./index.less"; import classNames from 'classnames'; import React from 'react'; var prefixCls = 'jfe-drip-table-rc-alert'; var Alert = /*#__PURE__*/React.memo(function (props) { var _classNames; var icon = React.useMemo(function () { if (props.icon) { return props.icon; } if (props.type === 'info' || !props.type) { return /*#__PURE__*/React.createElement("span", { role: "img", className: "".concat(prefixCls, "-icon"), "aria-label": "info-circle" }, /*#__PURE__*/React.createElement("svg", { viewBox: "64 64 896 896", focusable: "false", "data-icon": "info-circle", width: "1em", height: "1em", fill: "currentColor", "aria-hidden": "true" }, /*#__PURE__*/React.createElement("path", { d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 010-96 48.01 48.01 0 010 96z" }))); } if (props.type === 'success') { return /*#__PURE__*/React.createElement("span", { role: "img", className: "".concat(prefixCls, "-icon"), "aria-label": "check-circle" }, /*#__PURE__*/React.createElement("svg", { viewBox: "64 64 896 896", focusable: "false", "data-icon": "check-circle", width: "1em", height: "1em", fill: "currentColor", "aria-hidden": "true" }, /*#__PURE__*/React.createElement("path", { d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm193.5 301.7l-210.6 292a31.8 31.8 0 01-51.7 0L318.5 484.9c-3.8-5.3 0-12.7 6.5-12.7h46.9c10.2 0 19.9 4.9 25.9 13.3l71.2 98.8 157.2-218c6-8.3 15.6-13.3 25.9-13.3H699c6.5 0 10.3 7.4 6.5 12.7z" }))); } if (props.type === 'warning') { return /*#__PURE__*/React.createElement("span", { role: "img", className: "".concat(prefixCls, "-icon"), "aria-label": "exclamation-circle" }, /*#__PURE__*/React.createElement("svg", { viewBox: "64 64 896 896", focusable: "false", "data-icon": "exclamation-circle", width: "1em", height: "1em", fill: "currentColor", "aria-hidden": "true" }, /*#__PURE__*/React.createElement("path", { d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm-32 232c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V296zm32 440a48.01 48.01 0 010-96 48.01 48.01 0 010 96z" }))); } if (props.type === 'error') { return /*#__PURE__*/React.createElement("span", { role: "img", className: "".concat(prefixCls, "-icon"), "aria-label": "close-circle" }, /*#__PURE__*/React.createElement("svg", { viewBox: "64 64 896 896", focusable: "false", "data-icon": "close-circle", width: "1em", height: "1em", fill: "currentColor", "aria-hidden": "true" }, /*#__PURE__*/React.createElement("path", { d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm165.4 618.2l-66-.3L512 563.4l-99.3 118.4-66.1.3c-4.4 0-8-3.5-8-8 0-1.9.7-3.7 1.9-5.2l130.1-155L340.5 359a8.32 8.32 0 01-1.9-5.2c0-4.4 3.6-8 8-8l66.1.3L512 464.6l99.3-118.4 66-.3c4.4 0 8 3.5 8 8 0 1.9-.7 3.7-1.9 5.2L553.5 514l130 155c1.2 1.5 1.9 3.3 1.9 5.2 0 4.4-3.6 8-8 8z" }))); } return null; }, [props.type, props.icon]); return /*#__PURE__*/React.createElement("div", { className: classNames(prefixCls, (_classNames = {}, _defineProperty(_classNames, "".concat(prefixCls, "-info"), !props.type || props.type === 'info'), _defineProperty(_classNames, "".concat(prefixCls, "-success"), props.type === 'success'), _defineProperty(_classNames, "".concat(prefixCls, "-warning"), props.type === 'warning'), _defineProperty(_classNames, "".concat(prefixCls, "-error"), props.type === 'error'), _classNames)) }, props.showIcon && icon, /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-content") }, /*#__PURE__*/React.createElement("div", { className: "".concat(prefixCls, "-message") }, props.message))); }); export default Alert;