@monetizekit/react 0.1.0 → 0.3.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/dist/index.cjs +530 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +98 -8
- package/dist/index.d.ts +98 -8
- package/dist/index.js +522 -108
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -26,9 +26,13 @@ declare class MonetizeKitClient {
|
|
|
26
26
|
* preset name, a partial token override, or both.
|
|
27
27
|
*
|
|
28
28
|
* Presets:
|
|
29
|
-
* - `
|
|
30
|
-
* - `
|
|
31
|
-
* - `
|
|
29
|
+
* - `light` / `dark` — neutral defaults
|
|
30
|
+
* - `memphis` — the marketing site identity (coral/yellow/cyan, hard edges + hard shadow)
|
|
31
|
+
* - `dashboard` — the app's neutral palette (rounded, muted)
|
|
32
|
+
* - `console` — the dashboard "widgets" mock look: dark cards, emerald/amber/red
|
|
33
|
+
* semantics, soft elevation. Lets you reproduce the in-app preview style.
|
|
34
|
+
* - `midnight` — deep slate/indigo dark
|
|
35
|
+
* - `ocean` / `forest` / `sunset` / `grape` — light brand palettes for variety
|
|
32
36
|
*/
|
|
33
37
|
|
|
34
38
|
interface ThemeTokens {
|
|
@@ -39,11 +43,23 @@ interface ThemeTokens {
|
|
|
39
43
|
colorPrimaryForeground: string;
|
|
40
44
|
colorAccent: string;
|
|
41
45
|
colorBorder: string;
|
|
46
|
+
/** Surface color for cards/panels layered on the background. */
|
|
47
|
+
colorCard: string;
|
|
48
|
+
/** Foreground used on top of `colorCard`. */
|
|
49
|
+
colorCardForeground: string;
|
|
50
|
+
/** Semantic colors for status (healthy / approaching limit / over limit). */
|
|
51
|
+
colorSuccess: string;
|
|
52
|
+
colorWarning: string;
|
|
53
|
+
colorDanger: string;
|
|
42
54
|
radius: string;
|
|
55
|
+
/** Box-shadow applied to elevated surfaces (cards/portals). */
|
|
56
|
+
shadow: string;
|
|
43
57
|
fontFamily: string;
|
|
44
58
|
}
|
|
45
|
-
type ThemePresetName = "light" | "dark" | "memphis" | "dashboard";
|
|
59
|
+
type ThemePresetName = "light" | "dark" | "memphis" | "dashboard" | "console" | "midnight" | "ocean" | "forest" | "sunset" | "grape";
|
|
46
60
|
declare const THEME_PRESETS: Record<ThemePresetName, ThemeTokens>;
|
|
61
|
+
/** All preset names, useful for theme pickers / story matrices. */
|
|
62
|
+
declare const THEME_PRESET_NAMES: ThemePresetName[];
|
|
47
63
|
type Appearance = ThemePresetName | {
|
|
48
64
|
preset?: ThemePresetName;
|
|
49
65
|
tokens?: Partial<ThemeTokens>;
|
|
@@ -146,6 +162,21 @@ interface CreditBalance {
|
|
|
146
162
|
balance: number;
|
|
147
163
|
currency?: string;
|
|
148
164
|
}
|
|
165
|
+
interface TeamMember {
|
|
166
|
+
name: string;
|
|
167
|
+
email: string;
|
|
168
|
+
role: string;
|
|
169
|
+
avatarUrl?: string;
|
|
170
|
+
}
|
|
171
|
+
interface Invoice {
|
|
172
|
+
id: string;
|
|
173
|
+
/** ISO date string. */
|
|
174
|
+
date: string;
|
|
175
|
+
/** Amount in major currency units (e.g. dollars). */
|
|
176
|
+
amount: number;
|
|
177
|
+
currency: string;
|
|
178
|
+
status: "paid" | "pending" | "overdue";
|
|
179
|
+
}
|
|
149
180
|
|
|
150
181
|
interface PricingTableProps {
|
|
151
182
|
/** Plans to render; if omitted, fetched live from the publishable-key API. */
|
|
@@ -157,8 +188,15 @@ interface PricingTableProps {
|
|
|
157
188
|
onSelectPlan?: (planId: string) => void;
|
|
158
189
|
/** Where the Contact Sales CTA links (defaults to no-op). */
|
|
159
190
|
onContactSales?: (planId: string) => void;
|
|
191
|
+
/**
|
|
192
|
+
* When there are no plans to show, render illustrative sample plans behind a
|
|
193
|
+
* clear disclaimer instead of an empty table. Defaults to `true`.
|
|
194
|
+
*/
|
|
195
|
+
sampleWhenEmpty?: boolean;
|
|
196
|
+
/** Override the sample-data disclaimer copy. */
|
|
197
|
+
disclaimer?: ReactNode;
|
|
160
198
|
}
|
|
161
|
-
declare function PricingTable({ plans: plansProp, highlightPlan, locale, onSelectPlan, onContactSales, }: PricingTableProps): react.JSX.Element;
|
|
199
|
+
declare function PricingTable({ plans: plansProp, highlightPlan, locale, onSelectPlan, onContactSales, sampleWhenEmpty, disclaimer, }: PricingTableProps): react.JSX.Element;
|
|
162
200
|
|
|
163
201
|
interface PaywallProps {
|
|
164
202
|
/** Feature key gating the content. */
|
|
@@ -191,12 +229,31 @@ interface CustomerPortalProps {
|
|
|
191
229
|
meterIds?: string[];
|
|
192
230
|
/** Whether to show the credit balance card. */
|
|
193
231
|
showCredits?: boolean;
|
|
232
|
+
/** Show a team/seats section. Defaults to on in `sample` mode. */
|
|
233
|
+
showTeam?: boolean;
|
|
234
|
+
teamMembers?: TeamMember[];
|
|
235
|
+
seats?: {
|
|
236
|
+
used: number;
|
|
237
|
+
max: number;
|
|
238
|
+
};
|
|
239
|
+
/** Show a billing-history (invoices) section. Defaults to on in `sample` mode. */
|
|
240
|
+
showInvoices?: boolean;
|
|
241
|
+
invoices?: Invoice[];
|
|
242
|
+
/**
|
|
243
|
+
* Render illustrative sample plan/usage/credit/team/invoice data behind a clear
|
|
244
|
+
* disclaimer. Use for previews or a fresh workspace with no plans/products yet.
|
|
245
|
+
*/
|
|
246
|
+
sample?: boolean;
|
|
247
|
+
/** Override the sample-data disclaimer copy. */
|
|
248
|
+
disclaimer?: ReactNode;
|
|
249
|
+
/** Show the "Powered by MonetizeKit" footer. */
|
|
250
|
+
showBranding?: boolean;
|
|
194
251
|
locale?: string;
|
|
195
252
|
currency?: string;
|
|
196
253
|
onManageBilling?: () => void;
|
|
197
254
|
}
|
|
198
|
-
/** A self-service portal:
|
|
199
|
-
declare function CustomerPortal({ planName, meterIds, showCredits, locale, currency, onManageBilling, }: CustomerPortalProps): react.JSX.Element;
|
|
255
|
+
/** A self-service portal: plan, usage, credits, team, and invoices. */
|
|
256
|
+
declare function CustomerPortal({ planName, meterIds, showCredits, showTeam, teamMembers, seats, showInvoices, invoices, sample, disclaimer, showBranding, locale, currency, onManageBilling, }: CustomerPortalProps): react.JSX.Element;
|
|
200
257
|
|
|
201
258
|
interface EntitlementGateProps {
|
|
202
259
|
/** Feature key to check for the provider's customer. */
|
|
@@ -211,6 +268,39 @@ interface EntitlementGateProps {
|
|
|
211
268
|
/** Conditionally render children based on a live entitlement check. */
|
|
212
269
|
declare function EntitlementGate({ feature, children, fallback, loadingFallback, }: EntitlementGateProps): react.JSX.Element;
|
|
213
270
|
|
|
271
|
+
interface SampleNoticeProps {
|
|
272
|
+
/** Override the default disclaimer copy. */
|
|
273
|
+
children?: ReactNode;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* A clearly-styled disclaimer banner shown above illustrative sample content so
|
|
277
|
+
* it is never mistaken for live data.
|
|
278
|
+
*/
|
|
279
|
+
declare function SampleNotice({ children }: SampleNoticeProps): react.JSX.Element;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Illustrative sample data used to show what a surface *could* look like when no
|
|
283
|
+
* real catalog/customer data is available yet (e.g. a fresh workspace with no
|
|
284
|
+
* plans or products defined). Always paired with a visible <SampleNotice/> so it
|
|
285
|
+
* is never mistaken for live data.
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
declare const SAMPLE_PLANS: Plan[];
|
|
289
|
+
declare const SAMPLE_USAGE: Record<string, UsageResult>;
|
|
290
|
+
declare const SAMPLE_CREDITS: CreditBalance;
|
|
291
|
+
declare const SAMPLE_TEAM: {
|
|
292
|
+
members: TeamMember[];
|
|
293
|
+
seats: number;
|
|
294
|
+
maxSeats: number;
|
|
295
|
+
};
|
|
296
|
+
declare const SAMPLE_INVOICES: Invoice[];
|
|
297
|
+
declare const SAMPLE_PORTAL: {
|
|
298
|
+
readonly planName: "Growth";
|
|
299
|
+
readonly meterIds: readonly ["api_calls", "seats"];
|
|
300
|
+
};
|
|
301
|
+
/** Default disclaimer copy shown alongside sample data. */
|
|
302
|
+
declare const SAMPLE_NOTICE_TEXT = "Sample data for illustration only \u2014 define plans and products to show live values.";
|
|
303
|
+
|
|
214
304
|
/** Format a monetary amount with Intl, honoring locale + currency. */
|
|
215
305
|
declare function formatMoney(amount: number, currency?: string, locale?: string): string;
|
|
216
306
|
/** Format a large unit count compactly (e.g. 5,000 / 1M). */
|
|
@@ -231,4 +321,4 @@ declare function describePlanPrice(plan: Plan, locale?: string): PriceDisplay;
|
|
|
231
321
|
/** Human-readable description of a usage term's metered tiers. */
|
|
232
322
|
declare function describeUsageTerm(term: PricingTerm, locale?: string): string;
|
|
233
323
|
|
|
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 };
|
|
324
|
+
export { type Appearance, type CreditBalance, CustomerPortal, type CustomerPortalProps, EntitlementGate, type EntitlementGateProps, type EntitlementResult, type Invoice, MonetizeKitClient, type MonetizeKitClientConfig, type MonetizeKitContextValue, MonetizeKitProvider, type MonetizeKitProviderProps, Paywall, type PaywallProps, type Plan, type PlanEntitlement, type PriceDisplay, PricingTable, type PricingTableProps, type PricingTerm, type PricingTier, SAMPLE_CREDITS, SAMPLE_INVOICES, SAMPLE_NOTICE_TEXT, SAMPLE_PLANS, SAMPLE_PORTAL, SAMPLE_TEAM, SAMPLE_USAGE, SampleNotice, type SampleNoticeProps, THEME_PRESETS, THEME_PRESET_NAMES, type TeamMember, type ThemePresetName, type ThemeTokens, UsageBanner, type UsageBannerProps, type UsageResult, describePlanPrice, describeUsageTerm, formatMoney, formatUnits, resolveTokens, tokensToStyle, useCredits, useEntitlement, useMonetizeKit, useUsage };
|