source: trip-planner-front/node_modules/primeng/fesm2015/primeng-inputswitch.mjs@ 6fe77af

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

adding photos

  • Property mode set to 100644
File size: 7.0 KB
Line 
1import * as i0 from '@angular/core';
2import { forwardRef, EventEmitter, Component, ChangeDetectionStrategy, ViewEncapsulation, Input, Output, NgModule } from '@angular/core';
3import * as i1 from '@angular/common';
4import { CommonModule } from '@angular/common';
5import { NG_VALUE_ACCESSOR } from '@angular/forms';
6
7const INPUTSWITCH_VALUE_ACCESSOR = {
8 provide: NG_VALUE_ACCESSOR,
9 useExisting: forwardRef(() => InputSwitch),
10 multi: true
11};
12class InputSwitch {
13 constructor(cd) {
14 this.cd = cd;
15 this.trueValue = true;
16 this.falseValue = false;
17 this.onChange = new EventEmitter();
18 this.modelValue = false;
19 this.focused = false;
20 this.onModelChange = () => { };
21 this.onModelTouched = () => { };
22 }
23 onClick(event, cb) {
24 if (!this.disabled && !this.readonly) {
25 event.preventDefault();
26 this.toggle(event);
27 cb.focus();
28 }
29 }
30 onInputChange(event) {
31 if (!this.readonly) {
32 const inputChecked = event.target.checked;
33 this.updateModel(event, inputChecked);
34 }
35 }
36 toggle(event) {
37 this.updateModel(event, !this.checked());
38 }
39 updateModel(event, value) {
40 this.modelValue = value ? this.trueValue : this.falseValue;
41 this.onModelChange(this.modelValue);
42 this.onChange.emit({
43 originalEvent: event,
44 checked: this.modelValue
45 });
46 }
47 onFocus(event) {
48 this.focused = true;
49 }
50 onBlur(event) {
51 this.focused = false;
52 this.onModelTouched();
53 }
54 writeValue(value) {
55 this.modelValue = value;
56 this.cd.markForCheck();
57 }
58 registerOnChange(fn) {
59 this.onModelChange = fn;
60 }
61 registerOnTouched(fn) {
62 this.onModelTouched = fn;
63 }
64 setDisabledState(val) {
65 this.disabled = val;
66 this.cd.markForCheck();
67 }
68 checked() {
69 return this.modelValue === this.trueValue;
70 }
71}
72InputSwitch.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: InputSwitch, deps: [{ token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
73InputSwitch.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.0.0", type: InputSwitch, selector: "p-inputSwitch", inputs: { style: "style", styleClass: "styleClass", tabindex: "tabindex", inputId: "inputId", name: "name", disabled: "disabled", readonly: "readonly", trueValue: "trueValue", falseValue: "falseValue", ariaLabelledBy: "ariaLabelledBy" }, outputs: { onChange: "onChange" }, host: { classAttribute: "p-element" }, providers: [INPUTSWITCH_VALUE_ACCESSOR], ngImport: i0, template: `
74 <div [ngClass]="{'p-inputswitch p-component': true, 'p-inputswitch-checked': checked(), 'p-disabled': disabled, 'p-focus': focused}"
75 [ngStyle]="style" [class]="styleClass" (click)="onClick($event, cb)">
76 <div class="p-hidden-accessible">
77 <input #cb type="checkbox" [attr.id]="inputId" [attr.name]="name" [attr.tabindex]="tabindex" [checked]="checked()" (change)="onInputChange($event)"
78 (focus)="onFocus($event)" (blur)="onBlur($event)" [disabled]="disabled" role="switch" [attr.aria-checked]="checked()" [attr.aria-labelledby]="ariaLabelledBy"/>
79 </div>
80 <span class="p-inputswitch-slider"></span>
81 </div>
82 `, isInline: true, styles: [".p-inputswitch{position:relative;display:inline-block;-webkit-user-select:none;-ms-user-select:none;user-select:none}.p-inputswitch-slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0}.p-inputswitch-slider:before{position:absolute;content:\"\";top:50%}\n"], directives: [{ type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1.NgStyle, selector: "[ngStyle]", inputs: ["ngStyle"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush, encapsulation: i0.ViewEncapsulation.None });
83i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: InputSwitch, decorators: [{
84 type: Component,
85 args: [{ selector: 'p-inputSwitch', template: `
86 <div [ngClass]="{'p-inputswitch p-component': true, 'p-inputswitch-checked': checked(), 'p-disabled': disabled, 'p-focus': focused}"
87 [ngStyle]="style" [class]="styleClass" (click)="onClick($event, cb)">
88 <div class="p-hidden-accessible">
89 <input #cb type="checkbox" [attr.id]="inputId" [attr.name]="name" [attr.tabindex]="tabindex" [checked]="checked()" (change)="onInputChange($event)"
90 (focus)="onFocus($event)" (blur)="onBlur($event)" [disabled]="disabled" role="switch" [attr.aria-checked]="checked()" [attr.aria-labelledby]="ariaLabelledBy"/>
91 </div>
92 <span class="p-inputswitch-slider"></span>
93 </div>
94 `, providers: [INPUTSWITCH_VALUE_ACCESSOR], changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.None, host: {
95 'class': 'p-element'
96 }, styles: [".p-inputswitch{position:relative;display:inline-block;-webkit-user-select:none;-ms-user-select:none;user-select:none}.p-inputswitch-slider{position:absolute;cursor:pointer;top:0;left:0;right:0;bottom:0}.p-inputswitch-slider:before{position:absolute;content:\"\";top:50%}\n"] }]
97 }], ctorParameters: function () { return [{ type: i0.ChangeDetectorRef }]; }, propDecorators: { style: [{
98 type: Input
99 }], styleClass: [{
100 type: Input
101 }], tabindex: [{
102 type: Input
103 }], inputId: [{
104 type: Input
105 }], name: [{
106 type: Input
107 }], disabled: [{
108 type: Input
109 }], readonly: [{
110 type: Input
111 }], trueValue: [{
112 type: Input
113 }], falseValue: [{
114 type: Input
115 }], ariaLabelledBy: [{
116 type: Input
117 }], onChange: [{
118 type: Output
119 }] } });
120class InputSwitchModule {
121}
122InputSwitchModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: InputSwitchModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
123InputSwitchModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: InputSwitchModule, declarations: [InputSwitch], imports: [CommonModule], exports: [InputSwitch] });
124InputSwitchModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: InputSwitchModule, imports: [[CommonModule]] });
125i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.0", ngImport: i0, type: InputSwitchModule, decorators: [{
126 type: NgModule,
127 args: [{
128 imports: [CommonModule],
129 exports: [InputSwitch],
130 declarations: [InputSwitch]
131 }]
132 }] });
133
134/**
135 * Generated bundle index. Do not edit.
136 */
137
138export { INPUTSWITCH_VALUE_ACCESSOR, InputSwitch, InputSwitchModule };
Note: See TracBrowser for help on using the repository browser.