@molecule/app-angular 3.0.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +94 -52
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +30 -1
- package/dist/providers.js.map +1 -1
- package/dist/services/forms.service.d.ts +23 -4
- package/dist/services/forms.service.d.ts.map +1 -1
- package/dist/services/forms.service.js +17 -5
- package/dist/services/forms.service.js.map +1 -1
- package/dist/types.d.ts +12 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
|
3
3
|
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
4
|
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
5
|
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
-
Generated: 2026-
|
|
6
|
+
Generated: 2026-11-03T17:38:43.314Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/app-angular
|
|
@@ -94,7 +94,10 @@ Reactive authentication state snapshot (initialized, authenticated, user, loadin
|
|
|
94
94
|
interface AuthState<T = UserProfile> {
|
|
95
95
|
/**
|
|
96
96
|
* The session's state as one value — render from this instead of combining
|
|
97
|
-
* `initialized`/`authenticated`/`loading`.
|
|
97
|
+
* `initialized`/`authenticated`/`loading`. `'loading'` is undecided, so wait
|
|
98
|
+
* and redirect only on `'unauthenticated'`; `'unavailable'` keeps the candidate
|
|
99
|
+
* for retry and can have a null profile. A restore failure other than 401/403
|
|
100
|
+
* never signs out. See {@link AuthStatus}.
|
|
98
101
|
*/
|
|
99
102
|
status: AuthStatus
|
|
100
103
|
/**
|
|
@@ -102,11 +105,14 @@ interface AuthState<T = UserProfile> {
|
|
|
102
105
|
*/
|
|
103
106
|
initialized: boolean
|
|
104
107
|
/**
|
|
105
|
-
* Whether the
|
|
108
|
+
* Whether the client has an authenticated session. This is not a server
|
|
109
|
+
* confirmation flag: during `'unavailable'` it can be false for a retained
|
|
110
|
+
* token/cookie-only candidate with no cached profile. Use `status` for redirects.
|
|
106
111
|
*/
|
|
107
112
|
authenticated: boolean
|
|
108
113
|
/**
|
|
109
|
-
* Current user
|
|
114
|
+
* Current user, or null when none is cached. In particular, an `'unavailable'`
|
|
115
|
+
* token/cookie-only restore has a retained candidate but no profile yet.
|
|
110
116
|
*/
|
|
111
117
|
user: T | null
|
|
112
118
|
/**
|
|
@@ -160,12 +166,23 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
|
|
|
160
166
|
* Updates the cached user object (state + persistent storage) without
|
|
161
167
|
* hitting the network. Intended for local refreshes after a per-app
|
|
162
168
|
* mutation (e.g., the user just PATCHed their own profile and the
|
|
163
|
-
* server returned the canonical row).
|
|
169
|
+
* server returned the canonical row). A non-null profile does NOT change
|
|
170
|
+
* tokens or sign the client in: `authenticated` and `status` are unchanged,
|
|
171
|
+
* so an anonymous client stays anonymous. Use {@link login} /
|
|
172
|
+
* {@link register} for a credential exchange, or {@link setSession} when
|
|
173
|
+
* the token was issued outside the client.
|
|
164
174
|
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
*
|
|
175
|
+
* Passing `null` on a signed-in client, or while any session operation is
|
|
176
|
+
* pending, ends the local session: it clears the access token, refresh token
|
|
177
|
+
* and cached user, stops automatic refresh, and settles `authenticated: false`
|
|
178
|
+
* with `status: 'unauthenticated'` in one notification. Every older operation
|
|
179
|
+
* loses session ownership, and a persistent sign-out marker prevents a reload
|
|
180
|
+
* from restoring its credentials or a late cookie. A late credential exchange
|
|
181
|
+
* is revoked best-effort when a logout endpoint is configured, without blocking
|
|
182
|
+
* the caller. This method does not otherwise call the server for a settled
|
|
183
|
+
* session; use {@link logout} for explicit server revocation. On a settled
|
|
184
|
+
* anonymous client, `null` only clears the cached profile and leaves tokens
|
|
185
|
+
* and auth state unchanged.
|
|
169
186
|
*/
|
|
170
187
|
setUser(user: T | null): void;
|
|
171
188
|
/**
|
|
@@ -180,10 +197,13 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
|
|
|
180
197
|
* which would violate the storage contract and make a stored bearer token
|
|
181
198
|
* JS-readable (XSS-exfiltratable). Pass `null` to clear it.
|
|
182
199
|
*
|
|
183
|
-
* This changes token storage only
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
200
|
+
* This changes token storage only: passing `null` does not by itself sign a
|
|
201
|
+
* signed-in client out, and a non-null token does not sign an anonymous
|
|
202
|
+
* client in (`authenticated` and `status` are unchanged). Use {@link logout}
|
|
203
|
+
* to end a session, or {@link setUser} with `null` for local-only sign-out.
|
|
204
|
+
* Use {@link login} / {@link register} for a credential exchange, or call
|
|
205
|
+
* {@link setSession} with the token and user to establish an already-issued
|
|
206
|
+
* session.
|
|
187
207
|
*/
|
|
188
208
|
setAccessToken(token: string | null): void;
|
|
189
209
|
/**
|
|
@@ -208,7 +228,16 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
|
|
|
208
228
|
*/
|
|
209
229
|
login(credentials: LoginCredentials): Promise<AuthResult<T>>;
|
|
210
230
|
/**
|
|
211
|
-
* Logs out the current user.
|
|
231
|
+
* Logs out the current user. The server request is best-effort: a missing
|
|
232
|
+
* logout route (404), any other HTTP failure, or a network error never makes
|
|
233
|
+
* this method reject. It always clears the access token, refresh token and
|
|
234
|
+
* cached user, stops automatic refresh, and publishes one settled
|
|
235
|
+
* `authenticated: false`, `status: 'unauthenticated'` transition. Every pending
|
|
236
|
+
* session operation loses ownership; a persistent marker prevents reload from
|
|
237
|
+
* restoring an older session, and late credentials are revoked best-effort.
|
|
238
|
+
*
|
|
239
|
+
* When the API has no logout route, set {@link AuthClientConfigOptions.logoutEndpoint}
|
|
240
|
+
* to `null` (or `''`) to skip the request. Local sign-out still happens.
|
|
212
241
|
*/
|
|
213
242
|
logout(): Promise<void>;
|
|
214
243
|
/**
|
|
@@ -260,37 +289,6 @@ interface AuthClient<T = UserProfile, TRegister extends RegisterExtraShape<TRegi
|
|
|
260
289
|
* until the cookie restore decides.
|
|
261
290
|
*
|
|
262
291
|
* Do not put this call (or a `/me` request of your own) in front of the first
|
|
263
|
-
* render, and do not render a loading screen over a session it just restored:
|
|
264
|
-
* `whenRestored()` already resolves as soon as the restore has settled, and the
|
|
265
|
-
* HTTP gate built on it holds requests for exactly that window.
|
|
266
|
-
*/
|
|
267
|
-
initialize(): Promise<void>;
|
|
268
|
-
/**
|
|
269
|
-
* Re-checks a restored session against the server, in the background — the
|
|
270
|
-
* boot-time validation an app with a stored token needs when a revoked or
|
|
271
|
-
* expired token must sign the user out. Call it AFTER the first render
|
|
272
|
-
* (`initialize()` restores synchronously from storage; this costs one request).
|
|
273
|
-
*
|
|
274
|
-
* - The server confirms the user: the session is refreshed and {@link AuthState.status}
|
|
275
|
-
* stays `'authenticated'`.
|
|
276
|
-
* - The server answers 401 or 403: the token is dead — the stored session is
|
|
277
|
-
* cleared and the status becomes `'unauthenticated'`.
|
|
278
|
-
* - The server cannot confirm the session — a network failure, a 5xx, or a 404
|
|
279
|
-
* from a misconfigured {@link AuthClientConfig.currentUserEndpoint}: the
|
|
280
|
-
* session (token AND user) is KEPT and the status becomes `'unavailable'`, so
|
|
281
|
-
* the app can retry instead of signing the user out over a bad connection or a
|
|
282
|
-
* route that does not exist. The 404 error names `currentUserEndpoint`.
|
|
283
|
-
*
|
|
284
|
-
* Do not hand-write this beside the client: a parallel token/user store for a
|
|
285
|
-
* "validating"/"unavailable" flag is the race this method removes.
|
|
286
|
-
*
|
|
287
|
-
* Optional: a provider with no restorable session has nothing to validate.
|
|
288
|
-
*/
|
|
289
|
-
validateSession?(): Promise<void>;
|
|
290
|
-
/**
|
|
291
|
-
* Resolves when the session restore started by `initialize()` has settled — the point
|
|
292
|
-
* after which the client knows whether this visitor is signed in.
|
|
293
|
-
*
|
|
294
292
|
// … truncated — the full declaration is in node_modules/@molecule/app-angular/dist
|
|
295
293
|
```
|
|
296
294
|
|
|
@@ -379,9 +377,20 @@ interface FormController<T extends FormValuesConstraint<T> = Record<string, unkn
|
|
|
379
377
|
* `defaultValues`, or the values a previous `reset(values)` established.
|
|
380
378
|
* Passing `values` merges them over the current baseline and makes the
|
|
381
379
|
* result the new baseline, so a form reset to freshly loaded or saved data
|
|
382
|
-
* reads clean (`isDirty === false`).
|
|
380
|
+
* reads clean (`isDirty === false`). A changed non-null `id` replaces the
|
|
381
|
+
* record and cancels a pending submit.
|
|
383
382
|
*/
|
|
384
383
|
reset(values?: Partial<T>): void
|
|
384
|
+
/**
|
|
385
|
+
* Applies externally loaded values without clearing submission state.
|
|
386
|
+
*
|
|
387
|
+
* The new clean baseline is the original `defaultValues` plus this latest
|
|
388
|
+
* record, never a merge of earlier records. With `keepDirtyValues`, edited
|
|
389
|
+
* fields retain their values while pristine fields take the loaded values.
|
|
390
|
+
* A changed non-null `id` still replaces the record and cancels a pending
|
|
391
|
+
* submit. Equal-content baselines cause no update.
|
|
392
|
+
*/
|
|
393
|
+
updateValues(values: Partial<T>, resetOptions?: FormResetOptions): void
|
|
385
394
|
/**
|
|
386
395
|
* Handles form submission.
|
|
387
396
|
*/
|
|
@@ -415,6 +424,14 @@ interface FormOptions<T extends FormValuesConstraint<T>> {
|
|
|
415
424
|
* is created. Mutating this object afterwards does not change the baseline.
|
|
416
425
|
*/
|
|
417
426
|
defaultValues?: Partial<T>
|
|
427
|
+
/**
|
|
428
|
+
* Externally loaded values, merged over `defaultValues` as the clean
|
|
429
|
+
* baseline. Framework bindings also apply later content changes; use
|
|
430
|
+
* `resetOptions.keepDirtyValues` to preserve edits while pristine fields fill.
|
|
431
|
+
*/
|
|
432
|
+
values?: Partial<T>
|
|
433
|
+
/** Controls how framework bindings apply changed `values`. */
|
|
434
|
+
resetOptions?: FormResetOptions
|
|
418
435
|
/**
|
|
419
436
|
* Validation mode.
|
|
420
437
|
*/
|
|
@@ -1446,6 +1463,18 @@ Configuration for molecule Angular module.
|
|
|
1446
1463
|
interface MoleculeModuleConfig {
|
|
1447
1464
|
state?: StateProvider
|
|
1448
1465
|
auth?: AuthClient<unknown>
|
|
1466
|
+
/**
|
|
1467
|
+
* Hold bootstrap (and so every page's first render) until `auth` has decided the
|
|
1468
|
+
* session. After a full page load a returning visitor's session is restored by one
|
|
1469
|
+
* request, and until it answers `MoleculeAuthService.user` is `null` everywhere — a
|
|
1470
|
+
* public page's signed-in action (`if (!user) return`, a redirect to `/login`) then
|
|
1471
|
+
* treats a signed-in visitor as signed out. With this set, Angular's app initializer
|
|
1472
|
+
* waits only while status is `'loading'`, so a cached session can render while its
|
|
1473
|
+
* verification continues in the background. `'unavailable'` also renders and may have a
|
|
1474
|
+
* null user. Without a session hint, an anonymous visitor settles in microtasks without
|
|
1475
|
+
* a request. Ignored without `auth`.
|
|
1476
|
+
*/
|
|
1477
|
+
awaitSession?: boolean
|
|
1449
1478
|
theme?: ThemeProvider
|
|
1450
1479
|
router?: Router
|
|
1451
1480
|
i18n?: I18nProvider
|
|
@@ -1662,9 +1691,9 @@ class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
|
|
|
1662
1691
|
constructor(private controller: FormController<T>) {
|
|
1663
1692
|
this.stateSubject = new BehaviorSubject<FormState<T>>(controller.getState())
|
|
1664
1693
|
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1694
|
+
const refresh = (): void => this.stateSubject.next(controller.getState())
|
|
1695
|
+
this.unsubscribe = controller.subscribe(refresh)
|
|
1696
|
+
refresh()
|
|
1668
1697
|
|
|
1669
1698
|
this.state$ = this.stateSubject.asObservable()
|
|
1670
1699
|
|
|
@@ -1800,6 +1829,16 @@ class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
|
|
|
1800
1829
|
return this.controller.handleSubmit(onSubmit, onError)
|
|
1801
1830
|
}
|
|
1802
1831
|
|
|
1832
|
+
/**
|
|
1833
|
+
* Apply a newly loaded record without clearing submission state.
|
|
1834
|
+
*
|
|
1835
|
+
* @param values - The newly loaded record.
|
|
1836
|
+
* @param resetOptions - Set `keepDirtyValues` to retain edits and fill pristine fields.
|
|
1837
|
+
*/
|
|
1838
|
+
updateValues(values: Partial<T>, resetOptions: FormResetOptions = {}): void {
|
|
1839
|
+
this.controller.updateValues(values, resetOptions)
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1803
1842
|
/**
|
|
1804
1843
|
* Reset the form to initial values.
|
|
1805
1844
|
*
|
|
@@ -1848,12 +1887,15 @@ export class MoleculeFormsService implements OnDestroy {
|
|
|
1848
1887
|
* Create a form instance from a provider.
|
|
1849
1888
|
*
|
|
1850
1889
|
* @param provider - The form provider that creates form controllers.
|
|
1851
|
-
* @param options -
|
|
1852
|
-
*
|
|
1890
|
+
* @param options - Narrowed `FormOptions` without `values` or `resetOptions`;
|
|
1891
|
+
* includes default values and validation mode.
|
|
1892
|
+
* @returns A new form instance with RxJS observables and explicit
|
|
1893
|
+
* `updateValues(values, { keepDirtyValues })` delivery. The option defaults to
|
|
1894
|
+
* false; pass true to retain edited fields while pristine fields take the record.
|
|
1853
1895
|
*/
|
|
1854
1896
|
createForm<T extends FormValuesConstraint<T>>(
|
|
1855
1897
|
provider: FormProvider,
|
|
1856
|
-
options:
|
|
1898
|
+
options: AngularFormOptions<T>,
|
|
1857
1899
|
): MoleculeFormInstance<T> {
|
|
1858
1900
|
const controller = provider.createForm(options)
|
|
1859
1901
|
const instance = new MoleculeFormInstance<T>(controller)
|
package/dist/providers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,oBAAoB,EAAY,MAAM,eAAe,CAAA;
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":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,EAAE,cAAc,GAAG,oBAAoB,CAE5E;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAsElF"}
|
package/dist/providers.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import { ENVIRONMENT_INITIALIZER, makeEnvironmentProviders } from '@angular/core';
|
|
6
|
+
import { ENVIRONMENT_INITIALIZER, makeEnvironmentProviders, provideAppInitializer, } from '@angular/core';
|
|
7
7
|
import { bumpLocaleVersion } from './i18n-reactive.js';
|
|
8
8
|
import { AUTH_CLIENT, HTTP_CLIENT, I18N_PROVIDER, LOGGER_PROVIDER, ROUTER, STATE_PROVIDER, STORAGE_PROVIDER, THEME_PROVIDER, } from './tokens.js';
|
|
9
9
|
/**
|
|
@@ -139,6 +139,35 @@ export function provideMolecule(config) {
|
|
|
139
139
|
if (config.logger) {
|
|
140
140
|
providers.push({ provide: LOGGER_PROVIDER, useValue: config.logger });
|
|
141
141
|
}
|
|
142
|
+
if (config.awaitSession && config.auth) {
|
|
143
|
+
const client = config.auth;
|
|
144
|
+
providers.push(
|
|
145
|
+
// The idiomatic hold: Angular creates no component (so no page renders) until
|
|
146
|
+
// app initializers settle.
|
|
147
|
+
provideAppInitializer(() => {
|
|
148
|
+
// Start or join the one restore. A stored user can already be decided
|
|
149
|
+
// while initialize()/whenRestored() still verify it in the background.
|
|
150
|
+
const joined = client.initialize().catch((_error) => {
|
|
151
|
+
// The client's status represents restore failure (including timeout).
|
|
152
|
+
// Bootstrap renders 'unavailable' rather than rejecting on that failure.
|
|
153
|
+
});
|
|
154
|
+
if (client.getState().status !== 'loading')
|
|
155
|
+
return;
|
|
156
|
+
let unsubscribe;
|
|
157
|
+
const ready = new Promise((resolve) => {
|
|
158
|
+
const check = () => {
|
|
159
|
+
if (client.getState().status !== 'loading')
|
|
160
|
+
resolve();
|
|
161
|
+
};
|
|
162
|
+
unsubscribe = client.onAuthChange(check);
|
|
163
|
+
// Close the read/subscribe gap and include clients that settle only
|
|
164
|
+
// their initialization promise rather than emitting a final change.
|
|
165
|
+
check();
|
|
166
|
+
void joined.then(check);
|
|
167
|
+
});
|
|
168
|
+
return ready.finally(() => unsubscribe?.());
|
|
169
|
+
}));
|
|
170
|
+
}
|
|
142
171
|
return makeEnvironmentProviders(providers);
|
|
143
172
|
}
|
|
144
173
|
//# sourceMappingURL=providers.js.map
|
package/dist/providers.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,
|
|
1
|
+
{"version":3,"file":"providers.js","sourceRoot":"","sources":["../src/providers.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,eAAe,CAAA;AAWtB,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,EACL,WAAW,EACX,WAAW,EACX,aAAa,EACb,eAAe,EACf,MAAM,EACN,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,aAAa,CAAA;AAGpB;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAuB;IAClD,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAA;AACpF,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAI,MAAqB;IAClD,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC,CAAA;AAC/E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,QAAuB;IAClD,OAAO,wBAAwB,CAAC,C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AED,OAAO,wBAAwB,CAAC,SAAS,CAAC,CAAA;AAC5C,CAAC"}
|
|
@@ -5,8 +5,16 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { type OnDestroy } from '@angular/core';
|
|
7
7
|
import { type Observable } from 'rxjs';
|
|
8
|
-
import type { FieldRegistration, FormController, FormOptions, FormProvider, FormState, FormValuesConstraint, RegisterOptions } from '@molecule/app-forms';
|
|
8
|
+
import type { FieldRegistration, FormController, FormOptions, FormProvider, FormResetOptions, FormState, FormValuesConstraint, RegisterOptions } from '@molecule/app-forms';
|
|
9
9
|
import * as i0 from "@angular/core";
|
|
10
|
+
/**
|
|
11
|
+
* Angular form creation options. Unlike `FormOptions`, this narrowed type does
|
|
12
|
+
* not accept `values` or `resetOptions`: signal-backed getters are not observed.
|
|
13
|
+
* Deliver records after creation through the returned instance's
|
|
14
|
+
* `updateValues(values, { keepDirtyValues })` method. The option defaults to
|
|
15
|
+
* false; pass true to retain edited fields while pristine fields take the record.
|
|
16
|
+
*/
|
|
17
|
+
type AngularFormOptions<T extends FormValuesConstraint<T>> = Omit<FormOptions<T>, 'values' | 'resetOptions'>;
|
|
10
18
|
/**
|
|
11
19
|
* Wrapper around a FormController that provides RxJS observables and
|
|
12
20
|
* synchronous accessors for use in Angular components.
|
|
@@ -150,6 +158,13 @@ export declare class MoleculeFormInstance<T extends FormValuesConstraint<T>> {
|
|
|
150
158
|
handleSubmit(onSubmit: (values: T) => void | Promise<void>, onError?: (errors: Partial<Record<keyof T, string>>) => void): (event?: {
|
|
151
159
|
preventDefault?: () => void;
|
|
152
160
|
}) => Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Apply a newly loaded record without clearing submission state.
|
|
163
|
+
*
|
|
164
|
+
* @param values - The newly loaded record.
|
|
165
|
+
* @param resetOptions - Set `keepDirtyValues` to retain edits and fill pristine fields.
|
|
166
|
+
*/
|
|
167
|
+
updateValues(values: Partial<T>, resetOptions?: FormResetOptions): void;
|
|
153
168
|
/**
|
|
154
169
|
* Reset the form to initial values.
|
|
155
170
|
*
|
|
@@ -223,10 +238,13 @@ export declare class MoleculeFormsService implements OnDestroy {
|
|
|
223
238
|
* Create a form instance from a provider.
|
|
224
239
|
*
|
|
225
240
|
* @param provider - The form provider that creates form controllers.
|
|
226
|
-
* @param options -
|
|
227
|
-
*
|
|
241
|
+
* @param options - Narrowed `FormOptions` without `values` or `resetOptions`;
|
|
242
|
+
* includes default values and validation mode.
|
|
243
|
+
* @returns A new form instance with RxJS observables and explicit
|
|
244
|
+
* `updateValues(values, { keepDirtyValues })` delivery. The option defaults to
|
|
245
|
+
* false; pass true to retain edited fields while pristine fields take the record.
|
|
228
246
|
*/
|
|
229
|
-
createForm<T extends FormValuesConstraint<T>>(provider: FormProvider, options:
|
|
247
|
+
createForm<T extends FormValuesConstraint<T>>(provider: FormProvider, options: AngularFormOptions<T>): MoleculeFormInstance<T>;
|
|
230
248
|
/**
|
|
231
249
|
* Destroy all managed form instances on service destruction.
|
|
232
250
|
*/
|
|
@@ -234,4 +252,5 @@ export declare class MoleculeFormsService implements OnDestroy {
|
|
|
234
252
|
static ɵfac: i0.ɵɵFactoryDeclaration<MoleculeFormsService, never>;
|
|
235
253
|
static ɵprov: i0.ɵɵInjectableDeclaration<any>;
|
|
236
254
|
}
|
|
255
|
+
export {};
|
|
237
256
|
//# sourceMappingURL=forms.service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forms.service.d.ts","sourceRoot":"","sources":["../../src/services/forms.service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAc,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAA8C,KAAK,UAAU,EAAE,MAAM,MAAM,CAAA;AAElF,OAAO,KAAK,EACV,iBAAiB,EACjB,cAAc,EACd,WAAW,EACX,YAAY,EACZ,SAAS,EACT,oBAAoB,EACpB,eAAe,EAChB,MAAM,qBAAqB,CAAA;;AAE5B;;;;;;;;;;;;;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CAAC,CAAC,SAAS,oBAAoB,CAAC,CAAC,CAAC,EAC1C,QAAQ,EAAE,YAAY,EACtB,OAAO,EAAE,kBAAkB,CAAC,CAAC,CAAC,GAC7B,oBAAoB,CAAC,CAAC,CAAC;IAO1B;;OAEG;IACH,WAAW,IAAI,IAAI;yCA1BR,oBAAoB;;CAgChC"}
|
|
@@ -59,9 +59,9 @@ export class MoleculeFormInstance {
|
|
|
59
59
|
this.controller = controller;
|
|
60
60
|
this.unsubscribe = null;
|
|
61
61
|
this.stateSubject = new BehaviorSubject(controller.getState());
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
const refresh = () => this.stateSubject.next(controller.getState());
|
|
63
|
+
this.unsubscribe = controller.subscribe(refresh);
|
|
64
|
+
refresh();
|
|
65
65
|
this.state$ = this.stateSubject.asObservable();
|
|
66
66
|
this.isValid$ = this.state$.pipe(map((state) => state.isValid), distinctUntilChanged());
|
|
67
67
|
this.isDirty$ = this.state$.pipe(map((state) => state.isDirty), distinctUntilChanged());
|
|
@@ -166,6 +166,15 @@ export class MoleculeFormInstance {
|
|
|
166
166
|
handleSubmit(onSubmit, onError) {
|
|
167
167
|
return this.controller.handleSubmit(onSubmit, onError);
|
|
168
168
|
}
|
|
169
|
+
/**
|
|
170
|
+
* Apply a newly loaded record without clearing submission state.
|
|
171
|
+
*
|
|
172
|
+
* @param values - The newly loaded record.
|
|
173
|
+
* @param resetOptions - Set `keepDirtyValues` to retain edits and fill pristine fields.
|
|
174
|
+
*/
|
|
175
|
+
updateValues(values, resetOptions = {}) {
|
|
176
|
+
this.controller.updateValues(values, resetOptions);
|
|
177
|
+
}
|
|
169
178
|
/**
|
|
170
179
|
* Reset the form to initial values.
|
|
171
180
|
*
|
|
@@ -250,8 +259,11 @@ export class MoleculeFormsService {
|
|
|
250
259
|
* Create a form instance from a provider.
|
|
251
260
|
*
|
|
252
261
|
* @param provider - The form provider that creates form controllers.
|
|
253
|
-
* @param options -
|
|
254
|
-
*
|
|
262
|
+
* @param options - Narrowed `FormOptions` without `values` or `resetOptions`;
|
|
263
|
+
* includes default values and validation mode.
|
|
264
|
+
* @returns A new form instance with RxJS observables and explicit
|
|
265
|
+
* `updateValues(values, { keepDirtyValues })` delivery. The option defaults to
|
|
266
|
+
* false; pass true to retain edited fields while pristine fields take the record.
|
|
255
267
|
*/
|
|
256
268
|
createForm(provider, options) {
|
|
257
269
|
const controller = provider.createForm(options);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forms.service.js","sourceRoot":"","sources":["../../src/services/forms.service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAkB,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,GAAG,EAAmB,MAAM,MAAM,CAAA;;
|
|
1
|
+
{"version":3,"file":"forms.service.js","sourceRoot":"","sources":["../../src/services/forms.service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,UAAU,EAAkB,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,GAAG,EAAmB,MAAM,MAAM,CAAA;;AAyBlF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,MAAM,OAAO,oBAAoB;IA6B/B,YAAoB,UAA6B;QAA7B,eAAU,GAAV,UAAU,CAAmB;QA3BzC,gBAAW,GAAwB,IAAI,CAAA;QA4B7C,IAAI,CAAC,YAAY,GAAG,IAAI,eAAe,CAAe,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAA;QAE5E,MAAM,OAAO,GAAG,GAAS,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAA;QACzE,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC,SAAS,CAAC,OAAO,CAAC,CAAA;QAChD,OAAO,EAAE,CAAA;QAET,IA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oleculeModuleConfig {
|
|
19
19
|
state?: StateProvider;
|
|
20
20
|
auth?: AuthClient<unknown>;
|
|
21
|
+
/**
|
|
22
|
+
* Hold bootstrap (and so every page's first render) until `auth` has decided the
|
|
23
|
+
* session. After a full page load a returning visitor's session is restored by one
|
|
24
|
+
* request, and until it answers `MoleculeAuthService.user` is `null` everywhere — a
|
|
25
|
+
* public page's signed-in action (`if (!user) return`, a redirect to `/login`) then
|
|
26
|
+
* treats a signed-in visitor as signed out. With this set, Angular's app initializer
|
|
27
|
+
* waits only while status is `'loading'`, so a cached session can render while its
|
|
28
|
+
* verification continues in the background. `'unavailable'` also renders and may have a
|
|
29
|
+
* null user. Without a session hint, an anonymous visitor settles in microtasks without
|
|
30
|
+
* a request. Ignored without `auth`.
|
|
31
|
+
*/
|
|
32
|
+
awaitSession?: boolean;
|
|
21
33
|
theme?: ThemeProvider;
|
|
22
34
|
router?: Router;
|
|
23
35
|
i18n?: I18nProvider;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC5F,OAAO,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAC5E,OAA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