@onesy/ui-react
Version:
UI for React
84 lines (83 loc) • 5.22 kB
JavaScript
"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _react = _interopRequireDefault(require("react"));
var _reactRouterDom = require("react-router-dom");
var _utils = require("@onesy/utils");
var _styleReact = require("@onesy/style-react");
var _Section = _interopRequireDefault(require("../Section"));
var _Type = _interopRequireDefault(require("../Type"));
var _Button = _interopRequireDefault(require("../Button"));
var _utils2 = require("../utils");
var _jsxRuntime = require("react/jsx-runtime");
const _excluded = ["name", "to", "link", "renderButton", "fullHeight", "start", "end", "buttonText", "ButtonProps", "TypeProps", "className"];
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) { (0, _defineProperty2.default)(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; }
const useStyle = (0, _styleReact.style)(theme => ({
root: {},
fullHeight: {
height: '100vh'
}
}), {
name: 'onesy-NotFound'
});
const NotFound = props_ => {
var _theme$ui, _theme$ui2, _theme$elements, _theme$elements2, _theme$elements3;
const theme = (0, _styleReact.useOnesyTheme)();
const l = theme.l;
const props = _objectSpread(_objectSpread(_objectSpread({}, theme === null || theme === void 0 || (_theme$ui = theme.ui) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.elements) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.all) === null || _theme$ui === void 0 || (_theme$ui = _theme$ui.props) === null || _theme$ui === void 0 ? void 0 : _theme$ui.default), theme === null || theme === void 0 || (_theme$ui2 = theme.ui) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.elements) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.onesyNotFound) === null || _theme$ui2 === void 0 || (_theme$ui2 = _theme$ui2.props) === null || _theme$ui2 === void 0 ? void 0 : _theme$ui2.default), props_);
const Section = (theme === null || theme === void 0 || (_theme$elements = theme.elements) === null || _theme$elements === void 0 ? void 0 : _theme$elements.Section) || _Section.default;
const Type = (theme === null || theme === void 0 || (_theme$elements2 = theme.elements) === null || _theme$elements2 === void 0 ? void 0 : _theme$elements2.Type) || _Type.default;
const Button = (theme === null || theme === void 0 || (_theme$elements3 = theme.elements) === null || _theme$elements3 === void 0 ? void 0 : _theme$elements3.Button) || _Button.default;
const {
name = l('Page not found'),
to = '/',
link = '',
renderButton,
fullHeight,
start,
end,
buttonText = l('Back'),
ButtonProps,
TypeProps,
className
} = props,
other = (0, _objectWithoutProperties2.default)(props, _excluded);
const {
classes
} = useStyle();
const navigate = (0, _utils.isEnvironment)('browser') && (0, _reactRouterDom.useNavigate)();
const onTo = () => {
if (link) window.open(link, 'blank');else navigate(to);
};
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(Section, _objectSpread(_objectSpread({
flex: true,
fullWidth: true,
align: "center",
justify: "center",
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('NotFound', theme) && [`onesy-NotFound-root`], className, classes.root, fullHeight && classes.fullHeight])
}, other), {}, {
children: [start, /*#__PURE__*/(0, _jsxRuntime.jsx)(Type, _objectSpread(_objectSpread({
version: "h3",
align: "center"
}, TypeProps), {}, {
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('NotFound', theme) && [`onesy-NotFound-type`], TypeProps === null || TypeProps === void 0 ? void 0 : TypeProps.className]),
children: name
})), (0, _utils.is)('function', renderButton) ? renderButton({}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(Button, _objectSpread(_objectSpread({
color: "default",
version: "outlined",
size: "small",
onClick: onTo
}, ButtonProps), {}, {
className: (0, _styleReact.classNames)([(0, _utils2.staticClassName)('NotFound', theme) && [`onesy-NotFound-button`], ButtonProps === null || ButtonProps === void 0 ? void 0 : ButtonProps.className, classes.button]),
children: buttonText
})), end]
}));
};
NotFound.displayName = 'onesy-NotFound';
var _default = exports.default = NotFound;