quang 20.5.0 → 20.5.2-0
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/components/autocomplete/README.md +38 -1
- package/components/autocomplete/index.d.ts +266 -37
- package/components/date/index.d.ts +3 -0
- package/components/radio-group/README.md +75 -0
- package/components/radio-group/index.d.ts +31 -0
- package/components/select/README.md +34 -1
- package/components/select/index.d.ts +25 -3
- package/components/shared/index.d.ts +23 -3
- package/fesm2022/quang-auth.mjs +18 -18
- package/fesm2022/quang-components-autocomplete.mjs +647 -196
- package/fesm2022/quang-components-autocomplete.mjs.map +1 -1
- package/fesm2022/quang-components-checkbox.mjs +5 -5
- package/fesm2022/quang-components-checkbox.mjs.map +1 -1
- package/fesm2022/quang-components-date.mjs +68 -16
- package/fesm2022/quang-components-date.mjs.map +1 -1
- package/fesm2022/quang-components-input.mjs +5 -5
- package/fesm2022/quang-components-input.mjs.map +1 -1
- package/fesm2022/quang-components-paginator.mjs +13 -13
- package/fesm2022/quang-components-radio-group.mjs +59 -0
- package/fesm2022/quang-components-radio-group.mjs.map +1 -0
- package/fesm2022/quang-components-select.mjs +73 -24
- package/fesm2022/quang-components-select.mjs.map +1 -1
- package/fesm2022/quang-components-shared.mjs +93 -59
- package/fesm2022/quang-components-shared.mjs.map +1 -1
- package/fesm2022/quang-components-table.mjs +3 -3
- package/fesm2022/quang-components-wysiwyg.mjs +3 -3
- package/fesm2022/quang-device.mjs +3 -3
- package/fesm2022/quang-loader.mjs +6 -6
- package/fesm2022/quang-overlay-modal.mjs +6 -6
- package/fesm2022/quang-overlay-popover.mjs +6 -6
- package/fesm2022/quang-overlay-shared.mjs +9 -9
- package/fesm2022/quang-overlay-toast.mjs +6 -6
- package/fesm2022/quang-overlay-tooltip.mjs +6 -6
- package/fesm2022/quang-translation.mjs +6 -6
- package/package.json +36 -32
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NgClass } from '@angular/common';
|
|
1
|
+
import { NgClass, NgTemplateOutlet } from '@angular/common';
|
|
2
2
|
import * as i0 from '@angular/core';
|
|
3
3
|
import { input, viewChild, signal, computed, forwardRef, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
4
4
|
import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
@@ -28,8 +28,8 @@ class QuangSelectComponent extends QuangBaseComponent {
|
|
|
28
28
|
this.selectOptions = input.required(...(ngDevMode ? [{ debugName: "selectOptions" }] : []));
|
|
29
29
|
this.scrollBehaviorOnOpen = input('smooth', ...(ngDevMode ? [{ debugName: "scrollBehaviorOnOpen" }] : []));
|
|
30
30
|
this.selectButton = viewChild('selectButton', ...(ngDevMode ? [{ debugName: "selectButton" }] : []));
|
|
31
|
+
/** Whether the option list is currently visible */
|
|
31
32
|
this._showOptions = signal(false, ...(ngDevMode ? [{ debugName: "_showOptions" }] : []));
|
|
32
|
-
this._optionHideTimeout = signal(undefined, ...(ngDevMode ? [{ debugName: "_optionHideTimeout" }] : []));
|
|
33
33
|
this._selectedItems = computed(() => {
|
|
34
34
|
if (this._value() !== null) {
|
|
35
35
|
const targetValue = this._value();
|
|
@@ -54,43 +54,34 @@ class QuangSelectComponent extends QuangBaseComponent {
|
|
|
54
54
|
}
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
changeOptionsVisibility(
|
|
57
|
+
changeOptionsVisibility() {
|
|
58
58
|
if (this.isReadonly())
|
|
59
59
|
return;
|
|
60
60
|
if (this._showOptions()) {
|
|
61
|
-
this.
|
|
61
|
+
this.hideOptionVisibility();
|
|
62
62
|
}
|
|
63
63
|
else {
|
|
64
64
|
this.showOptionVisibility();
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
showOptionVisibility() {
|
|
68
|
-
if (this._optionHideTimeout()) {
|
|
69
|
-
clearTimeout(this._optionHideTimeout());
|
|
70
|
-
this._optionHideTimeout.set(null);
|
|
71
|
-
}
|
|
72
68
|
this._showOptions.set(true);
|
|
73
69
|
}
|
|
74
|
-
hideOptionVisibility(
|
|
75
|
-
|
|
76
|
-
clearTimeout(this._optionHideTimeout());
|
|
77
|
-
}
|
|
78
|
-
this._optionHideTimeout.set(setTimeout(() => {
|
|
79
|
-
this._showOptions.set(false);
|
|
80
|
-
}, skipTimeout ? 0 : 50));
|
|
70
|
+
hideOptionVisibility() {
|
|
71
|
+
this._showOptions.set(false);
|
|
81
72
|
}
|
|
82
73
|
onBlurHandler() {
|
|
83
74
|
if (this.selectionMode() === 'single') {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
super.onBlurHandler();
|
|
87
|
-
}, 100);
|
|
75
|
+
this.hideOptionVisibility();
|
|
76
|
+
super.onBlurHandler();
|
|
88
77
|
}
|
|
89
78
|
}
|
|
90
79
|
onChangedHandler(value) {
|
|
91
80
|
super.onChangedHandler(value);
|
|
92
81
|
if (this.selectionMode() === 'single') {
|
|
93
82
|
this.hideOptionVisibility();
|
|
83
|
+
// Return focus to button after selection
|
|
84
|
+
this.focusButton();
|
|
94
85
|
}
|
|
95
86
|
}
|
|
96
87
|
onMouseLeaveCallback() {
|
|
@@ -98,8 +89,66 @@ class QuangSelectComponent extends QuangBaseComponent {
|
|
|
98
89
|
this.hideOptionVisibility();
|
|
99
90
|
}
|
|
100
91
|
}
|
|
101
|
-
|
|
102
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Handles keydown events on the select button for accessibility.
|
|
94
|
+
* @param event The keyboard event
|
|
95
|
+
*/
|
|
96
|
+
onButtonKeydown(event) {
|
|
97
|
+
switch (event.key) {
|
|
98
|
+
case 'ArrowDown':
|
|
99
|
+
case 'ArrowUp':
|
|
100
|
+
// Open dropdown if closed
|
|
101
|
+
if (!this._showOptions()) {
|
|
102
|
+
event.preventDefault();
|
|
103
|
+
this.showOptionVisibility();
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
case ' ':
|
|
107
|
+
case 'Enter':
|
|
108
|
+
// Toggle dropdown with Space or Enter
|
|
109
|
+
if (!this._showOptions()) {
|
|
110
|
+
event.preventDefault();
|
|
111
|
+
this.showOptionVisibility();
|
|
112
|
+
}
|
|
113
|
+
break;
|
|
114
|
+
case 'Escape':
|
|
115
|
+
// Close dropdown and keep focus on button
|
|
116
|
+
if (this._showOptions()) {
|
|
117
|
+
event.preventDefault();
|
|
118
|
+
this.onEscapePressed();
|
|
119
|
+
}
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Handles Escape key press from option list.
|
|
125
|
+
* Closes dropdown and returns focus to button.
|
|
126
|
+
*/
|
|
127
|
+
onEscapePressed() {
|
|
128
|
+
this.hideOptionVisibility();
|
|
129
|
+
this.focusButton();
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Handles Tab key press from option list.
|
|
133
|
+
* Closes dropdown and allows natural tab navigation.
|
|
134
|
+
*/
|
|
135
|
+
onTabPressed(_event) {
|
|
136
|
+
this.hideOptionVisibility();
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Sets focus to the select button element.
|
|
140
|
+
*/
|
|
141
|
+
focusButton() {
|
|
142
|
+
const buttonEl = this.selectButton()?.nativeElement;
|
|
143
|
+
if (buttonEl) {
|
|
144
|
+
buttonEl.focus();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
getOptionIndex(option) {
|
|
148
|
+
return this.selectOptions().findIndex((x) => x.value === option.value);
|
|
149
|
+
}
|
|
150
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: QuangSelectComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
151
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: QuangSelectComponent, isStandalone: true, selector: "quang-select", inputs: { selectionMode: { classPropertyName: "selectionMode", publicName: "selectionMode", isSignal: true, isRequired: false, transformFunction: null }, optionListMaxHeight: { classPropertyName: "optionListMaxHeight", publicName: "optionListMaxHeight", isSignal: true, isRequired: false, transformFunction: null }, selectOptions: { classPropertyName: "selectOptions", publicName: "selectOptions", isSignal: true, isRequired: true, transformFunction: null }, scrollBehaviorOnOpen: { classPropertyName: "scrollBehaviorOnOpen", publicName: "scrollBehaviorOnOpen", isSignal: true, isRequired: false, transformFunction: null }, translateValue: { classPropertyName: "translateValue", publicName: "translateValue", isSignal: true, isRequired: false, transformFunction: null }, nullOption: { classPropertyName: "nullOption", publicName: "nullOption", isSignal: true, isRequired: false, transformFunction: null }, autoSelectSingleOption: { classPropertyName: "autoSelectSingleOption", publicName: "autoSelectSingleOption", isSignal: true, isRequired: false, transformFunction: null } }, providers: [
|
|
103
152
|
{
|
|
104
153
|
provide: NG_VALUE_ACCESSOR,
|
|
105
154
|
useExisting: forwardRef(() => QuangSelectComponent),
|
|
@@ -109,9 +158,9 @@ class QuangSelectComponent extends QuangBaseComponent {
|
|
|
109
158
|
provide: QuangOptionListComponent,
|
|
110
159
|
multi: false,
|
|
111
160
|
},
|
|
112
|
-
], viewQueries: [{ propertyName: "selectButton", first: true, predicate: ["selectButton"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div\n (mouseleave)=\"onMouseLeaveCallback()\"\n class=\"mb-3\"\n>\n @if (componentLabel()) {\n <label\n [htmlFor]=\"componentId()\"\n class=\"form-label d-flex gap-2\"\n >\n <div>\n <span>{{ componentLabel() | transloco }}</span>\n <span [hidden]=\"!_isRequired()\">*</span>\n </div>\n @if (helpMessage() && helpMessageTooltip()) {\n <div [quangTooltip]=\"helpMessage() | transloco\">\n <ng-content select=\"[help-icon]\" />\n </div>\n }\n </label>\n }\n <div\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n class=\"option-list-container\"\n >\n <button\n [attr.required]=\"getIsRequiredControl()\"\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n [disabled]=\"_isDisabled()\"\n [id]=\"componentId()\"\n [ngClass]=\"componentClass()\"\n [tabIndex]=\"componentTabIndex()\"\n (click)=\"changeOptionsVisibility()\"\n #selectButton\n class=\"form-select\"\n type=\"button\"\n >\n <div class=\"content\">\n @if (_selectedItems()?.length) {\n @for (val of _selectedItems(); track val
|
|
161
|
+
], viewQueries: [{ propertyName: "selectButton", first: true, predicate: ["selectButton"], descendants: true, isSignal: true }], usesInheritance: true, ngImport: i0, template: "<div\n (mouseleave)=\"onMouseLeaveCallback()\"\n class=\"mb-3\"\n>\n @if (componentLabel()) {\n <label\n [htmlFor]=\"componentId()\"\n class=\"form-label d-flex gap-2\"\n >\n <div>\n <span>{{ componentLabel() | transloco }}</span>\n <span [hidden]=\"!_isRequired()\">*</span>\n </div>\n @if (helpMessage() && helpMessageTooltip()) {\n <div [quangTooltip]=\"helpMessage() | transloco\">\n <ng-content select=\"[help-icon]\" />\n </div>\n }\n </label>\n }\n <div\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n class=\"option-list-container\"\n >\n <button\n [attr.aria-controls]=\"_showOptions() ? 'optionList' : null\"\n [attr.aria-expanded]=\"_showOptions()\"\n [attr.required]=\"getIsRequiredControl()\"\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n [disabled]=\"_isDisabled()\"\n [id]=\"componentId()\"\n [ngClass]=\"componentClass()\"\n [tabIndex]=\"componentTabIndex()\"\n (click)=\"changeOptionsVisibility()\"\n (keydown)=\"onButtonKeydown($event)\"\n #selectButton\n aria-haspopup=\"listbox\"\n class=\"form-select\"\n type=\"button\"\n >\n <div\n [class.multiple]=\"selectionMode() === 'multiple'\"\n class=\"content\"\n >\n @if (_selectedItems()?.length) {\n @for (val of _selectedItems(); track val; let last = $last) {\n <span class=\"selected-item\">\n @if (val.renderer) {\n <ng-container\n [ngTemplateOutlet]=\"val.renderer\"\n [ngTemplateOutletContext]=\"{ $implicit: val, selected: true, index: getOptionIndex(val) }\"\n ></ng-container>\n } @else {\n {{ translateValue() ? (val.label | transloco) : val.label }}\n }\n </span>\n @if (!last) {\n <span class=\"separator\">, </span>\n }\n }\n } @else {\n <ng-container>{{ componentPlaceholder() | transloco }}</ng-container>\n }\n </div>\n </button>\n\n @if (_showOptions()) {\n <quang-option-list\n [_isDisabled]=\"_isDisabled()\"\n [_value]=\"_value()\"\n [componentClass]=\"componentClass()\"\n [componentLabel]=\"componentLabel()\"\n [componentTabIndex]=\"componentTabIndex()\"\n [nullOption]=\"nullOption()\"\n [optionListMaxHeight]=\"optionListMaxHeight()\"\n [parentType]=\"ParentType\"\n [scrollBehaviorOnOpen]=\"scrollBehaviorOnOpen()\"\n [selectButtonRef]=\"selectButton\"\n [selectionMode]=\"selectionMode()\"\n [selectOptions]=\"selectOptions()\"\n [translateValue]=\"translateValue()\"\n (blurHandler)=\"onBlurHandler()\"\n (changedHandler)=\"onChangedHandler($event)\"\n (escapePressed)=\"onEscapePressed()\"\n (tabPressed)=\"onTabPressed($event)\"\n #optionList\n ></quang-option-list>\n }\n </div>\n <div class=\"valid-feedback\">\n {{ successMessage() | transloco }}\n </div>\n <div class=\"invalid-feedback\">\n {{ _currentErrorMessage() | transloco: _currentErrorMessageExtraData() }}\n </div>\n @if (helpMessage() && !helpMessageTooltip()) {\n <small\n [hidden]=\"_showSuccess() || _showErrors()\"\n aria-live=\"assertive\"\n class=\"form-text text-muted\"\n >\n {{ helpMessage() | transloco }}\n </small>\n }\n</div>\n", styles: [":host{display:block}:host .option-list-container{position:relative}.form-select{height:2.375rem;overflow:hidden;display:flex;align-items:center}.form-select:disabled{background-image:unset}.content{flex:1;min-width:0;text-align:left;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.content.multiple{display:block;text-overflow:unset;overflow:hidden;white-space:nowrap;max-width:100%}.selected-item{display:inline-flex;align-items:center;max-height:100%;white-space:nowrap}.separator{white-space:pre}:host ::ng-deep .content .d-flex{display:inline-flex!important}:host ::ng-deep .content *{max-height:100%}\n"], dependencies: [{ kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: QuangOptionListComponent, selector: "quang-option-list", inputs: ["selectionMode", "optionListMaxHeight", "selectOptions", "selectButtonRef", "_value", "_isDisabled", "componentClass", "componentLabel", "componentTabIndex", "translateValue", "nullOption", "scrollBehaviorOnOpen", "parentType", "parentID"], outputs: ["changedHandler", "blurHandler", "escapePressed", "tabPressed"] }, { kind: "directive", type: QuangTooltipDirective, selector: "[quangTooltip]", inputs: ["quangTooltip", "showMethod"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
113
162
|
}
|
|
114
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
163
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: QuangSelectComponent, decorators: [{
|
|
115
164
|
type: Component,
|
|
116
165
|
args: [{ selector: 'quang-select', providers: [
|
|
117
166
|
{
|
|
@@ -123,7 +172,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.10", ngImpo
|
|
|
123
172
|
provide: QuangOptionListComponent,
|
|
124
173
|
multi: false,
|
|
125
174
|
},
|
|
126
|
-
], imports: [TranslocoPipe, NgClass, QuangOptionListComponent, QuangTooltipDirective], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n (mouseleave)=\"onMouseLeaveCallback()\"\n class=\"mb-3\"\n>\n @if (componentLabel()) {\n <label\n [htmlFor]=\"componentId()\"\n class=\"form-label d-flex gap-2\"\n >\n <div>\n <span>{{ componentLabel() | transloco }}</span>\n <span [hidden]=\"!_isRequired()\">*</span>\n </div>\n @if (helpMessage() && helpMessageTooltip()) {\n <div [quangTooltip]=\"helpMessage() | transloco\">\n <ng-content select=\"[help-icon]\" />\n </div>\n }\n </label>\n }\n <div\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n class=\"option-list-container\"\n >\n <button\n [attr.required]=\"getIsRequiredControl()\"\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n [disabled]=\"_isDisabled()\"\n [id]=\"componentId()\"\n [ngClass]=\"componentClass()\"\n [tabIndex]=\"componentTabIndex()\"\n (click)=\"changeOptionsVisibility()\"\n #selectButton\n class=\"form-select\"\n type=\"button\"\n >\n <div class=\"content\">\n @if (_selectedItems()?.length) {\n @for (val of _selectedItems(); track val
|
|
175
|
+
], imports: [TranslocoPipe, NgClass, NgTemplateOutlet, QuangOptionListComponent, QuangTooltipDirective], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n (mouseleave)=\"onMouseLeaveCallback()\"\n class=\"mb-3\"\n>\n @if (componentLabel()) {\n <label\n [htmlFor]=\"componentId()\"\n class=\"form-label d-flex gap-2\"\n >\n <div>\n <span>{{ componentLabel() | transloco }}</span>\n <span [hidden]=\"!_isRequired()\">*</span>\n </div>\n @if (helpMessage() && helpMessageTooltip()) {\n <div [quangTooltip]=\"helpMessage() | transloco\">\n <ng-content select=\"[help-icon]\" />\n </div>\n }\n </label>\n }\n <div\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n class=\"option-list-container\"\n >\n <button\n [attr.aria-controls]=\"_showOptions() ? 'optionList' : null\"\n [attr.aria-expanded]=\"_showOptions()\"\n [attr.required]=\"getIsRequiredControl()\"\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n [disabled]=\"_isDisabled()\"\n [id]=\"componentId()\"\n [ngClass]=\"componentClass()\"\n [tabIndex]=\"componentTabIndex()\"\n (click)=\"changeOptionsVisibility()\"\n (keydown)=\"onButtonKeydown($event)\"\n #selectButton\n aria-haspopup=\"listbox\"\n class=\"form-select\"\n type=\"button\"\n >\n <div\n [class.multiple]=\"selectionMode() === 'multiple'\"\n class=\"content\"\n >\n @if (_selectedItems()?.length) {\n @for (val of _selectedItems(); track val; let last = $last) {\n <span class=\"selected-item\">\n @if (val.renderer) {\n <ng-container\n [ngTemplateOutlet]=\"val.renderer\"\n [ngTemplateOutletContext]=\"{ $implicit: val, selected: true, index: getOptionIndex(val) }\"\n ></ng-container>\n } @else {\n {{ translateValue() ? (val.label | transloco) : val.label }}\n }\n </span>\n @if (!last) {\n <span class=\"separator\">, </span>\n }\n }\n } @else {\n <ng-container>{{ componentPlaceholder() | transloco }}</ng-container>\n }\n </div>\n </button>\n\n @if (_showOptions()) {\n <quang-option-list\n [_isDisabled]=\"_isDisabled()\"\n [_value]=\"_value()\"\n [componentClass]=\"componentClass()\"\n [componentLabel]=\"componentLabel()\"\n [componentTabIndex]=\"componentTabIndex()\"\n [nullOption]=\"nullOption()\"\n [optionListMaxHeight]=\"optionListMaxHeight()\"\n [parentType]=\"ParentType\"\n [scrollBehaviorOnOpen]=\"scrollBehaviorOnOpen()\"\n [selectButtonRef]=\"selectButton\"\n [selectionMode]=\"selectionMode()\"\n [selectOptions]=\"selectOptions()\"\n [translateValue]=\"translateValue()\"\n (blurHandler)=\"onBlurHandler()\"\n (changedHandler)=\"onChangedHandler($event)\"\n (escapePressed)=\"onEscapePressed()\"\n (tabPressed)=\"onTabPressed($event)\"\n #optionList\n ></quang-option-list>\n }\n </div>\n <div class=\"valid-feedback\">\n {{ successMessage() | transloco }}\n </div>\n <div class=\"invalid-feedback\">\n {{ _currentErrorMessage() | transloco: _currentErrorMessageExtraData() }}\n </div>\n @if (helpMessage() && !helpMessageTooltip()) {\n <small\n [hidden]=\"_showSuccess() || _showErrors()\"\n aria-live=\"assertive\"\n class=\"form-text text-muted\"\n >\n {{ helpMessage() | transloco }}\n </small>\n }\n</div>\n", styles: [":host{display:block}:host .option-list-container{position:relative}.form-select{height:2.375rem;overflow:hidden;display:flex;align-items:center}.form-select:disabled{background-image:unset}.content{flex:1;min-width:0;text-align:left;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}.content.multiple{display:block;text-overflow:unset;overflow:hidden;white-space:nowrap;max-width:100%}.selected-item{display:inline-flex;align-items:center;max-height:100%;white-space:nowrap}.separator{white-space:pre}:host ::ng-deep .content .d-flex{display:inline-flex!important}:host ::ng-deep .content *{max-height:100%}\n"] }]
|
|
127
176
|
}], ctorParameters: () => [], propDecorators: { selectionMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionMode", required: false }] }], optionListMaxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionListMaxHeight", required: false }] }], selectOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectOptions", required: true }] }], scrollBehaviorOnOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollBehaviorOnOpen", required: false }] }], selectButton: [{ type: i0.ViewChild, args: ['selectButton', { isSignal: true }] }], translateValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "translateValue", required: false }] }], nullOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "nullOption", required: false }] }], autoSelectSingleOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "autoSelectSingleOption", required: false }] }] } });
|
|
128
177
|
|
|
129
178
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quang-components-select.mjs","sources":["../../../projects/quang/components/select/select.component.ts","../../../projects/quang/components/select/select.component.html","../../../projects/quang/components/select/quang-components-select.ts"],"sourcesContent":["import { NgClass } from '@angular/common'\nimport {\n AfterViewInit,\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n computed,\n forwardRef,\n input,\n signal,\n viewChild,\n} from '@angular/core'\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop'\nimport { NG_VALUE_ACCESSOR } from '@angular/forms'\n\nimport { TranslocoPipe } from '@jsverse/transloco'\nimport { QuangTooltipDirective } from 'quang/overlay/tooltip'\nimport { combineLatest, filter } from 'rxjs'\n\nimport {\n OptionListParentType,\n QuangBaseComponent,\n QuangOptionListComponent,\n SelectOption,\n} from 'quang/components/shared'\n\n@Component({\n selector: 'quang-select',\n templateUrl: './select.component.html',\n styleUrl: './select.component.scss',\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => QuangSelectComponent),\n multi: true,\n },\n {\n provide: QuangOptionListComponent,\n multi: false,\n },\n ],\n imports: [TranslocoPipe, NgClass, QuangOptionListComponent, QuangTooltipDirective],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\n/**\n * Select component for choosing one or multiple options from a dropdown.\n *\n * @usageNotes\n * This component supports both single and multiple selection modes. It can be configured\n * to display a list of options and allows users to select one or more of them by setting the `selectionMode` property to either `single` or `multiple`.\n */\nexport class QuangSelectComponent\n extends QuangBaseComponent<string | number | string[] | number[] | null>\n implements AfterViewInit\n{\n selectionMode = input<'single' | 'multiple'>('single')\n\n /**\n * Set the max height of the selection list before scrolling.\n * Default: 18rem\n * @default 18rem\n */\n optionListMaxHeight = input<string>('18rem')\n\n selectOptions = input.required<SelectOption[]>()\n\n scrollBehaviorOnOpen = input<ScrollBehavior>('smooth')\n\n selectButton = viewChild<ElementRef<HTMLButtonElement>>('selectButton')\n\n _showOptions = signal<boolean>(false)\n\n _optionHideTimeout = signal<any | undefined>(undefined)\n\n _selectedItems = computed(() => {\n if (this._value() !== null) {\n const targetValue = this._value()\n return this.selectOptions().filter((x) => {\n if (Array.isArray(targetValue)) {\n return targetValue.some((k) => k === x.value)\n }\n return targetValue === x.value\n })\n }\n return null\n })\n\n translateValue = input<boolean>(true)\n\n nullOption = input<boolean>(true)\n\n autoSelectSingleOption = input<boolean>(false)\n\n readonly ParentType = OptionListParentType.SELECT\n\n constructor() {\n super()\n combineLatest([toObservable(this.autoSelectSingleOption), toObservable(this.selectOptions)])\n .pipe(\n takeUntilDestroyed(this.destroyRef),\n filter(([autoselect, options]) => autoselect === true && options.length === 1)\n )\n .subscribe(([_, options]) => {\n if (this._value() === null || this._value() === undefined || this._value() === '') {\n this.onChangedHandler(options[0].value)\n }\n })\n }\n\n changeOptionsVisibility(skipTimeout = false): void {\n if (this.isReadonly()) return\n if (this._showOptions()) {\n this._showOptions.set(skipTimeout)\n } else {\n this.showOptionVisibility()\n }\n }\n\n showOptionVisibility(): void {\n if (this._optionHideTimeout()) {\n clearTimeout(this._optionHideTimeout())\n this._optionHideTimeout.set(null)\n }\n this._showOptions.set(true)\n }\n\n hideOptionVisibility(skipTimeout = false): void {\n if (this._optionHideTimeout()) {\n clearTimeout(this._optionHideTimeout())\n }\n this._optionHideTimeout.set(\n setTimeout(\n () => {\n this._showOptions.set(false)\n },\n skipTimeout ? 0 : 50\n )\n )\n }\n\n override onBlurHandler() {\n if (this.selectionMode() === 'single') {\n setTimeout(() => {\n this.hideOptionVisibility()\n super.onBlurHandler()\n }, 100)\n }\n }\n\n override onChangedHandler(value: string | number | string[] | number[] | null): void {\n super.onChangedHandler(value)\n if (this.selectionMode() === 'single') {\n this.hideOptionVisibility()\n }\n }\n\n onMouseLeaveCallback() {\n if (this.selectionMode() === 'multiple') {\n this.hideOptionVisibility()\n }\n }\n}\n","<div\n (mouseleave)=\"onMouseLeaveCallback()\"\n class=\"mb-3\"\n>\n @if (componentLabel()) {\n <label\n [htmlFor]=\"componentId()\"\n class=\"form-label d-flex gap-2\"\n >\n <div>\n <span>{{ componentLabel() | transloco }}</span>\n <span [hidden]=\"!_isRequired()\">*</span>\n </div>\n @if (helpMessage() && helpMessageTooltip()) {\n <div [quangTooltip]=\"helpMessage() | transloco\">\n <ng-content select=\"[help-icon]\" />\n </div>\n }\n </label>\n }\n <div\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n class=\"option-list-container\"\n >\n <button\n [attr.required]=\"getIsRequiredControl()\"\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n [disabled]=\"_isDisabled()\"\n [id]=\"componentId()\"\n [ngClass]=\"componentClass()\"\n [tabIndex]=\"componentTabIndex()\"\n (click)=\"changeOptionsVisibility()\"\n #selectButton\n class=\"form-select\"\n type=\"button\"\n >\n <div class=\"content\">\n @if (_selectedItems()?.length) {\n @for (val of _selectedItems(); track val.value; let last = $last) {\n {{ translateValue() ? (val.label | transloco) : val.label }}{{ !last ? ', ' : '' }}\n }\n } @else {\n <ng-container>{{ componentPlaceholder() | transloco }}</ng-container>\n }\n </div>\n </button>\n\n @if (_showOptions()) {\n <quang-option-list\n [_isDisabled]=\"_isDisabled()\"\n [_value]=\"_value()\"\n [componentClass]=\"componentClass()\"\n [componentLabel]=\"componentLabel()\"\n [componentTabIndex]=\"componentTabIndex()\"\n [nullOption]=\"nullOption()\"\n [optionListMaxHeight]=\"optionListMaxHeight()\"\n [parentType]=\"ParentType\"\n [scrollBehaviorOnOpen]=\"scrollBehaviorOnOpen()\"\n [selectButtonRef]=\"selectButton\"\n [selectionMode]=\"selectionMode()\"\n [selectOptions]=\"selectOptions()\"\n [translateValue]=\"translateValue()\"\n (blurHandler)=\"onBlurHandler()\"\n (changedHandler)=\"onChangedHandler($event)\"\n #optionList\n ></quang-option-list>\n }\n </div>\n <div class=\"valid-feedback\">\n {{ successMessage() | transloco }}\n </div>\n <div class=\"invalid-feedback\">\n {{ _currentErrorMessage() | transloco: _currentErrorMessageExtraData() }}\n </div>\n @if (helpMessage() && !helpMessageTooltip()) {\n <small\n [hidden]=\"_showSuccess() || _showErrors()\"\n aria-live=\"assertive\"\n class=\"form-text text-muted\"\n >\n {{ helpMessage() | transloco }}\n </small>\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AA4CA;;;;;;AAMG;AACG,MAAO,oBACX,SAAQ,kBAAgE,CAAA;AA2CxE,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE;AAzCT,QAAA,IAAA,CAAA,aAAa,GAAG,KAAK,CAAwB,QAAQ,yDAAC;AAEtD;;;;AAIG;AACH,QAAA,IAAA,CAAA,mBAAmB,GAAG,KAAK,CAAS,OAAO,+DAAC;AAE5C,QAAA,IAAA,CAAA,aAAa,GAAG,KAAK,CAAC,QAAQ,wDAAkB;AAEhD,QAAA,IAAA,CAAA,oBAAoB,GAAG,KAAK,CAAiB,QAAQ,gEAAC;AAEtD,QAAA,IAAA,CAAA,YAAY,GAAG,SAAS,CAAgC,cAAc,wDAAC;AAEvE,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAU,KAAK,wDAAC;AAErC,QAAA,IAAA,CAAA,kBAAkB,GAAG,MAAM,CAAkB,SAAS,8DA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AA,EAAA,IAAA,EAAA,KAAA,EAAA,YAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,sBAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,wBAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEpExE;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"quang-components-select.mjs","sources":["../../../projects/quang/components/select/select.component.ts","../../../projects/quang/components/select/select.component.html","../../../projects/quang/components/select/quang-components-select.ts"],"sourcesContent":["import { NgClass, NgTemplateOutlet } from '@angular/common'\nimport {\n AfterViewInit,\n ChangeDetectionStrategy,\n Component,\n ElementRef,\n computed,\n forwardRef,\n input,\n signal,\n viewChild,\n} from '@angular/core'\nimport { takeUntilDestroyed, toObservable } from '@angular/core/rxjs-interop'\nimport { NG_VALUE_ACCESSOR } from '@angular/forms'\n\nimport { TranslocoPipe } from '@jsverse/transloco'\nimport { QuangTooltipDirective } from 'quang/overlay/tooltip'\nimport { combineLatest, filter } from 'rxjs'\n\nimport {\n OptionListParentType,\n QuangBaseComponent,\n QuangOptionListComponent,\n SelectOption,\n} from 'quang/components/shared'\n\n@Component({\n selector: 'quang-select',\n templateUrl: './select.component.html',\n styleUrl: './select.component.scss',\n providers: [\n {\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => QuangSelectComponent),\n multi: true,\n },\n {\n provide: QuangOptionListComponent,\n multi: false,\n },\n ],\n imports: [TranslocoPipe, NgClass, NgTemplateOutlet, QuangOptionListComponent, QuangTooltipDirective],\n changeDetection: ChangeDetectionStrategy.OnPush,\n})\n/**\n * Select component for choosing one or multiple options from a dropdown.\n *\n * @usageNotes\n * This component supports both single and multiple selection modes. It can be configured\n * to display a list of options and allows users to select one or more of them by setting the `selectionMode` property to either `single` or `multiple`.\n */\nexport class QuangSelectComponent\n extends QuangBaseComponent<string | number | string[] | number[] | null>\n implements AfterViewInit\n{\n selectionMode = input<'single' | 'multiple'>('single')\n\n /**\n * Set the max height of the selection list before scrolling.\n * Default: 18rem\n * @default 18rem\n */\n optionListMaxHeight = input<string>('18rem')\n\n selectOptions = input.required<SelectOption[]>()\n\n scrollBehaviorOnOpen = input<ScrollBehavior>('smooth')\n\n selectButton = viewChild<ElementRef<HTMLButtonElement>>('selectButton')\n\n /** Whether the option list is currently visible */\n _showOptions = signal<boolean>(false)\n\n _selectedItems = computed(() => {\n if (this._value() !== null) {\n const targetValue = this._value()\n return this.selectOptions().filter((x) => {\n if (Array.isArray(targetValue)) {\n return targetValue.some((k) => k === x.value)\n }\n return targetValue === x.value\n })\n }\n return null\n })\n\n translateValue = input<boolean>(true)\n\n nullOption = input<boolean>(true)\n\n autoSelectSingleOption = input<boolean>(false)\n\n readonly ParentType = OptionListParentType.SELECT\n\n constructor() {\n super()\n combineLatest([toObservable(this.autoSelectSingleOption), toObservable(this.selectOptions)])\n .pipe(\n takeUntilDestroyed(this.destroyRef),\n filter(([autoselect, options]) => autoselect === true && options.length === 1)\n )\n .subscribe(([_, options]) => {\n if (this._value() === null || this._value() === undefined || this._value() === '') {\n this.onChangedHandler(options[0].value)\n }\n })\n }\n\n changeOptionsVisibility(): void {\n if (this.isReadonly()) return\n if (this._showOptions()) {\n this.hideOptionVisibility()\n } else {\n this.showOptionVisibility()\n }\n }\n\n showOptionVisibility(): void {\n this._showOptions.set(true)\n }\n\n hideOptionVisibility(): void {\n this._showOptions.set(false)\n }\n\n override onBlurHandler() {\n if (this.selectionMode() === 'single') {\n this.hideOptionVisibility()\n super.onBlurHandler()\n }\n }\n\n override onChangedHandler(value: string | number | string[] | number[] | null): void {\n super.onChangedHandler(value)\n if (this.selectionMode() === 'single') {\n this.hideOptionVisibility()\n // Return focus to button after selection\n this.focusButton()\n }\n }\n\n onMouseLeaveCallback() {\n if (this.selectionMode() === 'multiple') {\n this.hideOptionVisibility()\n }\n }\n\n /**\n * Handles keydown events on the select button for accessibility.\n * @param event The keyboard event\n */\n onButtonKeydown(event: KeyboardEvent): void {\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n // Open dropdown if closed\n if (!this._showOptions()) {\n event.preventDefault()\n this.showOptionVisibility()\n }\n break\n case ' ':\n case 'Enter':\n // Toggle dropdown with Space or Enter\n if (!this._showOptions()) {\n event.preventDefault()\n this.showOptionVisibility()\n }\n break\n case 'Escape':\n // Close dropdown and keep focus on button\n if (this._showOptions()) {\n event.preventDefault()\n this.onEscapePressed()\n }\n break\n }\n }\n\n /**\n * Handles Escape key press from option list.\n * Closes dropdown and returns focus to button.\n */\n onEscapePressed(): void {\n this.hideOptionVisibility()\n this.focusButton()\n }\n\n /**\n * Handles Tab key press from option list.\n * Closes dropdown and allows natural tab navigation.\n */\n onTabPressed(_event: { shiftKey: boolean }): void {\n this.hideOptionVisibility()\n }\n\n /**\n * Sets focus to the select button element.\n */\n focusButton(): void {\n const buttonEl = this.selectButton()?.nativeElement\n if (buttonEl) {\n buttonEl.focus()\n }\n }\n\n getOptionIndex(option: SelectOption): number {\n return this.selectOptions().findIndex((x) => x.value === option.value)\n }\n}\n","<div\n (mouseleave)=\"onMouseLeaveCallback()\"\n class=\"mb-3\"\n>\n @if (componentLabel()) {\n <label\n [htmlFor]=\"componentId()\"\n class=\"form-label d-flex gap-2\"\n >\n <div>\n <span>{{ componentLabel() | transloco }}</span>\n <span [hidden]=\"!_isRequired()\">*</span>\n </div>\n @if (helpMessage() && helpMessageTooltip()) {\n <div [quangTooltip]=\"helpMessage() | transloco\">\n <ng-content select=\"[help-icon]\" />\n </div>\n }\n </label>\n }\n <div\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n class=\"option-list-container\"\n >\n <button\n [attr.aria-controls]=\"_showOptions() ? 'optionList' : null\"\n [attr.aria-expanded]=\"_showOptions()\"\n [attr.required]=\"getIsRequiredControl()\"\n [class.is-invalid]=\"_ngControl()?.invalid && (_ngControl()?.dirty || _ngControl()?.touched) && errorMap().length\"\n [class.is-valid]=\"_ngControl()?.valid && (_ngControl()?.dirty || _ngControl()?.touched) && successMessage()\"\n [disabled]=\"_isDisabled()\"\n [id]=\"componentId()\"\n [ngClass]=\"componentClass()\"\n [tabIndex]=\"componentTabIndex()\"\n (click)=\"changeOptionsVisibility()\"\n (keydown)=\"onButtonKeydown($event)\"\n #selectButton\n aria-haspopup=\"listbox\"\n class=\"form-select\"\n type=\"button\"\n >\n <div\n [class.multiple]=\"selectionMode() === 'multiple'\"\n class=\"content\"\n >\n @if (_selectedItems()?.length) {\n @for (val of _selectedItems(); track val; let last = $last) {\n <span class=\"selected-item\">\n @if (val.renderer) {\n <ng-container\n [ngTemplateOutlet]=\"val.renderer\"\n [ngTemplateOutletContext]=\"{ $implicit: val, selected: true, index: getOptionIndex(val) }\"\n ></ng-container>\n } @else {\n {{ translateValue() ? (val.label | transloco) : val.label }}\n }\n </span>\n @if (!last) {\n <span class=\"separator\">, </span>\n }\n }\n } @else {\n <ng-container>{{ componentPlaceholder() | transloco }}</ng-container>\n }\n </div>\n </button>\n\n @if (_showOptions()) {\n <quang-option-list\n [_isDisabled]=\"_isDisabled()\"\n [_value]=\"_value()\"\n [componentClass]=\"componentClass()\"\n [componentLabel]=\"componentLabel()\"\n [componentTabIndex]=\"componentTabIndex()\"\n [nullOption]=\"nullOption()\"\n [optionListMaxHeight]=\"optionListMaxHeight()\"\n [parentType]=\"ParentType\"\n [scrollBehaviorOnOpen]=\"scrollBehaviorOnOpen()\"\n [selectButtonRef]=\"selectButton\"\n [selectionMode]=\"selectionMode()\"\n [selectOptions]=\"selectOptions()\"\n [translateValue]=\"translateValue()\"\n (blurHandler)=\"onBlurHandler()\"\n (changedHandler)=\"onChangedHandler($event)\"\n (escapePressed)=\"onEscapePressed()\"\n (tabPressed)=\"onTabPressed($event)\"\n #optionList\n ></quang-option-list>\n }\n </div>\n <div class=\"valid-feedback\">\n {{ successMessage() | transloco }}\n </div>\n <div class=\"invalid-feedback\">\n {{ _currentErrorMessage() | transloco: _currentErrorMessageExtraData() }}\n </div>\n @if (helpMessage() && !helpMessageTooltip()) {\n <small\n [hidden]=\"_showSuccess() || _showErrors()\"\n aria-live=\"assertive\"\n class=\"form-text text-muted\"\n >\n {{ helpMessage() | transloco }}\n </small>\n }\n</div>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;AA4CA;;;;;;AAMG;AACG,MAAO,oBACX,SAAQ,kBAAgE,CAAA;AA0CxE,IAAA,WAAA,GAAA;AACE,QAAA,KAAK,EAAE;AAxCT,QAAA,IAAA,CAAA,aAAa,GAAG,KAAK,CAAwB,QAAQ,yDAAC;AAEtD;;;;AAIG;AACH,QAAA,IAAA,CAAA,mBAAmB,GAAG,KAAK,CAAS,OAAO,+DAAC;AAE5C,QAAA,IAAA,CAAA,aAAa,GAAG,KAAK,CAAC,QAAQ,wDAAkB;AAEhD,QAAA,IAAA,CAAA,oBAAoB,GAAG,KAAK,CAAiB,QAAQ,gEAAC;AAEtD,QAAA,IAAA,CAAA,YAAY,GAAG,SAAS,CAAgC,cAAc,wDAAC;;AAGvE,QAAA,IAAA,CAAA,YAAY,GAAG,MAAM,CAAU,KAAK,wDAAC;AAErC,QAAA,IAAA,CAAA,cAAc,GAAG,QAAQ,CAAC,MAAK;AAC7B,YAAA,IAAI,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;AAC1B,gBAAA,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE;gBACjC,OAAO,IAAI,CAAC,aAAa,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,KAAI;AACvC,oBAAA,IAAI,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE;AAC9B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ACb,yBAAA;AACF,qBAAA,EAAA,OAAA,EACQ,CAAC,aAAa,EAAE,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,qBAAqB,CAAC,EAAA,eAAA,EACnF,uBAAuB,CAAC,MAAM,EAAA,QAAA,EAAA,gzHAAA,EAAA,MAAA,EAAA,CAAA,2mBAAA,CAAA,EAAA;qiBA0BS,cAAc,EAAA,EAAA,QAAA,EAAA,IAAA,EAAA,CAAA,EAAA,CAAA,EAAA,cAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,gBAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,UAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,YAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,sBAAA,EAAA,CAAA,EAAA,IAAA,EAAA,EAAA,CAAA,KAAA,EAAA,IAAA,EAAA,CAAA,EAAA,QAAA,EAAA,IAAA,EAAA,KAAA,EAAA,wBAAA,EAAA,QAAA,EAAA,KAAA,EAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA;;AEpExE;;AAEG;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { input, computed, output, signal, inject, Injector, DestroyRef, Directive, viewChild, effect, HostListener, ChangeDetectionStrategy, Component } from '@angular/core';
|
|
3
3
|
import { toObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
|
4
|
-
import {
|
|
5
|
-
import { NgStyle, NgClass } from '@angular/common';
|
|
4
|
+
import { Validators, NgControl } from '@angular/forms';
|
|
5
|
+
import { NgStyle, NgClass, NgTemplateOutlet } from '@angular/common';
|
|
6
6
|
import { TranslocoPipe } from '@jsverse/transloco';
|
|
7
7
|
import { QUANG_LOGGING_BEHAVIOR } from 'quang';
|
|
8
8
|
import { fromEvent } from 'rxjs';
|
|
@@ -52,7 +52,13 @@ class QuangBaseComponent {
|
|
|
52
52
|
this._currentErrorMessageExtraData = signal({}, ...(ngDevMode ? [{ debugName: "_currentErrorMessageExtraData" }] : []));
|
|
53
53
|
this._ngControl = signal(null, ...(ngDevMode ? [{ debugName: "_ngControl" }] : []));
|
|
54
54
|
this._injector = signal(inject(Injector), ...(ngDevMode ? [{ debugName: "_injector" }] : []));
|
|
55
|
-
this.getIsRequiredControl = computed(() =>
|
|
55
|
+
this.getIsRequiredControl = computed(() => {
|
|
56
|
+
const control = this._ngControl()?.control;
|
|
57
|
+
if (!control) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return control.hasValidator(Validators.required) || control.hasValidator(Validators.requiredTrue);
|
|
61
|
+
}, ...(ngDevMode ? [{ debugName: "getIsRequiredControl" }] : []));
|
|
56
62
|
this.destroyRef = inject(DestroyRef);
|
|
57
63
|
this.onChangeIsReadonly = this.isReadonly$.pipe(takeUntilDestroyed()).subscribe((isReadonly) => {
|
|
58
64
|
this._isDisabled.set(isReadonly || this._ngControl()?.disabled || false);
|
|
@@ -101,14 +107,29 @@ class QuangBaseComponent {
|
|
|
101
107
|
this._statusChange$.unsubscribe();
|
|
102
108
|
this._statusChange$ = undefined;
|
|
103
109
|
}
|
|
110
|
+
if (this._valueChange$) {
|
|
111
|
+
this._valueChange$.unsubscribe();
|
|
112
|
+
this._valueChange$ = undefined;
|
|
113
|
+
}
|
|
114
|
+
if (this._eventsChange$) {
|
|
115
|
+
this._eventsChange$.unsubscribe();
|
|
116
|
+
this._eventsChange$ = undefined;
|
|
117
|
+
}
|
|
104
118
|
this._ngControl.set(this._injector().get(NgControl));
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
.
|
|
119
|
+
const control = this._ngControl()?.control;
|
|
120
|
+
this._statusChange$ = control?.statusChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
|
121
|
+
this.checkFormErrors();
|
|
122
|
+
});
|
|
123
|
+
this._valueChange$ = control?.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
|
108
124
|
this.checkFormErrors();
|
|
109
125
|
});
|
|
110
|
-
|
|
111
|
-
|
|
126
|
+
// `markAllAsTouched()` updates the control's `touched` state without emitting `statusChanges`.
|
|
127
|
+
// Angular exposes an `events` stream that includes touched/pristine changes.
|
|
128
|
+
this._eventsChange$ = control?.events?.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(() => {
|
|
129
|
+
this.checkFormErrors();
|
|
130
|
+
});
|
|
131
|
+
this._isTouched.set(!!(control?.touched || control?.dirty));
|
|
132
|
+
this._isDisabled.set(this.isReadonly() || control?.disabled || false);
|
|
112
133
|
this.checkFormErrors();
|
|
113
134
|
}
|
|
114
135
|
setDisabledState(isDisabled) {
|
|
@@ -117,9 +138,9 @@ class QuangBaseComponent {
|
|
|
117
138
|
checkFormErrors() {
|
|
118
139
|
const control = this._ngControl()?.control;
|
|
119
140
|
this._isValid.set(control?.valid ?? false);
|
|
120
|
-
this._isTouched.set(
|
|
141
|
+
this._isTouched.set(!!(control?.touched || control?.dirty));
|
|
142
|
+
this._isRequired.set(!!control && (control.hasValidator(Validators.required) || control.hasValidator(Validators.requiredTrue)));
|
|
121
143
|
const validationErrors = control?.errors;
|
|
122
|
-
this._isRequired.set(validationErrors?.[Validators.required.name]);
|
|
123
144
|
let errorName = '';
|
|
124
145
|
let errorMessage = '';
|
|
125
146
|
let errorData = true;
|
|
@@ -137,10 +158,10 @@ class QuangBaseComponent {
|
|
|
137
158
|
ngAfterViewInit() {
|
|
138
159
|
this.setupFormControl();
|
|
139
160
|
}
|
|
140
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
141
|
-
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.
|
|
161
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: QuangBaseComponent, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
|
|
162
|
+
static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.15", type: QuangBaseComponent, isStandalone: true, inputs: { componentId: { classPropertyName: "componentId", publicName: "componentId", isSignal: true, isRequired: false, transformFunction: null }, isReadonly: { classPropertyName: "isReadonly", publicName: "isReadonly", isSignal: true, isRequired: false, transformFunction: null }, componentTabIndex: { classPropertyName: "componentTabIndex", publicName: "componentTabIndex", isSignal: true, isRequired: false, transformFunction: null }, componentClass: { classPropertyName: "componentClass", publicName: "componentClass", isSignal: true, isRequired: false, transformFunction: null }, componentLabel: { classPropertyName: "componentLabel", publicName: "componentLabel", isSignal: true, isRequired: false, transformFunction: null }, componentPlaceholder: { classPropertyName: "componentPlaceholder", publicName: "componentPlaceholder", isSignal: true, isRequired: false, transformFunction: null }, errorMap: { classPropertyName: "errorMap", publicName: "errorMap", isSignal: true, isRequired: false, transformFunction: null }, successMessage: { classPropertyName: "successMessage", publicName: "successMessage", isSignal: true, isRequired: false, transformFunction: null }, helpMessage: { classPropertyName: "helpMessage", publicName: "helpMessage", isSignal: true, isRequired: false, transformFunction: null }, formControl: { classPropertyName: "formControl", publicName: "formControl", isSignal: true, isRequired: false, transformFunction: null }, helpMessageTooltip: { classPropertyName: "helpMessageTooltip", publicName: "helpMessageTooltip", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { componentBlur: "componentBlur" }, ngImport: i0 }); }
|
|
142
163
|
}
|
|
143
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
164
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: QuangBaseComponent, decorators: [{
|
|
144
165
|
type: Directive
|
|
145
166
|
}], ctorParameters: () => [], propDecorators: { componentId: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentId", required: false }] }], isReadonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "isReadonly", required: false }] }], componentTabIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentTabIndex", required: false }] }], componentClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentClass", required: false }] }], componentLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentLabel", required: false }] }], componentPlaceholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentPlaceholder", required: false }] }], errorMap: [{ type: i0.Input, args: [{ isSignal: true, alias: "errorMap", required: false }] }], successMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "successMessage", required: false }] }], helpMessage: [{ type: i0.Input, args: [{ isSignal: true, alias: "helpMessage", required: false }] }], formControl: [{ type: i0.Input, args: [{ isSignal: true, alias: "formControl", required: false }] }], helpMessageTooltip: [{ type: i0.Input, args: [{ isSignal: true, alias: "helpMessageTooltip", required: false }] }], componentBlur: [{ type: i0.Output, args: ["componentBlur"] }] } });
|
|
146
167
|
|
|
@@ -170,6 +191,10 @@ class QuangOptionListComponent {
|
|
|
170
191
|
this.scrollBehaviorOnOpen = input('smooth', ...(ngDevMode ? [{ debugName: "scrollBehaviorOnOpen" }] : []));
|
|
171
192
|
this.changedHandler = output();
|
|
172
193
|
this.blurHandler = output();
|
|
194
|
+
/** Emitted when user presses Escape - parent should close dropdown and return focus to trigger */
|
|
195
|
+
this.escapePressed = output();
|
|
196
|
+
/** Emitted when user presses Tab - parent should handle focus transition */
|
|
197
|
+
this.tabPressed = output();
|
|
173
198
|
this.optionListContainer = viewChild('optionListContainer', ...(ngDevMode ? [{ debugName: "optionListContainer" }] : []));
|
|
174
199
|
this.destroyRef = inject(DestroyRef);
|
|
175
200
|
this.parentType = input.required(...(ngDevMode ? [{ debugName: "parentType" }] : []));
|
|
@@ -200,25 +225,28 @@ class QuangOptionListComponent {
|
|
|
200
225
|
}, ...(ngDevMode ? [{ debugName: "selectOptionsList" }] : []));
|
|
201
226
|
this.onKeyDown = null;
|
|
202
227
|
this.selectedElementIndex = computed(() => this.selectOptionsList()?.findIndex((x) => x?.value === this._value()) ?? 0, ...(ngDevMode ? [{ debugName: "selectedElementIndex" }] : []));
|
|
228
|
+
/** Signal to track currently focused item index for aria-activedescendant */
|
|
229
|
+
this.focusedItemIndex = signal(-1, ...(ngDevMode ? [{ debugName: "focusedItemIndex" }] : []));
|
|
203
230
|
this.optionList$ = effect(() => {
|
|
204
231
|
const optionListContainer = this.optionListContainer();
|
|
205
|
-
|
|
232
|
+
const parentType = this.parentType();
|
|
233
|
+
// Focus the option list container when opened (only for SELECT)
|
|
234
|
+
if (optionListContainer && parentType === OptionListParentType.SELECT) {
|
|
206
235
|
optionListContainer?.nativeElement.focus();
|
|
207
|
-
const optionListContainerNativeElement = optionListContainer?.nativeElement;
|
|
208
|
-
if (optionListContainerNativeElement) {
|
|
209
|
-
const ul = optionListContainerNativeElement?.children[0];
|
|
210
|
-
const listItem = ul?.children.item(this.selectedElementIndex());
|
|
211
|
-
if (listItem) {
|
|
212
|
-
setTimeout(() => {
|
|
213
|
-
listItem.scrollIntoView({ behavior: this.scrollBehaviorOnOpen() });
|
|
214
|
-
}, 0);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
236
|
}
|
|
218
237
|
const ul = optionListContainer?.nativeElement?.children[0];
|
|
219
238
|
const listItems = (ul?.children ?? []);
|
|
220
239
|
let currentIndex = this.selectedElementIndex();
|
|
221
240
|
listItems?.[currentIndex]?.classList.add('selected');
|
|
241
|
+
// Initialize focusedItemIndex with current selection
|
|
242
|
+
this.focusedItemIndex.set(currentIndex);
|
|
243
|
+
// Scroll to selected item when option list opens
|
|
244
|
+
const listItem = listItems[currentIndex];
|
|
245
|
+
if (listItem) {
|
|
246
|
+
setTimeout(() => {
|
|
247
|
+
listItem.scrollIntoView({ behavior: this.scrollBehaviorOnOpen(), block: 'nearest' });
|
|
248
|
+
}, 0);
|
|
249
|
+
}
|
|
222
250
|
if (this.onKeyDown) {
|
|
223
251
|
this.onKeyDown.unsubscribe();
|
|
224
252
|
}
|
|
@@ -239,25 +267,12 @@ class QuangOptionListComponent {
|
|
|
239
267
|
else {
|
|
240
268
|
currentIndex += 1;
|
|
241
269
|
}
|
|
242
|
-
|
|
243
|
-
event.preventDefault();
|
|
244
|
-
optionListContainer?.nativeElement?.scroll(0, 0);
|
|
245
|
-
}
|
|
246
|
-
const optionListBottom = optionListContainer?.nativeElement?.getBoundingClientRect()?.bottom ?? 0;
|
|
247
|
-
const itemListHeight = optionListContainer?.nativeElement?.children?.[0]?.children
|
|
248
|
-
?.item(currentIndex)
|
|
249
|
-
?.getBoundingClientRect()?.height;
|
|
250
|
-
const itemListBottom = optionListContainer?.nativeElement?.children?.[0]?.children
|
|
251
|
-
?.item(currentIndex)
|
|
252
|
-
?.getBoundingClientRect()?.bottom;
|
|
253
|
-
if (optionListBottom > (itemListBottom ?? 0) + (itemListHeight ?? 0))
|
|
254
|
-
event.preventDefault();
|
|
270
|
+
event.preventDefault();
|
|
255
271
|
listItems[currentIndex]?.classList.add('selected');
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
}
|
|
272
|
+
// Scroll item into view if not visible
|
|
273
|
+
listItems[currentIndex]?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
274
|
+
// Update focusedItemIndex for aria-activedescendant
|
|
275
|
+
this.focusedItemIndex.set(currentIndex);
|
|
261
276
|
break;
|
|
262
277
|
}
|
|
263
278
|
case 'ArrowUp': {
|
|
@@ -267,25 +282,34 @@ class QuangOptionListComponent {
|
|
|
267
282
|
listItems[currentIndex]?.classList.remove('selected');
|
|
268
283
|
if (currentIndex !== 0)
|
|
269
284
|
currentIndex -= 1;
|
|
270
|
-
|
|
271
|
-
const itemListHeight = optionListContainer?.nativeElement?.children?.[0]?.children
|
|
272
|
-
?.item(currentIndex)
|
|
273
|
-
?.getBoundingClientRect()?.height;
|
|
274
|
-
const itemListTop = optionListContainer?.nativeElement?.children?.[0]?.children
|
|
275
|
-
?.item(currentIndex)
|
|
276
|
-
?.getBoundingClientRect()?.top;
|
|
277
|
-
if (optionListTop < (itemListTop ?? 0) - (itemListHeight ?? 0))
|
|
278
|
-
event.preventDefault();
|
|
285
|
+
event.preventDefault();
|
|
279
286
|
listItems[currentIndex]?.classList.add('selected');
|
|
280
|
-
if
|
|
281
|
-
|
|
282
|
-
|
|
287
|
+
// Scroll item into view if not visible
|
|
288
|
+
listItems[currentIndex]?.scrollIntoView({ behavior: 'smooth', block: 'nearest' });
|
|
289
|
+
// Update focusedItemIndex for aria-activedescendant
|
|
290
|
+
this.focusedItemIndex.set(currentIndex);
|
|
283
291
|
break;
|
|
284
292
|
}
|
|
285
293
|
case 'Enter': {
|
|
294
|
+
event.preventDefault();
|
|
286
295
|
this.onSelectItem(this.selectOptionsList()[currentIndex]);
|
|
287
296
|
break;
|
|
288
297
|
}
|
|
298
|
+
case 'Escape': {
|
|
299
|
+
event.preventDefault();
|
|
300
|
+
this.escapePressed.emit();
|
|
301
|
+
break;
|
|
302
|
+
}
|
|
303
|
+
case 'Tab': {
|
|
304
|
+
// Only handle Tab when focus is on the option list itself
|
|
305
|
+
// If focus is on the parent input, let the input's blur handler deal with it
|
|
306
|
+
if (document.activeElement?.id === optionListContainer?.nativeElement?.id) {
|
|
307
|
+
// Allow Tab to close dropdown and move focus naturally
|
|
308
|
+
// Emit event so parent can handle focus transition
|
|
309
|
+
this.tabPressed.emit({ shiftKey: event.shiftKey });
|
|
310
|
+
}
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
289
313
|
default: {
|
|
290
314
|
if ((event?.key?.length === 1 || event?.key === 'Backspace') &&
|
|
291
315
|
this.parentType() === OptionListParentType.AUTOCOMPLETE &&
|
|
@@ -306,6 +330,16 @@ class QuangOptionListComponent {
|
|
|
306
330
|
});
|
|
307
331
|
}, ...(ngDevMode ? [{ debugName: "optionList$" }] : []));
|
|
308
332
|
}
|
|
333
|
+
/**
|
|
334
|
+
* Returns the ID of the currently focused item for aria-activedescendant
|
|
335
|
+
*/
|
|
336
|
+
getActiveDescendantId() {
|
|
337
|
+
const index = this.focusedItemIndex();
|
|
338
|
+
if (index >= 0 && index < this.selectOptionsList().length) {
|
|
339
|
+
return `item-${index}`;
|
|
340
|
+
}
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
309
343
|
handleSearch(key, listItems, currentIndex) {
|
|
310
344
|
if (this.searchResetTimer) {
|
|
311
345
|
clearTimeout(this.searchResetTimer);
|
|
@@ -414,13 +448,13 @@ class QuangOptionListComponent {
|
|
|
414
448
|
this.getOptionListTop();
|
|
415
449
|
});
|
|
416
450
|
}
|
|
417
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.
|
|
418
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.
|
|
451
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: QuangOptionListComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
452
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.15", type: QuangOptionListComponent, isStandalone: true, selector: "quang-option-list", inputs: { selectionMode: { classPropertyName: "selectionMode", publicName: "selectionMode", isSignal: true, isRequired: false, transformFunction: null }, optionListMaxHeight: { classPropertyName: "optionListMaxHeight", publicName: "optionListMaxHeight", isSignal: true, isRequired: false, transformFunction: null }, selectOptions: { classPropertyName: "selectOptions", publicName: "selectOptions", isSignal: true, isRequired: false, transformFunction: null }, selectButtonRef: { classPropertyName: "selectButtonRef", publicName: "selectButtonRef", isSignal: true, isRequired: true, transformFunction: null }, _value: { classPropertyName: "_value", publicName: "_value", isSignal: true, isRequired: false, transformFunction: null }, _isDisabled: { classPropertyName: "_isDisabled", publicName: "_isDisabled", isSignal: true, isRequired: false, transformFunction: null }, componentClass: { classPropertyName: "componentClass", publicName: "componentClass", isSignal: true, isRequired: false, transformFunction: null }, componentLabel: { classPropertyName: "componentLabel", publicName: "componentLabel", isSignal: true, isRequired: false, transformFunction: null }, componentTabIndex: { classPropertyName: "componentTabIndex", publicName: "componentTabIndex", isSignal: true, isRequired: false, transformFunction: null }, translateValue: { classPropertyName: "translateValue", publicName: "translateValue", isSignal: true, isRequired: false, transformFunction: null }, nullOption: { classPropertyName: "nullOption", publicName: "nullOption", isSignal: true, isRequired: false, transformFunction: null }, scrollBehaviorOnOpen: { classPropertyName: "scrollBehaviorOnOpen", publicName: "scrollBehaviorOnOpen", isSignal: true, isRequired: false, transformFunction: null }, parentType: { classPropertyName: "parentType", publicName: "parentType", isSignal: true, isRequired: true, transformFunction: null }, parentID: { classPropertyName: "parentID", publicName: "parentID", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { changedHandler: "changedHandler", blurHandler: "blurHandler", escapePressed: "escapePressed", tabPressed: "tabPressed" }, host: { listeners: { "window:scroll": "changePosition()" } }, viewQueries: [{ propertyName: "optionListContainer", first: true, predicate: ["optionListContainer"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n [attr.aria-activedescendant]=\"getActiveDescendantId()\"\n [attr.aria-label]=\"componentLabel()\"\n [ngStyle]=\"{\n 'max-height': optionListMaxHeight(),\n '--option-list-width': elementWidth(),\n '--option-list-top': elementTop(),\n '--option-list-bottom': elementBottom(),\n }\"\n (blur)=\"onBlurHandler($event)\"\n #optionListContainer\n aria-orientation=\"vertical\"\n class=\"option-list\"\n id=\"optionList\"\n role=\"listbox\"\n tabindex=\"0\"\n>\n <ul role=\"presentation\">\n @for (\n item of selectOptionsList();\n track (item.value ?? '') + (item.label ?? '');\n let i = $index;\n let last = $last\n ) {\n <li\n [attr.aria-selected]=\"getSelected(item)\"\n [class.m-0]=\"last\"\n [class.selected]=\"selectionMode() === 'single' ? getSelected(item) : null\"\n [id]=\"'item-' + i\"\n (mousedown)=\"$event.stopImmediatePropagation(); onSelectItem(item)\"\n class=\"item\"\n role=\"option\"\n >\n <input\n [checked]=\"getSelected(item)\"\n [class.d-none]=\"selectionMode() === 'single' || !item?.value\"\n [disabled]=\"true\"\n [id]=\"i + '-' + item.value + '-checkbox'\"\n [name]=\"i + '-' + item.value + '-checkbox'\"\n [ngClass]=\"componentClass()\"\n [value]=\"getSelected(item)\"\n (blur)=\"onBlurHandler($event)\"\n #inputCheckbox\n aria-hidden=\"true\"\n class=\"form-check-input opacity-100\"\n tabindex=\"-1\"\n type=\"checkbox\"\n />\n <label\n [class.ms-3]=\"selectionMode() === 'multiple' && item?.value\"\n [for]=\"i + '-' + item.value + '-checkbox'\"\n class=\"form-check-label checkbox-label w-100 opacity-100\"\n >\n @if (!item.renderer) {\n {{ translateValue() ? (item.label | transloco) : item.label }}\n }\n <ng-container\n [ngTemplateOutlet]=\"item.renderer ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: item, selected: getSelected(item), index: i }\"\n ></ng-container>\n </label>\n </li>\n }\n </ul>\n</div>\n", styles: [":host{display:block;z-index:999}.option-list{--option-list-width: 100%;--option-list-top: 10px;--option-list-bottom: unset;border:1px solid var(--bs-border-color);border-top:0;border-radius:var(--bs-border-radius);overflow-x:hidden;overflow-y:auto;scrollbar-color:auto;position:fixed;width:var(--option-list-width);top:var(--option-list-top);bottom:var(--option-list-bottom);z-index:999}.option-list ul{margin:0;padding:0}.option-list .selected{background-color:var(--bs-body-bg);filter:brightness(95%)}.option-list.option-list-top{border-top:1px solid var(--bs-border-color);border-bottom:0}.option-list:focus-visible{outline:none}.option-list::-webkit-scrollbar{width:8px}.option-list::-webkit-scrollbar-track{background:var(--bs-body-bg)}.option-list::-webkit-scrollbar-thumb{background-color:#00000038;border-radius:999px;border:2px solid transparent;background-clip:content-box}.option-list:hover::-webkit-scrollbar-thumb{background-color:#00000052}.item{display:flex;background-color:var(--bs-body-bg);z-index:1;padding:0 .5rem;min-height:2.5rem}.item label{padding:.5rem 0}.item:hover{cursor:pointer;background-color:var(--bs-body-bg);filter:brightness(95%)}.item *:hover{cursor:pointer}.item .form-check-input{align-self:center}.item .form-check-input:focus{border-color:var(--bs-border-color);box-shadow:unset}.item .form-check-input:checked{background-color:var(--bs-primary);border-color:var(--bs-border-color)}\n"], dependencies: [{ kind: "directive", type: NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { kind: "directive", type: NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "pipe", type: TranslocoPipe, name: "transloco" }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
419
453
|
}
|
|
420
|
-
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.
|
|
454
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.15", ngImport: i0, type: QuangOptionListComponent, decorators: [{
|
|
421
455
|
type: Component,
|
|
422
|
-
args: [{ selector: 'quang-option-list', imports: [NgStyle, NgClass, TranslocoPipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n [ngStyle]=\"{\n 'max-height': optionListMaxHeight(),\n '--option-list-width': elementWidth(),\n '--option-list-top': elementTop(),\n '--option-list-bottom': elementBottom(),\n }\"\n (blur)=\"onBlurHandler($event)\"\n #optionListContainer\n class=\"option-list\"\n id=\"optionList\"\n tabindex=\"
|
|
423
|
-
}], propDecorators: { selectionMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionMode", required: false }] }], optionListMaxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionListMaxHeight", required: false }] }], selectOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectOptions", required: false }] }], selectButtonRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectButtonRef", required: true }] }], _value: [{ type: i0.Input, args: [{ isSignal: true, alias: "_value", required: false }] }], _isDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "_isDisabled", required: false }] }], componentClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentClass", required: false }] }], componentLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentLabel", required: false }] }], componentTabIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentTabIndex", required: false }] }], translateValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "translateValue", required: false }] }], nullOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "nullOption", required: false }] }], scrollBehaviorOnOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollBehaviorOnOpen", required: false }] }], changedHandler: [{ type: i0.Output, args: ["changedHandler"] }], blurHandler: [{ type: i0.Output, args: ["blurHandler"] }], optionListContainer: [{ type: i0.ViewChild, args: ['optionListContainer', { isSignal: true }] }], parentType: [{ type: i0.Input, args: [{ isSignal: true, alias: "parentType", required: true }] }], parentID: [{ type: i0.Input, args: [{ isSignal: true, alias: "parentID", required: false }] }], changePosition: [{
|
|
456
|
+
args: [{ selector: 'quang-option-list', imports: [NgStyle, NgClass, NgTemplateOutlet, TranslocoPipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n [attr.aria-activedescendant]=\"getActiveDescendantId()\"\n [attr.aria-label]=\"componentLabel()\"\n [ngStyle]=\"{\n 'max-height': optionListMaxHeight(),\n '--option-list-width': elementWidth(),\n '--option-list-top': elementTop(),\n '--option-list-bottom': elementBottom(),\n }\"\n (blur)=\"onBlurHandler($event)\"\n #optionListContainer\n aria-orientation=\"vertical\"\n class=\"option-list\"\n id=\"optionList\"\n role=\"listbox\"\n tabindex=\"0\"\n>\n <ul role=\"presentation\">\n @for (\n item of selectOptionsList();\n track (item.value ?? '') + (item.label ?? '');\n let i = $index;\n let last = $last\n ) {\n <li\n [attr.aria-selected]=\"getSelected(item)\"\n [class.m-0]=\"last\"\n [class.selected]=\"selectionMode() === 'single' ? getSelected(item) : null\"\n [id]=\"'item-' + i\"\n (mousedown)=\"$event.stopImmediatePropagation(); onSelectItem(item)\"\n class=\"item\"\n role=\"option\"\n >\n <input\n [checked]=\"getSelected(item)\"\n [class.d-none]=\"selectionMode() === 'single' || !item?.value\"\n [disabled]=\"true\"\n [id]=\"i + '-' + item.value + '-checkbox'\"\n [name]=\"i + '-' + item.value + '-checkbox'\"\n [ngClass]=\"componentClass()\"\n [value]=\"getSelected(item)\"\n (blur)=\"onBlurHandler($event)\"\n #inputCheckbox\n aria-hidden=\"true\"\n class=\"form-check-input opacity-100\"\n tabindex=\"-1\"\n type=\"checkbox\"\n />\n <label\n [class.ms-3]=\"selectionMode() === 'multiple' && item?.value\"\n [for]=\"i + '-' + item.value + '-checkbox'\"\n class=\"form-check-label checkbox-label w-100 opacity-100\"\n >\n @if (!item.renderer) {\n {{ translateValue() ? (item.label | transloco) : item.label }}\n }\n <ng-container\n [ngTemplateOutlet]=\"item.renderer ?? null\"\n [ngTemplateOutletContext]=\"{ $implicit: item, selected: getSelected(item), index: i }\"\n ></ng-container>\n </label>\n </li>\n }\n </ul>\n</div>\n", styles: [":host{display:block;z-index:999}.option-list{--option-list-width: 100%;--option-list-top: 10px;--option-list-bottom: unset;border:1px solid var(--bs-border-color);border-top:0;border-radius:var(--bs-border-radius);overflow-x:hidden;overflow-y:auto;scrollbar-color:auto;position:fixed;width:var(--option-list-width);top:var(--option-list-top);bottom:var(--option-list-bottom);z-index:999}.option-list ul{margin:0;padding:0}.option-list .selected{background-color:var(--bs-body-bg);filter:brightness(95%)}.option-list.option-list-top{border-top:1px solid var(--bs-border-color);border-bottom:0}.option-list:focus-visible{outline:none}.option-list::-webkit-scrollbar{width:8px}.option-list::-webkit-scrollbar-track{background:var(--bs-body-bg)}.option-list::-webkit-scrollbar-thumb{background-color:#00000038;border-radius:999px;border:2px solid transparent;background-clip:content-box}.option-list:hover::-webkit-scrollbar-thumb{background-color:#00000052}.item{display:flex;background-color:var(--bs-body-bg);z-index:1;padding:0 .5rem;min-height:2.5rem}.item label{padding:.5rem 0}.item:hover{cursor:pointer;background-color:var(--bs-body-bg);filter:brightness(95%)}.item *:hover{cursor:pointer}.item .form-check-input{align-self:center}.item .form-check-input:focus{border-color:var(--bs-border-color);box-shadow:unset}.item .form-check-input:checked{background-color:var(--bs-primary);border-color:var(--bs-border-color)}\n"] }]
|
|
457
|
+
}], propDecorators: { selectionMode: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectionMode", required: false }] }], optionListMaxHeight: [{ type: i0.Input, args: [{ isSignal: true, alias: "optionListMaxHeight", required: false }] }], selectOptions: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectOptions", required: false }] }], selectButtonRef: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectButtonRef", required: true }] }], _value: [{ type: i0.Input, args: [{ isSignal: true, alias: "_value", required: false }] }], _isDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "_isDisabled", required: false }] }], componentClass: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentClass", required: false }] }], componentLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentLabel", required: false }] }], componentTabIndex: [{ type: i0.Input, args: [{ isSignal: true, alias: "componentTabIndex", required: false }] }], translateValue: [{ type: i0.Input, args: [{ isSignal: true, alias: "translateValue", required: false }] }], nullOption: [{ type: i0.Input, args: [{ isSignal: true, alias: "nullOption", required: false }] }], scrollBehaviorOnOpen: [{ type: i0.Input, args: [{ isSignal: true, alias: "scrollBehaviorOnOpen", required: false }] }], changedHandler: [{ type: i0.Output, args: ["changedHandler"] }], blurHandler: [{ type: i0.Output, args: ["blurHandler"] }], escapePressed: [{ type: i0.Output, args: ["escapePressed"] }], tabPressed: [{ type: i0.Output, args: ["tabPressed"] }], optionListContainer: [{ type: i0.ViewChild, args: ['optionListContainer', { isSignal: true }] }], parentType: [{ type: i0.Input, args: [{ isSignal: true, alias: "parentType", required: true }] }], parentID: [{ type: i0.Input, args: [{ isSignal: true, alias: "parentID", required: false }] }], changePosition: [{
|
|
424
458
|
type: HostListener,
|
|
425
459
|
args: ['window:scroll']
|
|
426
460
|
}] } });
|