UNPKG

@mui/x-license

Version:
59 lines 2.23 kB
import _formatErrorMessage from "@mui/x-internals/formatErrorMessage"; import { fastMemo } from '@mui/x-internals/fastMemo'; import { useLicenseVerifier } from "../useLicenseVerifier/index.mjs"; import { LICENSE_STATUS } from "../utils/licenseStatus.mjs"; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; function getLicenseErrorMessage(licenseStatus) { switch (licenseStatus) { case LICENSE_STATUS.ExpiredAnnualGrace: case LICENSE_STATUS.ExpiredAnnual: return 'MUI X Expired license key'; case LICENSE_STATUS.ExpiredVersion: return 'MUI X Expired package version'; case LICENSE_STATUS.Invalid: return 'MUI X Invalid license key'; case LICENSE_STATUS.OutOfScope: return 'MUI X License key plan mismatch'; case LICENSE_STATUS.NotAvailableInInitialProPlan: return 'MUI X Product not covered by plan'; case LICENSE_STATUS.NotFound: return 'MUI X Missing license key'; case 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.' : _formatErrorMessage(183)); } } function Watermark(props) { const { packageInfo } = props; const licenseStatus = useLicenseVerifier(packageInfo); if (licenseStatus.status === LICENSE_STATUS.Valid) { return null; } return /*#__PURE__*/_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__*/_jsx("div", { style: { fontSize: 12, letterSpacing: 1, marginTop: 8 }, children: "Open the browser console for details on how to resolve this." })] }); } const MemoizedWatermark = fastMemo(Watermark); export { MemoizedWatermark as Watermark };