mn-angular-lib 1.0.180 → 2.0.2
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.
- package/fesm2022/mn-angular-lib-alert.mjs +11 -10
- package/fesm2022/mn-angular-lib-alert.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-bottom-sheet.mjs +15 -14
- package/fesm2022/mn-angular-lib-bottom-sheet.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-button.mjs +9 -9
- package/fesm2022/mn-angular-lib-button.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-calendar-core.mjs +6 -6
- package/fesm2022/mn-angular-lib-calendar-core.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-calendar.mjs +118 -81
- package/fesm2022/mn-angular-lib-calendar.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-collection.mjs +36 -28
- package/fesm2022/mn-angular-lib-collection.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-core.mjs +17 -16
- package/fesm2022/mn-angular-lib-core.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-display.mjs +45 -37
- package/fesm2022/mn-angular-lib-display.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-forms.mjs +306 -99
- package/fesm2022/mn-angular-lib-forms.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-keyboard.mjs +3 -3
- package/fesm2022/mn-angular-lib-keyboard.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-modal-core.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-modal-ui.mjs +158 -100
- package/fesm2022/mn-angular-lib-modal-ui.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-modal.mjs +3 -3
- package/fesm2022/mn-angular-lib-modal.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-rich-text-editor.mjs +21 -12
- package/fesm2022/mn-angular-lib-rich-text-editor.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-segmented.mjs +3 -3
- package/fesm2022/mn-angular-lib-segmented.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-tab.mjs +14 -6
- package/fesm2022/mn-angular-lib-tab.mjs.map +1 -1
- package/package.json +4 -4
- package/types/mn-angular-lib-alert.d.ts +2 -2
- package/types/mn-angular-lib-calendar-core.d.ts +2 -2
- package/types/mn-angular-lib-calendar.d.ts +2 -0
- package/types/mn-angular-lib-core.d.ts +2 -2
- package/types/mn-angular-lib-display.d.ts +5 -0
- package/types/mn-angular-lib-forms.d.ts +10 -0
- package/types/mn-angular-lib-modal.d.ts +1 -1
- package/types/mn-angular-lib-tab.d.ts +7 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { Input, Component, InjectionToken, inject, ElementRef, DestroyRef, EventEmitter, Output, signal, computed, Renderer2,
|
|
2
|
+
import { Input, Component, InjectionToken, inject, ElementRef, ChangeDetectorRef, DestroyRef, EventEmitter, Output, signal, computed, Renderer2, Injector, afterNextRender, HostListener, ViewChild, TemplateRef } from '@angular/core';
|
|
3
3
|
import * as i1 from '@angular/common';
|
|
4
4
|
import { CommonModule, NgClass, NgTemplateOutlet } from '@angular/common';
|
|
5
5
|
import * as i1$1 from '@angular/forms';
|
|
@@ -244,10 +244,10 @@ const mnInputFieldVariants = tv({
|
|
|
244
244
|
class MnErrorMessage {
|
|
245
245
|
errorMessage;
|
|
246
246
|
id;
|
|
247
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
248
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "
|
|
247
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnErrorMessage, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
248
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "22.1.7", type: MnErrorMessage, isStandalone: true, selector: "mn-error-message", inputs: { errorMessage: "errorMessage", id: "id" }, ngImport: i0, template: "<div [id]=\"id + '-error'\" role=\"alert\" class=\"text-error mt-2 text-sm\">\n {{ errorMessage }}\n</div>\n" });
|
|
249
249
|
}
|
|
250
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
250
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnErrorMessage, decorators: [{
|
|
251
251
|
type: Component,
|
|
252
252
|
args: [{ selector: 'mn-error-message', imports: [], template: "<div [id]=\"id + '-error'\" role=\"alert\" class=\"text-error mt-2 text-sm\">\n {{ errorMessage }}\n</div>\n" }]
|
|
253
253
|
}], propDecorators: { errorMessage: [{
|
|
@@ -300,6 +300,8 @@ class MnInputField {
|
|
|
300
300
|
configService = inject(MnConfigService);
|
|
301
301
|
sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
|
|
302
302
|
explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
|
|
303
|
+
/** Marks the view when a locale change re-resolves the config (OnPush). */
|
|
304
|
+
cdr = inject(ChangeDetectorRef);
|
|
303
305
|
lang = inject(MnLanguageService);
|
|
304
306
|
destroyRef = inject(DestroyRef);
|
|
305
307
|
/** Current raw string value of the input element */
|
|
@@ -307,8 +309,7 @@ class MnInputField {
|
|
|
307
309
|
/** Whether the input is disabled */
|
|
308
310
|
isDisabled = false;
|
|
309
311
|
/** Callback function to notify Angular forms of value changes */
|
|
310
|
-
onChange = () => {
|
|
311
|
-
};
|
|
312
|
+
onChange = () => { };
|
|
312
313
|
/** Callback function to notify Angular forms when input is touched/blurred */
|
|
313
314
|
onTouched = () => { };
|
|
314
315
|
/**
|
|
@@ -334,9 +335,21 @@ class MnInputField {
|
|
|
334
335
|
this.ngControl.valueAccessor = this;
|
|
335
336
|
}
|
|
336
337
|
ngOnInit() {
|
|
338
|
+
// `showError` reads the control's touched/dirty/invalid state straight off the form.
|
|
339
|
+
// Those move from the forms API — `markAllAsTouched()` when the user tries to submit, a
|
|
340
|
+
// programmatic `setErrors` — never through an event on this component, so under OnPush
|
|
341
|
+
// the message would never appear. `events` covers value, status, touched and pristine.
|
|
342
|
+
const formControl = this.ngControl?.control;
|
|
343
|
+
if (formControl) {
|
|
344
|
+
const stateSub = formControl.events.subscribe(() => this.cdr.markForCheck());
|
|
345
|
+
this.destroyRef.onDestroy(() => stateSub.unsubscribe());
|
|
346
|
+
}
|
|
337
347
|
this.resolveConfig();
|
|
338
348
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
339
349
|
this.resolveConfig();
|
|
350
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
351
|
+
// marks this view for the locale change.
|
|
352
|
+
this.cdr.markForCheck();
|
|
340
353
|
});
|
|
341
354
|
this.destroyRef.onDestroy(() => sub.unsubscribe());
|
|
342
355
|
if (this.props.autoFocus) {
|
|
@@ -381,6 +394,9 @@ class MnInputField {
|
|
|
381
394
|
*/
|
|
382
395
|
writeValue(val) {
|
|
383
396
|
this.value = this.adapter.format(val);
|
|
397
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
398
|
+
// this view for it.
|
|
399
|
+
this.cdr.markForCheck();
|
|
384
400
|
}
|
|
385
401
|
/**
|
|
386
402
|
* Registers a callback function to be called when the input value changes.
|
|
@@ -405,6 +421,9 @@ class MnInputField {
|
|
|
405
421
|
*/
|
|
406
422
|
setDisabledState(isDisabled) {
|
|
407
423
|
this.isDisabled = isDisabled;
|
|
424
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
425
|
+
// from the forms API, with no event behind it.
|
|
426
|
+
this.cdr.markForCheck();
|
|
408
427
|
}
|
|
409
428
|
// ========== Event Handlers ==========
|
|
410
429
|
/**
|
|
@@ -558,7 +577,7 @@ class MnInputField {
|
|
|
558
577
|
if (!errors)
|
|
559
578
|
return [];
|
|
560
579
|
const errorKeys = Object.keys(errors);
|
|
561
|
-
return errorKeys.map(key => this.resolveErrorMessageForKey(key, errors));
|
|
580
|
+
return errorKeys.map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
562
581
|
}
|
|
563
582
|
/**
|
|
564
583
|
* Gets a single error message for the current control state.
|
|
@@ -596,10 +615,10 @@ class MnInputField {
|
|
|
596
615
|
disabled: this.isDisabled,
|
|
597
616
|
});
|
|
598
617
|
}
|
|
599
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
600
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
618
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnInputField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
619
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: MnInputField, isStandalone: true, selector: "mn-lib-input-field", inputs: { props: "props" }, host: { properties: { "style.display": "props?.fullWidth ? 'block' : null", "style.width": "props?.fullWidth ? '100%' : null" } }, ngImport: i0, template: "<div class=\"flex flex-col h-full\" [class.is-fullwidth]=\"props.fullWidth\">\n <!-- Label -->\n @if (uiConfig.label) {\n <label class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\" [attr.for]=\"resolvedId\">\n <p>{{ uiConfig.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n <!-- Input Element -->\n <input\n [id]=\"resolvedId\"\n [attr.aria-required]=\"isRequired() || null\"\n [attr.name]=\"resolvedName\"\n [type]=\"props.type\"\n [attr.placeholder]=\"uiConfig.placeholder || null\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || null\"\n [attr.aria-invalid]=\"showError || null\"\n [attr.aria-describedby]=\"showError ? errorDescribedBy : null\"\n [attr.aria-activedescendant]=\"props.ariaActiveDescendant || null\"\n [disabled]=\"isDisabled\"\n [attr.autocomplete]=\"props.autocomplete || null\"\n [attr.min]=\"minAttr\"\n [attr.max]=\"maxAttr\"\n [ngModel]=\"value\"\n [ngClass]=\"inputClasses\"\n (input)=\"handleInput(($any($event.target)).value)\"\n (search)=\"handleInput(($any($event.target)).value)\"\n (blur)=\"handleBlur()\"\n />\n\n <!-- Error Messages -->\n @if (showError) {\n <!-- Show all errors mode -->\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else {\n @if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n\n }\n }\n }\n</div>\n", styles: ["input::-webkit-search-cancel-button{cursor:pointer}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: MnErrorMessage, selector: "mn-error-message", inputs: ["errorMessage", "id"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.DefaultValueAccessor, selector: "input:not([type=checkbox]):not([ngNoCva])[formControlName],textarea:not([ngNoCva])[formControlName],input:not([type=checkbox]):not([ngNoCva])[formControl],textarea:not([ngNoCva])[formControl],input:not([type=checkbox]):not([ngNoCva])[ngModel],textarea:not([ngNoCva])[ngModel],[ngDefaultControl]" }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }] });
|
|
601
620
|
}
|
|
602
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
621
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnInputField, decorators: [{
|
|
603
622
|
type: Component,
|
|
604
623
|
args: [{ selector: 'mn-lib-input-field', standalone: true, imports: [CommonModule, NgClass, MnErrorMessage, FormsModule], host: {
|
|
605
624
|
// Native inputs (notably `type="date"`) have a platform-specific intrinsic width.
|
|
@@ -685,12 +704,13 @@ class MnCheckbox {
|
|
|
685
704
|
configService = inject(MnConfigService);
|
|
686
705
|
sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
|
|
687
706
|
explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
|
|
707
|
+
/** Marks the view when a locale change re-resolves the config (OnPush). */
|
|
708
|
+
cdr = inject(ChangeDetectorRef);
|
|
688
709
|
lang = inject(MnLanguageService);
|
|
689
710
|
destroyRef = inject(DestroyRef);
|
|
690
711
|
value = false;
|
|
691
712
|
isDisabled = false;
|
|
692
|
-
onChange = () => {
|
|
693
|
-
};
|
|
713
|
+
onChange = () => { };
|
|
694
714
|
onTouched = () => { };
|
|
695
715
|
builtInErrorMessages = {
|
|
696
716
|
required: 'This field is required',
|
|
@@ -700,9 +720,21 @@ class MnCheckbox {
|
|
|
700
720
|
this.ngControl.valueAccessor = this;
|
|
701
721
|
}
|
|
702
722
|
ngOnInit() {
|
|
723
|
+
// `showError` reads the control's touched/dirty/invalid state straight off the form.
|
|
724
|
+
// Those move from the forms API — `markAllAsTouched()` when the user tries to submit, a
|
|
725
|
+
// programmatic `setErrors` — never through an event on this component, so under OnPush
|
|
726
|
+
// the message would never appear. `events` covers value, status, touched and pristine.
|
|
727
|
+
const formControl = this.ngControl?.control;
|
|
728
|
+
if (formControl) {
|
|
729
|
+
const stateSub = formControl.events.subscribe(() => this.cdr.markForCheck());
|
|
730
|
+
this.destroyRef.onDestroy(() => stateSub.unsubscribe());
|
|
731
|
+
}
|
|
703
732
|
this.resolveConfig();
|
|
704
733
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
705
734
|
this.resolveConfig();
|
|
735
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
736
|
+
// marks this view for the locale change.
|
|
737
|
+
this.cdr.markForCheck();
|
|
706
738
|
});
|
|
707
739
|
this.destroyRef.onDestroy(() => sub.unsubscribe());
|
|
708
740
|
}
|
|
@@ -716,6 +748,9 @@ class MnCheckbox {
|
|
|
716
748
|
// ========== ControlValueAccessor Implementation ==========
|
|
717
749
|
writeValue(val) {
|
|
718
750
|
this.value = !!val;
|
|
751
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
752
|
+
// this view for it.
|
|
753
|
+
this.cdr.markForCheck();
|
|
719
754
|
}
|
|
720
755
|
/** Sync value from checked input when not using forms */
|
|
721
756
|
ngOnChanges() {
|
|
@@ -731,6 +766,9 @@ class MnCheckbox {
|
|
|
731
766
|
}
|
|
732
767
|
setDisabledState(isDisabled) {
|
|
733
768
|
this.isDisabled = isDisabled;
|
|
769
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
770
|
+
// from the forms API, with no event behind it.
|
|
771
|
+
this.cdr.markForCheck();
|
|
734
772
|
}
|
|
735
773
|
// ========== Event Handlers ==========
|
|
736
774
|
handleChange(checked) {
|
|
@@ -781,7 +819,7 @@ class MnCheckbox {
|
|
|
781
819
|
const errors = this.control?.errors;
|
|
782
820
|
if (!errors)
|
|
783
821
|
return [];
|
|
784
|
-
return Object.keys(errors).map(key => this.resolveErrorMessageForKey(key, errors));
|
|
822
|
+
return Object.keys(errors).map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
785
823
|
}
|
|
786
824
|
get errorMessage() {
|
|
787
825
|
const errors = this.control?.errors;
|
|
@@ -811,10 +849,10 @@ class MnCheckbox {
|
|
|
811
849
|
hover: this.props.hover,
|
|
812
850
|
});
|
|
813
851
|
}
|
|
814
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
815
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
852
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
853
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: MnCheckbox, isStandalone: true, selector: "mn-lib-checkbox", inputs: { props: "props", checked: "checked" }, outputs: { checkedChange: "checkedChange" }, usesOnChanges: true, ngImport: i0, template: "<div [class.is-fullwidth]=\"props.fullWidth\" class=\"flex flex-col items-start\">\n <label [attr.for]=\"resolvedId\" [ngClass]=\"wrapperClasses\"\n class=\"flex flex-row items-center gap-x-2 select-none cursor-pointer\">\n <input\n type=\"checkbox\"\n [id]=\"resolvedId\"\n [attr.aria-required]=\"isRequired() || null\"\n [attr.name]=\"resolvedName\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || props.label || null\"\n [attr.aria-invalid]=\"showError || null\"\n [attr.aria-describedby]=\"showError ? resolvedId + '-error' : null\"\n [disabled]=\"isDisabled\"\n [checked]=\"value\"\n [ngClass]=\"checkboxClasses\"\n (change)=\"handleChange($any($event.target).checked)\"\n (blur)=\"handleBlur()\"\n />\n @if (uiConfig.label || props.label) {\n <span class=\"flex flex-row items-center gap-x-0.5\">\n <span>{{ uiConfig.label || props.label }}</span>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </span>\n }\n </label>\n\n @if (showError) {\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1 mt-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else {\n @if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n }\n</div>\n", styles: [".mn-checkbox{position:relative;display:inline-block;flex-shrink:0;box-sizing:border-box;vertical-align:middle;cursor:pointer;appearance:none;-webkit-appearance:none;border-width:1px;border-style:solid;box-shadow:0 1px #0000001a inset,0 0 #0000 inset,0 0 #0000;transition:background-color .2s,box-shadow .2s}.mn-checkbox:before{content:\"\";display:block;width:100%;height:100%;rotate:45deg;background-color:currentColor;opacity:0;box-shadow:0 3px #ffffff1a inset;clip-path:polygon(20% 100%,20% 80%,50% 80%,50% 80%,70% 80%,70% 100%);transition:clip-path .3s,opacity .1s,rotate .3s,translate .3s;transition-delay:.1s}.mn-checkbox:focus-visible{outline-width:2px;outline-style:solid;outline-offset:2px}.mn-checkbox:checked,.mn-checkbox[aria-checked=true]{box-shadow:0 0 #0000 inset,0 8px 0 -4px #ffffff1a inset,0 1px #0000001a}.mn-checkbox:checked:before,.mn-checkbox[aria-checked=true]:before{opacity:1;clip-path:polygon(20% 100%,20% 80%,50% 80%,50% 0%,70% 0%,70% 100%)}.mn-checkbox:indeterminate:before{opacity:1;rotate:0deg;translate:0 -35%;clip-path:polygon(20% 100%,20% 80%,50% 80%,50% 80%,80% 80%,80% 100%)}.mn-checkbox:disabled{cursor:not-allowed;opacity:.2}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: MnErrorMessage, selector: "mn-error-message", inputs: ["errorMessage", "id"] }] });
|
|
816
854
|
}
|
|
817
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
855
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnCheckbox, decorators: [{
|
|
818
856
|
type: Component,
|
|
819
857
|
args: [{ selector: 'mn-lib-checkbox', standalone: true, imports: [NgClass, MnErrorMessage], template: "<div [class.is-fullwidth]=\"props.fullWidth\" class=\"flex flex-col items-start\">\n <label [attr.for]=\"resolvedId\" [ngClass]=\"wrapperClasses\"\n class=\"flex flex-row items-center gap-x-2 select-none cursor-pointer\">\n <input\n type=\"checkbox\"\n [id]=\"resolvedId\"\n [attr.aria-required]=\"isRequired() || null\"\n [attr.name]=\"resolvedName\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || props.label || null\"\n [attr.aria-invalid]=\"showError || null\"\n [attr.aria-describedby]=\"showError ? resolvedId + '-error' : null\"\n [disabled]=\"isDisabled\"\n [checked]=\"value\"\n [ngClass]=\"checkboxClasses\"\n (change)=\"handleChange($any($event.target).checked)\"\n (blur)=\"handleBlur()\"\n />\n @if (uiConfig.label || props.label) {\n <span class=\"flex flex-row items-center gap-x-0.5\">\n <span>{{ uiConfig.label || props.label }}</span>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </span>\n }\n </label>\n\n @if (showError) {\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1 mt-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else {\n @if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n }\n</div>\n", styles: [".mn-checkbox{position:relative;display:inline-block;flex-shrink:0;box-sizing:border-box;vertical-align:middle;cursor:pointer;appearance:none;-webkit-appearance:none;border-width:1px;border-style:solid;box-shadow:0 1px #0000001a inset,0 0 #0000 inset,0 0 #0000;transition:background-color .2s,box-shadow .2s}.mn-checkbox:before{content:\"\";display:block;width:100%;height:100%;rotate:45deg;background-color:currentColor;opacity:0;box-shadow:0 3px #ffffff1a inset;clip-path:polygon(20% 100%,20% 80%,50% 80%,50% 80%,70% 80%,70% 100%);transition:clip-path .3s,opacity .1s,rotate .3s,translate .3s;transition-delay:.1s}.mn-checkbox:focus-visible{outline-width:2px;outline-style:solid;outline-offset:2px}.mn-checkbox:checked,.mn-checkbox[aria-checked=true]{box-shadow:0 0 #0000 inset,0 8px 0 -4px #ffffff1a inset,0 1px #0000001a}.mn-checkbox:checked:before,.mn-checkbox[aria-checked=true]:before{opacity:1;clip-path:polygon(20% 100%,20% 80%,50% 80%,50% 0%,70% 0%,70% 100%)}.mn-checkbox:indeterminate:before{opacity:1;rotate:0deg;translate:0 -35%;clip-path:polygon(20% 100%,20% 80%,50% 80%,50% 80%,80% 80%,80% 100%)}.mn-checkbox:disabled{cursor:not-allowed;opacity:.2}\n"] }]
|
|
820
858
|
}], ctorParameters: () => [], propDecorators: { props: [{
|
|
@@ -907,6 +945,8 @@ class MnTextarea {
|
|
|
907
945
|
configService = inject(MnConfigService);
|
|
908
946
|
sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
|
|
909
947
|
explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
|
|
948
|
+
/** Marks the view when a locale change re-resolves the config (OnPush). */
|
|
949
|
+
cdr = inject(ChangeDetectorRef);
|
|
910
950
|
lang = inject(MnLanguageService);
|
|
911
951
|
destroyRef = inject(DestroyRef);
|
|
912
952
|
/** Current raw string value of the textarea element */
|
|
@@ -914,8 +954,7 @@ class MnTextarea {
|
|
|
914
954
|
/** Whether the textarea is disabled */
|
|
915
955
|
isDisabled = false;
|
|
916
956
|
/** Callback function to notify Angular forms of value changes */
|
|
917
|
-
onChange = () => {
|
|
918
|
-
};
|
|
957
|
+
onChange = () => { };
|
|
919
958
|
/** Callback function to notify Angular forms when textarea is touched/blurred */
|
|
920
959
|
onTouched = () => { };
|
|
921
960
|
/**
|
|
@@ -938,9 +977,21 @@ class MnTextarea {
|
|
|
938
977
|
this.ngControl.valueAccessor = this;
|
|
939
978
|
}
|
|
940
979
|
ngOnInit() {
|
|
980
|
+
// `showError` reads the control's touched/dirty/invalid state straight off the form.
|
|
981
|
+
// Those move from the forms API — `markAllAsTouched()` when the user tries to submit, a
|
|
982
|
+
// programmatic `setErrors` — never through an event on this component, so under OnPush
|
|
983
|
+
// the message would never appear. `events` covers value, status, touched and pristine.
|
|
984
|
+
const formControl = this.ngControl?.control;
|
|
985
|
+
if (formControl) {
|
|
986
|
+
const stateSub = formControl.events.subscribe(() => this.cdr.markForCheck());
|
|
987
|
+
this.destroyRef.onDestroy(() => stateSub.unsubscribe());
|
|
988
|
+
}
|
|
941
989
|
this.resolveConfig();
|
|
942
990
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
943
991
|
this.resolveConfig();
|
|
992
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
993
|
+
// marks this view for the locale change.
|
|
994
|
+
this.cdr.markForCheck();
|
|
944
995
|
});
|
|
945
996
|
this.destroyRef.onDestroy(() => sub.unsubscribe());
|
|
946
997
|
if (this.props.autoFocus) {
|
|
@@ -974,6 +1025,9 @@ class MnTextarea {
|
|
|
974
1025
|
*/
|
|
975
1026
|
writeValue(val) {
|
|
976
1027
|
this.value = val != null ? String(val) : null;
|
|
1028
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
1029
|
+
// this view for it.
|
|
1030
|
+
this.cdr.markForCheck();
|
|
977
1031
|
}
|
|
978
1032
|
/**
|
|
979
1033
|
* Registers a callback function to be called when the textarea value changes.
|
|
@@ -998,6 +1052,9 @@ class MnTextarea {
|
|
|
998
1052
|
*/
|
|
999
1053
|
setDisabledState(isDisabled) {
|
|
1000
1054
|
this.isDisabled = isDisabled;
|
|
1055
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
1056
|
+
// from the forms API, with no event behind it.
|
|
1057
|
+
this.cdr.markForCheck();
|
|
1001
1058
|
}
|
|
1002
1059
|
// ========== Event Handlers ==========
|
|
1003
1060
|
/**
|
|
@@ -1098,7 +1155,7 @@ class MnTextarea {
|
|
|
1098
1155
|
if (!errors)
|
|
1099
1156
|
return [];
|
|
1100
1157
|
const errorKeys = Object.keys(errors);
|
|
1101
|
-
return errorKeys.map(key => this.resolveErrorMessageForKey(key, errors));
|
|
1158
|
+
return errorKeys.map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
1102
1159
|
}
|
|
1103
1160
|
/**
|
|
1104
1161
|
* Gets a single error message for the current control state.
|
|
@@ -1134,10 +1191,10 @@ class MnTextarea {
|
|
|
1134
1191
|
resize: this.props.resize,
|
|
1135
1192
|
});
|
|
1136
1193
|
}
|
|
1137
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1138
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
1194
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnTextarea, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1195
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: MnTextarea, isStandalone: true, selector: "mn-lib-textarea", inputs: { props: "props" }, ngImport: i0, template: "<div class=\"flex flex-col h-full\" [class.is-fullwidth]=\"props.fullWidth\">\n <!-- Label -->\n @if (uiConfig.label || props.label) {\n <label class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\" [attr.for]=\"resolvedId\">\n <p>{{ uiConfig.label || props.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n <!-- Textarea Element -->\n <textarea\n [id]=\"resolvedId\"\n [attr.aria-required]=\"isRequired() || null\"\n [attr.name]=\"resolvedName\"\n [attr.placeholder]=\"uiConfig.placeholder || null\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || null\"\n [attr.aria-invalid]=\"showError || null\"\n [attr.aria-describedby]=\"showError ? errorDescribedBy : null\"\n [disabled]=\"isDisabled\"\n [attr.autocomplete]=\"props.autocomplete || null\"\n [attr.rows]=\"props.rows ?? null\"\n [attr.cols]=\"props.cols ?? null\"\n [ngClass]=\"textareaClasses\"\n (input)=\"handleInput(($any($event.target)).value)\"\n (blur)=\"handleBlur()\"\n >{{ value ?? '' }}</textarea>\n\n <!-- Error Messages -->\n @if (showError) {\n <!-- Show all errors mode -->\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else {\n @if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n }\n</div>\n", dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "component", type: MnErrorMessage, selector: "mn-error-message", inputs: ["errorMessage", "id"] }] });
|
|
1139
1196
|
}
|
|
1140
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1197
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnTextarea, decorators: [{
|
|
1141
1198
|
type: Component,
|
|
1142
1199
|
args: [{ selector: 'mn-lib-textarea', standalone: true, imports: [NgClass, MnErrorMessage], template: "<div class=\"flex flex-col h-full\" [class.is-fullwidth]=\"props.fullWidth\">\n <!-- Label -->\n @if (uiConfig.label || props.label) {\n <label class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\" [attr.for]=\"resolvedId\">\n <p>{{ uiConfig.label || props.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n <!-- Textarea Element -->\n <textarea\n [id]=\"resolvedId\"\n [attr.aria-required]=\"isRequired() || null\"\n [attr.name]=\"resolvedName\"\n [attr.placeholder]=\"uiConfig.placeholder || null\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || null\"\n [attr.aria-invalid]=\"showError || null\"\n [attr.aria-describedby]=\"showError ? errorDescribedBy : null\"\n [disabled]=\"isDisabled\"\n [attr.autocomplete]=\"props.autocomplete || null\"\n [attr.rows]=\"props.rows ?? null\"\n [attr.cols]=\"props.cols ?? null\"\n [ngClass]=\"textareaClasses\"\n (input)=\"handleInput(($any($event.target)).value)\"\n (blur)=\"handleBlur()\"\n >{{ value ?? '' }}</textarea>\n\n <!-- Error Messages -->\n @if (showError) {\n <!-- Show all errors mode -->\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else {\n @if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n }\n</div>\n" }]
|
|
1143
1200
|
}], ctorParameters: () => [], propDecorators: { props: [{
|
|
@@ -1193,12 +1250,13 @@ class MnDatetime {
|
|
|
1193
1250
|
configService = inject(MnConfigService);
|
|
1194
1251
|
sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
|
|
1195
1252
|
explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
|
|
1253
|
+
/** Marks the view when a locale change re-resolves the config (OnPush). */
|
|
1254
|
+
cdr = inject(ChangeDetectorRef);
|
|
1196
1255
|
lang = inject(MnLanguageService);
|
|
1197
1256
|
destroyRef = inject(DestroyRef);
|
|
1198
1257
|
value = null;
|
|
1199
1258
|
isDisabled = false;
|
|
1200
|
-
onChange = () => {
|
|
1201
|
-
};
|
|
1259
|
+
onChange = () => { };
|
|
1202
1260
|
onTouched = () => { };
|
|
1203
1261
|
builtInErrorMessages = {
|
|
1204
1262
|
required: 'This field is required',
|
|
@@ -1210,9 +1268,21 @@ class MnDatetime {
|
|
|
1210
1268
|
this.ngControl.valueAccessor = this;
|
|
1211
1269
|
}
|
|
1212
1270
|
ngOnInit() {
|
|
1271
|
+
// `showError` reads the control's touched/dirty/invalid state straight off the form.
|
|
1272
|
+
// Those move from the forms API — `markAllAsTouched()` when the user tries to submit, a
|
|
1273
|
+
// programmatic `setErrors` — never through an event on this component, so under OnPush
|
|
1274
|
+
// the message would never appear. `events` covers value, status, touched and pristine.
|
|
1275
|
+
const formControl = this.ngControl?.control;
|
|
1276
|
+
if (formControl) {
|
|
1277
|
+
const stateSub = formControl.events.subscribe(() => this.cdr.markForCheck());
|
|
1278
|
+
this.destroyRef.onDestroy(() => stateSub.unsubscribe());
|
|
1279
|
+
}
|
|
1213
1280
|
this.resolveConfig();
|
|
1214
1281
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
1215
1282
|
this.resolveConfig();
|
|
1283
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
1284
|
+
// marks this view for the locale change.
|
|
1285
|
+
this.cdr.markForCheck();
|
|
1216
1286
|
});
|
|
1217
1287
|
this.destroyRef.onDestroy(() => sub.unsubscribe());
|
|
1218
1288
|
}
|
|
@@ -1243,6 +1313,9 @@ class MnDatetime {
|
|
|
1243
1313
|
else {
|
|
1244
1314
|
this.value = null;
|
|
1245
1315
|
}
|
|
1316
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
1317
|
+
// this view for it.
|
|
1318
|
+
this.cdr.markForCheck();
|
|
1246
1319
|
}
|
|
1247
1320
|
registerOnChange(fn) {
|
|
1248
1321
|
this.onChange = fn;
|
|
@@ -1252,6 +1325,9 @@ class MnDatetime {
|
|
|
1252
1325
|
}
|
|
1253
1326
|
setDisabledState(isDisabled) {
|
|
1254
1327
|
this.isDisabled = isDisabled;
|
|
1328
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
1329
|
+
// from the forms API, with no event behind it.
|
|
1330
|
+
this.cdr.markForCheck();
|
|
1255
1331
|
}
|
|
1256
1332
|
// ========== Event Handlers ==========
|
|
1257
1333
|
handleInput(raw) {
|
|
@@ -1309,7 +1385,7 @@ class MnDatetime {
|
|
|
1309
1385
|
const errors = this.control?.errors;
|
|
1310
1386
|
if (!errors)
|
|
1311
1387
|
return [];
|
|
1312
|
-
return Object.keys(errors).map(key => this.resolveErrorMessageForKey(key, errors));
|
|
1388
|
+
return Object.keys(errors).map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
1313
1389
|
}
|
|
1314
1390
|
get errorMessage() {
|
|
1315
1391
|
const errors = this.control?.errors;
|
|
@@ -1341,7 +1417,7 @@ class MnDatetime {
|
|
|
1341
1417
|
const explicit = this.uiConfig.ariaLabel || this.uiConfig.label || this.props.label;
|
|
1342
1418
|
if (explicit)
|
|
1343
1419
|
return explicit;
|
|
1344
|
-
return this.iconOnly ?
|
|
1420
|
+
return this.iconOnly ? this.uiConfig.placeholder || this.props.placeholder || null : null;
|
|
1345
1421
|
}
|
|
1346
1422
|
/** Lucide icon size (px) tracking the field size, used only in the icon-only variant. */
|
|
1347
1423
|
get iconSize() {
|
|
@@ -1383,10 +1459,10 @@ class MnDatetime {
|
|
|
1383
1459
|
'focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-primary',
|
|
1384
1460
|
].join(' ');
|
|
1385
1461
|
}
|
|
1386
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1387
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
1462
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnDatetime, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1463
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: MnDatetime, isStandalone: true, selector: "mn-lib-datetime", inputs: { props: "props" }, host: { properties: { "style.display": "props?.fullWidth ? 'block' : null", "style.width": "props?.fullWidth ? '100%' : null" } }, ngImport: i0, template: "<div class=\"flex flex-col h-full\" [class.is-fullwidth]=\"props.fullWidth\">\n @if (uiConfig.label || props.label) {\n <label class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\" [attr.for]=\"resolvedId\">\n <p>{{ uiConfig.label || props.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n @if (iconOnly) {\n <!--\n Icon-only variant: a bordered box holding a calendar icon, with the native\n input layered on top at zero opacity. The box carries the look (border,\n background, radius, hover, focus ring); the input stays a real, focusable\n form control that opens the picker on click. `focus-within` on the box\n surfaces the keyboard focus ring, since the input itself is transparent.\n -->\n <div [ngClass]=\"iconBoxClasses\">\n <svg [size]=\"iconSize\" [lucideIcon]=\"icons.CalendarDays\" aria-hidden=\"true\" class=\"pointer-events-none\"></svg>\n <ng-container [ngTemplateOutlet]=\"inputTemplate\"></ng-container>\n </div>\n } @else {\n <ng-container [ngTemplateOutlet]=\"inputTemplate\"></ng-container>\n }\n\n @if (showError) {\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else {\n @if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n }\n</div>\n\n<!-- Single input definition, rendered either bare or inside the icon box above,\n so both variants share exactly the same bindings and behaviour. -->\n<ng-template #inputTemplate>\n <input\n #dateInput\n [id]=\"resolvedId\"\n [attr.aria-required]=\"isRequired() || null\"\n [attr.name]=\"resolvedName\"\n [type]=\"resolvedMode\"\n [attr.placeholder]=\"uiConfig.placeholder || props.placeholder || null\"\n [attr.aria-label]=\"resolvedAriaLabel\"\n [attr.aria-invalid]=\"showError || null\"\n [attr.aria-describedby]=\"showError ? resolvedId + '-error' : null\"\n [disabled]=\"isDisabled\"\n [attr.min]=\"props.min || null\"\n [attr.max]=\"props.max || null\"\n [attr.step]=\"props.step || null\"\n [value]=\"value ?? ''\"\n [ngClass]=\"inputClasses\"\n (click)=\"handleClick(dateInput)\"\n (input)=\"handleInput(($any($event.target)).value)\"\n (blur)=\"handleBlur()\"\n />\n</ng-template>\n", styles: ["input::-webkit-calendar-picker-indicator{cursor:pointer}@media(pointer:coarse){input[type=date],input[type=datetime-local],input[type=time],input[type=month],input[type=week]{-webkit-appearance:none;appearance:none;min-width:0;box-sizing:border-box}}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: MnErrorMessage, selector: "mn-error-message", inputs: ["errorMessage", "id"] }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }] });
|
|
1388
1464
|
}
|
|
1389
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1465
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnDatetime, decorators: [{
|
|
1390
1466
|
type: Component,
|
|
1391
1467
|
args: [{ selector: 'mn-lib-datetime', standalone: true, imports: [NgClass, NgTemplateOutlet, MnErrorMessage, LucideDynamicIcon], host: {
|
|
1392
1468
|
// Native date/time inputs have a platform-specific intrinsic width. Without an
|
|
@@ -1506,22 +1582,30 @@ class MnFileInput {
|
|
|
1506
1582
|
/** Resolved UI configuration for the file input. */
|
|
1507
1583
|
uiConfig = {};
|
|
1508
1584
|
/** Currently selected files (always an array internally). */
|
|
1509
|
-
files = signal([],
|
|
1585
|
+
files = signal([], /* @ts-ignore */
|
|
1586
|
+
...(ngDevMode ? [{ debugName: "files" }] : /* istanbul ignore next */ []));
|
|
1510
1587
|
/** True while files are dragged over the dropzone ("release to drop" state). */
|
|
1511
|
-
isDragging = signal(false,
|
|
1588
|
+
isDragging = signal(false, /* @ts-ignore */
|
|
1589
|
+
...(ngDevMode ? [{ debugName: "isDragging" }] : /* istanbul ignore next */ []));
|
|
1512
1590
|
/** Transient message for a rejected selection (accept/maxSize/maxFiles). */
|
|
1513
|
-
internalError = signal(null,
|
|
1591
|
+
internalError = signal(null, /* @ts-ignore */
|
|
1592
|
+
...(ngDevMode ? [{ debugName: "internalError" }] : /* istanbul ignore next */ []));
|
|
1514
1593
|
configService = inject(MnConfigService);
|
|
1515
1594
|
sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
|
|
1516
1595
|
explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
|
|
1596
|
+
/** Marks the view when a locale change re-resolves the config (OnPush). */
|
|
1597
|
+
cdr = inject(ChangeDetectorRef);
|
|
1517
1598
|
lang = inject(MnLanguageService);
|
|
1518
1599
|
destroyRef = inject(DestroyRef);
|
|
1519
1600
|
/** Object-URL previews aligned to {@link files}; null for non-image entries. */
|
|
1520
|
-
previewUrls = signal([],
|
|
1601
|
+
previewUrls = signal([], /* @ts-ignore */
|
|
1602
|
+
...(ngDevMode ? [{ debugName: "previewUrls" }] : /* istanbul ignore next */ []));
|
|
1521
1603
|
/** True once the user removed the single existing image. */
|
|
1522
|
-
currentCleared = signal(false,
|
|
1604
|
+
currentCleared = signal(false, /* @ts-ignore */
|
|
1605
|
+
...(ngDevMode ? [{ debugName: "currentCleared" }] : /* istanbul ignore next */ []));
|
|
1523
1606
|
/** Indices of removed existing images (multiple mode). */
|
|
1524
|
-
removedExisting = signal(new Set(),
|
|
1607
|
+
removedExisting = signal(new Set(), /* @ts-ignore */
|
|
1608
|
+
...(ngDevMode ? [{ debugName: "removedExisting" }] : /* istanbul ignore next */ []));
|
|
1525
1609
|
/** Renderable entries: existing images (when nothing newer hides them) then new files. */
|
|
1526
1610
|
displayItems = computed(() => {
|
|
1527
1611
|
const items = [];
|
|
@@ -1548,7 +1632,8 @@ class MnFileInput {
|
|
|
1548
1632
|
});
|
|
1549
1633
|
});
|
|
1550
1634
|
return items;
|
|
1551
|
-
},
|
|
1635
|
+
}, /* @ts-ignore */
|
|
1636
|
+
...(ngDevMode ? [{ debugName: "displayItems" }] : /* istanbul ignore next */ []));
|
|
1552
1637
|
/** Disabled state pushed by the forms API. */
|
|
1553
1638
|
formDisabled = false;
|
|
1554
1639
|
/**
|
|
@@ -1605,7 +1690,7 @@ class MnFileInput {
|
|
|
1605
1690
|
size: this.props.size,
|
|
1606
1691
|
borderRadius: this.props.borderRadius,
|
|
1607
1692
|
shadow: this.props.shadow,
|
|
1608
|
-
fullWidth: this.props.fullWidth ??
|
|
1693
|
+
fullWidth: this.props.fullWidth ?? this.displayMode !== 'compact',
|
|
1609
1694
|
dropzone: this.displayMode === 'dropzone',
|
|
1610
1695
|
dragging: this.isDragging(),
|
|
1611
1696
|
disabled: this.isDisabled,
|
|
@@ -1636,8 +1721,21 @@ class MnFileInput {
|
|
|
1636
1721
|
return this.resolveControlError(this.pickErrorKey(errors), errors);
|
|
1637
1722
|
}
|
|
1638
1723
|
ngOnInit() {
|
|
1724
|
+
// `showError` reads the control's touched/dirty/invalid state straight off the form.
|
|
1725
|
+
// Those move from the forms API — `markAllAsTouched()` when the user tries to submit, a
|
|
1726
|
+
// programmatic `setErrors` — never through an event on this component, so under OnPush
|
|
1727
|
+
// the message would never appear. `events` covers value, status, touched and pristine.
|
|
1728
|
+
const formControl = this.ngControl?.control;
|
|
1729
|
+
if (formControl) {
|
|
1730
|
+
const stateSub = formControl.events.subscribe(() => this.cdr.markForCheck());
|
|
1731
|
+
this.destroyRef.onDestroy(() => stateSub.unsubscribe());
|
|
1732
|
+
}
|
|
1639
1733
|
this.resolveConfig();
|
|
1640
|
-
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() =>
|
|
1734
|
+
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
1735
|
+
this.resolveConfig();
|
|
1736
|
+
// See mn-input-field: OnPush needs the locale change announced.
|
|
1737
|
+
this.cdr.markForCheck();
|
|
1738
|
+
});
|
|
1641
1739
|
this.destroyRef.onDestroy(() => sub.unsubscribe());
|
|
1642
1740
|
this.destroyRef.onDestroy(() => this.revokeAll());
|
|
1643
1741
|
}
|
|
@@ -1646,10 +1744,15 @@ class MnFileInput {
|
|
|
1646
1744
|
* @param val A `File`, an array of `File`, or null/undefined.
|
|
1647
1745
|
*/
|
|
1648
1746
|
writeValue(val) {
|
|
1649
|
-
const next = Array.isArray(val)
|
|
1650
|
-
|
|
1747
|
+
const next = Array.isArray(val)
|
|
1748
|
+
? val.filter((f) => f instanceof File)
|
|
1749
|
+
: val instanceof File
|
|
1750
|
+
? [val]
|
|
1651
1751
|
: [];
|
|
1652
1752
|
this.setFiles(next);
|
|
1753
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
1754
|
+
// this view for it.
|
|
1755
|
+
this.cdr.markForCheck();
|
|
1653
1756
|
}
|
|
1654
1757
|
/**
|
|
1655
1758
|
* Registers the form's change callback.
|
|
@@ -1672,6 +1775,9 @@ class MnFileInput {
|
|
|
1672
1775
|
*/
|
|
1673
1776
|
setDisabledState(isDisabled) {
|
|
1674
1777
|
this.formDisabled = isDisabled;
|
|
1778
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
1779
|
+
// from the forms API, with no event behind it.
|
|
1780
|
+
this.cdr.markForCheck();
|
|
1675
1781
|
}
|
|
1676
1782
|
/**
|
|
1677
1783
|
* Handles a file-picker change: validates the incoming files against the
|
|
@@ -1776,12 +1882,10 @@ class MnFileInput {
|
|
|
1776
1882
|
return (file.type ?? '').startsWith('image/');
|
|
1777
1883
|
}
|
|
1778
1884
|
/** Callback to notify Angular forms of value changes. */
|
|
1779
|
-
onChange = () => {
|
|
1780
|
-
};
|
|
1885
|
+
onChange = () => { };
|
|
1781
1886
|
// ========== Error handling (control validators) ==========
|
|
1782
1887
|
/** Callback to notify Angular forms when the control is touched. */
|
|
1783
|
-
onTouched = () => {
|
|
1784
|
-
};
|
|
1888
|
+
onTouched = () => { };
|
|
1785
1889
|
/** Resolves UI strings from config, layering built-in defaults and prop overrides. */
|
|
1786
1890
|
resolveConfig() {
|
|
1787
1891
|
const instanceId = this.explicitInstanceId || `mn-file-input-${this.props.id}`;
|
|
@@ -1925,7 +2029,10 @@ class MnFileInput {
|
|
|
1925
2029
|
const accept = this.props.accept;
|
|
1926
2030
|
if (!accept)
|
|
1927
2031
|
return true;
|
|
1928
|
-
const tokens = accept
|
|
2032
|
+
const tokens = accept
|
|
2033
|
+
.split(',')
|
|
2034
|
+
.map((t) => t.trim().toLowerCase())
|
|
2035
|
+
.filter(Boolean);
|
|
1929
2036
|
if (tokens.length === 0)
|
|
1930
2037
|
return true;
|
|
1931
2038
|
const name = file.name.toLowerCase();
|
|
@@ -1952,10 +2059,10 @@ class MnFileInput {
|
|
|
1952
2059
|
const segment = clean.substring(clean.lastIndexOf('/') + 1);
|
|
1953
2060
|
return segment || 'image';
|
|
1954
2061
|
}
|
|
1955
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1956
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: MnFileInput, isStandalone: true, selector: "mn-lib-file-input", inputs: { props: "props" }, outputs: { filesChange: "filesChange", cleared: "cleared" }, ngImport: i0, template: "<!--\n Drag handling sits on the wrapper so a drop anywhere inside the control counts.\n onDragEnter/onDragLeave balance out as the drag crosses children, and\n acceptsDrag() ignores the modes that have no drop target.\n-->\n<div\n (dragenter)=\"onDragEnter($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop($event)\"\n [class.w-full]=\"props.fullWidth !== false && displayMode !== 'compact'\"\n class=\"flex flex-col\">\n <!-- Label -->\n @if (uiConfig.label) {\n <label [attr.for]=\"resolvedId\" class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\">\n <p>{{ uiConfig.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n <!-- Hidden native file input shared by every trigger -->\n <input\n #fileInput\n (change)=\"onFileSelected($event)\"\n [accept]=\"acceptAttr\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || null\"\n [attr.multiple]=\"props.multiple || null\"\n [attr.name]=\"resolvedName\"\n [disabled]=\"isDisabled\"\n [id]=\"resolvedId\"\n [attr.aria-required]=\"isRequired() || null\"\n class=\"hidden\"\n type=\"file\"\n />\n\n @switch (displayMode) {\n <!-- Compact: inline button + filename chips -->\n @case ('compact') {\n <div class=\"flex flex-wrap items-center gap-2\">\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n [ngClass]=\"controlClasses\"\n class=\"inline-flex items-center gap-2 cursor-pointer hover:bg-base-200\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.Upload\" [size]=\"18\"></svg>\n <span class=\"text-sm\">{{ uiConfig.replaceLabel }}</span>\n </button>\n @for (item of displayItems(); track itemKey(item)) {\n <span class=\"inline-flex items-center gap-1 text-sm text-base-content/70\">\n @if (item.isImage && item.previewUrl) {\n <img [src]=\"item.previewUrl\" alt=\"\" class=\"h-6 w-6 rounded object-cover\"/>\n } @else {\n <svg [lucideIcon]=\"icons.File\" [size]=\"16\" class=\"text-base-content/50\"></svg>\n }\n <span class=\"max-w-40 truncate\">{{ item.name }}</span>\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"text-base-content/50 hover:text-error cursor-pointer\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.X\" [size]=\"14\"></svg>\n </button>\n </span>\n }\n </div>\n }\n\n <!-- List: compact rows of file icon + name + size -->\n @case ('list') {\n <div class=\"relative flex flex-col\">\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n [ngClass]=\"controlClasses\"\n class=\"flex flex-row items-center justify-center gap-2 cursor-pointer hover:bg-base-200\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.Upload\" [size]=\"18\"></svg>\n <span class=\"text-sm\">{{ uiConfig.replaceLabel }}</span>\n </button>\n @if (displayItems().length > 0) {\n <div class=\"mt-2 flex flex-col gap-1\">\n @for (item of displayItems(); track itemKey(item)) {\n <div class=\"flex items-center gap-2 rounded-lg bg-base-200 px-3 py-1.5 text-sm\">\n <svg [lucideIcon]=\"icons.File\" [size]=\"16\" class=\"text-base-content/50\"></svg>\n <span class=\"flex-1 truncate text-base-content\">{{ item.name }}</span>\n @if (item.sizeLabel) {\n <span class=\"text-base-content/50\">{{ item.sizeLabel }}</span>\n }\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"text-base-content/50 hover:text-error cursor-pointer\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.X\" [size]=\"16\"></svg>\n </button>\n </div>\n }\n </div>\n }\n @if (isDragging()) {\n <ng-container [ngTemplateOutlet]=\"dropOverlay\"></ng-container>\n }\n </div>\n }\n\n <!-- Thumbnail: grid of tiles with overlay remove + add tile -->\n @case ('thumbnail') {\n <div class=\"relative flex flex-wrap gap-3\">\n @for (item of displayItems(); track itemKey(item)) {\n <div class=\"relative h-24 w-24 overflow-hidden rounded-xl border border-base-300 bg-base-100\">\n @if (item.isImage && item.previewUrl) {\n <img [src]=\"item.previewUrl\" alt=\"\" class=\"h-full w-full object-cover\"/>\n } @else {\n <div class=\"flex h-full w-full flex-col items-center justify-center gap-1 p-1 text-center\">\n <svg [lucideIcon]=\"icons.File\" [size]=\"22\" class=\"text-base-content/50\"></svg>\n <span class=\"w-full truncate text-xs text-base-content/60\">{{ item.name }}</span>\n </div>\n }\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"inline-flex h-6 w-6 items-center justify-center rounded-full cursor-pointer transition-colors absolute top-1 right-1 border-none bg-black/60 text-white hover:bg-black/80\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.X\" [size]=\"14\"></svg>\n </button>\n </div>\n }\n @if (props.multiple || displayItems().length === 0) {\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n class=\"flex h-24 w-24 flex-col items-center justify-center gap-1 rounded-xl border-2 border-dashed border-base-300 text-base-content/50 hover:border-primary cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.ImagePlus\" [size]=\"22\"></svg>\n </button>\n }\n @if (isDragging()) {\n <ng-container [ngTemplateOutlet]=\"dropOverlay\"></ng-container>\n }\n </div>\n }\n\n <!-- Dropzone (default): large dashed area + preview rows -->\n @default {\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n [ngClass]=\"controlClasses\"\n type=\"button\">\n <!-- Inert so a drag crossing the icon/hint never reads as leaving the zone -->\n <span aria-live=\"polite\" class=\"pointer-events-none flex flex-col items-center gap-2\">\n @if (isDragging()) {\n <svg [size]=\"28\" class=\"animate-bounce text-primary\" [lucideIcon]=\"icons.Upload\"></svg>\n <span class=\"text-sm font-medium text-primary\">{{ uiConfig.dropActiveHint }}</span>\n } @else {\n <svg [size]=\"28\" class=\"text-base-content/40\" [lucideIcon]=\"icons.ImagePlus\"></svg>\n <span class=\"text-sm text-base-content/60\">{{ uiConfig.dropzoneHint }}</span>\n }\n </span>\n </button>\n @if (displayItems().length > 0) {\n <div class=\"mt-2 flex flex-col gap-2\">\n @for (item of displayItems(); track itemKey(item)) {\n <div class=\"flex items-center gap-3 rounded-lg bg-base-200 p-2\">\n @if (item.isImage && item.previewUrl) {\n <img [src]=\"item.previewUrl\" alt=\"\" class=\"h-12 w-12 rounded-md object-cover\"/>\n } @else {\n <svg [lucideIcon]=\"icons.File\" [size]=\"24\" class=\"text-base-content/50\"></svg>\n }\n <span class=\"flex-1 truncate text-sm text-base-content\">{{ item.name }}</span>\n @if (item.sizeLabel) {\n <span class=\"text-sm text-base-content/50\">{{ item.sizeLabel }}</span>\n }\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"inline-flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors text-error hover:bg-error/10\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.Trash2\" [size]=\"16\"></svg>\n </button>\n </div>\n }\n </div>\n }\n }\n }\n\n <!-- Selection-limit error (accept / maxSize / maxFiles) -->\n @if (internalError(); as msg) {\n <mn-error-message [errorMessage]=\"msg\" [id]=\"resolvedId + '-selection'\"></mn-error-message>\n }\n\n <!-- Control validation errors -->\n @if (showError) {\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n</div>\n\n<!--\n \"Release to drop\" cover for the modes that render their own layout instead of a\n dropzone. Absolutely positioned so arming it never shifts the layout, and inert\n so the drag keeps reaching the elements underneath.\n-->\n<ng-template #dropOverlay>\n <div\n aria-live=\"polite\"\n class=\"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-primary bg-base-100/90 text-center\">\n <svg [size]=\"24\" class=\"animate-bounce text-primary\" [lucideIcon]=\"icons.Upload\"></svg>\n <span class=\"px-2 text-sm font-medium text-primary\">{{ uiConfig.dropActiveHint }}</span>\n </div>\n</ng-template>\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: MnErrorMessage, selector: "mn-error-message", inputs: ["errorMessage", "id"] }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }] });
|
|
2062
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnFileInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2063
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: MnFileInput, isStandalone: true, selector: "mn-lib-file-input", inputs: { props: "props" }, outputs: { filesChange: "filesChange", cleared: "cleared" }, ngImport: i0, template: "<!--\n Drag handling sits on the wrapper so a drop anywhere inside the control counts.\n onDragEnter/onDragLeave balance out as the drag crosses children, and\n acceptsDrag() ignores the modes that have no drop target.\n-->\n<div\n (dragenter)=\"onDragEnter($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop($event)\"\n [class.w-full]=\"props.fullWidth !== false && displayMode !== 'compact'\"\n class=\"flex flex-col\">\n <!-- Label -->\n @if (uiConfig.label) {\n <label [attr.for]=\"resolvedId\" class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\">\n <p>{{ uiConfig.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n <!-- Hidden native file input shared by every trigger -->\n <input\n #fileInput\n (change)=\"onFileSelected($event)\"\n [accept]=\"acceptAttr\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || null\"\n [attr.multiple]=\"props.multiple || null\"\n [attr.name]=\"resolvedName\"\n [disabled]=\"isDisabled\"\n [id]=\"resolvedId\"\n [attr.aria-required]=\"isRequired() || null\"\n class=\"hidden\"\n type=\"file\"\n />\n\n @switch (displayMode) {\n <!-- Compact: inline button + filename chips -->\n @case ('compact') {\n <div class=\"flex flex-wrap items-center gap-2\">\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n [ngClass]=\"controlClasses\"\n class=\"inline-flex items-center gap-2 cursor-pointer hover:bg-base-200\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.Upload\" [size]=\"18\"></svg>\n <span class=\"text-sm\">{{ uiConfig.replaceLabel }}</span>\n </button>\n @for (item of displayItems(); track itemKey(item)) {\n <span class=\"inline-flex items-center gap-1 text-sm text-base-content/70\">\n @if (item.isImage && item.previewUrl) {\n <img [src]=\"item.previewUrl\" alt=\"\" class=\"h-6 w-6 rounded object-cover\"/>\n } @else {\n <svg [lucideIcon]=\"icons.File\" [size]=\"16\" class=\"text-base-content/50\"></svg>\n }\n <span class=\"max-w-40 truncate\">{{ item.name }}</span>\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"text-base-content/50 hover:text-error cursor-pointer\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.X\" [size]=\"14\"></svg>\n </button>\n </span>\n }\n </div>\n }\n\n <!-- List: compact rows of file icon + name + size -->\n @case ('list') {\n <div class=\"relative flex flex-col\">\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n [ngClass]=\"controlClasses\"\n class=\"flex flex-row items-center justify-center gap-2 cursor-pointer hover:bg-base-200\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.Upload\" [size]=\"18\"></svg>\n <span class=\"text-sm\">{{ uiConfig.replaceLabel }}</span>\n </button>\n @if (displayItems().length > 0) {\n <div class=\"mt-2 flex flex-col gap-1\">\n @for (item of displayItems(); track itemKey(item)) {\n <div class=\"flex items-center gap-2 rounded-lg bg-base-200 px-3 py-1.5 text-sm\">\n <svg [lucideIcon]=\"icons.File\" [size]=\"16\" class=\"text-base-content/50\"></svg>\n <span class=\"flex-1 truncate text-base-content\">{{ item.name }}</span>\n @if (item.sizeLabel) {\n <span class=\"text-base-content/50\">{{ item.sizeLabel }}</span>\n }\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"text-base-content/50 hover:text-error cursor-pointer\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.X\" [size]=\"16\"></svg>\n </button>\n </div>\n }\n </div>\n }\n @if (isDragging()) {\n <ng-container [ngTemplateOutlet]=\"dropOverlay\"></ng-container>\n }\n </div>\n }\n\n <!-- Thumbnail: grid of tiles with overlay remove + add tile -->\n @case ('thumbnail') {\n <div class=\"relative flex flex-wrap gap-3\">\n @for (item of displayItems(); track itemKey(item)) {\n <div class=\"relative h-24 w-24 overflow-hidden rounded-xl border border-base-300 bg-base-100\">\n @if (item.isImage && item.previewUrl) {\n <img [src]=\"item.previewUrl\" alt=\"\" class=\"h-full w-full object-cover\"/>\n } @else {\n <div class=\"flex h-full w-full flex-col items-center justify-center gap-1 p-1 text-center\">\n <svg [lucideIcon]=\"icons.File\" [size]=\"22\" class=\"text-base-content/50\"></svg>\n <span class=\"w-full truncate text-xs text-base-content/60\">{{ item.name }}</span>\n </div>\n }\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"inline-flex h-6 w-6 items-center justify-center rounded-full cursor-pointer transition-colors absolute top-1 right-1 border-none bg-black/60 text-white hover:bg-black/80\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.X\" [size]=\"14\"></svg>\n </button>\n </div>\n }\n @if (props.multiple || displayItems().length === 0) {\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n class=\"flex h-24 w-24 flex-col items-center justify-center gap-1 rounded-xl border-2 border-dashed border-base-300 text-base-content/50 hover:border-primary cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.ImagePlus\" [size]=\"22\"></svg>\n </button>\n }\n @if (isDragging()) {\n <ng-container [ngTemplateOutlet]=\"dropOverlay\"></ng-container>\n }\n </div>\n }\n\n <!-- Dropzone (default): large dashed area + preview rows -->\n @default {\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n [ngClass]=\"controlClasses\"\n type=\"button\">\n <!-- Inert so a drag crossing the icon/hint never reads as leaving the zone -->\n <span aria-live=\"polite\" class=\"pointer-events-none flex flex-col items-center gap-2\">\n @if (isDragging()) {\n <svg [size]=\"28\" class=\"animate-bounce text-primary\" [lucideIcon]=\"icons.Upload\"></svg>\n <span class=\"text-sm font-medium text-primary\">{{ uiConfig.dropActiveHint }}</span>\n } @else {\n <svg [size]=\"28\" class=\"text-base-content/40\" [lucideIcon]=\"icons.ImagePlus\"></svg>\n <span class=\"text-sm text-base-content/60\">{{ uiConfig.dropzoneHint }}</span>\n }\n </span>\n </button>\n @if (displayItems().length > 0) {\n <div class=\"mt-2 flex flex-col gap-2\">\n @for (item of displayItems(); track itemKey(item)) {\n <div class=\"flex items-center gap-3 rounded-lg bg-base-200 p-2\">\n @if (item.isImage && item.previewUrl) {\n <img [src]=\"item.previewUrl\" alt=\"\" class=\"h-12 w-12 rounded-md object-cover\"/>\n } @else {\n <svg [lucideIcon]=\"icons.File\" [size]=\"24\" class=\"text-base-content/50\"></svg>\n }\n <span class=\"flex-1 truncate text-sm text-base-content\">{{ item.name }}</span>\n @if (item.sizeLabel) {\n <span class=\"text-sm text-base-content/50\">{{ item.sizeLabel }}</span>\n }\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"inline-flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors text-error hover:bg-error/10\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.Trash2\" [size]=\"16\"></svg>\n </button>\n </div>\n }\n </div>\n }\n }\n }\n\n <!-- Selection-limit error (accept / maxSize / maxFiles) -->\n @if (internalError(); as msg) {\n <mn-error-message [errorMessage]=\"msg\" [id]=\"resolvedId + '-selection'\"></mn-error-message>\n }\n\n <!-- Control validation errors -->\n @if (showError) {\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n</div>\n\n<!--\n \"Release to drop\" cover for the modes that render their own layout instead of a\n dropzone. Absolutely positioned so arming it never shifts the layout, and inert\n so the drag keeps reaching the elements underneath.\n-->\n<ng-template #dropOverlay>\n <div\n aria-live=\"polite\"\n class=\"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-primary bg-base-100/90 text-center\">\n <svg [size]=\"24\" class=\"animate-bounce text-primary\" [lucideIcon]=\"icons.Upload\"></svg>\n <span class=\"px-2 text-sm font-medium text-primary\">{{ uiConfig.dropActiveHint }}</span>\n </div>\n</ng-template>\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: MnErrorMessage, selector: "mn-error-message", inputs: ["errorMessage", "id"] }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }] });
|
|
1957
2064
|
}
|
|
1958
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2065
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnFileInput, decorators: [{
|
|
1959
2066
|
type: Component,
|
|
1960
2067
|
args: [{ selector: 'mn-lib-file-input', standalone: true, imports: [CommonModule, NgClass, MnErrorMessage, LucideDynamicIcon], template: "<!--\n Drag handling sits on the wrapper so a drop anywhere inside the control counts.\n onDragEnter/onDragLeave balance out as the drag crosses children, and\n acceptsDrag() ignores the modes that have no drop target.\n-->\n<div\n (dragenter)=\"onDragEnter($event)\"\n (dragleave)=\"onDragLeave($event)\"\n (dragover)=\"onDragOver($event)\"\n (drop)=\"onDrop($event)\"\n [class.w-full]=\"props.fullWidth !== false && displayMode !== 'compact'\"\n class=\"flex flex-col\">\n <!-- Label -->\n @if (uiConfig.label) {\n <label [attr.for]=\"resolvedId\" class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\">\n <p>{{ uiConfig.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n <!-- Hidden native file input shared by every trigger -->\n <input\n #fileInput\n (change)=\"onFileSelected($event)\"\n [accept]=\"acceptAttr\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || null\"\n [attr.multiple]=\"props.multiple || null\"\n [attr.name]=\"resolvedName\"\n [disabled]=\"isDisabled\"\n [id]=\"resolvedId\"\n [attr.aria-required]=\"isRequired() || null\"\n class=\"hidden\"\n type=\"file\"\n />\n\n @switch (displayMode) {\n <!-- Compact: inline button + filename chips -->\n @case ('compact') {\n <div class=\"flex flex-wrap items-center gap-2\">\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n [ngClass]=\"controlClasses\"\n class=\"inline-flex items-center gap-2 cursor-pointer hover:bg-base-200\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.Upload\" [size]=\"18\"></svg>\n <span class=\"text-sm\">{{ uiConfig.replaceLabel }}</span>\n </button>\n @for (item of displayItems(); track itemKey(item)) {\n <span class=\"inline-flex items-center gap-1 text-sm text-base-content/70\">\n @if (item.isImage && item.previewUrl) {\n <img [src]=\"item.previewUrl\" alt=\"\" class=\"h-6 w-6 rounded object-cover\"/>\n } @else {\n <svg [lucideIcon]=\"icons.File\" [size]=\"16\" class=\"text-base-content/50\"></svg>\n }\n <span class=\"max-w-40 truncate\">{{ item.name }}</span>\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"text-base-content/50 hover:text-error cursor-pointer\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.X\" [size]=\"14\"></svg>\n </button>\n </span>\n }\n </div>\n }\n\n <!-- List: compact rows of file icon + name + size -->\n @case ('list') {\n <div class=\"relative flex flex-col\">\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n [ngClass]=\"controlClasses\"\n class=\"flex flex-row items-center justify-center gap-2 cursor-pointer hover:bg-base-200\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.Upload\" [size]=\"18\"></svg>\n <span class=\"text-sm\">{{ uiConfig.replaceLabel }}</span>\n </button>\n @if (displayItems().length > 0) {\n <div class=\"mt-2 flex flex-col gap-1\">\n @for (item of displayItems(); track itemKey(item)) {\n <div class=\"flex items-center gap-2 rounded-lg bg-base-200 px-3 py-1.5 text-sm\">\n <svg [lucideIcon]=\"icons.File\" [size]=\"16\" class=\"text-base-content/50\"></svg>\n <span class=\"flex-1 truncate text-base-content\">{{ item.name }}</span>\n @if (item.sizeLabel) {\n <span class=\"text-base-content/50\">{{ item.sizeLabel }}</span>\n }\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"text-base-content/50 hover:text-error cursor-pointer\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.X\" [size]=\"16\"></svg>\n </button>\n </div>\n }\n </div>\n }\n @if (isDragging()) {\n <ng-container [ngTemplateOutlet]=\"dropOverlay\"></ng-container>\n }\n </div>\n }\n\n <!-- Thumbnail: grid of tiles with overlay remove + add tile -->\n @case ('thumbnail') {\n <div class=\"relative flex flex-wrap gap-3\">\n @for (item of displayItems(); track itemKey(item)) {\n <div class=\"relative h-24 w-24 overflow-hidden rounded-xl border border-base-300 bg-base-100\">\n @if (item.isImage && item.previewUrl) {\n <img [src]=\"item.previewUrl\" alt=\"\" class=\"h-full w-full object-cover\"/>\n } @else {\n <div class=\"flex h-full w-full flex-col items-center justify-center gap-1 p-1 text-center\">\n <svg [lucideIcon]=\"icons.File\" [size]=\"22\" class=\"text-base-content/50\"></svg>\n <span class=\"w-full truncate text-xs text-base-content/60\">{{ item.name }}</span>\n </div>\n }\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"inline-flex h-6 w-6 items-center justify-center rounded-full cursor-pointer transition-colors absolute top-1 right-1 border-none bg-black/60 text-white hover:bg-black/80\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.X\" [size]=\"14\"></svg>\n </button>\n </div>\n }\n @if (props.multiple || displayItems().length === 0) {\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n class=\"flex h-24 w-24 flex-col items-center justify-center gap-1 rounded-xl border-2 border-dashed border-base-300 text-base-content/50 hover:border-primary cursor-pointer disabled:opacity-50 disabled:cursor-not-allowed\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.ImagePlus\" [size]=\"22\"></svg>\n </button>\n }\n @if (isDragging()) {\n <ng-container [ngTemplateOutlet]=\"dropOverlay\"></ng-container>\n }\n </div>\n }\n\n <!-- Dropzone (default): large dashed area + preview rows -->\n @default {\n <button\n (click)=\"fileInput.click()\"\n [disabled]=\"isDisabled\"\n [ngClass]=\"controlClasses\"\n type=\"button\">\n <!-- Inert so a drag crossing the icon/hint never reads as leaving the zone -->\n <span aria-live=\"polite\" class=\"pointer-events-none flex flex-col items-center gap-2\">\n @if (isDragging()) {\n <svg [size]=\"28\" class=\"animate-bounce text-primary\" [lucideIcon]=\"icons.Upload\"></svg>\n <span class=\"text-sm font-medium text-primary\">{{ uiConfig.dropActiveHint }}</span>\n } @else {\n <svg [size]=\"28\" class=\"text-base-content/40\" [lucideIcon]=\"icons.ImagePlus\"></svg>\n <span class=\"text-sm text-base-content/60\">{{ uiConfig.dropzoneHint }}</span>\n }\n </span>\n </button>\n @if (displayItems().length > 0) {\n <div class=\"mt-2 flex flex-col gap-2\">\n @for (item of displayItems(); track itemKey(item)) {\n <div class=\"flex items-center gap-3 rounded-lg bg-base-200 p-2\">\n @if (item.isImage && item.previewUrl) {\n <img [src]=\"item.previewUrl\" alt=\"\" class=\"h-12 w-12 rounded-md object-cover\"/>\n } @else {\n <svg [lucideIcon]=\"icons.File\" [size]=\"24\" class=\"text-base-content/50\"></svg>\n }\n <span class=\"flex-1 truncate text-sm text-base-content\">{{ item.name }}</span>\n @if (item.sizeLabel) {\n <span class=\"text-sm text-base-content/50\">{{ item.sizeLabel }}</span>\n }\n <button\n (click)=\"item.existing ? removeExisting(item.index) : removeFile(item.index)\"\n [attr.aria-label]=\"uiConfig.removeLabel\"\n class=\"inline-flex h-8 w-8 items-center justify-center rounded-full cursor-pointer transition-colors text-error hover:bg-error/10\"\n type=\"button\">\n <svg [lucideIcon]=\"icons.Trash2\" [size]=\"16\"></svg>\n </button>\n </div>\n }\n </div>\n }\n }\n }\n\n <!-- Selection-limit error (accept / maxSize / maxFiles) -->\n @if (internalError(); as msg) {\n <mn-error-message [errorMessage]=\"msg\" [id]=\"resolvedId + '-selection'\"></mn-error-message>\n }\n\n <!-- Control validation errors -->\n @if (showError) {\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n</div>\n\n<!--\n \"Release to drop\" cover for the modes that render their own layout instead of a\n dropzone. Absolutely positioned so arming it never shifts the layout, and inert\n so the drag keeps reaching the elements underneath.\n-->\n<ng-template #dropOverlay>\n <div\n aria-live=\"polite\"\n class=\"pointer-events-none absolute inset-0 z-10 flex flex-col items-center justify-center gap-2 rounded-xl border-2 border-dashed border-primary bg-base-100/90 text-center\">\n <svg [size]=\"24\" class=\"animate-bounce text-primary\" [lucideIcon]=\"icons.Upload\"></svg>\n <span class=\"px-2 text-sm font-medium text-primary\">{{ uiConfig.dropActiveHint }}</span>\n </div>\n</ng-template>\n" }]
|
|
1961
2068
|
}], ctorParameters: () => [], propDecorators: { props: [{
|
|
@@ -2200,10 +2307,8 @@ class MnSelect {
|
|
|
2200
2307
|
maxWidth: 'none',
|
|
2201
2308
|
maxHeight: null,
|
|
2202
2309
|
};
|
|
2203
|
-
onChange = () => {
|
|
2204
|
-
};
|
|
2205
|
-
onTouched = () => {
|
|
2206
|
-
};
|
|
2310
|
+
onChange = () => { };
|
|
2311
|
+
onTouched = () => { };
|
|
2207
2312
|
builtInErrorMessages = {
|
|
2208
2313
|
required: 'Please select an option',
|
|
2209
2314
|
};
|
|
@@ -2247,7 +2352,7 @@ class MnSelect {
|
|
|
2247
2352
|
return this.ngControl?.control ?? null;
|
|
2248
2353
|
}
|
|
2249
2354
|
get selectedOption() {
|
|
2250
|
-
return this.props.options.find(o => o.value === this.selectedValue);
|
|
2355
|
+
return this.props.options.find((o) => o.value === this.selectedValue);
|
|
2251
2356
|
}
|
|
2252
2357
|
/** The label shown in the trigger: the selected option, else the placeholder. */
|
|
2253
2358
|
get displayText() {
|
|
@@ -2293,7 +2398,7 @@ class MnSelect {
|
|
|
2293
2398
|
const errors = this.control?.errors;
|
|
2294
2399
|
if (!errors)
|
|
2295
2400
|
return [];
|
|
2296
|
-
return Object.keys(errors).map(key => this.resolveErrorMessageForKey(key, errors));
|
|
2401
|
+
return Object.keys(errors).map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
2297
2402
|
}
|
|
2298
2403
|
get errorMessage() {
|
|
2299
2404
|
const errors = this.control?.errors;
|
|
@@ -2334,14 +2439,26 @@ class MnSelect {
|
|
|
2334
2439
|
if (!this.searchTerm)
|
|
2335
2440
|
return this.props.options;
|
|
2336
2441
|
const lower = this.searchTerm.toLowerCase();
|
|
2337
|
-
return this.props.options.filter(o => o.label.toLowerCase().includes(lower));
|
|
2442
|
+
return this.props.options.filter((o) => o.label.toLowerCase().includes(lower));
|
|
2338
2443
|
}
|
|
2339
2444
|
// ========== Lifecycle ==========
|
|
2340
2445
|
ngOnInit() {
|
|
2446
|
+
// `showError` reads the control's touched/dirty/invalid state straight off the form.
|
|
2447
|
+
// Those move from the forms API — `markAllAsTouched()` when the user tries to submit, a
|
|
2448
|
+
// programmatic `setErrors` — never through an event on this component, so under OnPush
|
|
2449
|
+
// the message would never appear. `events` covers value, status, touched and pristine.
|
|
2450
|
+
const formControl = this.ngControl?.control;
|
|
2451
|
+
if (formControl) {
|
|
2452
|
+
const stateSub = formControl.events.subscribe(() => this.cdr.markForCheck());
|
|
2453
|
+
this.destroyRef.onDestroy(() => stateSub.unsubscribe());
|
|
2454
|
+
}
|
|
2341
2455
|
this.resolveConfig();
|
|
2342
2456
|
this.startWatchingViewport();
|
|
2343
2457
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
2344
2458
|
this.resolveConfig();
|
|
2459
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
2460
|
+
// marks this view for the locale change.
|
|
2461
|
+
this.cdr.markForCheck();
|
|
2345
2462
|
});
|
|
2346
2463
|
this.destroyRef.onDestroy(() => {
|
|
2347
2464
|
sub.unsubscribe();
|
|
@@ -2357,7 +2474,10 @@ class MnSelect {
|
|
|
2357
2474
|
// ========== ControlValueAccessor Implementation ==========
|
|
2358
2475
|
writeValue(val) {
|
|
2359
2476
|
// Treat empty string as null so the placeholder is shown and the control stays properly invalid.
|
|
2360
|
-
this.selectedValue =
|
|
2477
|
+
this.selectedValue = val === '' || val == null ? null : val;
|
|
2478
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
2479
|
+
// this view for it.
|
|
2480
|
+
this.cdr.markForCheck();
|
|
2361
2481
|
}
|
|
2362
2482
|
registerOnChange(fn) {
|
|
2363
2483
|
this.onChange = fn;
|
|
@@ -2367,6 +2487,9 @@ class MnSelect {
|
|
|
2367
2487
|
}
|
|
2368
2488
|
setDisabledState(isDisabled) {
|
|
2369
2489
|
this.isDisabled = isDisabled;
|
|
2490
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
2491
|
+
// from the forms API, with no event behind it.
|
|
2492
|
+
this.cdr.markForCheck();
|
|
2370
2493
|
}
|
|
2371
2494
|
// ========== Dropdown Logic ==========
|
|
2372
2495
|
toggle() {
|
|
@@ -2376,7 +2499,10 @@ class MnSelect {
|
|
|
2376
2499
|
this.close();
|
|
2377
2500
|
return;
|
|
2378
2501
|
}
|
|
2502
|
+
// `toggle()` and `close()` are public API: a consumer holding a @ViewChild can
|
|
2503
|
+
// open the panel without an event, and under OnPush nothing else marks this view.
|
|
2379
2504
|
this.isOpen = true;
|
|
2505
|
+
this.cdr.markForCheck();
|
|
2380
2506
|
if (this.isSheet) {
|
|
2381
2507
|
// A sheet is anchored to the viewport, so it needs no trigger tracking — only a
|
|
2382
2508
|
// scroll lock so the page behind it stays put while the list is scrolled.
|
|
@@ -2400,7 +2526,9 @@ class MnSelect {
|
|
|
2400
2526
|
/** Filters the options; the first match is highlighted so Enter picks it, none once the box is cleared. */
|
|
2401
2527
|
onSearch(term) {
|
|
2402
2528
|
this.searchTerm = term ?? '';
|
|
2403
|
-
this.activeIndex = this.searchTerm
|
|
2529
|
+
this.activeIndex = this.searchTerm
|
|
2530
|
+
? stepEnabledIndex(this.filteredOptions, -1, 1, isChoosable)
|
|
2531
|
+
: -1;
|
|
2404
2532
|
}
|
|
2405
2533
|
/** Id of the keyboard-highlighted option, for `aria-activedescendant`; null when none is. */
|
|
2406
2534
|
get activeOptionId() {
|
|
@@ -2435,10 +2563,11 @@ class MnSelect {
|
|
|
2435
2563
|
return;
|
|
2436
2564
|
claim(event);
|
|
2437
2565
|
this.toggle();
|
|
2438
|
-
const selected = this.filteredOptions.findIndex(o => this.isSelected(o) && isChoosable(o));
|
|
2439
|
-
this.activeIndex =
|
|
2440
|
-
|
|
2441
|
-
|
|
2566
|
+
const selected = this.filteredOptions.findIndex((o) => this.isSelected(o) && isChoosable(o));
|
|
2567
|
+
this.activeIndex =
|
|
2568
|
+
selected >= 0
|
|
2569
|
+
? selected
|
|
2570
|
+
: stepEnabledIndex(this.filteredOptions, -1, event.key === 'ArrowUp' ? -1 : 1, isChoosable);
|
|
2442
2571
|
this.revealActiveOption();
|
|
2443
2572
|
return;
|
|
2444
2573
|
}
|
|
@@ -2520,6 +2649,7 @@ class MnSelect {
|
|
|
2520
2649
|
if (!this.isOpen)
|
|
2521
2650
|
return;
|
|
2522
2651
|
this.isOpen = false;
|
|
2652
|
+
this.cdr.markForCheck();
|
|
2523
2653
|
this.searchTerm = '';
|
|
2524
2654
|
this.activeIndex = -1;
|
|
2525
2655
|
this.stopWatchingTrigger();
|
|
@@ -2657,8 +2787,8 @@ class MnSelect {
|
|
|
2657
2787
|
this.stopWatchingTrigger();
|
|
2658
2788
|
const trigger = this.triggerRef?.nativeElement;
|
|
2659
2789
|
if (trigger && typeof IntersectionObserver !== 'undefined') {
|
|
2660
|
-
this.visibilityObserver = new IntersectionObserver(entries => {
|
|
2661
|
-
if (!entries.some(entry => !entry.isIntersecting))
|
|
2790
|
+
this.visibilityObserver = new IntersectionObserver((entries) => {
|
|
2791
|
+
if (!entries.some((entry) => !entry.isIntersecting))
|
|
2662
2792
|
return;
|
|
2663
2793
|
this.close();
|
|
2664
2794
|
// The observer fires outside Angular, so a zoneless app needs an explicit nudge.
|
|
@@ -2668,7 +2798,9 @@ class MnSelect {
|
|
|
2668
2798
|
}
|
|
2669
2799
|
this.scrollCapture = (event) => {
|
|
2670
2800
|
const target = event.target;
|
|
2671
|
-
if (target &&
|
|
2801
|
+
if (target &&
|
|
2802
|
+
this.movedPanel &&
|
|
2803
|
+
(this.movedPanel === target || this.movedPanel.contains(target))) {
|
|
2672
2804
|
return;
|
|
2673
2805
|
}
|
|
2674
2806
|
this.close();
|
|
@@ -2779,12 +2911,20 @@ class MnSelect {
|
|
|
2779
2911
|
}
|
|
2780
2912
|
return msgDef;
|
|
2781
2913
|
}
|
|
2782
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
2783
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: MnSelect, isStandalone: true, selector: "mn-lib-select", inputs: { props: "props" }, host: { listeners: { "document:click": "onDocumentClick($event)", "document:keydown.escape": "onEscape()", "window:scroll": "onWindowScrollOrResize()", "window:resize": "onWindowScrollOrResize()" }, properties: { "style.display": "props?.fullWidth ? 'block' : null", "style.width": "props?.fullWidth ? '100%' : null" } }, viewQueries: [{ propertyName: "triggerRef", first: true, predicate: ["trigger"], descendants: true }, { propertyName: "dropdownRef", first: true, predicate: ["dropdown"], descendants: true }, { propertyName: "shieldRef", first: true, predicate: ["shield"], descendants: true }, { propertyName: "sheetRef", first: true, predicate: ["sheet"], descendants: true, read: ElementRef }], ngImport: i0, template: "<div [class.is-fullwidth]=\"props.fullWidth\" class=\"flex flex-col h-full\">\n @if (uiConfig.label || props.label) {\n <label [attr.for]=\"resolvedId\" class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\">\n <p>{{ uiConfig.label || props.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n <!-- Trigger -->\n <div\n #trigger\n (blur)=\"handleBlur()\"\n (click)=\"toggle()\"\n (keydown)=\"onKeydown($event)\"\n [attr.aria-activedescendant]=\"activeOptionId\"\n [attr.aria-controls]=\"isOpen ? resolvedId + '-listbox' : null\"\n [attr.aria-describedby]=\"showError ? resolvedId + '-error' : null\"\n [attr.aria-disabled]=\"isDisabled || null\"\n [attr.aria-expanded]=\"isOpen\"\n [attr.aria-invalid]=\"showError || null\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || props.label || null\"\n [class.cursor-not-allowed]=\"isDisabled\"\n [class.opacity-60]=\"isDisabled\"\n [id]=\"resolvedId\"\n [ngClass]=\"triggerClasses\"\n [tabindex]=\"isDisabled ? -1 : 0\"\n aria-haspopup=\"listbox\"\n class=\"relative\"\n role=\"combobox\"\n [attr.aria-required]=\"isRequired() || null\"\n >\n <!-- `pr-6` reserves the gutter the caret is absolutely positioned in (right-2 + w-4),\n so the value can never render underneath it. `min-w-0` lets the label shrink below\n its content width, which is what makes truncation possible. -->\n <div class=\"flex flex-row items-center min-h-6 min-w-0 pr-6\">\n <span\n [attr.title]=\"selectedOption?.label\"\n [ngClass]=\"selectedOption ? 'text-base-content' : 'text-base-content/50'\"\n class=\"truncate\"\n >{{ displayText }}</span>\n </div>\n <div class=\"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none\">\n <svg [size]=\"16\" class=\"text-base-content/50\" [lucideIcon]=\"icons.ChevronDown\"></svg>\n </div>\n </div>\n\n <!-- Dropdown -->\n @if (isOpen) {\n @if (isSheet) {\n <!-- On mobile the panel is presented as a shared bottom sheet: the sheet chrome\n (backdrop, grabber, swipe/flick-to-dismiss, slide animation) lives in\n mn-bottom-sheet; this component only projects the field's content into it. The\n sheet host is portalled to document.body (see the `sheet` ViewChild) so its\n `position: fixed` anchors to the viewport, not a transformed ancestor. -->\n <mn-bottom-sheet\n #sheet\n (dismiss)=\"close()\"\n [ariaLabel]=\"uiConfig.ariaLabel || uiConfig.label || props.label || uiConfig.placeholder || props.placeholder\"\n [maxHeightVh]=\"80\"\n [minHeightPx]=\"sheetFloorPx\"\n >\n <div\n [id]=\"resolvedId + '-listbox'\"\n class=\"flex flex-col flex-1 min-h-0 overflow-hidden\"\n role=\"listbox\"\n >\n <!-- The sheet covers its own trigger, so it carries a header to name the field; the\n way out is the grabber (swipe-to-dismiss) and a backdrop tap. -->\n <div class=\"px-4 pt-1 pb-2 shrink-0\">\n <p class=\"text-base font-medium text-base-content truncate\">\n {{ uiConfig.label || props.label || uiConfig.placeholder || props.placeholder || '' }}\n </p>\n </div>\n <ng-container [ngTemplateOutlet]=\"panelBody\"></ng-container>\n </div>\n </mn-bottom-sheet>\n } @else {\n <!-- A transparent full-viewport shield behind the panel, so \"click anywhere to dismiss\"\n is literally true. It also *consumes* that click: without it the click reaches\n whatever sits underneath \u2014 inside a modal that is the modal's own backdrop, so\n dismissing the dropdown would tear down the whole modal with it. Portalled to\n document.body for the same reason the panel is. It is aria-hidden and unfocusable:\n the keyboard equivalent of this click is Escape. -->\n <div\n #shield\n (click)=\"onShieldClick($event)\"\n [id]=\"resolvedId + '-shield'\"\n [ngClass]=\"shieldClasses\"\n aria-hidden=\"true\"\n ></div>\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n #dropdown\n (click)=\"$event.stopPropagation()\"\n [id]=\"resolvedId + '-listbox'\"\n [ngClass]=\"panelClasses\"\n [style.left]=\"dropdownStyle.left\"\n [style.top]=\"dropdownStyle.top\"\n [style.bottom]=\"dropdownStyle.bottom\"\n [style.max-height]=\"dropdownStyle.maxHeight\"\n [style.min-width]=\"dropdownStyle.minWidth\"\n [style.max-width]=\"dropdownStyle.maxWidth\"\n role=\"listbox\"\n >\n <ng-container [ngTemplateOutlet]=\"panelBody\"></ng-container>\n </div>\n }\n }\n\n <!-- The search box + option list, shared verbatim by the sheet and the anchored popover.\n `isSheet` only tunes spacing/sizing and which element scrolls: in sheet mode the list\n is the flex scroller; anchored, the popover itself scrolls. -->\n <ng-template #panelBody>\n @if (isSearchable) {\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"onKeydown($event, true)\"\n [ngClass]=\"isSheet ? 'px-4 py-2' : 'p-2'\"\n class=\"border-b border-base-300 shrink-0\"\n >\n <mn-lib-input-field\n (ngModelChange)=\"onSearch($event)\"\n [ngModelOptions]=\"{ standalone: true }\"\n [ngModel]=\"searchTerm\"\n [props]=\"{\n id: resolvedId + '-search',\n type: 'search',\n placeholder: searchPlaceholderLabel,\n ariaLabel: searchPlaceholderLabel,\n ariaActiveDescendant: activeOptionId,\n fullWidth: true,\n size: 'sm',\n autoFocus: !isSheet\n }\"\n ></mn-lib-input-field>\n </div>\n }\n <div [ngClass]=\"isSheet ? 'flex-1 overflow-auto overscroll-contain' : ''\">\n @for (opt of filteredOptions; track opt.value) {\n <!-- Options are not Tab stops: the keyboard reaches them with the arrow keys while focus\n stays on the trigger or the search box, and `aria-activedescendant` names the one it\n is on. The ring marks that option, since it never receives real focus. -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"selectOption(opt); $event.stopPropagation()\"\n [attr.aria-disabled]=\"opt.disabled || null\"\n [attr.aria-selected]=\"isSelected(opt)\"\n [class.opacity-50]=\"opt.disabled\"\n [class.pointer-events-none]=\"opt.disabled\"\n [id]=\"optionId($index)\"\n [ngClass]=\"[isSheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm', isSelected(opt) ? 'bg-primary/10 font-medium' : '', $index === activeIndex ? 'ring-2 ring-inset ring-primary' : '']\"\n class=\"flex items-center gap-x-2.5 cursor-pointer text-base-content hover:bg-base-200 transition-colors\"\n role=\"option\"\n >\n <span class=\"truncate min-w-0\">{{ opt.label }}</span>\n <!-- The current choice's marker. Decorative: the state is conveyed to assistive\n tech by `aria-selected` on the row. -->\n @if (isSelected(opt)) {\n <svg\n [lucideIcon]=\"checkIcon\"\n [size]=\"isSheet ? 18 : 16\"\n aria-hidden=\"true\"\n class=\"ml-auto shrink-0 text-primary\"\n ></svg>\n }\n </div>\n }\n @if (filteredOptions.length === 0) {\n <div [ngClass]=\"isSheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm'\" class=\"text-base-content/50\">\n {{ noOptionsLabel }}\n </div>\n }\n </div>\n </ng-template>\n\n @if (showError) {\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1 mt-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else {\n @if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n }\n</div>\n", dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: MnErrorMessage, selector: "mn-error-message", inputs: ["errorMessage", "id"] }, { kind: "component", type: MnInputField, selector: "mn-lib-input-field", inputs: ["props"] }, { 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"] }] });
|
|
2914
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnSelect, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2915
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: MnSelect, isStandalone: true, selector: "mn-lib-select", inputs: { props: "props" }, host: { listeners: { "document:click": "onDocumentClick($event)", "document:keydown.escape": "onEscape()", "window:scroll": "onWindowScrollOrResize()", "window:resize": "onWindowScrollOrResize()" }, properties: { "style.display": "props?.fullWidth ? 'block' : null", "style.width": "props?.fullWidth ? '100%' : null" } }, viewQueries: [{ propertyName: "triggerRef", first: true, predicate: ["trigger"], descendants: true }, { propertyName: "dropdownRef", first: true, predicate: ["dropdown"], descendants: true }, { propertyName: "shieldRef", first: true, predicate: ["shield"], descendants: true }, { propertyName: "sheetRef", first: true, predicate: ["sheet"], descendants: true, read: ElementRef }], ngImport: i0, template: "<div [class.is-fullwidth]=\"props.fullWidth\" class=\"flex flex-col h-full\">\n @if (uiConfig.label || props.label) {\n <label [attr.for]=\"resolvedId\" class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\">\n <p>{{ uiConfig.label || props.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n <!-- Trigger -->\n <div\n #trigger\n (blur)=\"handleBlur()\"\n (click)=\"toggle()\"\n (keydown)=\"onKeydown($event)\"\n [attr.aria-activedescendant]=\"activeOptionId\"\n [attr.aria-controls]=\"isOpen ? resolvedId + '-listbox' : null\"\n [attr.aria-describedby]=\"showError ? resolvedId + '-error' : null\"\n [attr.aria-disabled]=\"isDisabled || null\"\n [attr.aria-expanded]=\"isOpen\"\n [attr.aria-invalid]=\"showError || null\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || props.label || null\"\n [class.cursor-not-allowed]=\"isDisabled\"\n [class.opacity-60]=\"isDisabled\"\n [id]=\"resolvedId\"\n [ngClass]=\"triggerClasses\"\n [tabindex]=\"isDisabled ? -1 : 0\"\n aria-haspopup=\"listbox\"\n class=\"relative\"\n role=\"combobox\"\n [attr.aria-required]=\"isRequired() || null\"\n >\n <!-- `pr-6` reserves the gutter the caret is absolutely positioned in (right-2 + w-4),\n so the value can never render underneath it. `min-w-0` lets the label shrink below\n its content width, which is what makes truncation possible. -->\n <div class=\"flex flex-row items-center min-h-6 min-w-0 pr-6\">\n <span\n [attr.title]=\"selectedOption?.label\"\n [ngClass]=\"selectedOption ? 'text-base-content' : 'text-base-content/50'\"\n class=\"truncate\"\n >{{ displayText }}</span>\n </div>\n <div class=\"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none\">\n <svg [size]=\"16\" class=\"text-base-content/50\" [lucideIcon]=\"icons.ChevronDown\"></svg>\n </div>\n </div>\n\n <!-- Dropdown -->\n @if (isOpen) {\n @if (isSheet) {\n <!-- On mobile the panel is presented as a shared bottom sheet: the sheet chrome\n (backdrop, grabber, swipe/flick-to-dismiss, slide animation) lives in\n mn-bottom-sheet; this component only projects the field's content into it. The\n sheet host is portalled to document.body (see the `sheet` ViewChild) so its\n `position: fixed` anchors to the viewport, not a transformed ancestor. -->\n <mn-bottom-sheet\n #sheet\n (dismiss)=\"close()\"\n [ariaLabel]=\"uiConfig.ariaLabel || uiConfig.label || props.label || uiConfig.placeholder || props.placeholder\"\n [maxHeightVh]=\"80\"\n [minHeightPx]=\"sheetFloorPx\"\n >\n <div\n [id]=\"resolvedId + '-listbox'\"\n class=\"flex flex-col flex-1 min-h-0 overflow-hidden\"\n role=\"listbox\"\n >\n <!-- The sheet covers its own trigger, so it carries a header to name the field; the\n way out is the grabber (swipe-to-dismiss) and a backdrop tap. -->\n <div class=\"px-4 pt-1 pb-2 shrink-0\">\n <p class=\"text-base font-medium text-base-content truncate\">\n {{ uiConfig.label || props.label || uiConfig.placeholder || props.placeholder || '' }}\n </p>\n </div>\n <ng-container [ngTemplateOutlet]=\"panelBody\"></ng-container>\n </div>\n </mn-bottom-sheet>\n } @else {\n <!-- A transparent full-viewport shield behind the panel, so \"click anywhere to dismiss\"\n is literally true. It also *consumes* that click: without it the click reaches\n whatever sits underneath \u2014 inside a modal that is the modal's own backdrop, so\n dismissing the dropdown would tear down the whole modal with it. Portalled to\n document.body for the same reason the panel is. It is aria-hidden and unfocusable:\n the keyboard equivalent of this click is Escape. -->\n <div\n #shield\n (click)=\"onShieldClick($event)\"\n [id]=\"resolvedId + '-shield'\"\n [ngClass]=\"shieldClasses\"\n aria-hidden=\"true\"\n ></div>\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n #dropdown\n (click)=\"$event.stopPropagation()\"\n [id]=\"resolvedId + '-listbox'\"\n [ngClass]=\"panelClasses\"\n [style.left]=\"dropdownStyle.left\"\n [style.top]=\"dropdownStyle.top\"\n [style.bottom]=\"dropdownStyle.bottom\"\n [style.max-height]=\"dropdownStyle.maxHeight\"\n [style.min-width]=\"dropdownStyle.minWidth\"\n [style.max-width]=\"dropdownStyle.maxWidth\"\n role=\"listbox\"\n >\n <ng-container [ngTemplateOutlet]=\"panelBody\"></ng-container>\n </div>\n }\n }\n\n <!-- The search box + option list, shared verbatim by the sheet and the anchored popover.\n `isSheet` only tunes spacing/sizing and which element scrolls: in sheet mode the list\n is the flex scroller; anchored, the popover itself scrolls. -->\n <ng-template #panelBody>\n @if (isSearchable) {\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"onKeydown($event, true)\"\n [ngClass]=\"isSheet ? 'px-4 py-2' : 'p-2'\"\n class=\"border-b border-base-300 shrink-0\"\n >\n <mn-lib-input-field\n (ngModelChange)=\"onSearch($event)\"\n [ngModelOptions]=\"{ standalone: true }\"\n [ngModel]=\"searchTerm\"\n [props]=\"{\n id: resolvedId + '-search',\n type: 'search',\n placeholder: searchPlaceholderLabel,\n ariaLabel: searchPlaceholderLabel,\n ariaActiveDescendant: activeOptionId,\n fullWidth: true,\n size: 'sm',\n autoFocus: !isSheet\n }\"\n ></mn-lib-input-field>\n </div>\n }\n <div [ngClass]=\"isSheet ? 'flex-1 overflow-auto overscroll-contain' : ''\">\n @for (opt of filteredOptions; track opt.value) {\n <!-- Options are not Tab stops: the keyboard reaches them with the arrow keys while focus\n stays on the trigger or the search box, and `aria-activedescendant` names the one it\n is on. The ring marks that option, since it never receives real focus. -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"selectOption(opt); $event.stopPropagation()\"\n [attr.aria-disabled]=\"opt.disabled || null\"\n [attr.aria-selected]=\"isSelected(opt)\"\n [class.opacity-50]=\"opt.disabled\"\n [class.pointer-events-none]=\"opt.disabled\"\n [id]=\"optionId($index)\"\n [ngClass]=\"[isSheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm', isSelected(opt) ? 'bg-primary/10 font-medium' : '', $index === activeIndex ? 'ring-2 ring-inset ring-primary' : '']\"\n class=\"flex items-center gap-x-2.5 cursor-pointer text-base-content hover:bg-base-200 transition-colors\"\n role=\"option\"\n >\n <span class=\"truncate min-w-0\">{{ opt.label }}</span>\n <!-- The current choice's marker. Decorative: the state is conveyed to assistive\n tech by `aria-selected` on the row. -->\n @if (isSelected(opt)) {\n <svg\n [lucideIcon]=\"checkIcon\"\n [size]=\"isSheet ? 18 : 16\"\n aria-hidden=\"true\"\n class=\"ml-auto shrink-0 text-primary\"\n ></svg>\n }\n </div>\n }\n @if (filteredOptions.length === 0) {\n <div [ngClass]=\"isSheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm'\" class=\"text-base-content/50\">\n {{ noOptionsLabel }}\n </div>\n }\n </div>\n </ng-template>\n\n @if (showError) {\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1 mt-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else {\n @if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n }\n</div>\n", dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: MnErrorMessage, selector: "mn-error-message", inputs: ["errorMessage", "id"] }, { kind: "component", type: MnInputField, selector: "mn-lib-input-field", inputs: ["props"] }, { 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"] }] });
|
|
2784
2916
|
}
|
|
2785
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2917
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnSelect, decorators: [{
|
|
2786
2918
|
type: Component,
|
|
2787
|
-
args: [{ selector: 'mn-lib-select', standalone: true, imports: [
|
|
2919
|
+
args: [{ selector: 'mn-lib-select', standalone: true, imports: [
|
|
2920
|
+
NgClass,
|
|
2921
|
+
NgTemplateOutlet,
|
|
2922
|
+
FormsModule,
|
|
2923
|
+
MnErrorMessage,
|
|
2924
|
+
MnInputField,
|
|
2925
|
+
MnBottomSheet,
|
|
2926
|
+
LucideDynamicIcon,
|
|
2927
|
+
], host: {
|
|
2788
2928
|
// Without an explicit host width the inline host collapses to its content size, so
|
|
2789
2929
|
// the trigger's `w-full` (width:100%) resolves against a content-sized box and fails
|
|
2790
2930
|
// to fill the parent. Give the host a real width when fullWidth is requested.
|
|
@@ -2957,8 +3097,7 @@ class MnMultiSelect {
|
|
|
2957
3097
|
width: '0px',
|
|
2958
3098
|
maxHeight: null,
|
|
2959
3099
|
};
|
|
2960
|
-
onChange = () => {
|
|
2961
|
-
};
|
|
3100
|
+
onChange = () => { };
|
|
2962
3101
|
onTouched = () => { };
|
|
2963
3102
|
builtInErrorMessages = {
|
|
2964
3103
|
required: 'At least one option must be selected',
|
|
@@ -3010,10 +3149,22 @@ class MnMultiSelect {
|
|
|
3010
3149
|
this.sheetMediaListener = null;
|
|
3011
3150
|
}
|
|
3012
3151
|
ngOnInit() {
|
|
3152
|
+
// `showError` reads the control's touched/dirty/invalid state straight off the form.
|
|
3153
|
+
// Those move from the forms API — `markAllAsTouched()` when the user tries to submit, a
|
|
3154
|
+
// programmatic `setErrors` — never through an event on this component, so under OnPush
|
|
3155
|
+
// the message would never appear. `events` covers value, status, touched and pristine.
|
|
3156
|
+
const formControl = this.ngControl?.control;
|
|
3157
|
+
if (formControl) {
|
|
3158
|
+
const stateSub = formControl.events.subscribe(() => this.cdr.markForCheck());
|
|
3159
|
+
this.destroyRef.onDestroy(() => stateSub.unsubscribe());
|
|
3160
|
+
}
|
|
3013
3161
|
this.resolveConfig();
|
|
3014
3162
|
this.startWatchingViewport();
|
|
3015
3163
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
3016
3164
|
this.resolveConfig();
|
|
3165
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
3166
|
+
// marks this view for the locale change.
|
|
3167
|
+
this.cdr.markForCheck();
|
|
3017
3168
|
});
|
|
3018
3169
|
this.destroyRef.onDestroy(() => {
|
|
3019
3170
|
sub.unsubscribe();
|
|
@@ -3042,6 +3193,9 @@ class MnMultiSelect {
|
|
|
3042
3193
|
// ========== ControlValueAccessor Implementation ==========
|
|
3043
3194
|
writeValue(val) {
|
|
3044
3195
|
this.selectedValues = Array.isArray(val) ? val : [];
|
|
3196
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
3197
|
+
// this view for it.
|
|
3198
|
+
this.cdr.markForCheck();
|
|
3045
3199
|
}
|
|
3046
3200
|
registerOnChange(fn) {
|
|
3047
3201
|
this.onChange = fn;
|
|
@@ -3051,6 +3205,9 @@ class MnMultiSelect {
|
|
|
3051
3205
|
}
|
|
3052
3206
|
setDisabledState(isDisabled) {
|
|
3053
3207
|
this.isDisabled = isDisabled;
|
|
3208
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
3209
|
+
// from the forms API, with no event behind it.
|
|
3210
|
+
this.cdr.markForCheck();
|
|
3054
3211
|
}
|
|
3055
3212
|
// ========== Dropdown Logic ==========
|
|
3056
3213
|
toggle() {
|
|
@@ -3060,7 +3217,10 @@ class MnMultiSelect {
|
|
|
3060
3217
|
this.close();
|
|
3061
3218
|
return;
|
|
3062
3219
|
}
|
|
3220
|
+
// `toggle()` and `close()` are public API: a consumer holding a @ViewChild can
|
|
3221
|
+
// open the panel without an event, and under OnPush nothing else marks this view.
|
|
3063
3222
|
this.isOpen = true;
|
|
3223
|
+
this.cdr.markForCheck();
|
|
3064
3224
|
if (this.isSheet) {
|
|
3065
3225
|
// A sheet is anchored to the viewport, so it needs no trigger tracking — only a
|
|
3066
3226
|
// scroll lock so the page behind it stays put while the list is scrolled.
|
|
@@ -3163,6 +3323,7 @@ class MnMultiSelect {
|
|
|
3163
3323
|
if (!this.isOpen)
|
|
3164
3324
|
return;
|
|
3165
3325
|
this.isOpen = false;
|
|
3326
|
+
this.cdr.markForCheck();
|
|
3166
3327
|
this.searchTerm = '';
|
|
3167
3328
|
this.activeIndex = -1;
|
|
3168
3329
|
this.stopWatchingTrigger();
|
|
@@ -3214,8 +3375,8 @@ class MnMultiSelect {
|
|
|
3214
3375
|
this.stopWatchingTrigger();
|
|
3215
3376
|
const trigger = this.triggerRef?.nativeElement;
|
|
3216
3377
|
if (trigger && typeof IntersectionObserver !== 'undefined') {
|
|
3217
|
-
this.visibilityObserver = new IntersectionObserver(entries => {
|
|
3218
|
-
if (!entries.some(entry => !entry.isIntersecting))
|
|
3378
|
+
this.visibilityObserver = new IntersectionObserver((entries) => {
|
|
3379
|
+
if (!entries.some((entry) => !entry.isIntersecting))
|
|
3219
3380
|
return;
|
|
3220
3381
|
this.close();
|
|
3221
3382
|
// The observer fires outside Angular, so a zoneless app needs an explicit nudge.
|
|
@@ -3225,7 +3386,9 @@ class MnMultiSelect {
|
|
|
3225
3386
|
}
|
|
3226
3387
|
this.scrollCapture = (event) => {
|
|
3227
3388
|
const target = event.target;
|
|
3228
|
-
if (target &&
|
|
3389
|
+
if (target &&
|
|
3390
|
+
this.movedPanel &&
|
|
3391
|
+
(this.movedPanel === target || this.movedPanel.contains(target))) {
|
|
3229
3392
|
return;
|
|
3230
3393
|
}
|
|
3231
3394
|
this.close();
|
|
@@ -3272,7 +3435,7 @@ class MnMultiSelect {
|
|
|
3272
3435
|
return;
|
|
3273
3436
|
const index = this.selectedValues.indexOf(option.value);
|
|
3274
3437
|
if (index > -1) {
|
|
3275
|
-
this.selectedValues = this.selectedValues.filter(v => v !== option.value);
|
|
3438
|
+
this.selectedValues = this.selectedValues.filter((v) => v !== option.value);
|
|
3276
3439
|
}
|
|
3277
3440
|
else {
|
|
3278
3441
|
if (this.props.maxSelections && this.selectedValues.length >= this.props.maxSelections) {
|
|
@@ -3284,7 +3447,7 @@ class MnMultiSelect {
|
|
|
3284
3447
|
}
|
|
3285
3448
|
removeOption(option, event) {
|
|
3286
3449
|
event.stopPropagation();
|
|
3287
|
-
this.selectedValues = this.selectedValues.filter(v => v !== option.value);
|
|
3450
|
+
this.selectedValues = this.selectedValues.filter((v) => v !== option.value);
|
|
3288
3451
|
this.onChange(this.selectedValues);
|
|
3289
3452
|
}
|
|
3290
3453
|
isSelected(option) {
|
|
@@ -3298,7 +3461,9 @@ class MnMultiSelect {
|
|
|
3298
3461
|
/** Filters the options; the first match is highlighted so Enter toggles it, none once the box is cleared. */
|
|
3299
3462
|
onSearch(term) {
|
|
3300
3463
|
this.searchTerm = term;
|
|
3301
|
-
this.activeIndex = this.searchTerm
|
|
3464
|
+
this.activeIndex = this.searchTerm
|
|
3465
|
+
? stepEnabledIndex(this.filteredOptions, -1, 1, this.isChoosable)
|
|
3466
|
+
: -1;
|
|
3302
3467
|
}
|
|
3303
3468
|
/**
|
|
3304
3469
|
* Whether the keyboard may highlight an option: not disabled, and not blocked by `maxSelections`.
|
|
@@ -3419,10 +3584,10 @@ class MnMultiSelect {
|
|
|
3419
3584
|
if (!this.searchTerm)
|
|
3420
3585
|
return this.props.options;
|
|
3421
3586
|
const lower = this.searchTerm.toLowerCase();
|
|
3422
|
-
return this.props.options.filter(o => o.label.toLowerCase().includes(lower));
|
|
3587
|
+
return this.props.options.filter((o) => o.label.toLowerCase().includes(lower));
|
|
3423
3588
|
}
|
|
3424
3589
|
get selectedOptions() {
|
|
3425
|
-
return this.props.options.filter(o => this.selectedValues.includes(o.value));
|
|
3590
|
+
return this.props.options.filter((o) => this.selectedValues.includes(o.value));
|
|
3426
3591
|
}
|
|
3427
3592
|
// ========== Collapse Summary ==========
|
|
3428
3593
|
/**
|
|
@@ -3440,7 +3605,7 @@ class MnMultiSelect {
|
|
|
3440
3605
|
* "all of them" would be a claim about nothing.
|
|
3441
3606
|
*/
|
|
3442
3607
|
get allSelected() {
|
|
3443
|
-
return this.props.options.length > 0 && this.selectedOptions.length === this.props.options.length;
|
|
3608
|
+
return (this.props.options.length > 0 && this.selectedOptions.length === this.props.options.length);
|
|
3444
3609
|
}
|
|
3445
3610
|
/**
|
|
3446
3611
|
* The threshold above which the trigger collapses. Defaults to 5 when collapsing
|
|
@@ -3558,7 +3723,7 @@ class MnMultiSelect {
|
|
|
3558
3723
|
const errors = this.control?.errors;
|
|
3559
3724
|
if (!errors)
|
|
3560
3725
|
return [];
|
|
3561
|
-
return Object.keys(errors).map(key => this.resolveErrorMessageForKey(key, errors));
|
|
3726
|
+
return Object.keys(errors).map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
3562
3727
|
}
|
|
3563
3728
|
get errorMessage() {
|
|
3564
3729
|
const errors = this.control?.errors;
|
|
@@ -3582,12 +3747,21 @@ class MnMultiSelect {
|
|
|
3582
3747
|
fullWidth: this.props.fullWidth,
|
|
3583
3748
|
});
|
|
3584
3749
|
}
|
|
3585
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
3586
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: MnMultiSelect, isStandalone: true, selector: "mn-lib-multi-select", inputs: { props: "props" }, host: { listeners: { "document:click": "onDocumentClick($event)", "document:keydown.escape": "onEscape()", "window:scroll": "onWindowScrollOrResize()", "window:resize": "onWindowScrollOrResize()" } }, viewQueries: [{ propertyName: "triggerRef", first: true, predicate: ["trigger"], descendants: true }, { propertyName: "dropdownRef", first: true, predicate: ["dropdown"], descendants: true }, { propertyName: "shieldRef", first: true, predicate: ["shield"], descendants: true }, { propertyName: "sheetRef", first: true, predicate: ["sheet"], descendants: true, read: ElementRef }], ngImport: i0, template: "<div class=\"flex flex-col h-full\" [class.is-fullwidth]=\"props.fullWidth\">\n @if (uiConfig.label || props.label) {\n <label class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\" [attr.for]=\"resolvedId\">\n <p>{{ uiConfig.label || props.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n <!-- Trigger -->\n <div\n #trigger\n [id]=\"resolvedId\"\n [ngClass]=\"triggerClasses\"\n class=\"relative\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || props.label || null\"\n [attr.aria-invalid]=\"showError || null\"\n [attr.aria-describedby]=\"showError ? resolvedId + '-error' : null\"\n [attr.aria-expanded]=\"isOpen\"\n [attr.aria-controls]=\"isOpen ? resolvedId + '-listbox' : null\"\n role=\"combobox\"\n [attr.aria-required]=\"isRequired() || null\"\n tabindex=\"0\"\n (click)=\"toggle()\"\n (keydown)=\"onKeydown($event)\"\n [attr.aria-activedescendant]=\"activeOptionId\"\n (blur)=\"handleBlur()\"\n >\n <!-- `pr-6` reserves the gutter the caret is absolutely positioned in (right-2 +\n w-4), so a value can never render underneath it. `min-w-0` lets the chips\n shrink below their content width, which is what makes truncation possible. -->\n <div class=\"flex flex-row items-center gap-x-2 flex-wrap min-h-6 min-w-0 pr-6\">\n @if (selectedOptions.length === 0) {\n <span class=\"text-base-content/50\">{{ placeholderLabel }}</span>\n } @else if (isCollapsed) {\n <span\n class=\"inline-flex items-center max-w-full truncate bg-base-200 border border-accent text-base-content text-xs px-2 py-0.5 rounded-md\">\n {{ collapseSummaryText }}\n </span>\n } @else {\n @for (opt of selectedOptions; track opt.value) {\n <!-- Only the \u00D7 removes. The chip body deliberately carries no handler, so a click\n anywhere on it bubbles to the trigger and just opens/closes the panel \u2014 clicking\n the trigger to dismiss the dropdown must never silently delete a selection. -->\n <span\n class=\"inline-flex items-center gap-x-1 max-w-full min-w-0 bg-base-200 border border-accent text-base-content text-xs pl-2 py-0.5 rounded-md\">\n <span [attr.title]=\"opt.label\" class=\"truncate\">{{ opt.label }}</span>\n <button\n mnButton\n [data]=\"{ size: 'sm', variant: 'text', color: 'secondary', hover: false }\"\n type=\"button\"\n class=\"text-base-content/50 cursor-pointer shrink-0\"\n (click)=\"removeOption(opt, $event)\"\n [attr.aria-label]=\"'Remove ' + opt.label\"\n ><svg [lucideIcon]=\"icons.X\" [size]=\"18\"></svg></button>\n </span>\n }\n }\n </div>\n <div class=\"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none\">\n <svg [size]=\"16\" class=\"text-base-content/50\" [lucideIcon]=\"icons.ChevronDown\"></svg>\n </div>\n </div>\n\n <!-- Dropdown -->\n @if (isOpen) {\n @if (isSheet) {\n <!-- On mobile the panel is presented as a shared bottom sheet: the sheet chrome\n (backdrop, grabber, swipe/flick-to-dismiss, slide animation) lives in\n mn-bottom-sheet; this component only projects the field's content into it.\n The sheet host is portalled to document.body (see the `sheet` ViewChild) so\n its `position: fixed` anchors to the viewport, not a transformed ancestor. -->\n <mn-bottom-sheet\n #sheet\n (dismiss)=\"close()\"\n [ariaLabel]=\"uiConfig.ariaLabel || uiConfig.label || props.label || uiConfig.placeholder || props.placeholder\"\n [maxHeightVh]=\"80\"\n [minHeightPx]=\"sheetFloorPx\"\n >\n <div\n [id]=\"resolvedId + '-listbox'\"\n aria-multiselectable=\"true\"\n class=\"flex flex-col flex-1 min-h-0 overflow-hidden\"\n role=\"listbox\"\n >\n <!-- The sheet covers its own trigger, so it carries a header to name the field; the\n way out is the grabber (swipe-to-dismiss) and a backdrop tap. -->\n <div class=\"px-4 pt-1 pb-2 shrink-0\">\n <p class=\"text-base font-medium text-base-content truncate\">\n {{ uiConfig.label || props.label || uiConfig.placeholder || props.placeholder || '' }}\n </p>\n </div>\n <ng-container [ngTemplateOutlet]=\"panelBody\"></ng-container>\n </div>\n </mn-bottom-sheet>\n } @else {\n <!-- A transparent full-viewport shield behind the panel, so \"click anywhere to\n dismiss\" is literally true. It also *consumes* that click: without it the click\n reaches whatever sits underneath \u2014 inside a modal that is the modal's own\n backdrop, so dismissing the dropdown would tear down the whole modal with it.\n Portalled to document.body for the same reason the panel is. It is aria-hidden\n and unfocusable: the keyboard equivalent of this click is Escape. -->\n <div\n #shield\n (click)=\"onShieldClick($event)\"\n [id]=\"resolvedId + '-shield'\"\n [ngClass]=\"shieldClasses\"\n aria-hidden=\"true\"\n ></div>\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n #dropdown\n (click)=\"$event.stopPropagation()\"\n [id]=\"resolvedId + '-listbox'\"\n [ngClass]=\"panelClasses\"\n [style.left]=\"dropdownStyle.left\"\n [style.top]=\"dropdownStyle.top\"\n [style.bottom]=\"dropdownStyle.bottom\"\n [style.max-height]=\"dropdownStyle.maxHeight\"\n [style.width]=\"dropdownStyle.width\"\n aria-multiselectable=\"true\"\n role=\"listbox\"\n >\n <ng-container [ngTemplateOutlet]=\"panelBody\"></ng-container>\n </div>\n }\n }\n\n <!-- The search box + option list, shared verbatim by the sheet and the anchored\n popover. `isSheet` only tunes spacing/sizing and which element scrolls: in sheet\n mode the list is the flex scroller; anchored, the popover itself scrolls. -->\n <ng-template #panelBody>\n @if (isSearchable) {\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"onKeydown($event, true)\"\n [ngClass]=\"isSheet ? 'px-4 py-2' : 'p-2'\"\n class=\"border-b border-base-300 shrink-0\"\n >\n <mn-lib-input-field\n (ngModelChange)=\"onSearch($event)\"\n [ngModelOptions]=\"{ standalone: true }\"\n [ngModel]=\"searchTerm\"\n [props]=\"{\n id: resolvedId + '-search',\n type: 'search',\n placeholder: searchPlaceholderLabel,\n ariaLabel: searchPlaceholderLabel,\n ariaActiveDescendant: activeOptionId,\n fullWidth: true,\n size: 'sm'\n }\"\n ></mn-lib-input-field>\n </div>\n }\n <div [ngClass]=\"isSheet ? 'flex-1 overflow-auto overscroll-contain' : ''\">\n @for (opt of filteredOptions; track opt.value) {\n <!-- Options are not Tab stops: the keyboard reaches them with the arrow keys while focus\n stays on the trigger or the search box, and `aria-activedescendant` names the one it\n is on. The ring marks that option, since it never receives real focus. -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"toggleOption(opt); $event.stopPropagation()\"\n [attr.aria-disabled]=\"opt.disabled || isMaxReached(opt) || null\"\n [attr.aria-selected]=\"isSelected(opt)\"\n [class.opacity-50]=\"opt.disabled || isMaxReached(opt)\"\n [class.pointer-events-none]=\"opt.disabled || isMaxReached(opt)\"\n [id]=\"optionId($index)\"\n [ngClass]=\"[isSheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm', $index === activeIndex ? 'ring-2 ring-inset ring-primary' : '']\"\n class=\"flex items-center gap-x-2 cursor-pointer text-base-content hover:bg-base-200\"\n role=\"option\"\n >\n <input\n [checked]=\"isSelected(opt)\"\n [disabled]=\"opt.disabled || isMaxReached(opt)\"\n class=\"w-4 h-4 accent-primary pointer-events-none shrink-0\"\n tabindex=\"-1\"\n type=\"checkbox\"\n />\n <span>{{ opt.label }}</span>\n </div>\n }\n @if (filteredOptions.length === 0) {\n <div [ngClass]=\"isSheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm'\" class=\"text-base-content/50\">\n {{ noOptionsLabel }}\n </div>\n }\n </div>\n </ng-template>\n\n @if (showError) {\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1 mt-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else {\n @if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n }\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: MnErrorMessage, selector: "mn-error-message", inputs: ["errorMessage", "id"] }, { 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: 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"] }] });
|
|
3750
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnMultiSelect, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3751
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: MnMultiSelect, isStandalone: true, selector: "mn-lib-multi-select", inputs: { props: "props" }, host: { listeners: { "document:click": "onDocumentClick($event)", "document:keydown.escape": "onEscape()", "window:scroll": "onWindowScrollOrResize()", "window:resize": "onWindowScrollOrResize()" } }, viewQueries: [{ propertyName: "triggerRef", first: true, predicate: ["trigger"], descendants: true }, { propertyName: "dropdownRef", first: true, predicate: ["dropdown"], descendants: true }, { propertyName: "shieldRef", first: true, predicate: ["shield"], descendants: true }, { propertyName: "sheetRef", first: true, predicate: ["sheet"], descendants: true, read: ElementRef }], ngImport: i0, template: "<div class=\"flex flex-col h-full\" [class.is-fullwidth]=\"props.fullWidth\">\n @if (uiConfig.label || props.label) {\n <label class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\" [attr.for]=\"resolvedId\">\n <p>{{ uiConfig.label || props.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n <!-- Trigger -->\n <div\n #trigger\n [id]=\"resolvedId\"\n [ngClass]=\"triggerClasses\"\n class=\"relative\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || props.label || null\"\n [attr.aria-invalid]=\"showError || null\"\n [attr.aria-describedby]=\"showError ? resolvedId + '-error' : null\"\n [attr.aria-expanded]=\"isOpen\"\n [attr.aria-controls]=\"isOpen ? resolvedId + '-listbox' : null\"\n role=\"combobox\"\n [attr.aria-required]=\"isRequired() || null\"\n tabindex=\"0\"\n (click)=\"toggle()\"\n (keydown)=\"onKeydown($event)\"\n [attr.aria-activedescendant]=\"activeOptionId\"\n (blur)=\"handleBlur()\"\n >\n <!-- `pr-6` reserves the gutter the caret is absolutely positioned in (right-2 +\n w-4), so a value can never render underneath it. `min-w-0` lets the chips\n shrink below their content width, which is what makes truncation possible. -->\n <div class=\"flex flex-row items-center gap-x-2 flex-wrap min-h-6 min-w-0 pr-6\">\n @if (selectedOptions.length === 0) {\n <span class=\"text-base-content/50\">{{ placeholderLabel }}</span>\n } @else if (isCollapsed) {\n <span\n class=\"inline-flex items-center max-w-full truncate bg-base-200 border border-accent text-base-content text-xs px-2 py-0.5 rounded-md\">\n {{ collapseSummaryText }}\n </span>\n } @else {\n @for (opt of selectedOptions; track opt.value) {\n <!-- Only the \u00D7 removes. The chip body deliberately carries no handler, so a click\n anywhere on it bubbles to the trigger and just opens/closes the panel \u2014 clicking\n the trigger to dismiss the dropdown must never silently delete a selection. -->\n <span\n class=\"inline-flex items-center gap-x-1 max-w-full min-w-0 bg-base-200 border border-accent text-base-content text-xs pl-2 py-0.5 rounded-md\">\n <span [attr.title]=\"opt.label\" class=\"truncate\">{{ opt.label }}</span>\n <button\n mnButton\n [data]=\"{ size: 'sm', variant: 'text', color: 'secondary', hover: false }\"\n type=\"button\"\n class=\"text-base-content/50 cursor-pointer shrink-0\"\n (click)=\"removeOption(opt, $event)\"\n [attr.aria-label]=\"'Remove ' + opt.label\"\n ><svg [lucideIcon]=\"icons.X\" [size]=\"18\"></svg></button>\n </span>\n }\n }\n </div>\n <div class=\"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none\">\n <svg [size]=\"16\" class=\"text-base-content/50\" [lucideIcon]=\"icons.ChevronDown\"></svg>\n </div>\n </div>\n\n <!-- Dropdown -->\n @if (isOpen) {\n @if (isSheet) {\n <!-- On mobile the panel is presented as a shared bottom sheet: the sheet chrome\n (backdrop, grabber, swipe/flick-to-dismiss, slide animation) lives in\n mn-bottom-sheet; this component only projects the field's content into it.\n The sheet host is portalled to document.body (see the `sheet` ViewChild) so\n its `position: fixed` anchors to the viewport, not a transformed ancestor. -->\n <mn-bottom-sheet\n #sheet\n (dismiss)=\"close()\"\n [ariaLabel]=\"uiConfig.ariaLabel || uiConfig.label || props.label || uiConfig.placeholder || props.placeholder\"\n [maxHeightVh]=\"80\"\n [minHeightPx]=\"sheetFloorPx\"\n >\n <div\n [id]=\"resolvedId + '-listbox'\"\n aria-multiselectable=\"true\"\n class=\"flex flex-col flex-1 min-h-0 overflow-hidden\"\n role=\"listbox\"\n >\n <!-- The sheet covers its own trigger, so it carries a header to name the field; the\n way out is the grabber (swipe-to-dismiss) and a backdrop tap. -->\n <div class=\"px-4 pt-1 pb-2 shrink-0\">\n <p class=\"text-base font-medium text-base-content truncate\">\n {{ uiConfig.label || props.label || uiConfig.placeholder || props.placeholder || '' }}\n </p>\n </div>\n <ng-container [ngTemplateOutlet]=\"panelBody\"></ng-container>\n </div>\n </mn-bottom-sheet>\n } @else {\n <!-- A transparent full-viewport shield behind the panel, so \"click anywhere to\n dismiss\" is literally true. It also *consumes* that click: without it the click\n reaches whatever sits underneath \u2014 inside a modal that is the modal's own\n backdrop, so dismissing the dropdown would tear down the whole modal with it.\n Portalled to document.body for the same reason the panel is. It is aria-hidden\n and unfocusable: the keyboard equivalent of this click is Escape. -->\n <div\n #shield\n (click)=\"onShieldClick($event)\"\n [id]=\"resolvedId + '-shield'\"\n [ngClass]=\"shieldClasses\"\n aria-hidden=\"true\"\n ></div>\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n #dropdown\n (click)=\"$event.stopPropagation()\"\n [id]=\"resolvedId + '-listbox'\"\n [ngClass]=\"panelClasses\"\n [style.left]=\"dropdownStyle.left\"\n [style.top]=\"dropdownStyle.top\"\n [style.bottom]=\"dropdownStyle.bottom\"\n [style.max-height]=\"dropdownStyle.maxHeight\"\n [style.width]=\"dropdownStyle.width\"\n aria-multiselectable=\"true\"\n role=\"listbox\"\n >\n <ng-container [ngTemplateOutlet]=\"panelBody\"></ng-container>\n </div>\n }\n }\n\n <!-- The search box + option list, shared verbatim by the sheet and the anchored\n popover. `isSheet` only tunes spacing/sizing and which element scrolls: in sheet\n mode the list is the flex scroller; anchored, the popover itself scrolls. -->\n <ng-template #panelBody>\n @if (isSearchable) {\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"onKeydown($event, true)\"\n [ngClass]=\"isSheet ? 'px-4 py-2' : 'p-2'\"\n class=\"border-b border-base-300 shrink-0\"\n >\n <mn-lib-input-field\n (ngModelChange)=\"onSearch($event)\"\n [ngModelOptions]=\"{ standalone: true }\"\n [ngModel]=\"searchTerm\"\n [props]=\"{\n id: resolvedId + '-search',\n type: 'search',\n placeholder: searchPlaceholderLabel,\n ariaLabel: searchPlaceholderLabel,\n ariaActiveDescendant: activeOptionId,\n fullWidth: true,\n size: 'sm'\n }\"\n ></mn-lib-input-field>\n </div>\n }\n <div [ngClass]=\"isSheet ? 'flex-1 overflow-auto overscroll-contain' : ''\">\n @for (opt of filteredOptions; track opt.value) {\n <!-- Options are not Tab stops: the keyboard reaches them with the arrow keys while focus\n stays on the trigger or the search box, and `aria-activedescendant` names the one it\n is on. The ring marks that option, since it never receives real focus. -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"toggleOption(opt); $event.stopPropagation()\"\n [attr.aria-disabled]=\"opt.disabled || isMaxReached(opt) || null\"\n [attr.aria-selected]=\"isSelected(opt)\"\n [class.opacity-50]=\"opt.disabled || isMaxReached(opt)\"\n [class.pointer-events-none]=\"opt.disabled || isMaxReached(opt)\"\n [id]=\"optionId($index)\"\n [ngClass]=\"[isSheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm', $index === activeIndex ? 'ring-2 ring-inset ring-primary' : '']\"\n class=\"flex items-center gap-x-2 cursor-pointer text-base-content hover:bg-base-200\"\n role=\"option\"\n >\n <input\n [checked]=\"isSelected(opt)\"\n [disabled]=\"opt.disabled || isMaxReached(opt)\"\n class=\"w-4 h-4 accent-primary pointer-events-none shrink-0\"\n tabindex=\"-1\"\n type=\"checkbox\"\n />\n <span>{{ opt.label }}</span>\n </div>\n }\n @if (filteredOptions.length === 0) {\n <div [ngClass]=\"isSheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm'\" class=\"text-base-content/50\">\n {{ noOptionsLabel }}\n </div>\n }\n </div>\n </ng-template>\n\n @if (showError) {\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1 mt-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else {\n @if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n }\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: MnErrorMessage, selector: "mn-error-message", inputs: ["errorMessage", "id"] }, { 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: 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"] }] });
|
|
3587
3752
|
}
|
|
3588
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
3753
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnMultiSelect, decorators: [{
|
|
3589
3754
|
type: Component,
|
|
3590
|
-
args: [{ selector: 'mn-lib-multi-select', standalone: true, imports: [
|
|
3755
|
+
args: [{ selector: 'mn-lib-multi-select', standalone: true, imports: [
|
|
3756
|
+
NgClass,
|
|
3757
|
+
NgTemplateOutlet,
|
|
3758
|
+
FormsModule,
|
|
3759
|
+
MnErrorMessage,
|
|
3760
|
+
MnButton,
|
|
3761
|
+
MnInputField,
|
|
3762
|
+
MnBottomSheet,
|
|
3763
|
+
LucideDynamicIcon,
|
|
3764
|
+
], template: "<div class=\"flex flex-col h-full\" [class.is-fullwidth]=\"props.fullWidth\">\n @if (uiConfig.label || props.label) {\n <label class=\"pl-2 pb-1 flex flex-row gap-x-0.5! text-base!\" [attr.for]=\"resolvedId\">\n <p>{{ uiConfig.label || props.label }}</p>\n @if (isRequired()) {\n <span class=\"text-error\" aria-hidden=\"true\">*</span>\n }\n </label>\n }\n\n <!-- Trigger -->\n <div\n #trigger\n [id]=\"resolvedId\"\n [ngClass]=\"triggerClasses\"\n class=\"relative\"\n [attr.aria-label]=\"uiConfig.ariaLabel || uiConfig.label || props.label || null\"\n [attr.aria-invalid]=\"showError || null\"\n [attr.aria-describedby]=\"showError ? resolvedId + '-error' : null\"\n [attr.aria-expanded]=\"isOpen\"\n [attr.aria-controls]=\"isOpen ? resolvedId + '-listbox' : null\"\n role=\"combobox\"\n [attr.aria-required]=\"isRequired() || null\"\n tabindex=\"0\"\n (click)=\"toggle()\"\n (keydown)=\"onKeydown($event)\"\n [attr.aria-activedescendant]=\"activeOptionId\"\n (blur)=\"handleBlur()\"\n >\n <!-- `pr-6` reserves the gutter the caret is absolutely positioned in (right-2 +\n w-4), so a value can never render underneath it. `min-w-0` lets the chips\n shrink below their content width, which is what makes truncation possible. -->\n <div class=\"flex flex-row items-center gap-x-2 flex-wrap min-h-6 min-w-0 pr-6\">\n @if (selectedOptions.length === 0) {\n <span class=\"text-base-content/50\">{{ placeholderLabel }}</span>\n } @else if (isCollapsed) {\n <span\n class=\"inline-flex items-center max-w-full truncate bg-base-200 border border-accent text-base-content text-xs px-2 py-0.5 rounded-md\">\n {{ collapseSummaryText }}\n </span>\n } @else {\n @for (opt of selectedOptions; track opt.value) {\n <!-- Only the \u00D7 removes. The chip body deliberately carries no handler, so a click\n anywhere on it bubbles to the trigger and just opens/closes the panel \u2014 clicking\n the trigger to dismiss the dropdown must never silently delete a selection. -->\n <span\n class=\"inline-flex items-center gap-x-1 max-w-full min-w-0 bg-base-200 border border-accent text-base-content text-xs pl-2 py-0.5 rounded-md\">\n <span [attr.title]=\"opt.label\" class=\"truncate\">{{ opt.label }}</span>\n <button\n mnButton\n [data]=\"{ size: 'sm', variant: 'text', color: 'secondary', hover: false }\"\n type=\"button\"\n class=\"text-base-content/50 cursor-pointer shrink-0\"\n (click)=\"removeOption(opt, $event)\"\n [attr.aria-label]=\"'Remove ' + opt.label\"\n ><svg [lucideIcon]=\"icons.X\" [size]=\"18\"></svg></button>\n </span>\n }\n }\n </div>\n <div class=\"absolute right-2 top-1/2 -translate-y-1/2 pointer-events-none\">\n <svg [size]=\"16\" class=\"text-base-content/50\" [lucideIcon]=\"icons.ChevronDown\"></svg>\n </div>\n </div>\n\n <!-- Dropdown -->\n @if (isOpen) {\n @if (isSheet) {\n <!-- On mobile the panel is presented as a shared bottom sheet: the sheet chrome\n (backdrop, grabber, swipe/flick-to-dismiss, slide animation) lives in\n mn-bottom-sheet; this component only projects the field's content into it.\n The sheet host is portalled to document.body (see the `sheet` ViewChild) so\n its `position: fixed` anchors to the viewport, not a transformed ancestor. -->\n <mn-bottom-sheet\n #sheet\n (dismiss)=\"close()\"\n [ariaLabel]=\"uiConfig.ariaLabel || uiConfig.label || props.label || uiConfig.placeholder || props.placeholder\"\n [maxHeightVh]=\"80\"\n [minHeightPx]=\"sheetFloorPx\"\n >\n <div\n [id]=\"resolvedId + '-listbox'\"\n aria-multiselectable=\"true\"\n class=\"flex flex-col flex-1 min-h-0 overflow-hidden\"\n role=\"listbox\"\n >\n <!-- The sheet covers its own trigger, so it carries a header to name the field; the\n way out is the grabber (swipe-to-dismiss) and a backdrop tap. -->\n <div class=\"px-4 pt-1 pb-2 shrink-0\">\n <p class=\"text-base font-medium text-base-content truncate\">\n {{ uiConfig.label || props.label || uiConfig.placeholder || props.placeholder || '' }}\n </p>\n </div>\n <ng-container [ngTemplateOutlet]=\"panelBody\"></ng-container>\n </div>\n </mn-bottom-sheet>\n } @else {\n <!-- A transparent full-viewport shield behind the panel, so \"click anywhere to\n dismiss\" is literally true. It also *consumes* that click: without it the click\n reaches whatever sits underneath \u2014 inside a modal that is the modal's own\n backdrop, so dismissing the dropdown would tear down the whole modal with it.\n Portalled to document.body for the same reason the panel is. It is aria-hidden\n and unfocusable: the keyboard equivalent of this click is Escape. -->\n <div\n #shield\n (click)=\"onShieldClick($event)\"\n [id]=\"resolvedId + '-shield'\"\n [ngClass]=\"shieldClasses\"\n aria-hidden=\"true\"\n ></div>\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n #dropdown\n (click)=\"$event.stopPropagation()\"\n [id]=\"resolvedId + '-listbox'\"\n [ngClass]=\"panelClasses\"\n [style.left]=\"dropdownStyle.left\"\n [style.top]=\"dropdownStyle.top\"\n [style.bottom]=\"dropdownStyle.bottom\"\n [style.max-height]=\"dropdownStyle.maxHeight\"\n [style.width]=\"dropdownStyle.width\"\n aria-multiselectable=\"true\"\n role=\"listbox\"\n >\n <ng-container [ngTemplateOutlet]=\"panelBody\"></ng-container>\n </div>\n }\n }\n\n <!-- The search box + option list, shared verbatim by the sheet and the anchored\n popover. `isSheet` only tunes spacing/sizing and which element scrolls: in sheet\n mode the list is the flex scroller; anchored, the popover itself scrolls. -->\n <ng-template #panelBody>\n @if (isSearchable) {\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"$event.stopPropagation()\"\n (keydown)=\"onKeydown($event, true)\"\n [ngClass]=\"isSheet ? 'px-4 py-2' : 'p-2'\"\n class=\"border-b border-base-300 shrink-0\"\n >\n <mn-lib-input-field\n (ngModelChange)=\"onSearch($event)\"\n [ngModelOptions]=\"{ standalone: true }\"\n [ngModel]=\"searchTerm\"\n [props]=\"{\n id: resolvedId + '-search',\n type: 'search',\n placeholder: searchPlaceholderLabel,\n ariaLabel: searchPlaceholderLabel,\n ariaActiveDescendant: activeOptionId,\n fullWidth: true,\n size: 'sm'\n }\"\n ></mn-lib-input-field>\n </div>\n }\n <div [ngClass]=\"isSheet ? 'flex-1 overflow-auto overscroll-contain' : ''\">\n @for (opt of filteredOptions; track opt.value) {\n <!-- Options are not Tab stops: the keyboard reaches them with the arrow keys while focus\n stays on the trigger or the search box, and `aria-activedescendant` names the one it\n is on. The ring marks that option, since it never receives real focus. -->\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"toggleOption(opt); $event.stopPropagation()\"\n [attr.aria-disabled]=\"opt.disabled || isMaxReached(opt) || null\"\n [attr.aria-selected]=\"isSelected(opt)\"\n [class.opacity-50]=\"opt.disabled || isMaxReached(opt)\"\n [class.pointer-events-none]=\"opt.disabled || isMaxReached(opt)\"\n [id]=\"optionId($index)\"\n [ngClass]=\"[isSheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm', $index === activeIndex ? 'ring-2 ring-inset ring-primary' : '']\"\n class=\"flex items-center gap-x-2 cursor-pointer text-base-content hover:bg-base-200\"\n role=\"option\"\n >\n <input\n [checked]=\"isSelected(opt)\"\n [disabled]=\"opt.disabled || isMaxReached(opt)\"\n class=\"w-4 h-4 accent-primary pointer-events-none shrink-0\"\n tabindex=\"-1\"\n type=\"checkbox\"\n />\n <span>{{ opt.label }}</span>\n </div>\n }\n @if (filteredOptions.length === 0) {\n <div [ngClass]=\"isSheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm'\" class=\"text-base-content/50\">\n {{ noOptionsLabel }}\n </div>\n }\n </div>\n </ng-template>\n\n @if (showError) {\n @if (props.showAllErrors) {\n <div class=\"flex flex-col gap-y-1 mt-1\">\n @for (error of errorMessages; track $index) {\n <mn-error-message [errorMessage]=\"error\" [id]=\"resolvedId + '-' + $index\"></mn-error-message>\n }\n </div>\n } @else {\n @if (errorMessage !== null) {\n <mn-error-message [errorMessage]=\"errorMessage\" [id]=\"resolvedId\"></mn-error-message>\n }\n }\n }\n</div>\n" }]
|
|
3591
3765
|
}], ctorParameters: () => [], propDecorators: { props: [{
|
|
3592
3766
|
type: Input,
|
|
3593
3767
|
args: [{ required: true }]
|
|
@@ -3856,7 +4030,10 @@ class MnDropdown {
|
|
|
3856
4030
|
}
|
|
3857
4031
|
if (this.datasource.actions.length === 0)
|
|
3858
4032
|
return;
|
|
4033
|
+
// `toggle()` and `close()` are public API: a consumer holding a @ViewChild can
|
|
4034
|
+
// open the panel without an event, and under OnPush nothing else marks this view.
|
|
3859
4035
|
this.isOpen = true;
|
|
4036
|
+
this.cdr.markForCheck();
|
|
3860
4037
|
if (this.isSheet) {
|
|
3861
4038
|
// A sheet is anchored to the viewport, so it needs no trigger tracking — only a
|
|
3862
4039
|
// scroll lock so the page behind it stays put.
|
|
@@ -3871,6 +4048,7 @@ class MnDropdown {
|
|
|
3871
4048
|
if (!this.isOpen)
|
|
3872
4049
|
return;
|
|
3873
4050
|
this.isOpen = false;
|
|
4051
|
+
this.cdr.markForCheck();
|
|
3874
4052
|
this.searchTerm = '';
|
|
3875
4053
|
this.panelFloorPx = null;
|
|
3876
4054
|
this.panelWidthPx = null;
|
|
@@ -3902,6 +4080,9 @@ class MnDropdown {
|
|
|
3902
4080
|
*/
|
|
3903
4081
|
onSearch(term) {
|
|
3904
4082
|
this.searchTerm = term ?? '';
|
|
4083
|
+
// Public, like toggle()/close(): a caller that is not an event handler still has to
|
|
4084
|
+
// see the list narrow.
|
|
4085
|
+
this.cdr.markForCheck();
|
|
3905
4086
|
}
|
|
3906
4087
|
/**
|
|
3907
4088
|
* The actions currently passing the filter, in their declared order. Every action when
|
|
@@ -3914,7 +4095,7 @@ class MnDropdown {
|
|
|
3914
4095
|
return this.datasource.actions;
|
|
3915
4096
|
// While filtering, separators are dropped — a divider stranded between or after hidden
|
|
3916
4097
|
// results is meaningless — so match only real actions.
|
|
3917
|
-
return this.datasource.actions.filter(item => {
|
|
4098
|
+
return this.datasource.actions.filter((item) => {
|
|
3918
4099
|
if (this.isSeparator(item))
|
|
3919
4100
|
return false;
|
|
3920
4101
|
const haystack = `${this.actionLabel(item)} ${item.keywords ?? ''}`.toLowerCase();
|
|
@@ -3948,8 +4129,8 @@ class MnDropdown {
|
|
|
3948
4129
|
this.stopWatchingTrigger();
|
|
3949
4130
|
const trigger = this.triggerRef?.nativeElement;
|
|
3950
4131
|
if (trigger && typeof IntersectionObserver !== 'undefined') {
|
|
3951
|
-
this.visibilityObserver = new IntersectionObserver(entries => {
|
|
3952
|
-
if (!entries.some(entry => !entry.isIntersecting))
|
|
4132
|
+
this.visibilityObserver = new IntersectionObserver((entries) => {
|
|
4133
|
+
if (!entries.some((entry) => !entry.isIntersecting))
|
|
3953
4134
|
return;
|
|
3954
4135
|
this.close();
|
|
3955
4136
|
this.cdr.markForCheck();
|
|
@@ -3958,7 +4139,9 @@ class MnDropdown {
|
|
|
3958
4139
|
}
|
|
3959
4140
|
this.scrollCapture = (event) => {
|
|
3960
4141
|
const target = event.target;
|
|
3961
|
-
if (target &&
|
|
4142
|
+
if (target &&
|
|
4143
|
+
this.movedPanel &&
|
|
4144
|
+
(this.movedPanel === target || this.movedPanel.contains(target))) {
|
|
3962
4145
|
return;
|
|
3963
4146
|
}
|
|
3964
4147
|
this.close();
|
|
@@ -4121,12 +4304,16 @@ class MnDropdown {
|
|
|
4121
4304
|
}
|
|
4122
4305
|
/** Accessible name for the ⋯ trigger button. */
|
|
4123
4306
|
get triggerAriaLabel() {
|
|
4124
|
-
const translated = this.datasource.ariaLabelKey
|
|
4307
|
+
const translated = this.datasource.ariaLabelKey
|
|
4308
|
+
? this.lang.translateIfPresent(this.datasource.ariaLabelKey)
|
|
4309
|
+
: undefined;
|
|
4125
4310
|
return translated ?? this.datasource.ariaLabel ?? this.uiConfig.ariaLabel ?? 'Actions';
|
|
4126
4311
|
}
|
|
4127
4312
|
/** The visible text on the trigger, or null for an icon-only ⋯ trigger. */
|
|
4128
4313
|
get triggerLabelText() {
|
|
4129
|
-
const translated = this.datasource.triggerLabelKey
|
|
4314
|
+
const translated = this.datasource.triggerLabelKey
|
|
4315
|
+
? this.lang.translateIfPresent(this.datasource.triggerLabelKey)
|
|
4316
|
+
: undefined;
|
|
4130
4317
|
return translated ?? this.datasource.triggerLabel ?? null;
|
|
4131
4318
|
}
|
|
4132
4319
|
/**
|
|
@@ -4165,18 +4352,30 @@ class MnDropdown {
|
|
|
4165
4352
|
}
|
|
4166
4353
|
/** Heading shown above the menu/sheet, or null when none is configured. */
|
|
4167
4354
|
get menuLabel() {
|
|
4168
|
-
const translated = this.datasource.menuLabelKey
|
|
4355
|
+
const translated = this.datasource.menuLabelKey
|
|
4356
|
+
? this.lang.translateIfPresent(this.datasource.menuLabelKey)
|
|
4357
|
+
: undefined;
|
|
4169
4358
|
return translated ?? this.datasource.menuLabel ?? this.uiConfig.menuLabel ?? null;
|
|
4170
4359
|
}
|
|
4171
4360
|
/** Placeholder shown in the search input, preferring a resolved translation key. */
|
|
4172
4361
|
get searchPlaceholder() {
|
|
4173
|
-
const translated = this.datasource.searchPlaceholderKey
|
|
4174
|
-
|
|
4362
|
+
const translated = this.datasource.searchPlaceholderKey
|
|
4363
|
+
? this.lang.translateIfPresent(this.datasource.searchPlaceholderKey)
|
|
4364
|
+
: undefined;
|
|
4365
|
+
return (translated ??
|
|
4366
|
+
this.datasource.searchPlaceholder ??
|
|
4367
|
+
this.uiConfig.searchPlaceholder ??
|
|
4368
|
+
'Search...');
|
|
4175
4369
|
}
|
|
4176
4370
|
/** Text shown in place of the list when the filter matches no actions. */
|
|
4177
4371
|
get searchEmptyLabel() {
|
|
4178
|
-
const translated = this.datasource.searchEmptyLabelKey
|
|
4179
|
-
|
|
4372
|
+
const translated = this.datasource.searchEmptyLabelKey
|
|
4373
|
+
? this.lang.translateIfPresent(this.datasource.searchEmptyLabelKey)
|
|
4374
|
+
: undefined;
|
|
4375
|
+
return (translated ??
|
|
4376
|
+
this.datasource.searchEmptyLabel ??
|
|
4377
|
+
this.uiConfig.searchEmptyLabel ??
|
|
4378
|
+
'No results');
|
|
4180
4379
|
}
|
|
4181
4380
|
/** The ghost look the trigger has always used; a bare or partial `triggerButton` merges
|
|
4182
4381
|
* over this, so opting in without overriding anything keeps the current appearance. */
|
|
@@ -4212,12 +4411,20 @@ class MnDropdown {
|
|
|
4212
4411
|
get resolvedId() {
|
|
4213
4412
|
return this.datasource.id ?? this.autoId;
|
|
4214
4413
|
}
|
|
4215
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
4216
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
4414
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnDropdown, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4415
|
+
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.1.7", type: MnDropdown, isStandalone: true, selector: "mn-lib-dropdown", inputs: { datasource: "datasource" }, host: { listeners: { "document:click": "onDocumentClick($event)", "document:keydown.escape": "onEscape()", "window:scroll": "onWindowScrollOrResize()", "window:resize": "onWindowScrollOrResize()" } }, viewQueries: [{ propertyName: "triggerRef", first: true, predicate: ["trigger"], descendants: true, read: ElementRef }, { propertyName: "dropdownRef", first: true, predicate: ["dropdown"], descendants: true }, { propertyName: "sheetRef", first: true, predicate: ["sheet"], descendants: true, read: ElementRef }], ngImport: i0, template: "<div class=\"relative inline-flex\">\n <!-- Trigger -->\n <button\n #trigger\n mnButton\n type=\"button\"\n [id]=\"resolvedId\"\n [data]=\"triggerData\"\n [ngClass]=\"triggerClasses\"\n [attr.aria-label]=\"triggerLabelText ? null : triggerAriaLabel\"\n [attr.aria-haspopup]=\"'menu'\"\n [attr.aria-expanded]=\"isOpen\"\n [attr.aria-controls]=\"isOpen ? resolvedId + '-menu' : null\"\n (click)=\"toggle()\"\n >\n @if (triggerLabelText) {\n <span class=\"truncate\">{{ triggerLabelText }}</span>\n }\n <!-- One glyph, rendered like a menu item's icon: a caller's template, else lucide data\n (a preset resolves to its own data). No per-preset switch. -->\n @if (triggerIconTemplate; as tpl) {\n <span class=\"shrink-0 inline-flex items-center\">\n <ng-container [ngTemplateOutlet]=\"tpl\"></ng-container>\n </span>\n } @else if (triggerIconData; as glyph) {\n <span class=\"shrink-0 inline-flex items-center\">\n <svg [lucideIcon]=\"glyph.data\" [size]=\"glyph.size\" [class.opacity-70]=\"glyph.dim\"></svg>\n </span>\n }\n </button>\n\n <!-- Menu -->\n @if (isOpen) {\n @if (isSheet) {\n <!-- On mobile the menu is presented as the shared bottom sheet: chrome (backdrop,\n grabber, swipe-to-dismiss, slide animation) lives in mn-bottom-sheet; this\n component only projects the item list into it. The host is portalled to\n document.body (see the `sheet` ViewChild). -->\n <mn-bottom-sheet\n #sheet\n (dismiss)=\"close()\"\n [ariaLabel]=\"menuLabel || triggerAriaLabel\"\n [maxHeightVh]=\"80\"\n [minHeightPx]=\"sheetFloorPx\"\n >\n <div [id]=\"resolvedId + '-menu'\" role=\"menu\" class=\"flex flex-col flex-1 min-h-0 overflow-hidden\">\n <!-- The sheet covers its own trigger, so it carries a header to name itself; the\n way out is the grabber (swipe-to-dismiss) and a backdrop tap. -->\n <div class=\"px-4 pt-1 pb-2 shrink-0\">\n <p class=\"text-base font-bold text-base-content truncate\">{{ menuLabel || triggerAriaLabel }}</p>\n </div>\n <ng-container [ngTemplateOutlet]=\"searchBox\" [ngTemplateOutletContext]=\"{ sheet: true }\"></ng-container>\n <div class=\"flex-1 flex flex-col overflow-auto overscroll-contain\">\n <ng-container [ngTemplateOutlet]=\"items\" [ngTemplateOutletContext]=\"{ sheet: true }\"></ng-container>\n </div>\n </div>\n </mn-bottom-sheet>\n } @else {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n #dropdown\n (click)=\"$event.stopPropagation()\"\n [id]=\"resolvedId + '-menu'\"\n [ngClass]=\"panelClasses\"\n [style.left]=\"dropdownStyle.left\"\n [style.top]=\"dropdownStyle.top\"\n [style.bottom]=\"dropdownStyle.bottom\"\n [style.max-height]=\"dropdownStyle.maxHeight\"\n [style.height.px]=\"panelFloorPx\"\n [style.width.px]=\"panelWidthPx\"\n role=\"menu\"\n >\n @if (menuLabel) {\n <p class=\"px-3 pt-1 pb-1.5 text-xs font-medium text-base-content/50 truncate shrink-0\">{{ menuLabel }}</p>\n }\n <ng-container [ngTemplateOutlet]=\"searchBox\" [ngTemplateOutletContext]=\"{ sheet: false }\"></ng-container>\n @if (isSearchable) {\n <!-- Its own scroll region so the pinned search box above stays fixed and the\n locked panel height (panelFloorPx) doesn't change as the list filters. The\n flex column lets the empty state fill and centre in the reserved space. -->\n <div class=\"flex-1 min-h-0 flex flex-col overflow-auto\">\n <ng-container [ngTemplateOutlet]=\"items\" [ngTemplateOutletContext]=\"{ sheet: false }\"></ng-container>\n </div>\n } @else {\n <ng-container [ngTemplateOutlet]=\"items\" [ngTemplateOutletContext]=\"{ sheet: false }\"></ng-container>\n }\n </div>\n }\n }\n\n <!-- The item list, shared verbatim by the sheet and the anchored popover. `sheet`\n only tunes the spacing so touch targets are roomier on mobile. -->\n <ng-template #items let-sheet=\"sheet\">\n @for (item of filteredActions; track $index) {\n @if (asAction(item); as action) {\n <button\n type=\"button\"\n role=\"menuitem\"\n [disabled]=\"action.disabled\"\n [attr.aria-current]=\"action.active ? 'true' : null\"\n [class.opacity-50]=\"action.disabled\"\n [class.pointer-events-none]=\"action.disabled\"\n [ngClass]=\"[actionColorClass(action), sheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm', action.active ? 'bg-primary/10 font-medium' : '']\"\n class=\"flex w-full shrink-0 items-center gap-x-2.5 text-left cursor-pointer hover:bg-base-200 focus-visible:bg-base-200 focus:outline-none transition-colors\"\n (click)=\"select(action)\"\n >\n @if (action.icon) {\n <span class=\"shrink-0 inline-flex items-center\">\n @if (isTemplateRef(action.icon)) {\n <ng-container [ngTemplateOutlet]=\"action.icon\"></ng-container>\n } @else {\n <!-- Data icon: rendered here so the item sizes it to match its own text\n (larger in the sheet, where the rows are touch-sized). -->\n <svg [lucideIcon]=\"$any(action.icon)\" [size]=\"sheet ? 18 : 16\"></svg>\n }\n </span>\n }\n <span class=\"truncate min-w-0\">{{ actionLabel(action) }}</span>\n <!-- The current choice's marker (e.g. the active language). Decorative: the\n state is conveyed to assistive tech by `aria-current` on the row. -->\n @if (action.active) {\n <svg\n [lucideIcon]=\"checkIcon\"\n [size]=\"sheet ? 18 : 16\"\n class=\"ml-auto shrink-0 text-primary\"\n aria-hidden=\"true\"\n ></svg>\n }\n </button>\n } @else {\n <hr role=\"separator\" [ngClass]=\"sheet ? 'mx-4 my-1.5' : 'mx-2 my-1'\" class=\"shrink-0 border-t border-base-300\" />\n }\n }\n @if (isSearchable && filteredActions.length === 0) {\n <div class=\"flex-1 flex flex-col items-center justify-center gap-2 px-4 py-6 text-center text-base-content/50\">\n <svg [lucideIcon]=\"icons.SearchX\" [size]=\"sheet ? 28 : 24\" class=\"opacity-60\"></svg>\n <span [ngClass]=\"sheet ? 'text-base' : 'text-sm'\">{{ searchEmptyLabel }}</span>\n </div>\n }\n </ng-template>\n\n <!-- The filter input, shared by the sheet and the anchored popover. Autofocused on\n desktop (`!sheet`) so typing starts immediately; deliberately not on mobile, where\n it would pop the soft keyboard and fight the viewport-anchored sheet. Enter runs\n the first visible action via the wrapper's bubbled keydown. -->\n <ng-template #searchBox let-sheet=\"sheet\">\n @if (isSearchable) {\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"$event.stopPropagation()\"\n (keydown.enter)=\"selectFirstVisible()\"\n [ngClass]=\"sheet ? 'px-4 py-2' : 'p-2'\"\n class=\"border-b border-base-300 shrink-0\"\n >\n <mn-lib-input-field\n (ngModelChange)=\"onSearch($event)\"\n [ngModelOptions]=\"{ standalone: true }\"\n [ngModel]=\"searchTerm\"\n [props]=\"{\n id: resolvedId + '-search',\n type: 'search',\n placeholder: searchPlaceholder,\n ariaLabel: searchPlaceholder,\n fullWidth: true,\n size: 'sm',\n autoFocus: !sheet\n }\"\n ></mn-lib-input-field>\n </div>\n }\n </ng-template>\n</div>\n", styles: [""], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { 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: MnInputField, selector: "mn-lib-input-field", inputs: ["props"] }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }] });
|
|
4217
4416
|
}
|
|
4218
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
4417
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnDropdown, decorators: [{
|
|
4219
4418
|
type: Component,
|
|
4220
|
-
args: [{ selector: 'mn-lib-dropdown', standalone: true, imports: [
|
|
4419
|
+
args: [{ selector: 'mn-lib-dropdown', standalone: true, imports: [
|
|
4420
|
+
NgClass,
|
|
4421
|
+
NgTemplateOutlet,
|
|
4422
|
+
FormsModule,
|
|
4423
|
+
MnButton,
|
|
4424
|
+
MnBottomSheet,
|
|
4425
|
+
MnInputField,
|
|
4426
|
+
LucideDynamicIcon,
|
|
4427
|
+
], template: "<div class=\"relative inline-flex\">\n <!-- Trigger -->\n <button\n #trigger\n mnButton\n type=\"button\"\n [id]=\"resolvedId\"\n [data]=\"triggerData\"\n [ngClass]=\"triggerClasses\"\n [attr.aria-label]=\"triggerLabelText ? null : triggerAriaLabel\"\n [attr.aria-haspopup]=\"'menu'\"\n [attr.aria-expanded]=\"isOpen\"\n [attr.aria-controls]=\"isOpen ? resolvedId + '-menu' : null\"\n (click)=\"toggle()\"\n >\n @if (triggerLabelText) {\n <span class=\"truncate\">{{ triggerLabelText }}</span>\n }\n <!-- One glyph, rendered like a menu item's icon: a caller's template, else lucide data\n (a preset resolves to its own data). No per-preset switch. -->\n @if (triggerIconTemplate; as tpl) {\n <span class=\"shrink-0 inline-flex items-center\">\n <ng-container [ngTemplateOutlet]=\"tpl\"></ng-container>\n </span>\n } @else if (triggerIconData; as glyph) {\n <span class=\"shrink-0 inline-flex items-center\">\n <svg [lucideIcon]=\"glyph.data\" [size]=\"glyph.size\" [class.opacity-70]=\"glyph.dim\"></svg>\n </span>\n }\n </button>\n\n <!-- Menu -->\n @if (isOpen) {\n @if (isSheet) {\n <!-- On mobile the menu is presented as the shared bottom sheet: chrome (backdrop,\n grabber, swipe-to-dismiss, slide animation) lives in mn-bottom-sheet; this\n component only projects the item list into it. The host is portalled to\n document.body (see the `sheet` ViewChild). -->\n <mn-bottom-sheet\n #sheet\n (dismiss)=\"close()\"\n [ariaLabel]=\"menuLabel || triggerAriaLabel\"\n [maxHeightVh]=\"80\"\n [minHeightPx]=\"sheetFloorPx\"\n >\n <div [id]=\"resolvedId + '-menu'\" role=\"menu\" class=\"flex flex-col flex-1 min-h-0 overflow-hidden\">\n <!-- The sheet covers its own trigger, so it carries a header to name itself; the\n way out is the grabber (swipe-to-dismiss) and a backdrop tap. -->\n <div class=\"px-4 pt-1 pb-2 shrink-0\">\n <p class=\"text-base font-bold text-base-content truncate\">{{ menuLabel || triggerAriaLabel }}</p>\n </div>\n <ng-container [ngTemplateOutlet]=\"searchBox\" [ngTemplateOutletContext]=\"{ sheet: true }\"></ng-container>\n <div class=\"flex-1 flex flex-col overflow-auto overscroll-contain\">\n <ng-container [ngTemplateOutlet]=\"items\" [ngTemplateOutletContext]=\"{ sheet: true }\"></ng-container>\n </div>\n </div>\n </mn-bottom-sheet>\n } @else {\n <!-- eslint-disable-next-line @angular-eslint/template/click-events-have-key-events,@angular-eslint/template/interactive-supports-focus -->\n <div\n #dropdown\n (click)=\"$event.stopPropagation()\"\n [id]=\"resolvedId + '-menu'\"\n [ngClass]=\"panelClasses\"\n [style.left]=\"dropdownStyle.left\"\n [style.top]=\"dropdownStyle.top\"\n [style.bottom]=\"dropdownStyle.bottom\"\n [style.max-height]=\"dropdownStyle.maxHeight\"\n [style.height.px]=\"panelFloorPx\"\n [style.width.px]=\"panelWidthPx\"\n role=\"menu\"\n >\n @if (menuLabel) {\n <p class=\"px-3 pt-1 pb-1.5 text-xs font-medium text-base-content/50 truncate shrink-0\">{{ menuLabel }}</p>\n }\n <ng-container [ngTemplateOutlet]=\"searchBox\" [ngTemplateOutletContext]=\"{ sheet: false }\"></ng-container>\n @if (isSearchable) {\n <!-- Its own scroll region so the pinned search box above stays fixed and the\n locked panel height (panelFloorPx) doesn't change as the list filters. The\n flex column lets the empty state fill and centre in the reserved space. -->\n <div class=\"flex-1 min-h-0 flex flex-col overflow-auto\">\n <ng-container [ngTemplateOutlet]=\"items\" [ngTemplateOutletContext]=\"{ sheet: false }\"></ng-container>\n </div>\n } @else {\n <ng-container [ngTemplateOutlet]=\"items\" [ngTemplateOutletContext]=\"{ sheet: false }\"></ng-container>\n }\n </div>\n }\n }\n\n <!-- The item list, shared verbatim by the sheet and the anchored popover. `sheet`\n only tunes the spacing so touch targets are roomier on mobile. -->\n <ng-template #items let-sheet=\"sheet\">\n @for (item of filteredActions; track $index) {\n @if (asAction(item); as action) {\n <button\n type=\"button\"\n role=\"menuitem\"\n [disabled]=\"action.disabled\"\n [attr.aria-current]=\"action.active ? 'true' : null\"\n [class.opacity-50]=\"action.disabled\"\n [class.pointer-events-none]=\"action.disabled\"\n [ngClass]=\"[actionColorClass(action), sheet ? 'px-4 py-3 text-base' : 'px-3 py-2 text-sm', action.active ? 'bg-primary/10 font-medium' : '']\"\n class=\"flex w-full shrink-0 items-center gap-x-2.5 text-left cursor-pointer hover:bg-base-200 focus-visible:bg-base-200 focus:outline-none transition-colors\"\n (click)=\"select(action)\"\n >\n @if (action.icon) {\n <span class=\"shrink-0 inline-flex items-center\">\n @if (isTemplateRef(action.icon)) {\n <ng-container [ngTemplateOutlet]=\"action.icon\"></ng-container>\n } @else {\n <!-- Data icon: rendered here so the item sizes it to match its own text\n (larger in the sheet, where the rows are touch-sized). -->\n <svg [lucideIcon]=\"$any(action.icon)\" [size]=\"sheet ? 18 : 16\"></svg>\n }\n </span>\n }\n <span class=\"truncate min-w-0\">{{ actionLabel(action) }}</span>\n <!-- The current choice's marker (e.g. the active language). Decorative: the\n state is conveyed to assistive tech by `aria-current` on the row. -->\n @if (action.active) {\n <svg\n [lucideIcon]=\"checkIcon\"\n [size]=\"sheet ? 18 : 16\"\n class=\"ml-auto shrink-0 text-primary\"\n aria-hidden=\"true\"\n ></svg>\n }\n </button>\n } @else {\n <hr role=\"separator\" [ngClass]=\"sheet ? 'mx-4 my-1.5' : 'mx-2 my-1'\" class=\"shrink-0 border-t border-base-300\" />\n }\n }\n @if (isSearchable && filteredActions.length === 0) {\n <div class=\"flex-1 flex flex-col items-center justify-center gap-2 px-4 py-6 text-center text-base-content/50\">\n <svg [lucideIcon]=\"icons.SearchX\" [size]=\"sheet ? 28 : 24\" class=\"opacity-60\"></svg>\n <span [ngClass]=\"sheet ? 'text-base' : 'text-sm'\">{{ searchEmptyLabel }}</span>\n </div>\n }\n </ng-template>\n\n <!-- The filter input, shared by the sheet and the anchored popover. Autofocused on\n desktop (`!sheet`) so typing starts immediately; deliberately not on mobile, where\n it would pop the soft keyboard and fight the viewport-anchored sheet. Enter runs\n the first visible action via the wrapper's bubbled keydown. -->\n <ng-template #searchBox let-sheet=\"sheet\">\n @if (isSearchable) {\n <!-- eslint-disable-next-line @angular-eslint/template/interactive-supports-focus -->\n <div\n (click)=\"$event.stopPropagation()\"\n (keydown.enter)=\"selectFirstVisible()\"\n [ngClass]=\"sheet ? 'px-4 py-2' : 'p-2'\"\n class=\"border-b border-base-300 shrink-0\"\n >\n <mn-lib-input-field\n (ngModelChange)=\"onSearch($event)\"\n [ngModelOptions]=\"{ standalone: true }\"\n [ngModel]=\"searchTerm\"\n [props]=\"{\n id: resolvedId + '-search',\n type: 'search',\n placeholder: searchPlaceholder,\n ariaLabel: searchPlaceholder,\n fullWidth: true,\n size: 'sm',\n autoFocus: !sheet\n }\"\n ></mn-lib-input-field>\n </div>\n }\n </ng-template>\n</div>\n" }]
|
|
4221
4428
|
}], propDecorators: { datasource: [{
|
|
4222
4429
|
type: Input,
|
|
4223
4430
|
args: [{ required: true }]
|