@molecule/app-pricing-page-angular 0.0.1-stage → 1.1.1
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 +537 -4
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,11 +1,544 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-11-22T16:18:18.840Z
|
|
7
|
+
-->
|
|
8
|
+
|
|
1
9
|
# @molecule/app-pricing-page-angular
|
|
2
10
|
|
|
3
|
-
|
|
11
|
+
Angular drop-in pricing page used by every paid molecule.dev flagship app.
|
|
12
|
+
|
|
13
|
+
Components:
|
|
14
|
+
`<PricingPage />` — Renders one card per tier, with optional
|
|
15
|
+
monthly/yearly toggle and Stripe Checkout
|
|
16
|
+
CTA. Reads tiers from `usePricingTiers()`
|
|
17
|
+
unless an explicit `tiers` prop is passed.
|
|
18
|
+
|
|
19
|
+
`<PlanUpdatedPage />` — Post-checkout success page rendered at
|
|
20
|
+
Stripe's `success_url` redirect target.
|
|
21
|
+
|
|
22
|
+
It is the Angular counterpart of `@molecule/app-pricing-page-react`: the
|
|
23
|
+
same exports, the same inputs (React prop names) and the same DOM for the
|
|
24
|
+
same input.
|
|
25
|
+
|
|
26
|
+
Translations live in the companion locale bond
|
|
27
|
+
`@molecule/app-locales-pricing-page`. The checkout transport lives in
|
|
28
|
+
`@molecule/app-billing-angular` (`usePricingTiers()` calls
|
|
29
|
+
`GET /api/billing/tiers`; `useStartCheckout()` posts to
|
|
30
|
+
`/api/billing/checkout`) — your API must serve those routes and the HTTP
|
|
31
|
+
client must be wired. NOTE: `@molecule/app-billing-angular` also exports
|
|
32
|
+
its own different pricing page (compound LimitsList/LimitsItem layout);
|
|
33
|
+
import from the package whose API you are using. The default checkout
|
|
34
|
+
redirects with `window.location.assign(checkoutUrl)` — pass `onCheckout`
|
|
35
|
+
to route through an SPA router or a non-Stripe flow. `<PlanUpdatedPage />`
|
|
36
|
+
here is the pricing-page-flavored success page; a standalone plan-updated
|
|
37
|
+
page lives in `@molecule/app-plan-updated-page-angular` — import the one
|
|
38
|
+
whose kit you are using.
|
|
39
|
+
|
|
40
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
41
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
42
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
43
|
+
|
|
44
|
+
## Quick Start
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
import { Component } from '@angular/core'
|
|
48
|
+
import { PlanUpdatedPage, PricingPage } from '@molecule/app-pricing-page-angular'
|
|
49
|
+
|
|
50
|
+
@Component({
|
|
51
|
+
selector: 'app-pricing',
|
|
52
|
+
standalone: true,
|
|
53
|
+
imports: [PlanUpdatedPage, PricingPage],
|
|
54
|
+
template: `
|
|
55
|
+
<section mol-pricing-page></section>
|
|
56
|
+
<section
|
|
57
|
+
mol-plan-updated-page
|
|
58
|
+
planName="Pro"
|
|
59
|
+
ctaHref="/dashboard"
|
|
60
|
+
ctaLabel="Go to dashboard"
|
|
61
|
+
></section>
|
|
62
|
+
`,
|
|
63
|
+
})
|
|
64
|
+
export class PricingRoute {}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Type
|
|
68
|
+
|
|
69
|
+
`feature`
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
npm install @molecule/app-pricing-page-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-billing-angular @molecule/app-subscription-plan-card-angular @molecule/app-ui @molecule/app-ui-angular
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## API
|
|
78
|
+
|
|
79
|
+
### Interfaces
|
|
80
|
+
|
|
81
|
+
#### `PricingPageProps`
|
|
82
|
+
|
|
83
|
+
Props for `<PricingPage />` (the component's inputs).
|
|
84
|
+
|
|
85
|
+
```typescript
|
|
86
|
+
interface PricingPageProps<TLimits = unknown> {
|
|
87
|
+
/**
|
|
88
|
+
* Optional pre-fetched tiers. When omitted the component fetches them
|
|
89
|
+
* via `usePricingTiers()` (which calls `GET /api/billing/tiers`).
|
|
90
|
+
*/
|
|
91
|
+
tiers?: PricingTierEntry<TLimits>[]
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Optional override for the checkout handler. The default posts to
|
|
95
|
+
* `/api/billing/checkout` via `useStartCheckout()` and redirects the
|
|
96
|
+
* browser to the returned `checkoutUrl`. Custom apps can pass a
|
|
97
|
+
* function that performs Stripe checkout via a different transport,
|
|
98
|
+
* navigates within a router, etc.
|
|
99
|
+
*/
|
|
100
|
+
onCheckout?: (tier: PricingTierEntry<TLimits>, price: PricingTierPrice) => void | Promise<void>
|
|
101
|
+
|
|
102
|
+
/** When true (default), renders a monthly/yearly toggle. */
|
|
103
|
+
showPeriodToggle?: boolean
|
|
104
|
+
|
|
105
|
+
/** Default billing period for the toggle. Defaults to `'month'`. */
|
|
106
|
+
defaultPeriod?: PricingPagePeriod
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Optional template for the tier-specific limits block (React's
|
|
110
|
+
* `renderLimits` render function; its context carries the tier's limits
|
|
111
|
+
* as `$implicit` and `a0`). When omitted, `limits` are rendered as a
|
|
112
|
+
* `<dl>` of key-value pairs.
|
|
113
|
+
*/
|
|
114
|
+
renderLimits?: TemplateRef<TLimits> | null
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Optional translation key for the page heading. Defaults to
|
|
118
|
+
* `'pricingPage.heading'`.
|
|
119
|
+
*/
|
|
120
|
+
headingKey?: string
|
|
4
121
|
|
|
122
|
+
/** Optional English fallback for the heading. */
|
|
123
|
+
headingDefault?: string
|
|
124
|
+
|
|
125
|
+
/** Optional className applied to the outer wrapper (the host element). */
|
|
126
|
+
className?: string
|
|
127
|
+
}
|
|
5
128
|
```
|
|
6
|
-
|
|
129
|
+
|
|
130
|
+
#### `PlanUpdatedPageProps`
|
|
131
|
+
|
|
132
|
+
Props for `<PlanUpdatedPage />` (the component's inputs).
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
interface PlanUpdatedPageProps {
|
|
136
|
+
/**
|
|
137
|
+
* Optional new plan name to include in the heading (e.g. `'Pro'`).
|
|
138
|
+
* When omitted, a generic heading is rendered.
|
|
139
|
+
*/
|
|
140
|
+
planName?: string
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Optional CTA label / target. Renders a primary button when both
|
|
144
|
+
* `ctaLabel` and one of `onCta` / `ctaHref` are supplied. A typical
|
|
145
|
+
* use is "Continue to dashboard". A string input renders as text;
|
|
146
|
+
* `[slot=ctaLabel]` projected content renders in its place.
|
|
147
|
+
*/
|
|
148
|
+
ctaLabel?: string
|
|
149
|
+
|
|
150
|
+
/** Click handler for the CTA. Mutually exclusive with `ctaHref`. */
|
|
151
|
+
onCta?: (event: unknown) => void
|
|
152
|
+
|
|
153
|
+
/** Anchor target for the CTA. Mutually exclusive with `onCta`. */
|
|
154
|
+
ctaHref?: string
|
|
155
|
+
|
|
156
|
+
/** Optional className applied to the outer wrapper (the host element). */
|
|
157
|
+
className?: string
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Types
|
|
162
|
+
|
|
163
|
+
#### `PricingPagePeriod`
|
|
164
|
+
|
|
165
|
+
Billing period selector — currently `'month'` or `'year'`. Mirrors the
|
|
166
|
+
upstream `PricingTierPrice['period']` literal for type-safety.
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
type PricingPagePeriod = PricingTierPrice['period']
|
|
7
170
|
```
|
|
8
171
|
|
|
9
|
-
|
|
172
|
+
### Classes
|
|
173
|
+
|
|
174
|
+
#### `PlanUpdatedPage`
|
|
175
|
+
|
|
176
|
+
PlanUpdatedPage component.
|
|
177
|
+
|
|
178
|
+
Post-checkout success page. Rendered after Stripe redirects the user back
|
|
179
|
+
from Checkout (the standard `success_url` route in mlcl flagship apps).
|
|
180
|
+
The host IS the outer `<section>` React renders, so its class list and
|
|
181
|
+
`data-mol-id` are host bindings. The node-valued `ctaLabel` prop is
|
|
182
|
+
projected content (`[slot=ctaLabel]`) or a plain string input.
|
|
183
|
+
|
|
184
|
+
This is the Angular counterpart of `@molecule/app-pricing-page-react`'s
|
|
185
|
+
`PlanUpdatedPage`.
|
|
186
|
+
|
|
187
|
+
```typescript
|
|
188
|
+
@Component({
|
|
189
|
+
selector: 'section[mol-plan-updated-page]',
|
|
190
|
+
standalone: true,
|
|
191
|
+
inputs: ['planName', 'ctaLabel', 'onCta', 'ctaHref', 'className'],
|
|
192
|
+
host: {
|
|
193
|
+
'[class]': 'className ?? null',
|
|
194
|
+
'data-mol-id': 'plan-updated-page',
|
|
195
|
+
},
|
|
196
|
+
// prettier-ignore
|
|
197
|
+
template: `
|
|
198
|
+
<header [class]="cm.cardHeader">
|
|
199
|
+
<h1 [class]="cm.cardTitle">@if (planName) {{{ t('pricingPage.planUpdated.headingNamed', { planName: planName }, { defaultValue: "You're now on the {{planName}} plan" }) }}}@else {{{ t('pricingPage.planUpdated.heading', undefined, { defaultValue: 'Your plan has been updated' }) }}}</h1>
|
|
200
|
+
<p [class]="cm.cardDescription">{{ t('pricingPage.planUpdated.body', undefined, { defaultValue: 'Thanks for upgrading. Your new plan is active immediately and a receipt has been emailed to you.' }) }}</p>
|
|
201
|
+
</header>
|
|
202
|
+
@if (showCta) {
|
|
203
|
+
<footer [class]="cm.cardFooter">
|
|
204
|
+
@if (ctaHref) {
|
|
205
|
+
<a [href]="ctaHref" [class]="cm.button({ variant: 'solid', size: 'md' })" data-mol-id="plan-updated-cta" #ctaLabelEl>@if (hasCtaLabel) {{{ ctaLabel }}}<ng-content select="[slot=ctaLabel]" /></a>
|
|
206
|
+
} @else {
|
|
207
|
+
<button type="button" [class]="cm.button({ variant: 'solid', size: 'md' })" (click)="fireCta($event)" data-mol-id="plan-updated-cta" #ctaLabelEl>@if (hasCtaLabel) {{{ ctaLabel }}}<ng-content select="[slot=ctaLabel]" /></button>
|
|
208
|
+
}
|
|
209
|
+
</footer>
|
|
210
|
+
}
|
|
211
|
+
`,
|
|
212
|
+
})
|
|
213
|
+
export class PlanUpdatedPage implements AfterViewInit, PlanUpdatedPageProps {
|
|
214
|
+
/**
|
|
215
|
+
* Optional new plan name to include in the heading (e.g. `'Pro'`).
|
|
216
|
+
* When omitted, a generic heading is rendered.
|
|
217
|
+
*/
|
|
218
|
+
planName?: string
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Optional CTA label. A string input renders as text; `[slot=ctaLabel]`
|
|
222
|
+
* projected content renders in its place.
|
|
223
|
+
*/
|
|
224
|
+
ctaLabel?: string
|
|
225
|
+
|
|
226
|
+
/** Click handler for the CTA. Mutually exclusive with `ctaHref`. */
|
|
227
|
+
onCta?: (event: unknown) => void
|
|
228
|
+
|
|
229
|
+
/** Anchor target for the CTA. Mutually exclusive with `onCta`. */
|
|
230
|
+
ctaHref?: string
|
|
231
|
+
|
|
232
|
+
/** Optional className applied to the outer wrapper (the host element). */
|
|
233
|
+
className?: string
|
|
234
|
+
|
|
235
|
+
/** The i18n handle (locale-reactive), read in an injection context. */
|
|
236
|
+
private readonly i18n = useTranslation()
|
|
237
|
+
|
|
238
|
+
/** The translation function for the template. */
|
|
239
|
+
protected t = this.i18n.t
|
|
240
|
+
|
|
241
|
+
/** The bonded ClassMap (styling tokens resolve at render time). */
|
|
242
|
+
protected readonly cm: UIClassMap = getClassMap()
|
|
243
|
+
|
|
244
|
+
/** The CTA's label region (projected content lands here; read once). */
|
|
245
|
+
@ViewChild('ctaLabelEl') private ctaLabelEl?: ElementRef<HTMLElement>
|
|
246
|
+
|
|
247
|
+
/**
|
|
248
|
+
* Whether a `[slot=ctaLabel]` projection landed: true (optimistically)
|
|
249
|
+
* until the first view proves otherwise.
|
|
250
|
+
*/
|
|
251
|
+
private readonly ctaProjected = signal(true)
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Reads the CTA label region's first render: when neither a text input nor
|
|
255
|
+
* projected content landed, React would not render the CTA at all, so the
|
|
256
|
+
* optimistic render is withdrawn.
|
|
257
|
+
*/
|
|
258
|
+
ngAfterViewInit(): void {
|
|
259
|
+
const el = this.ctaLabelEl?.nativeElement
|
|
260
|
+
if (el) this.ctaProjected.set(hasRenderableContent(el))
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Whether a text CTA label input renders (a projected label is not).
|
|
265
|
+
*
|
|
266
|
+
* @returns True when the label renders as text.
|
|
267
|
+
*/
|
|
268
|
+
get hasCtaLabel(): boolean {
|
|
269
|
+
return this.ctaLabel !== undefined && this.ctaLabel !== null && this.ctaLabel !== ''
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* Whether the CTA renders: a truthy string input or a projected
|
|
274
|
+
* `[slot=ctaLabel]` element.
|
|
275
|
+
*
|
|
276
|
+
* @returns True when the CTA shows.
|
|
277
|
+
*/
|
|
278
|
+
get showCta(): boolean {
|
|
279
|
+
return this.hasCtaLabel || this.ctaProjected()
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Passes the click event to the caller's handler, as React's
|
|
284
|
+
* `onClick={onCta}` does.
|
|
285
|
+
*
|
|
286
|
+
* @param event - The DOM click event.
|
|
287
|
+
*/
|
|
288
|
+
fireCta(event: unknown): void {
|
|
289
|
+
this.onCta?.(event)
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
#### `PricingPage`
|
|
295
|
+
|
|
296
|
+
PricingPage component.
|
|
297
|
+
|
|
298
|
+
Drop-in pricing page: one card per tier from `tiers` (or
|
|
299
|
+
`usePricingTiers()` when not supplied), with an optional monthly/yearly
|
|
300
|
+
toggle and a Stripe Checkout CTA per card. The host IS the outer
|
|
301
|
+
`<section>` React renders, so its class list and state-dependent
|
|
302
|
+
`data-mol-id` are host bindings. The `renderLimits` render function
|
|
303
|
+
arrives as a template (its context carries the tier's limits as
|
|
304
|
+
`$implicit` and `a0`).
|
|
305
|
+
|
|
306
|
+
This is the Angular counterpart of `@molecule/app-pricing-page-react`'s
|
|
307
|
+
`PricingPage`.
|
|
308
|
+
|
|
309
|
+
```typescript
|
|
310
|
+
@Component({
|
|
311
|
+
selector: 'section[mol-pricing-page]',
|
|
312
|
+
standalone: true,
|
|
313
|
+
imports: [NgTemplateOutlet],
|
|
314
|
+
inputs: [
|
|
315
|
+
'tiers',
|
|
316
|
+
'onCheckout',
|
|
317
|
+
'showPeriodToggle',
|
|
318
|
+
'defaultPeriod',
|
|
319
|
+
'renderLimits',
|
|
320
|
+
'headingKey',
|
|
321
|
+
'headingDefault',
|
|
322
|
+
'className',
|
|
323
|
+
],
|
|
324
|
+
host: {
|
|
325
|
+
'[class]': 'className ?? null',
|
|
326
|
+
'[attr.data-mol-id]': 'molId()',
|
|
327
|
+
},
|
|
328
|
+
// prettier-ignore
|
|
329
|
+
template: `
|
|
330
|
+
@if (showLoading()) {
|
|
331
|
+
<p>{{ t('pricingPage.loading', undefined, { defaultValue: 'Loading plans…' }) }}</p>
|
|
332
|
+
} @else if (showError()) {
|
|
333
|
+
<p [class]="cm.formError" role="alert">{{ t('pricingPage.error', undefined, { defaultValue: 'Could not load pricing. Try again later.' }) }}</p>
|
|
334
|
+
} @else {
|
|
335
|
+
<header [class]="cm.cardHeader">
|
|
336
|
+
<h1 [class]="cm.cardTitle">{{ t(headingKey ?? 'pricingPage.heading', undefined, { defaultValue: headingDefault ?? 'Choose your plan' }) }}</h1>
|
|
337
|
+
</header>
|
|
338
|
+
@if (showPeriodToggle !== false && hasYearly()) {
|
|
339
|
+
<div [class]="cm.flex({ direction: 'row', gap: 'sm', justify: 'center' })" data-mol-id="pricing-page-period-toggle" role="tablist" [attr.aria-label]="t('pricingPage.periodToggle.label', undefined, { defaultValue: 'Billing period' })">
|
|
340
|
+
<button type="button" role="tab" [attr.aria-selected]="period === 'month'" [class]="cm.button({ variant: period === 'month' ? 'solid' : 'outline', size: 'sm' })" (click)="period = 'month'" data-mol-id="pricing-page-period-month">{{ t('pricingPage.periodToggle.monthly', undefined, { defaultValue: 'Monthly' }) }}</button>
|
|
341
|
+
<button type="button" role="tab" [attr.aria-selected]="period === 'year'" [class]="cm.button({ variant: period === 'year' ? 'solid' : 'outline', size: 'sm' })" (click)="period = 'year'" data-mol-id="pricing-page-period-year">{{ t('pricingPage.periodToggle.yearly', undefined, { defaultValue: 'Yearly' }) }}</button>
|
|
342
|
+
</div>
|
|
343
|
+
}
|
|
344
|
+
<div [class]="cm.flex({ direction: 'row', wrap: 'wrap', gap: 'md', justify: 'center' })" data-mol-id="pricing-page-grid">
|
|
345
|
+
@for (tier of tiersList(); track tier.key) {
|
|
346
|
+
<article [class]="cm.card({ variant: 'default' })" [attr.data-mol-id]="'pricing-page-tier-' + tier.key">
|
|
347
|
+
<header [class]="cm.cardHeader">
|
|
348
|
+
<h2 [class]="cm.cardTitle">{{ tier.name }}</h2>
|
|
349
|
+
<p [class]="cm.cardDescription">{{ priceFor(tier)?.price ?? '—' }}@if (tier.perSeat) {<span>{{ ' ' + t('pricingPage.perSeat', undefined, { defaultValue: 'per seat' }) }}</span>}</p>
|
|
350
|
+
@if (priceFor(tier)?.savings) {
|
|
351
|
+
<p [class]="cm.cardDescription">{{ priceFor(tier)?.savings }}</p>
|
|
352
|
+
}
|
|
353
|
+
</header>
|
|
354
|
+
<div [class]="cm.cardContent">
|
|
355
|
+
@if (renderLimits) {
|
|
356
|
+
<ng-container [ngTemplateOutlet]="renderLimits" [ngTemplateOutletContext]="limitsContext(tier.limits)" />
|
|
357
|
+
} @else if (isObjectLimits(tier.limits)) {
|
|
358
|
+
<dl>
|
|
359
|
+
@for (entry of entries(tier.limits); track entry[0]) {
|
|
360
|
+
<div>
|
|
361
|
+
<dt>{{ entry[0] }}</dt>
|
|
362
|
+
<dd>{{ limitValue(entry[1]) }}</dd>
|
|
363
|
+
</div>
|
|
364
|
+
}
|
|
365
|
+
</dl>
|
|
366
|
+
}
|
|
367
|
+
</div>
|
|
368
|
+
<footer [class]="cm.cardFooter">
|
|
369
|
+
<button type="button" [class]="cm.cn(cm.button({ variant: 'solid', color: 'primary', size: 'lg', fullWidth: true }), cm.touchTargetCompact)" [disabled]="!priceFor(tier)?.stripePriceId || startState.loading()" (click)="fireCheckout(tier)" [attr.data-mol-id]="'pricing-page-cta-' + tier.key">@if (priceFor(tier)?.stripePriceId) {{{ t('pricingPage.upgradeCta', { tierName: tier.name }, { defaultValue: 'Upgrade to {{tierName}}' }) }}}@else {{{ t('pricingPage.currentCta', undefined, { defaultValue: 'Current plan' }) }}}</button>
|
|
370
|
+
</footer>
|
|
371
|
+
</article>
|
|
372
|
+
}
|
|
373
|
+
</div>
|
|
374
|
+
@if (startState.error()) {
|
|
375
|
+
<p [class]="cm.formError" role="alert" data-mol-id="pricing-page-checkout-error">{{ t('pricingPage.checkoutError', undefined, { defaultValue: 'Could not start checkout. Please try again.' }) }}</p>
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
`,
|
|
379
|
+
})
|
|
380
|
+
export class PricingPage implements OnInit, PricingPageProps {
|
|
381
|
+
/** Optional pre-fetched tiers. */
|
|
382
|
+
tiers?: PricingTierEntry<unknown>[]
|
|
383
|
+
|
|
384
|
+
/** Optional override for the checkout handler. */
|
|
385
|
+
onCheckout?: (tier: PricingTierEntry<unknown>, price: PricingTierPrice) => void | Promise<void>
|
|
386
|
+
|
|
387
|
+
/** When true (default), renders a monthly/yearly toggle. */
|
|
388
|
+
showPeriodToggle?: boolean
|
|
389
|
+
|
|
390
|
+
/** Default billing period for the toggle. */
|
|
391
|
+
defaultPeriod?: PricingPagePeriod
|
|
392
|
+
|
|
393
|
+
renderLimits?: TemplateRef<unknown> | null
|
|
394
|
+
|
|
395
|
+
/** Optional translation key for the page heading. */
|
|
396
|
+
headingKey?: string
|
|
397
|
+
|
|
398
|
+
/** Optional English fallback for the heading. */
|
|
399
|
+
headingDefault?: string
|
|
400
|
+
|
|
401
|
+
className?: string
|
|
402
|
+
|
|
403
|
+
private readonly i18n = useTranslation()
|
|
404
|
+
|
|
405
|
+
/** The translation function for the template. */
|
|
406
|
+
protected t = this.i18n.t
|
|
407
|
+
|
|
408
|
+
/** The bonded ClassMap (styling tokens resolve at render time). */
|
|
409
|
+
protected readonly cm: UIClassMap = getClassMap()
|
|
410
|
+
|
|
411
|
+
protected readonly tiersState = usePricingTiers<unknown>()
|
|
412
|
+
|
|
413
|
+
/** The checkout action and its async state. */
|
|
414
|
+
protected readonly startState = useStartCheckout()
|
|
415
|
+
|
|
416
|
+
protected period: PricingPagePeriod = 'month'
|
|
417
|
+
|
|
418
|
+
ngOnInit(): void {
|
|
419
|
+
this.period = this.defaultPeriod ?? 'month'
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
usingFetched(): boolean {
|
|
423
|
+
return this.tiers === undefined
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
tiersList(): PricingTierEntry<unknown>[] | null {
|
|
427
|
+
return this.tiers ?? this.tiersState.data()?.data ?? null
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
/** Whether the loading line shows (React's first early return). */
|
|
431
|
+
showLoading(): boolean {
|
|
432
|
+
return this.usingFetched() && this.tiersState.loading() && !this.tiersList()
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/** Whether the error line shows (React's second early return). */
|
|
436
|
+
showError(): boolean {
|
|
437
|
+
return this.usingFetched() && (this.tiersState.error() != null || !this.tiersList())
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
molId(): string {
|
|
441
|
+
if (this.showLoading()) return 'pricing-page-loading'
|
|
442
|
+
if (this.showError()) return 'pricing-page-error'
|
|
443
|
+
return 'pricing-page'
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/** Whether any tier carries a yearly price (the toggle needs one). */
|
|
447
|
+
hasYearly(): boolean {
|
|
448
|
+
return (this.tiersList() ?? []).some((tier) => tier.prices.some((p) => p.period === 'year'))
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
priceFor(tier: PricingTierEntry<unknown>): PricingTierPrice | undefined {
|
|
452
|
+
return tier.prices.find((p) => p.period === this.period) ?? tier.prices[0]
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
isObjectLimits(limits: unknown): limits is Record<string, unknown> {
|
|
456
|
+
return limits != null && typeof limits === 'object'
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/** The entries of a limits object, in insertion order. */
|
|
460
|
+
entries(limits: Record<string, unknown>): [string, unknown][] {
|
|
461
|
+
return Object.entries(limits)
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
limitValue(value: unknown): string {
|
|
465
|
+
if (typeof value === 'boolean') return value ? '✓' : '—'
|
|
466
|
+
if (typeof value === 'number') {
|
|
467
|
+
if (value >= 999_999) return '∞'
|
|
468
|
+
return value.toLocaleString()
|
|
469
|
+
}
|
|
470
|
+
if (value == null) return '—'
|
|
471
|
+
if (typeof value === 'string') return value
|
|
472
|
+
try {
|
|
473
|
+
return JSON.stringify(value)
|
|
474
|
+
} catch (_error) {
|
|
475
|
+
return String(value)
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
limitsContext(limits: unknown): { $implicit: unknown; a0: unknown } {
|
|
480
|
+
return { $implicit: limits, a0: limits }
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
fireCheckout(tier: PricingTierEntry<unknown>): void {
|
|
484
|
+
const price = this.priceFor(tier)
|
|
485
|
+
if (price) void this.handleCheckout(tier, price)
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
private async handleCheckout(
|
|
489
|
+
tier: PricingTierEntry<unknown>,
|
|
490
|
+
price: PricingTierPrice,
|
|
491
|
+
): Promise<void> {
|
|
492
|
+
if (!price.stripePriceId) return
|
|
493
|
+
if (this.onCheckout) {
|
|
494
|
+
await this.onCheckout(tier, price)
|
|
495
|
+
return
|
|
496
|
+
}
|
|
497
|
+
const response = await this.startState.start(price.stripePriceId)
|
|
498
|
+
if (response?.checkoutUrl && typeof window !== 'undefined') {
|
|
499
|
+
window.location.assign(response.checkoutUrl)
|
|
500
|
+
} else if (response?.updated && typeof window !== 'undefined') {
|
|
501
|
+
window.location.reload()
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
```
|
|
506
|
+
|
|
507
|
+
_(Member comments are shortened to their first sentence, and the 16 longest are left out to fit; the full declaration is in `node_modules/@molecule/app-pricing-page-angular/dist/pricing-page.component.d.ts`.)_
|
|
508
|
+
|
|
509
|
+
## Injection Notes
|
|
510
|
+
|
|
511
|
+
### Requirements
|
|
512
|
+
|
|
513
|
+
Peer dependencies:
|
|
514
|
+
|
|
515
|
+
- `@angular/common` ^22.0.0
|
|
516
|
+
- `@angular/core` ^22.0.0
|
|
517
|
+
- `@angular/platform-browser` ^22.0.0
|
|
518
|
+
- `@molecule/app-angular` ^3.5.0
|
|
519
|
+
- `@molecule/app-billing-angular` ^1.0.0
|
|
520
|
+
- `@molecule/app-subscription-plan-card-angular` ^1.0.0
|
|
521
|
+
- `@molecule/app-ui` ^1.1.0
|
|
522
|
+
- `@molecule/app-ui-angular` ^1.1.0
|
|
523
|
+
|
|
524
|
+
### Runtime Dependencies
|
|
525
|
+
|
|
526
|
+
- `@angular/common`
|
|
527
|
+
- `@angular/core`
|
|
528
|
+
- `@angular/platform-browser`
|
|
529
|
+
- `@molecule/app-angular`
|
|
530
|
+
- `@molecule/app-billing-angular`
|
|
531
|
+
- `@molecule/app-subscription-plan-card-angular`
|
|
532
|
+
- `@molecule/app-ui`
|
|
533
|
+
- `@molecule/app-ui-angular`
|
|
534
|
+
|
|
535
|
+
- Inputs are React's prop names; the `renderLimits` render function is a
|
|
536
|
+
template whose context carries the tier's limits as `$implicit` and
|
|
537
|
+
`a0`, and the node-valued `ctaLabel` is projected content
|
|
538
|
+
(`[slot=ctaLabel]`) or a string input.
|
|
539
|
+
- Each page's host IS the `<section>` React renders, so its class list and
|
|
540
|
+
`data-mol-id` are host bindings.
|
|
541
|
+
|
|
542
|
+
## Translations
|
|
10
543
|
|
|
11
|
-
|
|
544
|
+
Translation strings are provided by `@molecule/app-locales-pricing-page`.
|
package/dist/index.d.ts
CHANGED
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
* standalone: true,
|
|
39
39
|
* imports: [PlanUpdatedPage, PricingPage],
|
|
40
40
|
* template: `
|
|
41
|
-
* <section mol-pricing-page
|
|
42
|
-
* <section mol-plan-updated-page planName="Pro" ctaHref="/dashboard" ctaLabel="Go to dashboard"
|
|
41
|
+
* <section mol-pricing-page></section>
|
|
42
|
+
* <section mol-plan-updated-page planName="Pro" ctaHref="/dashboard" ctaLabel="Go to dashboard"></section>
|
|
43
43
|
* `,
|
|
44
44
|
* })
|
|
45
45
|
* export class PricingRoute {}
|
package/dist/index.js
CHANGED
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
* standalone: true,
|
|
39
39
|
* imports: [PlanUpdatedPage, PricingPage],
|
|
40
40
|
* template: `
|
|
41
|
-
* <section mol-pricing-page
|
|
42
|
-
* <section mol-plan-updated-page planName="Pro" ctaHref="/dashboard" ctaLabel="Go to dashboard"
|
|
41
|
+
* <section mol-pricing-page></section>
|
|
42
|
+
* <section mol-plan-updated-page planName="Pro" ctaHref="/dashboard" ctaLabel="Go to dashboard"></section>
|
|
43
43
|
* `,
|
|
44
44
|
* })
|
|
45
45
|
* export class PricingRoute {}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-pricing-page-angular",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Standalone public pricing page — tier cards, period toggle, checkout handoff (distinct from billing-react's PricingPage)",
|
|
5
5
|
"homepage": "https://www.molecule.dev/packages/app-pricing-page-angular",
|
|
6
6
|
"type": "module",
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"@angular/compiler-cli": "22.2.3",
|
|
60
60
|
"@angular/core": "22.2.3",
|
|
61
61
|
"@angular/platform-browser": "22.2.3",
|
|
62
|
-
"@molecule/app-angular": "3.
|
|
63
|
-
"@molecule/app-billing-angular": "1.
|
|
62
|
+
"@molecule/app-angular": "3.11.0",
|
|
63
|
+
"@molecule/app-billing-angular": "1.1.0",
|
|
64
64
|
"@molecule/app-framework-conformance": "0.0.0",
|
|
65
65
|
"@molecule/app-i18n": "1.2.2",
|
|
66
66
|
"@molecule/app-icons": "1.0.4",
|
|
67
67
|
"@molecule/app-subscription-plan-card-angular": "1.1.0",
|
|
68
|
-
"@molecule/app-ui": "1.
|
|
69
|
-
"@molecule/app-ui-angular": "1.
|
|
68
|
+
"@molecule/app-ui": "1.5.0",
|
|
69
|
+
"@molecule/app-ui-angular": "1.4.0",
|
|
70
70
|
"@types/node": "26.6.5",
|
|
71
71
|
"jsdom": "30.1.3",
|
|
72
72
|
"rxjs": "7.8.2",
|