UNPKG

@yuntijs/ui

Version:

☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps

59 lines 2.93 kB
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _excluded = ["className", "children"]; 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; } import { Button, Flex, Result, Skeleton } from 'antd'; import React, { useCallback, useContext } from 'react'; import { PageContext } from "../PageContext"; import { useStyles } from "./style"; import { jsx as _jsx } from "react/jsx-runtime"; var STATUS_TITLE_MAP = { '403': 'Sorry, you are not authorized to access this page.', '404': 'Sorry, the page you visited does not exist.', '500': 'Sorry, something went wrong.' }; export var PageContent = function PageContent(props) { var className = props.className, children = props.children, otherProps = _objectWithoutProperties(props, _excluded); var _useStyles = useStyles(), styles = _useStyles.styles, cx = _useStyles.cx; var _useContext = useContext(PageContext), loading = _useContext.loading, breadcrumb = _useContext.breadcrumb, Link = _useContext.Link, status = _useContext.status; var renderChildren = useCallback(function () { if (status) { var _breadcrumb$items; return /*#__PURE__*/_jsx(Result, { extra: /*#__PURE__*/_jsx(Link, { to: breadcrumb === null || breadcrumb === void 0 || (_breadcrumb$items = breadcrumb.items) === null || _breadcrumb$items === void 0 || (_breadcrumb$items = _breadcrumb$items[0]) === null || _breadcrumb$items === void 0 ? void 0 : _breadcrumb$items.path, children: /*#__PURE__*/_jsx(Button, { type: "primary", children: "Go Back" }) }), status: status, subTitle: STATUS_TITLE_MAP[status], title: status }); } return children; }, [status, children, Link, breadcrumb === null || breadcrumb === void 0 ? void 0 : breadcrumb.items]); if (loading) { return /*#__PURE__*/_jsx(Skeleton, { active: true, className: cx(styles.root, className) }); } return /*#__PURE__*/_jsx(Flex, _objectSpread(_objectSpread({ className: cx(styles.root, className), gap: 20, vertical: true }, otherProps), {}, { children: renderChildren() })); };