mn-angular-lib 1.0.178 → 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 -15517
  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 -10822
  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,945 @@
1
+ import { InjectionToken } from '@angular/core';
2
+ export { TemplateRef, Type } from '@angular/core';
3
+ import * as lucide from 'lucide';
4
+ import { lucideIcons } from 'mn-angular-lib/core';
5
+ import { Validators } from '@angular/forms';
6
+ import { Subject } from 'rxjs';
7
+
8
+ // =========================
9
+ // Enums / Value Types
10
+ // =========================
11
+ var ModalKind;
12
+ (function (ModalKind) {
13
+ ModalKind["WIZARD"] = "wizard";
14
+ ModalKind["FORM"] = "form";
15
+ ModalKind["CONFIRMATION"] = "confirmation";
16
+ ModalKind["CUSTOM"] = "custom";
17
+ })(ModalKind || (ModalKind = {}));
18
+ var ModalSize;
19
+ (function (ModalSize) {
20
+ ModalSize["SM"] = "sm";
21
+ ModalSize["MD"] = "md";
22
+ ModalSize["LG"] = "lg";
23
+ ModalSize["XL"] = "xl";
24
+ ModalSize["FULL"] = "full";
25
+ })(ModalSize || (ModalSize = {}));
26
+ var CloseMode;
27
+ (function (CloseMode) {
28
+ CloseMode["ALLOWED"] = "allowed";
29
+ CloseMode["GUARDED"] = "guarded";
30
+ CloseMode["DISABLED"] = "disabled";
31
+ })(CloseMode || (CloseMode = {}));
32
+ var BackdropMode;
33
+ (function (BackdropMode) {
34
+ BackdropMode["HIDE"] = "hide";
35
+ BackdropMode["STATIC"] = "static";
36
+ BackdropMode["CLOSABLE"] = "closable";
37
+ })(BackdropMode || (BackdropMode = {}));
38
+ var KeyboardMode;
39
+ (function (KeyboardMode) {
40
+ KeyboardMode["ENABLED"] = "enabled";
41
+ KeyboardMode["DISABLED"] = "disabled";
42
+ })(KeyboardMode || (KeyboardMode = {}));
43
+ var ModalIntent;
44
+ (function (ModalIntent) {
45
+ ModalIntent["NEUTRAL"] = "neutral";
46
+ ModalIntent["INFO"] = "info";
47
+ ModalIntent["SUCCESS"] = "success";
48
+ ModalIntent["WARNING"] = "warning";
49
+ ModalIntent["DANGER"] = "danger";
50
+ })(ModalIntent || (ModalIntent = {}));
51
+ var WizardFlowMode;
52
+ (function (WizardFlowMode) {
53
+ WizardFlowMode["LINEAR"] = "linear";
54
+ WizardFlowMode["FREE"] = "free";
55
+ })(WizardFlowMode || (WizardFlowMode = {}));
56
+ var FormLayoutMode;
57
+ (function (FormLayoutMode) {
58
+ FormLayoutMode["SINGLE_COLUMN"] = "single-column";
59
+ FormLayoutMode["TWO_COLUMN"] = "two-column";
60
+ FormLayoutMode["INLINE"] = "inline";
61
+ })(FormLayoutMode || (FormLayoutMode = {}));
62
+ var SubmitMode;
63
+ (function (SubmitMode) {
64
+ SubmitMode["ONCE"] = "once";
65
+ SubmitMode["RETRYABLE"] = "retryable";
66
+ })(SubmitMode || (SubmitMode = {}));
67
+ var ConfirmationTone;
68
+ (function (ConfirmationTone) {
69
+ ConfirmationTone["DEFAULT"] = "default";
70
+ ConfirmationTone["WARNING"] = "warning";
71
+ ConfirmationTone["DANGER"] = "danger";
72
+ })(ConfirmationTone || (ConfirmationTone = {}));
73
+ var FieldKind;
74
+ (function (FieldKind) {
75
+ FieldKind["TEXT"] = "text";
76
+ FieldKind["NUMBER"] = "number";
77
+ FieldKind["SELECT"] = "select";
78
+ FieldKind["CHECKBOX"] = "checkbox";
79
+ FieldKind["DATE"] = "date";
80
+ FieldKind["TEXTAREA"] = "textarea";
81
+ FieldKind["DATETIME"] = "datetime";
82
+ FieldKind["MULTI_SELECT"] = "multi-select";
83
+ FieldKind["MULTI_SELECT_TABLE"] = "multi-select-table";
84
+ FieldKind["SINGLE_SELECT_TABLE"] = "single-select-table";
85
+ FieldKind["PASSWORD"] = "password";
86
+ FieldKind["FILE"] = "file";
87
+ FieldKind["COLOR"] = "color";
88
+ FieldKind["RATING"] = "rating";
89
+ FieldKind["SLIDER"] = "slider";
90
+ FieldKind["CUSTOM"] = "custom";
91
+ })(FieldKind || (FieldKind = {}));
92
+ var FieldAppearance;
93
+ (function (FieldAppearance) {
94
+ FieldAppearance["OUTLINE"] = "outline";
95
+ FieldAppearance["FILLED"] = "filled";
96
+ FieldAppearance["GHOST"] = "ghost";
97
+ })(FieldAppearance || (FieldAppearance = {}));
98
+ var SelectionMode;
99
+ (function (SelectionMode) {
100
+ SelectionMode["SINGLE"] = "single";
101
+ SelectionMode["MULTIPLE"] = "multiple";
102
+ })(SelectionMode || (SelectionMode = {}));
103
+ var OptionState;
104
+ (function (OptionState) {
105
+ OptionState["ENABLED"] = "enabled";
106
+ OptionState["DISABLED"] = "disabled";
107
+ })(OptionState || (OptionState = {}));
108
+ var ActionStyle;
109
+ (function (ActionStyle) {
110
+ ActionStyle["PRIMARY"] = "primary";
111
+ ActionStyle["SECONDARY"] = "secondary";
112
+ ActionStyle["DANGER"] = "danger";
113
+ ActionStyle["GHOST"] = "ghost";
114
+ })(ActionStyle || (ActionStyle = {}));
115
+ var StepState;
116
+ (function (StepState) {
117
+ StepState["PENDING"] = "pending";
118
+ StepState["ACTIVE"] = "active";
119
+ StepState["COMPLETE"] = "complete";
120
+ StepState["DISABLED"] = "disabled";
121
+ StepState["HIDDEN"] = "hidden";
122
+ })(StepState || (StepState = {}));
123
+ var NavigationDirection;
124
+ (function (NavigationDirection) {
125
+ NavigationDirection["FORWARD"] = "forward";
126
+ NavigationDirection["BACKWARD"] = "backward";
127
+ NavigationDirection["DIRECT"] = "direct";
128
+ })(NavigationDirection || (NavigationDirection = {}));
129
+ var ModalCloseReason;
130
+ (function (ModalCloseReason) {
131
+ ModalCloseReason["COMPLETED"] = "completed";
132
+ ModalCloseReason["CANCELLED"] = "cancelled";
133
+ ModalCloseReason["DISMISSED"] = "dismissed";
134
+ ModalCloseReason["BACKDROP"] = "backdrop";
135
+ ModalCloseReason["ESCAPE"] = "escape";
136
+ ModalCloseReason["PROGRAMMATIC"] = "programmatic";
137
+ ModalCloseReason["GUARD_REJECTED"] = "guard_rejected";
138
+ })(ModalCloseReason || (ModalCloseReason = {}));
139
+ var ValidationStatus;
140
+ (function (ValidationStatus) {
141
+ ValidationStatus["VALID"] = "valid";
142
+ ValidationStatus["INVALID"] = "invalid";
143
+ ValidationStatus["PENDING"] = "pending";
144
+ })(ValidationStatus || (ValidationStatus = {}));
145
+ var ValidationCode;
146
+ (function (ValidationCode) {
147
+ ValidationCode["REQUIRED"] = "required";
148
+ ValidationCode["MIN"] = "min";
149
+ ValidationCode["MAX"] = "max";
150
+ ValidationCode["PATTERN"] = "pattern";
151
+ ValidationCode["CUSTOM"] = "custom";
152
+ })(ValidationCode || (ValidationCode = {}));
153
+
154
+ /** Lucide icons this file renders. */
155
+ const ICONS = lucideIcons({
156
+ ArrowLeft: lucide.ArrowLeft,
157
+ ArrowRight: lucide.ArrowRight,
158
+ Check: lucide.Check,
159
+ Trash2: lucide.Trash2,
160
+ X: lucide.X,
161
+ });
162
+ /**
163
+ * Default leading-icon size (px) for modal action buttons, matching the standard
164
+ * (`md`) button. Small (`sm`) buttons use {@link MODAL_ACTION_ICON_SIZE_SM}.
165
+ */
166
+ const MODAL_ACTION_ICON_SIZE = 18;
167
+ /** Leading-icon size (px) for `sm`-sized modal action buttons. */
168
+ const MODAL_ACTION_ICON_SIZE_SM = 16;
169
+ /**
170
+ * The canonical Lucide icon data used as defaults across all modal action buttons.
171
+ * Each value is a Lucide icon's static `.icon` data, rendered via the dynamic
172
+ * `svg[lucideIcon]` directive so no icon has to be registered in `MN_ICON_MAP`.
173
+ */
174
+ const MN_MODAL_ACTION_ICONS = {
175
+ /** Affirmative action (confirm / submit / complete). */
176
+ confirm: ICONS.Check,
177
+ /** Destructive action (danger style). */
178
+ danger: ICONS.Trash2,
179
+ /** Cancel / dismiss / close action. */
180
+ cancel: ICONS.X,
181
+ /** Wizard forward navigation (rendered trailing). */
182
+ next: ICONS.ArrowRight,
183
+ /** Wizard backward navigation. */
184
+ back: ICONS.ArrowLeft,
185
+ };
186
+ /**
187
+ * Resolves the default action-button icon from its {@link ActionStyle}. Used by
188
+ * generic footer actions and any confirm button that has no explicit icon:
189
+ * `DANGER` → trash, `PRIMARY` → check, everything else (`GHOST`/`SECONDARY`) → cross.
190
+ * @param style The action's style, if any.
191
+ * @returns The Lucide icon data to render.
192
+ */
193
+ function defaultIconForStyle(style) {
194
+ switch (style) {
195
+ case ActionStyle.DANGER:
196
+ return MN_MODAL_ACTION_ICONS.danger;
197
+ case ActionStyle.PRIMARY:
198
+ return MN_MODAL_ACTION_ICONS.confirm;
199
+ default:
200
+ return MN_MODAL_ACTION_ICONS.cancel;
201
+ }
202
+ }
203
+
204
+ /**
205
+ * Optional DI token used by the bottom sheet to emit haptic feedback on native
206
+ * platforms (sheet open, swipe-dismiss, and snap-back). Provide a {@link MnHapticsHandler}
207
+ * at the application root to enable it; leave unprovided on the web (the modal injects it
208
+ * with `{ optional: true }` and no-ops when absent).
209
+ */
210
+ const MN_HAPTICS = new InjectionToken('MN_HAPTICS');
211
+
212
+ /**
213
+ * A builder class that provides form layout capabilities (fields, rows, groups).
214
+ * This can be used as a delegate to avoid code duplication between FormModalBuilder and StepBuilder.
215
+ */
216
+ class FormLayoutBuilder {
217
+ config;
218
+ parent;
219
+ currentRow = [];
220
+ currentRowColumns = 1;
221
+ constructor(config, parent) {
222
+ this.config = config;
223
+ this.parent = parent;
224
+ this.config.fields = this.config.fields || [];
225
+ this.config.rows = this.config.rows || [];
226
+ }
227
+ /**
228
+ * Add a custom body/content to the form/step.
229
+ */
230
+ body(body) {
231
+ this.config.body = body;
232
+ return this.parent;
233
+ }
234
+ /**
235
+ * Add a field as a full-width row (single column).
236
+ */
237
+ field(field) {
238
+ this.flushCurrentRow();
239
+ this.config.fields = this.config.fields || [];
240
+ this.config.fields.push(field);
241
+ this.config.rows = this.config.rows || [];
242
+ this.config.rows.push({
243
+ columns: 1,
244
+ fields: [{ field, span: 1 }],
245
+ });
246
+ return this.parent;
247
+ }
248
+ /**
249
+ * Start a new row with the specified number of columns.
250
+ * All subsequent `addToRow()` calls will add fields to this row.
251
+ */
252
+ row(columns = 2) {
253
+ this.flushCurrentRow();
254
+ this.currentRowColumns = columns;
255
+ return this.parent;
256
+ }
257
+ /**
258
+ * Add a field to the current row started by `row()`.
259
+ * @param field - The field configuration
260
+ * @param span - How many columns this field should span (default: 1)
261
+ */
262
+ addToRow(field, span = 1) {
263
+ this.config.fields = this.config.fields || [];
264
+ this.config.fields.push(field);
265
+ this.currentRow.push({ field, span });
266
+ return this.parent;
267
+ }
268
+ /**
269
+ * Declarative way to add a row.
270
+ * @example
271
+ * .addRow(2, row => {
272
+ * row.add({ kind: FieldKind.TEXT, key: 'first', ... });
273
+ * row.add({ kind: FieldKind.TEXT, key: 'last', ... });
274
+ * })
275
+ */
276
+ addRow(columns, buildFn) {
277
+ this.flushCurrentRow();
278
+ const rowFields = [];
279
+ buildFn({
280
+ add: (field, span = 1) => {
281
+ this.config.fields = this.config.fields || [];
282
+ this.config.fields.push(field);
283
+ rowFields.push({ field, span });
284
+ },
285
+ });
286
+ if (rowFields.length > 0) {
287
+ this.config.rows = this.config.rows || [];
288
+ this.config.rows.push({
289
+ columns,
290
+ fields: rowFields,
291
+ });
292
+ }
293
+ return this.parent;
294
+ }
295
+ fieldGroup(arg1, arg2, arg3) {
296
+ this.flushCurrentRow();
297
+ if (typeof arg1 !== 'string') {
298
+ const group = arg1;
299
+ this.processFieldGroup(group);
300
+ return this.parent;
301
+ }
302
+ const title = arg1;
303
+ let description;
304
+ let buildFn;
305
+ if (typeof arg2 === 'string') {
306
+ description = arg2;
307
+ buildFn = arg3;
308
+ }
309
+ else {
310
+ buildFn = arg2;
311
+ }
312
+ const groupConfig = {
313
+ fields: [],
314
+ rows: [],
315
+ };
316
+ const groupBuilder = new FormLayoutBuilder(groupConfig, null);
317
+ groupBuilder.parent = groupBuilder;
318
+ buildFn(groupBuilder);
319
+ groupBuilder.flushCurrentRow();
320
+ const group = {
321
+ title,
322
+ description,
323
+ fields: groupConfig.fields || [],
324
+ rows: groupConfig.rows || [],
325
+ };
326
+ this.processFieldGroup(group);
327
+ return this.parent;
328
+ }
329
+ processFieldGroup(group) {
330
+ if (!this.config.fieldGroups) {
331
+ this.config.fieldGroups = [];
332
+ }
333
+ // Also add group fields to the flat fields array for form control creation
334
+ this.config.fields = this.config.fields || [];
335
+ const fields = this.config.fields;
336
+ group.fields.forEach((f) => fields.push(f));
337
+ // Build rows for the group if not provided
338
+ if (!group.rows || group.rows.length === 0) {
339
+ group.rows = group.fields.map((f) => ({
340
+ columns: 1,
341
+ fields: [{ field: f, span: 1 }],
342
+ }));
343
+ }
344
+ this.config.fieldGroups.push(group);
345
+ }
346
+ /**
347
+ * Add form-level validators for cross-field validation.
348
+ */
349
+ formValidators(validators) {
350
+ this.config.formValidators = validators;
351
+ return this.parent;
352
+ }
353
+ /**
354
+ * Add Angular FormGroup-level validators.
355
+ */
356
+ groupValidators(validators) {
357
+ this.config.groupValidators = validators;
358
+ return this.parent;
359
+ }
360
+ /**
361
+ * Set initial value for fields.
362
+ */
363
+ initialValue(value) {
364
+ this.config.initialValue = value;
365
+ return this.parent;
366
+ }
367
+ /**
368
+ * Set the field to be focused when the form initializes.
369
+ */
370
+ focus(key) {
371
+ this.config.fields?.forEach(f => {
372
+ f.autoFocus = false;
373
+ });
374
+ this.config.fieldGroups?.forEach(g => {
375
+ g.fields.forEach(f => {
376
+ f.autoFocus = false;
377
+ });
378
+ });
379
+ const field = this.config.fields?.find(f => f.key === key);
380
+ if (field) {
381
+ field.autoFocus = true;
382
+ }
383
+ return this.parent;
384
+ }
385
+ /**
386
+ * Wraps a field with a fluent API for validation.
387
+ */
388
+ fieldWithValidators(field) {
389
+ const fieldWithV = field;
390
+ fieldWithV.validators = fieldWithV.validators || [];
391
+ this.field(field);
392
+ return new FieldValidatorBuilder(field, this.parent);
393
+ }
394
+ /**
395
+ * Flushes any pending fields in the current row to the configuration.
396
+ */
397
+ flushCurrentRow() {
398
+ if (this.currentRow.length > 0) {
399
+ this.config.rows.push({
400
+ columns: this.currentRowColumns,
401
+ fields: [...this.currentRow],
402
+ });
403
+ this.currentRow = [];
404
+ this.currentRowColumns = 1;
405
+ }
406
+ }
407
+ }
408
+ /**
409
+ * A builder for adding validation rules to a field fluently.
410
+ */
411
+ class FieldValidatorBuilder {
412
+ field;
413
+ parent;
414
+ constructor(field, parent) {
415
+ this.field = field;
416
+ this.parent = parent;
417
+ this.field.validators = this.field.validators || [];
418
+ }
419
+ required(_message) {
420
+ this.field.validators.push(Validators.required);
421
+ return this;
422
+ }
423
+ minLength(length) {
424
+ this.field.validators.push(Validators.minLength(length));
425
+ return this;
426
+ }
427
+ maxLength(length) {
428
+ this.field.validators.push(Validators.maxLength(length));
429
+ return this;
430
+ }
431
+ pattern(pattern) {
432
+ this.field.validators.push(Validators.pattern(pattern));
433
+ return this;
434
+ }
435
+ email() {
436
+ this.field.validators.push(Validators.email);
437
+ return this;
438
+ }
439
+ min(value) {
440
+ this.field.validators.push(Validators.min(value));
441
+ return this;
442
+ }
443
+ max(value) {
444
+ this.field.validators.push(Validators.max(value));
445
+ return this;
446
+ }
447
+ /**
448
+ * Add a custom validator.
449
+ */
450
+ custom(validator) {
451
+ this.field.validators.push(validator);
452
+ return this;
453
+ }
454
+ /**
455
+ * Return to the parent builder.
456
+ */
457
+ done() {
458
+ return this.parent;
459
+ }
460
+ }
461
+
462
+ class StepBuilder {
463
+ config;
464
+ layoutBuilder;
465
+ constructor(id, title) {
466
+ this.config = {
467
+ id,
468
+ title,
469
+ fields: [],
470
+ state: StepState.PENDING,
471
+ };
472
+ this.layoutBuilder = new FormLayoutBuilder(this.config, this);
473
+ }
474
+ /**
475
+ * Set the step body. Accepts plain text, a component, or a template.
476
+ * @param body The step body content (string, component `Type`, or `TemplateRef`).
477
+ * @param inputs Optional inputs for a component/template body (ignored for text).
478
+ */
479
+ body(body, inputs) {
480
+ this.config.body = body;
481
+ if (inputs !== undefined) {
482
+ this.config.bodyInputs = inputs;
483
+ }
484
+ return this;
485
+ }
486
+ state(state) {
487
+ this.config.state = state;
488
+ return this;
489
+ }
490
+ guard(guard) {
491
+ this.config.guard = guard;
492
+ return this;
493
+ }
494
+ validators(validators) {
495
+ this.config.validators = validators;
496
+ return this;
497
+ }
498
+ field(field) {
499
+ return this.layoutBuilder.field(field);
500
+ }
501
+ row(columns = 2) {
502
+ return this.layoutBuilder.row(columns);
503
+ }
504
+ addToRow(field, span = 1) {
505
+ return this.layoutBuilder.addToRow(field, span);
506
+ }
507
+ addRow(columns, buildFn) {
508
+ return this.layoutBuilder.addRow(columns, buildFn);
509
+ }
510
+ fieldGroup(arg1, arg2, arg3) {
511
+ if (typeof arg1 !== 'string') {
512
+ return this.layoutBuilder.fieldGroup(arg1);
513
+ }
514
+ if (typeof arg2 === 'string') {
515
+ return this.layoutBuilder.fieldGroup(arg1, arg2, arg3);
516
+ }
517
+ return this.layoutBuilder.fieldGroup(arg1, arg2);
518
+ }
519
+ formValidators(validators) {
520
+ return this.layoutBuilder.formValidators(validators);
521
+ }
522
+ groupValidators(validators) {
523
+ return this.layoutBuilder.groupValidators(validators);
524
+ }
525
+ initialValue(value) {
526
+ return this.layoutBuilder.initialValue(value);
527
+ }
528
+ visible(condition) {
529
+ this.config.visible = condition;
530
+ return this;
531
+ }
532
+ nextLabel(label) {
533
+ this.config.nextLabel = label;
534
+ return this;
535
+ }
536
+ backLabel(label) {
537
+ this.config.backLabel = label;
538
+ return this;
539
+ }
540
+ hideBack(hide = true) {
541
+ this.config.hideBack = hide;
542
+ return this;
543
+ }
544
+ build() {
545
+ this.layoutBuilder.flushCurrentRow();
546
+ return this.config;
547
+ }
548
+ }
549
+
550
+ class BaseModalBuilder {
551
+ config;
552
+ layoutBuilder;
553
+ constructor(initialConfig) {
554
+ this.config = initialConfig;
555
+ this.layoutBuilder = new FormLayoutBuilder(this.config, this);
556
+ }
557
+ title(title) {
558
+ this.config.title = title;
559
+ return this;
560
+ }
561
+ subtitle(subtitle) {
562
+ this.config.subtitle = subtitle;
563
+ return this;
564
+ }
565
+ description(description) {
566
+ this.config.description = description;
567
+ return this;
568
+ }
569
+ closeGuard(guard) {
570
+ this.config.closeGuard = guard;
571
+ return this;
572
+ }
573
+ /** Set the width of the modal */
574
+ sizeWidth(size) {
575
+ this.config.sizeWidth = size;
576
+ return this;
577
+ }
578
+ /** Set the height of the modal */
579
+ sizeHeight(size) {
580
+ this.config.sizeHeight = size;
581
+ return this;
582
+ }
583
+ closeMode(mode) {
584
+ this.config.closeMode = mode;
585
+ return this;
586
+ }
587
+ backdrop(mode) {
588
+ this.config.backdrop = mode;
589
+ return this;
590
+ }
591
+ keyboard(mode) {
592
+ this.config.keyboard = mode;
593
+ return this;
594
+ }
595
+ intent(intent) {
596
+ this.config.intent = intent;
597
+ return this;
598
+ }
599
+ readOnly(readOnly = true) {
600
+ this.config.readOnly = readOnly;
601
+ return this;
602
+ }
603
+ disabled(disabled = true) {
604
+ this.config.disabled = disabled;
605
+ return this;
606
+ }
607
+ footerActions(actions) {
608
+ this.config.footerActions = actions;
609
+ return this;
610
+ }
611
+ polling(config) {
612
+ this.config.polling = config;
613
+ return this;
614
+ }
615
+ onCancel(handler) {
616
+ this.config.onCancel = handler;
617
+ return this;
618
+ }
619
+ i18n(labels) {
620
+ this.config.i18n = labels;
621
+ return this;
622
+ }
623
+ component(component) {
624
+ this.config.component = component;
625
+ return this;
626
+ }
627
+ template(template) {
628
+ this.config.template = template;
629
+ return this;
630
+ }
631
+ inputs(inputs) {
632
+ this.config.inputs = inputs;
633
+ return this;
634
+ }
635
+ animation(animation) {
636
+ this.config.animation = animation;
637
+ return this;
638
+ }
639
+ /**
640
+ * Control whether the modal renders as a bottom sheet on small screens (< 640px).
641
+ * Enabled by default; pass `false` to keep a centered dialog on mobile.
642
+ */
643
+ mobileBottomSheet(enabled = true) {
644
+ this.config.mobileBottomSheet = enabled;
645
+ return this;
646
+ }
647
+ /**
648
+ * Add a custom body/content to the modal.
649
+ */
650
+ body(body) {
651
+ return this.layoutBuilder.body(body);
652
+ }
653
+ /**
654
+ * Add a field.
655
+ */
656
+ field(field) {
657
+ return this.layoutBuilder.field(field);
658
+ }
659
+ /**
660
+ * Add a field with a fluent validation builder.
661
+ */
662
+ fieldWithValidators(field) {
663
+ return this.layoutBuilder.fieldWithValidators(field);
664
+ }
665
+ /**
666
+ * Start a new row.
667
+ */
668
+ row(columns = 2) {
669
+ return this.layoutBuilder.row(columns);
670
+ }
671
+ /**
672
+ * Add a field to the current row.
673
+ */
674
+ addToRow(field, span = 1) {
675
+ return this.layoutBuilder.addToRow(field, span);
676
+ }
677
+ /**
678
+ * Declarative way to add a row.
679
+ */
680
+ addRow(columns, buildFn) {
681
+ return this.layoutBuilder.addRow(columns, buildFn);
682
+ }
683
+ fieldGroup(arg1, arg2, arg3) {
684
+ if (typeof arg1 !== 'string') {
685
+ return this.layoutBuilder.fieldGroup(arg1);
686
+ }
687
+ if (typeof arg2 === 'string') {
688
+ return this.layoutBuilder.fieldGroup(arg1, arg2, arg3);
689
+ }
690
+ return this.layoutBuilder.fieldGroup(arg1, arg2);
691
+ }
692
+ groupValidators(validators) {
693
+ return this.layoutBuilder.groupValidators(validators);
694
+ }
695
+ build() {
696
+ this.layoutBuilder.flushCurrentRow();
697
+ return Object.freeze({ ...this.config });
698
+ }
699
+ }
700
+
701
+ class WizardModalBuilder extends BaseModalBuilder {
702
+ constructor() {
703
+ super({
704
+ kind: ModalKind.WIZARD,
705
+ steps: [],
706
+ });
707
+ }
708
+ /**
709
+ * Set initial values for the entire wizard.
710
+ * Note: This will be merged with individual step initial values.
711
+ */
712
+ initialValue(value) {
713
+ this.config.initialValue = value;
714
+ return this;
715
+ }
716
+ /**
717
+ * Description is not supported for wizard modals.
718
+ * Use step-level body text instead.
719
+ */
720
+ description(_description) {
721
+ return this;
722
+ }
723
+ step(step) {
724
+ if (typeof step === 'function') {
725
+ const builder = new StepBuilder('', '');
726
+ step(builder);
727
+ const builtStep = builder.build();
728
+ this.config.steps.push(builtStep);
729
+ }
730
+ else {
731
+ this.config.steps.push(step);
732
+ }
733
+ return this;
734
+ }
735
+ addStep(title, buildFn, id) {
736
+ const stepId = id || `step-${this.config.steps.length}`;
737
+ const builder = new StepBuilder(stepId, title);
738
+ buildFn(builder);
739
+ const builtStep = builder.build();
740
+ this.config.steps.push(builtStep);
741
+ return this;
742
+ }
743
+ startAt(stepId) {
744
+ this.config.startStepId = stepId;
745
+ return this;
746
+ }
747
+ flow(mode) {
748
+ this.config.flow = mode;
749
+ return this;
750
+ }
751
+ onStepChange(handler) {
752
+ this.config.onStepChange = handler;
753
+ return this;
754
+ }
755
+ onComplete(handler) {
756
+ this.config.onComplete = handler;
757
+ return this;
758
+ }
759
+ onBeforeComplete(validators) {
760
+ this.config.onBeforeComplete = validators;
761
+ return this;
762
+ }
763
+ }
764
+
765
+ class FormModalBuilder extends BaseModalBuilder {
766
+ constructor() {
767
+ super({
768
+ kind: ModalKind.FORM,
769
+ fields: [],
770
+ rows: [],
771
+ });
772
+ }
773
+ field(field) {
774
+ return super.field(field);
775
+ }
776
+ layout(mode) {
777
+ this.config.layout = mode;
778
+ return this;
779
+ }
780
+ initialValue(value) {
781
+ return this.layoutBuilder.initialValue(value);
782
+ }
783
+ submitMode(mode) {
784
+ this.config.submitMode = mode;
785
+ return this;
786
+ }
787
+ onComplete(handler) {
788
+ this.config.onComplete = handler;
789
+ return this;
790
+ }
791
+ formValidators(validators) {
792
+ return this.layoutBuilder.formValidators(validators);
793
+ }
794
+ groupValidators(validators) {
795
+ return this.layoutBuilder.groupValidators(validators);
796
+ }
797
+ build() {
798
+ return super.build();
799
+ }
800
+ }
801
+
802
+ class ConfirmationModalBuilder extends BaseModalBuilder {
803
+ constructor() {
804
+ super({
805
+ kind: ModalKind.CONFIRMATION,
806
+ message: '',
807
+ fields: [],
808
+ rows: [],
809
+ });
810
+ }
811
+ message(text) {
812
+ this.config.message = text;
813
+ return this;
814
+ }
815
+ tone(tone) {
816
+ this.config.tone = tone;
817
+ return this;
818
+ }
819
+ confirmAction(action) {
820
+ this.config.confirm = action;
821
+ return this;
822
+ }
823
+ cancelAction(action) {
824
+ this.config.cancel = action;
825
+ return this;
826
+ }
827
+ initialValue(value) {
828
+ return this.layoutBuilder.initialValue(value);
829
+ }
830
+ formValidators(validators) {
831
+ return this.layoutBuilder.formValidators(validators);
832
+ }
833
+ groupValidators(validators) {
834
+ return this.layoutBuilder.groupValidators(validators);
835
+ }
836
+ build() {
837
+ return super.build();
838
+ }
839
+ }
840
+
841
+ class CustomModalBuilder extends BaseModalBuilder {
842
+ constructor() {
843
+ super({
844
+ kind: ModalKind.CUSTOM,
845
+ });
846
+ }
847
+ onComplete(handler) {
848
+ this.config.onComplete = handler;
849
+ return this;
850
+ }
851
+ }
852
+
853
+ class ModalBuilder {
854
+ static wizard() {
855
+ return new WizardModalBuilder();
856
+ }
857
+ static form() {
858
+ return new FormModalBuilder();
859
+ }
860
+ static confirmation() {
861
+ return new ConfirmationModalBuilder();
862
+ }
863
+ static custom() {
864
+ return new CustomModalBuilder();
865
+ }
866
+ }
867
+
868
+ class MnModalRef {
869
+ componentRef;
870
+ config;
871
+ closeSubject = new Subject();
872
+ afterClosed$ = this.closeSubject.asObservable();
873
+ /** Whether close() or dismiss() has run, so a shell that finishes loading afterwards is never shown. */
874
+ closeRequested = false;
875
+ /**
876
+ * @param componentRef The rendered modal shell, or null while `MnModalService` is still
877
+ * loading the modal components (`mn-angular-lib/modal-ui`); it is attached with {@link attach}.
878
+ * @param config The modal's mutable working config, shared with the shell.
879
+ */
880
+ constructor(componentRef, config) {
881
+ this.componentRef = componentRef;
882
+ this.config = config;
883
+ }
884
+ close(result) {
885
+ const event = {
886
+ reason: ModalCloseReason.COMPLETED,
887
+ result,
888
+ };
889
+ this.animateAndDestroy(event);
890
+ }
891
+ dismiss(reason) {
892
+ const event = {
893
+ reason,
894
+ };
895
+ this.animateAndDestroy(event);
896
+ }
897
+ async animateAndDestroy(event) {
898
+ this.closeRequested = true;
899
+ const shell = this.componentRef?.instance;
900
+ if (shell && typeof shell.startClosing === 'function') {
901
+ await shell.startClosing();
902
+ }
903
+ this.closeSubject.next(event);
904
+ this.closeSubject.complete();
905
+ this.destroy();
906
+ }
907
+ update(config) {
908
+ Object.assign(this.config, config);
909
+ // Trigger change detection on the shell component, once it is rendered
910
+ this.componentRef?.changeDetectorRef.detectChanges();
911
+ }
912
+ /** The rendered shell component, or undefined while the modal components are still loading. */
913
+ get component() {
914
+ return this.componentRef?.instance;
915
+ }
916
+ /** Whether close() or dismiss() has been called. */
917
+ get isCloseRequested() {
918
+ return this.closeRequested;
919
+ }
920
+ /**
921
+ * Attaches the rendered shell once `MnModalService` has loaded the modal components.
922
+ * @param componentRef The created shell.
923
+ */
924
+ attach(componentRef) {
925
+ this.componentRef = componentRef;
926
+ }
927
+ destroy() {
928
+ this.componentRef?.destroy();
929
+ }
930
+ }
931
+
932
+ /**
933
+ * Public API of the `mn-angular-lib/modal-core` entry point: modal types, builders, the modal ref and action icons, without any component.
934
+ *
935
+ * Each entry point is its own module in the published package, so a consumer's bundler
936
+ * splits it into the chunk that uses it instead of loading the whole library at startup.
937
+ * The root `mn-angular-lib` entry re-exports every entry point.
938
+ */
939
+
940
+ /**
941
+ * Generated bundle index. Do not edit.
942
+ */
943
+
944
+ export { ActionStyle, BackdropMode, BaseModalBuilder, CloseMode, ConfirmationModalBuilder, ConfirmationTone, CustomModalBuilder, FieldAppearance, FieldKind, FormLayoutMode, FormModalBuilder, KeyboardMode, MN_HAPTICS, MN_MODAL_ACTION_ICONS, MODAL_ACTION_ICON_SIZE, MODAL_ACTION_ICON_SIZE_SM, MnModalRef, ModalBuilder, ModalCloseReason, ModalIntent, ModalKind, ModalSize, NavigationDirection, OptionState, SelectionMode, StepBuilder, StepState, SubmitMode, ValidationCode, ValidationStatus, WizardFlowMode, WizardModalBuilder, defaultIconForStyle };
945
+ //# sourceMappingURL=mn-angular-lib-modal-core.mjs.map