source: trip-planner-front/node_modules/@angular/material/esm2015/chips/chip-input.js

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

initial commit

  • Property mode set to 100644
File size: 22.5 KB
RevLine 
[6a3a178]1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { coerceBooleanProperty } from '@angular/cdk/coercion';
9import { BACKSPACE, hasModifierKey, TAB } from '@angular/cdk/keycodes';
10import { Directive, ElementRef, EventEmitter, Inject, Input, Output } from '@angular/core';
11import { MAT_CHIPS_DEFAULT_OPTIONS } from './chip-default-options';
12import { MatChipList } from './chip-list';
13// Increasing integer for generating unique ids.
14let nextUniqueId = 0;
15/**
16 * Directive that adds chip-specific behaviors to an input element inside `<mat-form-field>`.
17 * May be placed inside or outside of an `<mat-chip-list>`.
18 */
19export class MatChipInput {
20 constructor(_elementRef, _defaultOptions) {
21 this._elementRef = _elementRef;
22 this._defaultOptions = _defaultOptions;
23 /** Whether the control is focused. */
24 this.focused = false;
25 this._addOnBlur = false;
26 /**
27 * The list of key codes that will trigger a chipEnd event.
28 *
29 * Defaults to `[ENTER]`.
30 */
31 this.separatorKeyCodes = this._defaultOptions.separatorKeyCodes;
32 /** Emitted when a chip is to be added. */
33 this.chipEnd = new EventEmitter();
34 /** The input's placeholder text. */
35 this.placeholder = '';
36 /** Unique id for the input. */
37 this.id = `mat-chip-list-input-${nextUniqueId++}`;
38 this._disabled = false;
39 this.inputElement = this._elementRef.nativeElement;
40 }
41 /** Register input for chip list */
42 set chipList(value) {
43 if (value) {
44 this._chipList = value;
45 this._chipList.registerInput(this);
46 }
47 }
48 /**
49 * Whether or not the chipEnd event will be emitted when the input is blurred.
50 */
51 get addOnBlur() { return this._addOnBlur; }
52 set addOnBlur(value) { this._addOnBlur = coerceBooleanProperty(value); }
53 /** Whether the input is disabled. */
54 get disabled() { return this._disabled || (this._chipList && this._chipList.disabled); }
55 set disabled(value) { this._disabled = coerceBooleanProperty(value); }
56 /** Whether the input is empty. */
57 get empty() { return !this.inputElement.value; }
58 ngOnChanges() {
59 this._chipList.stateChanges.next();
60 }
61 ngOnDestroy() {
62 this.chipEnd.complete();
63 }
64 ngAfterContentInit() {
65 this._focusLastChipOnBackspace = this.empty;
66 }
67 /** Utility method to make host definition/tests more clear. */
68 _keydown(event) {
69 if (event) {
70 // Allow the user's focus to escape when they're tabbing forward. Note that we don't
71 // want to do this when going backwards, because focus should go back to the first chip.
72 if (event.keyCode === TAB && !hasModifierKey(event, 'shiftKey')) {
73 this._chipList._allowFocusEscape();
74 }
75 // To prevent the user from accidentally deleting chips when pressing BACKSPACE continuously,
76 // We focus the last chip on backspace only after the user has released the backspace button,
77 // and the input is empty (see behaviour in _keyup)
78 if (event.keyCode === BACKSPACE && this._focusLastChipOnBackspace) {
79 this._chipList._keyManager.setLastItemActive();
80 event.preventDefault();
81 return;
82 }
83 else {
84 this._focusLastChipOnBackspace = false;
85 }
86 }
87 this._emitChipEnd(event);
88 }
89 /**
90 * Pass events to the keyboard manager. Available here for tests.
91 */
92 _keyup(event) {
93 // Allow user to move focus to chips next time he presses backspace
94 if (!this._focusLastChipOnBackspace && event.keyCode === BACKSPACE && this.empty) {
95 this._focusLastChipOnBackspace = true;
96 event.preventDefault();
97 }
98 }
99 /** Checks to see if the blur should emit the (chipEnd) event. */
100 _blur() {
101 if (this.addOnBlur) {
102 this._emitChipEnd();
103 }
104 this.focused = false;
105 // Blur the chip list if it is not focused
106 if (!this._chipList.focused) {
107 this._chipList._blur();
108 }
109 this._chipList.stateChanges.next();
110 }
111 _focus() {
112 this.focused = true;
113 this._focusLastChipOnBackspace = this.empty;
114 this._chipList.stateChanges.next();
115 }
116 /** Checks to see if the (chipEnd) event needs to be emitted. */
117 _emitChipEnd(event) {
118 if (!this.inputElement.value && !!event) {
119 this._chipList._keydown(event);
120 }
121 if (!event || this._isSeparatorKey(event)) {
122 this.chipEnd.emit({
123 input: this.inputElement,
124 value: this.inputElement.value,
125 chipInput: this,
126 });
127 event === null || event === void 0 ? void 0 : event.preventDefault();
128 }
129 }
130 _onInput() {
131 // Let chip list know whenever the value changes.
132 this._chipList.stateChanges.next();
133 }
134 /** Focuses the input. */
135 focus(options) {
136 this.inputElement.focus(options);
137 }
138 /** Clears the input */
139 clear() {
140 this.inputElement.value = '';
141 this._focusLastChipOnBackspace = true;
142 }
143 /** Checks whether a keycode is one of the configured separators. */
144 _isSeparatorKey(event) {
145 return !hasModifierKey(event) && new Set(this.separatorKeyCodes).has(event.keyCode);
146 }
147}
148MatChipInput.decorators = [
149 { type: Directive, args: [{
150 selector: 'input[matChipInputFor]',
151 exportAs: 'matChipInput, matChipInputFor',
152 host: {
153 'class': 'mat-chip-input mat-input-element',
154 '(keydown)': '_keydown($event)',
155 '(keyup)': '_keyup($event)',
156 '(blur)': '_blur()',
157 '(focus)': '_focus()',
158 '(input)': '_onInput()',
159 '[id]': 'id',
160 '[attr.disabled]': 'disabled || null',
161 '[attr.placeholder]': 'placeholder || null',
162 '[attr.aria-invalid]': '_chipList && _chipList.ngControl ? _chipList.ngControl.invalid : null',
163 '[attr.aria-required]': '_chipList && _chipList.required || null',
164 }
165 },] }
166];
167MatChipInput.ctorParameters = () => [
168 { type: ElementRef },
169 { type: undefined, decorators: [{ type: Inject, args: [MAT_CHIPS_DEFAULT_OPTIONS,] }] }
170];
171MatChipInput.propDecorators = {
172 chipList: [{ type: Input, args: ['matChipInputFor',] }],
173 addOnBlur: [{ type: Input, args: ['matChipInputAddOnBlur',] }],
174 separatorKeyCodes: [{ type: Input, args: ['matChipInputSeparatorKeyCodes',] }],
175 chipEnd: [{ type: Output, args: ['matChipInputTokenEnd',] }],
176 placeholder: [{ type: Input }],
177 id: [{ type: Input }],
178 disabled: [{ type: Input }]
179};
180//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hpcC1pbnB1dC5qcyIsInNvdXJjZVJvb3QiOiI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