Skip to main content

@topgrid/grid-license

Pro license validation runtime · Commercial (EULA)

Auto-generated

This page is auto-generated from TSDoc comments in the source code (internal markers scrubbed). For a curated getting-started summary, see the API Reference.

10 public exports — 4 functions · 2 hooks · 1 components · 3 types · 0 constants.

Components

Watermark

The watermark component displayed over the grid when there is no Pro license.

Returns null (nothing rendered) if required=false.

Watermark(__namedParameters: WatermarkProps): null | ReactElement<any, string | JSXElementConstructor<any>>

Hooks

useLicenseStatus

React hook returning the current license check result. Re-renders when the license state changes (e.g. async setLicenseKey resolution).

Backed by useSyncExternalStore — no tearing under React 18 concurrent mode.

useLicenseStatus(): LicenseCheckResult

Example

function MyGrid() {
const lic = useLicenseStatus();
return (
<div className="relative">
<table>{ ... }</table>
{lic.watermarkRequired && <Watermark required />}
</div>
);
}

useWatermarkEnforcement

Void registration hook for license watermark enforcement via a singleton portal mounted at document.body.

  • Each mount increments a module-level ref-count.
  • First mount creates the singleton portal + React root.
  • License state changes (setLicenseKey) re-render the portal via subscribeLicense.
  • Last unmount (ref-count → 0) tears down the portal.

Use case: per-cell renderers (e.g. DataMapCell) where the component itself has no host DOM suitable for wrapper-based watermarking.

SSR-safe: portal setup is skipped when document is undefined.

useWatermarkEnforcement(): void

Example

export function DataMapCell(info) {
useWatermarkEnforcement(); // void — no return value
return <span>{...}</span>;
}

Functions

checkLicense

Synchronously checks the current license state and returns a LicenseCheckResult.

  • If valid=false, then watermarkRequired=true.
  • If valid and less than 60 days remain until expiresAt, then expiryWarning='soon-expiring' + console.warn (once).
  • If valid and there is ample margin before expiry, { valid: true, watermarkRequired: false }.
checkLicense(): LicenseCheckResult

setLicenseKey

The global license registration API for Pro packages. Call once from the app entry (main.tsx / App.tsx).

setLicenseKey(key: string): LicenseStatus
ParameterTypeDescription
keystringA license key in the format Base64url(pubKey).Base64url(sig).Base64url(payload)

Returns — LicenseStatus — returned immediately (a synchronous wrapper; the state is updated after internal async verification completes). Note: the return value is designed as a synchronous API so it can be used immediately without a Promise. Internally it stores the result of verifySignature (async). Calling getLicenseState before the async completion returns the default {valid:false, reason:'invalid'}.

setLicenseState

setLicenseState(s: LicenseState): void

subscribeLicense

Subscribe to license state changes. Listener is invoked synchronously after every setLicenseState call. Returns an unsubscribe function.

Used internally by useLicenseStatus (via useSyncExternalStore) and by useWatermarkEnforcement (singleton portal re-render trigger).

subscribeLicense(listener: LicenseListener): () =>

Types & Interfaces

LicenseCheckResult

The return type of checkLicense. watermarkRequired: true → the Pro grid watermark needs to be displayed. expiryWarning: 'soon-expiring' → expires within 60 days (console.warn is emitted).

PropertyTypeDescription
expiresAt?Date
expiryWarning?"soon-expiring"
reason?LicenseReason
validboolean
watermarkRequiredboolean

LicenseStatus

PropertyTypeDescription
domain?string
expiresAt?Date
reason?LicenseReason
validboolean

LicenseReason

type LicenseReason = "invalid" | "expired" | "domain-mismatch"