UNPKG

@edugouvfr/ngx-dsfr

Version:

NgxDsfr est un portage Angular des éléments d'interface du Système de Design de l'État Français (DSFR).

118 lines 25.6 kB
import { Component, EventEmitter, forwardRef, Input, Output, ViewEncapsulation, } from '@angular/core'; import { NG_VALUE_ACCESSOR } from '@angular/forms'; import { DefaultControlComponent } from '../../shared'; import * as i0 from "@angular/core"; import * as i1 from "../../shared"; import * as i2 from "@angular/common"; import * as i3 from "@angular/forms"; export class DsfrFormSelectComponent extends DefaultControlComponent { /** @internal */ constructor(i18n) { super(); this.i18n = i18n; /** * Indique que le champ est obligatoire, nécessaire du point de vue de l'accessibilité. */ this.required = false; /** * Output équivalent de (ngModelChange) si celui n'est pas disponible. */ this.selectChange = new EventEmitter(); /** * @internal * https://github.com/angular/angular/issues/50233 : issue performance with ng-container/ng-template inside select for Firefox * Dans le cas ou il n'y a pas de groupe, supprimer le ng-container avec ngFor côté template * fixme: vérifier/améliorer le fix lors du passage à angular 17. */ this.noGroup = true; /** @internal fonction de comparaison */ this.compareFn = Object.is; this.trackByIndex = (index) => { return index; }; } /** * @deprecated since 1.2, utiliser `placeholder` à la place (sans H majuscule). */ get placeHolder() { return this.placeholder; } /** * @deprecated since 1.2, utiliser `placeholder` à la place (sans H majuscule). */ set placeHolder(value) { this.placeholder = value; } /** Personnalisation de la comparaison. CompareWith est une fonction qui a deux arguments: valeur option1 et valeur option2. Si compareWith est fournie, sélection de l'option en fonction du retour de la fonction. */ set compareWith(fn) { if (typeof fn !== 'function') { throw Error('`compareWith` must be a function.'); } this.compareFn = fn; } /** @internal */ ngOnInit() { if (this.options && this.options.length && this.options.find((o) => o.options)) { this.noGroup = false; } super.ngOnInit(); this.messagesGroupId = `${this.inputId}-messages`; this.placeholder ??= this.i18n.t('select.placeholder'); } ngOnChanges({ value }) { if (value && this.value && this.options?.length) { if (!this.findOption(this.value, this.options)) { this.value = undefined; } } } /** @internal */ onChange() { // Comme on a le double binding, la valeur est déjà à jour // this.value = (<HTMLSelectElement>event?.target)?.value; this.selectChange.emit(this.value); } findOption(value, options) { return options?.find((option) => this.compareFn(value, option.value) || option.value === value || (option.options && this.findOption(value, option.options))); } static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DsfrFormSelectComponent, deps: [{ token: i1.I18nService }], target: i0.ɵɵFactoryTarget.Component }); } static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "16.2.12", type: DsfrFormSelectComponent, selector: "dsfr-form-select", inputs: { placeholder: "placeholder", options: "options", required: "required", ariaLabel: "ariaLabel", error: "error", valid: "valid", placeHolder: "placeHolder", compareWith: "compareWith" }, outputs: { selectChange: "selectChange" }, providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DsfrFormSelectComponent), multi: true, }, ], usesInheritance: true, usesOnChanges: true, ngImport: i0, template: "<div\n [ngClass]=\"{\n 'fr-select-group': true,\n 'fr-select-group--error': error,\n 'fr-select-group--valid': valid,\n 'fr-select-group--disabled': disabled\n }\">\n <label class=\"fr-label\" [for]=\"inputId\">\n <ng-container *ngIf=\"label\">{{ label }}</ng-container>\n <ng-content *ngIf=\"!label\" select=\"[label]\"></ng-content>\n <span *ngIf=\"hint\" class=\"fr-hint-text\">{{ hint }}</span>\n </label>\n\n <!-- Select sans groupes. Duplication du select pour pb perf. affichage d'options sur firefox si utilisation d'un ng-container -->\n <select\n *ngIf=\"noGroup\"\n class=\"fr-select\"\n [id]=\"inputId\"\n [attr.name]=\"name || null\"\n [(ngModel)]=\"value\"\n [attr.aria-describedby]=\"messagesGroupId\"\n [attr.aria-label]=\"ariaLabel\"\n [disabled]=\"disabled\"\n [attr.required]=\"required || null\"\n [compareWith]=\"compareFn\"\n (change)=\"onChange()\">\n <option *ngIf=\"!value\" [value]=\"value\" selected hidden disabled>{{ placeholder }}</option>\n <option\n *ngFor=\"let option of options; trackBy: trackByIndex\"\n [ngValue]=\"option.value\"\n [attr.aria-selected]=\"compareFn(option.value, value)\"\n [disabled]=\"option.disabled || null\">\n {{ option.label }}\n </option>\n </select>\n\n <!-- Select avec groupes. Ne sera pas optimis\u00E9 pour FF, voir pour un fix avec angular 17 -->\n <select\n *ngIf=\"!noGroup\"\n class=\"fr-select\"\n [id]=\"inputId\"\n [attr.name]=\"name || null\"\n [(ngModel)]=\"value\"\n [attr.aria-describedby]=\"messagesGroupId\"\n [attr.aria-label]=\"ariaLabel\"\n [disabled]=\"disabled\"\n [attr.required]=\"required || null\"\n [compareWith]=\"compareFn\"\n (change)=\"onChange()\">\n <option *ngIf=\"!value\" [value]=\"value\" selected hidden disabled>{{ placeholder }}</option>\n <ng-container *ngFor=\"let option of options; trackBy: trackByIndex\">\n <option\n *ngIf=\"!option.options\"\n [ngValue]=\"option.value\"\n [attr.aria-selected]=\"compareFn(option.value, value)\"\n [disabled]=\"option.disabled || null\">\n {{ option.label }}\n </option>\n </ng-container>\n <ng-container *ngFor=\"let option of options; trackBy: trackByIndex\">\n <optgroup *ngIf=\"option.options\" [label]=\"option.label\">\n <option\n *ngFor=\"let option of option.options; trackBy: trackByIndex\"\n [ngValue]=\"option.value\"\n [attr.aria-selected]=\"compareFn(option.value, value)\"\n [disabled]=\"option.disabled || null\">\n {{ option.label }}\n </option>\n </optgroup>\n </ng-container>\n </select>\n\n <div [id]=\"messagesGroupId\" class=\"fr-messages-group\" aria-live=\"polite\">\n <p *ngIf=\"error\" class=\"fr-message fr-message--error\">{{ error }}</p>\n <p *ngIf=\"valid\" class=\"fr-message fr-message--valid\">{{ valid }}</p>\n </div>\n</div>\n", dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i3.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { kind: "directive", type: i3.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { kind: "directive", type: i3.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i3.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }], encapsulation: i0.ViewEncapsulation.None }); } } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: DsfrFormSelectComponent, decorators: [{ type: Component, args: [{ selector: 'dsfr-form-select', encapsulation: ViewEncapsulation.None, providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => DsfrFormSelectComponent), multi: true, }, ], template: "<div\n [ngClass]=\"{\n 'fr-select-group': true,\n 'fr-select-group--error': error,\n 'fr-select-group--valid': valid,\n 'fr-select-group--disabled': disabled\n }\">\n <label class=\"fr-label\" [for]=\"inputId\">\n <ng-container *ngIf=\"label\">{{ label }}</ng-container>\n <ng-content *ngIf=\"!label\" select=\"[label]\"></ng-content>\n <span *ngIf=\"hint\" class=\"fr-hint-text\">{{ hint }}</span>\n </label>\n\n <!-- Select sans groupes. Duplication du select pour pb perf. affichage d'options sur firefox si utilisation d'un ng-container -->\n <select\n *ngIf=\"noGroup\"\n class=\"fr-select\"\n [id]=\"inputId\"\n [attr.name]=\"name || null\"\n [(ngModel)]=\"value\"\n [attr.aria-describedby]=\"messagesGroupId\"\n [attr.aria-label]=\"ariaLabel\"\n [disabled]=\"disabled\"\n [attr.required]=\"required || null\"\n [compareWith]=\"compareFn\"\n (change)=\"onChange()\">\n <option *ngIf=\"!value\" [value]=\"value\" selected hidden disabled>{{ placeholder }}</option>\n <option\n *ngFor=\"let option of options; trackBy: trackByIndex\"\n [ngValue]=\"option.value\"\n [attr.aria-selected]=\"compareFn(option.value, value)\"\n [disabled]=\"option.disabled || null\">\n {{ option.label }}\n </option>\n </select>\n\n <!-- Select avec groupes. Ne sera pas optimis\u00E9 pour FF, voir pour un fix avec angular 17 -->\n <select\n *ngIf=\"!noGroup\"\n class=\"fr-select\"\n [id]=\"inputId\"\n [attr.name]=\"name || null\"\n [(ngModel)]=\"value\"\n [attr.aria-describedby]=\"messagesGroupId\"\n [attr.aria-label]=\"ariaLabel\"\n [disabled]=\"disabled\"\n [attr.required]=\"required || null\"\n [compareWith]=\"compareFn\"\n (change)=\"onChange()\">\n <option *ngIf=\"!value\" [value]=\"value\" selected hidden disabled>{{ placeholder }}</option>\n <ng-container *ngFor=\"let option of options; trackBy: trackByIndex\">\n <option\n *ngIf=\"!option.options\"\n [ngValue]=\"option.value\"\n [attr.aria-selected]=\"compareFn(option.value, value)\"\n [disabled]=\"option.disabled || null\">\n {{ option.label }}\n </option>\n </ng-container>\n <ng-container *ngFor=\"let option of options; trackBy: trackByIndex\">\n <optgroup *ngIf=\"option.options\" [label]=\"option.label\">\n <option\n *ngFor=\"let option of option.options; trackBy: trackByIndex\"\n [ngValue]=\"option.value\"\n [attr.aria-selected]=\"compareFn(option.value, value)\"\n [disabled]=\"option.disabled || null\">\n {{ option.label }}\n </option>\n </optgroup>\n </ng-container>\n </select>\n\n <div [id]=\"messagesGroupId\" class=\"fr-messages-group\" aria-live=\"polite\">\n <p *ngIf=\"error\" class=\"fr-message fr-message--error\">{{ error }}</p>\n <p *ngIf=\"valid\" class=\"fr-message fr-message--valid\">{{ valid }}</p>\n </div>\n</div>\n" }] }], ctorParameters: function () { return [{ type: i1.I18nService }]; }, propDecorators: { placeholder: [{ type: Input }], options: [{ type: Input }], required: [{ type: Input }], ariaLabel: [{ type: Input }], error: [{ type: Input }], valid: [{ type: Input }], selectChange: [{ type: Output }], placeHolder: [{ type: Input }], compareWith: [{ type: Input }] } }); //# sourceMappingURL=data:application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