@molecule/app-settings-panel-react 1.0.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.
Files changed (42) hide show
  1. package/LICENSE +115 -0
  2. package/README.md +487 -0
  3. package/dist/AccountSection.d.ts +15 -0
  4. package/dist/AccountSection.d.ts.map +1 -0
  5. package/dist/AccountSection.js +83 -0
  6. package/dist/AppearanceSection.d.ts +10 -0
  7. package/dist/AppearanceSection.d.ts.map +1 -0
  8. package/dist/AppearanceSection.js +17 -0
  9. package/dist/AuthSection.d.ts +19 -0
  10. package/dist/AuthSection.d.ts.map +1 -0
  11. package/dist/AuthSection.js +141 -0
  12. package/dist/BillingSection.d.ts +19 -0
  13. package/dist/BillingSection.d.ts.map +1 -0
  14. package/dist/BillingSection.js +49 -0
  15. package/dist/DevicesSection.d.ts +30 -0
  16. package/dist/DevicesSection.d.ts.map +1 -0
  17. package/dist/DevicesSection.js +76 -0
  18. package/dist/LogOutDeleteSection.d.ts +10 -0
  19. package/dist/LogOutDeleteSection.d.ts.map +1 -0
  20. package/dist/LogOutDeleteSection.js +50 -0
  21. package/dist/NotificationsSection.d.ts +16 -0
  22. package/dist/NotificationsSection.d.ts.map +1 -0
  23. package/dist/NotificationsSection.js +93 -0
  24. package/dist/SettingsContainer.d.ts +12 -0
  25. package/dist/SettingsContainer.d.ts.map +1 -0
  26. package/dist/SettingsContainer.js +15 -0
  27. package/dist/ThisDeviceSection.d.ts +9 -0
  28. package/dist/ThisDeviceSection.d.ts.map +1 -0
  29. package/dist/ThisDeviceSection.js +16 -0
  30. package/dist/TiersUpgradeSection.d.ts +15 -0
  31. package/dist/TiersUpgradeSection.d.ts.map +1 -0
  32. package/dist/TiersUpgradeSection.js +120 -0
  33. package/dist/context.d.ts +18 -0
  34. package/dist/context.d.ts.map +1 -0
  35. package/dist/context.js +15 -0
  36. package/dist/index.d.ts +85 -0
  37. package/dist/index.d.ts.map +1 -0
  38. package/dist/index.js +84 -0
  39. package/dist/pushToggle.d.ts +111 -0
  40. package/dist/pushToggle.d.ts.map +1 -0
  41. package/dist/pushToggle.js +170 -0
  42. package/package.json +50 -0
package/LICENSE ADDED
@@ -0,0 +1,115 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship.
43
+
44
+ "Contribution" shall mean any work of authorship, including the
45
+ original version of the Work and any modifications or additions
46
+ to that Work, that is intentionally submitted to the Licensor for
47
+ inclusion in the Work by the copyright owner or by an individual or
48
+ Legal Entity authorized to submit on behalf of the copyright owner.
49
+
50
+ "Contributor" shall mean Licensor and any individual or Legal Entity
51
+ on behalf of whom a Contribution has been received by the Licensor and
52
+ subsequently incorporated within the Work.
53
+
54
+ 2. Grant of Copyright License. Subject to the terms and conditions of
55
+ this License, each Contributor hereby grants to You a perpetual,
56
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
57
+ copyright license to reproduce, prepare Derivative Works of,
58
+ publicly display, publicly perform, sublicense, and distribute the
59
+ Work and such Derivative Works in Source or Object form.
60
+
61
+ 3. Grant of Patent License. Subject to the terms and conditions of
62
+ this License, each Contributor hereby grants to You a perpetual,
63
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
64
+ patent license to make, have made, use, offer to sell, sell, import,
65
+ and otherwise transfer the Work.
66
+
67
+ 4. Redistribution. You may reproduce and distribute copies of the
68
+ Work or Derivative Works thereof in any medium, with or without
69
+ modifications, and in Source or Object form, provided that You
70
+ meet the following conditions:
71
+
72
+ (a) You must give any other recipients of the Work or
73
+ Derivative Works a copy of this License; and
74
+
75
+ (b) You must cause any modified files to carry prominent notices
76
+ stating that You changed the files; and
77
+
78
+ (c) You must retain, in the Source form of any Derivative Works
79
+ that You distribute, all copyright, patent, trademark, and
80
+ attribution notices from the Source form of the Work,
81
+ excluding those notices that do not pertain to any part of
82
+ the Derivative Works; and
83
+
84
+ (d) If the Work includes a "NOTICE" text file as part of its
85
+ distribution, then any Derivative Works that You distribute must
86
+ include a readable copy of the attribution notices contained
87
+ within such NOTICE file.
88
+
89
+ 5. Submission of Contributions.
90
+
91
+ 6. Trademarks. This License does not grant permission to use the trade
92
+ names, trademarks, service marks, or product names of the Licensor.
93
+
94
+ 7. Disclaimer of Warranty. Unless required by applicable law or
95
+ agreed to in writing, Licensor provides the Work on an "AS IS" BASIS,
96
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND.
97
+
98
+ 8. Limitation of Liability. In no event and under no legal theory shall
99
+ any Contributor be liable to You for damages.
100
+
101
+ 9. Accepting Warranty or Additional Liability.
102
+
103
+ Copyright 2026 Molecule Dev, Inc.
104
+
105
+ Licensed under the Apache License, Version 2.0 (the "License");
106
+ you may not use this file except in compliance with the License.
107
+ You may obtain a copy of the License at
108
+
109
+ http://www.apache.org/licenses/LICENSE-2.0
110
+
111
+ Unless required by applicable law or agreed to in writing, software
112
+ distributed under the License is distributed on an "AS IS" BASIS,
113
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
114
+ See the License for the specific language governing permissions and
115
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,487 @@
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-04T00:41:05.064Z
7
+ -->
8
+
9
+ # @molecule/app-settings-panel-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
+ `@molecule/app-settings-panel-react` — composable, batteries-included
16
+ settings panel.
17
+
18
+ `<SettingsContainer onClose={…}>` owns the layout and publishes `onClose`
19
+ via context; each section component is independent and loads its own data
20
+ through hooks:
21
+
22
+ - `<AccountSection>` — name/email edit (`PATCH /api/users/:id`).
23
+ - `<AppearanceSection>` — dark-mode toggle (`useTheme()`).
24
+ - `<AuthSection>` — password change + TOTP two-factor
25
+ (`POST /api/users/:id/verify-two-factor`).
26
+ - `<NotificationsSection>` — web-push toggle (see the exported
27
+ `enablePushOnCurrentDevice` / `disablePushOnCurrentDevice` helpers and
28
+ their documented device-row contract).
29
+ - `<BillingSection>` — read-only plan display (`GET /api/billing/status`),
30
+ or `<TiersUpgradeSection>` — full Stripe upgrade/cancel flow
31
+ (`/api/billing/tiers|checkout|cancel`). Use one or the other, not both.
32
+ - `<DevicesSection>` / `<ThisDeviceSection>` — device list + current
33
+ device (`GET/DELETE /api/devices`).
34
+ - `<LogOutDeleteSection>` — sign out + delete account
35
+ (`DELETE /api/users/:id`).
36
+ Apps compose via JSX children — pick sections, order them, and interleave
37
+ custom sections.
38
+
39
+ ## Quick Start
40
+
41
+ ```tsx
42
+ import {
43
+ AccountSection,
44
+ AppearanceSection,
45
+ AuthSection,
46
+ BillingSection,
47
+ DevicesSection,
48
+ LogOutDeleteSection,
49
+ NotificationsSection,
50
+ SettingsContainer,
51
+ ThisDeviceSection,
52
+ } from '@molecule/app-settings-panel-react'
53
+
54
+ function SettingsPanel({ onClose }: { onClose: () => void }) {
55
+ return (
56
+ <SettingsContainer onClose={onClose}>
57
+ <AccountSection />
58
+ <AppearanceSection />
59
+ <AuthSection />
60
+ <NotificationsSection />
61
+ <BillingSection />
62
+ <DevicesSection />
63
+ <ThisDeviceSection />
64
+ <LogOutDeleteSection />
65
+ </SettingsContainer>
66
+ )
67
+ }
68
+ ```
69
+
70
+ ## Type
71
+
72
+ `feature`
73
+
74
+ ## Installation
75
+
76
+ ```bash
77
+ npm install @molecule/app-settings-panel-react @molecule/app-auth @molecule/app-react @molecule/app-ui @molecule/app-ui-react react react-router
78
+ npm install -D @types/react
79
+ ```
80
+
81
+ ## API
82
+
83
+ ### Interfaces
84
+
85
+ #### `Device`
86
+
87
+ A user's registered device (subset rendered in the settings list).
88
+
89
+ ```typescript
90
+ interface Device {
91
+ id: string
92
+ name: string
93
+ platform: string
94
+ lastSeen?: string
95
+ /** `true` for the device making the current request (the API marks it). */
96
+ isCurrent?: boolean
97
+ }
98
+ ```
99
+
100
+ #### `PushToggleDevice`
101
+
102
+ Device row slice returned by `GET /api/devices`.
103
+
104
+ ```typescript
105
+ interface PushToggleDevice {
106
+ id: string
107
+ isCurrent?: boolean
108
+ hasPushSubscription?: boolean
109
+ }
110
+ ```
111
+
112
+ #### `PushToggleHttp`
113
+
114
+ Minimal structural slice of `@molecule/app-http`'s HttpClient used here.
115
+
116
+ ```typescript
117
+ interface PushToggleHttp {
118
+ get<T = unknown>(url: string): Promise<{ data: T }>
119
+ patch<T = unknown>(url: string, data?: unknown): Promise<{ data: T }>
120
+ }
121
+ ```
122
+
123
+ #### `PushToggleToken`
124
+
125
+ Push token slice returned by `@molecule/app-push` `register()`.
126
+
127
+ ```typescript
128
+ interface PushToggleToken {
129
+ value: string
130
+ platform: 'web' | 'ios' | 'android'
131
+ }
132
+ ```
133
+
134
+ #### `SettingsPanelContextValue`
135
+
136
+ Context published by `<SettingsContainer>` to its children.
137
+
138
+ The container owns the dismiss-the-panel handler; sub-components
139
+ that need to close after an action (logout, delete account, email
140
+ error) read it from context rather than threading the prop down.
141
+
142
+ ```typescript
143
+ interface SettingsPanelContextValue {
144
+ onClose: () => void
145
+ }
146
+ ```
147
+
148
+ ### Types
149
+
150
+ #### `PushToggleFailureReason`
151
+
152
+ Why an enable/disable attempt failed (mapped to i18n by the component).
153
+
154
+ ```typescript
155
+ type PushToggleFailureReason =
156
+ 'permission-denied' | 'server-unconfigured' | 'register-failed' | 'persist-failed'
157
+ ```
158
+
159
+ #### `PushToggleResult`
160
+
161
+ Result of an enable/disable attempt.
162
+
163
+ ```typescript
164
+ type PushToggleResult =
165
+ { ok: true } | { ok: false; reason: PushToggleFailureReason; message?: string }
166
+ ```
167
+
168
+ ### Functions
169
+
170
+ #### `AccountSection()`
171
+
172
+ Account section — edits the user's display name + email. Fetches
173
+ `/users/me` on mount to refresh the current user record (and write it
174
+ back to the auth cache so subsequent reloads see the latest data). On
175
+ blur of either field, PATCHes `/api/users/:id` with the changed field;
176
+ reverts + shows an inline error if the request fails.
177
+
178
+ The user resource's update handler accepts `name`, `username`, and
179
+ `email`; this surfaces `name` + `email` (the universally-present
180
+ profile fields). Apps that use a public `username` handle can extend
181
+ this with a username field the same way.
182
+
183
+ ```typescript
184
+ function AccountSection(): JSX.Element
185
+ ```
186
+
187
+ #### `AppearanceSection()`
188
+
189
+ Appearance section — dark-mode toggle wired to the theme bond.
190
+
191
+ Apps that expose other appearance knobs (font size, density, etc.)
192
+ can either add more sub-components to this package or render their
193
+ own section in line with `<AppearanceSection>` via children.
194
+
195
+ ```typescript
196
+ function AppearanceSection(): JSX.Element
197
+ ```
198
+
199
+ #### `AuthSection()`
200
+
201
+ Authentication section — change password (modal) + two-factor (TOTP) setup.
202
+
203
+ Two-factor uses the real enrollment flow against the user resource's
204
+ `POST /users/:id/verify-two-factor` endpoint (`@molecule/api-two-factor`):
205
+
206
+ - Enable → `{action:'setup'}` returns a QR code + secret to scan into an
207
+ authenticator app → user enters the 6-digit code → `{action:'enable', token}`.
208
+ - Disable → user enters a current code → `{action:'disable', token}`.
209
+ The current status is read from `/users/me`. (This replaces the previous
210
+ boolean toggle, which PATCHed `twoFactorEnabled` — a field the update
211
+ handler deliberately ignores — so it never actually enrolled 2FA.)
212
+
213
+ Auto-hides for OAuth-only users (`user.oauthServer` truthy) since
214
+ password / 2FA wouldn't apply. If the app's API has no two-factor
215
+ provider bonded, setup fails gracefully with an inline message.
216
+
217
+ ```typescript
218
+ function AuthSection(): JSX.Element | null
219
+ ```
220
+
221
+ #### `BillingSection(props?)`
222
+
223
+ Billing section — current plan + Upgrade button.
224
+
225
+ Fetches `/api/billing/status` on mount and uses the returned plan
226
+ name as a more accurate label than the parent-supplied default.
227
+ The `plan` prop remains a fallback (e.g. for offline rendering or
228
+ apps that don't expose `/billing/status`).
229
+
230
+ The Upgrade button navigates to `upgradeTo` (default `/settings`).
231
+ Pass `upgradeTo="/billing"` or `upgradeTo="/pricing"` if your app
232
+ routes elsewhere. Apps with a multi-tier checkout flow should use
233
+ `<TiersUpgradeSection>` instead.
234
+
235
+ ```typescript
236
+ function BillingSection({
237
+ plan = 'Free',
238
+ upgradeTo = '/settings',
239
+ }?: {
240
+ plan?: string
241
+ upgradeTo?: string
242
+ }): JSX.Element
243
+ ```
244
+
245
+ #### `DevicesSection(props?)`
246
+
247
+ Devices section — lists the user's registered devices and lets them
248
+ revoke (sign out) any device other than the one they're currently using.
249
+
250
+ Revoking deletes the device row (`DELETE /api/devices/:id`). The API's
251
+ authorization layer enforces server-side revocation: it rejects that
252
+ device's session the next time it makes a request (within the
253
+ device-exists cache TTL), so the removed device is actually signed out —
254
+ not just hidden from the list. The current device is labelled
255
+ "This device" and is not revocable here (use Sign out for the current
256
+ session). Recreates molecule v1's device-revocation behaviour.
257
+
258
+ Apps that want a different trailing element per row can pass a
259
+ `renderRowIcon` callback (which then replaces the built-in revoke
260
+ control); pass `() => null` to suppress it entirely.
261
+
262
+ ```typescript
263
+ function DevicesSection({
264
+ renderRowIcon,
265
+ }?: {
266
+ renderRowIcon?: (device: Device) => ReactNode
267
+ }): JSX.Element
268
+ ```
269
+
270
+ #### `disablePushOnCurrentDevice(deps)`
271
+
272
+ Disables push: unsubscribes the browser (best-effort — a dev build without
273
+ a service worker has nothing to unsubscribe) and ALWAYS clears the server
274
+ state so no further pushes target this device.
275
+
276
+ ```typescript
277
+ function disablePushOnCurrentDevice(deps: {
278
+ http: PushToggleHttp
279
+ unregister: () => Promise<void>
280
+ }): Promise<PushToggleResult>
281
+ ```
282
+
283
+ - `deps` — The http client + push action from `usePush()`.
284
+ - `deps.http` — Authenticated http client (`useHttpClient()`).
285
+ - `deps.unregister` — `usePush().unregister`.
286
+
287
+ **Returns:** `{ ok: true }` or a typed failure (server state not cleared).
288
+
289
+ #### `enablePushOnCurrentDevice(deps)`
290
+
291
+ Runs the full enable chain: browser permission → runtime VAPID public key
292
+ (`GET /api/devices/push/public-key`) → `register({ vapidPublicKey })` →
293
+ persist the subscription on the current device row.
294
+
295
+ Every failure is returned as a typed reason (never thrown) so the UI can
296
+ show an honest, specific message instead of hanging or silently reverting.
297
+
298
+ ```typescript
299
+ function enablePushOnCurrentDevice(deps: {
300
+ http: PushToggleHttp
301
+ requestPermission: () => Promise<string>
302
+ register: (options?: { vapidPublicKey?: string }) => Promise<PushToggleToken>
303
+ }): Promise<PushToggleResult>
304
+ ```
305
+
306
+ - `deps` — The http client + push actions from `usePush()`.
307
+ - `deps.http` — Authenticated http client (`useHttpClient()`).
308
+ - `deps.requestPermission` — `usePush().requestPermission`.
309
+ - `deps.register` — `usePush().register`.
310
+
311
+ **Returns:** `{ ok: true }` or a typed failure.
312
+
313
+ #### `findCurrentDevice(devices)`
314
+
315
+ Picks the caller's own device row: the api flags the session device
316
+ `isCurrent`; fall back to the first row for sessions predating the flag.
317
+
318
+ ```typescript
319
+ function findCurrentDevice(devices: PushToggleDevice[] | undefined): PushToggleDevice | undefined
320
+ ```
321
+
322
+ - `devices` — Rows from `GET /api/devices`.
323
+
324
+ **Returns:** The current device row, or `undefined` when the user has none.
325
+
326
+ #### `LogOutDeleteSection()`
327
+
328
+ Bottom actions section — Log out + Delete account.
329
+
330
+ Owns the delete-account modal internally (the trigger lives in the
331
+ same section so the modal lives here too). Reads `onClose` from
332
+ the `<SettingsContainer>` context to dismiss the panel after either
333
+ action and navigates to `/login`.
334
+
335
+ ```typescript
336
+ function LogOutDeleteSection(): JSX.Element
337
+ ```
338
+
339
+ #### `NotificationsSection()`
340
+
341
+ Push-notification toggle section — the full receive-side enable chain:
342
+ browser permission → runtime VAPID public key
343
+ (`GET /api/devices/push/public-key`) → `pushManager.subscribe` with
344
+ `applicationServerKey` → PATCH the subscription onto the current device
345
+ row (`/api/devices/:id { pushSubscription, hasPushSubscription }`), which
346
+ is where the api-side push fan-outs look for it.
347
+
348
+ Initial state reflects SERVER truth (the current device row's
349
+ `hasPushSubscription`), and every failure surfaces as an honest inline
350
+ message — a dev build without a service worker fails fast instead of
351
+ hanging the switch.
352
+
353
+ ```typescript
354
+ function NotificationsSection(): JSX.Element
355
+ ```
356
+
357
+ #### `readCurrentDevicePushEnabled(http)`
358
+
359
+ Reads whether push is currently enabled for THIS device (server truth:
360
+ the current device row's `hasPushSubscription`).
361
+
362
+ ```typescript
363
+ function readCurrentDevicePushEnabled(http: PushToggleHttp): Promise<boolean>
364
+ ```
365
+
366
+ - `http` — Authenticated http client (`useHttpClient()`).
367
+
368
+ **Returns:** `true` when the current device has a stored subscription.
369
+
370
+ #### `SettingsContainer(props)`
371
+
372
+ Outer settings-panel layout: padded vertical stack that hosts the
373
+ section sub-components. Publishes `onClose` to descendants via
374
+ context so `<LogOutDeleteSection>` etc. can dismiss the panel
375
+ after an action without explicit prop threading.
376
+
377
+ ```typescript
378
+ function SettingsContainer({
379
+ onClose,
380
+ children,
381
+ }: {
382
+ onClose: () => void
383
+ children: ReactNode
384
+ }): ReactElement<unknown, string | JSXElementConstructor<any>>
385
+ ```
386
+
387
+ #### `subscriptionFromToken(token)`
388
+
389
+ Converts an `@molecule/app-push` token into the device resource's
390
+ `pushSubscription` shape (web PushSubscription JSON, FCM registration for
391
+ Android, APNs registration for iOS).
392
+
393
+ ```typescript
394
+ function subscriptionFromToken(token: PushToggleToken): unknown
395
+ ```
396
+
397
+ - `token` — The push token returned by `register()`.
398
+
399
+ **Returns:** The `pushSubscription` value to PATCH onto the device row.
400
+
401
+ #### `ThisDeviceSection()`
402
+
403
+ "This device" detail strip — OS, browser, online/offline.
404
+
405
+ Reads from `@molecule/app-device` (useDevice hook) + browser
406
+ `navigator.onLine`. No side effects, no app-specific state.
407
+
408
+ ```typescript
409
+ function ThisDeviceSection(): JSX.Element
410
+ ```
411
+
412
+ #### `TiersUpgradeSection()`
413
+
414
+ Billing section with full multi-tier upgrade flow.
415
+
416
+ Replaces the simpler `<BillingSection>` for apps backed by
417
+ `@molecule/api-payments-stripe` + `@molecule/api-resource-payment`
418
+ — loads the user's current plan from `/api/billing/status`,
419
+ loads available tiers from `/api/billing/tiers`, and renders an
420
+ Upgrade modal with a Subscribe button per tier price. Subscribe
421
+ POSTs to `/api/billing/checkout` and redirects to the Stripe
422
+ checkout URL; paid users see a Cancel button that POSTs to
423
+ `/api/billing/cancel`.
424
+
425
+ ```typescript
426
+ function TiersUpgradeSection(): JSX.Element
427
+ ```
428
+
429
+ #### `useSettingsPanelContext()`
430
+
431
+ Reads the `onClose` handler exposed by the parent `<SettingsContainer>`.
432
+ Throws if used outside the container so component misuse is loud.
433
+
434
+ ```typescript
435
+ function useSettingsPanelContext(): SettingsPanelContextValue
436
+ ```
437
+
438
+ ### Constants
439
+
440
+ #### `SettingsPanelContext`
441
+
442
+ React context object for the settings panel; consume via `useSettingsPanelContext`.
443
+
444
+ ```typescript
445
+ const SettingsPanelContext: Context<SettingsPanelContextValue | null>
446
+ ```
447
+
448
+ ## Injection Notes
449
+
450
+ ### Requirements
451
+
452
+ Peer dependencies:
453
+
454
+ - `@molecule/app-auth` ^1.0.0
455
+ - `@molecule/app-react` ^1.0.0
456
+ - `@molecule/app-ui` ^1.0.0
457
+ - `@molecule/app-ui-react` ^1.0.0
458
+ - `react` ^18.0.0 || ^19.0.0
459
+ - `react-router` ^7.0.0 || ^8.0.0
460
+
461
+ ### Runtime Dependencies
462
+
463
+ - `@molecule/app-auth`
464
+ - `@molecule/app-react`
465
+ - `@molecule/app-ui`
466
+ - `@molecule/app-ui-react`
467
+ - `react`
468
+ - `react-router`
469
+
470
+ - Wiring prereqs: sections need the standard `@molecule/app-react`
471
+ provider stack — `<I18nProvider>`, `<HttpProvider>` (authenticated
472
+ client), `<AuthProvider>`, `<ThemeProvider>` (AppearanceSection), push +
473
+ device providers (NotificationsSection/ThisDeviceSection) — plus a
474
+ bonded ClassMap. `<BillingSection>` and `<LogOutDeleteSection>` also
475
+ call react-router's `useNavigate()` and throw outside a `<Router>`.
476
+ - Section components throw if rendered outside `<SettingsContainer>`
477
+ (they read its context for `onClose`).
478
+ - Server contract: the molecule API surface from
479
+ `@molecule/api-resource-user`, `@molecule/api-resource-device`,
480
+ `@molecule/api-two-factor`, and the billing endpoints
481
+ (`/api/billing/*`) wired by the payments stack. Missing read endpoints
482
+ degrade gracefully (sections render empty); the mutating actions do not.
483
+ - Translations: `@molecule/app-locales-settings-panel` companion bond.
484
+
485
+ ## Translations
486
+
487
+ Translation strings are provided by `@molecule/app-locales-settings-panel`.
@@ -0,0 +1,15 @@
1
+ import { type JSX } from 'react';
2
+ /**
3
+ * Account section — edits the user's display name + email. Fetches
4
+ * `/users/me` on mount to refresh the current user record (and write it
5
+ * back to the auth cache so subsequent reloads see the latest data). On
6
+ * blur of either field, PATCHes `/api/users/:id` with the changed field;
7
+ * reverts + shows an inline error if the request fails.
8
+ *
9
+ * The user resource's update handler accepts `name`, `username`, and
10
+ * `email`; this surfaces `name` + `email` (the universally-present
11
+ * profile fields). Apps that use a public `username` handle can extend
12
+ * this with a username field the same way.
13
+ */
14
+ export declare function AccountSection(): JSX.Element;
15
+ //# sourceMappingURL=AccountSection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AccountSection.d.ts","sourceRoot":"","sources":["../src/AccountSection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAuB,MAAM,OAAO,CAAA;AAcrD;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,IAAI,GAAG,CAAC,OAAO,CA6G5C"}