mn-angular-lib 1.0.178 → 1.0.180

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 +763 -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 +1147 -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,2016 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, ViewContainerRef, forwardRef, Input, Directive, ViewChild, Component, ChangeDetectorRef, EventEmitter, ViewChildren, Output, signal, TemplateRef, ElementRef, viewChild, computed, HostListener, HostBinding } from '@angular/core';
3
+ import * as i1 from '@angular/common';
4
+ import { CommonModule } from '@angular/common';
5
+ import { FieldKind, ModalCloseReason, MODAL_ACTION_ICON_SIZE, MN_MODAL_ACTION_ICONS, SubmitMode, defaultIconForStyle, ActionStyle, ModalKind, NavigationDirection, ModalSize, WizardFlowMode, ConfirmationTone, MN_HAPTICS, CloseMode, KeyboardMode, BackdropMode } from 'mn-angular-lib/modal-core';
6
+ import * as i2 from '@angular/forms';
7
+ import { NG_VALUE_ACCESSOR, FormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
8
+ import { MnButton } from 'mn-angular-lib/button';
9
+ import { MnInputField, MnCheckbox, MnDatetime, MnMultiSelect, MnTextarea, MnFileInput, MnSelect } from 'mn-angular-lib/forms';
10
+ import { MnLanguageService, lucideIcons } from 'mn-angular-lib/core';
11
+ import { MnTable } from 'mn-angular-lib/collection';
12
+ import { LucideDynamicIcon } from '@lucide/angular';
13
+ import * as lucide from 'lucide';
14
+ import { MnBottomSheet } from 'mn-angular-lib/bottom-sheet';
15
+
16
+ class MnCustomFieldHostDirective {
17
+ vcr = inject(ViewContainerRef);
18
+ component;
19
+ inputs;
20
+ componentRef;
21
+ onChange = () => {
22
+ };
23
+ onTouched = () => { };
24
+ ngOnInit() {
25
+ if (!this.component)
26
+ return;
27
+ this.vcr.clear();
28
+ this.componentRef = this.vcr.createComponent(this.component);
29
+ // Pass inputs to the component
30
+ if (this.inputs) {
31
+ Object.entries(this.inputs).forEach(([key, value]) => {
32
+ this.componentRef.instance[key] = value;
33
+ });
34
+ }
35
+ // Wire up value accessor if the component supports it
36
+ const instance = this.componentRef.instance;
37
+ if (typeof instance.registerOnChange === 'function') {
38
+ instance.registerOnChange((val) => this.onChange(val));
39
+ }
40
+ if (typeof instance.registerOnTouched === 'function') {
41
+ instance.registerOnTouched(() => this.onTouched());
42
+ }
43
+ }
44
+ ngOnDestroy() {
45
+ this.componentRef?.destroy();
46
+ }
47
+ writeValue(val) {
48
+ const instance = this.componentRef?.instance;
49
+ if (instance && typeof instance.writeValue === 'function') {
50
+ instance.writeValue(val);
51
+ }
52
+ }
53
+ registerOnChange(fn) {
54
+ this.onChange = fn;
55
+ }
56
+ registerOnTouched(fn) {
57
+ this.onTouched = fn;
58
+ }
59
+ setDisabledState(isDisabled) {
60
+ const instance = this.componentRef?.instance;
61
+ if (instance && typeof instance.setDisabledState === 'function') {
62
+ instance.setDisabledState(isDisabled);
63
+ }
64
+ }
65
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnCustomFieldHostDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
66
+ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.1.3", type: MnCustomFieldHostDirective, isStandalone: true, selector: "[mnCustomFieldHost]", inputs: { component: "component", inputs: "inputs" }, providers: [
67
+ {
68
+ provide: NG_VALUE_ACCESSOR,
69
+ useExisting: forwardRef(() => MnCustomFieldHostDirective),
70
+ multi: true,
71
+ },
72
+ ], ngImport: i0 });
73
+ }
74
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnCustomFieldHostDirective, decorators: [{
75
+ type: Directive,
76
+ args: [{
77
+ selector: '[mnCustomFieldHost]',
78
+ standalone: true,
79
+ providers: [
80
+ {
81
+ provide: NG_VALUE_ACCESSOR,
82
+ useExisting: forwardRef(() => MnCustomFieldHostDirective),
83
+ multi: true,
84
+ },
85
+ ],
86
+ }]
87
+ }], propDecorators: { component: [{
88
+ type: Input
89
+ }], inputs: [{
90
+ type: Input
91
+ }] } });
92
+
93
+ class MnCustomBodyHostComponent {
94
+ config;
95
+ modalRef;
96
+ container;
97
+ componentRef;
98
+ ngOnInit() {
99
+ setTimeout(() => this.loadContent(), 0);
100
+ }
101
+ loadContent() {
102
+ if (!this.container)
103
+ return;
104
+ this.container.clear();
105
+ if (this.config.component) {
106
+ this.attachComponent(this.config.component);
107
+ }
108
+ else if (this.config.template) {
109
+ this.attachTemplate(this.config.template);
110
+ }
111
+ }
112
+ attachComponent(component) {
113
+ this.componentRef = this.container.createComponent(component);
114
+ // Pass inputs to the component
115
+ if (this.config.inputs) {
116
+ Object.entries(this.config.inputs).forEach(([key, value]) => {
117
+ this.componentRef.instance[key] = value;
118
+ });
119
+ }
120
+ // Pass modalRef if the component has a modalRef property
121
+ const instance = this.componentRef.instance;
122
+ if (instance && 'modalRef' in instance) {
123
+ instance['modalRef'] = this.modalRef;
124
+ }
125
+ }
126
+ attachTemplate(template) {
127
+ this.container.createEmbeddedView(template, {
128
+ $implicit: this.modalRef,
129
+ modalRef: this.modalRef,
130
+ });
131
+ }
132
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnCustomBodyHostComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
133
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.3", type: MnCustomBodyHostComponent, isStandalone: true, selector: "mn-custom-body-host", inputs: { config: "config", modalRef: "modalRef" }, viewQueries: [{ propertyName: "container", first: true, predicate: ["container"], descendants: true, read: ViewContainerRef }], ngImport: i0, template: '<ng-container #container></ng-container>', isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }] });
134
+ }
135
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnCustomBodyHostComponent, decorators: [{
136
+ type: Component,
137
+ args: [{
138
+ selector: 'mn-custom-body-host',
139
+ standalone: true,
140
+ imports: [CommonModule],
141
+ template: '<ng-container #container></ng-container>',
142
+ }]
143
+ }], propDecorators: { config: [{
144
+ type: Input
145
+ }], modalRef: [{
146
+ type: Input
147
+ }], container: [{
148
+ type: ViewChild,
149
+ args: ['container', { read: ViewContainerRef }]
150
+ }] } });
151
+
152
+ class MnFormBodyComponent {
153
+ fb = inject(FormBuilder);
154
+ /**
155
+ * Change detector used to announce state this component mutates outside an Angular
156
+ * event handler — after an `await`, or from an RxJS subscription. Consuming apps run
157
+ * zoneless, where such a write notifies nothing: the view is never marked dirty, so it
158
+ * keeps rendering the stale value and `checkNoChanges` then reports it as NG0100
159
+ * (e.g. the submit button staying disabled on "Submitting..." after a failed submit).
160
+ * Every async mutation of {@link isSubmitting}, {@link fieldLoading}, {@link fieldOptions}
161
+ * and {@link formErrors} must be followed by `markForCheck()`.
162
+ */
163
+ cdr = inject(ChangeDetectorRef);
164
+ config;
165
+ modalRef;
166
+ hideFooter = false;
167
+ hideCustomBody = false;
168
+ formStatusChange = new EventEmitter();
169
+ inputFields;
170
+ textareas;
171
+ form;
172
+ rows = [];
173
+ fieldGroups = [];
174
+ isSubmitting = false;
175
+ FieldKind = FieldKind;
176
+ ModalCloseReason = ModalCloseReason;
177
+ /** Cross-field validation errors: { fieldKey: errorMessage } */
178
+ formErrors = {};
179
+ /** Track which fields are currently visible (for conditional fields) */
180
+ fieldVisibility = {};
181
+ /** Track which fields are currently conditionally required */
182
+ fieldConditionallyRequired = {};
183
+ /** Track loading state per field for async data sources */
184
+ fieldLoading = {};
185
+ /** Dynamic options loaded from data sources */
186
+ fieldOptions = {};
187
+ valueChangesSubscription;
188
+ asField(field) {
189
+ return field;
190
+ }
191
+ asKey(key) {
192
+ return key;
193
+ }
194
+ // The template builds untyped `props` object literals and passes them to
195
+ // strongly-typed child component `[props]` inputs. There is no single static
196
+ // type for those literals, so this identity bridge must return `any` to keep
197
+ // the template assignment-compatible. This is a genuine template-bridge case.
198
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
199
+ asAny(val) {
200
+ return val;
201
+ }
202
+ hasRequiredValidator(field) {
203
+ const view = field;
204
+ // Check if conditionallyRequired is currently active
205
+ if (view.conditionallyRequired) {
206
+ const formValue = (this.form?.value ?? {});
207
+ if (view.conditionallyRequired(formValue))
208
+ return true;
209
+ }
210
+ const validators = view.validators;
211
+ if (!validators)
212
+ return false;
213
+ // Check if Validators.required is in the array by testing a dummy control
214
+ const control = this.fb.control(null, validators);
215
+ const errors = control.errors;
216
+ return errors != null && 'required' in errors;
217
+ }
218
+ /** Store table data sources keyed by field key for template access */
219
+ tableDataSources = {};
220
+ languageService = inject(MnLanguageService);
221
+ static DEFAULT_LABELS = {
222
+ submit: 'Submit',
223
+ cancel: 'Cancel',
224
+ submitting: 'Submitting...',
225
+ selectPlaceholder: 'Select...',
226
+ loading: 'Loading...',
227
+ fileUploadPrompt: 'Click or drag files here',
228
+ fieldRequired: 'This field is required',
229
+ loadingOptions: 'Loading options...',
230
+ accepted: 'Accepted:',
231
+ maxSize: 'Max size:',
232
+ };
233
+ resolveLabel(i18nValue, key) {
234
+ if (i18nValue)
235
+ return i18nValue;
236
+ const translated = this.languageService.translate(`common.${key}`);
237
+ return translated === `common.${key}` ? MnFormBodyComponent.DEFAULT_LABELS[key] : translated;
238
+ }
239
+ /** Resolved i18n labels with defaults, falling back to translated keys */
240
+ get labels() {
241
+ // The config's i18n map may carry extra keys beyond ModalI18nLabels (e.g.
242
+ // fieldRequired, loadingOptions), so widen the type to expose them as
243
+ // declared optional properties (keeps dot access type-checked).
244
+ const i18n = this.config.i18n || {};
245
+ return {
246
+ submit: this.resolveLabel(i18n.submit, 'submit'),
247
+ cancel: this.resolveLabel(i18n.cancel, 'cancel'),
248
+ submitting: this.resolveLabel(i18n.submitting, 'submitting'),
249
+ selectPlaceholder: this.resolveLabel(i18n.selectPlaceholder, 'selectPlaceholder'),
250
+ loading: this.resolveLabel(i18n.loading, 'loading'),
251
+ fileUploadPrompt: this.resolveLabel(i18n.fileUploadPrompt, 'fileUploadPrompt'),
252
+ fieldRequired: this.resolveLabel(i18n.fieldRequired, 'fieldRequired'),
253
+ loadingOptions: this.resolveLabel(i18n.loadingOptions, 'loadingOptions'),
254
+ accepted: this.resolveLabel(i18n.accepted, 'accepted'),
255
+ maxSize: this.resolveLabel(i18n.maxSize, 'maxSize'),
256
+ };
257
+ }
258
+ ngOnInit() {
259
+ this.initializeForm();
260
+ this.buildRows();
261
+ this.initializeVisibility();
262
+ this.initializeDataSources();
263
+ this.initializeTableFields();
264
+ this.subscribeToValueChanges();
265
+ if (this.config.disabled || this.config.readOnly) {
266
+ this.form.disable();
267
+ }
268
+ // Emit initial status
269
+ setTimeout(() => {
270
+ this.formStatusChange.emit(this.form.status);
271
+ });
272
+ }
273
+ ngAfterViewInit() {
274
+ // Small delay to ensure children are fully rendered and MnModalShell hasn't just stolen focus
275
+ setTimeout(() => {
276
+ this.applyAutoFocus();
277
+ }, 100);
278
+ }
279
+ applyAutoFocus() {
280
+ const autoFocusField = this.config.fields.find(f => f.autoFocus);
281
+ if (!autoFocusField)
282
+ return;
283
+ const key = autoFocusField.key;
284
+ // Small delay to ensure browser is ready to focus
285
+ setTimeout(() => {
286
+ // Try finding in MnInputField components
287
+ const inputField = this.inputFields?.find(f => f.props.id === key);
288
+ if (inputField) {
289
+ inputField.focus();
290
+ return;
291
+ }
292
+ // Try finding in MnTextarea components
293
+ const textarea = this.textareas?.find(f => f.props?.id === key);
294
+ if (textarea) {
295
+ textarea.focus();
296
+ return;
297
+ }
298
+ // Fallback to native element if possible
299
+ const el = document.getElementById(key);
300
+ if (el)
301
+ el.focus();
302
+ }, 50);
303
+ }
304
+ ngOnDestroy() {
305
+ this.valueChangesSubscription?.unsubscribe();
306
+ }
307
+ initializeForm() {
308
+ const formControls = {};
309
+ this.config.fields.forEach(field => {
310
+ const fieldConfig = field;
311
+ let initialValue = this.config.initialValue?.[field.key] ?? null;
312
+ // Handle checkbox default values
313
+ if (field.kind === FieldKind.CHECKBOX && initialValue === null) {
314
+ initialValue = fieldConfig.defaultValue ?? false;
315
+ }
316
+ const validators = fieldConfig.validators || [];
317
+ const asyncValidators = fieldConfig.asyncValidators || [];
318
+ const updateOn = fieldConfig.updateOn || 'change';
319
+ formControls[field.key] = [
320
+ initialValue,
321
+ {
322
+ validators,
323
+ asyncValidators,
324
+ updateOn
325
+ }
326
+ ];
327
+ });
328
+ this.form = this.fb.group(formControls);
329
+ // Apply Angular FormGroup-level validators
330
+ if (this.config.groupValidators && this.config.groupValidators.length > 0) {
331
+ this.form.setValidators(this.config.groupValidators);
332
+ this.form.updateValueAndValidity();
333
+ }
334
+ // Apply disabled/readOnly state to controls
335
+ this.config.fields.forEach(field => {
336
+ const fieldView = field;
337
+ const control = this.form.get(field.key);
338
+ if (control && (fieldView.disabled || fieldView.readOnly)) {
339
+ control.disable();
340
+ }
341
+ });
342
+ }
343
+ isFieldReadOnly(field) {
344
+ return this.config.readOnly === true || field.readOnly === true;
345
+ }
346
+ isFieldDisabled(field) {
347
+ return this.config.disabled === true || field.disabled === true;
348
+ }
349
+ /** Track which field groups are currently visible */
350
+ groupVisibility = {};
351
+ buildRows() {
352
+ if (this.config.rows && this.config.rows.length > 0) {
353
+ this.rows = this.config.rows;
354
+ }
355
+ else {
356
+ // Create rows for fields that are not in any row or group
357
+ const fieldsInGroups = new Set();
358
+ (this.config.fieldGroups || []).forEach(g => {
359
+ (g.rows || []).forEach(r => r.fields.forEach(f => fieldsInGroups.add(f.field.key)));
360
+ // Also check if group has flat fields list (compatibility)
361
+ if (g.fields) {
362
+ g.fields.forEach(f => fieldsInGroups.add(f.key));
363
+ }
364
+ });
365
+ const fieldsInRows = new Set();
366
+ (this.config.rows || []).forEach(r => r.fields.forEach(f => fieldsInRows.add(f.field.key)));
367
+ const standaloneFields = this.config.fields.filter(f => !fieldsInGroups.has(f.key) && !fieldsInRows.has(f.key));
368
+ if (standaloneFields.length > 0) {
369
+ this.rows = standaloneFields.map(field => ({
370
+ columns: 1,
371
+ fields: [{ field, span: 1 }],
372
+ }));
373
+ }
374
+ }
375
+ // Build field groups
376
+ this.fieldGroups = this.config.fieldGroups || [];
377
+ // Initialize group visibility
378
+ this.initializeGroupVisibility();
379
+ }
380
+ initializeGroupVisibility() {
381
+ this.fieldGroups.forEach((group, index) => {
382
+ const key = group.title || `group-${index}`;
383
+ const isVisible = group.visible ? group.visible(this.form.value) : true;
384
+ this.groupVisibility[key] = isVisible;
385
+ // If group is hidden, clear validators on its fields
386
+ if (!isVisible) {
387
+ group.fields.forEach(field => {
388
+ const control = this.form.get(field.key);
389
+ if (control) {
390
+ control.clearValidators();
391
+ control.updateValueAndValidity({ emitEvent: false });
392
+ }
393
+ });
394
+ }
395
+ });
396
+ }
397
+ updateGroupVisibility() {
398
+ const formValue = this.form.value;
399
+ this.fieldGroups.forEach((group, index) => {
400
+ const key = group.title || `group-${index}`;
401
+ const wasVisible = this.groupVisibility[key];
402
+ const isVisible = group.visible ? group.visible(formValue) : true;
403
+ this.groupVisibility[key] = isVisible;
404
+ if (!isVisible && wasVisible) {
405
+ // Group became hidden — clear validators on its fields
406
+ group.fields.forEach(field => {
407
+ const control = this.form.get(field.key);
408
+ if (control) {
409
+ control.clearValidators();
410
+ control.updateValueAndValidity({ emitEvent: false });
411
+ }
412
+ });
413
+ }
414
+ else if (isVisible && !wasVisible) {
415
+ // Group became visible — restore validators
416
+ group.fields.forEach(field => {
417
+ const fieldView = field;
418
+ const validators = fieldView.validators || [];
419
+ const control = this.form.get(field.key);
420
+ if (control) {
421
+ control.setValidators(validators);
422
+ control.updateValueAndValidity({ emitEvent: false });
423
+ }
424
+ });
425
+ }
426
+ });
427
+ }
428
+ isGroupVisible(group) {
429
+ const key = group.title || `group-${this.fieldGroups.indexOf(group)}`;
430
+ return this.groupVisibility[key];
431
+ }
432
+ // =========================
433
+ // Feature 1: Conditional/Dynamic Fields
434
+ // =========================
435
+ initializeVisibility() {
436
+ const formValue = this.form.value;
437
+ this.config.fields.forEach(field => {
438
+ const key = field.key;
439
+ const fieldView = field;
440
+ const isVisible = fieldView.visible ? fieldView.visible(formValue) : true;
441
+ this.fieldVisibility[key] = isVisible;
442
+ // If initially hidden, clear validators so they don't block submit
443
+ if (!isVisible) {
444
+ const control = this.form.get(key);
445
+ if (control) {
446
+ control.clearValidators();
447
+ control.updateValueAndValidity({ emitEvent: false });
448
+ }
449
+ }
450
+ else if (fieldView.conditionallyRequired) {
451
+ // Initialize conditionallyRequired state for visible fields
452
+ const isRequired = fieldView.conditionallyRequired(formValue);
453
+ this.fieldConditionallyRequired[key] = isRequired;
454
+ if (isRequired) {
455
+ const control = this.form.get(key);
456
+ if (control) {
457
+ const validators = this.buildValidators(fieldView, formValue);
458
+ control.setValidators(validators);
459
+ control.updateValueAndValidity({ emitEvent: false });
460
+ }
461
+ }
462
+ }
463
+ });
464
+ }
465
+ updateVisibility() {
466
+ const formValue = this.form.value;
467
+ this.config.fields.forEach(field => {
468
+ const key = field.key;
469
+ const fieldView = field;
470
+ const wasVisible = this.fieldVisibility[key];
471
+ const isVisible = fieldView.visible ? fieldView.visible(formValue) : true;
472
+ this.fieldVisibility[key] = isVisible;
473
+ // When a field becomes hidden, clear its validators so it doesn't block submit
474
+ const control = this.form.get(key);
475
+ if (control) {
476
+ if (!isVisible && wasVisible) {
477
+ control.clearValidators();
478
+ control.updateValueAndValidity({ emitEvent: false });
479
+ }
480
+ else if (isVisible && !wasVisible) {
481
+ // Restore validators (including conditionallyRequired if active)
482
+ const validators = this.buildValidators(fieldView, formValue);
483
+ control.setValidators(validators);
484
+ control.updateValueAndValidity({ emitEvent: false });
485
+ }
486
+ else if (isVisible) {
487
+ // Update conditionallyRequired for visible fields
488
+ this.updateConditionallyRequired(fieldView, formValue);
489
+ }
490
+ }
491
+ });
492
+ }
493
+ /**
494
+ * Builds the full validator array for a field, including conditionallyRequired.
495
+ * @param field The field configuration view.
496
+ * @param formValue The current form values.
497
+ * @returns Array of validators to apply.
498
+ */
499
+ buildValidators(field, formValue) {
500
+ const baseValidators = field.validators ? [...field.validators] : [];
501
+ if (field.conditionallyRequired && field.conditionallyRequired(formValue)) {
502
+ if (!baseValidators.includes(Validators.required)) {
503
+ baseValidators.push(Validators.required);
504
+ }
505
+ }
506
+ return baseValidators;
507
+ }
508
+ /**
509
+ * Updates the conditionallyRequired state for a single field and adjusts validators.
510
+ * @param field The field configuration view.
511
+ * @param formValue The current form values.
512
+ */
513
+ updateConditionallyRequired(field, formValue) {
514
+ if (!field.conditionallyRequired)
515
+ return;
516
+ const key = field.key;
517
+ const wasRequired = this.fieldConditionallyRequired[key] ?? false;
518
+ const isRequired = field.conditionallyRequired(formValue);
519
+ this.fieldConditionallyRequired[key] = isRequired;
520
+ if (isRequired !== wasRequired) {
521
+ const control = this.form.get(key);
522
+ if (control) {
523
+ const validators = this.buildValidators(field, formValue);
524
+ control.setValidators(validators);
525
+ control.updateValueAndValidity({ emitEvent: false });
526
+ }
527
+ }
528
+ }
529
+ isFieldVisible(field) {
530
+ return this.fieldVisibility[field.key];
531
+ }
532
+ // =========================
533
+ // Feature 2: Cross-Field Validation
534
+ // =========================
535
+ runFormValidators() {
536
+ this.formErrors = {};
537
+ if (!this.config.formValidators)
538
+ return;
539
+ const formValue = this.form.value;
540
+ for (const validator of this.config.formValidators) {
541
+ const errors = validator(formValue);
542
+ if (errors) {
543
+ Object.assign(this.formErrors, errors);
544
+ }
545
+ }
546
+ }
547
+ getFieldError(key) {
548
+ return this.formErrors[key] || null;
549
+ }
550
+ get hasFormErrors() {
551
+ return Object.keys(this.formErrors).length > 0;
552
+ }
553
+ // =========================
554
+ // Feature 3: Async Data Sources
555
+ // =========================
556
+ initializeDataSources() {
557
+ this.config.fields.forEach(field => {
558
+ const fieldView = field;
559
+ if (fieldView.dataSource) {
560
+ this.loadFieldOptions(field.key, fieldView.dataSource, this.form.value);
561
+ }
562
+ });
563
+ }
564
+ isFieldLoading(key) {
565
+ return this.fieldLoading[key];
566
+ }
567
+ /** Get options for a field — uses dataSource options if available, otherwise static options */
568
+ getFieldOptions(field) {
569
+ const key = field.key;
570
+ if (this.fieldOptions[key] !== undefined) {
571
+ return this.fieldOptions[key];
572
+ }
573
+ return field.options || [];
574
+ }
575
+ /** Convert SelectOption[] to MnSelectOption[] for mn-lib-select */
576
+ getSelectOptions(field) {
577
+ return this.getFieldOptions(field).map(o => ({
578
+ label: o.label,
579
+ value: o.value,
580
+ disabled: o.state === 'disabled',
581
+ }));
582
+ }
583
+ getSelectProps(field) {
584
+ return {
585
+ id: field.key,
586
+ label: this.asField(field).label,
587
+ placeholder: this.isFieldLoading(field.key) ? this.labels.loading : this.labels.selectPlaceholder,
588
+ options: this.getSelectOptions(field),
589
+ fullWidth: true,
590
+ };
591
+ }
592
+ async loadFieldOptions(key, dataSource, formValue) {
593
+ this.fieldLoading[key] = true;
594
+ this.cdr.markForCheck();
595
+ try {
596
+ this.fieldOptions[key] = await dataSource.load(formValue);
597
+ }
598
+ catch (error) {
599
+ console.error(`Failed to load options for field '${key}':`, error);
600
+ this.fieldOptions[key] = [];
601
+ }
602
+ finally {
603
+ // Resolved after an `await`, so nothing has told Angular the spinner can go and the
604
+ // options have arrived. Without this the field renders "Loading options..." forever.
605
+ this.fieldLoading[key] = false;
606
+ this.cdr.markForCheck();
607
+ }
608
+ }
609
+ // =========================
610
+ // Feature: Multi-Select Table Fields
611
+ // =========================
612
+ initializeTableFields() {
613
+ this.config.fields.forEach(field => {
614
+ if (field.kind === FieldKind.MULTI_SELECT_TABLE) {
615
+ const tableField = field;
616
+ const ds = tableField.tableDataSource;
617
+ // Force multi selection mode
618
+ ds.selectionMode = 'multi';
619
+ // Default the selection summary on. A table used as a form field is always
620
+ // inside a modal, where it is short, paged and searched — so the rows the
621
+ // user has already picked are the ones most likely to be scrolled out of
622
+ // sight, which is exactly what the summary exists to prevent. Set
623
+ // `selectionSummary: false` on the data source to opt a field out.
624
+ ds.selectionSummary ??= true;
625
+ // A modal is too short to make a rows-per-page choice meaningful, and the
626
+ // selector costs a row of footer the sheet cannot spare. Pinning the options
627
+ // to the single configured size hides it through the paginator's existing
628
+ // "more than one option" rule rather than adding a second way to hide it.
629
+ ds.pageSizeOptions = [ds.pageSize ?? 10];
630
+ // Pre-select rows from the form's initial value
631
+ const control = this.form.get(field.key);
632
+ if (control && Array.isArray(control.value) && control.value.length > 0) {
633
+ ds.initialSelectedIds = control.value.map((v) => String(v));
634
+ }
635
+ else if (control && control.value === null) {
636
+ control.setValue([], { emitEvent: false });
637
+ }
638
+ this.tableDataSources[field.key] = ds;
639
+ }
640
+ else if (field.kind === FieldKind.SINGLE_SELECT_TABLE) {
641
+ const tableField = field;
642
+ const ds = tableField.tableDataSource;
643
+ // Force single selection mode
644
+ ds.selectionMode = 'single';
645
+ // Pre-select row from the form's initial value
646
+ const control = this.form.get(field.key);
647
+ if (control && control.value != null) {
648
+ ds.initialSelectedIds = [String(control.value)];
649
+ }
650
+ this.tableDataSources[field.key] = ds;
651
+ }
652
+ });
653
+ }
654
+ onTableSelectionChange(field, selectedRows) {
655
+ if (field.kind === FieldKind.SINGLE_SELECT_TABLE) {
656
+ const tableField = field;
657
+ const getVal = tableField.getRowValue || tableField.tableDataSource.getID;
658
+ const value = selectedRows.length > 0 ? getVal(selectedRows[0]) : null;
659
+ const control = this.form.get(field.key);
660
+ if (control) {
661
+ control.setValue(value);
662
+ control.markAsTouched();
663
+ }
664
+ }
665
+ else {
666
+ const tableField = field;
667
+ const getVal = tableField.getRowValue || tableField.tableDataSource.getID;
668
+ const values = selectedRows.map(row => getVal(row));
669
+ const control = this.form.get(field.key);
670
+ if (control) {
671
+ control.setValue(values);
672
+ control.markAsTouched();
673
+ }
674
+ }
675
+ }
676
+ // =========================
677
+ // Feature: Rating Fields
678
+ // =========================
679
+ getRatingRange(field) {
680
+ const max = field.max || 5;
681
+ return Array.from({ length: max }, (_, i) => i + 1);
682
+ }
683
+ setRating(field, value) {
684
+ const control = this.form.get(field.key);
685
+ if (control) {
686
+ control.setValue(value);
687
+ control.markAsTouched();
688
+ }
689
+ }
690
+ getRatingValue(field) {
691
+ return this.form.get(field.key)?.value || 0;
692
+ }
693
+ // =========================
694
+ // Feature: Slider Fields
695
+ // =========================
696
+ onSliderChange(field, event) {
697
+ const input = event.target;
698
+ const value = parseFloat(input.value);
699
+ const control = this.form.get(field.key);
700
+ if (control) {
701
+ control.setValue(value);
702
+ control.markAsTouched();
703
+ }
704
+ }
705
+ getSliderValue(field) {
706
+ const f = field;
707
+ return this.form.get(field.key)?.value ?? f.min ?? 0;
708
+ }
709
+ // =========================
710
+ // Feature: Color Fields
711
+ // =========================
712
+ onColorChange(field, event) {
713
+ const input = event.target;
714
+ const control = this.form.get(field.key);
715
+ if (control) {
716
+ control.setValue(input.value);
717
+ control.markAsTouched();
718
+ }
719
+ }
720
+ setColorFromSwatch(field, color) {
721
+ const control = this.form.get(field.key);
722
+ if (control) {
723
+ control.setValue(color);
724
+ control.markAsTouched();
725
+ }
726
+ }
727
+ getColorValue(field) {
728
+ return this.form.get(field.key)?.value || '#000000';
729
+ }
730
+ // =========================
731
+ // Value Changes Subscription
732
+ // =========================
733
+ subscribeToValueChanges() {
734
+ // Initialize previousFormValue with current form state to avoid false "changed" on first emission
735
+ this.previousFormValue = { ...this.form.value };
736
+ this.valueChangesSubscription = this.form.valueChanges.subscribe(formValue => {
737
+ // Update conditional visibility
738
+ this.updateVisibility();
739
+ // Update group visibility
740
+ this.updateGroupVisibility();
741
+ // Run cross-field validators
742
+ this.runFormValidators();
743
+ // Reload data sources that depend on changed fields
744
+ this.reloadDependentDataSources(formValue);
745
+ // Emit status change
746
+ this.formStatusChange.emit(this.form.status);
747
+ // `valueChanges` can fire from outside an Angular event handler (a CVA writing on
748
+ // init, or a caller patching the form), and the callbacks above rewrite visibility,
749
+ // required-state and cross-field errors that the template reads.
750
+ this.cdr.markForCheck();
751
+ });
752
+ }
753
+ previousFormValue = {};
754
+ reloadDependentDataSources(formValue) {
755
+ this.config.fields.forEach(field => {
756
+ const fieldView = field;
757
+ const dataSource = fieldView.dataSource;
758
+ if (!dataSource?.dependsOn)
759
+ return;
760
+ // Check if any dependency changed
761
+ const changed = dataSource.dependsOn.some(depKey => {
762
+ return formValue[depKey] !== this.previousFormValue[depKey];
763
+ });
764
+ if (changed) {
765
+ this.loadFieldOptions(field.key, dataSource, formValue);
766
+ }
767
+ });
768
+ this.previousFormValue = { ...formValue };
769
+ }
770
+ // =========================
771
+ // Feature: File Upload Fields
772
+ // =========================
773
+ /**
774
+ * Invokes a FILE field's `onClear` callback when its existing image is removed.
775
+ * FILE fields render {@link MnFileInput}, which owns selection/validation and
776
+ * writes the value (`File | File[] | null`) straight to the form control.
777
+ * @param field The field whose existing image was cleared.
778
+ */
779
+ onFileCleared(field) {
780
+ field.onClear?.();
781
+ }
782
+ /** Icon size (px) for the footer action buttons. */
783
+ actionIconSize = MODAL_ACTION_ICON_SIZE;
784
+ /** Whether action-button icons should render on this modal (defaults to true). */
785
+ get showActionIcons() {
786
+ return this.config.showActionIcons !== false;
787
+ }
788
+ /** The leading icon for the submit button, or null when icons are disabled. */
789
+ get submitIcon() {
790
+ return this.showActionIcons ? MN_MODAL_ACTION_ICONS.confirm : null;
791
+ }
792
+ /** The leading icon for the cancel button, or null when icons are disabled. */
793
+ get cancelIcon() {
794
+ return this.showActionIcons ? MN_MODAL_ACTION_ICONS.cancel : null;
795
+ }
796
+ async submit() {
797
+ // Run cross-field validators before submit
798
+ this.runFormValidators();
799
+ if (this.form.invalid || this.isSubmitting || this.hasFormErrors) {
800
+ this.form.markAllAsTouched();
801
+ return;
802
+ }
803
+ if (this.config.submitMode === SubmitMode.ONCE) {
804
+ this.isSubmitting = true;
805
+ }
806
+ const formValue = this.form.value;
807
+ try {
808
+ if (this.config.onComplete) {
809
+ await this.config.onComplete.handle(formValue);
810
+ }
811
+ this.modalRef.close(formValue);
812
+ }
813
+ catch (error) {
814
+ // Always allow retry on error, regardless of submit mode. This runs after an `await`,
815
+ // so it must announce itself: otherwise the button stays disabled on "Submitting..."
816
+ // and the user can never retry the action that just failed.
817
+ this.isSubmitting = false;
818
+ this.cdr.markForCheck();
819
+ console.error('Form submission error:', error);
820
+ }
821
+ }
822
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnFormBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
823
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: MnFormBodyComponent, isStandalone: true, selector: "mn-form-body", inputs: { config: "config", modalRef: "modalRef", hideFooter: "hideFooter", hideCustomBody: "hideCustomBody" }, outputs: { formStatusChange: "formStatusChange" }, viewQueries: [{ propertyName: "inputFields", predicate: MnInputField, descendants: true }, { propertyName: "textareas", predicate: MnTextarea, descendants: true }], ngImport: i0, template: "@if ((config.component || config.template) && !hideCustomBody) {\n <mn-custom-body-host\n [config]=\"asAny(config)\"\n [modalRef]=\"asAny(modalRef)\"\n class=\"mb-6 block\"\n ></mn-custom-body-host>\n}\n\n<form (ngSubmit)=\"submit()\" [formGroup]=\"form\" class=\"flex flex-col gap-6 h-full\">\n <!-- Shared field rendering template (must be inside form for formControlName) -->\n <ng-template #fieldTemplate let-rowField>\n @switch (rowField.field.kind) {\n @case (FieldKind.TEXT) {\n <div>\n <mn-lib-input-field\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n type: 'text',\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n mask: asField(rowField.field).mask,\n autocomplete: asField(rowField.field).autocomplete,\n readonly: isFieldReadOnly(rowField.field),\n fullWidth: true\n })\"\n ></mn-lib-input-field>\n </div>\n }\n\n @case (FieldKind.NUMBER) {\n <div>\n <mn-lib-input-field\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n type: 'number',\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n readonly: isFieldReadOnly(rowField.field),\n fullWidth: true\n })\"\n ></mn-lib-input-field>\n </div>\n }\n\n @case (FieldKind.PASSWORD) {\n <div>\n <mn-lib-input-field\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n type: 'password',\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n readonly: isFieldReadOnly(rowField.field),\n fullWidth: true\n })\"\n ></mn-lib-input-field>\n </div>\n }\n\n @case (FieldKind.SELECT) {\n <div class=\"flex flex-col\">\n <mn-lib-select\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"getSelectProps(rowField.field)\"\n ></mn-lib-select>\n @if (isFieldLoading(asKey(rowField.field.key))) {\n <div class=\"flex items-center gap-1 pl-2 pt-1\">\n <div class=\"w-4 h-4 border-2 border-base-300 border-t-blue-500 rounded-full animate-spin\"></div>\n </div>\n }\n @if (getFieldError(asKey(rowField.field.key))) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ getFieldError(asKey(rowField.field.key)) }}\n </div>\n }\n </div>\n }\n\n @case (FieldKind.CHECKBOX) {\n <div>\n <mn-lib-checkbox\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n label: asField(rowField.field).label,\n disabled: isFieldDisabled(rowField.field) || isFieldReadOnly(rowField.field)\n })\"\n ></mn-lib-checkbox>\n </div>\n }\n\n @case (FieldKind.DATE) {\n <div>\n <mn-lib-input-field\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n type: 'date',\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n startDate: asField(rowField.field).minDate,\n endDate: asField(rowField.field).maxDate,\n readonly: isFieldReadOnly(rowField.field),\n fullWidth: true\n })\"\n ></mn-lib-input-field>\n </div>\n }\n\n @case (FieldKind.DATETIME) {\n <div>\n <mn-lib-datetime\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n mode: asField(rowField.field).mode || 'datetime-local',\n min: asField(rowField.field).min,\n max: asField(rowField.field).max,\n step: asField(rowField.field).step,\n readonly: isFieldReadOnly(rowField.field),\n fullWidth: true\n })\"\n ></mn-lib-datetime>\n </div>\n }\n\n @case (FieldKind.TEXTAREA) {\n <div>\n <mn-lib-textarea\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n rows: asField(rowField.field).rows || 4,\n resize: 'vertical',\n autocomplete: asField(rowField.field).autocomplete,\n readonly: isFieldReadOnly(rowField.field)\n })\"\n ></mn-lib-textarea>\n </div>\n }\n\n @case (FieldKind.MULTI_SELECT) {\n <div>\n @if (isFieldLoading(asKey(rowField.field.key))) {\n <div class=\"flex items-center gap-2 py-2 text-sm text-base-content/50\">\n <div class=\"w-4 h-4 border-2 border-base-300 border-t-blue-500 rounded-full animate-spin\"></div>\n {{ labels.loadingOptions }}\n </div>\n }\n @if (!isFieldLoading(asKey(rowField.field.key))) {\n <mn-lib-multi-select\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n label: asField(rowField.field).label,\n options: getFieldOptions(rowField.field),\n placeholder: asField(rowField.field).placeholder,\n searchable: asField(rowField.field).searchable,\n searchPlaceholder: asField(rowField.field).searchPlaceholder,\n maxSelections: asField(rowField.field).maxSelections,\n collapseThreshold: asField(rowField.field).collapseThreshold,\n collapsePlaceholder: asField(rowField.field).collapsePlaceholder,\n allSelectedPlaceholder: asField(rowField.field).allSelectedPlaceholder,\n disabled: isFieldDisabled(rowField.field) || isFieldReadOnly(rowField.field)\n })\"\n ></mn-lib-multi-select>\n }\n @if (getFieldError(asKey(rowField.field.key))) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ getFieldError(asKey(rowField.field.key)) }}\n </div>\n }\n </div>\n }\n\n @case (FieldKind.MULTI_SELECT_TABLE) {\n <ng-container [ngTemplateOutlet]=\"selectTableTemplate\" [ngTemplateOutletContext]=\"{ $implicit: rowField }\"></ng-container>\n }\n\n @case (FieldKind.SINGLE_SELECT_TABLE) {\n <ng-container [ngTemplateOutlet]=\"selectTableTemplate\" [ngTemplateOutletContext]=\"{ $implicit: rowField }\"></ng-container>\n }\n\n @case (FieldKind.COLOR) {\n <div class=\"flex flex-col gap-1\">\n <label [for]=\"'field-' + asKey(rowField.field.key)\"\n class=\"pl-2 pb-1 flex flex-row gap-0.5 text-base font-medium text-base-content\">\n {{ asField(rowField.field).label }}\n @if (hasRequiredValidator(rowField.field)) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n <div class=\"flex items-center gap-3\">\n <input\n type=\"color\"\n [id]=\"'field-' + asKey(rowField.field.key)\"\n class=\"w-10 h-10 rounded-lg border border-base-300 cursor-pointer p-0.5\"\n [value]=\"getColorValue(rowField.field)\"\n [disabled]=\"isFieldReadOnly(rowField.field) || isFieldDisabled(rowField.field)\"\n (input)=\"onColorChange(rowField.field, $event)\"\n />\n <span class=\"text-sm text-base-content/60 font-mono\">{{ getColorValue(rowField.field) }}</span>\n </div>\n @if (asField(rowField.field).swatches) {\n <div class=\"flex gap-1.5 mt-1\">\n @for (swatch of asField(rowField.field).swatches; track swatch) {\n <button\n mnButton\n [data]=\"{ size: 'sm', variant: 'text', color: 'secondary' }\"\n type=\"button\"\n class=\"w-6 h-6 rounded-md border border-base-300 cursor-pointer transition-transform hover:scale-110\"\n [style.background-color]=\"swatch\"\n [class.ring-2]=\"getColorValue(rowField.field) === swatch\"\n [class.ring-blue-500]=\"getColorValue(rowField.field) === swatch\"\n (click)=\"setColorFromSwatch(rowField.field, swatch)\"\n [attr.aria-label]=\"'Select color ' + swatch\"\n ></button>\n }\n </div>\n }\n @if (form.get(asKey(rowField.field.key))?.invalid && form.get(asKey(rowField.field.key))?.touched) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ labels.fieldRequired }}\n </div>\n }\n </div>\n }\n\n @case (FieldKind.RATING) {\n <div class=\"flex flex-col gap-1\">\n <span [id]=\"'rating-label-' + asKey(rowField.field.key)\"\n class=\"pl-2 pb-1 flex flex-row gap-0.5 text-base font-medium text-base-content\">\n {{ asField(rowField.field).label }}\n @if (hasRequiredValidator(rowField.field)) {\n <span class=\"text-red-500\">*</span>\n }\n </span>\n <div [attr.aria-labelledby]=\"'rating-label-' + asKey(rowField.field.key)\" class=\"flex items-center gap-1\"\n role=\"group\">\n @for (star of getRatingRange(rowField.field); track star) {\n <button\n mnButton\n [data]=\"{ size: 'sm', variant: 'text', color: 'secondary' }\"\n type=\"button\"\n class=\"text-2xl cursor-pointer transition-colors focus:outline-none\"\n [class.text-yellow-400]=\"star <= getRatingValue(rowField.field)\"\n [class.text-base-300]=\"star > getRatingValue(rowField.field)\"\n [disabled]=\"isFieldReadOnly(rowField.field) || isFieldDisabled(rowField.field)\"\n (click)=\"setRating(rowField.field, star)\"\n >\n &#9733;\n </button>\n }\n <span class=\"text-sm text-base-content/50 ml-2\">{{ getRatingValue(rowField.field) }} / {{ asField(rowField.field).max || 5 }}</span>\n </div>\n @if (form.get(asKey(rowField.field.key))?.invalid && form.get(asKey(rowField.field.key))?.touched) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ labels.fieldRequired }}\n </div>\n }\n </div>\n }\n\n @case (FieldKind.SLIDER) {\n <div class=\"flex flex-col gap-1\">\n <label [for]=\"'field-' + asKey(rowField.field.key)\"\n class=\"pl-2 pb-1 flex flex-row gap-0.5 text-base font-medium text-base-content\">\n {{ asField(rowField.field).label }}\n @if (hasRequiredValidator(rowField.field)) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n <div class=\"flex items-center gap-3\">\n <input\n type=\"range\"\n [id]=\"'field-' + asKey(rowField.field.key)\"\n class=\"flex-1 h-2 bg-base-200 rounded-lg appearance-none cursor-pointer accent-blue-500\"\n [attr.min]=\"asField(rowField.field).min ?? 0\"\n [attr.max]=\"asField(rowField.field).max ?? 100\"\n [attr.step]=\"asField(rowField.field).step ?? 1\"\n [value]=\"getSliderValue(rowField.field)\"\n [disabled]=\"isFieldReadOnly(rowField.field) || isFieldDisabled(rowField.field)\"\n (input)=\"onSliderChange(rowField.field, $event)\"\n />\n @if (asField(rowField.field).showValue !== false) {\n <span class=\"text-sm text-base-content/60 min-w-[3rem] text-right\">\n {{ getSliderValue(rowField.field) }}{{ asField(rowField.field).unit || '' }}\n </span>\n }\n </div>\n <div class=\"flex justify-between text-xs text-base-content/40 px-1\">\n <span>{{ asField(rowField.field).min ?? 0 }}</span>\n <span>{{ asField(rowField.field).max ?? 100 }}</span>\n </div>\n @if (form.get(asKey(rowField.field.key))?.invalid && form.get(asKey(rowField.field.key))?.touched) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ labels.fieldRequired }}\n </div>\n }\n </div>\n }\n\n @case (FieldKind.FILE) {\n <div>\n <mn-lib-file-input\n (cleared)=\"onFileCleared(rowField.field)\"\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n label: asField(rowField.field).label,\n accept: asField(rowField.field).accept,\n multiple: asField(rowField.field).multiple,\n maxFiles: asField(rowField.field).maxFiles,\n maxSize: asField(rowField.field).maxSize,\n displayMode: asField(rowField.field).displayMode,\n dropzoneHint: asField(rowField.field).dropzoneHint,\n dropActiveHint: asField(rowField.field).dropActiveHint,\n replaceLabel: asField(rowField.field).replaceLabel,\n removeLabel: asField(rowField.field).removeLabel,\n currentUrl: asField(rowField.field).currentUrl,\n currentUrls: asField(rowField.field).currentUrls,\n disabled: isFieldReadOnly(rowField.field) || isFieldDisabled(rowField.field)\n })\"\n ></mn-lib-file-input>\n </div>\n }\n\n @case (FieldKind.CUSTOM) {\n <div>\n <ng-container\n mnCustomFieldHost\n [component]=\"asField(rowField.field).component\"\n [inputs]=\"asField(rowField.field).inputs\"\n [formControlName]=\"asKey(rowField.field.key)\"\n ></ng-container>\n </div>\n }\n\n @default {\n <div></div>\n }\n }\n\n <!-- Show cross-field error below any field that has one -->\n @if (getFieldError(asKey(rowField.field.key)) && rowField.field.kind !== FieldKind.SELECT && rowField.field.kind !== FieldKind.MULTI_SELECT) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ getFieldError(asKey(rowField.field.key)) }}\n </div>\n }\n </ng-template>\n\n <!-- Shared template for MULTI_SELECT_TABLE and SINGLE_SELECT_TABLE -->\n <ng-template #selectTableTemplate let-rowField>\n <div class=\"flex flex-col gap-1\">\n @if (asField(rowField.field).label) {\n <span class=\"pl-2 pb-1 flex flex-row gap-0.5 text-base font-medium text-base-content\">\n {{ asField(rowField.field).label }}\n @if (hasRequiredValidator(rowField.field)) {\n <span class=\"text-red-500\">*</span>\n }\n </span>\n }\n <mn-table\n [dataSource]=\"tableDataSources[asKey(rowField.field.key)]\"\n [attr.aria-label]=\"asField(rowField.field).label || null\"\n (selectionChange)=\"onTableSelectionChange(rowField.field, $event)\"\n ></mn-table>\n @if (form.get(asKey(rowField.field.key))?.invalid && form.get(asKey(rowField.field.key))?.touched) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ labels.fieldRequired }}\n </div>\n }\n </div>\n </ng-template>\n\n <!-- Field Groups (sections with headers) -->\n @if (fieldGroups.length > 0) {\n <div class=\"flex flex-col gap-6\">\n @for (group of fieldGroups; track group.title) {\n <div class=\"flex flex-col gap-4\" [style.display]=\"isGroupVisible(group) ? '' : 'none'\">\n <div class=\"border-b border-base-300 pb-2\">\n <h3 class=\"text-base font-semibold text-base-content\">{{ group.title }}</h3>\n @if (group.description) {\n <p class=\"text-sm text-base-content/50 mt-0.5\">{{ group.description }}</p>\n }\n </div>\n @for (row of group.rows; track $index) {\n <div [style.--mn-form-cols]=\"row.columns || 1\" class=\"grid gap-4 mn-form-row\">\n @for (rowField of row.fields; track rowField.field.key) {\n <div [style.--mn-form-span]=\"rowField.span || 1\" [style.display]=\"isFieldVisible(rowField.field) ? '' : 'none'\"\n class=\"flex flex-col gap-2 mn-form-cell\">\n <ng-container [ngTemplateOutlet]=\"fieldTemplate\" [ngTemplateOutletContext]=\"{ $implicit: rowField }\"></ng-container>\n </div>\n }\n </div>\n }\n </div>\n }\n </div>\n }\n\n <!-- Standard rows (no groups) -->\n @if (rows.length > 0) {\n <div class=\"flex flex-col gap-4\">\n @for (row of rows; track $index) {\n <div [style.--mn-form-cols]=\"row.columns || 1\" class=\"grid gap-4 mn-form-row\">\n @for (rowField of row.fields; track rowField.field.key) {\n <div [style.--mn-form-span]=\"rowField.span || 1\" [style.display]=\"isFieldVisible(rowField.field) ? '' : 'none'\"\n class=\"flex flex-col gap-2 mn-form-cell\">\n <ng-container [ngTemplateOutlet]=\"fieldTemplate\" [ngTemplateOutletContext]=\"{ $implicit: rowField }\"></ng-container>\n </div>\n }\n </div>\n }\n </div>\n }\n\n <!-- Form-level errors (not tied to a specific field) -->\n @if (formErrors['_form']) {\n <div class=\"text-red-500 text-sm px-2 py-1 bg-red-50 rounded-md\">\n {{ formErrors['_form'] }}\n </div>\n }\n\n @if (!hideFooter) {\n <div class=\"flex gap-3 pt-4 pb-6 border-t border-base-300 mt-auto sticky bottom-0 bg-base-100 z-10\">\n <button\n mnButton\n type=\"button\"\n [data]=\"{ variant: 'outline', color: 'secondary' }\"\n (mousedown)=\"modalRef.dismiss(ModalCloseReason.CANCELLED)\"\n >\n @if (cancelIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ labels.cancel }}\n </button>\n\n <div class=\"flex-1\"></div>\n\n <button\n mnButton\n type=\"submit\"\n [data]=\"{ variant: 'fill', color: 'primary', disabled: form.invalid || isSubmitting }\"\n [disabled]=\"form.invalid || isSubmitting\"\n >\n @if (submitIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ isSubmitting ? labels.submitting : labels.submit }}\n </button>\n </div>\n }\n</form>\n", styles: [".select-arrow{background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-position:right .75rem center}.mn-form-row{grid-template-columns:repeat(var(--mn-form-cols, 1),minmax(0,1fr))}.mn-form-cell{grid-column:span var(--mn-form-span, 1)}@media(max-width:639.98px){.mn-form-row{grid-template-columns:1fr}.mn-form-cell{grid-column:auto}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],[formArray],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.FormControlName, selector: "[formControlName]", inputs: ["formControlName", "disabled", "ngModel"], outputs: ["ngModelChange"] }, { kind: "component", type: MnButton, selector: "button[mnButton], a[mnButton]", inputs: ["data"] }, { kind: "component", type: MnInputField, selector: "mn-lib-input-field", inputs: ["props"] }, { kind: "component", type: MnCheckbox, selector: "mn-lib-checkbox", inputs: ["props", "checked"], outputs: ["checkedChange"] }, { kind: "component", type: MnDatetime, selector: "mn-lib-datetime", inputs: ["props"] }, { kind: "component", type: MnMultiSelect, selector: "mn-lib-multi-select", inputs: ["props"] }, { kind: "component", type: MnTextarea, selector: "mn-lib-textarea", inputs: ["props"] }, { kind: "component", type: MnFileInput, selector: "mn-lib-file-input", inputs: ["props"], outputs: ["filesChange", "cleared"] }, { kind: "component", type: MnSelect, selector: "mn-lib-select", inputs: ["props"] }, { kind: "directive", type: MnCustomFieldHostDirective, selector: "[mnCustomFieldHost]", inputs: ["component", "inputs"] }, { kind: "component", type: MnTable, selector: "mn-table", outputs: ["sortChange", "rowClick"] }, { kind: "component", type: MnCustomBodyHostComponent, selector: "mn-custom-body-host", inputs: ["config", "modalRef"] }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }] });
824
+ }
825
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnFormBodyComponent, decorators: [{
826
+ type: Component,
827
+ args: [{ selector: 'mn-form-body', standalone: true, imports: [CommonModule, ReactiveFormsModule, MnButton, MnInputField, MnCheckbox, MnDatetime, MnMultiSelect, MnTextarea, MnFileInput, MnSelect, MnCustomFieldHostDirective, MnTable, MnCustomBodyHostComponent, LucideDynamicIcon], template: "@if ((config.component || config.template) && !hideCustomBody) {\n <mn-custom-body-host\n [config]=\"asAny(config)\"\n [modalRef]=\"asAny(modalRef)\"\n class=\"mb-6 block\"\n ></mn-custom-body-host>\n}\n\n<form (ngSubmit)=\"submit()\" [formGroup]=\"form\" class=\"flex flex-col gap-6 h-full\">\n <!-- Shared field rendering template (must be inside form for formControlName) -->\n <ng-template #fieldTemplate let-rowField>\n @switch (rowField.field.kind) {\n @case (FieldKind.TEXT) {\n <div>\n <mn-lib-input-field\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n type: 'text',\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n mask: asField(rowField.field).mask,\n autocomplete: asField(rowField.field).autocomplete,\n readonly: isFieldReadOnly(rowField.field),\n fullWidth: true\n })\"\n ></mn-lib-input-field>\n </div>\n }\n\n @case (FieldKind.NUMBER) {\n <div>\n <mn-lib-input-field\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n type: 'number',\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n readonly: isFieldReadOnly(rowField.field),\n fullWidth: true\n })\"\n ></mn-lib-input-field>\n </div>\n }\n\n @case (FieldKind.PASSWORD) {\n <div>\n <mn-lib-input-field\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n type: 'password',\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n readonly: isFieldReadOnly(rowField.field),\n fullWidth: true\n })\"\n ></mn-lib-input-field>\n </div>\n }\n\n @case (FieldKind.SELECT) {\n <div class=\"flex flex-col\">\n <mn-lib-select\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"getSelectProps(rowField.field)\"\n ></mn-lib-select>\n @if (isFieldLoading(asKey(rowField.field.key))) {\n <div class=\"flex items-center gap-1 pl-2 pt-1\">\n <div class=\"w-4 h-4 border-2 border-base-300 border-t-blue-500 rounded-full animate-spin\"></div>\n </div>\n }\n @if (getFieldError(asKey(rowField.field.key))) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ getFieldError(asKey(rowField.field.key)) }}\n </div>\n }\n </div>\n }\n\n @case (FieldKind.CHECKBOX) {\n <div>\n <mn-lib-checkbox\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n label: asField(rowField.field).label,\n disabled: isFieldDisabled(rowField.field) || isFieldReadOnly(rowField.field)\n })\"\n ></mn-lib-checkbox>\n </div>\n }\n\n @case (FieldKind.DATE) {\n <div>\n <mn-lib-input-field\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n type: 'date',\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n startDate: asField(rowField.field).minDate,\n endDate: asField(rowField.field).maxDate,\n readonly: isFieldReadOnly(rowField.field),\n fullWidth: true\n })\"\n ></mn-lib-input-field>\n </div>\n }\n\n @case (FieldKind.DATETIME) {\n <div>\n <mn-lib-datetime\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n mode: asField(rowField.field).mode || 'datetime-local',\n min: asField(rowField.field).min,\n max: asField(rowField.field).max,\n step: asField(rowField.field).step,\n readonly: isFieldReadOnly(rowField.field),\n fullWidth: true\n })\"\n ></mn-lib-datetime>\n </div>\n }\n\n @case (FieldKind.TEXTAREA) {\n <div>\n <mn-lib-textarea\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n label: asField(rowField.field).label,\n placeholder: asField(rowField.field).placeholder,\n rows: asField(rowField.field).rows || 4,\n resize: 'vertical',\n autocomplete: asField(rowField.field).autocomplete,\n readonly: isFieldReadOnly(rowField.field)\n })\"\n ></mn-lib-textarea>\n </div>\n }\n\n @case (FieldKind.MULTI_SELECT) {\n <div>\n @if (isFieldLoading(asKey(rowField.field.key))) {\n <div class=\"flex items-center gap-2 py-2 text-sm text-base-content/50\">\n <div class=\"w-4 h-4 border-2 border-base-300 border-t-blue-500 rounded-full animate-spin\"></div>\n {{ labels.loadingOptions }}\n </div>\n }\n @if (!isFieldLoading(asKey(rowField.field.key))) {\n <mn-lib-multi-select\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n label: asField(rowField.field).label,\n options: getFieldOptions(rowField.field),\n placeholder: asField(rowField.field).placeholder,\n searchable: asField(rowField.field).searchable,\n searchPlaceholder: asField(rowField.field).searchPlaceholder,\n maxSelections: asField(rowField.field).maxSelections,\n collapseThreshold: asField(rowField.field).collapseThreshold,\n collapsePlaceholder: asField(rowField.field).collapsePlaceholder,\n allSelectedPlaceholder: asField(rowField.field).allSelectedPlaceholder,\n disabled: isFieldDisabled(rowField.field) || isFieldReadOnly(rowField.field)\n })\"\n ></mn-lib-multi-select>\n }\n @if (getFieldError(asKey(rowField.field.key))) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ getFieldError(asKey(rowField.field.key)) }}\n </div>\n }\n </div>\n }\n\n @case (FieldKind.MULTI_SELECT_TABLE) {\n <ng-container [ngTemplateOutlet]=\"selectTableTemplate\" [ngTemplateOutletContext]=\"{ $implicit: rowField }\"></ng-container>\n }\n\n @case (FieldKind.SINGLE_SELECT_TABLE) {\n <ng-container [ngTemplateOutlet]=\"selectTableTemplate\" [ngTemplateOutletContext]=\"{ $implicit: rowField }\"></ng-container>\n }\n\n @case (FieldKind.COLOR) {\n <div class=\"flex flex-col gap-1\">\n <label [for]=\"'field-' + asKey(rowField.field.key)\"\n class=\"pl-2 pb-1 flex flex-row gap-0.5 text-base font-medium text-base-content\">\n {{ asField(rowField.field).label }}\n @if (hasRequiredValidator(rowField.field)) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n <div class=\"flex items-center gap-3\">\n <input\n type=\"color\"\n [id]=\"'field-' + asKey(rowField.field.key)\"\n class=\"w-10 h-10 rounded-lg border border-base-300 cursor-pointer p-0.5\"\n [value]=\"getColorValue(rowField.field)\"\n [disabled]=\"isFieldReadOnly(rowField.field) || isFieldDisabled(rowField.field)\"\n (input)=\"onColorChange(rowField.field, $event)\"\n />\n <span class=\"text-sm text-base-content/60 font-mono\">{{ getColorValue(rowField.field) }}</span>\n </div>\n @if (asField(rowField.field).swatches) {\n <div class=\"flex gap-1.5 mt-1\">\n @for (swatch of asField(rowField.field).swatches; track swatch) {\n <button\n mnButton\n [data]=\"{ size: 'sm', variant: 'text', color: 'secondary' }\"\n type=\"button\"\n class=\"w-6 h-6 rounded-md border border-base-300 cursor-pointer transition-transform hover:scale-110\"\n [style.background-color]=\"swatch\"\n [class.ring-2]=\"getColorValue(rowField.field) === swatch\"\n [class.ring-blue-500]=\"getColorValue(rowField.field) === swatch\"\n (click)=\"setColorFromSwatch(rowField.field, swatch)\"\n [attr.aria-label]=\"'Select color ' + swatch\"\n ></button>\n }\n </div>\n }\n @if (form.get(asKey(rowField.field.key))?.invalid && form.get(asKey(rowField.field.key))?.touched) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ labels.fieldRequired }}\n </div>\n }\n </div>\n }\n\n @case (FieldKind.RATING) {\n <div class=\"flex flex-col gap-1\">\n <span [id]=\"'rating-label-' + asKey(rowField.field.key)\"\n class=\"pl-2 pb-1 flex flex-row gap-0.5 text-base font-medium text-base-content\">\n {{ asField(rowField.field).label }}\n @if (hasRequiredValidator(rowField.field)) {\n <span class=\"text-red-500\">*</span>\n }\n </span>\n <div [attr.aria-labelledby]=\"'rating-label-' + asKey(rowField.field.key)\" class=\"flex items-center gap-1\"\n role=\"group\">\n @for (star of getRatingRange(rowField.field); track star) {\n <button\n mnButton\n [data]=\"{ size: 'sm', variant: 'text', color: 'secondary' }\"\n type=\"button\"\n class=\"text-2xl cursor-pointer transition-colors focus:outline-none\"\n [class.text-yellow-400]=\"star <= getRatingValue(rowField.field)\"\n [class.text-base-300]=\"star > getRatingValue(rowField.field)\"\n [disabled]=\"isFieldReadOnly(rowField.field) || isFieldDisabled(rowField.field)\"\n (click)=\"setRating(rowField.field, star)\"\n >\n &#9733;\n </button>\n }\n <span class=\"text-sm text-base-content/50 ml-2\">{{ getRatingValue(rowField.field) }} / {{ asField(rowField.field).max || 5 }}</span>\n </div>\n @if (form.get(asKey(rowField.field.key))?.invalid && form.get(asKey(rowField.field.key))?.touched) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ labels.fieldRequired }}\n </div>\n }\n </div>\n }\n\n @case (FieldKind.SLIDER) {\n <div class=\"flex flex-col gap-1\">\n <label [for]=\"'field-' + asKey(rowField.field.key)\"\n class=\"pl-2 pb-1 flex flex-row gap-0.5 text-base font-medium text-base-content\">\n {{ asField(rowField.field).label }}\n @if (hasRequiredValidator(rowField.field)) {\n <span class=\"text-red-500\">*</span>\n }\n </label>\n <div class=\"flex items-center gap-3\">\n <input\n type=\"range\"\n [id]=\"'field-' + asKey(rowField.field.key)\"\n class=\"flex-1 h-2 bg-base-200 rounded-lg appearance-none cursor-pointer accent-blue-500\"\n [attr.min]=\"asField(rowField.field).min ?? 0\"\n [attr.max]=\"asField(rowField.field).max ?? 100\"\n [attr.step]=\"asField(rowField.field).step ?? 1\"\n [value]=\"getSliderValue(rowField.field)\"\n [disabled]=\"isFieldReadOnly(rowField.field) || isFieldDisabled(rowField.field)\"\n (input)=\"onSliderChange(rowField.field, $event)\"\n />\n @if (asField(rowField.field).showValue !== false) {\n <span class=\"text-sm text-base-content/60 min-w-[3rem] text-right\">\n {{ getSliderValue(rowField.field) }}{{ asField(rowField.field).unit || '' }}\n </span>\n }\n </div>\n <div class=\"flex justify-between text-xs text-base-content/40 px-1\">\n <span>{{ asField(rowField.field).min ?? 0 }}</span>\n <span>{{ asField(rowField.field).max ?? 100 }}</span>\n </div>\n @if (form.get(asKey(rowField.field.key))?.invalid && form.get(asKey(rowField.field.key))?.touched) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ labels.fieldRequired }}\n </div>\n }\n </div>\n }\n\n @case (FieldKind.FILE) {\n <div>\n <mn-lib-file-input\n (cleared)=\"onFileCleared(rowField.field)\"\n [formControlName]=\"asKey(rowField.field.key)\"\n [props]=\"asAny({\n id: asKey(rowField.field.key),\n label: asField(rowField.field).label,\n accept: asField(rowField.field).accept,\n multiple: asField(rowField.field).multiple,\n maxFiles: asField(rowField.field).maxFiles,\n maxSize: asField(rowField.field).maxSize,\n displayMode: asField(rowField.field).displayMode,\n dropzoneHint: asField(rowField.field).dropzoneHint,\n dropActiveHint: asField(rowField.field).dropActiveHint,\n replaceLabel: asField(rowField.field).replaceLabel,\n removeLabel: asField(rowField.field).removeLabel,\n currentUrl: asField(rowField.field).currentUrl,\n currentUrls: asField(rowField.field).currentUrls,\n disabled: isFieldReadOnly(rowField.field) || isFieldDisabled(rowField.field)\n })\"\n ></mn-lib-file-input>\n </div>\n }\n\n @case (FieldKind.CUSTOM) {\n <div>\n <ng-container\n mnCustomFieldHost\n [component]=\"asField(rowField.field).component\"\n [inputs]=\"asField(rowField.field).inputs\"\n [formControlName]=\"asKey(rowField.field.key)\"\n ></ng-container>\n </div>\n }\n\n @default {\n <div></div>\n }\n }\n\n <!-- Show cross-field error below any field that has one -->\n @if (getFieldError(asKey(rowField.field.key)) && rowField.field.kind !== FieldKind.SELECT && rowField.field.kind !== FieldKind.MULTI_SELECT) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ getFieldError(asKey(rowField.field.key)) }}\n </div>\n }\n </ng-template>\n\n <!-- Shared template for MULTI_SELECT_TABLE and SINGLE_SELECT_TABLE -->\n <ng-template #selectTableTemplate let-rowField>\n <div class=\"flex flex-col gap-1\">\n @if (asField(rowField.field).label) {\n <span class=\"pl-2 pb-1 flex flex-row gap-0.5 text-base font-medium text-base-content\">\n {{ asField(rowField.field).label }}\n @if (hasRequiredValidator(rowField.field)) {\n <span class=\"text-red-500\">*</span>\n }\n </span>\n }\n <mn-table\n [dataSource]=\"tableDataSources[asKey(rowField.field.key)]\"\n [attr.aria-label]=\"asField(rowField.field).label || null\"\n (selectionChange)=\"onTableSelectionChange(rowField.field, $event)\"\n ></mn-table>\n @if (form.get(asKey(rowField.field.key))?.invalid && form.get(asKey(rowField.field.key))?.touched) {\n <div class=\"text-red-500 text-xs pl-2 pt-1\">\n {{ labels.fieldRequired }}\n </div>\n }\n </div>\n </ng-template>\n\n <!-- Field Groups (sections with headers) -->\n @if (fieldGroups.length > 0) {\n <div class=\"flex flex-col gap-6\">\n @for (group of fieldGroups; track group.title) {\n <div class=\"flex flex-col gap-4\" [style.display]=\"isGroupVisible(group) ? '' : 'none'\">\n <div class=\"border-b border-base-300 pb-2\">\n <h3 class=\"text-base font-semibold text-base-content\">{{ group.title }}</h3>\n @if (group.description) {\n <p class=\"text-sm text-base-content/50 mt-0.5\">{{ group.description }}</p>\n }\n </div>\n @for (row of group.rows; track $index) {\n <div [style.--mn-form-cols]=\"row.columns || 1\" class=\"grid gap-4 mn-form-row\">\n @for (rowField of row.fields; track rowField.field.key) {\n <div [style.--mn-form-span]=\"rowField.span || 1\" [style.display]=\"isFieldVisible(rowField.field) ? '' : 'none'\"\n class=\"flex flex-col gap-2 mn-form-cell\">\n <ng-container [ngTemplateOutlet]=\"fieldTemplate\" [ngTemplateOutletContext]=\"{ $implicit: rowField }\"></ng-container>\n </div>\n }\n </div>\n }\n </div>\n }\n </div>\n }\n\n <!-- Standard rows (no groups) -->\n @if (rows.length > 0) {\n <div class=\"flex flex-col gap-4\">\n @for (row of rows; track $index) {\n <div [style.--mn-form-cols]=\"row.columns || 1\" class=\"grid gap-4 mn-form-row\">\n @for (rowField of row.fields; track rowField.field.key) {\n <div [style.--mn-form-span]=\"rowField.span || 1\" [style.display]=\"isFieldVisible(rowField.field) ? '' : 'none'\"\n class=\"flex flex-col gap-2 mn-form-cell\">\n <ng-container [ngTemplateOutlet]=\"fieldTemplate\" [ngTemplateOutletContext]=\"{ $implicit: rowField }\"></ng-container>\n </div>\n }\n </div>\n }\n </div>\n }\n\n <!-- Form-level errors (not tied to a specific field) -->\n @if (formErrors['_form']) {\n <div class=\"text-red-500 text-sm px-2 py-1 bg-red-50 rounded-md\">\n {{ formErrors['_form'] }}\n </div>\n }\n\n @if (!hideFooter) {\n <div class=\"flex gap-3 pt-4 pb-6 border-t border-base-300 mt-auto sticky bottom-0 bg-base-100 z-10\">\n <button\n mnButton\n type=\"button\"\n [data]=\"{ variant: 'outline', color: 'secondary' }\"\n (mousedown)=\"modalRef.dismiss(ModalCloseReason.CANCELLED)\"\n >\n @if (cancelIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ labels.cancel }}\n </button>\n\n <div class=\"flex-1\"></div>\n\n <button\n mnButton\n type=\"submit\"\n [data]=\"{ variant: 'fill', color: 'primary', disabled: form.invalid || isSubmitting }\"\n [disabled]=\"form.invalid || isSubmitting\"\n >\n @if (submitIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ isSubmitting ? labels.submitting : labels.submit }}\n </button>\n </div>\n }\n</form>\n", styles: [".select-arrow{background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E\");background-repeat:no-repeat;background-position:right .75rem center}.mn-form-row{grid-template-columns:repeat(var(--mn-form-cols, 1),minmax(0,1fr))}.mn-form-cell{grid-column:span var(--mn-form-span, 1)}@media(max-width:639.98px){.mn-form-row{grid-template-columns:1fr}.mn-form-cell{grid-column:auto}}\n"] }]
828
+ }], propDecorators: { config: [{
829
+ type: Input
830
+ }], modalRef: [{
831
+ type: Input
832
+ }], hideFooter: [{
833
+ type: Input
834
+ }], hideCustomBody: [{
835
+ type: Input
836
+ }], formStatusChange: [{
837
+ type: Output
838
+ }], inputFields: [{
839
+ type: ViewChildren,
840
+ args: [MnInputField]
841
+ }], textareas: [{
842
+ type: ViewChildren,
843
+ args: [MnTextarea]
844
+ }] } });
845
+
846
+ class MnFooterActionsComponent {
847
+ actions = [];
848
+ /** Whether to render leading icons on the action buttons (defaults to true). */
849
+ showIcons = true;
850
+ actionClick = new EventEmitter();
851
+ /** Icon size (px) for the footer action buttons. */
852
+ actionIconSize = MODAL_ACTION_ICON_SIZE;
853
+ /**
854
+ * Resolves the leading icon for a footer action, or null when icons are disabled.
855
+ * Uses the per-action override, else the default derived from its style.
856
+ * @param action The footer action to resolve an icon for.
857
+ */
858
+ iconFor(action) {
859
+ if (!this.showIcons)
860
+ return null;
861
+ return action.icon ?? defaultIconForStyle(action.style);
862
+ }
863
+ get leftActions() {
864
+ return this.actions.filter(a => a.position === 'left');
865
+ }
866
+ get rightActions() {
867
+ return this.actions.filter(a => a.position !== 'left');
868
+ }
869
+ getButtonData(action) {
870
+ switch (action.style) {
871
+ case ActionStyle.PRIMARY:
872
+ return { variant: 'fill', color: 'primary', disabled: action.disabled };
873
+ case ActionStyle.DANGER:
874
+ return { variant: 'fill', color: 'danger', disabled: action.disabled };
875
+ case ActionStyle.GHOST:
876
+ return { variant: 'text', color: 'gray', disabled: action.disabled };
877
+ case ActionStyle.SECONDARY:
878
+ default:
879
+ return { variant: 'outline', color: 'secondary', disabled: action.disabled };
880
+ }
881
+ }
882
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnFooterActionsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
883
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: MnFooterActionsComponent, isStandalone: true, selector: "mn-footer-actions", inputs: { actions: "actions", showIcons: "showIcons" }, outputs: { actionClick: "actionClick" }, host: { classAttribute: "contents" }, ngImport: i0, template: `
884
+ @for (action of leftActions; track action.label) {
885
+ <button
886
+ mnButton
887
+ [data]="getButtonData(action)"
888
+ [disabled]="action.disabled || false"
889
+ (click)="actionClick.emit(action)"
890
+ >
891
+ @if (iconFor(action); as icon) {
892
+ <svg [lucideIcon]="icon" [size]="actionIconSize" class="mr-2"></svg>
893
+ }
894
+ {{ action.label }}
895
+ </button>
896
+ }
897
+
898
+ <div class="flex-1"></div>
899
+
900
+ @for (action of rightActions; track action.label) {
901
+ <button
902
+ mnButton
903
+ [data]="getButtonData(action)"
904
+ [disabled]="action.disabled || false"
905
+ (click)="actionClick.emit(action)"
906
+ >
907
+ @if (iconFor(action); as icon) {
908
+ <svg [lucideIcon]="icon" [size]="actionIconSize" class="mr-2"></svg>
909
+ }
910
+ {{ action.label }}
911
+ </button>
912
+ }
913
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: MnButton, selector: "button[mnButton], a[mnButton]", inputs: ["data"] }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }] });
914
+ }
915
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnFooterActionsComponent, decorators: [{
916
+ type: Component,
917
+ args: [{
918
+ selector: 'mn-footer-actions',
919
+ standalone: true,
920
+ imports: [CommonModule, MnButton, LucideDynamicIcon],
921
+ host: { class: 'contents' },
922
+ template: `
923
+ @for (action of leftActions; track action.label) {
924
+ <button
925
+ mnButton
926
+ [data]="getButtonData(action)"
927
+ [disabled]="action.disabled || false"
928
+ (click)="actionClick.emit(action)"
929
+ >
930
+ @if (iconFor(action); as icon) {
931
+ <svg [lucideIcon]="icon" [size]="actionIconSize" class="mr-2"></svg>
932
+ }
933
+ {{ action.label }}
934
+ </button>
935
+ }
936
+
937
+ <div class="flex-1"></div>
938
+
939
+ @for (action of rightActions; track action.label) {
940
+ <button
941
+ mnButton
942
+ [data]="getButtonData(action)"
943
+ [disabled]="action.disabled || false"
944
+ (click)="actionClick.emit(action)"
945
+ >
946
+ @if (iconFor(action); as icon) {
947
+ <svg [lucideIcon]="icon" [size]="actionIconSize" class="mr-2"></svg>
948
+ }
949
+ {{ action.label }}
950
+ </button>
951
+ }
952
+ `,
953
+ }]
954
+ }], propDecorators: { actions: [{
955
+ type: Input
956
+ }], showIcons: [{
957
+ type: Input
958
+ }], actionClick: [{
959
+ type: Output
960
+ }] } });
961
+
962
+ class MnWizardBodyComponent {
963
+ cdr = inject(ChangeDetectorRef);
964
+ config;
965
+ modalRef;
966
+ formBodies;
967
+ stepWrappers;
968
+ /**
969
+ * The step body's scroll container. Every step renders into this one element
970
+ * (inactive steps are hidden, not destroyed), so its scroll offset is shared —
971
+ * without an explicit reset, arriving on a new step lands you wherever the
972
+ * previous step was scrolled to. See {@link setCurrentStep}.
973
+ */
974
+ stepScroller;
975
+ currentStepId;
976
+ /**
977
+ * Title of the currently active step, mirrored into a signal so the modal
978
+ * shell can append it to the modal title on small screens (where the step
979
+ * labels under the progress circles are hidden). A signal — not a getter —
980
+ * because the shell lives outside this component's change-detection subtree,
981
+ * so a plain field mutation here would not update the shell in a zoneless app.
982
+ */
983
+ currentStepTitle = signal(undefined, ...(ngDevMode ? [{ debugName: "currentStepTitle" }] : []));
984
+ visitedStepIds = [];
985
+ isCurrentStepValid = true;
986
+ isCompleting = false;
987
+ wizardErrors = {};
988
+ /**
989
+ * Min-height (px) for the step container, sized to the tallest step so the
990
+ * modal does not jump when navigating between steps. Monotonic — only grows.
991
+ */
992
+ measuredMinHeight = 0;
993
+ languageService = inject(MnLanguageService);
994
+ static DEFAULT_LABELS = {
995
+ next: 'Next',
996
+ back: 'Back',
997
+ close: 'Close',
998
+ complete: 'Complete',
999
+ completing: 'Completing...',
1000
+ };
1001
+ resolveLabel(i18nValue, key) {
1002
+ if (i18nValue)
1003
+ return i18nValue;
1004
+ const translated = this.languageService.translate(`common.${key}`);
1005
+ return translated === `common.${key}` ? MnWizardBodyComponent.DEFAULT_LABELS[key] : translated;
1006
+ }
1007
+ /** Resolved i18n labels with defaults, falling back to translated keys */
1008
+ get labels() {
1009
+ const i18n = this.config.i18n || {};
1010
+ return {
1011
+ next: this.resolveLabel(i18n['next'], 'next'),
1012
+ back: this.resolveLabel(i18n['back'], 'back'),
1013
+ close: this.resolveLabel(i18n['close'], 'close'),
1014
+ complete: this.resolveLabel(i18n['complete'], 'complete'),
1015
+ completing: this.resolveLabel(i18n['completing'], 'completing'),
1016
+ };
1017
+ }
1018
+ /** Pre-built form configs keyed by step id — only for steps that have fields */
1019
+ stepFormConfigs = {};
1020
+ /**
1021
+ * Pre-built host configs keyed by step id — only for steps whose body is a
1022
+ * component or template (not a plain string) and that have no form fields.
1023
+ * Drives the `mn-custom-body-host` rendered for those steps.
1024
+ */
1025
+ stepBodyConfigs = {};
1026
+ statusSubscription;
1027
+ formBodiesSubscription;
1028
+ ngOnInit() {
1029
+ // Pre-build form configs for all form-driven steps
1030
+ for (const step of this.config.steps) {
1031
+ if (step.fields && step.fields.length > 0) {
1032
+ // Merge top-level initialValue with step-level initialValue
1033
+ const mergedInitialValue = {
1034
+ ...(this.config.initialValue || {}),
1035
+ ...(step.initialValue || {})
1036
+ };
1037
+ this.stepFormConfigs[step.id] = {
1038
+ kind: ModalKind.FORM,
1039
+ fields: step.fields,
1040
+ rows: step.rows,
1041
+ fieldGroups: step.fieldGroups,
1042
+ formValidators: step.formValidators,
1043
+ groupValidators: step.groupValidators,
1044
+ initialValue: mergedInitialValue,
1045
+ readOnly: this.config.readOnly,
1046
+ disabled: this.config.disabled
1047
+ };
1048
+ }
1049
+ else {
1050
+ // A component/template body (not a plain string) renders through the
1051
+ // custom-body host. Pre-build its config once so the `@Input` identity
1052
+ // stays stable across change detection and the body is not re-created.
1053
+ const bodyConfig = this.buildStepBodyConfig(step);
1054
+ if (bodyConfig) {
1055
+ this.stepBodyConfigs[step.id] = bodyConfig;
1056
+ }
1057
+ }
1058
+ }
1059
+ this.setCurrentStep(this.config.startStepId || this.config.steps[0]?.id);
1060
+ if (this.currentStepId) {
1061
+ this.visitedStepIds.push(this.currentStepId);
1062
+ }
1063
+ }
1064
+ ngAfterViewInit() {
1065
+ // Subscribe to form bodies list changes to track validity
1066
+ this.formBodiesSubscription = this.formBodies.changes.subscribe(() => {
1067
+ this.trackCurrentStepValidity();
1068
+ // Apply autofocus when form bodies change (e.g. step navigation)
1069
+ setTimeout(() => {
1070
+ this.getCurrentFormBody()?.applyAutoFocus();
1071
+ }, 100);
1072
+ // Re-measure in case dynamic field visibility changed a step's height
1073
+ this.measureTallestStep();
1074
+ });
1075
+ // Initial validity check
1076
+ this.trackCurrentStepValidity();
1077
+ // Pre-size the modal to the tallest step so it does not jump between steps.
1078
+ // All steps are already rendered (display:none), so this is a pure layout
1079
+ // read — it creates no components and triggers no data loads or autofocus.
1080
+ setTimeout(() => this.measureTallestStep(), 0);
1081
+ // A second pass catches content that grows after async data sources resolve.
1082
+ setTimeout(() => this.measureTallestStep(), 300);
1083
+ }
1084
+ isTextBody(step) {
1085
+ return typeof step.body === 'string';
1086
+ }
1087
+ /**
1088
+ * Builds the {@link CustomModalConfig} used to render a step whose body is a
1089
+ * component or template. Returns `undefined` for steps with no body or a
1090
+ * plain-string body (those render through their own template branches).
1091
+ * @param step The wizard step to inspect.
1092
+ */
1093
+ buildStepBodyConfig(step) {
1094
+ const body = step.body;
1095
+ if (!body || typeof body === 'string')
1096
+ return undefined;
1097
+ const config = { kind: ModalKind.CUSTOM, inputs: step.bodyInputs };
1098
+ if (body instanceof TemplateRef) {
1099
+ config.template = body;
1100
+ }
1101
+ else {
1102
+ config.component = body;
1103
+ }
1104
+ return config;
1105
+ }
1106
+ async goToStep(step) {
1107
+ if (!this.canNavigateToStep(step))
1108
+ return;
1109
+ if (step.id === this.currentStepId)
1110
+ return;
1111
+ // Validate current step's form before allowing direct step navigation
1112
+ const formBody = this.getCurrentFormBody();
1113
+ if (formBody && formBody.form.invalid) {
1114
+ formBody.form.markAllAsTouched();
1115
+ return;
1116
+ }
1117
+ const previousStepId = this.currentStepId;
1118
+ this.setCurrentStep(step.id);
1119
+ if (!this.visitedStepIds.includes(this.currentStepId)) {
1120
+ this.visitedStepIds.push(this.currentStepId);
1121
+ }
1122
+ await this.notifyStepChange(previousStepId, NavigationDirection.DIRECT);
1123
+ this.trackCurrentStepValidity();
1124
+ }
1125
+ ngOnDestroy() {
1126
+ this.statusSubscription?.unsubscribe();
1127
+ this.formBodiesSubscription?.unsubscribe();
1128
+ }
1129
+ /**
1130
+ * Measures every step's natural height and records the tallest as
1131
+ * {@link measuredMinHeight}. Monotonic: the value only ever grows, so a
1132
+ * re-measure can never shrink the modal. Skipped when the modal has an
1133
+ * explicit height or is full-size (those are already fixed-height).
1134
+ */
1135
+ measureTallestStep() {
1136
+ if (this.config.sizeHeight || this.config.sizeWidth === ModalSize.FULL)
1137
+ return;
1138
+ const wrappers = this.stepWrappers?.toArray().map(ref => ref.nativeElement) ?? [];
1139
+ if (wrappers.length === 0)
1140
+ return;
1141
+ // Synchronous pre-paint pass: show one step at a time, read its height,
1142
+ // then restore the original display values (so there is no visible flicker).
1143
+ const originalDisplay = wrappers.map(el => el.style.display);
1144
+ let tallest = 0;
1145
+ for (let i = 0; i < wrappers.length; i++) {
1146
+ for (let j = 0; j < wrappers.length; j++) {
1147
+ wrappers[j].style.display = i === j ? 'block' : 'none';
1148
+ }
1149
+ tallest = Math.max(tallest, wrappers[i].offsetHeight);
1150
+ }
1151
+ wrappers.forEach((el, i) => (el.style.display = originalDisplay[i]));
1152
+ if (tallest > this.measuredMinHeight) {
1153
+ this.measuredMinHeight = tallest;
1154
+ this.cdr.detectChanges();
1155
+ }
1156
+ }
1157
+ /** Get visible steps (filtered by visibility condition) */
1158
+ get visibleSteps() {
1159
+ return this.config.steps.filter(s => this.isStepVisible(s));
1160
+ }
1161
+ isStepVisible(step) {
1162
+ if (!step.visible)
1163
+ return true;
1164
+ return step.visible(this.getAggregatedData());
1165
+ }
1166
+ get currentStep() {
1167
+ return this.config.steps.find(s => s.id === this.currentStepId);
1168
+ }
1169
+ get currentVisibleIndex() {
1170
+ return this.visibleSteps.findIndex(s => s.id === this.currentStepId);
1171
+ }
1172
+ get currentStepIndex() {
1173
+ return this.config.steps.findIndex(s => s.id === this.currentStepId);
1174
+ }
1175
+ get canGoBack() {
1176
+ return this.currentVisibleIndex > 0;
1177
+ }
1178
+ get canGoNext() {
1179
+ return this.currentVisibleIndex < this.visibleSteps.length - 1;
1180
+ }
1181
+ get isLastStep() {
1182
+ return this.currentVisibleIndex === this.visibleSteps.length - 1;
1183
+ }
1184
+ /** Icon size (px) for the wizard action buttons. */
1185
+ actionIconSize = MODAL_ACTION_ICON_SIZE;
1186
+ /** Whether action-button icons should render on this wizard (defaults to true). */
1187
+ get showActionIcons() {
1188
+ return this.config.showActionIcons !== false;
1189
+ }
1190
+ /**
1191
+ * The leading icon for the back button, or null when icons are disabled.
1192
+ * Shows a back arrow when navigation is possible, otherwise a cross (the
1193
+ * button acts as "Close" on the first step).
1194
+ */
1195
+ get backIcon() {
1196
+ if (!this.showActionIcons)
1197
+ return null;
1198
+ return this.canGoBack ? MN_MODAL_ACTION_ICONS.back : MN_MODAL_ACTION_ICONS.cancel;
1199
+ }
1200
+ /** The trailing icon for the next button, or null when icons are disabled. */
1201
+ get nextIcon() {
1202
+ return this.showActionIcons ? MN_MODAL_ACTION_ICONS.next : null;
1203
+ }
1204
+ /** The leading icon for the complete button, or null when icons are disabled. */
1205
+ get completeIcon() {
1206
+ return this.showActionIcons ? MN_MODAL_ACTION_ICONS.confirm : null;
1207
+ }
1208
+ /** Index of the current step for the progress line */
1209
+ get currentProgressIndex() {
1210
+ return this.currentVisibleIndex;
1211
+ }
1212
+ get isFreeFlow() {
1213
+ return this.config.flow === WizardFlowMode.FREE;
1214
+ }
1215
+ canNavigateToStep(step) {
1216
+ if (!this.isFreeFlow)
1217
+ return false;
1218
+ return this.isStepVisible(step);
1219
+ }
1220
+ async next() {
1221
+ if (!this.canGoNext)
1222
+ return;
1223
+ const currentStep = this.currentStep;
1224
+ // Validate embedded form if present
1225
+ const formBody = this.getCurrentFormBody();
1226
+ if (formBody && formBody.form.invalid) {
1227
+ formBody.form.markAllAsTouched();
1228
+ return;
1229
+ }
1230
+ if (currentStep?.guard?.canExit) {
1231
+ const canExit = await currentStep.guard.canExit();
1232
+ if (!canExit)
1233
+ return;
1234
+ }
1235
+ if (currentStep?.validators) {
1236
+ for (const validator of currentStep.validators) {
1237
+ const result = await validator.validate();
1238
+ if (result.status === 'invalid')
1239
+ return;
1240
+ }
1241
+ }
1242
+ // Find next visible step
1243
+ const nextStep = this.visibleSteps[this.currentVisibleIndex + 1];
1244
+ if (!nextStep)
1245
+ return;
1246
+ if (nextStep.guard?.canEnter) {
1247
+ const canEnter = await nextStep.guard.canEnter();
1248
+ if (!canEnter)
1249
+ return;
1250
+ }
1251
+ const previousStepId = this.currentStepId;
1252
+ this.setCurrentStep(nextStep.id);
1253
+ if (!this.visitedStepIds.includes(this.currentStepId)) {
1254
+ this.visitedStepIds.push(this.currentStepId);
1255
+ }
1256
+ await this.notifyStepChange(previousStepId, NavigationDirection.FORWARD);
1257
+ this.trackCurrentStepValidity();
1258
+ }
1259
+ /** Find the MnFormBodyComponent for the current step */
1260
+ getCurrentFormBody() {
1261
+ if (!this.formBodies)
1262
+ return undefined;
1263
+ // formBodies only contains entries for steps that have stepFormConfigs
1264
+ // We need to find which form body index corresponds to the current step
1265
+ const formStepIds = this.config.steps
1266
+ .filter(s => this.stepFormConfigs[s.id])
1267
+ .map(s => s.id);
1268
+ const formIndex = formStepIds.indexOf(this.currentStepId);
1269
+ if (formIndex === -1)
1270
+ return undefined;
1271
+ return this.formBodies.toArray()[formIndex];
1272
+ }
1273
+ trackCurrentStepValidity() {
1274
+ // Unsubscribe from previous
1275
+ this.statusSubscription?.unsubscribe();
1276
+ this.statusSubscription = undefined;
1277
+ const formBody = this.getCurrentFormBody();
1278
+ if (formBody && formBody.form) {
1279
+ this.isCurrentStepValid = formBody.form.valid;
1280
+ this.statusSubscription = formBody.form.statusChanges.subscribe(() => {
1281
+ this.isCurrentStepValid = formBody.form.valid;
1282
+ this.cdr.detectChanges();
1283
+ });
1284
+ }
1285
+ else {
1286
+ this.isCurrentStepValid = true;
1287
+ }
1288
+ this.cdr.detectChanges();
1289
+ }
1290
+ async back() {
1291
+ if (!this.canGoBack) {
1292
+ // Call onCancel handler if configured
1293
+ if (this.config.onCancel) {
1294
+ await this.config.onCancel(ModalCloseReason.CANCELLED);
1295
+ }
1296
+ this.modalRef.dismiss(ModalCloseReason.CANCELLED);
1297
+ return;
1298
+ }
1299
+ const prevStep = this.visibleSteps[this.currentVisibleIndex - 1];
1300
+ const previousStepId = this.currentStepId;
1301
+ // Remove current step from visited so the circle resets
1302
+ this.visitedStepIds = this.visitedStepIds.filter(id => id !== this.currentStepId);
1303
+ this.setCurrentStep(prevStep.id);
1304
+ await this.notifyStepChange(previousStepId, NavigationDirection.BACKWARD);
1305
+ this.trackCurrentStepValidity();
1306
+ }
1307
+ /**
1308
+ * Activates a step and mirrors its title into {@link currentStepTitle} so the
1309
+ * shell can reflect the step name in the modal title on small screens.
1310
+ * @param stepId Id of the step to make current.
1311
+ */
1312
+ setCurrentStep(stepId) {
1313
+ this.currentStepId = stepId;
1314
+ this.currentStepTitle.set(this.config.steps.find(s => s.id === stepId)?.title);
1315
+ // A new step always starts at its top — the shared scroller would otherwise
1316
+ // keep the previous step's offset. Instant, not smooth: a scroll animation
1317
+ // during a step swap reads as a glitch. Absent before the view is created.
1318
+ if (this.stepScroller) {
1319
+ this.stepScroller.nativeElement.scrollTop = 0;
1320
+ }
1321
+ }
1322
+ async complete() {
1323
+ if (this.isCompleting)
1324
+ return;
1325
+ const currentStep = this.currentStep;
1326
+ // Validate embedded form if present
1327
+ const formBody = this.getCurrentFormBody();
1328
+ if (formBody && formBody.form.invalid) {
1329
+ formBody.form.markAllAsTouched();
1330
+ return;
1331
+ }
1332
+ if (currentStep?.validators) {
1333
+ for (const validator of currentStep.validators) {
1334
+ const result = await validator.validate();
1335
+ if (result.status === 'invalid')
1336
+ return;
1337
+ }
1338
+ }
1339
+ this.isCompleting = true;
1340
+ this.wizardErrors = {};
1341
+ this.cdr.detectChanges();
1342
+ try {
1343
+ const aggregatedData = this.getAggregatedData();
1344
+ // Run cross-step validators (onBeforeComplete)
1345
+ if (this.config.onBeforeComplete) {
1346
+ for (const validator of this.config.onBeforeComplete) {
1347
+ const errors = await validator(aggregatedData);
1348
+ if (errors) {
1349
+ this.wizardErrors = { ...this.wizardErrors, ...errors };
1350
+ }
1351
+ }
1352
+ if (Object.keys(this.wizardErrors).length > 0) {
1353
+ this.isCompleting = false;
1354
+ this.cdr.detectChanges();
1355
+ return;
1356
+ }
1357
+ }
1358
+ const result = {
1359
+ status: ModalCloseReason.COMPLETED,
1360
+ visitedStepIds: this.visitedStepIds,
1361
+ payload: aggregatedData,
1362
+ };
1363
+ if (this.config.onComplete) {
1364
+ await this.config.onComplete.handle(result);
1365
+ }
1366
+ this.modalRef.close(result);
1367
+ }
1368
+ catch (error) {
1369
+ this.isCompleting = false;
1370
+ this.cdr.detectChanges();
1371
+ console.error('Wizard completion error:', error);
1372
+ }
1373
+ }
1374
+ /** Collect form data from all form-driven steps, namespaced by step ID */
1375
+ getAggregatedData() {
1376
+ const aggregated = {};
1377
+ if (!this.formBodies)
1378
+ return aggregated;
1379
+ const formStepIds = this.config.steps
1380
+ .filter(s => this.stepFormConfigs[s.id])
1381
+ .map(s => s.id);
1382
+ this.formBodies.toArray().forEach((fb, index) => {
1383
+ if (fb.form && formStepIds[index]) {
1384
+ aggregated[formStepIds[index]] = { ...fb.form.value };
1385
+ }
1386
+ });
1387
+ return aggregated;
1388
+ }
1389
+ /**
1390
+ * Maps a footer action's ActionStyle to mnButton data props.
1391
+ * @param action The footer action configuration.
1392
+ */
1393
+ getFooterActionButtonData(action) {
1394
+ switch (action.style) {
1395
+ case ActionStyle.DANGER:
1396
+ return { variant: 'outline', color: 'danger' };
1397
+ case ActionStyle.PRIMARY:
1398
+ return { variant: 'fill', color: 'primary' };
1399
+ case ActionStyle.SECONDARY:
1400
+ return { variant: 'outline', color: 'secondary' };
1401
+ case ActionStyle.GHOST:
1402
+ return { variant: 'text', color: 'gray' };
1403
+ default:
1404
+ return { variant: 'outline', color: 'secondary' };
1405
+ }
1406
+ }
1407
+ /**
1408
+ * Handles a custom footer action click.
1409
+ * @param action The footer action configuration.
1410
+ */
1411
+ async handleFooterAction(action) {
1412
+ if (action.handler) {
1413
+ await action.handler(this.modalRef);
1414
+ }
1415
+ if (action.closesModal) {
1416
+ this.modalRef.close((action.closeReason || ModalCloseReason.PROGRAMMATIC));
1417
+ }
1418
+ }
1419
+ async notifyStepChange(previousStepId, direction) {
1420
+ if (this.config.onStepChange) {
1421
+ await this.config.onStepChange.handle({
1422
+ previousStepId,
1423
+ currentStepId: this.currentStepId,
1424
+ direction,
1425
+ });
1426
+ }
1427
+ }
1428
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnWizardBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1429
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: MnWizardBodyComponent, isStandalone: true, selector: "mn-wizard-body", inputs: { config: "config", modalRef: "modalRef" }, viewQueries: [{ propertyName: "stepScroller", first: true, predicate: ["stepScroller"], descendants: true }, { propertyName: "formBodies", predicate: MnFormBodyComponent, descendants: true }, { propertyName: "stepWrappers", predicate: ["stepWrapper"], descendants: true }], ngImport: i0, template: "<div class=\"flex flex-col flex-auto min-h-0\">\n @if (config.component || config.template) {\n <mn-custom-body-host\n [config]=\"$any(config)\"\n [modalRef]=\"$any(modalRef)\"\n class=\"block flex-none px-6 pt-6\"\n ></mn-custom-body-host>\n }\n\n <!-- Steps header \u2014 fixed (does not scroll with the step body) -->\n <div class=\"flex-none px-6 pt-2 pb-4 border-b border-base-300 bg-base-100\">\n <div class=\"relative flex items-start\">\n <!-- Background line spanning from first circle center to last circle center -->\n <div\n [style.left]=\"'calc(' + 100 / (2 * visibleSteps.length) + '%)'\"\n [style.right]=\"'calc(' + 100 / (2 * visibleSteps.length) + '%)'\"\n class=\"absolute top-3.75 h-1 bg-base-300 z-0\"\n ></div>\n\n <!-- Progress fill line -->\n @if (visibleSteps.length > 1) {\n <div\n [style.left]=\"'calc(' + 100 / (2 * visibleSteps.length) + '%)'\"\n [style.width]=\"'calc(' + (currentProgressIndex / (visibleSteps.length - 1)) * (100 - 100 / visibleSteps.length) + '%)'\"\n class=\"absolute top-3.75 h-1 bg-success z-1 transition-all duration-500\"\n ></div>\n }\n\n @for (step of visibleSteps; track step.id; let i = $index; ) {\n <div\n (keyup.enter)=\"isFreeFlow ? goToStep(step) : null\"\n (click)=\"isFreeFlow ? goToStep(step) : null\"\n [attr.tabindex]=\"isFreeFlow && canNavigateToStep(step) ? 0 : null\"\n [class.cursor-pointer]=\"isFreeFlow && canNavigateToStep(step)\"\n class=\"relative flex flex-col items-center gap-1 z-10 w-0 flex-1\"\n >\n <div\n [ngClass]=\"{\n 'bg-primary text-primary-content': step.id === currentStepId,\n 'bg-success text-success-content': visitedStepIds.includes(step.id) && step.id !== currentStepId,\n 'bg-base-200 text-base-content/50': !visitedStepIds.includes(step.id) && step.id !== currentStepId\n }\"\n class=\"w-8 h-8 rounded-full flex items-center justify-center font-semibold transition-all text-sm\"\n >{{ i + 1 }}\n </div>\n <div\n [ngClass]=\"{\n 'text-base-content font-semibold': step.id === currentStepId,\n 'text-base-content/50': step.id !== currentStepId\n }\"\n class=\"text-xs text-center whitespace-nowrap hidden sm:block\"\n >{{ step.title }}\n </div>\n\n </div>\n }\n </div>\n </div>\n\n <!-- Step body \u2014 the only scrolling region in the wizard, shared by every step -->\n <div #stepScroller class=\"flex-auto min-h-0 overflow-y-auto px-6 py-6\">\n <div [style.min-height]=\"measuredMinHeight ? measuredMinHeight + 'px' : null\" class=\"min-h-48\">\n @for (step of config.steps; track step.id) {\n <div #stepWrapper [style.display]=\"step.id === currentStepId ? 'block' : 'none'\">\n <h3 class=\"text-lg font-semibold text-base-content mb-4\">{{ step.title }}</h3>\n <div class=\"text-base-content/80\">\n <!-- Form step -->\n @if (stepFormConfigs[step.id]) {\n <mn-form-body\n [config]=\"stepFormConfigs[step.id]\"\n [modalRef]=\"$any(modalRef)\"\n [hideFooter]=\"true\"\n [hideCustomBody]=\"true\"\n ></mn-form-body>\n }\n\n <!-- Text body -->\n @if (!stepFormConfigs[step.id] && isTextBody(step)) {\n <div>\n {{ step.body }}\n </div>\n }\n\n <!-- Component / template body -->\n @if (stepBodyConfigs[step.id]) {\n <mn-custom-body-host\n [config]=\"stepBodyConfigs[step.id]\"\n [modalRef]=\"$any(modalRef)\"\n ></mn-custom-body-host>\n }\n </div>\n </div>\n }\n </div>\n </div>\n\n <!-- Wizard-level errors (from onBeforeComplete) \u2014 fixed, above the footer -->\n @if (wizardErrors && (wizardErrors | keyvalue).length > 0) {\n <div class=\"flex flex-col gap-1 mx-6 mb-2 px-2 py-2 bg-red-50 rounded-md\">\n @for (err of wizardErrors | keyvalue; track err.key) {\n <div class=\"text-red-500 text-sm\">\n {{ err.value }}\n </div>\n }\n </div>\n }\n\n <!-- Footer \u2014 fixed (does not scroll with the step body) -->\n <div class=\"flex-none flex gap-3 px-6 pt-4 pb-6 border-t border-base-300 bg-base-100\">\n @if (!currentStep?.hideBack) {\n <button\n type=\"button\"\n mnButton\n [data]=\"{ variant: 'outline', color: 'secondary' }\"\n (click)=\"back()\"\n >\n @if (backIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ currentStep?.backLabel || (canGoBack ? labels.back : labels.close) }}\n </button>\n }\n\n <!-- Custom footer actions -->\n @if (config.footerActions) {\n <mn-footer-actions\n [actions]=\"config.footerActions\"\n [showIcons]=\"showActionIcons\"\n (actionClick)=\"handleFooterAction($any($event))\"\n ></mn-footer-actions>\n } @else {\n <div class=\"flex-1\"></div>\n }\n\n @if (!isLastStep) {\n <button\n type=\"button\"\n mnButton\n [data]=\"{ variant: 'fill', color: 'primary', disabled: !isCurrentStepValid }\"\n (click)=\"next()\"\n >\n {{ currentStep?.nextLabel || labels.next }}\n @if (nextIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"ml-2\"></svg>\n }\n </button>\n }\n\n @if (isLastStep) {\n <button\n type=\"button\"\n mnButton\n [data]=\"{ variant: 'fill', color: 'primary', disabled: !isCurrentStepValid || isCompleting }\"\n [disabled]=\"!isCurrentStepValid || isCompleting\"\n (click)=\"complete()\"\n >\n @if (completeIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ currentStep?.nextLabel || (isCompleting ? labels.completing : labels.complete) }}\n </button>\n }\n </div>\n</div>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "component", type: MnButton, selector: "button[mnButton], a[mnButton]", inputs: ["data"] }, { kind: "component", type: MnFormBodyComponent, selector: "mn-form-body", inputs: ["config", "modalRef", "hideFooter", "hideCustomBody"], outputs: ["formStatusChange"] }, { kind: "component", type: MnCustomBodyHostComponent, selector: "mn-custom-body-host", inputs: ["config", "modalRef"] }, { kind: "component", type: MnFooterActionsComponent, selector: "mn-footer-actions", inputs: ["actions", "showIcons"], outputs: ["actionClick"] }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }, { kind: "pipe", type: i1.KeyValuePipe, name: "keyvalue" }] });
1430
+ }
1431
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnWizardBodyComponent, decorators: [{
1432
+ type: Component,
1433
+ args: [{ selector: 'mn-wizard-body', standalone: true, imports: [CommonModule, ReactiveFormsModule, MnButton, MnFormBodyComponent, MnCustomBodyHostComponent, MnFooterActionsComponent, LucideDynamicIcon], template: "<div class=\"flex flex-col flex-auto min-h-0\">\n @if (config.component || config.template) {\n <mn-custom-body-host\n [config]=\"$any(config)\"\n [modalRef]=\"$any(modalRef)\"\n class=\"block flex-none px-6 pt-6\"\n ></mn-custom-body-host>\n }\n\n <!-- Steps header \u2014 fixed (does not scroll with the step body) -->\n <div class=\"flex-none px-6 pt-2 pb-4 border-b border-base-300 bg-base-100\">\n <div class=\"relative flex items-start\">\n <!-- Background line spanning from first circle center to last circle center -->\n <div\n [style.left]=\"'calc(' + 100 / (2 * visibleSteps.length) + '%)'\"\n [style.right]=\"'calc(' + 100 / (2 * visibleSteps.length) + '%)'\"\n class=\"absolute top-3.75 h-1 bg-base-300 z-0\"\n ></div>\n\n <!-- Progress fill line -->\n @if (visibleSteps.length > 1) {\n <div\n [style.left]=\"'calc(' + 100 / (2 * visibleSteps.length) + '%)'\"\n [style.width]=\"'calc(' + (currentProgressIndex / (visibleSteps.length - 1)) * (100 - 100 / visibleSteps.length) + '%)'\"\n class=\"absolute top-3.75 h-1 bg-success z-1 transition-all duration-500\"\n ></div>\n }\n\n @for (step of visibleSteps; track step.id; let i = $index; ) {\n <div\n (keyup.enter)=\"isFreeFlow ? goToStep(step) : null\"\n (click)=\"isFreeFlow ? goToStep(step) : null\"\n [attr.tabindex]=\"isFreeFlow && canNavigateToStep(step) ? 0 : null\"\n [class.cursor-pointer]=\"isFreeFlow && canNavigateToStep(step)\"\n class=\"relative flex flex-col items-center gap-1 z-10 w-0 flex-1\"\n >\n <div\n [ngClass]=\"{\n 'bg-primary text-primary-content': step.id === currentStepId,\n 'bg-success text-success-content': visitedStepIds.includes(step.id) && step.id !== currentStepId,\n 'bg-base-200 text-base-content/50': !visitedStepIds.includes(step.id) && step.id !== currentStepId\n }\"\n class=\"w-8 h-8 rounded-full flex items-center justify-center font-semibold transition-all text-sm\"\n >{{ i + 1 }}\n </div>\n <div\n [ngClass]=\"{\n 'text-base-content font-semibold': step.id === currentStepId,\n 'text-base-content/50': step.id !== currentStepId\n }\"\n class=\"text-xs text-center whitespace-nowrap hidden sm:block\"\n >{{ step.title }}\n </div>\n\n </div>\n }\n </div>\n </div>\n\n <!-- Step body \u2014 the only scrolling region in the wizard, shared by every step -->\n <div #stepScroller class=\"flex-auto min-h-0 overflow-y-auto px-6 py-6\">\n <div [style.min-height]=\"measuredMinHeight ? measuredMinHeight + 'px' : null\" class=\"min-h-48\">\n @for (step of config.steps; track step.id) {\n <div #stepWrapper [style.display]=\"step.id === currentStepId ? 'block' : 'none'\">\n <h3 class=\"text-lg font-semibold text-base-content mb-4\">{{ step.title }}</h3>\n <div class=\"text-base-content/80\">\n <!-- Form step -->\n @if (stepFormConfigs[step.id]) {\n <mn-form-body\n [config]=\"stepFormConfigs[step.id]\"\n [modalRef]=\"$any(modalRef)\"\n [hideFooter]=\"true\"\n [hideCustomBody]=\"true\"\n ></mn-form-body>\n }\n\n <!-- Text body -->\n @if (!stepFormConfigs[step.id] && isTextBody(step)) {\n <div>\n {{ step.body }}\n </div>\n }\n\n <!-- Component / template body -->\n @if (stepBodyConfigs[step.id]) {\n <mn-custom-body-host\n [config]=\"stepBodyConfigs[step.id]\"\n [modalRef]=\"$any(modalRef)\"\n ></mn-custom-body-host>\n }\n </div>\n </div>\n }\n </div>\n </div>\n\n <!-- Wizard-level errors (from onBeforeComplete) \u2014 fixed, above the footer -->\n @if (wizardErrors && (wizardErrors | keyvalue).length > 0) {\n <div class=\"flex flex-col gap-1 mx-6 mb-2 px-2 py-2 bg-red-50 rounded-md\">\n @for (err of wizardErrors | keyvalue; track err.key) {\n <div class=\"text-red-500 text-sm\">\n {{ err.value }}\n </div>\n }\n </div>\n }\n\n <!-- Footer \u2014 fixed (does not scroll with the step body) -->\n <div class=\"flex-none flex gap-3 px-6 pt-4 pb-6 border-t border-base-300 bg-base-100\">\n @if (!currentStep?.hideBack) {\n <button\n type=\"button\"\n mnButton\n [data]=\"{ variant: 'outline', color: 'secondary' }\"\n (click)=\"back()\"\n >\n @if (backIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ currentStep?.backLabel || (canGoBack ? labels.back : labels.close) }}\n </button>\n }\n\n <!-- Custom footer actions -->\n @if (config.footerActions) {\n <mn-footer-actions\n [actions]=\"config.footerActions\"\n [showIcons]=\"showActionIcons\"\n (actionClick)=\"handleFooterAction($any($event))\"\n ></mn-footer-actions>\n } @else {\n <div class=\"flex-1\"></div>\n }\n\n @if (!isLastStep) {\n <button\n type=\"button\"\n mnButton\n [data]=\"{ variant: 'fill', color: 'primary', disabled: !isCurrentStepValid }\"\n (click)=\"next()\"\n >\n {{ currentStep?.nextLabel || labels.next }}\n @if (nextIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"ml-2\"></svg>\n }\n </button>\n }\n\n @if (isLastStep) {\n <button\n type=\"button\"\n mnButton\n [data]=\"{ variant: 'fill', color: 'primary', disabled: !isCurrentStepValid || isCompleting }\"\n [disabled]=\"!isCurrentStepValid || isCompleting\"\n (click)=\"complete()\"\n >\n @if (completeIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ currentStep?.nextLabel || (isCompleting ? labels.completing : labels.complete) }}\n </button>\n }\n </div>\n</div>\n" }]
1434
+ }], propDecorators: { config: [{
1435
+ type: Input
1436
+ }], modalRef: [{
1437
+ type: Input
1438
+ }], formBodies: [{
1439
+ type: ViewChildren,
1440
+ args: [MnFormBodyComponent]
1441
+ }], stepWrappers: [{
1442
+ type: ViewChildren,
1443
+ args: ['stepWrapper']
1444
+ }], stepScroller: [{
1445
+ type: ViewChild,
1446
+ args: ['stepScroller']
1447
+ }] } });
1448
+
1449
+ /** Lucide icons this file renders. */
1450
+ const ICONS$1 = lucideIcons({ CircleAlert: lucide.CircleAlert, TriangleAlert: lucide.TriangleAlert });
1451
+ class MnConfirmationBodyComponent {
1452
+ /** Lucide icons the template renders. */
1453
+ icons = ICONS$1;
1454
+ cdr = inject(ChangeDetectorRef);
1455
+ config;
1456
+ modalRef;
1457
+ formBody;
1458
+ confirmButtonStatus = 'VALID';
1459
+ hasFormFields = false;
1460
+ languageService = inject(MnLanguageService);
1461
+ ngOnInit() {
1462
+ this.hasFormFields = !!((this.config.fields && this.config.fields.length > 0) ||
1463
+ (this.config.fieldGroups && this.config.fieldGroups.length > 0) ||
1464
+ (this.config.rows && this.config.rows.length > 0));
1465
+ }
1466
+ onFormStatusChange(status) {
1467
+ this.confirmButtonStatus = status;
1468
+ this.cdr.markForCheck();
1469
+ this.cdr.detectChanges();
1470
+ }
1471
+ async confirm() {
1472
+ if (this.hasFormFields && this.formBody?.form.invalid) {
1473
+ this.formBody.form.markAllAsTouched();
1474
+ return;
1475
+ }
1476
+ const result = (this.hasFormFields ? this.formBody?.form.value : true);
1477
+ if (this.config.confirm?.handler) {
1478
+ await this.config.confirm.handler.handle(result);
1479
+ }
1480
+ this.modalRef.close(result);
1481
+ }
1482
+ cancel() {
1483
+ const reason = this.config.cancel?.reason || ModalCloseReason.CANCELLED;
1484
+ this.modalRef.dismiss(reason);
1485
+ }
1486
+ resolveLabel(value, key, fallback) {
1487
+ if (value)
1488
+ return value;
1489
+ const translated = this.languageService.translate(`common.${key}`);
1490
+ return translated === `common.${key}` ? fallback : translated;
1491
+ }
1492
+ get confirmLabel() {
1493
+ return this.resolveLabel(this.config.confirm?.label, 'confirm', 'Confirm');
1494
+ }
1495
+ get cancelLabel() {
1496
+ return this.resolveLabel(this.config.cancel?.label, 'cancel', 'Cancel');
1497
+ }
1498
+ get confirmStyle() {
1499
+ return this.config.confirm?.style || ActionStyle.PRIMARY;
1500
+ }
1501
+ get cancelStyle() {
1502
+ return this.config.cancel?.style || ActionStyle.SECONDARY;
1503
+ }
1504
+ get toneClass() {
1505
+ switch (this.config.tone) {
1506
+ case ConfirmationTone.WARNING:
1507
+ return 'tone-warning';
1508
+ case ConfirmationTone.DANGER:
1509
+ return 'tone-danger';
1510
+ default:
1511
+ return 'tone-default';
1512
+ }
1513
+ }
1514
+ getButtonColor(style) {
1515
+ switch (style) {
1516
+ case ActionStyle.PRIMARY:
1517
+ return 'primary';
1518
+ case ActionStyle.DANGER:
1519
+ return 'danger';
1520
+ case ActionStyle.GHOST:
1521
+ return 'secondary';
1522
+ default:
1523
+ return 'secondary';
1524
+ }
1525
+ }
1526
+ getButtonVariant(style) {
1527
+ switch (style) {
1528
+ case ActionStyle.PRIMARY:
1529
+ case ActionStyle.DANGER:
1530
+ return 'fill';
1531
+ case ActionStyle.GHOST:
1532
+ return 'text';
1533
+ default:
1534
+ return 'outline';
1535
+ }
1536
+ }
1537
+ get isConfirmDisabled() {
1538
+ if (this.hasFormFields) {
1539
+ return this.confirmButtonStatus !== 'VALID';
1540
+ }
1541
+ return false;
1542
+ }
1543
+ /** Icon size (px) for the action buttons. */
1544
+ actionIconSize = MODAL_ACTION_ICON_SIZE;
1545
+ /** Whether action-button icons should render on this modal (defaults to true). */
1546
+ get showActionIcons() {
1547
+ return this.config.showActionIcons !== false;
1548
+ }
1549
+ /**
1550
+ * The leading icon for the confirm button, or null when icons are disabled.
1551
+ * Uses the per-action override, else defaults by style (DANGER → trash, else check).
1552
+ */
1553
+ get confirmIcon() {
1554
+ if (!this.showActionIcons)
1555
+ return null;
1556
+ if (this.config.confirm?.icon)
1557
+ return this.config.confirm.icon;
1558
+ return this.confirmStyle === ActionStyle.DANGER
1559
+ ? MN_MODAL_ACTION_ICONS.danger
1560
+ : MN_MODAL_ACTION_ICONS.confirm;
1561
+ }
1562
+ /** The leading icon for the cancel button, or null when icons are disabled. */
1563
+ get cancelIcon() {
1564
+ if (!this.showActionIcons)
1565
+ return null;
1566
+ return this.config.cancel?.icon ?? MN_MODAL_ACTION_ICONS.cancel;
1567
+ }
1568
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnConfirmationBodyComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1569
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: MnConfirmationBodyComponent, isStandalone: true, selector: "mn-confirmation-body", inputs: { config: "config", modalRef: "modalRef" }, viewQueries: [{ propertyName: "formBody", first: true, predicate: MnFormBodyComponent, descendants: true }], ngImport: i0, template: "<div class=\"flex flex-col gap-6\" [ngClass]=\"toneClass\">\n <!-- Custom Content (Component or Template) -->\n @if (config.component || config.template) {\n <mn-custom-body-host\n [config]=\"$any(config)\"\n [modalRef]=\"$any(modalRef)\"\n ></mn-custom-body-host>\n }\n\n <div class=\"flex flex-col items-center text-center gap-6\">\n @if (config.tone === 'warning' || config.tone === 'danger') {\n <div\n class=\"w-12 h-12 rounded-full flex items-center justify-center\"\n [ngClass]=\"{\n 'bg-blue-100 text-blue-500': config.tone !== 'warning' && config.tone !== 'danger',\n 'bg-amber-100 text-amber-500': config.tone === 'warning',\n 'bg-red-100 text-red-500': config.tone === 'danger'\n }\">\n @if (config.tone === 'warning') {\n <svg [size]=\"24\" [lucideIcon]=\"icons.TriangleAlert\"></svg>\n }\n @if (config.tone === 'danger') {\n <svg [size]=\"24\" [lucideIcon]=\"icons.CircleAlert\"></svg>\n }\n </div>\n }\n\n @if (config.message) {\n <div class=\"text-base text-base-content/80 leading-relaxed max-w-[28rem]\">\n {{ config.message }}\n </div>\n }\n </div>\n\n <!-- Form Fields / Rows -->\n @if (hasFormFields) {\n <mn-form-body\n [config]=\"$any(config)\"\n [modalRef]=\"$any(modalRef)\"\n [hideFooter]=\"true\"\n [hideCustomBody]=\"true\"\n (formStatusChange)=\"onFormStatusChange($event)\"\n ></mn-form-body>\n }\n\n <div class=\"flex gap-3 w-full pb-6 sticky bottom-0 bg-base-100 z-10\">\n <button\n type=\"button\"\n mnButton\n [data]=\"{\n variant: getButtonVariant(cancelStyle),\n color: getButtonColor(cancelStyle)\n }\"\n (click)=\"cancel()\"\n >\n @if (cancelIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ cancelLabel }}\n </button>\n\n <div class=\"flex-1\"></div>\n\n <button\n type=\"button\"\n mnButton\n [data]=\"{\n variant: getButtonVariant(confirmStyle),\n color: getButtonColor(confirmStyle),\n disabled: isConfirmDisabled\n }\"\n [disabled]=\"isConfirmDisabled\"\n (click)=\"confirm()\"\n >\n @if (confirmIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ confirmLabel }}\n </button>\n </div>\n</div>\n", styles: [""], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: MnButton, selector: "button[mnButton], a[mnButton]", inputs: ["data"] }, { kind: "component", type: MnFormBodyComponent, selector: "mn-form-body", inputs: ["config", "modalRef", "hideFooter", "hideCustomBody"], outputs: ["formStatusChange"] }, { kind: "component", type: MnCustomBodyHostComponent, selector: "mn-custom-body-host", inputs: ["config", "modalRef"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }] });
1570
+ }
1571
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnConfirmationBodyComponent, decorators: [{
1572
+ type: Component,
1573
+ args: [{ selector: 'mn-confirmation-body', standalone: true, imports: [CommonModule, MnButton, MnFormBodyComponent, MnCustomBodyHostComponent, ReactiveFormsModule, LucideDynamicIcon], template: "<div class=\"flex flex-col gap-6\" [ngClass]=\"toneClass\">\n <!-- Custom Content (Component or Template) -->\n @if (config.component || config.template) {\n <mn-custom-body-host\n [config]=\"$any(config)\"\n [modalRef]=\"$any(modalRef)\"\n ></mn-custom-body-host>\n }\n\n <div class=\"flex flex-col items-center text-center gap-6\">\n @if (config.tone === 'warning' || config.tone === 'danger') {\n <div\n class=\"w-12 h-12 rounded-full flex items-center justify-center\"\n [ngClass]=\"{\n 'bg-blue-100 text-blue-500': config.tone !== 'warning' && config.tone !== 'danger',\n 'bg-amber-100 text-amber-500': config.tone === 'warning',\n 'bg-red-100 text-red-500': config.tone === 'danger'\n }\">\n @if (config.tone === 'warning') {\n <svg [size]=\"24\" [lucideIcon]=\"icons.TriangleAlert\"></svg>\n }\n @if (config.tone === 'danger') {\n <svg [size]=\"24\" [lucideIcon]=\"icons.CircleAlert\"></svg>\n }\n </div>\n }\n\n @if (config.message) {\n <div class=\"text-base text-base-content/80 leading-relaxed max-w-[28rem]\">\n {{ config.message }}\n </div>\n }\n </div>\n\n <!-- Form Fields / Rows -->\n @if (hasFormFields) {\n <mn-form-body\n [config]=\"$any(config)\"\n [modalRef]=\"$any(modalRef)\"\n [hideFooter]=\"true\"\n [hideCustomBody]=\"true\"\n (formStatusChange)=\"onFormStatusChange($event)\"\n ></mn-form-body>\n }\n\n <div class=\"flex gap-3 w-full pb-6 sticky bottom-0 bg-base-100 z-10\">\n <button\n type=\"button\"\n mnButton\n [data]=\"{\n variant: getButtonVariant(cancelStyle),\n color: getButtonColor(cancelStyle)\n }\"\n (click)=\"cancel()\"\n >\n @if (cancelIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ cancelLabel }}\n </button>\n\n <div class=\"flex-1\"></div>\n\n <button\n type=\"button\"\n mnButton\n [data]=\"{\n variant: getButtonVariant(confirmStyle),\n color: getButtonColor(confirmStyle),\n disabled: isConfirmDisabled\n }\"\n [disabled]=\"isConfirmDisabled\"\n (click)=\"confirm()\"\n >\n @if (confirmIcon; as icon) {\n <svg [lucideIcon]=\"icon\" [size]=\"actionIconSize\" class=\"mr-2\"></svg>\n }\n {{ confirmLabel }}\n </button>\n </div>\n</div>\n" }]
1574
+ }], propDecorators: { config: [{
1575
+ type: Input
1576
+ }], modalRef: [{
1577
+ type: Input
1578
+ }], formBody: [{
1579
+ type: ViewChild,
1580
+ args: [MnFormBodyComponent]
1581
+ }] } });
1582
+
1583
+ /** Lucide icons this file renders. */
1584
+ const ICONS = lucideIcons({ X: lucide.X });
1585
+ class MnModalShellComponent {
1586
+ /** Lucide icons the template renders. */
1587
+ icons = ICONS;
1588
+ lang = inject(MnLanguageService);
1589
+ /**
1590
+ * Accessible name for this control. Resolved through the conventional
1591
+ * `mnModal.close` key so an app can translate it, falling back to English when the
1592
+ * key is not defined rather than leaking the raw key into the UI.
1593
+ */
1594
+ get closeModalLabel() {
1595
+ return this.lang.translateIfPresent('mnModal.close') ?? 'Close modal';
1596
+ }
1597
+ el = inject(ElementRef);
1598
+ cdr = inject(ChangeDetectorRef);
1599
+ config;
1600
+ modalRef;
1601
+ isClosing = false;
1602
+ /**
1603
+ * Whether another modal is stacked on top of this one. Set imperatively by
1604
+ * `MnModalService` on the already-rendered shell below the newly opened one, so it must
1605
+ * be a signal: mutating a plain field there changes the host `[class]` after the view was
1606
+ * checked (NG0100 ExpressionChangedAfterItHasBeenChecked) and does not schedule change
1607
+ * detection in a zoneless app. A signal write both notifies the host binding and schedules CD.
1608
+ */
1609
+ isStacked = signal(false, ...(ngDevMode ? [{ debugName: "isStacked" }] : []));
1610
+ ModalKind = ModalKind;
1611
+ /** The rendered wizard body, when this modal is a wizard — used to read the active step title. */
1612
+ wizardBody = viewChild(MnWizardBodyComponent, ...(ngDevMode ? [{ debugName: "wizardBody" }] : []));
1613
+ /** Tailwind's `sm` breakpoint — below this the modal presents as a bottom sheet. */
1614
+ static SHEET_MAX_WIDTH = 639.98;
1615
+ /**
1616
+ * Title of the wizard's current step, or undefined for non-wizard modals.
1617
+ * The template appends it to the modal title on small screens, where the
1618
+ * step labels under the progress circles are hidden.
1619
+ */
1620
+ wizardStepTitle = computed(() => this.wizardBody()?.currentStepTitle(), ...(ngDevMode ? [{ debugName: "wizardStepTitle" }] : []));
1621
+ previouslyFocusedElement = null;
1622
+ focusTrapListener = null;
1623
+ pollingTimer = null;
1624
+ pollAttempts = 0;
1625
+ /** Upper bound for the close wait if no animation/transition end event fires
1626
+ * (e.g. an animation was suppressed). Must stay longer than the slowest close
1627
+ * path so it never preempts. */
1628
+ static CLOSE_FALLBACK_MS = 700;
1629
+ /** Live match of the sheet breakpoint, so the modal switches between the centered dialog
1630
+ * and the bottom sheet when the viewport crosses it (e.g. an orientation change). */
1631
+ isNarrow = signal(false, ...(ngDevMode ? [{ debugName: "isNarrow" }] : []));
1632
+ /** The bottom sheet presenting this modal on mobile, absent on the desktop dialog path. */
1633
+ bottomSheet = viewChild(MnBottomSheet, ...(ngDevMode ? [{ debugName: "bottomSheet" }] : []));
1634
+ /** Optional native haptic engine. Absent on the web — every call is null-guarded. */
1635
+ haptics = inject(MN_HAPTICS, { optional: true });
1636
+ sheetMedia = null;
1637
+ sheetMediaListener = null;
1638
+ /** Whether this modal is allowed to present as a bottom sheet on small screens (default: true). */
1639
+ get isMobileSheet() {
1640
+ return this.config.mobileBottomSheet !== false;
1641
+ }
1642
+ /** Whether the modal should currently render as a bottom sheet (mobile) rather than the
1643
+ * centered dialog (desktop). */
1644
+ get showMobileSheet() {
1645
+ return this.isMobileSheet && this.isNarrow();
1646
+ }
1647
+ get hostClasses() {
1648
+ const size = this.config.sizeWidth || ModalSize.MD;
1649
+ // `closing` is intentionally NOT derived here. startClosing() adds the
1650
+ // `.closing` class imperatively (classList.add) for reliable, zoneless-safe
1651
+ // application. Deriving it here as well flips the host class string after the
1652
+ // view has been checked (NG0100). Angular's class binding only manages the tokens
1653
+ // it emits, so it leaves the imperatively added `.closing` untouched.
1654
+ const animType = typeof this.config.animation === 'string'
1655
+ ? this.config.animation
1656
+ : this.config.animation?.type || 'slide';
1657
+ const animation = ` anim-${animType}`;
1658
+ const stacked = this.isStacked() ? ' is-stacked' : '';
1659
+ const mobileSheet = this.showMobileSheet ? ' mobile-sheet' : '';
1660
+ return `modal-shell modal-${size}${animation}${stacked}${mobileSheet}`;
1661
+ }
1662
+ setupFocusTrap() {
1663
+ this.focusTrapListener = (e) => {
1664
+ if (e.key !== 'Tab')
1665
+ return;
1666
+ const focusable = this.el.nativeElement.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');
1667
+ if (focusable.length === 0)
1668
+ return;
1669
+ const first = focusable[0];
1670
+ const last = focusable[focusable.length - 1];
1671
+ if (e.shiftKey) {
1672
+ if (document.activeElement === first) {
1673
+ e.preventDefault();
1674
+ last.focus();
1675
+ }
1676
+ }
1677
+ else {
1678
+ if (document.activeElement === last) {
1679
+ e.preventDefault();
1680
+ first.focus();
1681
+ }
1682
+ }
1683
+ };
1684
+ this.el.nativeElement.addEventListener('keydown', this.focusTrapListener);
1685
+ }
1686
+ removeFocusTrap() {
1687
+ if (this.focusTrapListener) {
1688
+ this.el.nativeElement.removeEventListener('keydown', this.focusTrapListener);
1689
+ this.focusTrapListener = null;
1690
+ }
1691
+ }
1692
+ asWizard(config) {
1693
+ return config;
1694
+ }
1695
+ asForm(config) {
1696
+ return config;
1697
+ }
1698
+ asConfirmation(config) {
1699
+ return config;
1700
+ }
1701
+ asCustom(config) {
1702
+ return config;
1703
+ }
1704
+ /** Whether the modal can be dismissed at all (drives the sheet's swipe/backdrop arming). */
1705
+ get canClose() {
1706
+ return this.config.closeMode !== CloseMode.DISABLED;
1707
+ }
1708
+ ngOnInit() {
1709
+ this.startWatchingViewport();
1710
+ this.startPollingIfConfigured();
1711
+ }
1712
+ ngOnDestroy() {
1713
+ this.removeFocusTrap();
1714
+ this.stopPolling();
1715
+ this.stopWatchingViewport();
1716
+ // Restore focus to previously focused element
1717
+ if (this.previouslyFocusedElement && typeof this.previouslyFocusedElement.focus === 'function') {
1718
+ this.previouslyFocusedElement.focus();
1719
+ }
1720
+ }
1721
+ /**
1722
+ * Triggers the closing animation and resolves once it has actually finished.
1723
+ *
1724
+ * Deferred via setTimeout to avoid NG0100 when called during a CD cycle. On mobile the
1725
+ * exit is owned by the bottom sheet, so we delegate to its `startClosing()` (idempotent
1726
+ * with a swipe-dismiss already in flight); on desktop we wait for the dialog container's
1727
+ * `animationend`/`transitionend`. A fallback timeout guarantees resolution if no event
1728
+ * fires, and we short-circuit under reduced motion (the CSS collapses to instant).
1729
+ */
1730
+ startClosing() {
1731
+ return new Promise(resolve => {
1732
+ setTimeout(async () => {
1733
+ this.isClosing = true;
1734
+ // @HostBinding('class') updates are flushed when the host view is checked
1735
+ // (appRef.tick), not by a bare detectChanges() on this dynamically-created
1736
+ // root component. Apply the `.closing` class directly so the backdrop fade is
1737
+ // reliable in a zoneless app.
1738
+ this.el.nativeElement.classList.add('closing');
1739
+ this.cdr.detectChanges();
1740
+ if (this.prefersReducedMotion()) {
1741
+ resolve();
1742
+ return;
1743
+ }
1744
+ // Mobile: the bottom sheet drives the slide-down exit.
1745
+ const sheet = this.bottomSheet();
1746
+ if (sheet) {
1747
+ await sheet.startClosing();
1748
+ resolve();
1749
+ return;
1750
+ }
1751
+ // Desktop: wait for the centered dialog container's own close animation.
1752
+ const container = this.el.nativeElement.querySelector('.modal-container');
1753
+ if (!container) {
1754
+ resolve();
1755
+ return;
1756
+ }
1757
+ let settled = false;
1758
+ const done = (event) => {
1759
+ // Ignore end events bubbling up from descendant animations/transitions.
1760
+ if (event && event.target !== container)
1761
+ return;
1762
+ if (settled)
1763
+ return;
1764
+ settled = true;
1765
+ container.removeEventListener('animationend', done);
1766
+ container.removeEventListener('transitionend', done);
1767
+ clearTimeout(fallback);
1768
+ resolve();
1769
+ };
1770
+ container.addEventListener('animationend', done);
1771
+ container.addEventListener('transitionend', done);
1772
+ const fallback = setTimeout(done, MnModalShellComponent.CLOSE_FALLBACK_MS);
1773
+ });
1774
+ });
1775
+ }
1776
+ prefersReducedMotion() {
1777
+ return typeof window !== 'undefined'
1778
+ && typeof window.matchMedia === 'function'
1779
+ && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
1780
+ }
1781
+ onEscapeKey(event) {
1782
+ if (this.config.keyboard === KeyboardMode.ENABLED) {
1783
+ this.handleClose(ModalCloseReason.ESCAPE);
1784
+ if (event && event.preventDefault) {
1785
+ event.preventDefault();
1786
+ }
1787
+ }
1788
+ }
1789
+ onBackdropClick() {
1790
+ const shouldClose = this.config.backdrop === BackdropMode.CLOSABLE
1791
+ || (this.isMobileSheet && this.config.backdrop !== BackdropMode.STATIC);
1792
+ if (shouldClose) {
1793
+ this.handleClose(ModalCloseReason.BACKDROP);
1794
+ }
1795
+ }
1796
+ onCloseButtonClick() {
1797
+ this.handleClose(ModalCloseReason.DISMISSED);
1798
+ }
1799
+ /**
1800
+ * Guard consulted by the bottom sheet before it commits a swipe/flick/backdrop dismissal.
1801
+ * Mirrors the DISABLED/GUARDED rules of {@link handleClose} so a swipe cannot escape a
1802
+ * modal that a button close could not. Bound as a field so the template passes it directly.
1803
+ */
1804
+ sheetDismissGuard = async () => {
1805
+ if (this.config.closeMode === CloseMode.DISABLED) {
1806
+ return false;
1807
+ }
1808
+ if (this.config.closeMode === CloseMode.GUARDED && this.config.closeGuard) {
1809
+ return await this.config.closeGuard();
1810
+ }
1811
+ return true;
1812
+ };
1813
+ /**
1814
+ * Handles the sheet's `(dismiss)` — emitted only after its guard passed and its exit
1815
+ * animation finished. Dismisses the modal (no re-guard) with a confirming haptic.
1816
+ */
1817
+ onSheetDismiss() {
1818
+ this.haptics?.impact('medium');
1819
+ this.modalRef.dismiss(ModalCloseReason.DISMISSED);
1820
+ }
1821
+ ngAfterViewInit() {
1822
+ this.previouslyFocusedElement = document.activeElement;
1823
+ this.setupFocusTrap();
1824
+ // Focus the modal container (the centered dialog, or the sheet's container on mobile).
1825
+ const container = this.el.nativeElement.querySelector('.modal-container');
1826
+ if (container) {
1827
+ container.focus();
1828
+ }
1829
+ }
1830
+ /** Tracks the sheet breakpoint through `matchMedia` so the dialog/sheet fork re-renders
1831
+ * when the viewport crosses it. */
1832
+ startWatchingViewport() {
1833
+ if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
1834
+ return;
1835
+ this.sheetMedia = window.matchMedia(`(max-width: ${MnModalShellComponent.SHEET_MAX_WIDTH}px)`);
1836
+ this.isNarrow.set(this.sheetMedia.matches);
1837
+ this.sheetMediaListener = (event) => this.isNarrow.set(event.matches);
1838
+ this.sheetMedia.addEventListener('change', this.sheetMediaListener);
1839
+ }
1840
+ /** Tears down the breakpoint listener. Idempotent. */
1841
+ stopWatchingViewport() {
1842
+ if (this.sheetMedia && this.sheetMediaListener) {
1843
+ this.sheetMedia.removeEventListener('change', this.sheetMediaListener);
1844
+ }
1845
+ this.sheetMedia = null;
1846
+ this.sheetMediaListener = null;
1847
+ }
1848
+ /** Attempts to dismiss the modal. Resolves true if it was actually dismissed,
1849
+ * false if blocked by a DISABLED close mode or a rejected close guard. */
1850
+ async handleClose(reason) {
1851
+ if (this.config.closeMode === CloseMode.DISABLED) {
1852
+ return false;
1853
+ }
1854
+ if (this.config.closeMode === CloseMode.GUARDED) {
1855
+ if (this.config.closeGuard) {
1856
+ const allowed = await this.config.closeGuard();
1857
+ if (!allowed)
1858
+ return false;
1859
+ }
1860
+ }
1861
+ this.modalRef.dismiss(reason);
1862
+ return true;
1863
+ }
1864
+ get showBackdrop() {
1865
+ return this.config.backdrop !== BackdropMode.HIDE;
1866
+ }
1867
+ get containerSizeClass() {
1868
+ switch (this.config.sizeWidth || ModalSize.MD) {
1869
+ case ModalSize.SM: return 'w-96';
1870
+ case ModalSize.MD: return 'w-[32rem]';
1871
+ case ModalSize.LG: return 'w-[48rem]';
1872
+ case ModalSize.XL: return 'w-[64rem]';
1873
+ case ModalSize.FULL: return 'w-[95vw]';
1874
+ default: return 'w-[32rem]';
1875
+ }
1876
+ }
1877
+ get containerHeightStyle() {
1878
+ if (this.config.sizeWidth === ModalSize.FULL && !this.config.sizeHeight) {
1879
+ return '95vh';
1880
+ }
1881
+ if (!this.config.sizeHeight)
1882
+ return null;
1883
+ switch (this.config.sizeHeight) {
1884
+ case ModalSize.SM: return '30vh';
1885
+ case ModalSize.MD: return '50vh';
1886
+ case ModalSize.LG: return '70vh';
1887
+ case ModalSize.XL: return '85vh';
1888
+ case ModalSize.FULL: return '95vh';
1889
+ default: return null;
1890
+ }
1891
+ }
1892
+ get showCloseButton() {
1893
+ return this.config.closeMode !== CloseMode.DISABLED;
1894
+ }
1895
+ // =========================
1896
+ // Footer Actions
1897
+ // =========================
1898
+ get hasCustomFooterActions() {
1899
+ return !!this.config.footerActions && this.config.footerActions.length > 0;
1900
+ }
1901
+ get leftFooterActions() {
1902
+ return (this.config.footerActions || []).filter(a => a.position === 'left');
1903
+ }
1904
+ get rightFooterActions() {
1905
+ return (this.config.footerActions || []).filter(a => a.position !== 'left');
1906
+ }
1907
+ async onFooterAction(action) {
1908
+ if (action.disabled)
1909
+ return;
1910
+ if (action.handler) {
1911
+ await action.handler(this.modalRef);
1912
+ }
1913
+ if (action.closesModal) {
1914
+ if (action.closeReason === ModalCloseReason.COMPLETED) {
1915
+ this.modalRef.close();
1916
+ }
1917
+ else {
1918
+ this.modalRef.dismiss(action.closeReason || ModalCloseReason.DISMISSED);
1919
+ }
1920
+ }
1921
+ }
1922
+ getActionButtonColor(style) {
1923
+ switch (style) {
1924
+ case ActionStyle.PRIMARY: return 'primary';
1925
+ case ActionStyle.DANGER: return 'danger';
1926
+ case ActionStyle.GHOST: return 'secondary';
1927
+ default: return 'secondary';
1928
+ }
1929
+ }
1930
+ getActionButtonVariant(style) {
1931
+ switch (style) {
1932
+ case ActionStyle.PRIMARY:
1933
+ case ActionStyle.DANGER: return 'fill';
1934
+ case ActionStyle.GHOST: return 'text';
1935
+ default: return 'outline';
1936
+ }
1937
+ }
1938
+ // =========================
1939
+ // Polling
1940
+ // =========================
1941
+ startPollingIfConfigured() {
1942
+ const polling = this.config.polling;
1943
+ if (!polling)
1944
+ return;
1945
+ if (polling.autoStart === false)
1946
+ return;
1947
+ this.startPolling();
1948
+ }
1949
+ startPolling() {
1950
+ const polling = this.config.polling;
1951
+ if (!polling)
1952
+ return;
1953
+ this.pollingTimer = setInterval(async () => {
1954
+ this.pollAttempts++;
1955
+ try {
1956
+ const shouldStop = await polling.onPoll(this.modalRef);
1957
+ if (shouldStop === true) {
1958
+ this.stopPolling();
1959
+ }
1960
+ }
1961
+ catch (e) {
1962
+ console.error('Polling error:', e);
1963
+ }
1964
+ if (polling.maxAttempts && this.pollAttempts >= polling.maxAttempts) {
1965
+ this.stopPolling();
1966
+ }
1967
+ }, polling.interval);
1968
+ }
1969
+ stopPolling() {
1970
+ if (this.pollingTimer) {
1971
+ clearInterval(this.pollingTimer);
1972
+ this.pollingTimer = null;
1973
+ }
1974
+ }
1975
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnModalShellComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1976
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: MnModalShellComponent, isStandalone: true, selector: "mn-modal-shell", inputs: { config: "config", modalRef: "modalRef" }, host: { listeners: { "document:keydown.escape": "onEscapeKey($event)" }, properties: { "class": "this.hostClasses" } }, viewQueries: [{ propertyName: "wizardBody", first: true, predicate: MnWizardBodyComponent, descendants: true, isSignal: true }, { propertyName: "bottomSheet", first: true, predicate: MnBottomSheet, descendants: true, isSignal: true }], ngImport: i0, template: "@if (showBackdrop) {\n <!-- The backdrop is a visual overlay \u2014 keyboard dismiss is handled at component level via Escape key -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div class=\"modal-backdrop absolute inset-0 bg-black/50 animate-[fadeIn_0.2s_ease-in-out]\" (click)=\"onBackdropClick()\"></div>\n}\n\n@if (showMobileSheet) {\n <!-- Mobile: the shared bottom sheet owns the anchoring, grabber, swipe/flick-to-dismiss\n and slide animation. The shell keeps its own backdrop (so the sheet renders none),\n and its close animation delegates to the sheet's startClosing(). `modal-container`\n is kept as a class hook so the host app's keyboard-lift CSS still matches. -->\n <mn-bottom-sheet\n (dismiss)=\"onSheetDismiss()\"\n [ariaLabelledby]=\"config.title ? 'mn-modal-title' : undefined\"\n [containerClass]=\"'modal-container'\"\n [dismissGuard]=\"sheetDismissGuard\"\n [dismissible]=\"canClose\"\n [growWithKeyboard]=\"true\"\n [maxHeightVh]=\"92\"\n [showBackdrop]=\"false\"\n >\n <ng-container [ngTemplateOutlet]=\"modalBody\"></ng-container>\n </mn-bottom-sheet>\n} @else {\n <!--\n Desktop centered dialog. The container deliberately does NOT stop click propagation.\n The backdrop is a *sibling* element (absolutely positioned behind this one), never an\n ancestor, so clicks in here can't reach `onBackdropClick()` anyway. Swallowing them\n instead broke every \"click outside me\" handler inside a modal.\n -->\n <div\n [attr.aria-describedby]=\"config.description ? 'mn-modal-description' : null\"\n [attr.aria-labelledby]=\"config.title ? 'mn-modal-title' : null\"\n [ngClass]=\"containerSizeClass\"\n [style.height]=\"containerHeightStyle\"\n aria-modal=\"true\"\n class=\"modal-container relative bg-base-100 rounded-lg shadow-xl max-h-[90vh] max-w-[calc(100vw-2rem)] overflow-hidden flex flex-col\"\n role=\"dialog\"\n tabindex=\"-1\"\n >\n <ng-container [ngTemplateOutlet]=\"modalBody\"></ng-container>\n </div>\n}\n\n<ng-template #modalBody>\n <div [class.border-b]=\"config.kind !== ModalKind.WIZARD\"\n [class.border-base-300]=\"config.kind !== ModalKind.WIZARD\"\n class=\"flex items-center justify-between p-6\">\n <div class=\"flex flex-col gap-0.5\">\n @if (config.title) {\n <!-- On small screens the wizard's step labels (under the progress circles) are hidden,\n so surface the active step name here as \"Title - Step\" instead. -->\n <h2 class=\"m-0 text-xl font-semibold text-base-content\"\n id=\"mn-modal-title\">{{ config.title }}@if (config.kind === ModalKind.WIZARD && wizardStepTitle()) {\n <span class=\"sm:hidden font-normal text-base-content/60\"> - {{ wizardStepTitle() }}</span>\n }</h2>\n }\n @if (config.subtitle) {\n <p class=\"m-0 text-sm text-base-content/60 font-normal\">{{ config.subtitle }}</p>\n }\n </div>\n @if (showCloseButton) {\n <div [class]=\"showMobileSheet ? 'hidden sm:flex' : ''\">\n <button\n mnButton\n [data]=\"{ size: 'sm', variant: 'text', color: 'gray', hover: true, borderRadius: 'md' }\"\n type=\"button\"\n class=\"w-8 h-8\"\n (click)=\"onCloseButtonClick()\"\n [attr.aria-label]=\"closeModalLabel\"\n >\n <svg [lucideIcon]=\"icons.X\" [size]=\"18\"></svg>\n </button>\n </div>\n }\n </div>\n @if (config.description) {\n <p class=\"m-0 px-6 text-sm text-base-content/60 leading-relaxed\" id=\"mn-modal-description\">{{ config.description }}</p>\n }\n\n @if (config.kind === ModalKind.WIZARD) {\n <!-- Wizard manages its own internal scrolling so the steps header and footer\n stay fixed while only the step body scrolls. No padding/scroll here. -->\n <div class=\"flex-auto min-h-0 overflow-hidden flex flex-col\">\n <mn-wizard-body\n [config]=\"asWizard(config)\"\n [modalRef]=\"$any(modalRef)\"\n class=\"flex-auto min-h-0 flex flex-col\"\n ></mn-wizard-body>\n </div>\n } @else {\n <div class=\"flex-1 overflow-y-auto px-6 pt-6\">\n @if (config.kind === ModalKind.FORM) {\n <mn-form-body\n [config]=\"asForm(config)\"\n [modalRef]=\"$any(modalRef)\"\n class=\"block h-full\"\n ></mn-form-body>\n }\n\n @if (config.kind === ModalKind.CONFIRMATION) {\n <mn-confirmation-body\n [config]=\"asConfirmation(config)\"\n [modalRef]=\"$any(modalRef)\"\n ></mn-confirmation-body>\n }\n\n @if (config.kind === ModalKind.CUSTOM) {\n <mn-custom-body-host\n [config]=\"asCustom(config)\"\n [modalRef]=\"$any(modalRef)\"\n class=\"block pb-6\"\n ></mn-custom-body-host>\n }\n </div>\n }\n\n <!-- Custom Footer Actions (not for wizard modals, they render their own) -->\n @if (hasCustomFooterActions && config.kind !== ModalKind.WIZARD) {\n <div class=\"flex gap-3 p-6 border-t border-base-300\">\n <mn-footer-actions\n [actions]=\"config.footerActions || []\"\n [showIcons]=\"config.showActionIcons !== false\"\n (actionClick)=\"onFooterAction($event)\"\n ></mn-footer-actions>\n </div>\n }\n</ng-template>\n", styles: [":host{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;transition:transform .3s ease-in-out,filter .3s ease-in-out,opacity .3s ease-in-out}:host(.mobile-sheet){align-items:flex-end}:host(.is-stacked){transform:scale(.96) translateY(-1rem);filter:brightness(.9) blur(1px);pointer-events:none;opacity:.8}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes slideIn{0%{opacity:0;transform:translateY(-1rem)}to{opacity:1;transform:translateY(0)}}@keyframes zoomIn{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}@keyframes slideOut{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(1rem)}}@keyframes zoomOut{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}:host(.anim-slide) .modal-container{animation:slideIn .2s ease-in-out}:host(.anim-fade) .modal-container{animation:fadeIn .2s ease-in-out}:host(.anim-zoom) .modal-container{animation:zoomIn .2s ease-in-out}:host(.closing) .modal-backdrop{animation:fadeOut .15s ease-in-out forwards}:host(.closing).anim-slide .modal-container{animation:slideOut .15s ease-in-out forwards}:host(.closing).anim-fade .modal-container{animation:fadeOut .15s ease-in-out forwards}:host(.closing).anim-zoom .modal-container{animation:zoomOut .15s ease-in-out forwards}@media(prefers-reduced-motion:reduce){:host,:host .modal-backdrop,:host .modal-container{animation-duration:.01ms!important;animation-delay:0ms!important;transition-duration:.01ms!important}}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: MnWizardBodyComponent, selector: "mn-wizard-body", inputs: ["config", "modalRef"] }, { kind: "component", type: MnFormBodyComponent, selector: "mn-form-body", inputs: ["config", "modalRef", "hideFooter", "hideCustomBody"], outputs: ["formStatusChange"] }, { kind: "component", type: MnConfirmationBodyComponent, selector: "mn-confirmation-body", inputs: ["config", "modalRef"] }, { kind: "component", type: MnCustomBodyHostComponent, selector: "mn-custom-body-host", inputs: ["config", "modalRef"] }, { kind: "component", type: MnFooterActionsComponent, selector: "mn-footer-actions", inputs: ["actions", "showIcons"], outputs: ["actionClick"] }, { kind: "component", type: MnButton, selector: "button[mnButton], a[mnButton]", inputs: ["data"] }, { kind: "component", type: MnBottomSheet, selector: "mn-bottom-sheet", inputs: ["showBackdrop", "showGrabber", "dismissible", "minHeightPx", "maxHeightVh", "containerClass", "ariaLabel", "ariaLabelledby", "growWithKeyboard", "dismissGuard"], outputs: ["dismiss"] }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }] });
1977
+ }
1978
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnModalShellComponent, decorators: [{
1979
+ type: Component,
1980
+ args: [{ selector: 'mn-modal-shell', standalone: true, imports: [
1981
+ CommonModule,
1982
+ MnWizardBodyComponent,
1983
+ MnFormBodyComponent,
1984
+ MnConfirmationBodyComponent,
1985
+ MnCustomBodyHostComponent,
1986
+ MnFooterActionsComponent,
1987
+ MnButton,
1988
+ MnBottomSheet,
1989
+ LucideDynamicIcon,
1990
+ ], template: "@if (showBackdrop) {\n <!-- The backdrop is a visual overlay \u2014 keyboard dismiss is handled at component level via Escape key -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div class=\"modal-backdrop absolute inset-0 bg-black/50 animate-[fadeIn_0.2s_ease-in-out]\" (click)=\"onBackdropClick()\"></div>\n}\n\n@if (showMobileSheet) {\n <!-- Mobile: the shared bottom sheet owns the anchoring, grabber, swipe/flick-to-dismiss\n and slide animation. The shell keeps its own backdrop (so the sheet renders none),\n and its close animation delegates to the sheet's startClosing(). `modal-container`\n is kept as a class hook so the host app's keyboard-lift CSS still matches. -->\n <mn-bottom-sheet\n (dismiss)=\"onSheetDismiss()\"\n [ariaLabelledby]=\"config.title ? 'mn-modal-title' : undefined\"\n [containerClass]=\"'modal-container'\"\n [dismissGuard]=\"sheetDismissGuard\"\n [dismissible]=\"canClose\"\n [growWithKeyboard]=\"true\"\n [maxHeightVh]=\"92\"\n [showBackdrop]=\"false\"\n >\n <ng-container [ngTemplateOutlet]=\"modalBody\"></ng-container>\n </mn-bottom-sheet>\n} @else {\n <!--\n Desktop centered dialog. The container deliberately does NOT stop click propagation.\n The backdrop is a *sibling* element (absolutely positioned behind this one), never an\n ancestor, so clicks in here can't reach `onBackdropClick()` anyway. Swallowing them\n instead broke every \"click outside me\" handler inside a modal.\n -->\n <div\n [attr.aria-describedby]=\"config.description ? 'mn-modal-description' : null\"\n [attr.aria-labelledby]=\"config.title ? 'mn-modal-title' : null\"\n [ngClass]=\"containerSizeClass\"\n [style.height]=\"containerHeightStyle\"\n aria-modal=\"true\"\n class=\"modal-container relative bg-base-100 rounded-lg shadow-xl max-h-[90vh] max-w-[calc(100vw-2rem)] overflow-hidden flex flex-col\"\n role=\"dialog\"\n tabindex=\"-1\"\n >\n <ng-container [ngTemplateOutlet]=\"modalBody\"></ng-container>\n </div>\n}\n\n<ng-template #modalBody>\n <div [class.border-b]=\"config.kind !== ModalKind.WIZARD\"\n [class.border-base-300]=\"config.kind !== ModalKind.WIZARD\"\n class=\"flex items-center justify-between p-6\">\n <div class=\"flex flex-col gap-0.5\">\n @if (config.title) {\n <!-- On small screens the wizard's step labels (under the progress circles) are hidden,\n so surface the active step name here as \"Title - Step\" instead. -->\n <h2 class=\"m-0 text-xl font-semibold text-base-content\"\n id=\"mn-modal-title\">{{ config.title }}@if (config.kind === ModalKind.WIZARD && wizardStepTitle()) {\n <span class=\"sm:hidden font-normal text-base-content/60\"> - {{ wizardStepTitle() }}</span>\n }</h2>\n }\n @if (config.subtitle) {\n <p class=\"m-0 text-sm text-base-content/60 font-normal\">{{ config.subtitle }}</p>\n }\n </div>\n @if (showCloseButton) {\n <div [class]=\"showMobileSheet ? 'hidden sm:flex' : ''\">\n <button\n mnButton\n [data]=\"{ size: 'sm', variant: 'text', color: 'gray', hover: true, borderRadius: 'md' }\"\n type=\"button\"\n class=\"w-8 h-8\"\n (click)=\"onCloseButtonClick()\"\n [attr.aria-label]=\"closeModalLabel\"\n >\n <svg [lucideIcon]=\"icons.X\" [size]=\"18\"></svg>\n </button>\n </div>\n }\n </div>\n @if (config.description) {\n <p class=\"m-0 px-6 text-sm text-base-content/60 leading-relaxed\" id=\"mn-modal-description\">{{ config.description }}</p>\n }\n\n @if (config.kind === ModalKind.WIZARD) {\n <!-- Wizard manages its own internal scrolling so the steps header and footer\n stay fixed while only the step body scrolls. No padding/scroll here. -->\n <div class=\"flex-auto min-h-0 overflow-hidden flex flex-col\">\n <mn-wizard-body\n [config]=\"asWizard(config)\"\n [modalRef]=\"$any(modalRef)\"\n class=\"flex-auto min-h-0 flex flex-col\"\n ></mn-wizard-body>\n </div>\n } @else {\n <div class=\"flex-1 overflow-y-auto px-6 pt-6\">\n @if (config.kind === ModalKind.FORM) {\n <mn-form-body\n [config]=\"asForm(config)\"\n [modalRef]=\"$any(modalRef)\"\n class=\"block h-full\"\n ></mn-form-body>\n }\n\n @if (config.kind === ModalKind.CONFIRMATION) {\n <mn-confirmation-body\n [config]=\"asConfirmation(config)\"\n [modalRef]=\"$any(modalRef)\"\n ></mn-confirmation-body>\n }\n\n @if (config.kind === ModalKind.CUSTOM) {\n <mn-custom-body-host\n [config]=\"asCustom(config)\"\n [modalRef]=\"$any(modalRef)\"\n class=\"block pb-6\"\n ></mn-custom-body-host>\n }\n </div>\n }\n\n <!-- Custom Footer Actions (not for wizard modals, they render their own) -->\n @if (hasCustomFooterActions && config.kind !== ModalKind.WIZARD) {\n <div class=\"flex gap-3 p-6 border-t border-base-300\">\n <mn-footer-actions\n [actions]=\"config.footerActions || []\"\n [showIcons]=\"config.showActionIcons !== false\"\n (actionClick)=\"onFooterAction($event)\"\n ></mn-footer-actions>\n </div>\n }\n</ng-template>\n", styles: [":host{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;transition:transform .3s ease-in-out,filter .3s ease-in-out,opacity .3s ease-in-out}:host(.mobile-sheet){align-items:flex-end}:host(.is-stacked){transform:scale(.96) translateY(-1rem);filter:brightness(.9) blur(1px);pointer-events:none;opacity:.8}@keyframes fadeIn{0%{opacity:0}to{opacity:1}}@keyframes slideIn{0%{opacity:0;transform:translateY(-1rem)}to{opacity:1;transform:translateY(0)}}@keyframes zoomIn{0%{opacity:0;transform:scale(.95)}to{opacity:1;transform:scale(1)}}@keyframes fadeOut{0%{opacity:1}to{opacity:0}}@keyframes slideOut{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(1rem)}}@keyframes zoomOut{0%{opacity:1;transform:scale(1)}to{opacity:0;transform:scale(.95)}}:host(.anim-slide) .modal-container{animation:slideIn .2s ease-in-out}:host(.anim-fade) .modal-container{animation:fadeIn .2s ease-in-out}:host(.anim-zoom) .modal-container{animation:zoomIn .2s ease-in-out}:host(.closing) .modal-backdrop{animation:fadeOut .15s ease-in-out forwards}:host(.closing).anim-slide .modal-container{animation:slideOut .15s ease-in-out forwards}:host(.closing).anim-fade .modal-container{animation:fadeOut .15s ease-in-out forwards}:host(.closing).anim-zoom .modal-container{animation:zoomOut .15s ease-in-out forwards}@media(prefers-reduced-motion:reduce){:host,:host .modal-backdrop,:host .modal-container{animation-duration:.01ms!important;animation-delay:0ms!important;transition-duration:.01ms!important}}\n"] }]
1991
+ }], propDecorators: { config: [{
1992
+ type: Input
1993
+ }], modalRef: [{
1994
+ type: Input
1995
+ }], wizardBody: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MnWizardBodyComponent), { isSignal: true }] }], bottomSheet: [{ type: i0.ViewChild, args: [i0.forwardRef(() => MnBottomSheet), { isSignal: true }] }], hostClasses: [{
1996
+ type: HostBinding,
1997
+ args: ['class']
1998
+ }], onEscapeKey: [{
1999
+ type: HostListener,
2000
+ args: ['document:keydown.escape', ['$event']]
2001
+ }] } });
2002
+
2003
+ /**
2004
+ * Public API of the `mn-angular-lib/modal-ui` entry point: the modal shell and body components. `MnModalService` loads this entry point on demand, so it is not part of a consumer's startup bundle.
2005
+ *
2006
+ * Each entry point is its own module in the published package, so a consumer's bundler
2007
+ * splits it into the chunk that uses it instead of loading the whole library at startup.
2008
+ * The root `mn-angular-lib` entry re-exports every entry point.
2009
+ */
2010
+
2011
+ /**
2012
+ * Generated bundle index. Do not edit.
2013
+ */
2014
+
2015
+ export { MnConfirmationBodyComponent, MnCustomBodyHostComponent, MnFormBodyComponent, MnModalShellComponent, MnWizardBodyComponent };
2016
+ //# sourceMappingURL=mn-angular-lib-modal-ui.mjs.map