source: trip-planner-front/node_modules/primeng/fesm2015/primeng-radiobutton.mjs@ 571e0df

Last change on this file since 571e0df was 59329aa, checked in by Ema <ema_spirova@…>, 3 years ago

adding photos

  • Property mode set to 100644
File size: 10.4 KB
Line 
1import * as i0 from '@angular/core';
2import { forwardRef, Injectable, EventEmitter, Component, ChangeDetectionStrategy, Input, Output, ViewChild, NgModule } from '@angular/core';
3import * as i1 from '@angular/common';
4import { CommonModule } from '@angular/common';
5import { NG_VALUE_ACCESSOR, NgControl } from '@angular/forms';
6
7const RADIO_VALUE_ACCESSOR = {
8 provide: NG_VALUE_ACCESSOR,
9 useExisting: forwardRef(() => RadioButton),
10 multi: true
11};
12class RadioControlRegistry {
13 constructor() {
14 this.accessors = [];
15 }
16 add(control, accessor) {
17 this.accessors.push([control, accessor]);
18 }
19 remove(accessor) {
20 this.accessors = this.accessors.filter((c) => {
21 return c[1] !== accessor;
22 });
23 }
24 select(accessor) {
25 this.accessors.forEach((c) => {
26 if (this.isSameGroup(c, accessor) && c[1] !== accessor) {
27 c[1].writeValue(accessor.value);
28 }
29 });
30 }
31 isSameGroup(controlPair, accessor) {
32 if (!controlPair[0].control) {
33 return false;
34 }
35 return controlPair[0].control.root === accessor.control.control.root && controlPair[1].name === accessor.name;
36 }
37}
38RadioControlRegistry.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RadioControlRegistry, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
39RadioControlRegistry.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RadioControlRegistry, providedIn: 'root' });
40i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RadioControlRegistry, decorators: [{
41 type: Injectable,
42 args: [{
43 providedIn: 'root',
44 }]
45 }] });
46class RadioButton {
47 constructor(cd, injector, registry) {
48 this.cd = cd;
49 this.injector = injector;
50 this.registry = registry;
51 this.onClick = new EventEmitter();
52 this.onFocus = new EventEmitter();
53 this.onBlur = new EventEmitter();
54 this.onModelChange = () => { };
55 this.onModelTouched = () => { };
56 }
57 ngOnInit() {
58 this.control = this.injector.get(NgControl);
59 this.checkName();
60 this.registry.add(this.control, this);
61 }
62 handleClick(event, radioButton, focus) {
63 event.preventDefault();
64 if (this.disabled) {
65 return;
66 }
67 this.select(event);
68 if (focus) {
69 radioButton.focus();
70 }
71 }
72 select(event) {
73 if (!this.disabled) {
74 this.inputViewChild.nativeElement.checked = true;
75 this.checked = true;
76 this.onModelChange(this.value);
77 this.registry.select(this);
78 this.onClick.emit(event);
79 }
80 }
81 writeValue(value) {
82 this.checked = (value == this.value);
83 if (this.inputViewChild && this.inputViewChild.nativeElement) {
84 this.inputViewChild.nativeElement.checked = this.checked;
85 }
86 this.cd.markForCheck();
87 }
88 registerOnChange(fn) {
89 this.onModelChange = fn;
90 }
91 registerOnTouched(fn) {
92 this.onModelTouched = fn;
93 }
94 setDisabledState(val) {
95 this.disabled = val;
96 this.cd.markForCheck();
97 }
98 onInputFocus(event) {
99 this.focused = true;
100 this.onFocus.emit(event);
101 }
102 onInputBlur(event) {
103 this.focused = false;
104 this.onModelTouched();
105 this.onBlur.emit(event);
106 }
107 onChange(event) {
108 this.select(event);
109 }
110 focus() {
111 this.inputViewChild.nativeElement.focus();
112 }
113 ngOnDestroy() {
114 this.registry.remove(this);
115 }
116 checkName() {
117 if (this.name && this.formControlName && this.name !== this.formControlName) {
118 this.throwNameError();
119 }
120 if (!this.name && this.formControlName) {
121 this.name = this.formControlName;
122 }
123 }
124 throwNameError() {
125 throw new Error(`
126 If you define both a name and a formControlName attribute on your radio button, their values
127 must match. Ex: <p-radioButton formControlName="food" name="food"></p-radioButton>
128 `);
129 }
130}
131RadioButton.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RadioButton, deps: [{ token: i0.ChangeDetectorRef }, { token: i0.Injector }, { token: RadioControlRegistry }], target: i0.ɵɵFactoryTarget.Component });
132RadioButton.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: RadioButton, selector: "p-radioButton", inputs: { value: "value", formControlName: "formControlName", name: "name", disabled: "disabled", label: "label", tabindex: "tabindex", inputId: "inputId", ariaLabelledBy: "ariaLabelledBy", ariaLabel: "ariaLabel", style: "style", styleClass: "styleClass", labelStyleClass: "labelStyleClass" }, outputs: { onClick: "onClick", onFocus: "onFocus", onBlur: "onBlur" }, host: { classAttribute: "p-element" }, providers: [RADIO_VALUE_ACCESSOR], viewQueries: [{ propertyName: "inputViewChild", first: true, predicate: ["rb"], descendants: true }], ngImport: i0, template: `
133 <div [ngStyle]="style" [ngClass]="{'p-radiobutton p-component':true,'p-radiobutton-checked': checked, 'p-radiobutton-disabled': disabled, 'p-radiobutton-focused': focused}" [class]="styleClass">
134 <div class="p-hidden-accessible">
135 <input #rb type="radio" [attr.id]="inputId" [attr.name]="name" [attr.value]="value" [attr.tabindex]="tabindex" [attr.aria-checked]="checked" [attr.aria-label]="ariaLabel"
136 [attr.aria-labelledby]="ariaLabelledBy" [checked]="checked" (change)="onChange($event)" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)" [disabled]="disabled">
137 </div>
138 <div (click)="handleClick($event, rb, true)" [ngClass]="{'p-radiobutton-box':true, 'p-highlight': checked, 'p-disabled': disabled, 'p-focus': focused}">
139 <span class="p-radiobutton-icon"></span>
140 </div>
141 </div>
142 <label (click)="select($event)" [class]="labelStyleClass"
143 [ngClass]="{'p-radiobutton-label':true, 'p-radiobutton-label-active':rb.checked, 'p-disabled':disabled, 'p-radiobutton-label-focus':focused}"
144 *ngIf="label" [attr.for]="inputId">{{label}}</label>
145 `, isInline: true, directives: [{ type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }, { type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
146i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RadioButton, decorators: [{
147 type: Component,
148 args: [{
149 selector: 'p-radioButton',
150 template: `
151 <div [ngStyle]="style" [ngClass]="{'p-radiobutton p-component':true,'p-radiobutton-checked': checked, 'p-radiobutton-disabled': disabled, 'p-radiobutton-focused': focused}" [class]="styleClass">
152 <div class="p-hidden-accessible">
153 <input #rb type="radio" [attr.id]="inputId" [attr.name]="name" [attr.value]="value" [attr.tabindex]="tabindex" [attr.aria-checked]="checked" [attr.aria-label]="ariaLabel"
154 [attr.aria-labelledby]="ariaLabelledBy" [checked]="checked" (change)="onChange($event)" (focus)="onInputFocus($event)" (blur)="onInputBlur($event)" [disabled]="disabled">
155 </div>
156 <div (click)="handleClick($event, rb, true)" [ngClass]="{'p-radiobutton-box':true, 'p-highlight': checked, 'p-disabled': disabled, 'p-focus': focused}">
157 <span class="p-radiobutton-icon"></span>
158 </div>
159 </div>
160 <label (click)="select($event)" [class]="labelStyleClass"
161 [ngClass]="{'p-radiobutton-label':true, 'p-radiobutton-label-active':rb.checked, 'p-disabled':disabled, 'p-radiobutton-label-focus':focused}"
162 *ngIf="label" [attr.for]="inputId">{{label}}</label>
163 `,
164 providers: [RADIO_VALUE_ACCESSOR],
165 changeDetection: ChangeDetectionStrategy.OnPush,
166 host: {
167 'class': 'p-element'
168 }
169 }]
170 }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }, { type: i0.Injector }, { type: RadioControlRegistry }]; }, propDecorators: { value: [{
171 type: Input
172 }], formControlName: [{
173 type: Input
174 }], name: [{
175 type: Input
176 }], disabled: [{
177 type: Input
178 }], label: [{
179 type: Input
180 }], tabindex: [{
181 type: Input
182 }], inputId: [{
183 type: Input
184 }], ariaLabelledBy: [{
185 type: Input
186 }], ariaLabel: [{
187 type: Input
188 }], style: [{
189 type: Input
190 }], styleClass: [{
191 type: Input
192 }], labelStyleClass: [{
193 type: Input
194 }], onClick: [{
195 type: Output
196 }], onFocus: [{
197 type: Output
198 }], onBlur: [{
199 type: Output
200 }], inputViewChild: [{
201 type: ViewChild,
202 args: ['rb']
203 }] } });
204class RadioButtonModule {
205}
206RadioButtonModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RadioButtonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
207RadioButtonModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RadioButtonModule, declarations: [RadioButton], imports: [CommonModule], exports: [RadioButton] });
208RadioButtonModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RadioButtonModule, imports: [[CommonModule]] });
209i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: RadioButtonModule, decorators: [{
210 type: NgModule,
211 args: [{
212 imports: [CommonModule],
213 exports: [RadioButton],
214 declarations: [RadioButton]
215 }]
216 }] });
217
218/**
219 * Generated bundle index. Do not edit.
220 */
221
222export { RADIO_VALUE_ACCESSOR, RadioButton, RadioButtonModule, RadioControlRegistry };
Note: See TracBrowser for help on using the repository browser.