@molecule/app-settings-panel-solid 0.0.0-stage → 1.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/LICENSE +202 -0
- package/README.md +535 -2
- package/dist/AccountSection.d.ts +19 -0
- package/dist/AccountSection.d.ts.map +1 -0
- package/dist/AccountSection.jsx +147 -0
- package/dist/AccountSection.jsx.map +1 -0
- package/dist/AppearanceSection.d.ts +17 -0
- package/dist/AppearanceSection.d.ts.map +1 -0
- package/dist/AppearanceSection.jsx +34 -0
- package/dist/AppearanceSection.jsx.map +1 -0
- package/dist/AuthSection.d.ts +26 -0
- package/dist/AuthSection.d.ts.map +1 -0
- package/dist/AuthSection.jsx +252 -0
- package/dist/AuthSection.jsx.map +1 -0
- package/dist/BillingSection.d.ts +29 -0
- package/dist/BillingSection.d.ts.map +1 -0
- package/dist/BillingSection.jsx +69 -0
- package/dist/BillingSection.jsx.map +1 -0
- package/dist/DevicesSection.d.ts +31 -0
- package/dist/DevicesSection.d.ts.map +1 -0
- package/dist/DevicesSection.jsx +130 -0
- package/dist/DevicesSection.jsx.map +1 -0
- package/dist/LogOutDeleteSection.d.ts +18 -0
- package/dist/LogOutDeleteSection.d.ts.map +1 -0
- package/dist/LogOutDeleteSection.jsx +99 -0
- package/dist/LogOutDeleteSection.jsx.map +1 -0
- package/dist/NotificationsSection.d.ts +23 -0
- package/dist/NotificationsSection.d.ts.map +1 -0
- package/dist/NotificationsSection.jsx +120 -0
- package/dist/NotificationsSection.jsx.map +1 -0
- package/dist/SettingsContainer.d.ts +22 -0
- package/dist/SettingsContainer.d.ts.map +1 -0
- package/dist/SettingsContainer.jsx +30 -0
- package/dist/SettingsContainer.jsx.map +1 -0
- package/dist/ThisDeviceSection.d.ts +17 -0
- package/dist/ThisDeviceSection.d.ts.map +1 -0
- package/dist/ThisDeviceSection.jsx +60 -0
- package/dist/ThisDeviceSection.jsx.map +1 -0
- package/dist/TiersUpgradeSection.d.ts +24 -0
- package/dist/TiersUpgradeSection.d.ts.map +1 -0
- package/dist/TiersUpgradeSection.jsx +181 -0
- package/dist/TiersUpgradeSection.jsx.map +1 -0
- package/dist/context.d.ts +17 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +24 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +88 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +88 -0
- package/dist/index.js.map +1 -0
- package/dist/pushToggle.d.ts +12 -0
- package/dist/pushToggle.d.ts.map +1 -0
- package/dist/pushToggle.js +11 -0
- package/dist/pushToggle.js.map +1 -0
- package/dist/types.d.ts +38 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +71 -4
package/README.md
CHANGED
|
@@ -1,3 +1,536 @@
|
|
|
1
|
-
|
|
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-14T15:07:18.675Z
|
|
7
|
+
-->
|
|
2
8
|
|
|
3
|
-
|
|
9
|
+
# @molecule/app-settings-panel-solid
|
|
10
|
+
|
|
11
|
+
`@molecule/app-settings-panel-solid` — the Solid counterpart of
|
|
12
|
+
`@molecule/app-settings-panel-react`: the same composable, batteries-included
|
|
13
|
+
settings panel, with the same props, DOM, callbacks, service calls and i18n
|
|
14
|
+
keys, rendered with Solid.
|
|
15
|
+
|
|
16
|
+
`<SettingsContainer onClose={…}>` owns the layout and publishes `onClose`
|
|
17
|
+
via context; each section component is independent and loads its own data
|
|
18
|
+
through hooks:
|
|
19
|
+
|
|
20
|
+
- `<AccountSection>` — name/email edit (`PATCH /api/users/:id`).
|
|
21
|
+
- `<AppearanceSection>` — dark-mode toggle (`useTheme()`).
|
|
22
|
+
- `<AuthSection>` — password change + TOTP two-factor
|
|
23
|
+
(`POST /api/users/:id/verify-two-factor`).
|
|
24
|
+
- `<NotificationsSection>` — web-push toggle (see the exported
|
|
25
|
+
`enablePushOnCurrentDevice` / `disablePushOnCurrentDevice` helpers and
|
|
26
|
+
their documented device-row contract).
|
|
27
|
+
- `<BillingSection>` — read-only plan display (`GET /api/billing/status`),
|
|
28
|
+
or `<TiersUpgradeSection>` — full Stripe upgrade/cancel flow
|
|
29
|
+
(`/api/billing/tiers|checkout|cancel`). Use one or the other, not both.
|
|
30
|
+
- `<DevicesSection>` / `<ThisDeviceSection>` — device list + current
|
|
31
|
+
device (`GET/DELETE /api/devices`).
|
|
32
|
+
- `<LogOutDeleteSection>` — sign out + delete account
|
|
33
|
+
(`DELETE /api/users/:id`).
|
|
34
|
+
Apps compose via JSX children — pick sections, order them, and interleave
|
|
35
|
+
custom sections.
|
|
36
|
+
|
|
37
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
38
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
39
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
40
|
+
|
|
41
|
+
## Quick Start
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import {
|
|
45
|
+
AccountSection,
|
|
46
|
+
AppearanceSection,
|
|
47
|
+
AuthSection,
|
|
48
|
+
BillingSection,
|
|
49
|
+
DevicesSection,
|
|
50
|
+
LogOutDeleteSection,
|
|
51
|
+
NotificationsSection,
|
|
52
|
+
SettingsContainer,
|
|
53
|
+
ThisDeviceSection,
|
|
54
|
+
} from '@molecule/app-settings-panel-solid'
|
|
55
|
+
|
|
56
|
+
function SettingsPanel(props: { onClose: () => void }) {
|
|
57
|
+
return (
|
|
58
|
+
<SettingsContainer onClose={props.onClose}>
|
|
59
|
+
<AccountSection />
|
|
60
|
+
<AppearanceSection />
|
|
61
|
+
<AuthSection />
|
|
62
|
+
<NotificationsSection />
|
|
63
|
+
<BillingSection />
|
|
64
|
+
<DevicesSection />
|
|
65
|
+
<ThisDeviceSection />
|
|
66
|
+
<LogOutDeleteSection />
|
|
67
|
+
</SettingsContainer>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Type
|
|
73
|
+
|
|
74
|
+
`feature`
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
npm install @molecule/app-settings-panel-solid @molecule/app-auth @molecule/app-http @molecule/app-push @molecule/app-solid @molecule/app-ui @molecule/app-ui-solid @molecule/app-utilities solid-js
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## API
|
|
83
|
+
|
|
84
|
+
### Interfaces
|
|
85
|
+
|
|
86
|
+
#### `SettingsPanelContextValue`
|
|
87
|
+
|
|
88
|
+
Context published by `<SettingsContainer>` to its children.
|
|
89
|
+
|
|
90
|
+
The container owns the dismiss-the-panel handler; sub-components
|
|
91
|
+
that need to close after an action (logout, delete account, email
|
|
92
|
+
error) read it from context rather than threading the prop down.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
interface SettingsPanelContextValue {
|
|
96
|
+
/** Dismisses the settings panel (the container's `onClose` prop). */
|
|
97
|
+
onClose: () => void
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
#### `Device`
|
|
102
|
+
|
|
103
|
+
A user's registered device (subset rendered in the settings list).
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
interface Device {
|
|
107
|
+
/** The device's id on the wire (`DELETE /api/devices/:id`). */
|
|
108
|
+
id: string
|
|
109
|
+
/** The device's display name; may be empty (the platform is shown then). */
|
|
110
|
+
name: string
|
|
111
|
+
/** The device's platform (`ios`, `linux`, …). */
|
|
112
|
+
platform: string
|
|
113
|
+
/** When the device was last seen, as the API renders it. */
|
|
114
|
+
lastSeen?: string
|
|
115
|
+
/** `true` for the device making the current request (the API marks it). */
|
|
116
|
+
isCurrent?: boolean
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### `TiersUpgradeSectionProps`
|
|
121
|
+
|
|
122
|
+
Props for {@link TiersUpgradeSection}.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
interface TiersUpgradeSectionProps {
|
|
126
|
+
/**
|
|
127
|
+
* How the page leaves for the checkout URL the server returns. Defaults to a
|
|
128
|
+
* full-page navigation (`openUrl` from `@molecule/app-utilities`).
|
|
129
|
+
*/
|
|
130
|
+
redirectToCheckout?: (checkoutUrl: string) => void
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
#### `PushToggleHttp`
|
|
135
|
+
|
|
136
|
+
Minimal structural slice of `@molecule/app-http`'s HttpClient used here.
|
|
137
|
+
|
|
138
|
+
```typescript
|
|
139
|
+
interface PushToggleHttp {
|
|
140
|
+
get<T = unknown>(url: string): Promise<{ data: T }>
|
|
141
|
+
patch<T = unknown>(url: string, data?: unknown): Promise<{ data: T }>
|
|
142
|
+
}
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
#### `PushToggleDevice`
|
|
146
|
+
|
|
147
|
+
Device row slice returned by `GET /api/devices`.
|
|
148
|
+
|
|
149
|
+
```typescript
|
|
150
|
+
interface PushToggleDevice {
|
|
151
|
+
id: string
|
|
152
|
+
isCurrent?: boolean
|
|
153
|
+
hasPushSubscription?: boolean
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
#### `PushToggleToken`
|
|
158
|
+
|
|
159
|
+
Push token slice returned by `@molecule/app-push` `register()`.
|
|
160
|
+
|
|
161
|
+
```typescript
|
|
162
|
+
interface PushToggleToken {
|
|
163
|
+
value: string
|
|
164
|
+
platform: 'web' | 'ios' | 'android'
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Types
|
|
169
|
+
|
|
170
|
+
#### `PushToggleFailureReason`
|
|
171
|
+
|
|
172
|
+
Why an enable/disable attempt failed (mapped to i18n by the component).
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
type PushToggleFailureReason =
|
|
176
|
+
'permission-denied' | 'server-unconfigured' | 'register-failed' | 'persist-failed'
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
#### `PushToggleResult`
|
|
180
|
+
|
|
181
|
+
Result of an enable/disable attempt.
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
type PushToggleResult =
|
|
185
|
+
{ ok: true } | { ok: false; reason: PushToggleFailureReason; message?: string }
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Functions
|
|
189
|
+
|
|
190
|
+
#### `AccountSection()`
|
|
191
|
+
|
|
192
|
+
Account fields over the shared profile lifecycle. Background validation uses
|
|
193
|
+
the auth client's configured route, mapping and session ownership guards.
|
|
194
|
+
|
|
195
|
+
`UserProfile.email` is optional (phone/handle accounts have none), so email is
|
|
196
|
+
validated only when non-empty and a blank email is never sent: clearing the
|
|
197
|
+
field leaves the stored address untouched, and a name-only account can still
|
|
198
|
+
save its name.
|
|
199
|
+
|
|
200
|
+
```typescript
|
|
201
|
+
function AccountSection(): JSX.Element
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**Returns:** The account settings section.
|
|
205
|
+
|
|
206
|
+
#### `AppearanceSection()`
|
|
207
|
+
|
|
208
|
+
Appearance section — dark-mode toggle wired to the theme bond.
|
|
209
|
+
|
|
210
|
+
Apps that expose other appearance knobs (font size, density, etc.)
|
|
211
|
+
can either add more sub-components to this package or render their
|
|
212
|
+
own section in line with `<AppearanceSection>` via children.
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
function AppearanceSection(): JSX.Element
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Returns:** The appearance settings section.
|
|
219
|
+
|
|
220
|
+
#### `AuthSection()`
|
|
221
|
+
|
|
222
|
+
Authentication section — change password (modal) + two-factor (TOTP) setup.
|
|
223
|
+
|
|
224
|
+
Two-factor uses the real enrollment flow against the user resource's
|
|
225
|
+
`POST /users/:id/verify-two-factor` endpoint (`@molecule/api-two-factor`):
|
|
226
|
+
|
|
227
|
+
- Enable → `{action:'setup'}` returns a QR code + secret to scan into an
|
|
228
|
+
authenticator app → user enters the 6-digit code → `{action:'enable', token}`.
|
|
229
|
+
- Disable → user enters a current code → `{action:'disable', token}`.
|
|
230
|
+
The current status is read from `/users/me`. (This replaces the previous
|
|
231
|
+
boolean toggle, which PATCHed `twoFactorEnabled` — a field the update
|
|
232
|
+
handler deliberately ignores — so it never actually enrolled 2FA.)
|
|
233
|
+
|
|
234
|
+
Auto-hides for OAuth-only users (`user.oauthServer` truthy) since
|
|
235
|
+
password / 2FA wouldn't apply. If the app's API has no two-factor
|
|
236
|
+
provider bonded, setup fails gracefully with an inline message.
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
function AuthSection(): JSX.Element
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
**Returns:** The authentication settings section.
|
|
243
|
+
|
|
244
|
+
#### `BillingSection(props)`
|
|
245
|
+
|
|
246
|
+
Billing section — current plan + Upgrade button.
|
|
247
|
+
|
|
248
|
+
Fetches `/api/billing/status` on mount and uses the returned plan
|
|
249
|
+
name as a more accurate label than the parent-supplied default.
|
|
250
|
+
The `plan` prop remains a fallback (e.g. for offline rendering or
|
|
251
|
+
apps that don't expose `/billing/status`).
|
|
252
|
+
|
|
253
|
+
The Upgrade button navigates to `upgradeTo` (default `/settings`).
|
|
254
|
+
Pass `upgradeTo="/billing"` or `upgradeTo="/pricing"` if your app
|
|
255
|
+
routes elsewhere. Apps with a multi-tier checkout flow should use
|
|
256
|
+
`<TiersUpgradeSection>` instead.
|
|
257
|
+
|
|
258
|
+
```typescript
|
|
259
|
+
function BillingSection(props: {
|
|
260
|
+
/** Fallback plan label until (or unless) `/api/billing/status` answers. */
|
|
261
|
+
plan?: string
|
|
262
|
+
/** Where the Upgrade button navigates. Defaults to `/settings`. */
|
|
263
|
+
upgradeTo?: string
|
|
264
|
+
}): JSX.Element
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
- `props` — Component props.
|
|
268
|
+
|
|
269
|
+
**Returns:** The billing section.
|
|
270
|
+
|
|
271
|
+
#### `DevicesSection(props)`
|
|
272
|
+
|
|
273
|
+
Devices section — lists the user's registered devices and lets them
|
|
274
|
+
revoke (sign out) any device other than the one they're currently using.
|
|
275
|
+
|
|
276
|
+
Revoking deletes the device row (`DELETE /api/devices/:id`). The API's
|
|
277
|
+
authorization layer enforces server-side revocation: it rejects that
|
|
278
|
+
device's session the next time it makes a request (within the
|
|
279
|
+
device-exists cache TTL), so the removed device is actually signed out —
|
|
280
|
+
not just hidden from the list. The current device is labelled
|
|
281
|
+
"This device" and is not revocable here (use Sign out for the current
|
|
282
|
+
session). Recreates molecule v1's device-revocation behaviour.
|
|
283
|
+
|
|
284
|
+
Apps that want a different trailing element per row can pass a
|
|
285
|
+
`renderRowIcon` callback (which then replaces the built-in revoke
|
|
286
|
+
control); pass `() => null` to suppress it entirely.
|
|
287
|
+
|
|
288
|
+
```typescript
|
|
289
|
+
function DevicesSection(props: {
|
|
290
|
+
/** Replaces the built-in revoke control per row; `() => null` suppresses it. */
|
|
291
|
+
renderRowIcon?: (device: Device) => JSX.Element
|
|
292
|
+
}): JSX.Element
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
- `props` — Component props.
|
|
296
|
+
|
|
297
|
+
**Returns:** The devices settings section.
|
|
298
|
+
|
|
299
|
+
#### `LogOutDeleteSection()`
|
|
300
|
+
|
|
301
|
+
Bottom actions section — Log out + Delete account.
|
|
302
|
+
|
|
303
|
+
Owns the delete-account modal internally (the trigger lives in the
|
|
304
|
+
same section so the modal lives here too). Reads `onClose` from
|
|
305
|
+
the `<SettingsContainer>` context to dismiss the panel after either
|
|
306
|
+
action and navigates to `/login`.
|
|
307
|
+
|
|
308
|
+
```typescript
|
|
309
|
+
function LogOutDeleteSection(): JSX.Element
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Returns:** The bottom actions section.
|
|
313
|
+
|
|
314
|
+
#### `NotificationsSection()`
|
|
315
|
+
|
|
316
|
+
Push-notification toggle section — the full receive-side enable chain:
|
|
317
|
+
browser permission → runtime VAPID public key
|
|
318
|
+
(`GET /api/devices/push/public-key`) → `pushManager.subscribe` with
|
|
319
|
+
`applicationServerKey` → PATCH the subscription onto the current device
|
|
320
|
+
row (`/api/devices/:id { pushSubscription, hasPushSubscription }`), which
|
|
321
|
+
is where the api-side push fan-outs look for it.
|
|
322
|
+
|
|
323
|
+
Initial state reflects SERVER truth (the current device row's
|
|
324
|
+
`hasPushSubscription`), and every failure surfaces as an honest inline
|
|
325
|
+
message — a dev build without a service worker fails fast instead of
|
|
326
|
+
hanging the switch.
|
|
327
|
+
|
|
328
|
+
```typescript
|
|
329
|
+
function NotificationsSection(): JSX.Element
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
**Returns:** The notifications settings section.
|
|
333
|
+
|
|
334
|
+
#### `SettingsContainer(props)`
|
|
335
|
+
|
|
336
|
+
Outer settings-panel layout: padded vertical stack that hosts the
|
|
337
|
+
section sub-components. Publishes `onClose` to descendants via
|
|
338
|
+
context so `<LogOutDeleteSection>` etc. can dismiss the panel
|
|
339
|
+
after an action without explicit prop threading.
|
|
340
|
+
|
|
341
|
+
```typescript
|
|
342
|
+
function SettingsContainer(props: {
|
|
343
|
+
/** The handler published to descendants through the container context. */
|
|
344
|
+
onClose: () => void
|
|
345
|
+
/** The section sub-components the panel hosts. */
|
|
346
|
+
children?: JSX.Element
|
|
347
|
+
}): JSX.Element
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
- `props` — The component props.
|
|
351
|
+
|
|
352
|
+
**Returns:** The settings panel container.
|
|
353
|
+
|
|
354
|
+
#### `ThisDeviceSection()`
|
|
355
|
+
|
|
356
|
+
"This device" detail strip — OS, browser, online/offline.
|
|
357
|
+
|
|
358
|
+
Reads everything from `@molecule/app-device` through the `useDevice` hook
|
|
359
|
+
(`deviceInfo` and `isOnline()`), so the bonded device provider decides what
|
|
360
|
+
it shows. No side effects, no app-specific state.
|
|
361
|
+
|
|
362
|
+
```typescript
|
|
363
|
+
function ThisDeviceSection(): JSX.Element
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
**Returns:** The this-device settings section.
|
|
367
|
+
|
|
368
|
+
#### `TiersUpgradeSection(props)`
|
|
369
|
+
|
|
370
|
+
Billing section with full multi-tier upgrade flow.
|
|
371
|
+
|
|
372
|
+
Replaces the simpler `<BillingSection>` for apps backed by
|
|
373
|
+
`@molecule/api-payments-stripe` + `@molecule/api-resource-payment`
|
|
374
|
+
— loads the user's current plan from `/api/billing/status`,
|
|
375
|
+
loads available tiers from `/api/billing/tiers`, and renders an
|
|
376
|
+
Upgrade modal with a Subscribe button per tier price. Subscribe
|
|
377
|
+
POSTs to `/api/billing/checkout` and redirects to the Stripe
|
|
378
|
+
checkout URL; paid users see a Cancel button that POSTs to
|
|
379
|
+
`/api/billing/cancel`. A refused request shows the server's message.
|
|
380
|
+
|
|
381
|
+
```typescript
|
|
382
|
+
function TiersUpgradeSection(props: TiersUpgradeSectionProps): JSX.Element
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
- `props` — Component props.
|
|
386
|
+
|
|
387
|
+
**Returns:** The billing section.
|
|
388
|
+
|
|
389
|
+
#### `useSettingsPanelContext()`
|
|
390
|
+
|
|
391
|
+
Reads the `onClose` handler exposed by the parent `<SettingsContainer>`.
|
|
392
|
+
Throws if used outside the container so component misuse is loud.
|
|
393
|
+
|
|
394
|
+
```typescript
|
|
395
|
+
function useSettingsPanelContext(): SettingsPanelContextValue
|
|
396
|
+
```
|
|
397
|
+
|
|
398
|
+
**Returns:** The container's context value.
|
|
399
|
+
|
|
400
|
+
#### `findCurrentDevice(devices)`
|
|
401
|
+
|
|
402
|
+
Picks the caller's own device row: the api flags the session device
|
|
403
|
+
`isCurrent`; fall back to the first row for sessions predating the flag.
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
function findCurrentDevice(devices: PushToggleDevice[] | undefined): PushToggleDevice | undefined
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
- `devices` — Rows from `GET /api/devices`.
|
|
410
|
+
|
|
411
|
+
**Returns:** The current device row, or `undefined` when the user has none.
|
|
412
|
+
|
|
413
|
+
#### `subscriptionFromToken(token)`
|
|
414
|
+
|
|
415
|
+
Converts an `@molecule/app-push` token into the device resource's
|
|
416
|
+
`pushSubscription` shape (web PushSubscription JSON, FCM registration for
|
|
417
|
+
Android, APNs registration for iOS).
|
|
418
|
+
|
|
419
|
+
```typescript
|
|
420
|
+
function subscriptionFromToken(token: PushToggleToken): unknown
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
- `token` — The push token returned by `register()`.
|
|
424
|
+
|
|
425
|
+
**Returns:** The `pushSubscription` value to PATCH onto the device row.
|
|
426
|
+
|
|
427
|
+
#### `enablePushOnCurrentDevice(deps)`
|
|
428
|
+
|
|
429
|
+
Runs the full enable chain: browser permission → runtime VAPID public key
|
|
430
|
+
(`GET /api/devices/push/public-key`) → `register({ vapidPublicKey })` →
|
|
431
|
+
persist the subscription on the current device row.
|
|
432
|
+
|
|
433
|
+
Every failure is returned as a typed reason (never thrown) so the UI can
|
|
434
|
+
show an honest, specific message instead of hanging or silently reverting.
|
|
435
|
+
|
|
436
|
+
```typescript
|
|
437
|
+
function enablePushOnCurrentDevice(deps: {
|
|
438
|
+
http: PushToggleHttp
|
|
439
|
+
requestPermission: () => Promise<string>
|
|
440
|
+
register: (options?: { vapidPublicKey?: string }) => Promise<PushToggleToken>
|
|
441
|
+
}): Promise<PushToggleResult>
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
- `deps` — The http client + push actions from `usePush()`.
|
|
445
|
+
- `deps.http` — Authenticated http client (`useHttpClient()`).
|
|
446
|
+
- `deps.requestPermission` — `usePush().requestPermission`.
|
|
447
|
+
- `deps.register` — `usePush().register`.
|
|
448
|
+
|
|
449
|
+
**Returns:** `{ ok: true }` or a typed failure.
|
|
450
|
+
|
|
451
|
+
#### `disablePushOnCurrentDevice(deps)`
|
|
452
|
+
|
|
453
|
+
Disables push: unsubscribes the browser (best-effort — a dev build without
|
|
454
|
+
a service worker has nothing to unsubscribe) and ALWAYS clears the server
|
|
455
|
+
state so no further pushes target this device.
|
|
456
|
+
|
|
457
|
+
```typescript
|
|
458
|
+
function disablePushOnCurrentDevice(deps: {
|
|
459
|
+
http: PushToggleHttp
|
|
460
|
+
unregister: () => Promise<void>
|
|
461
|
+
}): Promise<PushToggleResult>
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
- `deps` — The http client + push action from `usePush()`.
|
|
465
|
+
- `deps.http` — Authenticated http client (`useHttpClient()`).
|
|
466
|
+
- `deps.unregister` — `usePush().unregister`.
|
|
467
|
+
|
|
468
|
+
**Returns:** `{ ok: true }` or a typed failure (server state not cleared).
|
|
469
|
+
|
|
470
|
+
#### `readCurrentDevicePushEnabled(http)`
|
|
471
|
+
|
|
472
|
+
Reads whether push is currently enabled for THIS device (server truth:
|
|
473
|
+
the current device row's `hasPushSubscription`).
|
|
474
|
+
|
|
475
|
+
```typescript
|
|
476
|
+
function readCurrentDevicePushEnabled(http: PushToggleHttp): Promise<boolean>
|
|
477
|
+
```
|
|
478
|
+
|
|
479
|
+
- `http` — Authenticated http client (`useHttpClient()`).
|
|
480
|
+
|
|
481
|
+
**Returns:** `true` when the current device has a stored subscription.
|
|
482
|
+
|
|
483
|
+
### Constants
|
|
484
|
+
|
|
485
|
+
#### `SettingsPanelContext`
|
|
486
|
+
|
|
487
|
+
Solid context object for the settings panel; consume via `useSettingsPanelContext`.
|
|
488
|
+
|
|
489
|
+
```typescript
|
|
490
|
+
const SettingsPanelContext: Context<SettingsPanelContextValue | null>
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
## Injection Notes
|
|
494
|
+
|
|
495
|
+
### Requirements
|
|
496
|
+
|
|
497
|
+
Peer dependencies:
|
|
498
|
+
|
|
499
|
+
- `@molecule/app-auth` ^3.0.0
|
|
500
|
+
- `@molecule/app-http` ^1.8.0
|
|
501
|
+
- `@molecule/app-push` ^1.1.0
|
|
502
|
+
- `@molecule/app-solid` ^3.5.0
|
|
503
|
+
- `@molecule/app-ui` ^1.0.1
|
|
504
|
+
- `@molecule/app-ui-solid` ^1.1.0
|
|
505
|
+
- `@molecule/app-utilities` ^1.0.6
|
|
506
|
+
- `solid-js` ^1.8.0
|
|
507
|
+
|
|
508
|
+
### Runtime Dependencies
|
|
509
|
+
|
|
510
|
+
- `@molecule/app-auth`
|
|
511
|
+
- `@molecule/app-http`
|
|
512
|
+
- `@molecule/app-push`
|
|
513
|
+
- `@molecule/app-solid`
|
|
514
|
+
- `@molecule/app-ui`
|
|
515
|
+
- `@molecule/app-ui-solid`
|
|
516
|
+
- `@molecule/app-utilities`
|
|
517
|
+
- `solid-js`
|
|
518
|
+
|
|
519
|
+
- Wiring prereqs: sections need the standard `@molecule/app-solid` provider
|
|
520
|
+
stack — `MoleculeProvider` with `i18n`, `http` (authenticated client),
|
|
521
|
+
`auth`, `theme` (AppearanceSection), and the bonded device + push
|
|
522
|
+
providers (NotificationsSection/ThisDeviceSection) — plus a bonded
|
|
523
|
+
ClassMap. `<BillingSection>` and `<LogOutDeleteSection>` also navigate
|
|
524
|
+
through the binding's router (`useRouter()`).
|
|
525
|
+
- Section components throw if rendered outside `<SettingsContainer>`
|
|
526
|
+
(they read its context for `onClose`).
|
|
527
|
+
- Server contract: the molecule API surface from
|
|
528
|
+
`@molecule/api-resource-user`, `@molecule/api-resource-device`,
|
|
529
|
+
`@molecule/api-two-factor`, and the billing endpoints
|
|
530
|
+
(`/api/billing/*`) wired by the payments stack. Missing read endpoints
|
|
531
|
+
degrade gracefully (sections render empty); the mutating actions do not.
|
|
532
|
+
- Translations: `@molecule/app-locales-settings-panel` companion bond.
|
|
533
|
+
|
|
534
|
+
## Translations
|
|
535
|
+
|
|
536
|
+
Translation strings are provided by `@molecule/app-locales-settings-panel`.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The account section.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { type JSX } from 'solid-js';
|
|
7
|
+
/**
|
|
8
|
+
* Account fields over the shared profile lifecycle. Background validation uses
|
|
9
|
+
* the auth client's configured route, mapping and session ownership guards.
|
|
10
|
+
*
|
|
11
|
+
* `UserProfile.email` is optional (phone/handle accounts have none), so email is
|
|
12
|
+
* validated only when non-empty and a blank email is never sent: clearing the
|
|
13
|
+
* field leaves the stored address untouched, and a name-only account can still
|
|
14
|
+
* save its name.
|
|
15
|
+
*
|
|
16
|
+
* @returns The account settings section.
|
|
17
|
+
*/
|
|
18
|
+
export declare function AccountSection(): JSX.Element;
|
|
19
|
+
//# sourceMappingURL=AccountSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountSection.d.ts","sourceRoot":"","sources":["../src/AccountSection.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAgB,KAAK,GAAG,EAAiB,MAAM,UAAU,CAAA;AAYhE;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,IAAI,GAAG,CAAC,OAAO,CA4J5C"}
|