UNPKG

@mui/x-license

Version:
65 lines (64 loc) 2.63 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default; Object.defineProperty(exports, "__esModule", { value: true }); exports.Watermark = void 0; var _formatErrorMessage2 = _interopRequireDefault(require("@mui/x-internals/formatErrorMessage")); var _fastMemo = require("@mui/x-internals/fastMemo"); var _useLicenseVerifier = require("../useLicenseVerifier"); var _licenseStatus = require("../utils/licenseStatus"); var _jsxRuntime = require("react/jsx-runtime"); function getLicenseErrorMessage(licenseStatus) { switch (licenseStatus) { case _licenseStatus.LICENSE_STATUS.ExpiredAnnualGrace: case _licenseStatus.LICENSE_STATUS.ExpiredAnnual: return 'MUI X Expired license key'; case _licenseStatus.LICENSE_STATUS.ExpiredVersion: return 'MUI X Expired package version'; case _licenseStatus.LICENSE_STATUS.Invalid: return 'MUI X Invalid license key'; case _licenseStatus.LICENSE_STATUS.OutOfScope: return 'MUI X License key plan mismatch'; case _licenseStatus.LICENSE_STATUS.NotAvailableInInitialProPlan: return 'MUI X Product not covered by plan'; case _licenseStatus.LICENSE_STATUS.NotFound: return 'MUI X Missing license key'; case _licenseStatus.LICENSE_STATUS.NotValidForPackage: return 'MUI X License key version mismatch'; default: throw new Error(process.env.NODE_ENV !== "production" ? 'MUI X: Unhandled license status encountered in watermark display. ' + 'This is an internal error indicating an unknown license status. ' + 'Please report this issue if you encounter it.' : (0, _formatErrorMessage2.default)(183)); } } function Watermark(props) { const { packageInfo } = props; const licenseStatus = (0, _useLicenseVerifier.useLicenseVerifier)(packageInfo); if (licenseStatus.status === _licenseStatus.LICENSE_STATUS.Valid) { return null; } return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", { style: { position: 'absolute', pointerEvents: 'none', color: '#8282829e', zIndex: 100000, width: '100%', textAlign: 'center', bottom: '50%', right: 0, letterSpacing: 5, fontSize: 24 }, children: [getLicenseErrorMessage(licenseStatus.status), process.env.NODE_ENV !== 'production' && /*#__PURE__*/(0, _jsxRuntime.jsx)("div", { style: { fontSize: 12, letterSpacing: 1, marginTop: 8 }, children: "Open the browser console for details on how to resolve this." })] }); } const MemoizedWatermark = exports.Watermark = (0, _fastMemo.fastMemo)(Watermark);