drip-table
Version:
A tiny and powerful enterprise-class solution for building tables.
113 lines (97 loc) • 5.03 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
require("./index.less");
var _classnames = _interopRequireDefault(require("classnames"));
var _react = _interopRequireDefault(require("react"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
var prefixCls = 'jfe-drip-table-rc-alert';
var Alert = /*#__PURE__*/_react.default.memo(function (props) {
var _classNames;
var icon = _react.default.useMemo(function () {
if (props.icon) {
return props.icon;
}
if (props.type === 'info' || !props.type) {
return /*#__PURE__*/_react.default.createElement("span", {
role: "img",
className: "".concat(prefixCls, "-icon"),
"aria-label": "info-circle"
}, /*#__PURE__*/_react.default.createElement("svg", {
viewBox: "64 64 896 896",
focusable: "false",
"data-icon": "info-circle",
width: "1em",
height: "1em",
fill: "currentColor",
"aria-hidden": "true"
}, /*#__PURE__*/_react.default.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.default.createElement("span", {
role: "img",
className: "".concat(prefixCls, "-icon"),
"aria-label": "check-circle"
}, /*#__PURE__*/_react.default.createElement("svg", {
viewBox: "64 64 896 896",
focusable: "false",
"data-icon": "check-circle",
width: "1em",
height: "1em",
fill: "currentColor",
"aria-hidden": "true"
}, /*#__PURE__*/_react.default.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.default.createElement("span", {
role: "img",
className: "".concat(prefixCls, "-icon"),
"aria-label": "exclamation-circle"
}, /*#__PURE__*/_react.default.createElement("svg", {
viewBox: "64 64 896 896",
focusable: "false",
"data-icon": "exclamation-circle",
width: "1em",
height: "1em",
fill: "currentColor",
"aria-hidden": "true"
}, /*#__PURE__*/_react.default.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.default.createElement("span", {
role: "img",
className: "".concat(prefixCls, "-icon"),
"aria-label": "close-circle"
}, /*#__PURE__*/_react.default.createElement("svg", {
viewBox: "64 64 896 896",
focusable: "false",
"data-icon": "close-circle",
width: "1em",
height: "1em",
fill: "currentColor",
"aria-hidden": "true"
}, /*#__PURE__*/_react.default.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.default.createElement("div", {
className: (0, _classnames.default)(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.default.createElement("div", {
className: "".concat(prefixCls, "-content")
}, /*#__PURE__*/_react.default.createElement("div", {
className: "".concat(prefixCls, "-message")
}, props.message)));
});
var _default = Alert;
exports.default = _default;