@monetizekit/react 0.2.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.d.cts CHANGED
@@ -162,6 +162,21 @@ interface CreditBalance {
162
162
  balance: number;
163
163
  currency?: string;
164
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
+ }
165
180
 
166
181
  interface PricingTableProps {
167
182
  /** Plans to render; if omitted, fetched live from the publishable-key API. */
@@ -214,9 +229,19 @@ interface CustomerPortalProps {
214
229
  meterIds?: string[];
215
230
  /** Whether to show the credit balance card. */
216
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[];
217
242
  /**
218
- * Render illustrative sample plan/usage/credit data behind a clear disclaimer.
219
- * Use for previews or a fresh workspace with no plans/products defined yet.
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.
220
245
  */
221
246
  sample?: boolean;
222
247
  /** Override the sample-data disclaimer copy. */
@@ -227,8 +252,8 @@ interface CustomerPortalProps {
227
252
  currency?: string;
228
253
  onManageBilling?: () => void;
229
254
  }
230
- /** A self-service portal: current plan, usage meters, and credit balance. */
231
- declare function CustomerPortal({ planName, meterIds, showCredits, sample, disclaimer, showBranding, 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;
232
257
 
233
258
  interface EntitlementGateProps {
234
259
  /** Feature key to check for the provider's customer. */
@@ -263,6 +288,12 @@ declare function SampleNotice({ children }: SampleNoticeProps): react.JSX.Elemen
263
288
  declare const SAMPLE_PLANS: Plan[];
264
289
  declare const SAMPLE_USAGE: Record<string, UsageResult>;
265
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[];
266
297
  declare const SAMPLE_PORTAL: {
267
298
  readonly planName: "Growth";
268
299
  readonly meterIds: readonly ["api_calls", "seats"];
@@ -290,4 +321,4 @@ declare function describePlanPrice(plan: Plan, locale?: string): PriceDisplay;
290
321
  /** Human-readable description of a usage term's metered tiers. */
291
322
  declare function describeUsageTerm(term: PricingTerm, locale?: string): string;
292
323
 
293
- 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, SAMPLE_CREDITS, SAMPLE_NOTICE_TEXT, SAMPLE_PLANS, SAMPLE_PORTAL, SAMPLE_USAGE, SampleNotice, type SampleNoticeProps, THEME_PRESETS, THEME_PRESET_NAMES, 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 };
package/dist/index.d.ts CHANGED
@@ -162,6 +162,21 @@ interface CreditBalance {
162
162
  balance: number;
163
163
  currency?: string;
164
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
+ }
165
180
 
166
181
  interface PricingTableProps {
167
182
  /** Plans to render; if omitted, fetched live from the publishable-key API. */
@@ -214,9 +229,19 @@ interface CustomerPortalProps {
214
229
  meterIds?: string[];
215
230
  /** Whether to show the credit balance card. */
216
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[];
217
242
  /**
218
- * Render illustrative sample plan/usage/credit data behind a clear disclaimer.
219
- * Use for previews or a fresh workspace with no plans/products defined yet.
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.
220
245
  */
221
246
  sample?: boolean;
222
247
  /** Override the sample-data disclaimer copy. */
@@ -227,8 +252,8 @@ interface CustomerPortalProps {
227
252
  currency?: string;
228
253
  onManageBilling?: () => void;
229
254
  }
230
- /** A self-service portal: current plan, usage meters, and credit balance. */
231
- declare function CustomerPortal({ planName, meterIds, showCredits, sample, disclaimer, showBranding, 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;
232
257
 
233
258
  interface EntitlementGateProps {
234
259
  /** Feature key to check for the provider's customer. */
@@ -263,6 +288,12 @@ declare function SampleNotice({ children }: SampleNoticeProps): react.JSX.Elemen
263
288
  declare const SAMPLE_PLANS: Plan[];
264
289
  declare const SAMPLE_USAGE: Record<string, UsageResult>;
265
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[];
266
297
  declare const SAMPLE_PORTAL: {
267
298
  readonly planName: "Growth";
268
299
  readonly meterIds: readonly ["api_calls", "seats"];
@@ -290,4 +321,4 @@ declare function describePlanPrice(plan: Plan, locale?: string): PriceDisplay;
290
321
  /** Human-readable description of a usage term's metered tiers. */
291
322
  declare function describeUsageTerm(term: PricingTerm, locale?: string): string;
292
323
 
293
- 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, SAMPLE_CREDITS, SAMPLE_NOTICE_TEXT, SAMPLE_PLANS, SAMPLE_PORTAL, SAMPLE_USAGE, SampleNotice, type SampleNoticeProps, THEME_PRESETS, THEME_PRESET_NAMES, 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 };
package/dist/index.js CHANGED
@@ -407,7 +407,7 @@ var SAMPLE_PLANS = [
407
407
  id: "sample_pro",
408
408
  name: "Growth",
409
409
  description: "Product-led monetization at scale",
410
- pricing: [{ type: "flat", amount: 49900, currency: "USD", interval: "monthly" }],
410
+ pricing: [{ type: "flat", amount: 499, currency: "USD", interval: "monthly" }],
411
411
  entitlements: [
412
412
  { featureKey: "max_customers", featureDisplayName: "Tracked customers", type: "limit", value: 1e4 },
413
413
  { featureKey: "stripe", featureDisplayName: "Stripe integration", type: "boolean", value: true },
@@ -420,7 +420,7 @@ var SAMPLE_PLANS = [
420
420
  name: "Scale",
421
421
  description: "Volume-based capacity pricing",
422
422
  pricing: [
423
- { type: "flat", amount: 99900, currency: "USD", interval: "monthly" },
423
+ { type: "flat", amount: 999, currency: "USD", interval: "monthly" },
424
424
  {
425
425
  type: "usage",
426
426
  amount: 0,
@@ -458,7 +458,21 @@ var SAMPLE_USAGE = {
458
458
  seats: { meterId: "seats", current: 8, limit: 10 },
459
459
  storage_gb: { meterId: "storage_gb", current: 3, limit: 10 }
460
460
  };
461
- var SAMPLE_CREDITS = { balance: 12e4, currency: "USD" };
461
+ var SAMPLE_CREDITS = { balance: 1200, currency: "USD" };
462
+ var SAMPLE_TEAM = {
463
+ members: [
464
+ { name: "Jordan Lee", email: "jordan@acme.test", role: "owner" },
465
+ { name: "Sam Rivera", email: "sam@acme.test", role: "admin" },
466
+ { name: "Taylor Kim", email: "taylor@acme.test", role: "member" }
467
+ ],
468
+ seats: 3,
469
+ maxSeats: 10
470
+ };
471
+ var SAMPLE_INVOICES = [
472
+ { id: "in_1003", date: "2026-03-01T00:00:00Z", amount: 499, currency: "USD", status: "paid" },
473
+ { id: "in_1002", date: "2026-02-01T00:00:00Z", amount: 499, currency: "USD", status: "paid" },
474
+ { id: "in_1001", date: "2026-01-01T00:00:00Z", amount: 499, currency: "USD", status: "paid" }
475
+ ];
462
476
  var SAMPLE_PORTAL = {
463
477
  planName: "Growth",
464
478
  meterIds: ["api_calls", "seats"]
@@ -756,10 +770,38 @@ function SampleUsageRow({
756
770
  hasLimit ? /* @__PURE__ */ jsx("div", { style: { height: 6, borderRadius: 999, background: "var(--mk-border)", overflow: "hidden" }, children: /* @__PURE__ */ jsx("div", { style: { width: `${fraction * 100}%`, height: "100%", background: barColor } }) }) : null
757
771
  ] });
758
772
  }
773
+ var ROW_DIVIDER = { borderTop: "1px solid var(--mk-border)" };
774
+ var INVOICE_STATUS_COLOR = {
775
+ paid: "var(--mk-success)",
776
+ pending: "var(--mk-warning)",
777
+ overdue: "var(--mk-danger)"
778
+ };
779
+ function StatusBadge({ label, color }) {
780
+ return /* @__PURE__ */ jsx(
781
+ "span",
782
+ {
783
+ style: {
784
+ fontSize: "0.6875rem",
785
+ fontWeight: 600,
786
+ textTransform: "capitalize",
787
+ color,
788
+ border: `1px solid ${color}`,
789
+ borderRadius: 999,
790
+ padding: "0.0625rem 0.5rem"
791
+ },
792
+ children: label
793
+ }
794
+ );
795
+ }
759
796
  function CustomerPortal({
760
797
  planName,
761
798
  meterIds,
762
799
  showCredits = true,
800
+ showTeam,
801
+ teamMembers,
802
+ seats,
803
+ showInvoices,
804
+ invoices,
763
805
  sample = false,
764
806
  disclaimer,
765
807
  showBranding = false,
@@ -774,6 +816,11 @@ function CustomerPortal({
774
816
  const creditBalance = sample ? SAMPLE_CREDITS.balance : credits.balance;
775
817
  const creditCurrency = sample ? SAMPLE_CREDITS.currency : credits.currency;
776
818
  const creditLoading = sample ? false : credits.loading;
819
+ const teamEnabled = showTeam ?? sample;
820
+ const resolvedTeam = teamMembers ?? (sample ? SAMPLE_TEAM.members : []);
821
+ const resolvedSeats = seats ?? (sample ? { used: SAMPLE_TEAM.seats, max: SAMPLE_TEAM.maxSeats } : void 0);
822
+ const invoicesEnabled = showInvoices ?? sample;
823
+ const resolvedInvoices = invoices ?? (sample ? SAMPLE_INVOICES : []);
777
824
  return /* @__PURE__ */ jsxs(
778
825
  "div",
779
826
  {
@@ -840,6 +887,64 @@ function CustomerPortal({
840
887
  /* @__PURE__ */ jsx("span", { style: { fontWeight: 600, fontSize: "0.875rem" }, children: "Credits" }),
841
888
  /* @__PURE__ */ jsx("span", { style: { color: "var(--mk-muted)" }, children: creditLoading ? "\u2026" : formatMoney(creditBalance, creditCurrency ?? currency, locale) })
842
889
  ] }) : null,
890
+ teamEnabled ? /* @__PURE__ */ jsxs("div", { style: cardStyle, children: [
891
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center" }, children: [
892
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 600, fontSize: "0.875rem" }, children: "Team" }),
893
+ resolvedSeats ? /* @__PURE__ */ jsxs("span", { style: { color: "var(--mk-muted)", fontSize: "0.75rem" }, children: [
894
+ resolvedSeats.used,
895
+ "/",
896
+ resolvedSeats.max >= 9999 ? "Unlimited" : resolvedSeats.max,
897
+ " seats"
898
+ ] }) : null
899
+ ] }),
900
+ resolvedTeam.length === 0 ? /* @__PURE__ */ jsx("span", { style: { color: "var(--mk-muted)", fontSize: "0.8125rem" }, children: "No team members." }) : resolvedTeam.map((member, i) => /* @__PURE__ */ jsxs(
901
+ "div",
902
+ {
903
+ style: {
904
+ display: "flex",
905
+ justifyContent: "space-between",
906
+ alignItems: "center",
907
+ gap: "0.75rem",
908
+ fontSize: "0.8125rem",
909
+ paddingTop: i === 0 ? 0 : "0.5rem",
910
+ ...i === 0 ? {} : ROW_DIVIDER
911
+ },
912
+ children: [
913
+ /* @__PURE__ */ jsxs("div", { style: { minWidth: 0 }, children: [
914
+ /* @__PURE__ */ jsx("div", { style: { fontWeight: 600 }, children: member.name }),
915
+ /* @__PURE__ */ jsx("div", { style: { color: "var(--mk-muted)", fontSize: "0.75rem" }, children: member.email })
916
+ ] }),
917
+ /* @__PURE__ */ jsx(StatusBadge, { label: member.role, color: "var(--mk-muted)" })
918
+ ]
919
+ },
920
+ member.email
921
+ ))
922
+ ] }) : null,
923
+ invoicesEnabled ? /* @__PURE__ */ jsxs("div", { style: cardStyle, children: [
924
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 600, fontSize: "0.875rem" }, children: "Invoices" }),
925
+ resolvedInvoices.length === 0 ? /* @__PURE__ */ jsx("span", { style: { color: "var(--mk-muted)", fontSize: "0.8125rem" }, children: "No invoices yet." }) : resolvedInvoices.map((invoice, i) => /* @__PURE__ */ jsxs(
926
+ "div",
927
+ {
928
+ style: {
929
+ display: "flex",
930
+ justifyContent: "space-between",
931
+ alignItems: "center",
932
+ gap: "0.75rem",
933
+ fontSize: "0.8125rem",
934
+ paddingTop: i === 0 ? 0 : "0.5rem",
935
+ ...i === 0 ? {} : ROW_DIVIDER
936
+ },
937
+ children: [
938
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 500 }, children: new Date(invoice.date).toLocaleDateString(locale) }),
939
+ /* @__PURE__ */ jsxs("div", { style: { display: "flex", alignItems: "center", gap: "0.5rem" }, children: [
940
+ /* @__PURE__ */ jsx("span", { style: { fontWeight: 600 }, children: formatMoney(invoice.amount, invoice.currency, locale) }),
941
+ /* @__PURE__ */ jsx(StatusBadge, { label: invoice.status, color: INVOICE_STATUS_COLOR[invoice.status] })
942
+ ] })
943
+ ]
944
+ },
945
+ invoice.id
946
+ ))
947
+ ] }) : null,
843
948
  showBranding ? /* @__PURE__ */ jsx("div", { style: { textAlign: "center", fontSize: "0.625rem", color: "var(--mk-muted)" }, children: "Powered by MonetizeKit" }) : null
844
949
  ]
845
950
  }
@@ -856,6 +961,6 @@ function EntitlementGate({
856
961
  return /* @__PURE__ */ jsx(Fragment, { children: allowed ? children : fallback });
857
962
  }
858
963
 
859
- export { CustomerPortal, EntitlementGate, MonetizeKitClient, MonetizeKitProvider, Paywall, PricingTable, SAMPLE_CREDITS, SAMPLE_NOTICE_TEXT, SAMPLE_PLANS, SAMPLE_PORTAL, SAMPLE_USAGE, SampleNotice, THEME_PRESETS, THEME_PRESET_NAMES, UsageBanner, describePlanPrice, describeUsageTerm, formatMoney, formatUnits, resolveTokens, tokensToStyle, useCredits, useEntitlement, useMonetizeKit, useUsage };
964
+ export { CustomerPortal, EntitlementGate, MonetizeKitClient, MonetizeKitProvider, Paywall, PricingTable, SAMPLE_CREDITS, SAMPLE_INVOICES, SAMPLE_NOTICE_TEXT, SAMPLE_PLANS, SAMPLE_PORTAL, SAMPLE_TEAM, SAMPLE_USAGE, SampleNotice, THEME_PRESETS, THEME_PRESET_NAMES, UsageBanner, describePlanPrice, describeUsageTerm, formatMoney, formatUnits, resolveTokens, tokensToStyle, useCredits, useEntitlement, useMonetizeKit, useUsage };
860
965
  //# sourceMappingURL=index.js.map
861
966
  //# sourceMappingURL=index.js.map