mn-angular-lib 1.0.177 → 1.0.179

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