@formata/limitr-ui 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 ADDED
@@ -0,0 +1,30 @@
1
+ # Limitr UI
2
+ Open-source and vibe-code friendly UI library for [Limitr](https://limitr.dev).
3
+
4
+ ## Example
5
+ To show a customer's current Limitr plan information, usage, Stripe subscription details, recent invoices, billing management options, cancel/resume actions, plan selection table, etc, just import and include the limitr-current-plan component like so.
6
+
7
+ > See [@formata/limitr](https://github.com/dev-formata-io/limitr) for more information on Limitr pricing policies, and check out [Limitr Cloud](https://cloud.limitr.dev) to implement your pricing in a few minutes.
8
+
9
+ ```typescript
10
+ renderCurrentUserSubscription(customerId: string) {
11
+ const policy: any = this.policy ?? new Limitr();
12
+ return html`
13
+ <div class="section">
14
+ <div class="section-header">
15
+ <h2 class="section-title">Subscription</h2>
16
+ </div>
17
+ <div class="section-content">
18
+ <limitr-current-plan
19
+ .policy=${policy}
20
+ .customerId=${customerId}
21
+ ?showStripeInfo=${true}
22
+ ?cancelImmediately=${false}
23
+ ?requestStripeInvoices=${true}
24
+ ?requestStripePortalUrl=${true}
25
+ ></limitr-current-plan>
26
+ </div>
27
+ </div>
28
+ `;
29
+ }
30
+ ```
@@ -0,0 +1,84 @@
1
+ import { LimitrElement } from './element.js';
2
+ import { type CSSResult } from "lit";
3
+ import './table.ts';
4
+ /**
5
+ * Show a customer's current plan & usage information (if any).
6
+ *
7
+ * For Stripe integration via Limitr Cloud, the following metadata fields are expected
8
+ * in customer.metadata:
9
+ *
10
+ * - stripe_subscription_id: string - Stripe subscription ID
11
+ * - stripe_subscription_status: string - Status (active, canceled, past_due, etc.)
12
+ * - stripe_current_period_start: number - Unix timestamp (ms)
13
+ * - stripe_current_period_end: number - Unix timestamp (ms)
14
+ * - stripe_cancel_at_period_end: boolean - Will cancel at end of period
15
+ * - stripe_customer_id: string - Stripe customer ID
16
+ * - stripe_payment_method_type: string - Payment method type (card, etc.)
17
+ * - stripe_payment_method_last4: string - Last 4 digits of payment method
18
+ * - stripe_payment_method_brand: string - Card brand (visa, mastercard, etc.)
19
+ *
20
+ * Coupon metadata fields (populated by Limitr when coupon is applied):
21
+ * - stripe_coupon_code: string - The coupon/promo code
22
+ * - stripe_coupon_status: string - 'pending' | 'applied' | 'invalid' | 'expired'
23
+ * - stripe_coupon_name: string - Display name for the coupon
24
+ * - stripe_coupon_percent_off: string - Percentage off (if percent-based)
25
+ * - stripe_coupon_amount_off: string - Amount off in cents (if amount-based)
26
+ * - stripe_coupon_currency: string - Currency for amount_off coupons
27
+ * - stripe_coupon_duration: string - 'once' | 'repeating' | 'forever'
28
+ * - stripe_coupon_duration_in_months: string - Number of months (if repeating)
29
+ */
30
+ export declare class LimitrCurrentPlan extends LimitrElement {
31
+ showStripeInfo: boolean;
32
+ hideUsage: boolean;
33
+ hideCancel: boolean;
34
+ cancelImmediately: boolean;
35
+ theme: 'light' | 'dark';
36
+ /** When true, emit plan select events only, without setting customer plan on policy. */
37
+ denyPolicyChanges: boolean;
38
+ private currentPlan;
39
+ private currentCustomer;
40
+ private loading;
41
+ private showPricingTable;
42
+ /**
43
+ * Styles.
44
+ */
45
+ static get styles(): CSSResult;
46
+ connectedCallback(): void;
47
+ updated(changedProperties: Map<string | number | symbol, unknown>): Promise<void>;
48
+ protected _internalHideCancel: boolean;
49
+ private loadData;
50
+ private handleChangePlan;
51
+ private handleClosePricingTable;
52
+ private handlePlanSelected;
53
+ private handleCancelPlan;
54
+ private handleResumeSubscription;
55
+ /**
56
+ * Pluralize a unit name if needed based on the value.
57
+ */
58
+ private pluralizeUnit;
59
+ private getCouponDetails;
60
+ /**
61
+ * Check if subscription status is active/valid (not terminated or never activated)
62
+ */
63
+ private hasActiveSubscription;
64
+ private formatLimitValue;
65
+ private formatUsageValue;
66
+ private getUsagePercentage;
67
+ private getUsageClass;
68
+ private formatDate;
69
+ private renderStripeInfo;
70
+ private renderUsage;
71
+ /**
72
+ * Render invoices section if invoices are available in policy.
73
+ */
74
+ private renderInvoices;
75
+ /**
76
+ * Format currency value
77
+ */
78
+ private formatCurrency;
79
+ /**
80
+ * Render.
81
+ */
82
+ render(): unknown;
83
+ }
84
+ //# sourceMappingURL=current.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"current.d.ts","sourceRoot":"","sources":["../current.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAO,KAAK,SAAS,EAAiB,MAAM,KAAK,CAAC;AACzD,OAAO,YAAY,CAAC;AAGpB;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBACa,iBAAkB,SAAQ,aAAa;IAEhD,cAAc,EAAE,OAAO,CAAS;IAGhC,SAAS,EAAE,OAAO,CAAS;IAG3B,UAAU,EAAE,OAAO,CAAS;IAG5B,iBAAiB,EAAE,OAAO,CAAS;IAGnC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAW;IAGlC,wFAAwF;IACxF,iBAAiB,EAAE,OAAO,CAAS;IAInC,OAAO,CAAC,WAAW,CAAa;IAIhC,OAAO,CAAC,eAAe,CAAa;IAGpC,OAAO,CAAC,OAAO,CAAiB;IAGhC,OAAO,CAAC,gBAAgB,CAAkB;IAG1C;;OAEG;IACH,WAAoB,MAAM,IAAI,SAAS,CA4dtC;IAGQ,iBAAiB;IAMX,OAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,OAAO,CAAC;IAwBhF,SAAS,CAAC,mBAAmB,EAAE,OAAO,CAAS;YAEjC,QAAQ;IAsBtB,OAAO,CAAC,gBAAgB;IAKxB,OAAO,CAAC,uBAAuB;YAKjB,kBAAkB;IAahC,OAAO,CAAC,gBAAgB;IAwBxB,OAAO,CAAC,wBAAwB;IAuBhC;;OAEG;IACH,OAAO,CAAC,aAAa;IAwCrB,OAAO,CAAC,gBAAgB;IA0CxB;;OAEG;IAEH,OAAO,CAAC,qBAAqB;IAW7B,OAAO,CAAC,gBAAgB;IAmBxB,OAAO,CAAC,gBAAgB;IAiBxB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,aAAa;IAOrB,OAAO,CAAC,UAAU;IAUlB,OAAO,CAAC,gBAAgB;IA8CxB,OAAO,CAAC,WAAW;IA6CnB;;OAEG;IACH,OAAO,CAAC,cAAc;IA6CtB;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACM,MAAM,IAAI,OAAO;CAmG7B"}