UNPKG

36.2 kBJavaScriptView Raw
1import { CommonModule } from '@angular/common';
2import { Component, ChangeDetectionStrategy, ViewEncapsulation, forwardRef, Renderer2, ViewChildren, ElementRef, Input, ChangeDetectorRef, ViewChild, HostBinding, EventEmitter, Output, Directive, ContentChildren, NgModule } from '@angular/core';
3import { NG_VALUE_ACCESSOR } from '@angular/forms';
4import { trigger, state, style, transition, animate } from '@angular/animations';
5
6/**
7 * @fileoverview added by tsickle
8 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
9 */
10class BMDurationInputComponent {
11 /**
12 * @param {?} renderer
13 */
14 constructor(renderer) {
15 this.renderer = renderer;
16 // tslint:disable-next-line:prefer-array-literal
17 this.timeValues = new Array(3).fill(null);
18 // tslint:disable:no-any
19 // tslint:disable:no-empty
20 this.propagateChange = (/**
21 * @param {?} _
22 * @return {?}
23 */
24 (_) => { });
25 }
26 /**
27 * @param {?} val
28 * @return {?}
29 */
30 set value(val) {
31 this.writeValue(val);
32 }
33 /**
34 * @return {?}
35 */
36 get value() {
37 return this.computeTotalTime();
38 }
39 /**
40 * @param {?} index
41 * @param {?} $event
42 * @return {?}
43 */
44 format(index, $event) {
45 /** @type {?} */
46 const inputEle = (/** @type {?} */ ($event.target));
47 /** @type {?} */
48 let value = Number.parseInt(inputEle.value, 10);
49 if (Number.isNaN(value)) {
50 value = 0;
51 }
52 if (index && value >= 60) {
53 value = (value % 100) % 60;
54 }
55 this.timeValues[index] = value;
56 this.propagateChange(this.computeTotalTime());
57 /** @type {?} */
58 const formatedVal = this.timeValues[index] < 10
59 ? '0' + this.timeValues[index]
60 : this.timeValues[index];
61 this.renderer.setProperty(inputEle, 'value', formatedVal);
62 }
63 // tslint:disable-next-line:no-any
64 /**
65 * @param {?} value
66 * @return {?}
67 */
68 writeValue(value) {
69 if (!value && value !== 0) {
70 // tslint:disable-next-line:prefer-array-literal
71 this.timeValues = new Array(3).fill(null);
72 }
73 else {
74 /** @type {?} */
75 let coerceInteger = Number.parseInt(value, 10);
76 if (Number.isNaN(coerceInteger)) {
77 coerceInteger = 0;
78 }
79 coerceInteger = Math.max(0, coerceInteger);
80 [
81 Math.floor(coerceInteger / 3600),
82 Math.floor(coerceInteger / 60) % 60,
83 coerceInteger % 60,
84 ].forEach((/**
85 * @param {?} val
86 * @param {?} i
87 * @return {?}
88 */
89 (val, i) => {
90 this.timeValues[i] = val;
91 }));
92 }
93 this.updateInputValues();
94 }
95 // tslint:disable-next-line:no-any
96 /**
97 * @param {?} fn
98 * @return {?}
99 */
100 registerOnChange(fn) {
101 this.propagateChange = fn;
102 }
103 // tslint:disable-next-line:no-empty
104 /**
105 * @return {?}
106 */
107 registerOnTouched() { }
108 /**
109 * @return {?}
110 */
111 ngAfterViewInit() {
112 this.updateInputValues();
113 }
114 /**
115 * @private
116 * @return {?}
117 */
118 computeTotalTime() {
119 return this.timeValues.reduce((/**
120 * @param {?} acum
121 * @param {?} curr
122 * @param {?} i
123 * @return {?}
124 */
125 (acum, curr, i) => {
126 if (curr) {
127 acum += ((/** @type {?} */ (curr))) * Math.pow(60, (2 - i));
128 }
129 return acum;
130 }), 0);
131 }
132 /**
133 * @private
134 * @return {?}
135 */
136 updateInputValues() {
137 if (this.viewTimeValues) {
138 this.viewTimeValues.forEach((/**
139 * @param {?} element
140 * @param {?} index
141 * @return {?}
142 */
143 (element, index) => {
144 /** @type {?} */
145 const value = this.timeValues[index];
146 /** @type {?} */
147 const formatedValue = value < 10 ? '0' + value : value;
148 this.renderer.setProperty(element.nativeElement, 'value', formatedValue);
149 }));
150 }
151 }
152}
153BMDurationInputComponent.decorators = [
154 { type: Component, args: [{
155 selector: 'bm-input-duration',
156 template: "<input #hours type=\"number\" min=\"0\" class=\"bm-input bm-duration-input__input\"\n (input)=\"format(0, $event)\" (keyup)=\"format(0, $event)\" placeholder=\"HH\" />\n<input #minutes type=\"number\" min=\"0\" max=\"59\" class=\"bm-input bm-duration-input__input\"\n (input)=\"format(1, $event)\" (keyup)=\"format(1, $event)\" placeholder=\"MM\"/>\n<input #seconds type=\"number\" min=\"0\" max=\"59\" class=\"bm-input bm-duration-input__input\"\n (input)=\"format(2, $event)\" (keyup)=\"format(2, $event)\" placeholder=\"SS\"/>",
157 changeDetection: ChangeDetectionStrategy.OnPush,
158 encapsulation: ViewEncapsulation.None,
159 providers: [
160 {
161 provide: NG_VALUE_ACCESSOR,
162 // tslint:disable-next-line:no-forward-ref
163 useExisting: forwardRef((/**
164 * @return {?}
165 */
166 () => BMDurationInputComponent)),
167 multi: true,
168 },
169 ],
170 styles: ["bm-input-duration{display:inline-flex;flex-wrap:nowrap}.bm-duration-input--inverse .bm-duration-input__input{background-color:#fff}.bm-duration-input__input{width:3em}"]
171 }] }
172];
173/** @nocollapse */
174BMDurationInputComponent.ctorParameters = () => [
175 { type: Renderer2 }
176];
177BMDurationInputComponent.propDecorators = {
178 viewTimeValues: [{ type: ViewChildren, args: ['hours, minutes, seconds', { read: ElementRef },] }],
179 value: [{ type: Input }]
180};
181
182/**
183 * @fileoverview added by tsickle
184 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
185 */
186class BMMultiselectComponent {
187 /**
188 * @param {?} changeDetectorRef
189 */
190 constructor(changeDetectorRef) {
191 this.changeDetectorRef = changeDetectorRef;
192 /**
193 * Input values to directly copy to inner input
194 */
195 this.name = '';
196 this.tabIndex = 0;
197 this.options = [];
198 this.availableOptions = [];
199 this.filteredOptions = [];
200 this.selectedOptionsList = [];
201 this.selectedOptions = new Set();
202 this.showSuggestions = false;
203 // tslint:disable-next-line:no-any no-empty
204 this.onTouched = (/**
205 * @return {?}
206 */
207 () => { });
208 // tslint:disable:no-any
209 // tslint:disable:no-empty
210 this.propagateChange = (/**
211 * @param {?} _
212 * @return {?}
213 */
214 (_) => { });
215 }
216 /**
217 * @return {?}
218 */
219 get isFocused() {
220 return this.focused;
221 }
222 /**
223 * @param {?} v
224 * @return {?}
225 */
226 set value(v) {
227 if (Array.isArray(v)) {
228 this.selectedOptions = new Set(v);
229 }
230 this.updateListAndSuggestions();
231 this.updateSelectedList();
232 }
233 /**
234 * @return {?}
235 */
236 get value() {
237 return Array.from(this.selectedOptions.values());
238 }
239 /**
240 * @param {?} option
241 * @param {?} event
242 * @return {?}
243 */
244 selectOption(option, event) {
245 /** @type {?} */
246 const target = (/** @type {?} */ (event.target));
247 if (target.nextElementSibling) {
248 ((/** @type {?} */ (target.nextElementSibling))).focus();
249 }
250 else if (target.previousElementSibling) {
251 ((/** @type {?} */ (target.previousElementSibling))).focus();
252 }
253 this.selectedOptions.add(option.key);
254 this.valueChange();
255 }
256 /**
257 * @param {?} option
258 * @return {?}
259 */
260 removeOption(option) {
261 this.selectedOptions.delete(option.key);
262 this.valueChange();
263 }
264 /**
265 * @return {?}
266 */
267 removeAll() {
268 this.selectedOptions.clear();
269 this.valueChange();
270 }
271 /**
272 * @return {?}
273 */
274 addAll() {
275 this.selectedOptions = new Set(this.options.map((/**
276 * @param {?} item
277 * @return {?}
278 */
279 item => item.key)));
280 this.valueChange();
281 this.showSuggestions = false;
282 }
283 /**
284 * @param {?} event
285 * @return {?}
286 */
287 inputKeyUp(event) {
288 switch (event.keyCode) {
289 case 40: // Down arrow
290 this.showSuggestions = true;
291 if (this.suggestionList.first &&
292 this.suggestionList.first.nativeElement) {
293 this.suggestionList.first.nativeElement.focus();
294 }
295 break;
296 case 27: // Escape
297 this.showSuggestions = false;
298 break;
299 default:
300 this.updateSuggestionList();
301 }
302 }
303 /**
304 * @param {?} event
305 * @param {?} index
306 * @param {?} value
307 * @return {?}
308 */
309 suggestionKeyUp(event, index, value) {
310 /** @type {?} */
311 const suggestionLi = this.suggestionList.toArray();
312 /** @type {?} */
313 const keyDown = (/**
314 * @return {?}
315 */
316 () => {
317 if (index === 0 &&
318 this.suggestionList.last &&
319 this.suggestionList.last.nativeElement) {
320 this.suggestionList.last.nativeElement.focus();
321 }
322 else if (suggestionLi[index - 1] &&
323 suggestionLi[index - 1].nativeElement) {
324 suggestionLi[index - 1].nativeElement.focus();
325 }
326 });
327 switch (event.keyCode) {
328 case 40: // Up arrow
329 if (index === this.filteredOptions.length - 1 &&
330 this.suggestionList.first &&
331 this.suggestionList.first.nativeElement) {
332 this.suggestionList.first.nativeElement.focus();
333 }
334 else if (suggestionLi[index + 1] &&
335 suggestionLi[index + 1].nativeElement) {
336 suggestionLi[index + 1].nativeElement.focus();
337 }
338 event.preventDefault();
339 break;
340 case 38: // Down arrow
341 keyDown();
342 event.preventDefault();
343 break;
344 case 27: // Escape
345 this.showSuggestions = false;
346 break;
347 case 13: // Enter
348 this.selectOption(value, event);
349 keyDown();
350 break;
351 default:
352 return;
353 }
354 }
355 /**
356 * @param {?} event
357 * @param {?} value
358 * @return {?}
359 */
360 selectedItemKeyup(event, value) {
361 if (event.keyCode === 46 || event.keyCode === 8) {
362 event.preventDefault();
363 this.removeOption(value);
364 }
365 }
366 /**
367 * @return {?}
368 */
369 afterOptionFocus() {
370 this.showSuggestions = false;
371 }
372 // Focus Blur Handle
373 /**
374 * @return {?}
375 */
376 inputFocus() {
377 this.focused = true;
378 this.showSuggestions = true;
379 }
380 /**
381 * @param {?} event
382 * @return {?}
383 */
384 inputFocusout(event) {
385 /** @type {?} */
386 const relatedTarget = (/** @type {?} */ (event.relatedTarget));
387 /** @type {?} */
388 const suggestions = this.suggestionList.map((/**
389 * @param {?} item
390 * @return {?}
391 */
392 item => item.nativeElement));
393 if (suggestions.indexOf(relatedTarget) === -1) {
394 this.showSuggestions = false;
395 }
396 this.focused = false;
397 this.onTouched();
398 }
399 /**
400 * @param {?} event
401 * @return {?}
402 */
403 suggestionFocusout(event) {
404 /** @type {?} */
405 const target = (/** @type {?} */ (event.target));
406 /** @type {?} */
407 const relatedTarget = (/** @type {?} */ (event.relatedTarget));
408 if (!relatedTarget ||
409 target.parentElement !== relatedTarget.parentElement) {
410 this.showSuggestions = false;
411 }
412 }
413 /**
414 * @return {?}
415 */
416 ngAfterViewInit() {
417 this.updateListAndSuggestions();
418 }
419 // tslint:disable-next-line:no-any
420 /**
421 * @param {?} value
422 * @return {?}
423 */
424 writeValue(value) {
425 this.value = value;
426 this.changeDetectorRef.markForCheck();
427 }
428 // tslint:disable-next-line:no-any
429 /**
430 * @param {?} fn
431 * @return {?}
432 */
433 registerOnChange(fn) {
434 this.propagateChange = fn;
435 }
436 // tslint:disable-next-line:no-any
437 /**
438 * @param {?} fn
439 * @return {?}
440 */
441 registerOnTouched(fn) {
442 this.onTouched = fn;
443 }
444 /**
445 * @return {?}
446 */
447 focus() {
448 if (this.input && this.input.nativeElement) {
449 this.input.nativeElement.focus();
450 }
451 }
452 /**
453 * @private
454 * @return {?}
455 */
456 updateSelectedList() {
457 this.selectedOptionsList = this.options.filter((/**
458 * @param {?} option
459 * @return {?}
460 */
461 option => this.selectedOptions.has(option.key)));
462 }
463 /**
464 * @private
465 * @return {?}
466 */
467 updateListAndSuggestions() {
468 this.availableOptions = this.options.filter((/**
469 * @param {?} option
470 * @return {?}
471 */
472 option => !this.selectedOptions.has(option.key)));
473 this.updateSuggestionList();
474 }
475 /**
476 * @private
477 * @return {?}
478 */
479 updateSuggestionList() {
480 /** @type {?} */
481 const value = ((/** @type {?} */ ((this.input.nativeElement)))).value.toLowerCase();
482 this.filteredOptions = this.availableOptions.filter((/**
483 * @param {?} item
484 * @return {?}
485 */
486 item => item.displayValue.toLowerCase().search(value) !== -1));
487 }
488 /**
489 * @private
490 * @return {?}
491 */
492 valueChange() {
493 this.propagateChange(Array.from(this.selectedOptions.values()));
494 this.updateListAndSuggestions();
495 this.updateSelectedList();
496 if (this.availableOptions.length === 0 &&
497 this.input &&
498 this.input.nativeElement) {
499 this.input.nativeElement.focus();
500 }
501 }
502}
503BMMultiselectComponent.decorators = [
504 { type: Component, args: [{
505 selector: 'bm-multiselect',
506 template: "<div class=\"bm-multiselect-input-container\">\n <input\n class=\"bm-multiselect-input bm-input\"\n #input\n autocomplete=\"off\"\n [required]=\"required\"\n [disabled]=\"disabled\"\n [name]=\"name\"\n [tabIndex]=\"tabIndex\"\n [readonly]=\"readonly\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n (keyup)=\"inputKeyUp($event)\"\n (focus)=\"inputFocus()\"\n (focusout)=\"inputFocusout($event)\"\n />\n <div\n *ngIf=\"showSuggestions\"\n tabindex=\"-1\"\n class=\"bm-multiselect-suggestions-container\"\n [@fadeInOut]=\"'in'\"\n >\n <ul>\n <li i18n tabindex=\"-1\" *ngIf=\"filteredOptions.length === 0\">\n No matches found\n </li>\n <li\n #sugg\n tabindex=\"0\"\n *ngFor=\"let option of filteredOptions; let i = index\"\n aria-selected=\"true\"\n (click)=\"selectOption(option, $event)\"\n (focusout)=\"suggestionFocusout($event)\"\n (keydown)=\"suggestionKeyUp($event, i, option)\"\n >\n {{ option.displayValue }}\n </li>\n </ul>\n </div>\n <button\n class=\"bm-multiselect-add-all\"\n i18n\n (click)=\"addAll()\"\n (focus)=\"afterOptionFocus()\"\n >\n Add all\n </button>\n</div>\n<div *ngIf=\"value.length\" class=\"bm-multiselect-selected-options\">\n <div class=\"bm-multiselect-button-container\">\n <button class=\"bm-multiselect-remove-all\" i18n (click)=\"removeAll()\">\n Remove all\n </button>\n </div>\n <ul>\n <li\n *ngFor=\"let option of selectedOptionsList\"\n tabindex=\"0\"\n aria-selected=\"false\"\n (keyup)=\"selectedItemKeyup($event, option)\"\n >\n <span>{{ option.displayValue }}</span>\n <button\n bmIconButton\n class=\"bm-multiselect-remove-item fas fa-trash\"\n arial-label=\"Remove this item\"\n (click)=\"removeOption(option)\"\n i18n-arial-label\n ></button>\n </li>\n </ul>\n</div>\n",
507 changeDetection: ChangeDetectionStrategy.OnPush,
508 encapsulation: ViewEncapsulation.None,
509 providers: [
510 {
511 provide: NG_VALUE_ACCESSOR,
512 // tslint:disable-next-line:no-forward-ref
513 useExisting: forwardRef((/**
514 * @return {?}
515 */
516 () => BMMultiselectComponent)),
517 multi: true,
518 },
519 ],
520 animations: [
521 trigger('fadeInOut', [
522 state('in', style({ opacity: 1 })),
523 transition('void => *', [
524 style({
525 opacity: 0,
526 }),
527 animate('0.2s ease-in'),
528 ]),
529 transition('* => void', [
530 animate('0.2s ease-out', style({
531 opacity: 0,
532 })),
533 ]),
534 ]),
535 ],
536 styles: ["bm-multiselect{display:inline-block}.bm-multiselect-input-container{display:block;position:relative}.bm-multiselect-input{width:100%;box-sizing:border-box}.bm-multiselect-add-all,.bm-multiselect-remove-all,.bm-multiselect-remove-item{background:0 0;color:#4399fd;border:none}.bm-multiselect-add-all{position:absolute;right:0;top:.5em}.bm-multiselect-suggestions-container{position:absolute;top:1.8em;width:100%;background:#fff;max-height:10em;box-shadow:0 0 4px 0 rgba(0,0,0,.09);overflow-x:auto;z-index:1000}.bm-multiselect-suggestions-container ul{list-style:none;padding:0;margin:0}.bm-multiselect-suggestions-container li{padding:.2em 1em;cursor:pointer}.bm-multiselect-suggestions-container li:nth-child(odd){background-color:#fff}.bm-multiselect-suggestions-container li:nth-child(even){background-color:var(--secondary-color,#bcbcbc)}.bm-multiselect-suggestions-container li:focus,.bm-multiselect-suggestions-container li:hover{background-color:var(--secondary-color-hover,#959494)}.bm-multiselect-selected-options{text-align:left}.bm-multiselect-selected-options .bm-multiselect-button-container{text-align:right;padding:1em 0}.bm-multiselect-selected-options .bm-multiselect-remove-item{display:none}.bm-multiselect-selected-options ul{margin:0;padding:0;max-height:15em;overflow-x:auto;list-style-type:none}.bm-multiselect-selected-options li{padding:.5em;display:flex}.bm-multiselect-selected-options li:nth-child(odd){background-color:#f5f7f8}.bm-multiselect-selected-options li:focus{background-color:var(--secondary-color-hover,#959494)}.bm-multiselect-selected-options li:hover .bm-multiselect-remove-item{display:block;margin-right:0;margin-left:auto}"]
537 }] }
538];
539/** @nocollapse */
540BMMultiselectComponent.ctorParameters = () => [
541 { type: ChangeDetectorRef }
542];
543BMMultiselectComponent.propDecorators = {
544 input: [{ type: ViewChild, args: ['input', { static: true },] }],
545 suggestionList: [{ type: ViewChildren, args: ['sugg',] }],
546 isFocused: [{ type: HostBinding, args: ['class.bm-multiselect-focused',] }],
547 name: [{ type: Input }],
548 tabIndex: [{ type: Input }],
549 required: [{ type: Input }],
550 disabled: [{ type: Input }],
551 readonly: [{ type: Input }],
552 ariaLabel: [{ type: Input, args: ['aria-label',] }],
553 ariaLabelledby: [{ type: Input, args: ['aria-labelledby',] }],
554 value: [{ type: Input }],
555 options: [{ type: Input }]
556};
557
558/**
559 * @fileoverview added by tsickle
560 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
561 */
562class BMInputSearchComponent {
563 /**
564 * @param {?} _renderer
565 */
566 constructor(_renderer) {
567 this._renderer = _renderer;
568 /**
569 * Input values to directly copy to inner checkbox
570 */
571 this.name = '';
572 this.placeholder = '';
573 this.tabIndex = 0;
574 // tslint:disable-next-line:no-reserved-keywords
575 this.type = 'text';
576 /**
577 * Suggestions specifics
578 */
579 this.showSuggestions = false;
580 this.minSuggestionChars = 2;
581 this.search = new EventEmitter();
582 // tslint:disable-next-line:no-any no-empty
583 this.onTouched = (/**
584 * @return {?}
585 */
586 () => { });
587 // tslint:disable:no-any
588 // tslint:disable:no-empty
589 this.propagateChange = (/**
590 * @param {?} _
591 * @return {?}
592 */
593 (_) => { });
594 }
595 /**
596 * @param {?} v
597 * @return {?}
598 */
599 set value(v) {
600 if (v) {
601 this._renderer.setProperty(this.input.nativeElement, 'value', v);
602 }
603 }
604 /**
605 * @return {?}
606 */
607 get value() {
608 return this.input.nativeElement.value;
609 }
610 /**
611 * @param {?} event
612 * @return {?}
613 */
614 inputKeyUp(event) {
615 switch (event.keyCode) {
616 case 40: // Down arrow
617 if (this.suggestionList.first) {
618 this.suggestionList.first.nativeElement.focus();
619 }
620 break;
621 case 27: // Escape
622 this.closeSuggestions();
623 break;
624 default:
625 /** @type {?} */
626 const value = ((/** @type {?} */ (event.target))).value.toLowerCase();
627 if (value.length >= this.minSuggestionChars &&
628 Array.isArray(this.suggestions)) {
629 this.showSuggestions = true;
630 this.filteredSuggestions = this.suggestions
631 .map((/**
632 * @param {?} item
633 * @return {?}
634 */
635 item => item.toString().toLowerCase()))
636 .filter((/**
637 * @param {?} item
638 * @return {?}
639 */
640 item => item.search(value) !== -1));
641 }
642 else {
643 this.showSuggestions = false;
644 }
645 return;
646 }
647 }
648 // tslint:disable-next-line:no-any
649 /**
650 * @param {?} event
651 * @param {?} index
652 * @param {?} value
653 * @return {?}
654 */
655 suggestionKeyUp(event, index, value) {
656 /** @type {?} */
657 const suggestionLi = this.suggestionList.toArray();
658 switch (event.keyCode) {
659 case 40: // Up arrow
660 if (index === this.suggestions.length - 1) {
661 this.suggestionList.first.nativeElement.focus();
662 }
663 else {
664 suggestionLi[index + 1].nativeElement.focus();
665 }
666 event.preventDefault();
667 break;
668 case 38: // Down arrow
669 if (index === 0) {
670 this.suggestionList.last.nativeElement.focus();
671 }
672 else {
673 suggestionLi[index - 1].nativeElement.focus();
674 }
675 event.preventDefault();
676 break;
677 case 27: // Escape
678 this.closeSuggestions();
679 break;
680 case 13: // Enter
681 this.setInput(value);
682 break;
683 default:
684 return;
685 }
686 }
687 // tslint:disable-next-line:no-any
688 /**
689 * @param {?} v
690 * @return {?}
691 */
692 setInput(v) {
693 this.value = v;
694 this.propagateChange(this.value);
695 this.closeSuggestions();
696 }
697 /**
698 * Custom Input functions
699 * @return {?}
700 */
701 inputBlur() {
702 this.onTouched();
703 }
704 // tslint:disable-next-line:no-any
705 /**
706 * @param {?} value
707 * @return {?}
708 */
709 writeValue(value) {
710 this._renderer.setProperty(this.input.nativeElement, 'value', value);
711 }
712 // tslint:disable-next-line:no-any
713 /**
714 * @param {?} fn
715 * @return {?}
716 */
717 registerOnChange(fn) {
718 this.propagateChange = fn;
719 }
720 // tslint:disable-next-line:no-any
721 /**
722 * @param {?} fn
723 * @return {?}
724 */
725 registerOnTouched(fn) {
726 this.onTouched = fn;
727 }
728 /**
729 * @param {?} event
730 * @return {?}
731 */
732 inputChange(event) {
733 const { value } = (/** @type {?} */ (event.target));
734 this.propagateChange(value);
735 }
736 /**
737 * @return {?}
738 */
739 focus() {
740 this.input.nativeElement.focus();
741 }
742 /**
743 * @private
744 * @return {?}
745 */
746 closeSuggestions() {
747 this.input.nativeElement.focus();
748 this.showSuggestions = false;
749 }
750}
751BMInputSearchComponent.decorators = [
752 { type: Component, args: [{
753 selector: 'bm-input-search',
754 template: "<div class=\"bm-input bm-input-search__input-container\">\n <input\n #input\n class=\"bm-input bm-input-search__input\"\n autocomplete=\"off\"\n [type]=\"type\"\n [required]=\"required\"\n [disabled]=\"disabled\"\n [name]=\"name\"\n [tabIndex]=\"tabIndex\"\n [readonly]=\"readonly\"\n [placeholder]=\"placeholder\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n (keyup)=\"inputKeyUp($event)\"\n (change)=\"inputChange($event)\"\n (blur)=\"inputBlur()\"\n />\n <button\n class=\"bm-button bm-button--primary bm-input-search__search-button\"\n (click)=\"search.emit(input.value)\"\n >\n <i class=\"fas fa-search\" aria-hidden=\"true\"></i>\n </button>\n</div>\n\n<div class=\"bm-input-search__suggestions-container\" *ngIf=\"showSuggestions\">\n <ul class=\"bm-input-search__suggestions-list\">\n <li\n i18n\n tabindex=\"-1\"\n *ngIf=\"filteredSuggestions?.length === 0\"\n class=\"bm-input-search__suggestions-list-item\"\n >\n No matches found\n </li>\n <li\n #sugg\n tabindex=\"0\"\n *ngFor=\"let suggestion of filteredSuggestions; let i = index\"\n class=\"bm-input-search__suggestions-list-item\"\n (click)=\"setInput(suggestion)\"\n (keydown)=\"suggestionKeyUp($event, i, suggestion)\"\n >\n {{ suggestion }}\n </li>\n </ul>\n</div>\n",
755 providers: [
756 {
757 provide: NG_VALUE_ACCESSOR,
758 // tslint:disable-next-line:no-forward-ref
759 useExisting: forwardRef((/**
760 * @return {?}
761 */
762 () => BMInputSearchComponent)),
763 multi: true,
764 },
765 ],
766 changeDetection: ChangeDetectionStrategy.OnPush,
767 encapsulation: ViewEncapsulation.None,
768 styles: ["bm-input-search{display:inline-block;position:relative}.bm-input-search__input{padding:.3rem 3rem .3rem 1rem!important;width:100%;box-sizing:border-box}.bm-input-search__input-container{position:relative;width:100%;height:100%}.bm-input-search__search-button{display:block;position:absolute;right:0;top:1px;bottom:1px;border-top-left-radius:0;border-bottom-left-radius:0;padding:0 .75em;font-weight:400}.bm-input-search--inverse .bm-input-search__input{background-color:#fff}.bm-input-search__suggestions-container{position:absolute;top:2.4em;width:100%;max-height:10em;box-shadow:0 0 4px 0 rgba(0,0,0,.09);overflow-x:auto}.bm-input-search__suggestions-list{list-style:none;padding:0;margin:0}.bm-input-search__suggestions-list-item{padding:.2em 1em;cursor:pointer}.bm-input-search__suggestions-list-item:nth-child(odd){background-color:#fff}.bm-input-search__suggestions-list-item:nth-child(even){background-color:var(--secondary-color,#bcbcbc)}.bm-input-search__suggestions-list-item:focus,.bm-input-search__suggestions-list-item:hover{background-color:var(--secondary-color-hover,#959494)}"]
769 }] }
770];
771/** @nocollapse */
772BMInputSearchComponent.ctorParameters = () => [
773 { type: Renderer2 }
774];
775BMInputSearchComponent.propDecorators = {
776 input: [{ type: ViewChild, args: ['input', { static: true },] }],
777 suggestionList: [{ type: ViewChildren, args: ['sugg',] }],
778 name: [{ type: Input }],
779 placeholder: [{ type: Input }],
780 tabIndex: [{ type: Input }],
781 required: [{ type: Input }],
782 disabled: [{ type: Input }],
783 readonly: [{ type: Input }],
784 type: [{ type: Input }],
785 ariaLabel: [{ type: Input, args: ['aria-label',] }],
786 ariaLabelledby: [{ type: Input, args: ['aria-labelledby',] }],
787 value: [{ type: Input }],
788 minSuggestionChars: [{ type: Input }],
789 suggestions: [{ type: Input }],
790 search: [{ type: Output }]
791};
792
793/**
794 * @fileoverview added by tsickle
795 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
796 */
797class BMOptionDirective {
798}
799BMOptionDirective.decorators = [
800 { type: Directive, args: [{
801 selector: '[bmOption]',
802 },] }
803];
804class BMSelectComponent {
805 /**
806 * @param {?} _renderer
807 */
808 constructor(_renderer) {
809 this._renderer = _renderer;
810 /**
811 * Input values to directly copy to inner checkbox
812 */
813 this.name = '';
814 this.tabIndex = 0;
815 // tslint:disable-next-line:no-reserved-keywords
816 this.type = 'text';
817 // tslint:disable-next-line:no-any no-empty
818 this.onTouched = (/**
819 * @return {?}
820 */
821 () => { });
822 // tslint:disable:no-any
823 // tslint:disable:no-empty
824 this.propagateChange = (/**
825 * @param {?} _
826 * @return {?}
827 */
828 (_) => { });
829 }
830 /**
831 * @param {?} v
832 * @return {?}
833 */
834 set value(v) {
835 this._valueCopy = v;
836 this.setCheckedOption();
837 }
838 /**
839 * @return {?}
840 */
841 get value() {
842 return this._valueCopy;
843 }
844 /**
845 * Custom Input functions
846 * @return {?}
847 */
848 inputBlur() {
849 this.onTouched();
850 }
851 // tslint:disable-next-line:no-any
852 /**
853 * @param {?} value
854 * @return {?}
855 */
856 writeValue(value) {
857 this._valueCopy = value;
858 this.setCheckedOption();
859 }
860 // tslint:disable-next-line:no-any
861 /**
862 * @param {?} fn
863 * @return {?}
864 */
865 registerOnChange(fn) {
866 this.propagateChange = fn;
867 }
868 // tslint:disable-next-line:no-any
869 /**
870 * @param {?} fn
871 * @return {?}
872 */
873 registerOnTouched(fn) {
874 this.onTouched = fn;
875 }
876 /**
877 * @param {?} event
878 * @return {?}
879 */
880 inputChange(event) {
881 const { value } = (/** @type {?} */ (event.target));
882 this._valueCopy = value;
883 this.propagateChange(value);
884 }
885 /**
886 * @return {?}
887 */
888 focus() {
889 ((/** @type {?} */ (this.select.nativeElement))).focus();
890 }
891 /**
892 * @return {?}
893 */
894 ngAfterContentInit() {
895 this._optionsSubs = this.options.changes.subscribe((/**
896 * @return {?}
897 */
898 () => this.setCheckedOption()));
899 this.setCheckedOption();
900 }
901 /**
902 * @return {?}
903 */
904 ngOnDestroy() {
905 if (this._optionsSubs) {
906 this._optionsSubs.unsubscribe();
907 }
908 }
909 /**
910 * @private
911 * @return {?}
912 */
913 setCheckedOption() {
914 if (this._valueCopy !== undefined) {
915 this._renderer.setValue(this.select.nativeElement, this._valueCopy);
916 }
917 if (!this.options) {
918 return;
919 }
920 this.options.forEach((/**
921 * @param {?} elem
922 * @return {?}
923 */
924 elem => {
925 /** @type {?} */
926 const domEle = elem.nativeElement;
927 if (domEle) {
928 domEle.selected = domEle.value === this._valueCopy;
929 }
930 }));
931 }
932}
933BMSelectComponent.decorators = [
934 { type: Component, args: [{
935 selector: 'bm-select',
936 template: "<select #select\n class=\"bm-select__select\"\n [required]=\"required\"\n [disabled]=\"disabled\"\n [name]=\"name\"\n [tabIndex]=\"tabIndex\"\n [attr.aria-label]=\"ariaLabel\"\n [attr.aria-labelledby]=\"ariaLabelledby\"\n (change)=\"inputChange($event)\"\n (blur)=\"inputBlur()\">\n <ng-content></ng-content>\n</select>\n",
937 providers: [
938 {
939 provide: NG_VALUE_ACCESSOR,
940 // tslint:disable-next-line:no-forward-ref
941 useExisting: forwardRef((/**
942 * @return {?}
943 */
944 () => BMSelectComponent)),
945 multi: true,
946 },
947 ],
948 changeDetection: ChangeDetectionStrategy.OnPush,
949 encapsulation: ViewEncapsulation.None,
950 styles: [".bm-select__select{-moz-appearance:none;-ms-word-break:normal;-webkit-appearance:none;appearance:none;background:var(--header-color,#f8f8f8);border-radius:.333em;border:none;box-shadow:0 1px 1px 0 rgba(0,0,0,.2);font-family:proxima-regular;font-size:.815rem;font-weight:400;line-height:1.45rem;padding:.3em 2em .3em .6em;width:100%;word-break:normal}bm-select{min-width:200;display:inline-block;position:relative}bm-select--inverse .bm-select__select{background:#fff;box-shadow:inset 0 1px 1px 0 rgba(0,0,0,.2)}bm-select::after{content:'\\f0d7';font-weight:900;font-family:\"Font Awesome 5 Free\";pointer-events:none;position:absolute;right:8px;top:6px}"]
951 }] }
952];
953/** @nocollapse */
954BMSelectComponent.ctorParameters = () => [
955 { type: Renderer2 }
956];
957BMSelectComponent.propDecorators = {
958 select: [{ type: ViewChild, args: ['select', { static: true },] }],
959 options: [{ type: ContentChildren, args: [BMOptionDirective, { read: ElementRef },] }],
960 name: [{ type: Input }],
961 tabIndex: [{ type: Input }],
962 required: [{ type: Input }],
963 disabled: [{ type: Input }],
964 readonly: [{ type: Input }],
965 type: [{ type: Input }],
966 ariaLabel: [{ type: Input, args: ['aria-label',] }],
967 ariaLabelledby: [{ type: Input, args: ['aria-labelledby',] }],
968 value: [{ type: Input }]
969};
970
971/**
972 * @fileoverview added by tsickle
973 * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
974 */
975class BMATFormsModule {
976}
977BMATFormsModule.decorators = [
978 { type: NgModule, args: [{
979 imports: [CommonModule],
980 declarations: [
981 BMDurationInputComponent,
982 BMInputSearchComponent,
983 BMMultiselectComponent,
984 BMOptionDirective,
985 BMSelectComponent,
986 ],
987 exports: [
988 BMDurationInputComponent,
989 BMInputSearchComponent,
990 BMMultiselectComponent,
991 BMOptionDirective,
992 BMSelectComponent,
993 ],
994 providers: [],
995 },] }
996];
997
998export { BMATFormsModule, BMDurationInputComponent, BMInputSearchComponent, BMMultiselectComponent, BMOptionDirective, BMSelectComponent };
999//# sourceMappingURL=bmat-angular-forms.js.map