mn-angular-lib 2.0.33 → 2.0.35

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 (52) hide show
  1. package/fesm2022/mn-angular-lib-alert.mjs +515 -527
  2. package/fesm2022/mn-angular-lib-alert.mjs.map +1 -1
  3. package/fesm2022/mn-angular-lib-bottom-sheet.mjs +264 -357
  4. package/fesm2022/mn-angular-lib-bottom-sheet.mjs.map +1 -1
  5. package/fesm2022/mn-angular-lib-button.mjs +819 -382
  6. package/fesm2022/mn-angular-lib-button.mjs.map +1 -1
  7. package/fesm2022/mn-angular-lib-calendar-core.mjs +240 -365
  8. package/fesm2022/mn-angular-lib-calendar-core.mjs.map +1 -1
  9. package/fesm2022/mn-angular-lib-calendar.mjs +1691 -1545
  10. package/fesm2022/mn-angular-lib-calendar.mjs.map +1 -1
  11. package/fesm2022/mn-angular-lib-collection.mjs +2367 -2796
  12. package/fesm2022/mn-angular-lib-collection.mjs.map +1 -1
  13. package/fesm2022/mn-angular-lib-core.mjs +693 -1241
  14. package/fesm2022/mn-angular-lib-core.mjs.map +1 -1
  15. package/fesm2022/mn-angular-lib-display.mjs +679 -712
  16. package/fesm2022/mn-angular-lib-display.mjs.map +1 -1
  17. package/fesm2022/mn-angular-lib-forms.mjs +3671 -4647
  18. package/fesm2022/mn-angular-lib-forms.mjs.map +1 -1
  19. package/fesm2022/mn-angular-lib-keyboard.mjs +221 -190
  20. package/fesm2022/mn-angular-lib-keyboard.mjs.map +1 -1
  21. package/fesm2022/mn-angular-lib-modal-core.mjs +711 -896
  22. package/fesm2022/mn-angular-lib-modal-core.mjs.map +1 -1
  23. package/fesm2022/mn-angular-lib-modal-ui.mjs +2089 -2035
  24. package/fesm2022/mn-angular-lib-modal-ui.mjs.map +1 -1
  25. package/fesm2022/mn-angular-lib-modal.mjs +76 -121
  26. package/fesm2022/mn-angular-lib-modal.mjs.map +1 -1
  27. package/fesm2022/mn-angular-lib-rich-text-editor.mjs +289 -277
  28. package/fesm2022/mn-angular-lib-rich-text-editor.mjs.map +1 -1
  29. package/fesm2022/mn-angular-lib-segmented.mjs +189 -241
  30. package/fesm2022/mn-angular-lib-segmented.mjs.map +1 -1
  31. package/fesm2022/mn-angular-lib-tab.mjs +409 -642
  32. package/fesm2022/mn-angular-lib-tab.mjs.map +1 -1
  33. package/fesm2022/mn-angular-lib.mjs +16 -29
  34. package/package.json +1 -1
  35. package/types/mn-angular-lib-alert.d.ts +239 -241
  36. package/types/mn-angular-lib-bottom-sheet.d.ts +190 -150
  37. package/types/mn-angular-lib-button.d.ts +319 -317
  38. package/types/mn-angular-lib-calendar-core.d.ts +199 -209
  39. package/types/mn-angular-lib-calendar.d.ts +656 -511
  40. package/types/mn-angular-lib-collection.d.ts +1649 -1585
  41. package/types/mn-angular-lib-core.d.ts +524 -535
  42. package/types/mn-angular-lib-display.d.ts +946 -886
  43. package/types/mn-angular-lib-forms.d.ts +3012 -3013
  44. package/types/mn-angular-lib-keyboard.d.ts +125 -85
  45. package/types/mn-angular-lib-modal-core.d.ts +978 -994
  46. package/types/mn-angular-lib-modal-ui.d.ts +541 -493
  47. package/types/mn-angular-lib-modal.d.ts +24 -27
  48. package/types/mn-angular-lib-rich-text-editor.d.ts +131 -98
  49. package/types/mn-angular-lib-segmented.d.ts +354 -341
  50. package/types/mn-angular-lib-tab.d.ts +345 -336
  51. package/types/mn-angular-lib.d.ts +16 -16
  52. package/fesm2022/mn-angular-lib.mjs.map +0 -1
@@ -1,37 +1,35 @@
1
- import * as i0 from '@angular/core';
2
- import { Provider, InjectionToken, PipeTransform } from '@angular/core';
3
- import { HttpStatusCode, HttpHeaders, HttpErrorResponse, HttpClient, HttpResponse, HttpParams } from '@angular/common/http';
4
- import { Observable } from 'rxjs';
5
- import { ValidationErrors } from '@angular/forms';
6
- import { LucideIconData } from '@lucide/angular';
7
- import { IconNode } from 'lucide';
8
-
1
+ import * as i0 from "@angular/core";
2
+ import { InjectionToken, PipeTransform, Provider } from "@angular/core";
3
+ import { HttpClient, HttpErrorResponse, HttpHeaders, HttpParams, HttpResponse, HttpStatusCode } from "@angular/common/http";
4
+ import { Observable } from "rxjs";
5
+ import { ValidationErrors } from "@angular/forms";
6
+ import { LucideIconData } from "@lucide/angular";
7
+ import { IconNode } from "lucide";
9
8
  /**
10
9
  * Types for mn-lib configuration.
11
10
  */
12
- type MnConfigSettings = {
13
- /** Application or library version. */
14
- version?: string;
15
- /** Application or library name. */
16
- name?: string;
11
+ export type MnConfigSettings = {
12
+ /** Application or library version. */
13
+ version?: string;
14
+ /** Application or library name. */
15
+ name?: string;
17
16
  };
18
- type MnConfigFile = {
19
- /**
20
- * General settings such as version and name.
21
- */
22
- settings?: MnConfigSettings;
23
- /**
24
- * Base defaults by component name. Each value is a plain object with inputs/options for that component.
25
- */
26
- defaults: Record<string, unknown>;
27
- /**
28
- * Nested object tree keyed by section names. Leaf nodes may contain
29
- * component-name keys (component override objects) and keys starting with '#'
30
- * representing instance-id overrides.
31
- */
32
- overrides: Record<string, unknown>;
17
+ export type MnConfigFile = {
18
+ /**
19
+ * General settings such as version and name.
20
+ */
21
+ settings?: MnConfigSettings;
22
+ /**
23
+ * Base defaults by component name. Each value is a plain object with inputs/options for that component.
24
+ */
25
+ defaults: Record<string, unknown>;
26
+ /**
27
+ * Nested object tree keyed by section names. Leaf nodes may contain
28
+ * component-name keys (component override objects) and keys starting with '#'
29
+ * representing instance-id overrides.
30
+ */
31
+ overrides: Record<string, unknown>;
33
32
  };
34
-
35
33
  /**
36
34
  * Parses a config file. Strict JSON goes through `JSON.parse`; only a file that needs JSON5
37
35
  * syntax (comments, unquoted keys, trailing commas) loads the `json5` parser, as its own chunk.
@@ -40,60 +38,58 @@ type MnConfigFile = {
40
38
  * @param text The raw file content.
41
39
  * @returns The parsed value.
42
40
  */
43
- declare function parseConfigText(text: string): Promise<unknown>;
44
- declare class MnConfigService {
45
- private readonly http;
46
- private _config;
47
- private _settings;
48
- private _debugMode;
49
- /** Reactive version counter — incremented on every config load. */
50
- private _configVersion;
51
- readonly configVersion: i0.Signal<number>;
52
- private readonly lang;
53
- /** General settings from the config file (version, name, etc.). */
54
- get settings(): Readonly<MnConfigSettings>;
55
- /**
56
- * Load the configuration JSON from the provided URL and cache it in memory.
57
- * Consumers should typically call this via the APP_INITIALIZER helper.
58
- */
59
- load(url: string, debugMode?: boolean): Promise<void>;
60
- /**
61
- * Load configuration from a pre-parsed object (no HTTP fetch).
62
- * Used for live preview scenarios where config is pushed via postMessage.
63
- * Optionally re-bootstraps the language service if a `language` section is present.
64
- */
65
- loadFromObject(config: Record<string, unknown>, bootstrapLanguage?: boolean): Promise<void>;
66
- /**
67
- * Resolve a configuration object for a component, optionally scoped to a section path
68
- * and optionally overridden by an instance id.
69
- */
70
- resolve<T extends object = Record<string, unknown>>(componentName: string, sectionPath?: string[], instanceId?: string): T;
71
- /**
72
- * Walk the overrides nested object using the provided section path and return the leaf node.
73
- * If any segment is missing or the current node is not a plain object, returns undefined.
74
- */
75
- walkOverrides(overridesRoot: unknown, sectionPath: string[]): unknown | undefined;
76
- /**
77
- * Recursively walk a resolved config object and replace any `{ $translate: "key" }` markers
78
- * with their translated values from MnLanguageService.
79
- */
80
- private resolveTranslatables;
81
- /**
82
- * Deep merge two plain-object trees. Arrays and non-plain values are replaced by the patch.
83
- * Does not mutate inputs; returns a new object.
84
- */
85
- deepMerge<A extends Record<string, unknown>, B extends Record<string, unknown>>(base: A, patch: B): A & B;
86
- static ɵfac: i0.ɵɵFactoryDeclaration<MnConfigService, never>;
87
- static ɵprov: i0.ɵɵInjectableDeclaration<any>;
41
+ export declare function parseConfigText(text: string): Promise<unknown>;
42
+ export declare class MnConfigService {
43
+ private readonly http;
44
+ private _config;
45
+ private _settings;
46
+ private _debugMode;
47
+ /** Reactive version counter — incremented on every config load. */
48
+ private _configVersion;
49
+ readonly configVersion: import("@angular/core").Signal<number>;
50
+ private readonly lang;
51
+ /** General settings from the config file (version, name, etc.). */
52
+ get settings(): Readonly<MnConfigSettings>;
53
+ /**
54
+ * Load the configuration JSON from the provided URL and cache it in memory.
55
+ * Consumers should typically call this via the APP_INITIALIZER helper.
56
+ */
57
+ load(url: string, debugMode?: boolean): Promise<void>;
58
+ /**
59
+ * Load configuration from a pre-parsed object (no HTTP fetch).
60
+ * Used for live preview scenarios where config is pushed via postMessage.
61
+ * Optionally re-bootstraps the language service if a `language` section is present.
62
+ */
63
+ loadFromObject(config: Record<string, unknown>, bootstrapLanguage?: boolean): Promise<void>;
64
+ /**
65
+ * Resolve a configuration object for a component, optionally scoped to a section path
66
+ * and optionally overridden by an instance id.
67
+ */
68
+ resolve<T extends object = Record<string, unknown>>(componentName: string, sectionPath?: string[], instanceId?: string): T;
69
+ /**
70
+ * Walk the overrides nested object using the provided section path and return the leaf node.
71
+ * If any segment is missing or the current node is not a plain object, returns undefined.
72
+ */
73
+ walkOverrides(overridesRoot: unknown, sectionPath: string[]): unknown | undefined;
74
+ /**
75
+ * Recursively walk a resolved config object and replace any `{ $translate: "key" }` markers
76
+ * with their translated values from MnLanguageService.
77
+ */
78
+ private resolveTranslatables;
79
+ /**
80
+ * Deep merge two plain-object trees. Arrays and non-plain values are replaced by the patch.
81
+ * Does not mutate inputs; returns a new object.
82
+ */
83
+ deepMerge<A extends Record<string, unknown>, B extends Record<string, unknown>>(base: A, patch: B): A & B;
84
+ static ɵfac: i0.ɵɵFactoryDeclaration<MnConfigService, never>;
85
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
88
86
  }
89
-
90
87
  /**
91
88
  * Provides an APP_INITIALIZER that loads the mn-lib configuration from the given URL
92
89
  * during application bootstrap. The consuming application is responsible for providing
93
90
  * HttpClient (e.g., via HttpClientModule or provideHttpClient()).
94
91
  */
95
- declare function provideMnConfig(url: string, debugMode?: boolean): Provider[];
96
-
92
+ export declare function provideMnConfig(url: string, debugMode?: boolean): Provider[];
97
93
  /**
98
94
  * Helper to provide a resolved, typed component config via DI.
99
95
  *
@@ -107,45 +103,51 @@ declare function provideMnConfig(url: string, debugMode?: boolean): Provider[];
107
103
  * all translatable values are re-resolved in place so that templates using
108
104
  * `cfg.someLabel` automatically reflect the new language on the next change-detection cycle.
109
105
  */
110
- declare function provideMnComponentConfig<T extends object>(token: InjectionToken<T>, componentName: string, initial?: Partial<T>): Provider;
111
-
106
+ export declare function provideMnComponentConfig<T extends object>(token: InjectionToken<T>, componentName: string, initial?: Partial<T>): Provider;
112
107
  /**
113
108
  * Represents the current section path based on nested mn-section directives.
114
109
  */
115
- declare const MN_SECTION_PATH: InjectionToken<string[]>;
110
+ export declare const MN_SECTION_PATH: InjectionToken<string[]>;
116
111
  /**
117
112
  * Whether the injecting component renders inside an mn modal. `MnModalShellComponent` provides
118
113
  * `true` for everything in its view, so a component deep in a modal body can tell without the
119
114
  * consumer passing anything: mn-table uses it to skip its own bottom sheet, because a sheet
120
115
  * opened over a modal that is already a sheet on a phone stacks two drawers on one screen.
121
116
  */
122
- declare const MN_IN_MODAL: InjectionToken<boolean>;
117
+ export declare const MN_IN_MODAL: InjectionToken<boolean>;
123
118
  /**
124
119
  * Whether the injecting component renders inside an `mn-bottom-sheet`. The sheet provides `true`
125
120
  * to its content. mn-select and mn-multi-select read it: on a phone they normally open their
126
121
  * options as a bottom sheet of their own, which inside a sheet stacks a second one on top and
127
122
  * hides the form around it, so there they open as an anchored dropdown instead.
128
123
  */
129
- declare const MN_IN_BOTTOM_SHEET: InjectionToken<boolean>;
124
+ export declare const MN_IN_BOTTOM_SHEET: InjectionToken<boolean>;
130
125
  /**
131
126
  * Represents the current component instance id provided by [mn-instance].
132
127
  */
133
- declare const MN_INSTANCE_ID: InjectionToken<string | null>;
134
-
135
- declare class MnSectionDirective {
136
- /** Section name contributed by this DOM node to the section path */
137
- mnSection: string | undefined;
138
- static ɵfac: i0.ɵɵFactoryDeclaration<MnSectionDirective, never>;
139
- static ɵdir: i0.ɵɵDirectiveDeclaration<MnSectionDirective, "[mn-section]", never, { "mnSection": { "alias": "mn-section"; "required": false; }; }, {}, never, never, true, never>;
128
+ export declare const MN_INSTANCE_ID: InjectionToken<string | null>;
129
+ export declare class MnSectionDirective {
130
+ /** Section name contributed by this DOM node to the section path */
131
+ mnSection: string | undefined;
132
+ static ɵfac: i0.ɵɵFactoryDeclaration<MnSectionDirective, never>;
133
+ static ɵdir: i0.ɵɵDirectiveDeclaration<MnSectionDirective, "[mn-section]", never, {
134
+ "mnSection": {
135
+ "alias": "mn-section";
136
+ "required": false;
137
+ };
138
+ }, {}, never, never, true, never>;
140
139
  }
141
-
142
- declare class MnInstanceDirective {
143
- /** Instance id for targeting per-component instance overrides */
144
- mnInstance: string | undefined;
145
- static ɵfac: i0.ɵɵFactoryDeclaration<MnInstanceDirective, never>;
146
- static ɵdir: i0.ɵɵDirectiveDeclaration<MnInstanceDirective, "[mn-instance]", never, { "mnInstance": { "alias": "mn-instance"; "required": false; }; }, {}, never, never, true, never>;
140
+ export declare class MnInstanceDirective {
141
+ /** Instance id for targeting per-component instance overrides */
142
+ mnInstance: string | undefined;
143
+ static ɵfac: i0.ɵɵFactoryDeclaration<MnInstanceDirective, never>;
144
+ static ɵdir: i0.ɵɵDirectiveDeclaration<MnInstanceDirective, "[mn-instance]", never, {
145
+ "mnInstance": {
146
+ "alias": "mn-instance";
147
+ "required": false;
148
+ };
149
+ }, {}, never, never, true, never>;
147
150
  }
148
-
149
151
  /**
150
152
  * A structured representation of an API error.
151
153
  *
@@ -153,17 +155,17 @@ declare class MnInstanceDirective {
153
155
  * and retry information — so consumers can log, display, or act on
154
156
  * failures without inspecting the raw HTTP response.
155
157
  */
156
- type ApiError = {
157
- status: HttpStatusCode | null;
158
- message: string;
159
- details?: unknown;
160
- backendMessage?: string;
161
- validationErrors?: Record<string, string[]>;
162
- url?: string | null;
163
- headers?: HttpHeaders;
164
- original: HttpErrorResponse | Error;
165
- retryable: boolean;
166
- timestamp: string;
158
+ export type ApiError = {
159
+ status: HttpStatusCode | null;
160
+ message: string;
161
+ details?: unknown;
162
+ backendMessage?: string;
163
+ validationErrors?: Record<string, string[]>;
164
+ url?: string | null;
165
+ headers?: HttpHeaders;
166
+ original: HttpErrorResponse | Error;
167
+ retryable: boolean;
168
+ timestamp: string;
167
169
  };
168
170
  /**
169
171
  * Metadata associated with an API result.
@@ -172,10 +174,10 @@ type ApiError = {
172
174
  * transport-level details such as the HTTP status code, response
173
175
  * headers, and the final URL after any redirects.
174
176
  */
175
- type ResultMeta = {
176
- statusCode?: number;
177
- headers?: HttpHeaders;
178
- url?: string;
177
+ export type ResultMeta = {
178
+ statusCode?: number;
179
+ headers?: HttpHeaders;
180
+ url?: string;
179
181
  };
180
182
  /**
181
183
  * Represents a successful API result containing the response data.
@@ -185,10 +187,10 @@ type ResultMeta = {
185
187
  *
186
188
  * @template T The type of the response data.
187
189
  */
188
- type SuccessResult<T> = {
189
- ok: true;
190
- data: T;
191
- meta?: ResultMeta;
190
+ export type SuccessResult<T> = {
191
+ ok: true;
192
+ data: T;
193
+ meta?: ResultMeta;
192
194
  };
193
195
  /**
194
196
  * Represents a failed API result containing the structured error.
@@ -196,10 +198,10 @@ type SuccessResult<T> = {
196
198
  * Discriminated by `ok: false`. Use `result.ok` to narrow the union
197
199
  * before accessing `error`.
198
200
  */
199
- type FailureResult = {
200
- ok: false;
201
- error: ApiError;
202
- meta?: ResultMeta;
201
+ export type FailureResult = {
202
+ ok: false;
203
+ error: ApiError;
204
+ meta?: ResultMeta;
203
205
  };
204
206
  /**
205
207
  * A discriminated union representing either a successful or failed API result.
@@ -209,20 +211,20 @@ type FailureResult = {
209
211
  *
210
212
  * @template T The type of the response data on success.
211
213
  */
212
- type Result<T> = SuccessResult<T> | FailureResult;
214
+ export type Result<T> = SuccessResult<T> | FailureResult;
213
215
  /**
214
216
  * A JavaScript primitive value.
215
217
  *
216
218
  * Used as the building block for query parameter values.
217
219
  */
218
- type Primitive = string | number | boolean | null | undefined;
220
+ export type Primitive = string | number | boolean | null | undefined;
219
221
  /**
220
222
  * A value that can be used as a query parameter.
221
223
  *
222
224
  * Either a single primitive or an array of primitives.
223
225
  * Array values are appended as multiple entries for the same key.
224
226
  */
225
- type QueryValue = Primitive | Primitive[];
227
+ export type QueryValue = Primitive | Primitive[];
226
228
  /**
227
229
  * A record of query parameter key-value pairs.
228
230
  *
@@ -230,16 +232,15 @@ type QueryValue = Primitive | Primitive[];
230
232
  * before the request is sent. `null` and `undefined` values
231
233
  * are silently skipped during conversion.
232
234
  */
233
- type QueryParams = Record<string, QueryValue>;
234
-
235
+ export type QueryParams = Record<string, QueryValue>;
235
236
  /**
236
237
  * Configuration for a CRUD service endpoint.
237
238
  *
238
239
  * Passed to the `CrudService` constructor to define which API
239
240
  * resource the service operates on.
240
241
  */
241
- type CrudConfig = {
242
- endpoint: string;
242
+ export type CrudConfig = {
243
+ endpoint: string;
243
244
  };
244
245
  /**
245
246
  * Abstract base class for CRUD services.
@@ -255,192 +256,190 @@ type CrudConfig = {
255
256
  * @template TUpdateResponse The response type for update and patch (defaults to `TEntity`).
256
257
  * @template TDeleteResponse The response type for delete (defaults to `void`).
257
258
  */
258
- declare abstract class CrudService<TEntity, TListResponse = TEntity[], TCreatePayload = Partial<TEntity>, TUpdatePayload = Partial<TEntity>, TId extends string | number = number, TGetByIdResponse = TEntity, TCreateResponse = TEntity, TUpdateResponse = TEntity, TDeleteResponse = void> {
259
- protected readonly http: HttpClient;
260
- protected readonly baseUrl: string;
261
- protected readonly endpoint: string;
262
- protected constructor(config: CrudConfig);
263
- /**
264
- * Retrieves all entities from the configured endpoint.
265
- *
266
- * Sends a GET request to the base endpoint. Query values are
267
- * converted to `HttpParams` before the request is sent.
268
- *
269
- * @param query Optional query parameters appended to the request URL.
270
- * @returns An observable emitting a `Result` with the list response or a structured failure.
271
- */
272
- getAll(query?: QueryParams): Observable<Result<TListResponse>>;
273
- /**
274
- * Retrieves a single entity by its identifier.
275
- *
276
- * Sends a GET request to `{endpoint}/{id}`.
277
- *
278
- * @param id The unique identifier of the entity to retrieve.
279
- * @returns An observable emitting a `Result` with the entity or a structured failure.
280
- */
281
- getById(id: TId): Observable<Result<TGetByIdResponse>>;
282
- /**
283
- * Creates a new entity at the configured endpoint.
284
- *
285
- * Sends a POST request with the provided payload as the request body.
286
- *
287
- * @param payload The data used to create the entity.
288
- * @returns An observable emitting a `Result` with the created entity or a structured failure.
289
- */
290
- create(payload: TCreatePayload): Observable<Result<TCreateResponse>>;
291
- /**
292
- * Fully replaces an existing entity.
293
- *
294
- * Sends a PUT request to `{endpoint}/{id}` with the provided payload,
295
- * replacing the entire entity.
296
- *
297
- * @param id The unique identifier of the entity to update.
298
- * @param payload The complete data to replace the existing entity with.
299
- * @returns An observable emitting a `Result` with the updated entity or a structured failure.
300
- */
301
- update(id: TId, payload: TUpdatePayload): Observable<Result<TUpdateResponse>>;
302
- /**
303
- * Partially updates an existing entity.
304
- *
305
- * Sends a PATCH request to `{endpoint}/{id}` with the provided payload,
306
- * merging changes into the existing entity.
307
- *
308
- * @param id The unique identifier of the entity to patch.
309
- * @param payload A partial set of fields to update on the existing entity.
310
- * @returns An observable emitting a `Result` with the updated entity or a structured failure.
311
- */
312
- patch(id: TId, payload: Partial<TUpdatePayload>): Observable<Result<TUpdateResponse>>;
313
- /**
314
- * Deletes an entity by its identifier.
315
- *
316
- * Sends a DELETE request to `{endpoint}/{id}`.
317
- *
318
- * @param id The unique identifier of the entity to delete.
319
- * @returns An observable emitting a `Result` with the delete response or a structured failure.
320
- */
321
- delete(id: TId): Observable<Result<TDeleteResponse>>;
322
- /**
323
- * Retrieves all entities with the full `HttpResponse` wrapper.
324
- *
325
- * Behaves like {@link getAll} but observes the complete HTTP response,
326
- * giving access to headers, status code, and URL alongside the body.
327
- *
328
- * @param query Optional query parameters appended to the request URL.
329
- * @returns An observable emitting a `Result` with the full HTTP response or a structured failure.
330
- */
331
- getAllResponse(query?: QueryParams): Observable<Result<HttpResponse<TListResponse>>>;
332
- /**
333
- * Builds the URL for a single entity by appending the identifier to the endpoint.
334
- *
335
- * @param id The unique identifier to append.
336
- * @returns The full URL targeting the specific entity.
337
- */
338
- protected itemUrl(id: TId): string;
339
- /**
340
- * Wraps a value in a `SuccessResult`.
341
- *
342
- * @template T The type of the response data.
343
- * @param data The response data to wrap.
344
- * @param meta Optional metadata (status code, headers, URL) to attach.
345
- * @returns A `SuccessResult` containing the provided data.
346
- */
347
- protected success<T>(data: T, meta?: ResultMeta): SuccessResult<T>;
348
- /**
349
- * Wraps an error in a `FailureResult`.
350
- *
351
- * When no explicit metadata is provided, metadata is derived from
352
- * the `ApiError` itself (status code, headers, URL).
353
- *
354
- * @param error The structured API error.
355
- * @param meta Optional metadata to override the error-derived values.
356
- * @returns A `FailureResult` containing the error and metadata.
357
- */
358
- protected failure(error: ApiError, meta?: ResultMeta): FailureResult;
359
- /**
360
- * Maps an unknown error into a structured `ApiError`.
361
- *
362
- * Handles both `HttpErrorResponse` instances and unexpected error types.
363
- * Extracts backend messages, validation errors, and retry information
364
- * so callers receive a consistent error shape.
365
- *
366
- * @param error The raw error caught from the HTTP pipeline.
367
- * @returns A fully populated `ApiError` object.
368
- */
369
- protected mapHttpError(error: unknown): ApiError;
370
- /**
371
- * Extracts a human-readable message from the error response body.
372
- *
373
- * Checks common keys (`message`, `title`, `detail`, `error`) on the
374
- * body object and returns the first non-empty string found.
375
- *
376
- * @param body The parsed error response body.
377
- * @returns The extracted message, or `undefined` if none was found.
378
- */
379
- protected extractBackendMessage(body: unknown): string | undefined;
380
- /**
381
- * Extracts field-level validation errors from the error response body.
382
- *
383
- * Expects an `errors` property on the body containing a record of
384
- * field names to error messages (string or string array).
385
- *
386
- * @param body The parsed error response body.
387
- * @returns A record mapping field names to their error messages, or `undefined` if none were found.
388
- */
389
- protected extractValidationErrors(body: unknown): Record<string, string[]> | undefined;
390
- /**
391
- * Returns a default user-facing message for the given HTTP status code.
392
- *
393
- * Provides human-readable messages for common HTTP status codes.
394
- * Override this method to customise messages.
395
- *
396
- * @param status The HTTP status code, or `null` when unknown.
397
- * @returns A descriptive error message.
398
- */
399
- protected defaultMessage(status: HttpStatusCode | null): string;
400
- /**
401
- * Determines whether a request with the given status can be retried.
402
- *
403
- * Timeouts, rate-limiting responses, and server errors
404
- * (5xx) are considered retryable by default.
405
- *
406
- * @param status The HTTP status code, or `null` when unknown.
407
- * @returns `true` if the request is safe to retry.
408
- */
409
- protected isRetryable(status: HttpStatusCode | null): boolean;
410
- /**
411
- * Normalises a raw HTTP status into an `HttpStatusCode | null` value.
412
- *
413
- * Converts `undefined`, `NaN`, and `0` (network error) to `null`
414
- * so downstream code only needs to handle `HttpStatusCode | null`.
415
- *
416
- * @param status The raw status value from the HTTP response.
417
- * @returns The normalised status code, or `null` when indeterminate.
418
- */
419
- protected normalizeStatus(status: number | null | undefined): HttpStatusCode | null;
420
- /**
421
- * Converts query parameters into Angular `HttpParams`.
422
- *
423
- * `null` and `undefined` values are silently skipped.
424
- * Array values are appended as multiple entries for the same key.
425
- *
426
- * @param query The query parameter record to convert.
427
- * @returns An `HttpParams` instance, or `undefined` when no parameters are provided.
428
- */
429
- protected toHttpParams(query?: QueryParams): HttpParams | undefined;
259
+ export declare abstract class CrudService<TEntity, TListResponse = TEntity[], TCreatePayload = Partial<TEntity>, TUpdatePayload = Partial<TEntity>, TId extends string | number = number, TGetByIdResponse = TEntity, TCreateResponse = TEntity, TUpdateResponse = TEntity, TDeleteResponse = void> {
260
+ protected readonly http: HttpClient;
261
+ protected readonly baseUrl: string;
262
+ protected readonly endpoint: string;
263
+ protected constructor(config: CrudConfig);
264
+ /**
265
+ * Retrieves all entities from the configured endpoint.
266
+ *
267
+ * Sends a GET request to the base endpoint. Query values are
268
+ * converted to `HttpParams` before the request is sent.
269
+ *
270
+ * @param query Optional query parameters appended to the request URL.
271
+ * @returns An observable emitting a `Result` with the list response or a structured failure.
272
+ */
273
+ getAll(query?: QueryParams): Observable<Result<TListResponse>>;
274
+ /**
275
+ * Retrieves a single entity by its identifier.
276
+ *
277
+ * Sends a GET request to `{endpoint}/{id}`.
278
+ *
279
+ * @param id The unique identifier of the entity to retrieve.
280
+ * @returns An observable emitting a `Result` with the entity or a structured failure.
281
+ */
282
+ getById(id: TId): Observable<Result<TGetByIdResponse>>;
283
+ /**
284
+ * Creates a new entity at the configured endpoint.
285
+ *
286
+ * Sends a POST request with the provided payload as the request body.
287
+ *
288
+ * @param payload The data used to create the entity.
289
+ * @returns An observable emitting a `Result` with the created entity or a structured failure.
290
+ */
291
+ create(payload: TCreatePayload): Observable<Result<TCreateResponse>>;
292
+ /**
293
+ * Fully replaces an existing entity.
294
+ *
295
+ * Sends a PUT request to `{endpoint}/{id}` with the provided payload,
296
+ * replacing the entire entity.
297
+ *
298
+ * @param id The unique identifier of the entity to update.
299
+ * @param payload The complete data to replace the existing entity with.
300
+ * @returns An observable emitting a `Result` with the updated entity or a structured failure.
301
+ */
302
+ update(id: TId, payload: TUpdatePayload): Observable<Result<TUpdateResponse>>;
303
+ /**
304
+ * Partially updates an existing entity.
305
+ *
306
+ * Sends a PATCH request to `{endpoint}/{id}` with the provided payload,
307
+ * merging changes into the existing entity.
308
+ *
309
+ * @param id The unique identifier of the entity to patch.
310
+ * @param payload A partial set of fields to update on the existing entity.
311
+ * @returns An observable emitting a `Result` with the updated entity or a structured failure.
312
+ */
313
+ patch(id: TId, payload: Partial<TUpdatePayload>): Observable<Result<TUpdateResponse>>;
314
+ /**
315
+ * Deletes an entity by its identifier.
316
+ *
317
+ * Sends a DELETE request to `{endpoint}/{id}`.
318
+ *
319
+ * @param id The unique identifier of the entity to delete.
320
+ * @returns An observable emitting a `Result` with the delete response or a structured failure.
321
+ */
322
+ delete(id: TId): Observable<Result<TDeleteResponse>>;
323
+ /**
324
+ * Retrieves all entities with the full `HttpResponse` wrapper.
325
+ *
326
+ * Behaves like {@link getAll} but observes the complete HTTP response,
327
+ * giving access to headers, status code, and URL alongside the body.
328
+ *
329
+ * @param query Optional query parameters appended to the request URL.
330
+ * @returns An observable emitting a `Result` with the full HTTP response or a structured failure.
331
+ */
332
+ getAllResponse(query?: QueryParams): Observable<Result<HttpResponse<TListResponse>>>;
333
+ /**
334
+ * Builds the URL for a single entity by appending the identifier to the endpoint.
335
+ *
336
+ * @param id The unique identifier to append.
337
+ * @returns The full URL targeting the specific entity.
338
+ */
339
+ protected itemUrl(id: TId): string;
340
+ /**
341
+ * Wraps a value in a `SuccessResult`.
342
+ *
343
+ * @template T The type of the response data.
344
+ * @param data The response data to wrap.
345
+ * @param meta Optional metadata (status code, headers, URL) to attach.
346
+ * @returns A `SuccessResult` containing the provided data.
347
+ */
348
+ protected success<T>(data: T, meta?: ResultMeta): SuccessResult<T>;
349
+ /**
350
+ * Wraps an error in a `FailureResult`.
351
+ *
352
+ * When no explicit metadata is provided, metadata is derived from
353
+ * the `ApiError` itself (status code, headers, URL).
354
+ *
355
+ * @param error The structured API error.
356
+ * @param meta Optional metadata to override the error-derived values.
357
+ * @returns A `FailureResult` containing the error and metadata.
358
+ */
359
+ protected failure(error: ApiError, meta?: ResultMeta): FailureResult;
360
+ /**
361
+ * Maps an unknown error into a structured `ApiError`.
362
+ *
363
+ * Handles both `HttpErrorResponse` instances and unexpected error types.
364
+ * Extracts backend messages, validation errors, and retry information
365
+ * so callers receive a consistent error shape.
366
+ *
367
+ * @param error The raw error caught from the HTTP pipeline.
368
+ * @returns A fully populated `ApiError` object.
369
+ */
370
+ protected mapHttpError(error: unknown): ApiError;
371
+ /**
372
+ * Extracts a human-readable message from the error response body.
373
+ *
374
+ * Checks common keys (`message`, `title`, `detail`, `error`) on the
375
+ * body object and returns the first non-empty string found.
376
+ *
377
+ * @param body The parsed error response body.
378
+ * @returns The extracted message, or `undefined` if none was found.
379
+ */
380
+ protected extractBackendMessage(body: unknown): string | undefined;
381
+ /**
382
+ * Extracts field-level validation errors from the error response body.
383
+ *
384
+ * Expects an `errors` property on the body containing a record of
385
+ * field names to error messages (string or string array).
386
+ *
387
+ * @param body The parsed error response body.
388
+ * @returns A record mapping field names to their error messages, or `undefined` if none were found.
389
+ */
390
+ protected extractValidationErrors(body: unknown): Record<string, string[]> | undefined;
391
+ /**
392
+ * Returns a default user-facing message for the given HTTP status code.
393
+ *
394
+ * Provides human-readable messages for common HTTP status codes.
395
+ * Override this method to customise messages.
396
+ *
397
+ * @param status The HTTP status code, or `null` when unknown.
398
+ * @returns A descriptive error message.
399
+ */
400
+ protected defaultMessage(status: HttpStatusCode | null): string;
401
+ /**
402
+ * Determines whether a request with the given status can be retried.
403
+ *
404
+ * Timeouts, rate-limiting responses, and server errors
405
+ * (5xx) are considered retryable by default.
406
+ *
407
+ * @param status The HTTP status code, or `null` when unknown.
408
+ * @returns `true` if the request is safe to retry.
409
+ */
410
+ protected isRetryable(status: HttpStatusCode | null): boolean;
411
+ /**
412
+ * Normalises a raw HTTP status into an `HttpStatusCode | null` value.
413
+ *
414
+ * Converts `undefined`, `NaN`, and `0` (network error) to `null`
415
+ * so downstream code only needs to handle `HttpStatusCode | null`.
416
+ *
417
+ * @param status The raw status value from the HTTP response.
418
+ * @returns The normalised status code, or `null` when indeterminate.
419
+ */
420
+ protected normalizeStatus(status: number | null | undefined): HttpStatusCode | null;
421
+ /**
422
+ * Converts query parameters into Angular `HttpParams`.
423
+ *
424
+ * `null` and `undefined` values are silently skipped.
425
+ * Array values are appended as multiple entries for the same key.
426
+ *
427
+ * @param query The query parameter record to convert.
428
+ * @returns An `HttpParams` instance, or `undefined` when no parameters are provided.
429
+ */
430
+ protected toHttpParams(query?: QueryParams): HttpParams | undefined;
430
431
  }
431
-
432
432
  /**
433
433
  * Injection token for the base URL used by all CRUD service requests.
434
434
  *
435
435
  * Provide this token at the application or module level to configure
436
436
  * the root API URL that `CrudService` prepends to every endpoint.
437
437
  */
438
- declare const API_BASE_URL: InjectionToken<string>;
439
-
438
+ export declare const API_BASE_URL: InjectionToken<string>;
440
439
  /** A single query parameter value. */
441
440
  type MnQueryValue = string | number | boolean | null | undefined;
442
441
  /** A record of query parameter key-value pairs. Arrays are appended as multiple entries. */
443
- type MnQueryParams = Record<string, MnQueryValue | MnQueryValue[]>;
442
+ export type MnQueryParams = Record<string, MnQueryValue | MnQueryValue[]>;
444
443
  /**
445
444
  * Lightweight abstract HTTP base class that removes common boilerplate
446
445
  * from API services.
@@ -452,84 +451,81 @@ type MnQueryParams = Record<string, MnQueryValue | MnQueryValue[]>;
452
451
  * Subclass this directly for services with static or mixed endpoints.
453
452
  * No CRUD structure is imposed — every method accepts a free-form path.
454
453
  */
455
- declare abstract class MnHttpService {
456
- /** Angular HTTP client injected automatically. */
457
- protected readonly http: HttpClient;
458
- /** Base API URL provided via the `API_BASE_URL` injection token. */
459
- protected readonly baseUrl: string;
460
- /**
461
- * Sends a typed GET request.
462
- * @param path The path appended to the base URL.
463
- * @param query Optional query parameters.
464
- * @returns A promise resolving to the typed response body.
465
- */
466
- protected get<T>(path: string, query?: MnQueryParams): Promise<T>;
467
- /**
468
- * Sends a typed POST request.
469
- * @param path The path appended to the base URL.
470
- * @param body Optional request body.
471
- * @param query Optional query parameters.
472
- * @returns A promise resolving to the typed response body.
473
- */
474
- protected post<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T>;
475
- /**
476
- * Sends a typed PATCH request.
477
- * @param path The path appended to the base URL.
478
- * @param body Optional request body.
479
- * @param query Optional query parameters.
480
- * @returns A promise resolving to the typed response body.
481
- */
482
- protected patch<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T>;
483
- /**
484
- * Sends a typed PUT request.
485
- * @param path The path appended to the base URL.
486
- * @param body Optional request body.
487
- * @param query Optional query parameters.
488
- * @returns A promise resolving to the typed response body.
489
- */
490
- protected put<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T>;
491
- /**
492
- * Sends a typed DELETE request.
493
- * @param path The path appended to the base URL.
494
- * @param query Optional query parameters.
495
- * @returns A promise resolving to the typed response body.
496
- */
497
- protected delete<T = void>(path: string, query?: MnQueryParams): Promise<T>;
498
- /**
499
- * Converts a query-params record to Angular `HttpParams`.
500
- * Null and undefined values are silently skipped.
501
- * Array values are appended as multiple entries for the same key.
502
- * @param query The query parameter record to convert.
503
- * @returns An `HttpParams` instance, or `undefined` when no parameters are provided.
504
- */
505
- protected toHttpParams(query?: MnQueryParams): HttpParams | undefined;
454
+ export declare abstract class MnHttpService {
455
+ /** Angular HTTP client injected automatically. */
456
+ protected readonly http: HttpClient;
457
+ /** Base API URL provided via the `API_BASE_URL` injection token. */
458
+ protected readonly baseUrl: string;
459
+ /**
460
+ * Sends a typed GET request.
461
+ * @param path The path appended to the base URL.
462
+ * @param query Optional query parameters.
463
+ * @returns A promise resolving to the typed response body.
464
+ */
465
+ protected get<T>(path: string, query?: MnQueryParams): Promise<T>;
466
+ /**
467
+ * Sends a typed POST request.
468
+ * @param path The path appended to the base URL.
469
+ * @param body Optional request body.
470
+ * @param query Optional query parameters.
471
+ * @returns A promise resolving to the typed response body.
472
+ */
473
+ protected post<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T>;
474
+ /**
475
+ * Sends a typed PATCH request.
476
+ * @param path The path appended to the base URL.
477
+ * @param body Optional request body.
478
+ * @param query Optional query parameters.
479
+ * @returns A promise resolving to the typed response body.
480
+ */
481
+ protected patch<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T>;
482
+ /**
483
+ * Sends a typed PUT request.
484
+ * @param path The path appended to the base URL.
485
+ * @param body Optional request body.
486
+ * @param query Optional query parameters.
487
+ * @returns A promise resolving to the typed response body.
488
+ */
489
+ protected put<T>(path: string, body?: unknown, query?: MnQueryParams): Promise<T>;
490
+ /**
491
+ * Sends a typed DELETE request.
492
+ * @param path The path appended to the base URL.
493
+ * @param query Optional query parameters.
494
+ * @returns A promise resolving to the typed response body.
495
+ */
496
+ protected delete<T = void>(path: string, query?: MnQueryParams): Promise<T>;
497
+ /**
498
+ * Converts a query-params record to Angular `HttpParams`.
499
+ * Null and undefined values are silently skipped.
500
+ * Array values are appended as multiple entries for the same key.
501
+ * @param query The query parameter record to convert.
502
+ * @returns An `HttpParams` instance, or `undefined` when no parameters are provided.
503
+ */
504
+ protected toHttpParams(query?: MnQueryParams): HttpParams | undefined;
506
505
  }
507
-
508
- type MnImageType = {
509
- id: number;
510
- url: string;
511
- alt?: string;
506
+ export type MnImageType = {
507
+ id: number;
508
+ url: string;
509
+ alt?: string;
512
510
  };
513
-
514
511
  /**
515
512
  * Known shapes of Angular validator error argument objects.
516
513
  * Covers built-in validators (minlength, maxlength, min, max, pattern)
517
514
  * and the library's custom validators (mnMin, mnMax).
518
515
  */
519
- type MnValidationErrorArgs = {
520
- /** Produced by Validators.minLength / Validators.maxLength */
521
- requiredLength?: number;
522
- actualLength?: number;
523
- /** Produced by Validators.min / Validators.max */
524
- min?: number | string;
525
- max?: number | string;
526
- actual?: number | string;
527
- /** Produced by Validators.pattern */
528
- requiredPattern?: string;
529
- actualValue?: unknown;
516
+ export type MnValidationErrorArgs = {
517
+ /** Produced by Validators.minLength / Validators.maxLength */
518
+ requiredLength?: number;
519
+ actualLength?: number;
520
+ /** Produced by Validators.min / Validators.max */
521
+ min?: number | string;
522
+ max?: number | string;
523
+ actual?: number | string;
524
+ /** Produced by Validators.pattern */
525
+ requiredPattern?: string;
526
+ actualValue?: unknown;
530
527
  };
531
- type MnErrorMessageFn = (args: MnValidationErrorArgs, errors: ValidationErrors) => string;
532
-
528
+ export type MnErrorMessageFn = (args: MnValidationErrorArgs, errors: ValidationErrors) => string;
533
529
  /**
534
530
  * Turns icon nodes from the vanilla `lucide` package into the icon data that
535
531
  * `<svg [lucideIcon]>` (`LucideDynamicIcon`) and MnLib's icon inputs accept.
@@ -554,8 +550,7 @@ type MnErrorMessageFn = (args: MnValidationErrorArgs, errors: ValidationErrors)
554
550
  * @returns Icon data under the same keys, named `arrow-left`-style for the
555
551
  * `lucide-<name>` class the icon renders with.
556
552
  */
557
- declare function lucideIcons<K extends string>(nodes: Record<K, IconNode>): Record<K, LucideIconData>;
558
-
553
+ export declare function lucideIcons<K extends string>(nodes: Record<K, IconNode>): Record<K, LucideIconData>;
559
554
  /**
560
555
  * A marker object used in config values to indicate that the value
561
556
  * should be resolved via the MnLanguageService.
@@ -563,173 +558,171 @@ declare function lucideIcons<K extends string>(nodes: Record<K, IconNode>): Reco
563
558
  * Example in mn-config.json5:
564
559
  * label: { $translate: "form.email.label" }
565
560
  */
566
- type MnTranslatable = {
567
- $translate: string;
568
- params?: Record<string, string | number>;
561
+ export type MnTranslatable = {
562
+ $translate: string;
563
+ params?: Record<string, string | number>;
569
564
  };
570
565
  /**
571
566
  * A config value that is either a plain value or a translatable marker.
572
567
  */
573
- type MnConfigValue<T = string> = T | MnTranslatable;
568
+ export type MnConfigValue<T = string> = T | MnTranslatable;
574
569
  /**
575
570
  * Translations for a single locale, as a tree of keys.
576
571
  *
577
572
  * Both shapes resolve through the same dotted lookup: a bundle may nest
578
573
  * (`{ form: { email: { label } } }`), flatten (`{ "form.email.label": … }`), or mix the two.
579
574
  */
580
- type MnTranslationMap = {
581
- [key: string]: string | MnTranslationMap;
575
+ export type MnTranslationMap = {
576
+ [key: string]: string | MnTranslationMap;
582
577
  };
583
578
  /**
584
579
  * All loaded translations keyed by locale code (e.g. "en", "nl", "de").
585
580
  */
586
- type MnTranslations = Record<string, MnTranslationMap>;
581
+ export type MnTranslations = Record<string, MnTranslationMap>;
587
582
  /**
588
583
  * Configuration for the language provider.
589
584
  */
590
- type MnLanguageConfig = {
591
- /** URL pattern for loading translation files. Use `{locale}` as placeholder. e.g. "assets/i18n/{locale}.json" */
592
- urlPattern: string;
593
- /** The default/fallback locale. */
594
- defaultLocale: string;
595
- /** Locales to preload at bootstrap. */
596
- preload?: string[];
597
- /**
598
- * Optional mapping of domain hostnames to locale codes.
599
- * When set, the service will use the current domain to determine the initial locale.
600
- * Example: { "example.nl": "nl", "example.de": "de", "example.com": "en" }
601
- */
602
- domainLocaleMap?: Record<string, string>;
603
- /** Whether to enable debug logging. */
604
- debug?: boolean;
585
+ export type MnLanguageConfig = {
586
+ /** URL pattern for loading translation files. Use `{locale}` as placeholder. e.g. "assets/i18n/{locale}.json" */
587
+ urlPattern: string;
588
+ /** The default/fallback locale. */
589
+ defaultLocale: string;
590
+ /** Locales to preload at bootstrap. */
591
+ preload?: string[];
592
+ /**
593
+ * Optional mapping of domain hostnames to locale codes.
594
+ * When set, the service will use the current domain to determine the initial locale.
595
+ * Example: { "example.nl": "nl", "example.de": "de", "example.com": "en" }
596
+ */
597
+ domainLocaleMap?: Record<string, string>;
598
+ /** Whether to enable debug logging. */
599
+ debug?: boolean;
605
600
  };
606
601
  /**
607
602
  * Type guard: checks whether a value is a translatable marker object.
608
603
  */
609
- declare function isTranslatable(value: unknown): value is MnTranslatable;
610
-
611
- declare class MnLanguageService {
612
- private readonly http;
613
- private readonly appRef;
614
- private _translations;
615
- private _locale$;
616
- /**
617
- * The active locale as a signal, read by {@link locale} and so by every lookup.
618
- *
619
- * Components are OnPush, and `setLocale` only ran one `appRef.tick()`, which skips every view
620
- * nobody marked: a tab bar, a card heading or a bar label kept the old language until the page
621
- * was reloaded. A signal read while a template renders (through the `mnTranslate` pipe, or a
622
- * getter calling `translate`) is tracked by that view, so switching the locale marks exactly
623
- * the views that translated something, and a `computed` built on `translate` recomputes.
624
- */
625
- private readonly _locale;
626
- private _urlPattern;
627
- private _debug;
628
- /**
629
- * `Intl.PluralRules` per locale. Cached because {@link translate} runs on every change
630
- * detection through the impure `mnTranslate` pipe, and constructing one is not cheap.
631
- */
632
- private readonly _pluralRules;
633
- /** Observable of the current active locale. */
634
- readonly locale$: Observable<string>;
635
- /** Current active locale. */
636
- get locale(): string;
637
- /**
638
- * Enable or disable debug logging.
639
- */
640
- setDebug(enabled: boolean): void;
641
- /**
642
- * Configure the URL pattern used to fetch translation files.
643
- * Use `{locale}` as placeholder, e.g. `"assets/i18n/{locale}.json"`.
644
- */
645
- configure(urlPattern: string): void;
646
- /**
647
- * Load translations for a locale from the configured URL pattern.
648
- * If translations are already loaded for this locale, this is a no-op.
649
- */
650
- loadLocale(locale: string): Promise<void>;
651
- /**
652
- * Switch the active locale. Loads translations if not yet loaded.
653
- */
654
- setLocale(locale: string): Promise<void>;
655
- /**
656
- * Register translations for a locale directly from code (no HTTP needed).
657
- */
658
- registerTranslations(locale: string, translations: MnTranslationMap): void;
659
- /**
660
- * Translate a key using the current locale, with optional parameter interpolation.
661
- * Falls back to the key itself if no translation is found.
662
- *
663
- * Interpolation replaces `{{paramName}}` with the provided value.
664
- *
665
- * A `count` param additionally selects the wording that agrees with it: the key is
666
- * resolved against its CLDR plural category first (`key` + `One`/`Two`/`Few`/`Many`/
667
- * `Zero`), falling back to `key` when that sibling is undefined. Nothing has to opt in —
668
- * a key with no sibling behaves exactly as before.
669
- *
670
- * ```ts
671
- * // 'shift.asked' → '{{count}} members are notified'
672
- * // 'shift.askedOne' → '{{count}} member is notified'
673
- * lang.translate('shift.asked', { count: 3 }); // 3 members are notified
674
- * lang.translate('shift.asked', { count: 1 }); // 1 member is notified
675
- * ```
676
- */
677
- translate(key: string, params?: Record<string, string | number>): string;
678
- /**
679
- * Picks the wording that agrees with a `count` param.
680
- *
681
- * A key carrying a count resolves against its CLDR plural category first, so
682
- * `askedMessage` + `askedMessageOne` render "3 leden krijgen bericht" and "1 lid krijgt
683
- * bericht" off the same call. Both languages change the verb as well as the noun, which
684
- * is why each form is a whole sentence under its own key rather than a swapped noun.
685
- *
686
- * Falls back to `key` whenever the sibling is undefined, so a key that never needed a
687
- * plural — or an app that has not written one yet — behaves exactly as it did before.
688
- * @param map The active locale's translations.
689
- * @param key The dot-notated translation key.
690
- * @param params The interpolation values, inspected for `count`.
691
- * @returns The key to look up: the plural sibling, or `key` itself.
692
- */
693
- private resolvePluralKey;
694
- /**
695
- * The CLDR plural category of a count in the active locale.
696
- * @param count The count being quoted.
697
- * @returns The category, falling back to English rules for an unusable locale.
698
- */
699
- private pluralCategory;
700
- /**
701
- * Helper to retrieve a value from a potentially nested translation map using a dot-notated key.
702
- */
703
- private getValueFromMap;
704
- /**
705
- * Translate a key **only if it is defined**, returning `undefined` otherwise.
706
- *
707
- * {@link translate} deliberately returns the key itself when it is missing, which
708
- * makes it unusable for a library's own default labels: a consumer that never
709
- * defined `mnCollection.rowsPerPage` would see that raw string in their UI. This
710
- * lets a caller try a conventional key and fall back to a readable English default
711
- * when the app has not translated it, so components ship translatable strings
712
- * without forcing every consumer to define them.
713
- *
714
- * @param key The dot-notated translation key.
715
- * @param params Optional `{{name}}` interpolation values.
716
- * @returns The translation, or `undefined` when the key is not defined.
717
- */
718
- translateIfPresent(key: string, params?: Record<string, string | number>): string | undefined;
719
- /**
720
- * Shorthand alias for `translate`.
721
- */
722
- t(key: string, params?: Record<string, string | number>): string;
723
- /**
724
- * Resolve the effective default locale from a domain-to-locale map.
725
- * Matches `window.location.hostname` against the map keys.
726
- * Returns the mapped locale, or the provided fallback if no match is found.
727
- */
728
- resolveLocaleForDomain(domainLocaleMap: Record<string, string> | undefined, fallback: string): string;
729
- static ɵfac: i0.ɵɵFactoryDeclaration<MnLanguageService, never>;
730
- static ɵprov: i0.ɵɵInjectableDeclaration<any>;
604
+ export declare function isTranslatable(value: unknown): value is MnTranslatable;
605
+ export declare class MnLanguageService {
606
+ private readonly http;
607
+ private readonly appRef;
608
+ private _translations;
609
+ private _locale$;
610
+ /**
611
+ * The active locale as a signal, read by {@link locale} and so by every lookup.
612
+ *
613
+ * Components are OnPush, and `setLocale` only ran one `appRef.tick()`, which skips every view
614
+ * nobody marked: a tab bar, a card heading or a bar label kept the old language until the page
615
+ * was reloaded. A signal read while a template renders (through the `mnTranslate` pipe, or a
616
+ * getter calling `translate`) is tracked by that view, so switching the locale marks exactly
617
+ * the views that translated something, and a `computed` built on `translate` recomputes.
618
+ */
619
+ private readonly _locale;
620
+ private _urlPattern;
621
+ private _debug;
622
+ /**
623
+ * `Intl.PluralRules` per locale. Cached because {@link translate} runs on every change
624
+ * detection through the impure `mnTranslate` pipe, and constructing one is not cheap.
625
+ */
626
+ private readonly _pluralRules;
627
+ /** Observable of the current active locale. */
628
+ readonly locale$: Observable<string>;
629
+ /** Current active locale. */
630
+ get locale(): string;
631
+ /**
632
+ * Enable or disable debug logging.
633
+ */
634
+ setDebug(enabled: boolean): void;
635
+ /**
636
+ * Configure the URL pattern used to fetch translation files.
637
+ * Use `{locale}` as placeholder, e.g. `"assets/i18n/{locale}.json"`.
638
+ */
639
+ configure(urlPattern: string): void;
640
+ /**
641
+ * Load translations for a locale from the configured URL pattern.
642
+ * If translations are already loaded for this locale, this is a no-op.
643
+ */
644
+ loadLocale(locale: string): Promise<void>;
645
+ /**
646
+ * Switch the active locale. Loads translations if not yet loaded.
647
+ */
648
+ setLocale(locale: string): Promise<void>;
649
+ /**
650
+ * Register translations for a locale directly from code (no HTTP needed).
651
+ */
652
+ registerTranslations(locale: string, translations: MnTranslationMap): void;
653
+ /**
654
+ * Translate a key using the current locale, with optional parameter interpolation.
655
+ * Falls back to the key itself if no translation is found.
656
+ *
657
+ * Interpolation replaces `{{paramName}}` with the provided value.
658
+ *
659
+ * A `count` param additionally selects the wording that agrees with it: the key is
660
+ * resolved against its CLDR plural category first (`key` + `One`/`Two`/`Few`/`Many`/
661
+ * `Zero`), falling back to `key` when that sibling is undefined. Nothing has to opt in —
662
+ * a key with no sibling behaves exactly as before.
663
+ *
664
+ * ```ts
665
+ * // 'shift.asked' → '{{count}} members are notified'
666
+ * // 'shift.askedOne' → '{{count}} member is notified'
667
+ * lang.translate('shift.asked', { count: 3 }); // 3 members are notified
668
+ * lang.translate('shift.asked', { count: 1 }); // 1 member is notified
669
+ * ```
670
+ */
671
+ translate(key: string, params?: Record<string, string | number>): string;
672
+ /**
673
+ * Picks the wording that agrees with a `count` param.
674
+ *
675
+ * A key carrying a count resolves against its CLDR plural category first, so
676
+ * `askedMessage` + `askedMessageOne` render "3 leden krijgen bericht" and "1 lid krijgt
677
+ * bericht" off the same call. Both languages change the verb as well as the noun, which
678
+ * is why each form is a whole sentence under its own key rather than a swapped noun.
679
+ *
680
+ * Falls back to `key` whenever the sibling is undefined, so a key that never needed a
681
+ * plural — or an app that has not written one yet — behaves exactly as it did before.
682
+ * @param map The active locale's translations.
683
+ * @param key The dot-notated translation key.
684
+ * @param params The interpolation values, inspected for `count`.
685
+ * @returns The key to look up: the plural sibling, or `key` itself.
686
+ */
687
+ private resolvePluralKey;
688
+ /**
689
+ * The CLDR plural category of a count in the active locale.
690
+ * @param count The count being quoted.
691
+ * @returns The category, falling back to English rules for an unusable locale.
692
+ */
693
+ private pluralCategory;
694
+ /**
695
+ * Helper to retrieve a value from a potentially nested translation map using a dot-notated key.
696
+ */
697
+ private getValueFromMap;
698
+ /**
699
+ * Translate a key **only if it is defined**, returning `undefined` otherwise.
700
+ *
701
+ * {@link translate} deliberately returns the key itself when it is missing, which
702
+ * makes it unusable for a library's own default labels: a consumer that never
703
+ * defined `mnCollection.rowsPerPage` would see that raw string in their UI. This
704
+ * lets a caller try a conventional key and fall back to a readable English default
705
+ * when the app has not translated it, so components ship translatable strings
706
+ * without forcing every consumer to define them.
707
+ *
708
+ * @param key The dot-notated translation key.
709
+ * @param params Optional `{{name}}` interpolation values.
710
+ * @returns The translation, or `undefined` when the key is not defined.
711
+ */
712
+ translateIfPresent(key: string, params?: Record<string, string | number>): string | undefined;
713
+ /**
714
+ * Shorthand alias for `translate`.
715
+ */
716
+ t(key: string, params?: Record<string, string | number>): string;
717
+ /**
718
+ * Resolve the effective default locale from a domain-to-locale map.
719
+ * Matches `window.location.hostname` against the map keys.
720
+ * Returns the mapped locale, or the provided fallback if no match is found.
721
+ */
722
+ resolveLocaleForDomain(domainLocaleMap: Record<string, string> | undefined, fallback: string): string;
723
+ static ɵfac: i0.ɵɵFactoryDeclaration<MnLanguageService, never>;
724
+ static ɵprov: i0.ɵɵInjectableDeclaration<any>;
731
725
  }
732
-
733
726
  /**
734
727
  * Provides an APP_INITIALIZER that configures the MnLanguageService and
735
728
  * preloads the requested locales during application bootstrap.
@@ -741,8 +734,7 @@ declare class MnLanguageService {
741
734
  * preload: ['en', 'nl'],
742
735
  * })
743
736
  */
744
- declare function provideMnLanguage(config: MnLanguageConfig): Provider[];
745
-
737
+ export declare function provideMnLanguage(config: MnLanguageConfig): Provider[];
746
738
  /**
747
739
  * Pipe that translates a key via MnLanguageService.
748
740
  *
@@ -752,17 +744,16 @@ declare function provideMnLanguage(config: MnLanguageConfig): Provider[];
752
744
  *
753
745
  * Note: This pipe is impure so it re-evaluates when the locale changes.
754
746
  */
755
- declare class MnTranslatePipe implements PipeTransform {
756
- private readonly lang;
757
- transform(key: string, params?: Record<string, string | number>): string;
758
- static ɵfac: i0.ɵɵFactoryDeclaration<MnTranslatePipe, never>;
759
- static ɵpipe: i0.ɵɵPipeDeclaration<MnTranslatePipe, "mnTranslate", true>;
747
+ export declare class MnTranslatePipe implements PipeTransform {
748
+ private readonly lang;
749
+ transform(key: string, params?: Record<string, string | number>): string;
750
+ static ɵfac: i0.ɵɵFactoryDeclaration<MnTranslatePipe, never>;
751
+ static ɵpipe: i0.ɵɵPipeDeclaration<MnTranslatePipe, "mnTranslate", true>;
760
752
  }
761
-
762
- type MnPreviewMessage = {
763
- type: 'mn-config-update' | 'mn-translations-update';
764
- config?: Record<string, unknown>;
765
- translations?: Record<string, Record<string, string>>;
753
+ export type MnPreviewMessage = {
754
+ type: 'mn-config-update' | 'mn-translations-update';
755
+ config?: Record<string, unknown>;
756
+ translations?: Record<string, Record<string, string>>;
766
757
  };
767
758
  /**
768
759
  * Enable live preview mode. Listens for postMessage events from
@@ -774,7 +765,5 @@ type MnPreviewMessage = {
774
765
  * @param langService - The MnLanguageService instance
775
766
  * @param allowedOrigins - Optional whitelist of allowed origins (security)
776
767
  */
777
- declare function enableMnPreviewMode(configService: MnConfigService, langService: MnLanguageService, allowedOrigins?: string[]): void;
778
-
779
- export { API_BASE_URL, CrudService, MN_INSTANCE_ID, MN_IN_BOTTOM_SHEET, MN_IN_MODAL, MN_SECTION_PATH, MnConfigService, MnHttpService, MnInstanceDirective, MnLanguageService, MnSectionDirective, MnTranslatePipe, enableMnPreviewMode, isTranslatable, lucideIcons, parseConfigText, provideMnComponentConfig, provideMnConfig, provideMnLanguage };
780
- export type { ApiError, CrudConfig, FailureResult, MnConfigFile, MnConfigSettings, MnConfigValue, MnErrorMessageFn, MnImageType, MnLanguageConfig, MnPreviewMessage, MnQueryParams, MnTranslatable, MnTranslationMap, MnTranslations, MnValidationErrorArgs, Primitive, QueryParams, QueryValue, Result, ResultMeta, SuccessResult };
768
+ export declare function enableMnPreviewMode(configService: MnConfigService, langService: MnLanguageService, allowedOrigins?: string[]): void;
769
+ export {};