mn-angular-lib 2.0.34 → 2.0.36

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