mn-angular-lib 1.0.179 → 2.0.1
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 +88 -45
- package/fesm2022/mn-angular-lib-display.mjs.map +1 -1
- package/fesm2022/mn-angular-lib-forms.mjs +243 -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 +80 -3
- 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
|
/**
|
|
@@ -337,6 +338,9 @@ class MnInputField {
|
|
|
337
338
|
this.resolveConfig();
|
|
338
339
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
339
340
|
this.resolveConfig();
|
|
341
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
342
|
+
// marks this view for the locale change.
|
|
343
|
+
this.cdr.markForCheck();
|
|
340
344
|
});
|
|
341
345
|
this.destroyRef.onDestroy(() => sub.unsubscribe());
|
|
342
346
|
if (this.props.autoFocus) {
|
|
@@ -381,6 +385,9 @@ class MnInputField {
|
|
|
381
385
|
*/
|
|
382
386
|
writeValue(val) {
|
|
383
387
|
this.value = this.adapter.format(val);
|
|
388
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
389
|
+
// this view for it.
|
|
390
|
+
this.cdr.markForCheck();
|
|
384
391
|
}
|
|
385
392
|
/**
|
|
386
393
|
* Registers a callback function to be called when the input value changes.
|
|
@@ -405,6 +412,9 @@ class MnInputField {
|
|
|
405
412
|
*/
|
|
406
413
|
setDisabledState(isDisabled) {
|
|
407
414
|
this.isDisabled = isDisabled;
|
|
415
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
416
|
+
// from the forms API, with no event behind it.
|
|
417
|
+
this.cdr.markForCheck();
|
|
408
418
|
}
|
|
409
419
|
// ========== Event Handlers ==========
|
|
410
420
|
/**
|
|
@@ -558,7 +568,7 @@ class MnInputField {
|
|
|
558
568
|
if (!errors)
|
|
559
569
|
return [];
|
|
560
570
|
const errorKeys = Object.keys(errors);
|
|
561
|
-
return errorKeys.map(key => this.resolveErrorMessageForKey(key, errors));
|
|
571
|
+
return errorKeys.map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
562
572
|
}
|
|
563
573
|
/**
|
|
564
574
|
* Gets a single error message for the current control state.
|
|
@@ -596,10 +606,10 @@ class MnInputField {
|
|
|
596
606
|
disabled: this.isDisabled,
|
|
597
607
|
});
|
|
598
608
|
}
|
|
599
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
600
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
609
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnInputField, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
610
|
+
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
611
|
}
|
|
602
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
612
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnInputField, decorators: [{
|
|
603
613
|
type: Component,
|
|
604
614
|
args: [{ selector: 'mn-lib-input-field', standalone: true, imports: [CommonModule, NgClass, MnErrorMessage, FormsModule], host: {
|
|
605
615
|
// Native inputs (notably `type="date"`) have a platform-specific intrinsic width.
|
|
@@ -685,12 +695,13 @@ class MnCheckbox {
|
|
|
685
695
|
configService = inject(MnConfigService);
|
|
686
696
|
sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
|
|
687
697
|
explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
|
|
698
|
+
/** Marks the view when a locale change re-resolves the config (OnPush). */
|
|
699
|
+
cdr = inject(ChangeDetectorRef);
|
|
688
700
|
lang = inject(MnLanguageService);
|
|
689
701
|
destroyRef = inject(DestroyRef);
|
|
690
702
|
value = false;
|
|
691
703
|
isDisabled = false;
|
|
692
|
-
onChange = () => {
|
|
693
|
-
};
|
|
704
|
+
onChange = () => { };
|
|
694
705
|
onTouched = () => { };
|
|
695
706
|
builtInErrorMessages = {
|
|
696
707
|
required: 'This field is required',
|
|
@@ -703,6 +714,9 @@ class MnCheckbox {
|
|
|
703
714
|
this.resolveConfig();
|
|
704
715
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
705
716
|
this.resolveConfig();
|
|
717
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
718
|
+
// marks this view for the locale change.
|
|
719
|
+
this.cdr.markForCheck();
|
|
706
720
|
});
|
|
707
721
|
this.destroyRef.onDestroy(() => sub.unsubscribe());
|
|
708
722
|
}
|
|
@@ -716,6 +730,9 @@ class MnCheckbox {
|
|
|
716
730
|
// ========== ControlValueAccessor Implementation ==========
|
|
717
731
|
writeValue(val) {
|
|
718
732
|
this.value = !!val;
|
|
733
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
734
|
+
// this view for it.
|
|
735
|
+
this.cdr.markForCheck();
|
|
719
736
|
}
|
|
720
737
|
/** Sync value from checked input when not using forms */
|
|
721
738
|
ngOnChanges() {
|
|
@@ -731,6 +748,9 @@ class MnCheckbox {
|
|
|
731
748
|
}
|
|
732
749
|
setDisabledState(isDisabled) {
|
|
733
750
|
this.isDisabled = isDisabled;
|
|
751
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
752
|
+
// from the forms API, with no event behind it.
|
|
753
|
+
this.cdr.markForCheck();
|
|
734
754
|
}
|
|
735
755
|
// ========== Event Handlers ==========
|
|
736
756
|
handleChange(checked) {
|
|
@@ -781,7 +801,7 @@ class MnCheckbox {
|
|
|
781
801
|
const errors = this.control?.errors;
|
|
782
802
|
if (!errors)
|
|
783
803
|
return [];
|
|
784
|
-
return Object.keys(errors).map(key => this.resolveErrorMessageForKey(key, errors));
|
|
804
|
+
return Object.keys(errors).map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
785
805
|
}
|
|
786
806
|
get errorMessage() {
|
|
787
807
|
const errors = this.control?.errors;
|
|
@@ -811,10 +831,10 @@ class MnCheckbox {
|
|
|
811
831
|
hover: this.props.hover,
|
|
812
832
|
});
|
|
813
833
|
}
|
|
814
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
815
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
834
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnCheckbox, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
835
|
+
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
836
|
}
|
|
817
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
837
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnCheckbox, decorators: [{
|
|
818
838
|
type: Component,
|
|
819
839
|
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
840
|
}], ctorParameters: () => [], propDecorators: { props: [{
|
|
@@ -907,6 +927,8 @@ class MnTextarea {
|
|
|
907
927
|
configService = inject(MnConfigService);
|
|
908
928
|
sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
|
|
909
929
|
explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
|
|
930
|
+
/** Marks the view when a locale change re-resolves the config (OnPush). */
|
|
931
|
+
cdr = inject(ChangeDetectorRef);
|
|
910
932
|
lang = inject(MnLanguageService);
|
|
911
933
|
destroyRef = inject(DestroyRef);
|
|
912
934
|
/** Current raw string value of the textarea element */
|
|
@@ -914,8 +936,7 @@ class MnTextarea {
|
|
|
914
936
|
/** Whether the textarea is disabled */
|
|
915
937
|
isDisabled = false;
|
|
916
938
|
/** Callback function to notify Angular forms of value changes */
|
|
917
|
-
onChange = () => {
|
|
918
|
-
};
|
|
939
|
+
onChange = () => { };
|
|
919
940
|
/** Callback function to notify Angular forms when textarea is touched/blurred */
|
|
920
941
|
onTouched = () => { };
|
|
921
942
|
/**
|
|
@@ -941,6 +962,9 @@ class MnTextarea {
|
|
|
941
962
|
this.resolveConfig();
|
|
942
963
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
943
964
|
this.resolveConfig();
|
|
965
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
966
|
+
// marks this view for the locale change.
|
|
967
|
+
this.cdr.markForCheck();
|
|
944
968
|
});
|
|
945
969
|
this.destroyRef.onDestroy(() => sub.unsubscribe());
|
|
946
970
|
if (this.props.autoFocus) {
|
|
@@ -974,6 +998,9 @@ class MnTextarea {
|
|
|
974
998
|
*/
|
|
975
999
|
writeValue(val) {
|
|
976
1000
|
this.value = val != null ? String(val) : null;
|
|
1001
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
1002
|
+
// this view for it.
|
|
1003
|
+
this.cdr.markForCheck();
|
|
977
1004
|
}
|
|
978
1005
|
/**
|
|
979
1006
|
* Registers a callback function to be called when the textarea value changes.
|
|
@@ -998,6 +1025,9 @@ class MnTextarea {
|
|
|
998
1025
|
*/
|
|
999
1026
|
setDisabledState(isDisabled) {
|
|
1000
1027
|
this.isDisabled = isDisabled;
|
|
1028
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
1029
|
+
// from the forms API, with no event behind it.
|
|
1030
|
+
this.cdr.markForCheck();
|
|
1001
1031
|
}
|
|
1002
1032
|
// ========== Event Handlers ==========
|
|
1003
1033
|
/**
|
|
@@ -1098,7 +1128,7 @@ class MnTextarea {
|
|
|
1098
1128
|
if (!errors)
|
|
1099
1129
|
return [];
|
|
1100
1130
|
const errorKeys = Object.keys(errors);
|
|
1101
|
-
return errorKeys.map(key => this.resolveErrorMessageForKey(key, errors));
|
|
1131
|
+
return errorKeys.map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
1102
1132
|
}
|
|
1103
1133
|
/**
|
|
1104
1134
|
* Gets a single error message for the current control state.
|
|
@@ -1134,10 +1164,10 @@ class MnTextarea {
|
|
|
1134
1164
|
resize: this.props.resize,
|
|
1135
1165
|
});
|
|
1136
1166
|
}
|
|
1137
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1138
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
1167
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnTextarea, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1168
|
+
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
1169
|
}
|
|
1140
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1170
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnTextarea, decorators: [{
|
|
1141
1171
|
type: Component,
|
|
1142
1172
|
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
1173
|
}], ctorParameters: () => [], propDecorators: { props: [{
|
|
@@ -1193,12 +1223,13 @@ class MnDatetime {
|
|
|
1193
1223
|
configService = inject(MnConfigService);
|
|
1194
1224
|
sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
|
|
1195
1225
|
explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
|
|
1226
|
+
/** Marks the view when a locale change re-resolves the config (OnPush). */
|
|
1227
|
+
cdr = inject(ChangeDetectorRef);
|
|
1196
1228
|
lang = inject(MnLanguageService);
|
|
1197
1229
|
destroyRef = inject(DestroyRef);
|
|
1198
1230
|
value = null;
|
|
1199
1231
|
isDisabled = false;
|
|
1200
|
-
onChange = () => {
|
|
1201
|
-
};
|
|
1232
|
+
onChange = () => { };
|
|
1202
1233
|
onTouched = () => { };
|
|
1203
1234
|
builtInErrorMessages = {
|
|
1204
1235
|
required: 'This field is required',
|
|
@@ -1213,6 +1244,9 @@ class MnDatetime {
|
|
|
1213
1244
|
this.resolveConfig();
|
|
1214
1245
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
1215
1246
|
this.resolveConfig();
|
|
1247
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
1248
|
+
// marks this view for the locale change.
|
|
1249
|
+
this.cdr.markForCheck();
|
|
1216
1250
|
});
|
|
1217
1251
|
this.destroyRef.onDestroy(() => sub.unsubscribe());
|
|
1218
1252
|
}
|
|
@@ -1243,6 +1277,9 @@ class MnDatetime {
|
|
|
1243
1277
|
else {
|
|
1244
1278
|
this.value = null;
|
|
1245
1279
|
}
|
|
1280
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
1281
|
+
// this view for it.
|
|
1282
|
+
this.cdr.markForCheck();
|
|
1246
1283
|
}
|
|
1247
1284
|
registerOnChange(fn) {
|
|
1248
1285
|
this.onChange = fn;
|
|
@@ -1252,6 +1289,9 @@ class MnDatetime {
|
|
|
1252
1289
|
}
|
|
1253
1290
|
setDisabledState(isDisabled) {
|
|
1254
1291
|
this.isDisabled = isDisabled;
|
|
1292
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
1293
|
+
// from the forms API, with no event behind it.
|
|
1294
|
+
this.cdr.markForCheck();
|
|
1255
1295
|
}
|
|
1256
1296
|
// ========== Event Handlers ==========
|
|
1257
1297
|
handleInput(raw) {
|
|
@@ -1309,7 +1349,7 @@ class MnDatetime {
|
|
|
1309
1349
|
const errors = this.control?.errors;
|
|
1310
1350
|
if (!errors)
|
|
1311
1351
|
return [];
|
|
1312
|
-
return Object.keys(errors).map(key => this.resolveErrorMessageForKey(key, errors));
|
|
1352
|
+
return Object.keys(errors).map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
1313
1353
|
}
|
|
1314
1354
|
get errorMessage() {
|
|
1315
1355
|
const errors = this.control?.errors;
|
|
@@ -1341,7 +1381,7 @@ class MnDatetime {
|
|
|
1341
1381
|
const explicit = this.uiConfig.ariaLabel || this.uiConfig.label || this.props.label;
|
|
1342
1382
|
if (explicit)
|
|
1343
1383
|
return explicit;
|
|
1344
|
-
return this.iconOnly ?
|
|
1384
|
+
return this.iconOnly ? this.uiConfig.placeholder || this.props.placeholder || null : null;
|
|
1345
1385
|
}
|
|
1346
1386
|
/** Lucide icon size (px) tracking the field size, used only in the icon-only variant. */
|
|
1347
1387
|
get iconSize() {
|
|
@@ -1383,10 +1423,10 @@ class MnDatetime {
|
|
|
1383
1423
|
'focus-within:outline-2 focus-within:outline-offset-2 focus-within:outline-primary',
|
|
1384
1424
|
].join(' ');
|
|
1385
1425
|
}
|
|
1386
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
1387
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
1426
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnDatetime, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
1427
|
+
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
1428
|
}
|
|
1389
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
1429
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnDatetime, decorators: [{
|
|
1390
1430
|
type: Component,
|
|
1391
1431
|
args: [{ selector: 'mn-lib-datetime', standalone: true, imports: [NgClass, NgTemplateOutlet, MnErrorMessage, LucideDynamicIcon], host: {
|
|
1392
1432
|
// Native date/time inputs have a platform-specific intrinsic width. Without an
|
|
@@ -1506,22 +1546,30 @@ class MnFileInput {
|
|
|
1506
1546
|
/** Resolved UI configuration for the file input. */
|
|
1507
1547
|
uiConfig = {};
|
|
1508
1548
|
/** Currently selected files (always an array internally). */
|
|
1509
|
-
files = signal([],
|
|
1549
|
+
files = signal([], /* @ts-ignore */
|
|
1550
|
+
...(ngDevMode ? [{ debugName: "files" }] : /* istanbul ignore next */ []));
|
|
1510
1551
|
/** True while files are dragged over the dropzone ("release to drop" state). */
|
|
1511
|
-
isDragging = signal(false,
|
|
1552
|
+
isDragging = signal(false, /* @ts-ignore */
|
|
1553
|
+
...(ngDevMode ? [{ debugName: "isDragging" }] : /* istanbul ignore next */ []));
|
|
1512
1554
|
/** Transient message for a rejected selection (accept/maxSize/maxFiles). */
|
|
1513
|
-
internalError = signal(null,
|
|
1555
|
+
internalError = signal(null, /* @ts-ignore */
|
|
1556
|
+
...(ngDevMode ? [{ debugName: "internalError" }] : /* istanbul ignore next */ []));
|
|
1514
1557
|
configService = inject(MnConfigService);
|
|
1515
1558
|
sectionPath = inject(MN_SECTION_PATH, { optional: true }) ?? [];
|
|
1516
1559
|
explicitInstanceId = inject(MN_INSTANCE_ID, { optional: true });
|
|
1560
|
+
/** Marks the view when a locale change re-resolves the config (OnPush). */
|
|
1561
|
+
cdr = inject(ChangeDetectorRef);
|
|
1517
1562
|
lang = inject(MnLanguageService);
|
|
1518
1563
|
destroyRef = inject(DestroyRef);
|
|
1519
1564
|
/** Object-URL previews aligned to {@link files}; null for non-image entries. */
|
|
1520
|
-
previewUrls = signal([],
|
|
1565
|
+
previewUrls = signal([], /* @ts-ignore */
|
|
1566
|
+
...(ngDevMode ? [{ debugName: "previewUrls" }] : /* istanbul ignore next */ []));
|
|
1521
1567
|
/** True once the user removed the single existing image. */
|
|
1522
|
-
currentCleared = signal(false,
|
|
1568
|
+
currentCleared = signal(false, /* @ts-ignore */
|
|
1569
|
+
...(ngDevMode ? [{ debugName: "currentCleared" }] : /* istanbul ignore next */ []));
|
|
1523
1570
|
/** Indices of removed existing images (multiple mode). */
|
|
1524
|
-
removedExisting = signal(new Set(),
|
|
1571
|
+
removedExisting = signal(new Set(), /* @ts-ignore */
|
|
1572
|
+
...(ngDevMode ? [{ debugName: "removedExisting" }] : /* istanbul ignore next */ []));
|
|
1525
1573
|
/** Renderable entries: existing images (when nothing newer hides them) then new files. */
|
|
1526
1574
|
displayItems = computed(() => {
|
|
1527
1575
|
const items = [];
|
|
@@ -1548,7 +1596,8 @@ class MnFileInput {
|
|
|
1548
1596
|
});
|
|
1549
1597
|
});
|
|
1550
1598
|
return items;
|
|
1551
|
-
},
|
|
1599
|
+
}, /* @ts-ignore */
|
|
1600
|
+
...(ngDevMode ? [{ debugName: "displayItems" }] : /* istanbul ignore next */ []));
|
|
1552
1601
|
/** Disabled state pushed by the forms API. */
|
|
1553
1602
|
formDisabled = false;
|
|
1554
1603
|
/**
|
|
@@ -1605,7 +1654,7 @@ class MnFileInput {
|
|
|
1605
1654
|
size: this.props.size,
|
|
1606
1655
|
borderRadius: this.props.borderRadius,
|
|
1607
1656
|
shadow: this.props.shadow,
|
|
1608
|
-
fullWidth: this.props.fullWidth ??
|
|
1657
|
+
fullWidth: this.props.fullWidth ?? this.displayMode !== 'compact',
|
|
1609
1658
|
dropzone: this.displayMode === 'dropzone',
|
|
1610
1659
|
dragging: this.isDragging(),
|
|
1611
1660
|
disabled: this.isDisabled,
|
|
@@ -1637,7 +1686,11 @@ class MnFileInput {
|
|
|
1637
1686
|
}
|
|
1638
1687
|
ngOnInit() {
|
|
1639
1688
|
this.resolveConfig();
|
|
1640
|
-
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() =>
|
|
1689
|
+
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
1690
|
+
this.resolveConfig();
|
|
1691
|
+
// See mn-input-field: OnPush needs the locale change announced.
|
|
1692
|
+
this.cdr.markForCheck();
|
|
1693
|
+
});
|
|
1641
1694
|
this.destroyRef.onDestroy(() => sub.unsubscribe());
|
|
1642
1695
|
this.destroyRef.onDestroy(() => this.revokeAll());
|
|
1643
1696
|
}
|
|
@@ -1646,10 +1699,15 @@ class MnFileInput {
|
|
|
1646
1699
|
* @param val A `File`, an array of `File`, or null/undefined.
|
|
1647
1700
|
*/
|
|
1648
1701
|
writeValue(val) {
|
|
1649
|
-
const next = Array.isArray(val)
|
|
1650
|
-
|
|
1702
|
+
const next = Array.isArray(val)
|
|
1703
|
+
? val.filter((f) => f instanceof File)
|
|
1704
|
+
: val instanceof File
|
|
1705
|
+
? [val]
|
|
1651
1706
|
: [];
|
|
1652
1707
|
this.setFiles(next);
|
|
1708
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
1709
|
+
// this view for it.
|
|
1710
|
+
this.cdr.markForCheck();
|
|
1653
1711
|
}
|
|
1654
1712
|
/**
|
|
1655
1713
|
* Registers the form's change callback.
|
|
@@ -1672,6 +1730,9 @@ class MnFileInput {
|
|
|
1672
1730
|
*/
|
|
1673
1731
|
setDisabledState(isDisabled) {
|
|
1674
1732
|
this.formDisabled = isDisabled;
|
|
1733
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
1734
|
+
// from the forms API, with no event behind it.
|
|
1735
|
+
this.cdr.markForCheck();
|
|
1675
1736
|
}
|
|
1676
1737
|
/**
|
|
1677
1738
|
* Handles a file-picker change: validates the incoming files against the
|
|
@@ -1776,12 +1837,10 @@ class MnFileInput {
|
|
|
1776
1837
|
return (file.type ?? '').startsWith('image/');
|
|
1777
1838
|
}
|
|
1778
1839
|
/** Callback to notify Angular forms of value changes. */
|
|
1779
|
-
onChange = () => {
|
|
1780
|
-
};
|
|
1840
|
+
onChange = () => { };
|
|
1781
1841
|
// ========== Error handling (control validators) ==========
|
|
1782
1842
|
/** Callback to notify Angular forms when the control is touched. */
|
|
1783
|
-
onTouched = () => {
|
|
1784
|
-
};
|
|
1843
|
+
onTouched = () => { };
|
|
1785
1844
|
/** Resolves UI strings from config, layering built-in defaults and prop overrides. */
|
|
1786
1845
|
resolveConfig() {
|
|
1787
1846
|
const instanceId = this.explicitInstanceId || `mn-file-input-${this.props.id}`;
|
|
@@ -1925,7 +1984,10 @@ class MnFileInput {
|
|
|
1925
1984
|
const accept = this.props.accept;
|
|
1926
1985
|
if (!accept)
|
|
1927
1986
|
return true;
|
|
1928
|
-
const tokens = accept
|
|
1987
|
+
const tokens = accept
|
|
1988
|
+
.split(',')
|
|
1989
|
+
.map((t) => t.trim().toLowerCase())
|
|
1990
|
+
.filter(Boolean);
|
|
1929
1991
|
if (tokens.length === 0)
|
|
1930
1992
|
return true;
|
|
1931
1993
|
const name = file.name.toLowerCase();
|
|
@@ -1952,10 +2014,10 @@ class MnFileInput {
|
|
|
1952
2014
|
const segment = clean.substring(clean.lastIndexOf('/') + 1);
|
|
1953
2015
|
return segment || 'image';
|
|
1954
2016
|
}
|
|
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"] }] });
|
|
2017
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnFileInput, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2018
|
+
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
2019
|
}
|
|
1958
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2020
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnFileInput, decorators: [{
|
|
1959
2021
|
type: Component,
|
|
1960
2022
|
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
2023
|
}], ctorParameters: () => [], propDecorators: { props: [{
|
|
@@ -2200,10 +2262,8 @@ class MnSelect {
|
|
|
2200
2262
|
maxWidth: 'none',
|
|
2201
2263
|
maxHeight: null,
|
|
2202
2264
|
};
|
|
2203
|
-
onChange = () => {
|
|
2204
|
-
};
|
|
2205
|
-
onTouched = () => {
|
|
2206
|
-
};
|
|
2265
|
+
onChange = () => { };
|
|
2266
|
+
onTouched = () => { };
|
|
2207
2267
|
builtInErrorMessages = {
|
|
2208
2268
|
required: 'Please select an option',
|
|
2209
2269
|
};
|
|
@@ -2247,7 +2307,7 @@ class MnSelect {
|
|
|
2247
2307
|
return this.ngControl?.control ?? null;
|
|
2248
2308
|
}
|
|
2249
2309
|
get selectedOption() {
|
|
2250
|
-
return this.props.options.find(o => o.value === this.selectedValue);
|
|
2310
|
+
return this.props.options.find((o) => o.value === this.selectedValue);
|
|
2251
2311
|
}
|
|
2252
2312
|
/** The label shown in the trigger: the selected option, else the placeholder. */
|
|
2253
2313
|
get displayText() {
|
|
@@ -2293,7 +2353,7 @@ class MnSelect {
|
|
|
2293
2353
|
const errors = this.control?.errors;
|
|
2294
2354
|
if (!errors)
|
|
2295
2355
|
return [];
|
|
2296
|
-
return Object.keys(errors).map(key => this.resolveErrorMessageForKey(key, errors));
|
|
2356
|
+
return Object.keys(errors).map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
2297
2357
|
}
|
|
2298
2358
|
get errorMessage() {
|
|
2299
2359
|
const errors = this.control?.errors;
|
|
@@ -2334,7 +2394,7 @@ class MnSelect {
|
|
|
2334
2394
|
if (!this.searchTerm)
|
|
2335
2395
|
return this.props.options;
|
|
2336
2396
|
const lower = this.searchTerm.toLowerCase();
|
|
2337
|
-
return this.props.options.filter(o => o.label.toLowerCase().includes(lower));
|
|
2397
|
+
return this.props.options.filter((o) => o.label.toLowerCase().includes(lower));
|
|
2338
2398
|
}
|
|
2339
2399
|
// ========== Lifecycle ==========
|
|
2340
2400
|
ngOnInit() {
|
|
@@ -2342,6 +2402,9 @@ class MnSelect {
|
|
|
2342
2402
|
this.startWatchingViewport();
|
|
2343
2403
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
2344
2404
|
this.resolveConfig();
|
|
2405
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
2406
|
+
// marks this view for the locale change.
|
|
2407
|
+
this.cdr.markForCheck();
|
|
2345
2408
|
});
|
|
2346
2409
|
this.destroyRef.onDestroy(() => {
|
|
2347
2410
|
sub.unsubscribe();
|
|
@@ -2357,7 +2420,10 @@ class MnSelect {
|
|
|
2357
2420
|
// ========== ControlValueAccessor Implementation ==========
|
|
2358
2421
|
writeValue(val) {
|
|
2359
2422
|
// Treat empty string as null so the placeholder is shown and the control stays properly invalid.
|
|
2360
|
-
this.selectedValue =
|
|
2423
|
+
this.selectedValue = val === '' || val == null ? null : val;
|
|
2424
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
2425
|
+
// this view for it.
|
|
2426
|
+
this.cdr.markForCheck();
|
|
2361
2427
|
}
|
|
2362
2428
|
registerOnChange(fn) {
|
|
2363
2429
|
this.onChange = fn;
|
|
@@ -2367,6 +2433,9 @@ class MnSelect {
|
|
|
2367
2433
|
}
|
|
2368
2434
|
setDisabledState(isDisabled) {
|
|
2369
2435
|
this.isDisabled = isDisabled;
|
|
2436
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
2437
|
+
// from the forms API, with no event behind it.
|
|
2438
|
+
this.cdr.markForCheck();
|
|
2370
2439
|
}
|
|
2371
2440
|
// ========== Dropdown Logic ==========
|
|
2372
2441
|
toggle() {
|
|
@@ -2376,7 +2445,10 @@ class MnSelect {
|
|
|
2376
2445
|
this.close();
|
|
2377
2446
|
return;
|
|
2378
2447
|
}
|
|
2448
|
+
// `toggle()` and `close()` are public API: a consumer holding a @ViewChild can
|
|
2449
|
+
// open the panel without an event, and under OnPush nothing else marks this view.
|
|
2379
2450
|
this.isOpen = true;
|
|
2451
|
+
this.cdr.markForCheck();
|
|
2380
2452
|
if (this.isSheet) {
|
|
2381
2453
|
// A sheet is anchored to the viewport, so it needs no trigger tracking — only a
|
|
2382
2454
|
// scroll lock so the page behind it stays put while the list is scrolled.
|
|
@@ -2400,7 +2472,9 @@ class MnSelect {
|
|
|
2400
2472
|
/** Filters the options; the first match is highlighted so Enter picks it, none once the box is cleared. */
|
|
2401
2473
|
onSearch(term) {
|
|
2402
2474
|
this.searchTerm = term ?? '';
|
|
2403
|
-
this.activeIndex = this.searchTerm
|
|
2475
|
+
this.activeIndex = this.searchTerm
|
|
2476
|
+
? stepEnabledIndex(this.filteredOptions, -1, 1, isChoosable)
|
|
2477
|
+
: -1;
|
|
2404
2478
|
}
|
|
2405
2479
|
/** Id of the keyboard-highlighted option, for `aria-activedescendant`; null when none is. */
|
|
2406
2480
|
get activeOptionId() {
|
|
@@ -2435,10 +2509,11 @@ class MnSelect {
|
|
|
2435
2509
|
return;
|
|
2436
2510
|
claim(event);
|
|
2437
2511
|
this.toggle();
|
|
2438
|
-
const selected = this.filteredOptions.findIndex(o => this.isSelected(o) && isChoosable(o));
|
|
2439
|
-
this.activeIndex =
|
|
2440
|
-
|
|
2441
|
-
|
|
2512
|
+
const selected = this.filteredOptions.findIndex((o) => this.isSelected(o) && isChoosable(o));
|
|
2513
|
+
this.activeIndex =
|
|
2514
|
+
selected >= 0
|
|
2515
|
+
? selected
|
|
2516
|
+
: stepEnabledIndex(this.filteredOptions, -1, event.key === 'ArrowUp' ? -1 : 1, isChoosable);
|
|
2442
2517
|
this.revealActiveOption();
|
|
2443
2518
|
return;
|
|
2444
2519
|
}
|
|
@@ -2520,6 +2595,7 @@ class MnSelect {
|
|
|
2520
2595
|
if (!this.isOpen)
|
|
2521
2596
|
return;
|
|
2522
2597
|
this.isOpen = false;
|
|
2598
|
+
this.cdr.markForCheck();
|
|
2523
2599
|
this.searchTerm = '';
|
|
2524
2600
|
this.activeIndex = -1;
|
|
2525
2601
|
this.stopWatchingTrigger();
|
|
@@ -2657,8 +2733,8 @@ class MnSelect {
|
|
|
2657
2733
|
this.stopWatchingTrigger();
|
|
2658
2734
|
const trigger = this.triggerRef?.nativeElement;
|
|
2659
2735
|
if (trigger && typeof IntersectionObserver !== 'undefined') {
|
|
2660
|
-
this.visibilityObserver = new IntersectionObserver(entries => {
|
|
2661
|
-
if (!entries.some(entry => !entry.isIntersecting))
|
|
2736
|
+
this.visibilityObserver = new IntersectionObserver((entries) => {
|
|
2737
|
+
if (!entries.some((entry) => !entry.isIntersecting))
|
|
2662
2738
|
return;
|
|
2663
2739
|
this.close();
|
|
2664
2740
|
// The observer fires outside Angular, so a zoneless app needs an explicit nudge.
|
|
@@ -2668,7 +2744,9 @@ class MnSelect {
|
|
|
2668
2744
|
}
|
|
2669
2745
|
this.scrollCapture = (event) => {
|
|
2670
2746
|
const target = event.target;
|
|
2671
|
-
if (target &&
|
|
2747
|
+
if (target &&
|
|
2748
|
+
this.movedPanel &&
|
|
2749
|
+
(this.movedPanel === target || this.movedPanel.contains(target))) {
|
|
2672
2750
|
return;
|
|
2673
2751
|
}
|
|
2674
2752
|
this.close();
|
|
@@ -2779,12 +2857,20 @@ class MnSelect {
|
|
|
2779
2857
|
}
|
|
2780
2858
|
return msgDef;
|
|
2781
2859
|
}
|
|
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"] }] });
|
|
2860
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnSelect, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
2861
|
+
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
2862
|
}
|
|
2785
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
2863
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnSelect, decorators: [{
|
|
2786
2864
|
type: Component,
|
|
2787
|
-
args: [{ selector: 'mn-lib-select', standalone: true, imports: [
|
|
2865
|
+
args: [{ selector: 'mn-lib-select', standalone: true, imports: [
|
|
2866
|
+
NgClass,
|
|
2867
|
+
NgTemplateOutlet,
|
|
2868
|
+
FormsModule,
|
|
2869
|
+
MnErrorMessage,
|
|
2870
|
+
MnInputField,
|
|
2871
|
+
MnBottomSheet,
|
|
2872
|
+
LucideDynamicIcon,
|
|
2873
|
+
], host: {
|
|
2788
2874
|
// Without an explicit host width the inline host collapses to its content size, so
|
|
2789
2875
|
// the trigger's `w-full` (width:100%) resolves against a content-sized box and fails
|
|
2790
2876
|
// to fill the parent. Give the host a real width when fullWidth is requested.
|
|
@@ -2957,8 +3043,7 @@ class MnMultiSelect {
|
|
|
2957
3043
|
width: '0px',
|
|
2958
3044
|
maxHeight: null,
|
|
2959
3045
|
};
|
|
2960
|
-
onChange = () => {
|
|
2961
|
-
};
|
|
3046
|
+
onChange = () => { };
|
|
2962
3047
|
onTouched = () => { };
|
|
2963
3048
|
builtInErrorMessages = {
|
|
2964
3049
|
required: 'At least one option must be selected',
|
|
@@ -3014,6 +3099,9 @@ class MnMultiSelect {
|
|
|
3014
3099
|
this.startWatchingViewport();
|
|
3015
3100
|
const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
|
|
3016
3101
|
this.resolveConfig();
|
|
3102
|
+
// `resolveConfig` rewrites plain fields the template reads; under OnPush nothing else
|
|
3103
|
+
// marks this view for the locale change.
|
|
3104
|
+
this.cdr.markForCheck();
|
|
3017
3105
|
});
|
|
3018
3106
|
this.destroyRef.onDestroy(() => {
|
|
3019
3107
|
sub.unsubscribe();
|
|
@@ -3042,6 +3130,9 @@ class MnMultiSelect {
|
|
|
3042
3130
|
// ========== ControlValueAccessor Implementation ==========
|
|
3043
3131
|
writeValue(val) {
|
|
3044
3132
|
this.selectedValues = Array.isArray(val) ? val : [];
|
|
3133
|
+
// The forms API writes in from outside (setValue, reset, patch); nothing marks
|
|
3134
|
+
// this view for it.
|
|
3135
|
+
this.cdr.markForCheck();
|
|
3045
3136
|
}
|
|
3046
3137
|
registerOnChange(fn) {
|
|
3047
3138
|
this.onChange = fn;
|
|
@@ -3051,6 +3142,9 @@ class MnMultiSelect {
|
|
|
3051
3142
|
}
|
|
3052
3143
|
setDisabledState(isDisabled) {
|
|
3053
3144
|
this.isDisabled = isDisabled;
|
|
3145
|
+
// `control.disable()` / `.enable()` reaches us the same way `writeValue` does —
|
|
3146
|
+
// from the forms API, with no event behind it.
|
|
3147
|
+
this.cdr.markForCheck();
|
|
3054
3148
|
}
|
|
3055
3149
|
// ========== Dropdown Logic ==========
|
|
3056
3150
|
toggle() {
|
|
@@ -3060,7 +3154,10 @@ class MnMultiSelect {
|
|
|
3060
3154
|
this.close();
|
|
3061
3155
|
return;
|
|
3062
3156
|
}
|
|
3157
|
+
// `toggle()` and `close()` are public API: a consumer holding a @ViewChild can
|
|
3158
|
+
// open the panel without an event, and under OnPush nothing else marks this view.
|
|
3063
3159
|
this.isOpen = true;
|
|
3160
|
+
this.cdr.markForCheck();
|
|
3064
3161
|
if (this.isSheet) {
|
|
3065
3162
|
// A sheet is anchored to the viewport, so it needs no trigger tracking — only a
|
|
3066
3163
|
// scroll lock so the page behind it stays put while the list is scrolled.
|
|
@@ -3163,6 +3260,7 @@ class MnMultiSelect {
|
|
|
3163
3260
|
if (!this.isOpen)
|
|
3164
3261
|
return;
|
|
3165
3262
|
this.isOpen = false;
|
|
3263
|
+
this.cdr.markForCheck();
|
|
3166
3264
|
this.searchTerm = '';
|
|
3167
3265
|
this.activeIndex = -1;
|
|
3168
3266
|
this.stopWatchingTrigger();
|
|
@@ -3214,8 +3312,8 @@ class MnMultiSelect {
|
|
|
3214
3312
|
this.stopWatchingTrigger();
|
|
3215
3313
|
const trigger = this.triggerRef?.nativeElement;
|
|
3216
3314
|
if (trigger && typeof IntersectionObserver !== 'undefined') {
|
|
3217
|
-
this.visibilityObserver = new IntersectionObserver(entries => {
|
|
3218
|
-
if (!entries.some(entry => !entry.isIntersecting))
|
|
3315
|
+
this.visibilityObserver = new IntersectionObserver((entries) => {
|
|
3316
|
+
if (!entries.some((entry) => !entry.isIntersecting))
|
|
3219
3317
|
return;
|
|
3220
3318
|
this.close();
|
|
3221
3319
|
// The observer fires outside Angular, so a zoneless app needs an explicit nudge.
|
|
@@ -3225,7 +3323,9 @@ class MnMultiSelect {
|
|
|
3225
3323
|
}
|
|
3226
3324
|
this.scrollCapture = (event) => {
|
|
3227
3325
|
const target = event.target;
|
|
3228
|
-
if (target &&
|
|
3326
|
+
if (target &&
|
|
3327
|
+
this.movedPanel &&
|
|
3328
|
+
(this.movedPanel === target || this.movedPanel.contains(target))) {
|
|
3229
3329
|
return;
|
|
3230
3330
|
}
|
|
3231
3331
|
this.close();
|
|
@@ -3272,7 +3372,7 @@ class MnMultiSelect {
|
|
|
3272
3372
|
return;
|
|
3273
3373
|
const index = this.selectedValues.indexOf(option.value);
|
|
3274
3374
|
if (index > -1) {
|
|
3275
|
-
this.selectedValues = this.selectedValues.filter(v => v !== option.value);
|
|
3375
|
+
this.selectedValues = this.selectedValues.filter((v) => v !== option.value);
|
|
3276
3376
|
}
|
|
3277
3377
|
else {
|
|
3278
3378
|
if (this.props.maxSelections && this.selectedValues.length >= this.props.maxSelections) {
|
|
@@ -3284,7 +3384,7 @@ class MnMultiSelect {
|
|
|
3284
3384
|
}
|
|
3285
3385
|
removeOption(option, event) {
|
|
3286
3386
|
event.stopPropagation();
|
|
3287
|
-
this.selectedValues = this.selectedValues.filter(v => v !== option.value);
|
|
3387
|
+
this.selectedValues = this.selectedValues.filter((v) => v !== option.value);
|
|
3288
3388
|
this.onChange(this.selectedValues);
|
|
3289
3389
|
}
|
|
3290
3390
|
isSelected(option) {
|
|
@@ -3298,7 +3398,9 @@ class MnMultiSelect {
|
|
|
3298
3398
|
/** Filters the options; the first match is highlighted so Enter toggles it, none once the box is cleared. */
|
|
3299
3399
|
onSearch(term) {
|
|
3300
3400
|
this.searchTerm = term;
|
|
3301
|
-
this.activeIndex = this.searchTerm
|
|
3401
|
+
this.activeIndex = this.searchTerm
|
|
3402
|
+
? stepEnabledIndex(this.filteredOptions, -1, 1, this.isChoosable)
|
|
3403
|
+
: -1;
|
|
3302
3404
|
}
|
|
3303
3405
|
/**
|
|
3304
3406
|
* Whether the keyboard may highlight an option: not disabled, and not blocked by `maxSelections`.
|
|
@@ -3419,10 +3521,10 @@ class MnMultiSelect {
|
|
|
3419
3521
|
if (!this.searchTerm)
|
|
3420
3522
|
return this.props.options;
|
|
3421
3523
|
const lower = this.searchTerm.toLowerCase();
|
|
3422
|
-
return this.props.options.filter(o => o.label.toLowerCase().includes(lower));
|
|
3524
|
+
return this.props.options.filter((o) => o.label.toLowerCase().includes(lower));
|
|
3423
3525
|
}
|
|
3424
3526
|
get selectedOptions() {
|
|
3425
|
-
return this.props.options.filter(o => this.selectedValues.includes(o.value));
|
|
3527
|
+
return this.props.options.filter((o) => this.selectedValues.includes(o.value));
|
|
3426
3528
|
}
|
|
3427
3529
|
// ========== Collapse Summary ==========
|
|
3428
3530
|
/**
|
|
@@ -3440,7 +3542,7 @@ class MnMultiSelect {
|
|
|
3440
3542
|
* "all of them" would be a claim about nothing.
|
|
3441
3543
|
*/
|
|
3442
3544
|
get allSelected() {
|
|
3443
|
-
return this.props.options.length > 0 && this.selectedOptions.length === this.props.options.length;
|
|
3545
|
+
return (this.props.options.length > 0 && this.selectedOptions.length === this.props.options.length);
|
|
3444
3546
|
}
|
|
3445
3547
|
/**
|
|
3446
3548
|
* The threshold above which the trigger collapses. Defaults to 5 when collapsing
|
|
@@ -3558,7 +3660,7 @@ class MnMultiSelect {
|
|
|
3558
3660
|
const errors = this.control?.errors;
|
|
3559
3661
|
if (!errors)
|
|
3560
3662
|
return [];
|
|
3561
|
-
return Object.keys(errors).map(key => this.resolveErrorMessageForKey(key, errors));
|
|
3663
|
+
return Object.keys(errors).map((key) => this.resolveErrorMessageForKey(key, errors));
|
|
3562
3664
|
}
|
|
3563
3665
|
get errorMessage() {
|
|
3564
3666
|
const errors = this.control?.errors;
|
|
@@ -3582,12 +3684,21 @@ class MnMultiSelect {
|
|
|
3582
3684
|
fullWidth: this.props.fullWidth,
|
|
3583
3685
|
});
|
|
3584
3686
|
}
|
|
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"] }] });
|
|
3687
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnMultiSelect, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
3688
|
+
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
3689
|
}
|
|
3588
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
3690
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnMultiSelect, decorators: [{
|
|
3589
3691
|
type: Component,
|
|
3590
|
-
args: [{ selector: 'mn-lib-multi-select', standalone: true, imports: [
|
|
3692
|
+
args: [{ selector: 'mn-lib-multi-select', standalone: true, imports: [
|
|
3693
|
+
NgClass,
|
|
3694
|
+
NgTemplateOutlet,
|
|
3695
|
+
FormsModule,
|
|
3696
|
+
MnErrorMessage,
|
|
3697
|
+
MnButton,
|
|
3698
|
+
MnInputField,
|
|
3699
|
+
MnBottomSheet,
|
|
3700
|
+
LucideDynamicIcon,
|
|
3701
|
+
], 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
3702
|
}], ctorParameters: () => [], propDecorators: { props: [{
|
|
3592
3703
|
type: Input,
|
|
3593
3704
|
args: [{ required: true }]
|
|
@@ -3856,7 +3967,10 @@ class MnDropdown {
|
|
|
3856
3967
|
}
|
|
3857
3968
|
if (this.datasource.actions.length === 0)
|
|
3858
3969
|
return;
|
|
3970
|
+
// `toggle()` and `close()` are public API: a consumer holding a @ViewChild can
|
|
3971
|
+
// open the panel without an event, and under OnPush nothing else marks this view.
|
|
3859
3972
|
this.isOpen = true;
|
|
3973
|
+
this.cdr.markForCheck();
|
|
3860
3974
|
if (this.isSheet) {
|
|
3861
3975
|
// A sheet is anchored to the viewport, so it needs no trigger tracking — only a
|
|
3862
3976
|
// scroll lock so the page behind it stays put.
|
|
@@ -3871,6 +3985,7 @@ class MnDropdown {
|
|
|
3871
3985
|
if (!this.isOpen)
|
|
3872
3986
|
return;
|
|
3873
3987
|
this.isOpen = false;
|
|
3988
|
+
this.cdr.markForCheck();
|
|
3874
3989
|
this.searchTerm = '';
|
|
3875
3990
|
this.panelFloorPx = null;
|
|
3876
3991
|
this.panelWidthPx = null;
|
|
@@ -3902,6 +4017,9 @@ class MnDropdown {
|
|
|
3902
4017
|
*/
|
|
3903
4018
|
onSearch(term) {
|
|
3904
4019
|
this.searchTerm = term ?? '';
|
|
4020
|
+
// Public, like toggle()/close(): a caller that is not an event handler still has to
|
|
4021
|
+
// see the list narrow.
|
|
4022
|
+
this.cdr.markForCheck();
|
|
3905
4023
|
}
|
|
3906
4024
|
/**
|
|
3907
4025
|
* The actions currently passing the filter, in their declared order. Every action when
|
|
@@ -3914,7 +4032,7 @@ class MnDropdown {
|
|
|
3914
4032
|
return this.datasource.actions;
|
|
3915
4033
|
// While filtering, separators are dropped — a divider stranded between or after hidden
|
|
3916
4034
|
// results is meaningless — so match only real actions.
|
|
3917
|
-
return this.datasource.actions.filter(item => {
|
|
4035
|
+
return this.datasource.actions.filter((item) => {
|
|
3918
4036
|
if (this.isSeparator(item))
|
|
3919
4037
|
return false;
|
|
3920
4038
|
const haystack = `${this.actionLabel(item)} ${item.keywords ?? ''}`.toLowerCase();
|
|
@@ -3948,8 +4066,8 @@ class MnDropdown {
|
|
|
3948
4066
|
this.stopWatchingTrigger();
|
|
3949
4067
|
const trigger = this.triggerRef?.nativeElement;
|
|
3950
4068
|
if (trigger && typeof IntersectionObserver !== 'undefined') {
|
|
3951
|
-
this.visibilityObserver = new IntersectionObserver(entries => {
|
|
3952
|
-
if (!entries.some(entry => !entry.isIntersecting))
|
|
4069
|
+
this.visibilityObserver = new IntersectionObserver((entries) => {
|
|
4070
|
+
if (!entries.some((entry) => !entry.isIntersecting))
|
|
3953
4071
|
return;
|
|
3954
4072
|
this.close();
|
|
3955
4073
|
this.cdr.markForCheck();
|
|
@@ -3958,7 +4076,9 @@ class MnDropdown {
|
|
|
3958
4076
|
}
|
|
3959
4077
|
this.scrollCapture = (event) => {
|
|
3960
4078
|
const target = event.target;
|
|
3961
|
-
if (target &&
|
|
4079
|
+
if (target &&
|
|
4080
|
+
this.movedPanel &&
|
|
4081
|
+
(this.movedPanel === target || this.movedPanel.contains(target))) {
|
|
3962
4082
|
return;
|
|
3963
4083
|
}
|
|
3964
4084
|
this.close();
|
|
@@ -4121,12 +4241,16 @@ class MnDropdown {
|
|
|
4121
4241
|
}
|
|
4122
4242
|
/** Accessible name for the ⋯ trigger button. */
|
|
4123
4243
|
get triggerAriaLabel() {
|
|
4124
|
-
const translated = this.datasource.ariaLabelKey
|
|
4244
|
+
const translated = this.datasource.ariaLabelKey
|
|
4245
|
+
? this.lang.translateIfPresent(this.datasource.ariaLabelKey)
|
|
4246
|
+
: undefined;
|
|
4125
4247
|
return translated ?? this.datasource.ariaLabel ?? this.uiConfig.ariaLabel ?? 'Actions';
|
|
4126
4248
|
}
|
|
4127
4249
|
/** The visible text on the trigger, or null for an icon-only ⋯ trigger. */
|
|
4128
4250
|
get triggerLabelText() {
|
|
4129
|
-
const translated = this.datasource.triggerLabelKey
|
|
4251
|
+
const translated = this.datasource.triggerLabelKey
|
|
4252
|
+
? this.lang.translateIfPresent(this.datasource.triggerLabelKey)
|
|
4253
|
+
: undefined;
|
|
4130
4254
|
return translated ?? this.datasource.triggerLabel ?? null;
|
|
4131
4255
|
}
|
|
4132
4256
|
/**
|
|
@@ -4165,18 +4289,30 @@ class MnDropdown {
|
|
|
4165
4289
|
}
|
|
4166
4290
|
/** Heading shown above the menu/sheet, or null when none is configured. */
|
|
4167
4291
|
get menuLabel() {
|
|
4168
|
-
const translated = this.datasource.menuLabelKey
|
|
4292
|
+
const translated = this.datasource.menuLabelKey
|
|
4293
|
+
? this.lang.translateIfPresent(this.datasource.menuLabelKey)
|
|
4294
|
+
: undefined;
|
|
4169
4295
|
return translated ?? this.datasource.menuLabel ?? this.uiConfig.menuLabel ?? null;
|
|
4170
4296
|
}
|
|
4171
4297
|
/** Placeholder shown in the search input, preferring a resolved translation key. */
|
|
4172
4298
|
get searchPlaceholder() {
|
|
4173
|
-
const translated = this.datasource.searchPlaceholderKey
|
|
4174
|
-
|
|
4299
|
+
const translated = this.datasource.searchPlaceholderKey
|
|
4300
|
+
? this.lang.translateIfPresent(this.datasource.searchPlaceholderKey)
|
|
4301
|
+
: undefined;
|
|
4302
|
+
return (translated ??
|
|
4303
|
+
this.datasource.searchPlaceholder ??
|
|
4304
|
+
this.uiConfig.searchPlaceholder ??
|
|
4305
|
+
'Search...');
|
|
4175
4306
|
}
|
|
4176
4307
|
/** Text shown in place of the list when the filter matches no actions. */
|
|
4177
4308
|
get searchEmptyLabel() {
|
|
4178
|
-
const translated = this.datasource.searchEmptyLabelKey
|
|
4179
|
-
|
|
4309
|
+
const translated = this.datasource.searchEmptyLabelKey
|
|
4310
|
+
? this.lang.translateIfPresent(this.datasource.searchEmptyLabelKey)
|
|
4311
|
+
: undefined;
|
|
4312
|
+
return (translated ??
|
|
4313
|
+
this.datasource.searchEmptyLabel ??
|
|
4314
|
+
this.uiConfig.searchEmptyLabel ??
|
|
4315
|
+
'No results');
|
|
4180
4316
|
}
|
|
4181
4317
|
/** The ghost look the trigger has always used; a bare or partial `triggerButton` merges
|
|
4182
4318
|
* over this, so opting in without overriding anything keeps the current appearance. */
|
|
@@ -4212,12 +4348,20 @@ class MnDropdown {
|
|
|
4212
4348
|
get resolvedId() {
|
|
4213
4349
|
return this.datasource.id ?? this.autoId;
|
|
4214
4350
|
}
|
|
4215
|
-
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "
|
|
4216
|
-
static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "
|
|
4351
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnDropdown, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
4352
|
+
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
4353
|
}
|
|
4218
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "
|
|
4354
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImport: i0, type: MnDropdown, decorators: [{
|
|
4219
4355
|
type: Component,
|
|
4220
|
-
args: [{ selector: 'mn-lib-dropdown', standalone: true, imports: [
|
|
4356
|
+
args: [{ selector: 'mn-lib-dropdown', standalone: true, imports: [
|
|
4357
|
+
NgClass,
|
|
4358
|
+
NgTemplateOutlet,
|
|
4359
|
+
FormsModule,
|
|
4360
|
+
MnButton,
|
|
4361
|
+
MnBottomSheet,
|
|
4362
|
+
MnInputField,
|
|
4363
|
+
LucideDynamicIcon,
|
|
4364
|
+
], 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
4365
|
}], propDecorators: { datasource: [{
|
|
4222
4366
|
type: Input,
|
|
4223
4367
|
args: [{ required: true }]
|