mui-component
Version:
some custom mui components
69 lines • 4.91 kB
JavaScript
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 = ["border", "boxShadow", "children", "content", "contentClass", "contentSx", "darkTitle", "secondary", "shadow", "sx", "title", "headerSx", "divider"];
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 { forwardRef } from 'react';
import { useTheme } from '@mui/material/styles';
import { Card, CardContent, CardHeader, Divider, Typography } from '@mui/material';
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
export var PageContainer = /*#__PURE__*/forwardRef(function (_ref, ref) {
var _ref$border = _ref.border,
border = _ref$border === void 0 ? true : _ref$border,
boxShadow = _ref.boxShadow,
children = _ref.children,
_ref$content = _ref.content,
content = _ref$content === void 0 ? true : _ref$content,
_ref$contentClass = _ref.contentClass,
contentClass = _ref$contentClass === void 0 ? '' : _ref$contentClass,
_ref$contentSx = _ref.contentSx,
contentSx = _ref$contentSx === void 0 ? {} : _ref$contentSx,
darkTitle = _ref.darkTitle,
secondary = _ref.secondary,
shadow = _ref.shadow,
_ref$sx = _ref.sx,
sx = _ref$sx === void 0 ? {} : _ref$sx,
title = _ref.title,
headerSxProps = _ref.headerSx,
_ref$divider = _ref.divider,
divider = _ref$divider === void 0 ? true : _ref$divider,
otherProps = _objectWithoutProperties(_ref, _excluded);
var theme = useTheme();
var headerSx = _objectSpread({
'& .MuiCardHeader-action': {
mr: 0
},
py: 2
}, headerSxProps || {});
var showHeader = Boolean(title || secondary);
return /*#__PURE__*/_jsxs(Card, _objectSpread(_objectSpread({
ref: ref
}, otherProps), {}, {
sx: _objectSpread({
border: border ? '1px solid' : 'none',
// @ts-ignore
borderColor: theme.palette.primary[200] + 75,
':hover': {
boxShadow: boxShadow ? shadow || '0 2px 14px 0 rgb(32 40 45 / 8%)' : 'inherit'
}
}, sx || {}),
children: [showHeader && /*#__PURE__*/_jsx(CardHeader, {
sx: headerSx,
title: darkTitle ? /*#__PURE__*/_jsx(Typography, {
variant: "h3",
children: title
}) : title,
action: secondary
}), divider && showHeader && /*#__PURE__*/_jsx(Divider, {}), content && /*#__PURE__*/_jsx(CardContent, {
sx: contentSx,
className: contentClass,
children: children
}), !content && children]
}));
});
PageContainer.displayName = 'iimm.Mui.PageContainer';