@monetizekit/react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/dist/index.cjs +571 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +234 -0
- package/dist/index.d.ts +234 -0
- package/dist/index.js +552 -0
- package/dist/index.js.map +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/lib/client.ts","../src/theme/tokens.ts","../src/provider.tsx","../src/hooks.ts","../src/lib/format.ts","../src/components/PricingTable.tsx","../src/components/Paywall.tsx","../src/components/UsageBanner.tsx","../src/components/CustomerPortal.tsx","../src/components/EntitlementGate.tsx"],"names":["createContext","useMemo","jsx","useContext","useState","useEffect","jsxs","Fragment"],"mappings":";;;;;;;;AAUO,IAAM,oBAAN,MAAwB;AAAA,EAC7B,YAA6B,MAAA,EAAiC;AAAjC,IAAA,IAAA,CAAA,MAAA,GAAA,MAAA;AAAA,EAAkC;AAAA,EAE/D,MAAc,IAAO,IAAA,EAA0B;AAC7C,IAAA,MAAM,OAAA,GAAkC;AAAA,MACtC,aAAA,EAAe,CAAA,OAAA,EAAU,IAAA,CAAK,MAAA,CAAO,cAAc,CAAA;AAAA,KACrD;AACA,IAAA,IAAI,IAAA,CAAK,OAAO,aAAA,EAAe;AAC7B,MAAA,OAAA,CAAQ,kBAAkB,CAAA,GAAI,IAAA,CAAK,MAAA,CAAO,aAAA;AAAA,IAC5C;AACA,IAAA,MAAM,GAAA,GAAM,MAAM,KAAA,CAAM,CAAA,EAAG,IAAA,CAAK,MAAA,CAAO,OAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,EAAE,OAAA,EAAS,CAAA;AACpE,IAAA,IAAI,CAAC,IAAI,EAAA,EAAI;AACX,MAAA,MAAM,IAAI,KAAA,CAAM,CAAA,gBAAA,EAAmB,IAAI,MAAM,CAAA,KAAA,EAAQ,IAAI,CAAA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kB;AACpB,CAAA,EAAyB;AACvB,EAAA,MAAM,EAAE,OAAA,EAAS,OAAA,EAAQ,GAAI,eAAe,OAAO,CAAA;AACnD,EAAA,IAAI,SAAS,uBAAOA,cAAAA,CAAAK,mBAAAA,EAAA,EAAG,QAAA,EAAA,eAAA,EAAgB,CAAA;AACvC,EAAA,uBAAOL,cAAAA,CAAAK,mBAAAA,EAAA,EAAG,QAAA,EAAA,OAAA,GAAU,WAAW,QAAA,EAAS,CAAA;AAC1C","file":"index.cjs","sourcesContent":["/**\n * Minimal fetch client for the MonetizeKit public API. Uses a publishable key\n * (pk_*) as a Bearer token; safe for browser use against allowlisted origins.\n */\nexport interface MonetizeKitClientConfig {\n publishableKey: string;\n baseUrl: string;\n customerToken?: string;\n}\n\nexport class MonetizeKitClient {\n constructor(private readonly config: MonetizeKitClientConfig) {}\n\n private async get<T>(path: string): Promise<T> {\n const headers: Record<string, string> = {\n Authorization: `Bearer ${this.config.publishableKey}`,\n };\n if (this.config.customerToken) {\n headers[\"X-Customer-Token\"] = this.config.customerToken;\n }\n const res = await fetch(`${this.config.baseUrl}${path}`, { headers });\n if (!res.ok) {\n throw new Error(`MonetizeKit API ${res.status} for ${path}`);\n }\n return (await res.json()) as T;\n }\n\n listPlans<T>(): Promise<T> {\n return this.get<T>(\"/api/v1/plans?page=1&pageSize=100\");\n }\n\n getEntitlement<T>(customerId: string, featureKey: string): Promise<T> {\n return this.get<T>(`/api/v1/entitlements/${customerId}/${encodeURIComponent(featureKey)}`);\n }\n\n getUsage<T>(customerId: string, meterId: string): Promise<T> {\n return this.get<T>(`/api/v1/usage/${customerId}/${encodeURIComponent(meterId)}`);\n }\n\n getCredits<T>(customerId: string): Promise<T> {\n return this.get<T>(`/api/v1/credits/${customerId}`);\n }\n}\n","/**\n * Appearance/theme token contract for MonetizeKit components. Components consume\n * CSS custom properties derived from these tokens, so a host app can pass a\n * preset name, a partial token override, or both.\n *\n * Presets:\n * - `memphis` — the marketing site identity (coral/yellow/cyan, sharp corners)\n * - `dashboard` — the app's neutral palette (rounded, muted)\n * - `light` / `dark` — neutral defaults\n */\nimport type { CSSProperties } from \"react\";\n\nexport interface ThemeTokens {\n colorBackground: string;\n colorForeground: string;\n colorMuted: string;\n colorPrimary: string;\n colorPrimaryForeground: string;\n colorAccent: string;\n colorBorder: string;\n radius: string;\n fontFamily: string;\n}\n\nexport type ThemePresetName = \"light\" | \"dark\" | \"memphis\" | \"dashboard\";\n\nexport const THEME_PRESETS: Record<ThemePresetName, ThemeTokens> = {\n light: {\n colorBackground: \"#ffffff\",\n colorForeground: \"#0a0a0a\",\n colorMuted: \"#71717a\",\n colorPrimary: \"#4f46e5\",\n colorPrimaryForeground: \"#ffffff\",\n colorAccent: \"#10b981\",\n colorBorder: \"#e4e4e7\",\n radius: \"0.5rem\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n dark: {\n colorBackground: \"#0a0a0a\",\n colorForeground: \"#fafafa\",\n colorMuted: \"#a1a1aa\",\n colorPrimary: \"#6366f1\",\n colorPrimaryForeground: \"#0a0a0a\",\n colorAccent: \"#10b981\",\n colorBorder: \"#27272a\",\n radius: \"0.5rem\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n memphis: {\n colorBackground: \"#FFFEF2\",\n colorForeground: \"#1a1a1a\",\n colorMuted: \"#5b5b52\",\n colorPrimary: \"#FF6B35\",\n colorPrimaryForeground: \"#1a1a1a\",\n colorAccent: \"#00D9FF\",\n colorBorder: \"#1a1a1a\",\n radius: \"0\",\n fontFamily: \"system-ui, -apple-system, sans-serif\",\n },\n dashboard: {\n colorBackground: \"oklch(1 0 0)\",\n colorForeground: \"oklch(0.145 0 0)\",\n colorMuted: \"oklch(0.556 0 0)\",\n colorPrimary: \"oklch(0.205 0 0)\",\n colorPrimaryForeground: \"oklch(0.985 0 0)\",\n colorAccent: \"oklch(0.97 0 0)\",\n colorBorder: \"oklch(0.922 0 0)\",\n radius: \"0.625rem\",\n fontFamily: \"Geist, system-ui, sans-serif\",\n },\n};\n\nexport type Appearance =\n | ThemePresetName\n | { preset?: ThemePresetName; tokens?: Partial<ThemeTokens> };\n\n/** Resolve an appearance prop into a concrete token set. */\nexport function resolveTokens(appearance: Appearance = \"light\"): ThemeTokens {\n if (typeof appearance === \"string\") {\n return THEME_PRESETS[appearance];\n }\n const base = THEME_PRESETS[appearance.preset ?? \"light\"];\n return { ...base, ...appearance.tokens };\n}\n\nconst TOKEN_TO_CSS_VAR: Record<keyof ThemeTokens, string> = {\n colorBackground: \"--mk-bg\",\n colorForeground: \"--mk-fg\",\n colorMuted: \"--mk-muted\",\n colorPrimary: \"--mk-primary\",\n colorPrimaryForeground: \"--mk-primary-fg\",\n colorAccent: \"--mk-accent\",\n colorBorder: \"--mk-border\",\n radius: \"--mk-radius\",\n fontFamily: \"--mk-font\",\n};\n\n/** Convert tokens into a CSS custom-property style object for a wrapper element. */\nexport function tokensToStyle(tokens: ThemeTokens): CSSProperties {\n const style: Record<string, string> = {};\n (Object.keys(tokens) as (keyof ThemeTokens)[]).forEach((key) => {\n style[TOKEN_TO_CSS_VAR[key]] = String(tokens[key]);\n });\n return style as CSSProperties;\n}\n\n","import {\n createContext,\n useContext,\n useMemo,\n type ReactNode,\n} from \"react\";\nimport { MonetizeKitClient } from \"./lib/client\";\nimport {\n resolveTokens,\n type Appearance,\n type ThemeTokens,\n} from \"./theme/tokens\";\n\nexport interface MonetizeKitContextValue {\n client: MonetizeKitClient;\n customerId?: string;\n appearance: Appearance;\n tokens: ThemeTokens;\n}\n\nconst MonetizeKitContext = createContext<MonetizeKitContextValue | null>(null);\n\nexport interface MonetizeKitProviderProps {\n /** Browser-safe publishable key (pk_*). */\n publishableKey: string;\n /** API origin, e.g. https://app.monetizekit.app. */\n baseUrl: string;\n /** Optional customer JWT for customer-scoped reads (entitlements/usage/credits). */\n customerToken?: string;\n /** Customer id for entitlement/usage/credit hooks. */\n customerId?: string;\n /** Theme preset name or token overrides. */\n appearance?: Appearance;\n children: ReactNode;\n}\n\nexport function MonetizeKitProvider({\n publishableKey,\n baseUrl,\n customerToken,\n customerId,\n appearance = \"light\",\n children,\n}: MonetizeKitProviderProps) {\n const value = useMemo<MonetizeKitContextValue>(() => {\n return {\n client: new MonetizeKitClient({ publishableKey, baseUrl, customerToken }),\n customerId,\n appearance,\n tokens: resolveTokens(appearance),\n };\n }, [publishableKey, baseUrl, customerToken, customerId, appearance]);\n\n return (\n <MonetizeKitContext.Provider value={value}>\n {children}\n </MonetizeKitContext.Provider>\n );\n}\n\nexport function useMonetizeKit(): MonetizeKitContextValue {\n const ctx = useContext(MonetizeKitContext);\n if (!ctx) {\n throw new Error(\"useMonetizeKit must be used within a <MonetizeKitProvider>.\");\n }\n return ctx;\n}\n","import { useEffect, useState } from \"react\";\nimport { useMonetizeKit } from \"./provider\";\nimport type { CreditBalance, EntitlementResult, UsageResult } from \"./types\";\n\ninterface AsyncState<T> {\n data: T | null;\n loading: boolean;\n error: Error | null;\n}\n\nfunction useAsync<T>(\n run: () => Promise<T> | null,\n deps: unknown[],\n): AsyncState<T> {\n const [state, setState] = useState<AsyncState<T>>({\n data: null,\n loading: true,\n error: null,\n });\n\n useEffect(() => {\n let active = true;\n const promise = run();\n if (!promise) {\n setState({ data: null, loading: false, error: null });\n return;\n }\n setState((prev) => ({ ...prev, loading: true, error: null }));\n promise\n .then((data) => {\n if (active) setState({ data, loading: false, error: null });\n })\n .catch((error: unknown) => {\n if (active) {\n setState({\n data: null,\n loading: false,\n error: error instanceof Error ? error : new Error(String(error)),\n });\n }\n });\n return () => {\n active = false;\n };\n }, deps);\n\n return state;\n}\n\n/** Resolve a single feature entitlement for the provider's customer. */\nexport function useEntitlement(featureKey: string) {\n const { client, customerId } = useMonetizeKit();\n const state = useAsync<EntitlementResult>(\n () =>\n customerId\n ? client.getEntitlement<EntitlementResult>(customerId, featureKey)\n : null,\n [client, customerId, featureKey],\n );\n return {\n value: state.data?.value ?? null,\n allowed: state.data?.allowed ?? false,\n loading: state.loading,\n error: state.error,\n };\n}\n\n/** Resolve current usage for a meter. */\nexport function useUsage(meterId: string) {\n const { client, customerId } = useMonetizeKit();\n const state = useAsync<UsageResult>(\n () => (customerId ? client.getUsage<UsageResult>(customerId, meterId) : null),\n [client, customerId, meterId],\n );\n return {\n current: state.data?.current ?? 0,\n limit: state.data?.limit ?? null,\n loading: state.loading,\n error: state.error,\n };\n}\n\n/** Resolve the customer's credit balance. */\nexport function useCredits() {\n const { client, customerId } = useMonetizeKit();\n const state = useAsync<CreditBalance>(\n () => (customerId ? client.getCredits<CreditBalance>(customerId) : null),\n [client, customerId],\n );\n return {\n balance: state.data?.balance ?? 0,\n currency: state.data?.currency,\n loading: state.loading,\n error: state.error,\n };\n}\n","import type { Plan, PricingTerm } from \"../types\";\n\n/** Format a monetary amount with Intl, honoring locale + currency. */\nexport function formatMoney(\n amount: number,\n currency = \"USD\",\n locale?: string,\n): string {\n return new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency,\n minimumFractionDigits: Number.isInteger(amount) ? 0 : 2,\n maximumFractionDigits: amount < 1 ? 3 : 2,\n }).format(amount);\n}\n\n/** Format a large unit count compactly (e.g. 5,000 / 1M). */\nexport function formatUnits(value: number, locale?: string): string {\n return new Intl.NumberFormat(locale, {\n notation: value >= 10_000 ? \"compact\" : \"standard\",\n maximumFractionDigits: 1,\n }).format(value);\n}\n\nexport interface PriceDisplay {\n /** Headline price string, or null for contact-sales. */\n headline: string | null;\n /** Secondary line (e.g. \"+ usage\" or billing interval). */\n caption?: string;\n contactSales: boolean;\n}\n\nconst INTERVAL_SUFFIX: Record<PricingTerm[\"interval\"], string> = {\n monthly: \"/mo\",\n annually: \"/yr\",\n one_time: \"\",\n};\n\n/**\n * Derive a display from a plan's pricing terms. Returns a contact-sales display\n * when the plan is tagged `contact_sales` or has no public price; renders a\n * \"from $base + usage\" headline when metered usage terms are present.\n */\nexport function describePlanPrice(\n plan: Plan,\n locale?: string,\n): PriceDisplay {\n const pricing = plan.pricing ?? [];\n const contactSales =\n (plan.tags ?? []).includes(\"contact_sales\") || pricing.length === 0;\n if (contactSales) {\n return { headline: null, contactSales: true };\n }\n\n const base = pricing.find((t) => t.type === \"flat\");\n const hasUsage = pricing.some((t) => t.type === \"usage\");\n const currency = base?.currency ?? pricing[0]?.currency ?? \"USD\";\n const interval = base?.interval ?? pricing[0]?.interval ?? \"monthly\";\n const baseAmount = base?.amount ?? 0;\n\n const headline = `${formatMoney(baseAmount, currency, locale)}${INTERVAL_SUFFIX[interval]}`;\n return {\n headline,\n caption: hasUsage ? \"+ usage\" : undefined,\n contactSales: false,\n };\n}\n\n/** Human-readable description of a usage term's metered tiers. */\nexport function describeUsageTerm(term: PricingTerm, locale?: string): string {\n const parts: string[] = [];\n if (term.includedUnits && term.includedUnits > 0) {\n parts.push(`${formatUnits(term.includedUnits, locale)} ${term.meterDisplayName ?? \"units\"} included`);\n }\n const tiers = term.tieredPricing ?? [];\n if (tiers.length > 0) {\n const first = tiers[0]!;\n parts.push(\n `then ${formatMoney(first.unitPrice, term.currency, locale)}/unit${\n term.tierMode === \"volume\" ? \" (volume)\" : \"\"\n }`,\n );\n }\n return parts.join(\", \");\n}\n","import { useEffect, useState, type CSSProperties } from \"react\";\nimport { useMonetizeKit } from \"../provider\";\nimport { tokensToStyle } from \"../theme/tokens\";\nimport { describePlanPrice } from \"../lib/format\";\nimport type { Plan } from \"../types\";\n\nexport interface PricingTableProps {\n /** Plans to render; if omitted, fetched live from the publishable-key API. */\n plans?: Plan[];\n /** Plan name to highlight as \"Most Popular\". */\n highlightPlan?: string;\n billingCycle?: \"monthly\" | \"annually\";\n locale?: string;\n onSelectPlan?: (planId: string) => void;\n /** Where the Contact Sales CTA links (defaults to no-op). */\n onContactSales?: (planId: string) => void;\n}\n\nconst wrapperStyle: CSSProperties = {\n display: \"grid\",\n gridTemplateColumns: \"repeat(auto-fit, minmax(240px, 1fr))\",\n gap: \"1.5rem\",\n background: \"var(--mk-bg)\",\n color: \"var(--mk-fg)\",\n fontFamily: \"var(--mk-font)\",\n};\n\nconst cardBase: CSSProperties = {\n border: \"1px solid var(--mk-border)\",\n borderRadius: \"var(--mk-radius)\",\n padding: \"1.5rem\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.75rem\",\n};\n\nexport function PricingTable({\n plans: plansProp,\n highlightPlan,\n locale,\n onSelectPlan,\n onContactSales,\n}: PricingTableProps) {\n const { client, tokens } = useMonetizeKit();\n const [plans, setPlans] = useState<Plan[] | null>(plansProp ?? null);\n const [error, setError] = useState<Error | null>(null);\n\n useEffect(() => {\n if (plansProp) {\n setPlans(plansProp);\n return;\n }\n let active = true;\n client\n .listPlans<{ data: Plan[] }>()\n .then((res) => {\n if (active) setPlans(res.data ?? []);\n })\n .catch((e: unknown) => {\n if (active) setError(e instanceof Error ? e : new Error(String(e)));\n });\n return () => {\n active = false;\n };\n }, [client, plansProp]);\n\n if (error) {\n return <div role=\"alert\" style={{ color: \"var(--mk-muted)\" }}>Unable to load pricing.</div>;\n }\n if (!plans) {\n return <div aria-busy=\"true\" style={{ color: \"var(--mk-muted)\" }}>Loading pricing…</div>;\n }\n\n return (\n <div style={{ ...tokensToStyle(tokens), ...wrapperStyle }} data-mk-component=\"pricing-table\">\n {plans.map((plan) => {\n const price = describePlanPrice(plan, locale);\n const highlighted =\n highlightPlan != null &&\n plan.name.toLowerCase() === highlightPlan.toLowerCase();\n return (\n <div\n key={plan.id}\n style={{\n ...cardBase,\n borderColor: highlighted ? \"var(--mk-primary)\" : \"var(--mk-border)\",\n borderWidth: highlighted ? 2 : 1,\n }}\n data-mk-plan={plan.name}\n data-mk-highlighted={highlighted ? \"true\" : undefined}\n >\n {highlighted ? (\n <span\n style={{\n alignSelf: \"flex-start\",\n background: \"var(--mk-primary)\",\n color: \"var(--mk-primary-fg)\",\n borderRadius: \"var(--mk-radius)\",\n padding: \"0.125rem 0.5rem\",\n fontSize: \"0.75rem\",\n fontWeight: 600,\n }}\n >\n Most Popular\n </span>\n ) : null}\n <h3 style={{ margin: 0, fontSize: \"1.25rem\", fontWeight: 700 }}>{plan.name}</h3>\n {plan.description ? (\n <p style={{ margin: 0, color: \"var(--mk-muted)\", fontSize: \"0.875rem\" }}>\n {plan.description}\n </p>\n ) : null}\n <div style={{ display: \"flex\", alignItems: \"baseline\", gap: \"0.375rem\" }}>\n <span style={{ fontSize: \"2rem\", fontWeight: 700 }}>\n {price.contactSales ? \"Custom\" : price.headline}\n </span>\n {price.caption ? (\n <span style={{ color: \"var(--mk-muted)\", fontSize: \"0.875rem\" }}>\n {price.caption}\n </span>\n ) : null}\n </div>\n {plan.entitlements && plan.entitlements.length > 0 ? (\n <ul style={{ margin: 0, paddingLeft: \"1rem\", color: \"var(--mk-fg)\", fontSize: \"0.875rem\" }}>\n {plan.entitlements.slice(0, 6).map((e) => (\n <li key={e.featureKey}>\n {e.featureDisplayName}\n {e.type !== \"boolean\" ? `: ${String(e.value)}` : \"\"}\n </li>\n ))}\n </ul>\n ) : null}\n <button\n type=\"button\"\n onClick={() =>\n price.contactSales\n ? onContactSales?.(plan.id)\n : onSelectPlan?.(plan.id)\n }\n style={{\n marginTop: \"auto\",\n background: \"var(--mk-primary)\",\n color: \"var(--mk-primary-fg)\",\n border: \"none\",\n borderRadius: \"var(--mk-radius)\",\n padding: \"0.625rem 1rem\",\n fontWeight: 600,\n cursor: \"pointer\",\n }}\n >\n {price.contactSales ? \"Contact Sales\" : \"Get started\"}\n </button>\n </div>\n );\n })}\n </div>\n );\n}\n","import { type CSSProperties, type ReactNode } from \"react\";\nimport { useEntitlement } from \"../hooks\";\nimport { useMonetizeKit } from \"../provider\";\nimport { tokensToStyle } from \"../theme/tokens\";\n\nexport interface PaywallProps {\n /** Feature key gating the content. */\n feature: string;\n /** Protected content, shown when entitled. */\n children: ReactNode;\n title?: string;\n description?: string;\n ctaLabel?: string;\n onUpgrade?: () => void;\n}\n\nconst overlayStyle: CSSProperties = {\n border: \"1px solid var(--mk-border)\",\n borderRadius: \"var(--mk-radius)\",\n padding: \"2rem\",\n textAlign: \"center\",\n background: \"var(--mk-bg)\",\n color: \"var(--mk-fg)\",\n fontFamily: \"var(--mk-font)\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.75rem\",\n alignItems: \"center\",\n};\n\n/** Gate content behind an entitlement, showing an upgrade prompt when locked. */\nexport function Paywall({\n feature,\n children,\n title = \"Upgrade to unlock this feature\",\n description = \"This feature isn't included in your current plan.\",\n ctaLabel = \"Upgrade\",\n onUpgrade,\n}: PaywallProps) {\n const { allowed, loading } = useEntitlement(feature);\n const { tokens } = useMonetizeKit();\n\n if (loading) {\n return <div aria-busy=\"true\" style={{ color: \"var(--mk-muted)\" }}>Checking access…</div>;\n }\n if (allowed) {\n return <>{children}</>;\n }\n\n return (\n <div style={{ ...tokensToStyle(tokens), ...overlayStyle }} data-mk-component=\"paywall\">\n <h3 style={{ margin: 0, fontSize: \"1.125rem\", fontWeight: 700 }}>{title}</h3>\n <p style={{ margin: 0, color: \"var(--mk-muted)\", fontSize: \"0.875rem\" }}>{description}</p>\n <button\n type=\"button\"\n onClick={onUpgrade}\n style={{\n background: \"var(--mk-primary)\",\n color: \"var(--mk-primary-fg)\",\n border: \"none\",\n borderRadius: \"var(--mk-radius)\",\n padding: \"0.625rem 1.25rem\",\n fontWeight: 600,\n cursor: \"pointer\",\n }}\n >\n {ctaLabel}\n </button>\n </div>\n );\n}\n","import { type CSSProperties } from \"react\";\nimport { useUsage } from \"../hooks\";\nimport { useMonetizeKit } from \"../provider\";\nimport { tokensToStyle } from \"../theme/tokens\";\nimport { formatUnits } from \"../lib/format\";\n\nexport interface UsageBannerProps {\n /** Meter to display usage for. */\n meterId: string;\n label?: string;\n locale?: string;\n /** Fraction (0-1) at which the banner switches to a warning style. */\n warnAt?: number;\n}\n\nconst bannerStyle: CSSProperties = {\n border: \"1px solid var(--mk-border)\",\n borderRadius: \"var(--mk-radius)\",\n padding: \"0.875rem 1rem\",\n background: \"var(--mk-bg)\",\n color: \"var(--mk-fg)\",\n fontFamily: \"var(--mk-font)\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"0.5rem\",\n};\n\n/** Show current usage vs allotment for a capacity meter, with overage hint. */\nexport function UsageBanner({\n meterId,\n label = \"Usage\",\n locale,\n warnAt = 0.8,\n}: UsageBannerProps) {\n const { current, limit, loading } = useUsage(meterId);\n const { tokens } = useMonetizeKit();\n\n if (loading) {\n return <div aria-busy=\"true\" style={{ color: \"var(--mk-muted)\" }}>Loading usage…</div>;\n }\n\n const hasLimit = typeof limit === \"number\" && limit > 0;\n const fraction = hasLimit ? Math.min(1, current / (limit as number)) : 0;\n const over = hasLimit && current > (limit as number);\n const warn = hasLimit && fraction >= warnAt;\n const barColor = over || warn ? \"var(--mk-primary)\" : \"var(--mk-accent)\";\n\n return (\n <div style={{ ...tokensToStyle(tokens), ...bannerStyle }} data-mk-component=\"usage-banner\">\n <div style={{ display: \"flex\", justifyContent: \"space-between\", fontSize: \"0.875rem\" }}>\n <span style={{ fontWeight: 600 }}>{label}</span>\n <span style={{ color: \"var(--mk-muted)\" }}>\n {formatUnits(current, locale)}\n {hasLimit ? ` / ${formatUnits(limit as number, locale)}` : \"\"}\n </span>\n </div>\n {hasLimit ? (\n <div\n style={{\n height: 6,\n borderRadius: 999,\n background: \"var(--mk-border)\",\n overflow: \"hidden\",\n }}\n role=\"progressbar\"\n aria-valuenow={Math.round(fraction * 100)}\n aria-valuemin={0}\n aria-valuemax={100}\n >\n <div style={{ width: `${fraction * 100}%`, height: \"100%\", background: barColor }} />\n </div>\n ) : null}\n {over ? (\n <span style={{ color: \"var(--mk-primary)\", fontSize: \"0.75rem\" }}>\n Over included allotment — overage billed per usage pricing.\n </span>\n ) : null}\n </div>\n );\n}\n","import { type CSSProperties } from \"react\";\nimport { useCredits } from \"../hooks\";\nimport { useMonetizeKit } from \"../provider\";\nimport { tokensToStyle } from \"../theme/tokens\";\nimport { formatMoney } from \"../lib/format\";\nimport { UsageBanner } from \"./UsageBanner\";\n\nexport interface CustomerPortalProps {\n /** Current plan name to display. */\n planName?: string;\n /** Meters to surface usage for. */\n meterIds?: string[];\n /** Whether to show the credit balance card. */\n showCredits?: boolean;\n locale?: string;\n currency?: string;\n onManageBilling?: () => void;\n}\n\nconst containerStyle: CSSProperties = {\n border: \"1px solid var(--mk-border)\",\n borderRadius: \"var(--mk-radius)\",\n padding: \"1.25rem\",\n background: \"var(--mk-bg)\",\n color: \"var(--mk-fg)\",\n fontFamily: \"var(--mk-font)\",\n display: \"flex\",\n flexDirection: \"column\",\n gap: \"1rem\",\n maxWidth: 480,\n};\n\n/** A self-service portal: current plan, usage meters, and credit balance. */\nexport function CustomerPortal({\n planName = \"Current plan\",\n meterIds = [],\n showCredits = true,\n locale,\n currency = \"USD\",\n onManageBilling,\n}: CustomerPortalProps) {\n const { tokens } = useMonetizeKit();\n const credits = useCredits();\n\n return (\n <div style={{ ...tokensToStyle(tokens), ...containerStyle }} data-mk-component=\"customer-portal\">\n <div style={{ display: \"flex\", justifyContent: \"space-between\", alignItems: \"center\" }}>\n <div>\n <div style={{ fontSize: \"0.75rem\", color: \"var(--mk-muted)\" }}>Plan</div>\n <div style={{ fontSize: \"1.125rem\", fontWeight: 700 }}>{planName}</div>\n </div>\n <button\n type=\"button\"\n onClick={onManageBilling}\n style={{\n background: \"var(--mk-primary)\",\n color: \"var(--mk-primary-fg)\",\n border: \"none\",\n borderRadius: \"var(--mk-radius)\",\n padding: \"0.5rem 0.875rem\",\n fontWeight: 600,\n cursor: \"pointer\",\n }}\n >\n Manage billing\n </button>\n </div>\n\n {meterIds.map((meterId) => (\n <UsageBanner key={meterId} meterId={meterId} label={meterId} locale={locale} />\n ))}\n\n {showCredits ? (\n <div\n style={{\n border: \"1px solid var(--mk-border)\",\n borderRadius: \"var(--mk-radius)\",\n padding: \"0.875rem 1rem\",\n display: \"flex\",\n justifyContent: \"space-between\",\n }}\n >\n <span style={{ fontWeight: 600, fontSize: \"0.875rem\" }}>Credits</span>\n <span style={{ color: \"var(--mk-muted)\" }}>\n {credits.loading\n ? \"…\"\n : formatMoney(credits.balance, credits.currency ?? currency, locale)}\n </span>\n </div>\n ) : null}\n </div>\n );\n}\n","import type { ReactNode } from \"react\";\nimport { useEntitlement } from \"../hooks\";\n\nexport interface EntitlementGateProps {\n /** Feature key to check for the provider's customer. */\n feature: string;\n /** Rendered when the customer is entitled. */\n children: ReactNode;\n /** Rendered when not entitled (defaults to nothing). */\n fallback?: ReactNode;\n /** Rendered while the entitlement check is loading. */\n loadingFallback?: ReactNode;\n}\n\n/** Conditionally render children based on a live entitlement check. */\nexport function EntitlementGate({\n feature,\n children,\n fallback = null,\n loadingFallback = null,\n}: EntitlementGateProps) {\n const { allowed, loading } = useEntitlement(feature);\n if (loading) return <>{loadingFallback}</>;\n return <>{allowed ? children : fallback}</>;\n}\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Minimal fetch client for the MonetizeKit public API. Uses a publishable key
|
|
6
|
+
* (pk_*) as a Bearer token; safe for browser use against allowlisted origins.
|
|
7
|
+
*/
|
|
8
|
+
interface MonetizeKitClientConfig {
|
|
9
|
+
publishableKey: string;
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
customerToken?: string;
|
|
12
|
+
}
|
|
13
|
+
declare class MonetizeKitClient {
|
|
14
|
+
private readonly config;
|
|
15
|
+
constructor(config: MonetizeKitClientConfig);
|
|
16
|
+
private get;
|
|
17
|
+
listPlans<T>(): Promise<T>;
|
|
18
|
+
getEntitlement<T>(customerId: string, featureKey: string): Promise<T>;
|
|
19
|
+
getUsage<T>(customerId: string, meterId: string): Promise<T>;
|
|
20
|
+
getCredits<T>(customerId: string): Promise<T>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Appearance/theme token contract for MonetizeKit components. Components consume
|
|
25
|
+
* CSS custom properties derived from these tokens, so a host app can pass a
|
|
26
|
+
* preset name, a partial token override, or both.
|
|
27
|
+
*
|
|
28
|
+
* Presets:
|
|
29
|
+
* - `memphis` — the marketing site identity (coral/yellow/cyan, sharp corners)
|
|
30
|
+
* - `dashboard` — the app's neutral palette (rounded, muted)
|
|
31
|
+
* - `light` / `dark` — neutral defaults
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
interface ThemeTokens {
|
|
35
|
+
colorBackground: string;
|
|
36
|
+
colorForeground: string;
|
|
37
|
+
colorMuted: string;
|
|
38
|
+
colorPrimary: string;
|
|
39
|
+
colorPrimaryForeground: string;
|
|
40
|
+
colorAccent: string;
|
|
41
|
+
colorBorder: string;
|
|
42
|
+
radius: string;
|
|
43
|
+
fontFamily: string;
|
|
44
|
+
}
|
|
45
|
+
type ThemePresetName = "light" | "dark" | "memphis" | "dashboard";
|
|
46
|
+
declare const THEME_PRESETS: Record<ThemePresetName, ThemeTokens>;
|
|
47
|
+
type Appearance = ThemePresetName | {
|
|
48
|
+
preset?: ThemePresetName;
|
|
49
|
+
tokens?: Partial<ThemeTokens>;
|
|
50
|
+
};
|
|
51
|
+
/** Resolve an appearance prop into a concrete token set. */
|
|
52
|
+
declare function resolveTokens(appearance?: Appearance): ThemeTokens;
|
|
53
|
+
/** Convert tokens into a CSS custom-property style object for a wrapper element. */
|
|
54
|
+
declare function tokensToStyle(tokens: ThemeTokens): CSSProperties;
|
|
55
|
+
|
|
56
|
+
interface MonetizeKitContextValue {
|
|
57
|
+
client: MonetizeKitClient;
|
|
58
|
+
customerId?: string;
|
|
59
|
+
appearance: Appearance;
|
|
60
|
+
tokens: ThemeTokens;
|
|
61
|
+
}
|
|
62
|
+
interface MonetizeKitProviderProps {
|
|
63
|
+
/** Browser-safe publishable key (pk_*). */
|
|
64
|
+
publishableKey: string;
|
|
65
|
+
/** API origin, e.g. https://app.monetizekit.app. */
|
|
66
|
+
baseUrl: string;
|
|
67
|
+
/** Optional customer JWT for customer-scoped reads (entitlements/usage/credits). */
|
|
68
|
+
customerToken?: string;
|
|
69
|
+
/** Customer id for entitlement/usage/credit hooks. */
|
|
70
|
+
customerId?: string;
|
|
71
|
+
/** Theme preset name or token overrides. */
|
|
72
|
+
appearance?: Appearance;
|
|
73
|
+
children: ReactNode;
|
|
74
|
+
}
|
|
75
|
+
declare function MonetizeKitProvider({ publishableKey, baseUrl, customerToken, customerId, appearance, children, }: MonetizeKitProviderProps): react.JSX.Element;
|
|
76
|
+
declare function useMonetizeKit(): MonetizeKitContextValue;
|
|
77
|
+
|
|
78
|
+
/** Resolve a single feature entitlement for the provider's customer. */
|
|
79
|
+
declare function useEntitlement(featureKey: string): {
|
|
80
|
+
value: string | number | boolean | null;
|
|
81
|
+
allowed: boolean;
|
|
82
|
+
loading: boolean;
|
|
83
|
+
error: Error | null;
|
|
84
|
+
};
|
|
85
|
+
/** Resolve current usage for a meter. */
|
|
86
|
+
declare function useUsage(meterId: string): {
|
|
87
|
+
current: number;
|
|
88
|
+
limit: number | null;
|
|
89
|
+
loading: boolean;
|
|
90
|
+
error: Error | null;
|
|
91
|
+
};
|
|
92
|
+
/** Resolve the customer's credit balance. */
|
|
93
|
+
declare function useCredits(): {
|
|
94
|
+
balance: number;
|
|
95
|
+
currency: string | undefined;
|
|
96
|
+
loading: boolean;
|
|
97
|
+
error: Error | null;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Public types for @monetizekit/react. Kept self-contained so the package has
|
|
102
|
+
* no cross-repo dependency; mirrors the canonical catalog/pricing contract.
|
|
103
|
+
*/
|
|
104
|
+
interface PricingTier {
|
|
105
|
+
/** Absolute quantity upper bound; `null` = open-ended ("and above"). */
|
|
106
|
+
upTo: number | null;
|
|
107
|
+
unitPrice: number;
|
|
108
|
+
}
|
|
109
|
+
interface PricingTerm {
|
|
110
|
+
type: "flat" | "per_seat" | "usage" | "credits" | "setup_fee";
|
|
111
|
+
amount: number;
|
|
112
|
+
currency: string;
|
|
113
|
+
interval: "monthly" | "annually" | "one_time";
|
|
114
|
+
meterId?: string;
|
|
115
|
+
meterDisplayName?: string;
|
|
116
|
+
includedUnits?: number;
|
|
117
|
+
tierMode?: "graduated" | "volume";
|
|
118
|
+
tieredPricing?: PricingTier[];
|
|
119
|
+
}
|
|
120
|
+
interface PlanEntitlement {
|
|
121
|
+
featureKey: string;
|
|
122
|
+
featureDisplayName: string;
|
|
123
|
+
type: "boolean" | "limit" | "enum" | "string";
|
|
124
|
+
value: string | number | boolean;
|
|
125
|
+
}
|
|
126
|
+
interface Plan {
|
|
127
|
+
id: string;
|
|
128
|
+
name: string;
|
|
129
|
+
description?: string;
|
|
130
|
+
/** Marketing/grouping tags; `contact_sales` renders a Contact Sales CTA. */
|
|
131
|
+
tags?: string[];
|
|
132
|
+
entitlements?: PlanEntitlement[];
|
|
133
|
+
pricing?: PricingTerm[];
|
|
134
|
+
}
|
|
135
|
+
interface EntitlementResult {
|
|
136
|
+
featureKey: string;
|
|
137
|
+
value: string | number | boolean | null;
|
|
138
|
+
allowed: boolean;
|
|
139
|
+
}
|
|
140
|
+
interface UsageResult {
|
|
141
|
+
meterId: string;
|
|
142
|
+
current: number;
|
|
143
|
+
limit: number | null;
|
|
144
|
+
}
|
|
145
|
+
interface CreditBalance {
|
|
146
|
+
balance: number;
|
|
147
|
+
currency?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
interface PricingTableProps {
|
|
151
|
+
/** Plans to render; if omitted, fetched live from the publishable-key API. */
|
|
152
|
+
plans?: Plan[];
|
|
153
|
+
/** Plan name to highlight as "Most Popular". */
|
|
154
|
+
highlightPlan?: string;
|
|
155
|
+
billingCycle?: "monthly" | "annually";
|
|
156
|
+
locale?: string;
|
|
157
|
+
onSelectPlan?: (planId: string) => void;
|
|
158
|
+
/** Where the Contact Sales CTA links (defaults to no-op). */
|
|
159
|
+
onContactSales?: (planId: string) => void;
|
|
160
|
+
}
|
|
161
|
+
declare function PricingTable({ plans: plansProp, highlightPlan, locale, onSelectPlan, onContactSales, }: PricingTableProps): react.JSX.Element;
|
|
162
|
+
|
|
163
|
+
interface PaywallProps {
|
|
164
|
+
/** Feature key gating the content. */
|
|
165
|
+
feature: string;
|
|
166
|
+
/** Protected content, shown when entitled. */
|
|
167
|
+
children: ReactNode;
|
|
168
|
+
title?: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
ctaLabel?: string;
|
|
171
|
+
onUpgrade?: () => void;
|
|
172
|
+
}
|
|
173
|
+
/** Gate content behind an entitlement, showing an upgrade prompt when locked. */
|
|
174
|
+
declare function Paywall({ feature, children, title, description, ctaLabel, onUpgrade, }: PaywallProps): react.JSX.Element;
|
|
175
|
+
|
|
176
|
+
interface UsageBannerProps {
|
|
177
|
+
/** Meter to display usage for. */
|
|
178
|
+
meterId: string;
|
|
179
|
+
label?: string;
|
|
180
|
+
locale?: string;
|
|
181
|
+
/** Fraction (0-1) at which the banner switches to a warning style. */
|
|
182
|
+
warnAt?: number;
|
|
183
|
+
}
|
|
184
|
+
/** Show current usage vs allotment for a capacity meter, with overage hint. */
|
|
185
|
+
declare function UsageBanner({ meterId, label, locale, warnAt, }: UsageBannerProps): react.JSX.Element;
|
|
186
|
+
|
|
187
|
+
interface CustomerPortalProps {
|
|
188
|
+
/** Current plan name to display. */
|
|
189
|
+
planName?: string;
|
|
190
|
+
/** Meters to surface usage for. */
|
|
191
|
+
meterIds?: string[];
|
|
192
|
+
/** Whether to show the credit balance card. */
|
|
193
|
+
showCredits?: boolean;
|
|
194
|
+
locale?: string;
|
|
195
|
+
currency?: string;
|
|
196
|
+
onManageBilling?: () => void;
|
|
197
|
+
}
|
|
198
|
+
/** A self-service portal: current plan, usage meters, and credit balance. */
|
|
199
|
+
declare function CustomerPortal({ planName, meterIds, showCredits, locale, currency, onManageBilling, }: CustomerPortalProps): react.JSX.Element;
|
|
200
|
+
|
|
201
|
+
interface EntitlementGateProps {
|
|
202
|
+
/** Feature key to check for the provider's customer. */
|
|
203
|
+
feature: string;
|
|
204
|
+
/** Rendered when the customer is entitled. */
|
|
205
|
+
children: ReactNode;
|
|
206
|
+
/** Rendered when not entitled (defaults to nothing). */
|
|
207
|
+
fallback?: ReactNode;
|
|
208
|
+
/** Rendered while the entitlement check is loading. */
|
|
209
|
+
loadingFallback?: ReactNode;
|
|
210
|
+
}
|
|
211
|
+
/** Conditionally render children based on a live entitlement check. */
|
|
212
|
+
declare function EntitlementGate({ feature, children, fallback, loadingFallback, }: EntitlementGateProps): react.JSX.Element;
|
|
213
|
+
|
|
214
|
+
/** Format a monetary amount with Intl, honoring locale + currency. */
|
|
215
|
+
declare function formatMoney(amount: number, currency?: string, locale?: string): string;
|
|
216
|
+
/** Format a large unit count compactly (e.g. 5,000 / 1M). */
|
|
217
|
+
declare function formatUnits(value: number, locale?: string): string;
|
|
218
|
+
interface PriceDisplay {
|
|
219
|
+
/** Headline price string, or null for contact-sales. */
|
|
220
|
+
headline: string | null;
|
|
221
|
+
/** Secondary line (e.g. "+ usage" or billing interval). */
|
|
222
|
+
caption?: string;
|
|
223
|
+
contactSales: boolean;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Derive a display from a plan's pricing terms. Returns a contact-sales display
|
|
227
|
+
* when the plan is tagged `contact_sales` or has no public price; renders a
|
|
228
|
+
* "from $base + usage" headline when metered usage terms are present.
|
|
229
|
+
*/
|
|
230
|
+
declare function describePlanPrice(plan: Plan, locale?: string): PriceDisplay;
|
|
231
|
+
/** Human-readable description of a usage term's metered tiers. */
|
|
232
|
+
declare function describeUsageTerm(term: PricingTerm, locale?: string): string;
|
|
233
|
+
|
|
234
|
+
export { type Appearance, type CreditBalance, CustomerPortal, type CustomerPortalProps, EntitlementGate, type EntitlementGateProps, type EntitlementResult, MonetizeKitClient, type MonetizeKitClientConfig, type MonetizeKitContextValue, MonetizeKitProvider, type MonetizeKitProviderProps, Paywall, type PaywallProps, type Plan, type PlanEntitlement, type PriceDisplay, PricingTable, type PricingTableProps, type PricingTerm, type PricingTier, THEME_PRESETS, type ThemePresetName, type ThemeTokens, UsageBanner, type UsageBannerProps, type UsageResult, describePlanPrice, describeUsageTerm, formatMoney, formatUnits, resolveTokens, tokensToStyle, useCredits, useEntitlement, useMonetizeKit, useUsage };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Minimal fetch client for the MonetizeKit public API. Uses a publishable key
|
|
6
|
+
* (pk_*) as a Bearer token; safe for browser use against allowlisted origins.
|
|
7
|
+
*/
|
|
8
|
+
interface MonetizeKitClientConfig {
|
|
9
|
+
publishableKey: string;
|
|
10
|
+
baseUrl: string;
|
|
11
|
+
customerToken?: string;
|
|
12
|
+
}
|
|
13
|
+
declare class MonetizeKitClient {
|
|
14
|
+
private readonly config;
|
|
15
|
+
constructor(config: MonetizeKitClientConfig);
|
|
16
|
+
private get;
|
|
17
|
+
listPlans<T>(): Promise<T>;
|
|
18
|
+
getEntitlement<T>(customerId: string, featureKey: string): Promise<T>;
|
|
19
|
+
getUsage<T>(customerId: string, meterId: string): Promise<T>;
|
|
20
|
+
getCredits<T>(customerId: string): Promise<T>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Appearance/theme token contract for MonetizeKit components. Components consume
|
|
25
|
+
* CSS custom properties derived from these tokens, so a host app can pass a
|
|
26
|
+
* preset name, a partial token override, or both.
|
|
27
|
+
*
|
|
28
|
+
* Presets:
|
|
29
|
+
* - `memphis` — the marketing site identity (coral/yellow/cyan, sharp corners)
|
|
30
|
+
* - `dashboard` — the app's neutral palette (rounded, muted)
|
|
31
|
+
* - `light` / `dark` — neutral defaults
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
interface ThemeTokens {
|
|
35
|
+
colorBackground: string;
|
|
36
|
+
colorForeground: string;
|
|
37
|
+
colorMuted: string;
|
|
38
|
+
colorPrimary: string;
|
|
39
|
+
colorPrimaryForeground: string;
|
|
40
|
+
colorAccent: string;
|
|
41
|
+
colorBorder: string;
|
|
42
|
+
radius: string;
|
|
43
|
+
fontFamily: string;
|
|
44
|
+
}
|
|
45
|
+
type ThemePresetName = "light" | "dark" | "memphis" | "dashboard";
|
|
46
|
+
declare const THEME_PRESETS: Record<ThemePresetName, ThemeTokens>;
|
|
47
|
+
type Appearance = ThemePresetName | {
|
|
48
|
+
preset?: ThemePresetName;
|
|
49
|
+
tokens?: Partial<ThemeTokens>;
|
|
50
|
+
};
|
|
51
|
+
/** Resolve an appearance prop into a concrete token set. */
|
|
52
|
+
declare function resolveTokens(appearance?: Appearance): ThemeTokens;
|
|
53
|
+
/** Convert tokens into a CSS custom-property style object for a wrapper element. */
|
|
54
|
+
declare function tokensToStyle(tokens: ThemeTokens): CSSProperties;
|
|
55
|
+
|
|
56
|
+
interface MonetizeKitContextValue {
|
|
57
|
+
client: MonetizeKitClient;
|
|
58
|
+
customerId?: string;
|
|
59
|
+
appearance: Appearance;
|
|
60
|
+
tokens: ThemeTokens;
|
|
61
|
+
}
|
|
62
|
+
interface MonetizeKitProviderProps {
|
|
63
|
+
/** Browser-safe publishable key (pk_*). */
|
|
64
|
+
publishableKey: string;
|
|
65
|
+
/** API origin, e.g. https://app.monetizekit.app. */
|
|
66
|
+
baseUrl: string;
|
|
67
|
+
/** Optional customer JWT for customer-scoped reads (entitlements/usage/credits). */
|
|
68
|
+
customerToken?: string;
|
|
69
|
+
/** Customer id for entitlement/usage/credit hooks. */
|
|
70
|
+
customerId?: string;
|
|
71
|
+
/** Theme preset name or token overrides. */
|
|
72
|
+
appearance?: Appearance;
|
|
73
|
+
children: ReactNode;
|
|
74
|
+
}
|
|
75
|
+
declare function MonetizeKitProvider({ publishableKey, baseUrl, customerToken, customerId, appearance, children, }: MonetizeKitProviderProps): react.JSX.Element;
|
|
76
|
+
declare function useMonetizeKit(): MonetizeKitContextValue;
|
|
77
|
+
|
|
78
|
+
/** Resolve a single feature entitlement for the provider's customer. */
|
|
79
|
+
declare function useEntitlement(featureKey: string): {
|
|
80
|
+
value: string | number | boolean | null;
|
|
81
|
+
allowed: boolean;
|
|
82
|
+
loading: boolean;
|
|
83
|
+
error: Error | null;
|
|
84
|
+
};
|
|
85
|
+
/** Resolve current usage for a meter. */
|
|
86
|
+
declare function useUsage(meterId: string): {
|
|
87
|
+
current: number;
|
|
88
|
+
limit: number | null;
|
|
89
|
+
loading: boolean;
|
|
90
|
+
error: Error | null;
|
|
91
|
+
};
|
|
92
|
+
/** Resolve the customer's credit balance. */
|
|
93
|
+
declare function useCredits(): {
|
|
94
|
+
balance: number;
|
|
95
|
+
currency: string | undefined;
|
|
96
|
+
loading: boolean;
|
|
97
|
+
error: Error | null;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Public types for @monetizekit/react. Kept self-contained so the package has
|
|
102
|
+
* no cross-repo dependency; mirrors the canonical catalog/pricing contract.
|
|
103
|
+
*/
|
|
104
|
+
interface PricingTier {
|
|
105
|
+
/** Absolute quantity upper bound; `null` = open-ended ("and above"). */
|
|
106
|
+
upTo: number | null;
|
|
107
|
+
unitPrice: number;
|
|
108
|
+
}
|
|
109
|
+
interface PricingTerm {
|
|
110
|
+
type: "flat" | "per_seat" | "usage" | "credits" | "setup_fee";
|
|
111
|
+
amount: number;
|
|
112
|
+
currency: string;
|
|
113
|
+
interval: "monthly" | "annually" | "one_time";
|
|
114
|
+
meterId?: string;
|
|
115
|
+
meterDisplayName?: string;
|
|
116
|
+
includedUnits?: number;
|
|
117
|
+
tierMode?: "graduated" | "volume";
|
|
118
|
+
tieredPricing?: PricingTier[];
|
|
119
|
+
}
|
|
120
|
+
interface PlanEntitlement {
|
|
121
|
+
featureKey: string;
|
|
122
|
+
featureDisplayName: string;
|
|
123
|
+
type: "boolean" | "limit" | "enum" | "string";
|
|
124
|
+
value: string | number | boolean;
|
|
125
|
+
}
|
|
126
|
+
interface Plan {
|
|
127
|
+
id: string;
|
|
128
|
+
name: string;
|
|
129
|
+
description?: string;
|
|
130
|
+
/** Marketing/grouping tags; `contact_sales` renders a Contact Sales CTA. */
|
|
131
|
+
tags?: string[];
|
|
132
|
+
entitlements?: PlanEntitlement[];
|
|
133
|
+
pricing?: PricingTerm[];
|
|
134
|
+
}
|
|
135
|
+
interface EntitlementResult {
|
|
136
|
+
featureKey: string;
|
|
137
|
+
value: string | number | boolean | null;
|
|
138
|
+
allowed: boolean;
|
|
139
|
+
}
|
|
140
|
+
interface UsageResult {
|
|
141
|
+
meterId: string;
|
|
142
|
+
current: number;
|
|
143
|
+
limit: number | null;
|
|
144
|
+
}
|
|
145
|
+
interface CreditBalance {
|
|
146
|
+
balance: number;
|
|
147
|
+
currency?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
interface PricingTableProps {
|
|
151
|
+
/** Plans to render; if omitted, fetched live from the publishable-key API. */
|
|
152
|
+
plans?: Plan[];
|
|
153
|
+
/** Plan name to highlight as "Most Popular". */
|
|
154
|
+
highlightPlan?: string;
|
|
155
|
+
billingCycle?: "monthly" | "annually";
|
|
156
|
+
locale?: string;
|
|
157
|
+
onSelectPlan?: (planId: string) => void;
|
|
158
|
+
/** Where the Contact Sales CTA links (defaults to no-op). */
|
|
159
|
+
onContactSales?: (planId: string) => void;
|
|
160
|
+
}
|
|
161
|
+
declare function PricingTable({ plans: plansProp, highlightPlan, locale, onSelectPlan, onContactSales, }: PricingTableProps): react.JSX.Element;
|
|
162
|
+
|
|
163
|
+
interface PaywallProps {
|
|
164
|
+
/** Feature key gating the content. */
|
|
165
|
+
feature: string;
|
|
166
|
+
/** Protected content, shown when entitled. */
|
|
167
|
+
children: ReactNode;
|
|
168
|
+
title?: string;
|
|
169
|
+
description?: string;
|
|
170
|
+
ctaLabel?: string;
|
|
171
|
+
onUpgrade?: () => void;
|
|
172
|
+
}
|
|
173
|
+
/** Gate content behind an entitlement, showing an upgrade prompt when locked. */
|
|
174
|
+
declare function Paywall({ feature, children, title, description, ctaLabel, onUpgrade, }: PaywallProps): react.JSX.Element;
|
|
175
|
+
|
|
176
|
+
interface UsageBannerProps {
|
|
177
|
+
/** Meter to display usage for. */
|
|
178
|
+
meterId: string;
|
|
179
|
+
label?: string;
|
|
180
|
+
locale?: string;
|
|
181
|
+
/** Fraction (0-1) at which the banner switches to a warning style. */
|
|
182
|
+
warnAt?: number;
|
|
183
|
+
}
|
|
184
|
+
/** Show current usage vs allotment for a capacity meter, with overage hint. */
|
|
185
|
+
declare function UsageBanner({ meterId, label, locale, warnAt, }: UsageBannerProps): react.JSX.Element;
|
|
186
|
+
|
|
187
|
+
interface CustomerPortalProps {
|
|
188
|
+
/** Current plan name to display. */
|
|
189
|
+
planName?: string;
|
|
190
|
+
/** Meters to surface usage for. */
|
|
191
|
+
meterIds?: string[];
|
|
192
|
+
/** Whether to show the credit balance card. */
|
|
193
|
+
showCredits?: boolean;
|
|
194
|
+
locale?: string;
|
|
195
|
+
currency?: string;
|
|
196
|
+
onManageBilling?: () => void;
|
|
197
|
+
}
|
|
198
|
+
/** A self-service portal: current plan, usage meters, and credit balance. */
|
|
199
|
+
declare function CustomerPortal({ planName, meterIds, showCredits, locale, currency, onManageBilling, }: CustomerPortalProps): react.JSX.Element;
|
|
200
|
+
|
|
201
|
+
interface EntitlementGateProps {
|
|
202
|
+
/** Feature key to check for the provider's customer. */
|
|
203
|
+
feature: string;
|
|
204
|
+
/** Rendered when the customer is entitled. */
|
|
205
|
+
children: ReactNode;
|
|
206
|
+
/** Rendered when not entitled (defaults to nothing). */
|
|
207
|
+
fallback?: ReactNode;
|
|
208
|
+
/** Rendered while the entitlement check is loading. */
|
|
209
|
+
loadingFallback?: ReactNode;
|
|
210
|
+
}
|
|
211
|
+
/** Conditionally render children based on a live entitlement check. */
|
|
212
|
+
declare function EntitlementGate({ feature, children, fallback, loadingFallback, }: EntitlementGateProps): react.JSX.Element;
|
|
213
|
+
|
|
214
|
+
/** Format a monetary amount with Intl, honoring locale + currency. */
|
|
215
|
+
declare function formatMoney(amount: number, currency?: string, locale?: string): string;
|
|
216
|
+
/** Format a large unit count compactly (e.g. 5,000 / 1M). */
|
|
217
|
+
declare function formatUnits(value: number, locale?: string): string;
|
|
218
|
+
interface PriceDisplay {
|
|
219
|
+
/** Headline price string, or null for contact-sales. */
|
|
220
|
+
headline: string | null;
|
|
221
|
+
/** Secondary line (e.g. "+ usage" or billing interval). */
|
|
222
|
+
caption?: string;
|
|
223
|
+
contactSales: boolean;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Derive a display from a plan's pricing terms. Returns a contact-sales display
|
|
227
|
+
* when the plan is tagged `contact_sales` or has no public price; renders a
|
|
228
|
+
* "from $base + usage" headline when metered usage terms are present.
|
|
229
|
+
*/
|
|
230
|
+
declare function describePlanPrice(plan: Plan, locale?: string): PriceDisplay;
|
|
231
|
+
/** Human-readable description of a usage term's metered tiers. */
|
|
232
|
+
declare function describeUsageTerm(term: PricingTerm, locale?: string): string;
|
|
233
|
+
|
|
234
|
+
export { type Appearance, type CreditBalance, CustomerPortal, type CustomerPortalProps, EntitlementGate, type EntitlementGateProps, type EntitlementResult, MonetizeKitClient, type MonetizeKitClientConfig, type MonetizeKitContextValue, MonetizeKitProvider, type MonetizeKitProviderProps, Paywall, type PaywallProps, type Plan, type PlanEntitlement, type PriceDisplay, PricingTable, type PricingTableProps, type PricingTerm, type PricingTier, THEME_PRESETS, type ThemePresetName, type ThemeTokens, UsageBanner, type UsageBannerProps, type UsageResult, describePlanPrice, describeUsageTerm, formatMoney, formatUnits, resolveTokens, tokensToStyle, useCredits, useEntitlement, useMonetizeKit, useUsage };
|