@molecule/app-legal-pages-react 1.0.0 → 1.0.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.
Files changed (2) hide show
  1. package/README.md +532 -0
  2. package/package.json +14 -8
package/README.md ADDED
@@ -0,0 +1,532 @@
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-08-04T01:51:13.845Z
7
+ -->
8
+
9
+ # @molecule/app-legal-pages-react
10
+
11
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
+ > It is written to be read by coding agents as much as by people, and is generated from this
13
+ > package's source — edit `src/index.ts` JSDoc, not this file.
14
+
15
+ React page scaffolds for Terms, Privacy, and PlanUpdated.
16
+
17
+ Exports:
18
+
19
+ - Drop-in pages: `<TermsPage>`, `<PrivacyPage>` (boilerplate bodies with
20
+ configurable i18n keys), `<PlanUpdatedPage>` (post-checkout confirmation).
21
+ - Bonded-content pages: `<LegalContentPage kind="privacy" | "terms">` — renders
22
+ the SAME legal HTML as the footer modals (`content.privacyPolicy` /
23
+ `content.termsOfService` from `@molecule/app-locales-legal-default`), inside
24
+ the branded `<ContentPageShell>`.
25
+ - In-place modals: `<LegalModalLinks>` + `useLegalModals()` — Privacy/Terms
26
+ triggers that open modals instead of navigating.
27
+ - Primitives: `<ContentPageShell>` (hero band + surface card),
28
+ `<LegalPageLayout>`, `<LegalPageSection>`.
29
+
30
+ ## Quick Start
31
+
32
+ ```tsx
33
+ import { ContentPageShell, LegalPageLayout, LegalPageSection, TermsPage } from '@molecule/app-legal-pages-react'
34
+
35
+ // Drop-in Terms page (boilerplate body):
36
+ <TermsPage />
37
+
38
+ // Custom Terms page with structured sections:
39
+ <ContentPageShell eyebrow="Legal" title="Terms of Service" subtitle="Last updated June 2025">
40
+ <LegalPageLayout title="Terms of Service">
41
+ <LegalPageSection title="Acceptance">
42
+ <p>By using this service you agree to these terms.</p>
43
+ </LegalPageSection>
44
+ </LegalPageLayout>
45
+ </ContentPageShell>
46
+ ```
47
+
48
+ ## Type
49
+
50
+ `feature`
51
+
52
+ ## Installation
53
+
54
+ ```bash
55
+ npm install @molecule/app-legal-pages-react @molecule/app-react @molecule/app-ui @molecule/app-ui-react react react-router
56
+ npm install -D @types/react
57
+ ```
58
+
59
+ ## API
60
+
61
+ ### Interfaces
62
+
63
+ #### `ContentPageShellProps`
64
+
65
+ Props for {@link ContentPageShell}.
66
+
67
+ ```typescript
68
+ interface ContentPageShellProps {
69
+ /** `data-mol-id` applied to the hero `<header>` for AI-agent selectors. */
70
+ dataMolId?: string
71
+ /** Small uppercase label above the title (e.g. "Legal", "Billing"). */
72
+ eyebrow?: ReactNode
73
+ /**
74
+ * Page title, rendered in the app's headline font inside the hero band.
75
+ * Omit to skip the hero entirely (e.g. for content that renders its own
76
+ * heading, like a pricing tier grid).
77
+ */
78
+ title?: ReactNode
79
+ /** Optional supporting line under the title (e.g. "Last updated …"). */
80
+ subtitle?: ReactNode
81
+ /** App-specific top navigation, rendered above the hero. */
82
+ header?: ReactNode
83
+ /** App-specific footer, rendered below the content. */
84
+ footer?: ReactNode
85
+ /** Page body. Rendered inside a surface card unless {@link bare} is set. */
86
+ children: ReactNode
87
+ /**
88
+ * When true, the body is rendered without the surface card wrapper — for
89
+ * content that brings its own surfaces (e.g. a pricing tier grid).
90
+ */
91
+ bare?: boolean
92
+ /** Container width passed to ClassMap `container({ size })`. Defaults to `'md'`. */
93
+ containerSize?: 'sm' | 'md' | 'lg' | 'xl'
94
+ }
95
+ ```
96
+
97
+ #### `LegalContentPageProps`
98
+
99
+ Props for {@link LegalContentPage}.
100
+
101
+ ```typescript
102
+ interface LegalContentPageProps {
103
+ /** Which legal document to render. */
104
+ kind: LegalKind
105
+ /** App name interpolated into the policy body (privacy uses `{{appName}}`). */
106
+ appName?: string
107
+ /**
108
+ * Lazy-loader for the legal HTML (pass `loadContent` from the app's
109
+ * `src/config.ts`, which re-exports it from
110
+ * `@molecule/app-locales-legal-default`). Called once on mount so the
111
+ * standalone page shows the **same** bonded content as the footer modal.
112
+ */
113
+ loadContent?: (key: 'privacyPolicy' | 'termsOfService') => Promise<void> | void
114
+ /** App-specific top navigation, rendered above the hero. */
115
+ header?: ReactNode
116
+ /** App-specific footer, rendered below the content. */
117
+ footer?: ReactNode
118
+ /** i18n key for the small uppercase eyebrow. Defaults to `nav.legal`. */
119
+ eyebrowKey?: string
120
+ /** Default eyebrow text. Defaults to `Legal`. */
121
+ eyebrowDefault?: string
122
+ }
123
+ ```
124
+
125
+ #### `LegalModalLinksProps`
126
+
127
+ Props for {@link LegalModalLinks}.
128
+
129
+ ```typescript
130
+ interface LegalModalLinksProps extends UseLegalModalsOptions {
131
+ /** className applied to each trigger `<button>` (match the footer's link style). */
132
+ linkClassName?: string
133
+ /** Which links to render. Defaults to `'both'`. */
134
+ show?: 'both' | 'privacy' | 'terms'
135
+ /** Override the Privacy label (defaults to i18n `footer.privacyPolicy`). */
136
+ privacyLabel?: ReactNode
137
+ /** Override the Terms label (defaults to i18n `footer.termsOfService`). */
138
+ termsLabel?: ReactNode
139
+ }
140
+ ```
141
+
142
+ #### `LegalModalsApi`
143
+
144
+ Imperative API returned by {@link useLegalModals}.
145
+
146
+ ```typescript
147
+ interface LegalModalsApi {
148
+ /** Open the Privacy Policy modal (loads content first). */
149
+ openPrivacy: () => Promise<void>
150
+ /** Open the Terms of Service modal (loads content first). */
151
+ openTerms: () => Promise<void>
152
+ /** The two `<Modal>` elements — render once anywhere in the tree. */
153
+ modals: JSX.Element
154
+ }
155
+ ```
156
+
157
+ #### `LegalPageLayoutProps`
158
+
159
+ Props for {@link LegalPageLayout}.
160
+
161
+ ```typescript
162
+ interface LegalPageLayoutProps {
163
+ /** `data-mol-id` for AI agent selectors. */
164
+ dataMolId?: string
165
+ /** Rendered heading text (usually `t('...')`). */
166
+ title: ReactNode
167
+ /** Body content — paragraphs, `<LegalPageSection>`s, etc. */
168
+ children: ReactNode
169
+ /** ClassMap `container({size})` value. Defaults to `'md'`. */
170
+ containerSize?: 'sm' | 'md' | 'lg' | 'xl'
171
+ /** Stack gap between body children passed to ClassMap `stack()`. Defaults to 4. */
172
+ stackGap?: SpacingScale
173
+ /** Override the main wrapper's className (used by apps with custom chrome). */
174
+ mainClassName?: string
175
+ /** Override the body wrapper's className. */
176
+ bodyClassName?: string
177
+ }
178
+ ```
179
+
180
+ #### `LegalPageSectionProps`
181
+
182
+ Props for {@link LegalPageSection}.
183
+
184
+ ```typescript
185
+ interface LegalPageSectionProps {
186
+ /** Rendered heading text. */
187
+ title: ReactNode
188
+ /** Section body — one or more paragraphs. */
189
+ children: ReactNode
190
+ /** Stack gap between heading and body (ClassMap `stack()`). Defaults to 2. */
191
+ stackGap?: SpacingScale
192
+ }
193
+ ```
194
+
195
+ #### `PlanUpdatedPageProps`
196
+
197
+ Props for {@link PlanUpdatedPage}.
198
+
199
+ ```typescript
200
+ interface PlanUpdatedPageProps {
201
+ /** i18n key for the primary message heading. */
202
+ messageKey?: string
203
+ /** Default message when the key is missing. */
204
+ messageDefault?: string
205
+ /** i18n key for the secondary heading. */
206
+ thankYouKey?: string
207
+ /** Default thank-you text when the key is missing. */
208
+ thankYouDefault?: string
209
+ /** i18n key for the action-button label. */
210
+ actionKey?: string
211
+ /** Default action label when the key is missing. */
212
+ actionDefault?: string
213
+ /** Href the action button navigates to. Defaults to `/`. */
214
+ actionHref?: string
215
+ }
216
+ ```
217
+
218
+ #### `PrivacyPageProps`
219
+
220
+ Props for {@link PrivacyPage}.
221
+
222
+ ```typescript
223
+ interface PrivacyPageProps {
224
+ /** i18n key for the page heading. Defaults to `privacy.title`. */
225
+ titleKey?: string
226
+ /** Default for the heading when the key is missing. Defaults to `"Privacy"`. */
227
+ titleDefault?: string
228
+ /** i18n key for the single-paragraph intro (ignored when `children` is passed). */
229
+ introKey?: string
230
+ /** Default intro body when the key is missing. */
231
+ introDefault?: string
232
+ /** Optional override body — use when the page has real content. */
233
+ children?: ReactNode
234
+ /** Stack gap between body children. */
235
+ stackGap?: SpacingScale
236
+ }
237
+ ```
238
+
239
+ #### `TermsPageProps`
240
+
241
+ Props for {@link TermsPage}.
242
+
243
+ ```typescript
244
+ interface TermsPageProps {
245
+ /** i18n key for the page heading. Defaults to `terms.title`. */
246
+ titleKey?: string
247
+ /** Default for the heading when the i18n key is missing. Defaults to `"Terms"`. */
248
+ titleDefault?: string
249
+ /** i18n key for the single-paragraph intro (ignored when `children` is passed). */
250
+ introKey?: string
251
+ /** Default intro body when the key is missing. */
252
+ introDefault?: string
253
+ /** Optional override body — use when the page has real content, not boilerplate. */
254
+ children?: ReactNode
255
+ /** Stack gap between body children. */
256
+ stackGap?: SpacingScale
257
+ }
258
+ ```
259
+
260
+ #### `UseLegalModalsOptions`
261
+
262
+ Shared options for the legal-modal hook + component.
263
+
264
+ ```typescript
265
+ interface UseLegalModalsOptions {
266
+ /** App name interpolated into the privacy AND terms bodies (`{{appName}}`). */
267
+ appName?: string
268
+ /**
269
+ * Lazy-loader for the legal HTML — pass `loadContent` from the app's
270
+ * `src/config.ts`. Called right before a modal opens so the bonded
271
+ * content is present on first render.
272
+ */
273
+ loadContent?: (key: 'privacyPolicy' | 'termsOfService') => Promise<void> | void
274
+ }
275
+ ```
276
+
277
+ ### Types
278
+
279
+ #### `LegalKind`
280
+
281
+ Which legal document a {@link LegalContentPage} renders.
282
+
283
+ ```typescript
284
+ type LegalKind = 'privacy' | 'terms'
285
+ ```
286
+
287
+ ### Functions
288
+
289
+ #### `ContentPageShell(props)`
290
+
291
+ Branded shell for public content pages (Privacy, Terms, Pricing,
292
+ PlanUpdated, …).
293
+
294
+ Renders the app's own `header`/`footer` slots around a themed hero band
295
+ (eyebrow + title + subtitle) and a surface-card content area. Everything
296
+ is driven by theme tokens (`--mol-color-*`) and the app's font utility
297
+ classes (`font-display` for the title, `font-body`/`font-label` for the
298
+ rest), so each app's palette and typography are applied automatically
299
+ without per-app overrides.
300
+
301
+ ```typescript
302
+ function ContentPageShell({
303
+ dataMolId,
304
+ eyebrow,
305
+ title,
306
+ subtitle,
307
+ header,
308
+ footer,
309
+ children,
310
+ bare = false,
311
+ containerSize = 'md',
312
+ }: ContentPageShellProps): JSX.Element
313
+ ```
314
+
315
+ - `props` — See {@link ContentPageShellProps}.
316
+
317
+ **Returns:** The rendered content-page shell.
318
+
319
+ #### `LegalContentPage(props)`
320
+
321
+ Standalone Privacy / Terms page that renders the **same** bonded legal
322
+ HTML the footer modal shows (`content.privacyPolicy` /
323
+ `content.termsOfService` from `@molecule/app-locales-legal-default`),
324
+ wrapped in the branded {@link ContentPageShell}.
325
+
326
+ This keeps the in-place footer modal and the standalone `/privacy`,
327
+ `/terms` routes perfectly in sync — one source of legal copy, two
328
+ surfaces. Drop one of these into each app's `pages/Privacy.tsx` /
329
+ `pages/Terms.tsx`, passing the app's own header/footer chrome.
330
+
331
+ ```typescript
332
+ function LegalContentPage({
333
+ kind,
334
+ appName,
335
+ loadContent,
336
+ header,
337
+ footer,
338
+ eyebrowKey = 'nav.legal',
339
+ eyebrowDefault = 'Legal',
340
+ }: LegalContentPageProps): JSX.Element
341
+ ```
342
+
343
+ - `props` — See {@link LegalContentPageProps}.
344
+
345
+ **Returns:** The rendered legal content page.
346
+
347
+ #### `LegalModalLinks(props)`
348
+
349
+ Drop-in Privacy/Terms links that open IN-PLACE modals instead of
350
+ navigating — for bespoke footers and signup pages. Replace
351
+ `<Link to="/privacy">Privacy</Link>` / `<Link to="/terms">Terms</Link>`
352
+ with `<LegalModalLinks linkClassName={...} appName={APP_NAME} loadContent={loadContent} />`.
353
+
354
+ Renders the trigger button(s) + the modals together, so it suits the
355
+ common case where the two legal links are adjacent. For separated
356
+ triggers, use {@link useLegalModals} directly.
357
+
358
+ ```typescript
359
+ function LegalModalLinks({
360
+ linkClassName,
361
+ show = 'both',
362
+ privacyLabel,
363
+ termsLabel,
364
+ ...opts
365
+ }: LegalModalLinksProps): JSX.Element
366
+ ```
367
+
368
+ - `props` — See {@link LegalModalLinksProps}.
369
+
370
+ **Returns:** The trigger button(s) and their modals.
371
+
372
+ #### `LegalPageLayout(props)`
373
+
374
+ Canonical Terms / Privacy layout shell.
375
+
376
+ `<main data-mol-id={...} class="container py-12">
377
+ <h1>{title}</h1>
378
+ <div class="prose stack">{children}</div>
379
+ </main>`
380
+
381
+ Use this as the content shell for legal pages. Custom chrome (landing
382
+ top-nav, admin sidebar, etc.) should wrap the shell at the call site.
383
+
384
+ ```typescript
385
+ function LegalPageLayout({
386
+ dataMolId,
387
+ title,
388
+ children,
389
+ containerSize = 'md',
390
+ stackGap = 4,
391
+ mainClassName,
392
+ bodyClassName,
393
+ }: LegalPageLayoutProps): JSX.Element
394
+ ```
395
+
396
+ - `props` — Component props (see {@link LegalPageLayoutProps}).
397
+
398
+ #### `LegalPageSection(props)`
399
+
400
+ One sub-section of a legal page (`h2` + body) styled for use inside
401
+ `<LegalPageLayout>`.
402
+
403
+ ```typescript
404
+ function LegalPageSection({ title, children, stackGap = 2 }: LegalPageSectionProps): JSX.Element
405
+ ```
406
+
407
+ - `props` — Component props (see {@link LegalPageSectionProps}).
408
+
409
+ #### `PlanUpdatedPage(props)`
410
+
411
+ "Plan updated" confirmation screen.
412
+
413
+ Waits for auth state to initialize, then shows a two-line confirmation
414
+ with a single return-home action. i18n keys are configurable so apps
415
+ can match their existing locale shape.
416
+
417
+ ```typescript
418
+ function PlanUpdatedPage({
419
+ messageKey = 'planUpdated.message',
420
+ messageDefault = 'Your plan has been updated.',
421
+ thankYouKey = 'planUpdated.thankYou',
422
+ thankYouDefault = 'Thank you!',
423
+ actionKey = 'planUpdated.returnHome',
424
+ actionDefault = 'Return to Home',
425
+ actionHref = '/',
426
+ }?: PlanUpdatedPageProps): JSX.Element
427
+ ```
428
+
429
+ - `props` — Component props (see {@link PlanUpdatedPageProps}).
430
+
431
+ #### `PrivacyPage(props)`
432
+
433
+ Default Privacy-policy page scaffold.
434
+
435
+ With no props, renders the canonical boilerplate Privacy page.
436
+ Pass `children` to render real content.
437
+
438
+ ```typescript
439
+ function PrivacyPage({
440
+ titleKey = 'privacy.title',
441
+ titleDefault = 'Privacy',
442
+ introKey = 'privacy.intro',
443
+ introDefault = 'This is the Privacy page. Replace this placeholder with real content.',
444
+ children,
445
+ stackGap,
446
+ }: PrivacyPageProps): JSX.Element
447
+ ```
448
+
449
+ - `props` — Component props (see {@link PrivacyPageProps}).
450
+
451
+ #### `TermsPage(props)`
452
+
453
+ Default Terms-of-service page scaffold.
454
+
455
+ With no props, renders the canonical boilerplate Terms
456
+ (`<main><h1>{t('terms.title')}</h1><p>{t('terms.intro')}</p></main>`).
457
+ Pass `children` to render real content (e.g. `<LegalPageSection>`s).
458
+
459
+ ```typescript
460
+ function TermsPage({
461
+ titleKey = 'terms.title',
462
+ titleDefault = 'Terms',
463
+ introKey = 'terms.intro',
464
+ introDefault = 'This is the Terms page. Replace this placeholder with real content.',
465
+ children,
466
+ stackGap,
467
+ }: TermsPageProps): JSX.Element
468
+ ```
469
+
470
+ - `props` — Component props (see {@link TermsPageProps}).
471
+
472
+ #### `useLegalModals(options)`
473
+
474
+ Headless hook powering in-place Privacy/Terms modals. Use it when the
475
+ triggers live in different parts of a bespoke footer (or a signup
476
+ page); place `{modals}` once and wire `openPrivacy`/`openTerms` to your
477
+ own links/buttons.
478
+
479
+ The modal body is the SAME bonded HTML the {@link LegalContentPage}
480
+ standalone routes render (`content.privacyPolicy` /
481
+ `content.termsOfService`), so every legal surface stays in sync.
482
+
483
+ ```typescript
484
+ function useLegalModals({ appName, loadContent }?: UseLegalModalsOptions): LegalModalsApi
485
+ ```
486
+
487
+ - `options` — See {@link UseLegalModalsOptions}.
488
+
489
+ **Returns:** Imperative {@link LegalModalsApi}.
490
+
491
+ ## Injection Notes
492
+
493
+ ### Requirements
494
+
495
+ Peer dependencies:
496
+
497
+ - `@molecule/app-react` ^1.0.1
498
+ - `@molecule/app-ui` ^1.0.1
499
+ - `@molecule/app-ui-react` ^1.0.1
500
+ - `react` ^18.0.0 || ^19.0.0
501
+ - `react-router` ^7.0.0 || ^8.0.0
502
+
503
+ ### Runtime Dependencies
504
+
505
+ - `@molecule/app-react`
506
+ - `@molecule/app-ui`
507
+ - `@molecule/app-ui-react`
508
+ - `react`
509
+ - `react-router`
510
+
511
+ - `LegalContentPage` / `useLegalModals` render bonded HTML that defaults to an
512
+ EMPTY string until the locale module is registered — pass your app's
513
+ `loadContent` (from `src/config.ts`, re-exporting
514
+ `@molecule/app-locales-legal-default`) or the page/modal body will be blank.
515
+ - `PlanUpdatedPage` requires BOTH a react-router `<Router>` ancestor (it renders
516
+ a `<Link>`) and wired auth state from `@molecule/app-react` — without an auth
517
+ provider it shows a spinner forever (`state.initialized` never flips). The
518
+ rest of the package is router-free.
519
+ - **Name collision:** `PlanUpdatedPage` is also exported by
520
+ `@molecule/app-pricing-page-react` (the pricing-page-flavored success page), and a
521
+ standalone `<PlanUpdated>` lives in `@molecule/app-plan-updated-page-react`. THIS
522
+ package's `<PlanUpdatedPage>` is the legal-pages-kit confirmation page — import it
523
+ from `@molecule/app-legal-pages-react` when you use this kit's other pages.
524
+ - `ContentPageShell`'s hero reads `var(--mol-color-primary)` and
525
+ `var(--mol-color-background)` with no fallback, and uses Tailwind theme
526
+ utilities (`font-display`, `bg-background`, `border-outline-variant`) — the
527
+ app theme must define the `--mol-color-` override tokens and font utilities
528
+ or the hero band renders unstyled.
529
+ - `TermsPage`/`PrivacyPage` default keys (`terms.title`, `terms.intro`,
530
+ `privacy.title`, `privacy.intro`) and the `nav.legal` eyebrow ship in no
531
+ locale bond — the English `defaultValue`s render unless your app defines
532
+ those keys (all keys are overridable via props).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/app-legal-pages-react",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "React page scaffolds for Terms, Privacy, and PlanUpdated (i18n-driven, customizable keys)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -17,7 +17,8 @@
17
17
  }
18
18
  },
19
19
  "files": [
20
- "dist"
20
+ "dist",
21
+ "README.md"
21
22
  ],
22
23
  "keywords": [
23
24
  "molecule",
@@ -26,17 +27,22 @@
26
27
  "react"
27
28
  ],
28
29
  "license": "Apache-2.0",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/molecule-dev/molecule.git",
33
+ "directory": "packages/app/features/legal-pages-react"
34
+ },
29
35
  "peerDependencies": {
30
- "@molecule/app-react": "^1.0.0",
31
- "@molecule/app-ui": "^1.0.0",
32
- "@molecule/app-ui-react": "^1.0.0",
36
+ "@molecule/app-react": "^1.0.1",
37
+ "@molecule/app-ui": "^1.0.1",
38
+ "@molecule/app-ui-react": "^1.0.1",
33
39
  "react": "^18.0.0 || ^19.0.0",
34
40
  "react-router": "^7.0.0 || ^8.0.0"
35
41
  },
36
42
  "devDependencies": {
37
- "@molecule/app-react": "1.0.0",
38
- "@molecule/app-ui": "1.0.0",
39
- "@molecule/app-ui-react": "1.0.0",
43
+ "@molecule/app-react": "1.0.1",
44
+ "@molecule/app-ui": "1.0.1",
45
+ "@molecule/app-ui-react": "1.0.1",
40
46
  "@types/node": "26.1.2",
41
47
  "@types/react": "19.2.17",
42
48
  "@types/react-dom": "19.2.3",