UNPKG

mui-component

Version:

some custom mui components

101 lines 5.33 kB
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); } var _excluded = ["icon", "title", "subTitle", "status", "actions", "sx", "content", "children", "spaceProps"]; 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 _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); } 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; } import { Stack } from "@mui/material"; import { CheckCircle as CheckCircleIcon, Report as ReportIcon, Dangerous as DangerousIcon, Warning as WarningIcon, Block as BlockIcon } from "@mui/icons-material"; import { Space } from "@iimm/react-shared"; import { ContentCard } from "../../container"; import { jsx as _jsx } from "react/jsx-runtime"; import { jsxs as _jsxs } from "react/jsx-runtime"; var iconMap = { success: /*#__PURE__*/_jsx(CheckCircleIcon, { color: "success", sx: { fontSize: 70 } }), error: /*#__PURE__*/_jsx(DangerousIcon, { color: "error", sx: { fontSize: 70 } }), info: /*#__PURE__*/_jsx(ReportIcon, { color: "info", sx: { fontSize: 70 } }), warning: /*#__PURE__*/_jsx(WarningIcon, { color: "warning", sx: { fontSize: 70 } }), 404: /*#__PURE__*/_jsx(BlockIcon, { color: "secondary", sx: { fontSize: 70 } }) }; export var Result = function Result(props) { var icon = props.icon, title = props.title, subTitle = props.subTitle, _props$status = props.status, status = _props$status === void 0 ? "info" : _props$status, actions = props.actions, sx = props.sx, content = props.content, children = props.children, spaceProps = props.spaceProps, restProps = _objectWithoutProperties(props, _excluded); return /*#__PURE__*/_jsx(ContentCard, _objectSpread(_objectSpread({ sx: _objectSpread({ justifyContent: "center" }, sx || {}) }, restProps), {}, { children: /*#__PURE__*/_jsxs(Stack, { direction: "column", justifyContent: "center", alignContent: "center", textAlign: "center", spacing: 1.5, children: [/*#__PURE__*/_jsx("div", { children: icon || iconMap[status] }), title ? /*#__PURE__*/_jsx("div", { style: { fontSize: "1.25rem", lineHeight: "1.5rem" }, children: title }) : status === "404" ? /*#__PURE__*/_jsx("div", { style: { fontSize: "1.25rem", lineHeight: "1.5rem" }, children: "\u4F60\u6CA1\u6709\u6743\u9650\u8FDB\u5165\u6B64\u6A21\u5757" }) : null, !!subTitle && /*#__PURE__*/_jsx("div", { style: { fontSize: "1rem", lineHeight: "1.25rem", color: "#00000073" }, children: subTitle }), (typeof content !== "undefined" || !!children) && /*#__PURE__*/_jsx("div", { children: content !== null && content !== void 0 ? content : children }), !!actions && /*#__PURE__*/_jsx(Space, _objectSpread(_objectSpread({ justify: "center" }, spaceProps || {}), {}, { children: actions }))] }) })); };