blob: e735eb541418bb47d4986ab869aa980452b74161 [file] [log] [blame]
import { Component, Input, Output, forwardRef, ViewChild, ViewChildren, HostListener, ElementRef, Optional, Inject, Directive, TemplateRef, ViewContainerRef, ContentChild, ChangeDetectionStrategy, ChangeDetectorRef, HostBinding, Renderer2, EventEmitter, NgModule } from '@angular/core';
import { DOCUMENT } from '@angular/platform-browser';
import { NG_VALUE_ACCESSOR, FormControl, ReactiveFormsModule } from '@angular/forms';
import { TemplatePortalDirective } from '@angular/cdk/portal';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
import { UP_ARROW, DOWN_ARROW, ESCAPE, LEFT_ARROW, RIGHT_ARROW, DELETE, BACKSPACE, TAB } from '@angular/cdk/keycodes';
import { MatChip, MatChipsModule } from '@angular/material/chips';
import { MatInput, MatInputModule } from '@angular/material/input';
import { MatOption } from '@angular/material/core';
import { MatAutocompleteTrigger, MatAutocompleteModule } from '@angular/material/autocomplete';
import { timer } from 'rxjs/observable/timer';
import { merge } from 'rxjs/observable/merge';
import { toPromise } from 'rxjs/operator/toPromise';
import { fromEvent } from 'rxjs/observable/fromEvent';
import { filter } from 'rxjs/operators/filter';
import { debounceTime } from 'rxjs/operators/debounceTime';
import { mixinDisabled, mixinControlValueAccessor } from '@covalent/core/common';
import { CommonModule } from '@angular/common';
import { MatIconModule } from '@angular/material/icon';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class TdChipDirective extends TemplatePortalDirective {
/**
* @param {?} templateRef
* @param {?} viewContainerRef
*/
constructor(templateRef, viewContainerRef) {
super(templateRef, viewContainerRef);
}
}
TdChipDirective.decorators = [
{ type: Directive, args: [{
selector: '[td-chip]ng-template',
},] },
];
/** @nocollapse */
TdChipDirective.ctorParameters = () => [
{ type: TemplateRef, },
{ type: ViewContainerRef, },
];
class TdAutocompleteOptionDirective extends TemplatePortalDirective {
/**
* @param {?} templateRef
* @param {?} viewContainerRef
*/
constructor(templateRef, viewContainerRef) {
super(templateRef, viewContainerRef);
}
}
TdAutocompleteOptionDirective.decorators = [
{ type: Directive, args: [{
selector: '[td-autocomplete-option]ng-template',
},] },
];
/** @nocollapse */
TdAutocompleteOptionDirective.ctorParameters = () => [
{ type: TemplateRef, },
{ type: ViewContainerRef, },
];
class TdChipsBase {
/**
* @param {?} _changeDetectorRef
*/
constructor(_changeDetectorRef) {
this._changeDetectorRef = _changeDetectorRef;
}
}
/* tslint:disable-next-line */
const _TdChipsMixinBase = mixinControlValueAccessor(mixinDisabled(TdChipsBase), []);
class TdChipsComponent extends _TdChipsMixinBase {
/**
* @param {?} _elementRef
* @param {?} _renderer
* @param {?} _document
* @param {?} _changeDetectorRef
*/
constructor(_elementRef, _renderer, _document, _changeDetectorRef) {
super(_changeDetectorRef);
this._elementRef = _elementRef;
this._renderer = _renderer;
this._document = _document;
this._isMousedown = false;
this._length = 0;
this._stacked = false;
this._requireMatch = false;
this._color = 'primary';
this._inputPosition = 'after';
this._chipAddition = true;
this._chipRemoval = true;
this._focused = false;
this._tabIndex = 0;
this._internalClick = false;
this._internalActivateOption = false;
/**
* FormControl for the matInput element.
*/
this.inputControl = new FormControl();
/**
* debounce?: number
* Debounce timeout between keypresses. Defaults to 200.
*/
this.debounce = 200;
/**
* add?: function
* Method to be executed when a chip is added.
* Sends chip value as event.
*/
this.onAdd = new EventEmitter();
/**
* remove?: function
* Method to be executed when a chip is removed.
* Sends chip value as event.
*/
this.onRemove = new EventEmitter();
/**
* inputChange?: function
* Method to be executed when the value in the autocomplete input changes.
* Sends string value as event.
*/
this.onInputChange = new EventEmitter();
/**
* chipFocus?: function
* Method to be executed when a chip is focused.
* Sends chip value as event.
*/
this.onChipFocus = new EventEmitter();
/**
* blur?: function
* Method to be executed when a chip is blurred.
* Sends chip value as event.
*/
this.onChipBlur = new EventEmitter();
this._renderer.addClass(this._elementRef.nativeElement, 'mat-' + this._color);
}
/**
* Flag that is true when autocomplete is focused.
* @return {?}
*/
get focused() {
return this._focused;
}
/**
* items?: any[]
* Renders the `mat-autocomplete` with the provided list to display as options.
* @param {?} items
* @return {?}
*/
set items(items) {
this._items = items;
this._setFirstOptionActive();
this._changeDetectorRef.markForCheck();
}
/**
* @return {?}
*/
get items() {
return this._items;
}
/**
* stacked?: boolean
* Set stacked or horizontal chips depending on value.
* Defaults to false.
* @param {?} stacked
* @return {?}
*/
set stacked(stacked) {
this._stacked = coerceBooleanProperty(stacked);
}
/**
* @return {?}
*/
get stacked() {
return this._stacked;
}
/**
* inputPosition?: 'before' | 'after'
* Set input position before or after the chips.
* Defaults to 'after'.
* @param {?} inputPosition
* @return {?}
*/
set inputPosition(inputPosition) {
this._inputPosition = inputPosition;
}
/**
* @return {?}
*/
get inputPosition() {
return this._inputPosition;
}
/**
* requireMatch?: boolean
* Blocks custom inputs and only allows selections from the autocomplete list.
* @param {?} requireMatch
* @return {?}
*/
set requireMatch(requireMatch) {
this._requireMatch = coerceBooleanProperty(requireMatch);
}
/**
* @return {?}
*/
get requireMatch() {
return this._requireMatch;
}
/**
* chipAddition?: boolean
* Disables the ability to add chips. When setting disabled as true, this will be overriden.
* Defaults to true.
* @param {?} chipAddition
* @return {?}
*/
set chipAddition(chipAddition) {
this._chipAddition = chipAddition;
this._toggleInput();
}
/**
* @return {?}
*/
get chipAddition() {
return this._chipAddition;
}
/**
* Checks if not in disabled state and if chipAddition is set to 'true'
* States if a chip can be added and if the input is available
* @return {?}
*/
get canAddChip() {
return this.chipAddition && !this.disabled;
}
/**
* chipRemoval?: boolean
* Disables the ability to remove chips. If it doesn't exist chip remmoval defaults to true.
* When setting disabled as true, this will be overriden to false.
* @param {?} chipRemoval
* @return {?}
*/
set chipRemoval(chipRemoval) {
this._chipRemoval = chipRemoval;
}
/**
* @return {?}
*/
get chipRemoval() {
return this._chipRemoval;
}
/**
* Checks if not in disabled state and if chipRemoval is set to 'true'
* States if a chip can be removed
* @return {?}
*/
get canRemoveChip() {
return this.chipRemoval && !this.disabled;
}
/**
* color?: 'primary' | 'accent' | 'warn'
* Sets the color for the input and focus/selected state of the chips.
* Defaults to 'primary'
* @param {?} color
* @return {?}
*/
set color(color) {
if (color) {
this._renderer.removeClass(this._elementRef.nativeElement, 'mat-' + this._color);
this._color = color;
this._renderer.addClass(this._elementRef.nativeElement, 'mat-' + this._color);
}
}
/**
* @return {?}
*/
get color() {
return this._color;
}
/**
* Hostbinding to set the a11y of the TdChipsComponent depending on its state
* @return {?}
*/
get tabIndex() {
return this.disabled ? -1 : this._tabIndex;
}
/**
* Listens to host focus event to act on it
* @param {?} event
* @return {?}
*/
focusListener(event) {
// should only focus if its not via mousedown to prevent clashing with autocomplete
if (!this._isMousedown) {
this.focus();
}
event.preventDefault();
}
/**
* Listens to host mousedown event to act on it
* @param {?} event
* @return {?}
*/
mousedownListener(event) {
// sets a flag to know if there was a mousedown and then it returns it back to false
this._isMousedown = true;
toPromise.call(timer()).then(() => {
this._isMousedown = false;
});
}
/**
* If clicking on :host or `td-chips-wrapper`, then we stop the click propagation so the autocomplete
* doesnt close automatically.
* @param {?} event
* @return {?}
*/
clickListener(event) {
const /** @type {?} */ clickTarget = /** @type {?} */ (event.target);
if (clickTarget === this._elementRef.nativeElement ||
clickTarget.className.indexOf('td-chips-wrapper') > -1) {
this.focus();
event.preventDefault();
event.stopPropagation();
}
}
/**
* Listens to host keydown event to act on it depending on the keypress
* @param {?} event
* @return {?}
*/
keydownListener(event) {
switch (event.keyCode) {
case TAB:
// if tabing out, then unfocus the component
toPromise.call(timer()).then(() => {
this.removeFocusedState();
});
break;
case ESCAPE:
if (this._inputChild.focused) {
this._nativeInput.nativeElement.blur();
this.removeFocusedState();
this._closeAutocomplete();
}
else {
this.focus();
}
break;
default:
}
}
/**
* @return {?}
*/
ngOnInit() {
this.inputControl.valueChanges.pipe(debounceTime(this.debounce)).subscribe((value) => {
this.onInputChange.emit(value ? value : '');
});
this._changeDetectorRef.markForCheck();
}
/**
* @return {?}
*/
ngAfterViewInit() {
this._watchOutsideClick();
this._changeDetectorRef.markForCheck();
}
/**
* @return {?}
*/
ngDoCheck() {
// Throw onChange event only if array changes size.
if (this.value && this.value.length !== this._length) {
this._length = this.value.length;
this.onChange(this.value);
}
}
/**
* @return {?}
*/
ngOnDestroy() {
if (this._outsideClickSubs) {
this._outsideClickSubs.unsubscribe();
this._outsideClickSubs = undefined;
}
}
/**
* @return {?}
*/
_setInternalClick() {
this._internalClick = true;
}
/**
* Method executed when the disabled value changes
* @param {?} v
* @return {?}
*/
onDisabledChange(v) {
this._toggleInput();
}
/**
* Method that is executed when trying to create a new chip from the autocomplete.
* It check if [requireMatch] is enabled, and tries to add the first active option
* else if just adds the value thats on the input
* returns 'true' if successful, 'false' if it fails.
* @return {?}
*/
_handleAddChip() {
let /** @type {?} */ value;
if (this.requireMatch) {
let /** @type {?} */ selectedOptions = this._options.toArray().filter((option) => {
return option.active;
});
if (selectedOptions.length > 0) {
value = selectedOptions[0].value;
selectedOptions[0].setInactiveStyles();
}
if (!value) {
return false;
}
}
else {
// if there is a selection, then use that
// else use the input value as chip
if (this._autocompleteTrigger.activeOption) {
value = this._autocompleteTrigger.activeOption.value;
this._autocompleteTrigger.activeOption.setInactiveStyles();
}
else {
value = this._inputChild.value;
if (value.trim() === '') {
return false;
}
}
}
return this.addChip(value);
}
/**
* Method thats exectuted when trying to add a value as chip
* returns 'true' if successful, 'false' if it fails.
* @param {?} value
* @return {?}
*/
addChip(value) {
/**
* add a debounce ms delay when reopening the autocomplete to give it time
* to rerender the next list and at the correct spot
*/
this._closeAutocomplete();
toPromise.call(timer(this.debounce)).then(() => {
this.setFocusedState();
this._setFirstOptionActive();
this._openAutocomplete();
});
this.inputControl.setValue('');
// check if value is already part of the model
if (this.value.indexOf(value) > -1) {
return false;
}
this.value.push(value);
this.onAdd.emit(value);
this.onChange(this.value);
this._changeDetectorRef.markForCheck();
return true;
}
/**
* Method that is executed when trying to remove a chip.
* returns 'true' if successful, 'false' if it fails.
* @param {?} index
* @return {?}
*/
removeChip(index) {
let /** @type {?} */ removedValues = this.value.splice(index, 1);
if (removedValues.length === 0) {
return false;
}
/**
* Checks if deleting last single chip, to focus input afterwards
* Else check if its not the last chip of the list to focus the next one.
*/
if (index === (this._totalChips - 1) && index === 0) {
this._inputChild.focus();
}
else if (index < (this._totalChips - 1)) {
this._focusChip(index + 1);
}
else if (index > 0) {
this._focusChip(index - 1);
}
this.onRemove.emit(removedValues[0]);
this.onChange(this.value);
this.inputControl.setValue('');
this._changeDetectorRef.markForCheck();
return true;
}
/**
* Sets blur of chip and sends out event
* @param {?} event
* @param {?} value
* @return {?}
*/
_handleChipBlur(event, value) {
this.onChipBlur.emit(value);
}
/**
* Sets focus of chip and sends out event
* @param {?} event
* @param {?} value
* @return {?}
*/
_handleChipFocus(event, value) {
this.setFocusedState();
this.onChipFocus.emit(value);
}
/**
* @return {?}
*/
_handleFocus() {
this.setFocusedState();
this._setFirstOptionActive();
return true;
}
/**
* Sets focus state of the component
* @return {?}
*/
setFocusedState() {
if (!this.disabled) {
this._focused = true;
this._tabIndex = -1;
this._changeDetectorRef.markForCheck();
}
}
/**
* Removes focus state of the component
* @return {?}
*/
removeFocusedState() {
this._focused = false;
this._tabIndex = 0;
this._changeDetectorRef.markForCheck();
}
/**
* Programmatically focus the input or first chip. Since its the component entry point
* depending if a user can add or remove chips
* @return {?}
*/
focus() {
if (this.canAddChip) {
this._inputChild.focus();
}
else if (!this.disabled) {
this._focusFirstChip();
}
}
/**
* Passes relevant input key presses.
* @param {?} event
* @return {?}
*/
_inputKeydown(event) {
switch (event.keyCode) {
case UP_ARROW:
/**
* Since the first item is highlighted on [requireMatch], we need to inactivate it
* when pressing the up key
*/
if (this.requireMatch) {
let /** @type {?} */ length = this._options.length;
if (length > 1 && this._options.toArray()[0].active && this._internalActivateOption) {
this._options.toArray()[0].setInactiveStyles();
this._internalActivateOption = false;
// prevent default window scrolling
event.preventDefault();
}
}
break;
case LEFT_ARROW:
case DELETE:
case BACKSPACE:
this._closeAutocomplete();
/** Check to see if input is empty when pressing left arrow to move to the last chip */
if (!this._inputChild.value) {
this._focusLastChip();
// prevent default window scrolling
event.preventDefault();
}
break;
case RIGHT_ARROW:
this._closeAutocomplete();
/** Check to see if input is empty when pressing right arrow to move to the first chip */
if (!this._inputChild.value) {
this._focusFirstChip();
// prevent default window scrolling
event.preventDefault();
}
break;
default:
}
}
/**
* Passes relevant chip key presses.
* @param {?} event
* @param {?} index
* @return {?}
*/
_chipKeydown(event, index) {
switch (event.keyCode) {
case DELETE:
case BACKSPACE:
/** Check to see if we can delete a chip */
if (this.canRemoveChip) {
this.removeChip(index);
}
break;
case UP_ARROW:
case LEFT_ARROW:
/**
* Check to see if left/down arrow was pressed while focusing the first chip to focus input next
* Also check if input should be focused
*/
if (index === 0) {
// only try to target input if pressing left
if (this.canAddChip && event.keyCode === LEFT_ARROW) {
this._inputChild.focus();
}
else {
this._focusLastChip();
}
}
else if (index > 0) {
this._focusChip(index - 1);
}
// prevent default window scrolling
event.preventDefault();
break;
case DOWN_ARROW:
case RIGHT_ARROW:
/**
* Check to see if right/up arrow was pressed while focusing the last chip to focus input next
* Also check if input should be focused
*/
if (index === (this._totalChips - 1)) {
// only try to target input if pressing right
if (this.canAddChip && event.keyCode === RIGHT_ARROW) {
this._inputChild.focus();
}
else {
this._focusFirstChip();
}
}
else if (index < (this._totalChips - 1)) {
this._focusChip(index + 1);
}
// prevent default window scrolling
event.preventDefault();
break;
default:
}
}
/**
* Method to remove from display the value added from the autocomplete since it goes directly as chip.
* @return {?}
*/
_removeInputDisplay() {
return '';
}
/**
* Method to open the autocomplete manually if its not already opened
* @return {?}
*/
_openAutocomplete() {
if (!this._autocompleteTrigger.panelOpen) {
this._autocompleteTrigger.openPanel();
this._changeDetectorRef.markForCheck();
}
}
/**
* Method to close the autocomplete manually if its not already closed
* @return {?}
*/
_closeAutocomplete() {
if (this._autocompleteTrigger.panelOpen) {
this._autocompleteTrigger.closePanel();
this._changeDetectorRef.markForCheck();
}
}
/**
* Get total of chips
* @return {?}
*/
get _totalChips() {
let /** @type {?} */ chips = this._chipsChildren.toArray();
return chips.length;
}
/**
* Method to focus a desired chip by index
* @param {?} index
* @return {?}
*/
_focusChip(index) {
/** check to see if index exists in the array before focusing */
if (index > -1 && this._totalChips > index) {
this._chipsChildren.toArray()[index].focus();
}
}
/**
* Method to focus first chip
* @return {?}
*/
_focusFirstChip() {
this._focusChip(0);
}
/**
* Method to focus last chip
* @return {?}
*/
_focusLastChip() {
this._focusChip(this._totalChips - 1);
}
/**
* Method to toggle the disable state of input
* Checks if not in disabled state and if chipAddition is set to 'true'
* @return {?}
*/
_toggleInput() {
if (this.canAddChip) {
this.inputControl.enable();
}
else {
this.inputControl.disable();
}
this._changeDetectorRef.markForCheck();
}
/**
* Sets first option as active to let the user know which one will be added when pressing enter
* Only if [requireMatch] has been set
* @return {?}
*/
_setFirstOptionActive() {
if (this.requireMatch) {
// need to use a timer here to wait until the autocomplete has been opened (end of queue)
toPromise.call(timer()).then(() => {
if (this.focused && this._options && this._options.length > 0) {
// clean up of previously active options
this._options.toArray().forEach((option) => {
option.setInactiveStyles();
});
// set the first one as active
this._options.toArray()[0].setActiveStyles();
this._internalActivateOption = true;
this._changeDetectorRef.markForCheck();
}
});
}
}
/**
* Watches clicks outside of the component to remove the focus
* The autocomplete panel is considered inside the component so we
* need to use a flag to find out when its clicked.
* @return {?}
*/
_watchOutsideClick() {
if (this._document) {
merge(fromEvent(this._document, 'click'), fromEvent(this._document, 'touchend')).pipe(filter((event) => {
const /** @type {?} */ clickTarget = /** @type {?} */ (event.target);
setTimeout(() => {
this._internalClick = false;
});
return this.focused &&
(clickTarget !== this._elementRef.nativeElement) &&
!this._elementRef.nativeElement.contains(clickTarget) && !this._internalClick;
})).subscribe(() => {
if (this.focused) {
this._autocompleteTrigger.closePanel();
this.removeFocusedState();
this.onTouched();
this._changeDetectorRef.markForCheck();
}
});
}
return undefined;
}
}
TdChipsComponent.decorators = [
{ type: Component, args: [{
providers: [{
provide: NG_VALUE_ACCESSOR,
useExisting: forwardRef(() => TdChipsComponent),
multi: true,
}],
selector: 'td-chips',
inputs: ['disabled', 'value'],
styles: [`:host{
display:block;
padding:0 5px;
min-height:48px; }
:host .td-chips-wrapper{
min-height:42px;
display:-webkit-box;
display:-ms-flexbox;
display:flex;
-webkit-box-orient:horizontal;
-webkit-box-direction:normal;
-ms-flex-direction:row;
flex-direction:row;
-ms-flex-wrap:wrap;
flex-wrap:wrap;
-webkit-box-align:start;
-ms-flex-align:start;
align-items:flex-start; }
:host .td-chips-wrapper.td-chips-stacked .mat-basic-chip,
:host .td-chips-wrapper.td-chips-stacked .td-chips-form-field{
width:100%; }
:host .td-chips-wrapper.td-chips-input-before-position .td-chips-form-field{
-webkit-box-ordinal-group:0;
-ms-flex-order:-1;
order:-1; }
:host .td-chip, :host .td-chip > .td-chip-content{
-webkit-box-sizing:border-box;
box-sizing:border-box;
display:-webkit-box;
display:-ms-flexbox;
display:flex;
-webkit-box-orient:horizontal;
-webkit-box-direction:normal;
-ms-flex-direction:row;
flex-direction:row;
max-width:100%;
-webkit-box-align:center;
-ms-flex-align:center;
align-items:center;
-ms-flex-line-pack:center;
align-content:center;
-webkit-box-pack:start;
-ms-flex-pack:start;
justify-content:start; }
:host .td-chip.td-chip-stacked, :host .td-chip > .td-chip-content.td-chip-stacked{
-webkit-box-pack:justify;
-ms-flex-pack:justify;
justify-content:space-between; }
:host ::ng-deep{ }
:host ::ng-deep .mat-form-field-wrapper{
padding-bottom:2px; }
:host ::ng-deep .mat-basic-chip{
display:inline-block;
cursor:default;
border-radius:16px;
margin:8px 8px 0 0;
-webkit-box-sizing:border-box;
box-sizing:border-box;
max-width:100%;
position:relative; }
html[dir=rtl] :host ::ng-deep .mat-basic-chip{
margin:8px 0 0 8px;
unicode-bidi:embed; }
body[dir=rtl] :host ::ng-deep .mat-basic-chip{
margin:8px 0 0 8px;
unicode-bidi:embed; }
[dir=rtl] :host ::ng-deep .mat-basic-chip{
margin:8px 0 0 8px;
unicode-bidi:embed; }
:host ::ng-deep .mat-basic-chip bdo[dir=rtl]{
direction:rtl;
unicode-bidi:bidi-override; }
:host ::ng-deep .mat-basic-chip bdo[dir=ltr]{
direction:ltr;
unicode-bidi:bidi-override; }
:host ::ng-deep .mat-basic-chip .td-chip{
min-height:32px;
line-height:32px;
font-size:13px;
padding:0 0 0 12px; }
html[dir=rtl] :host ::ng-deep .mat-basic-chip .td-chip{
padding:0 12px 0 0;
unicode-bidi:embed; }
body[dir=rtl] :host ::ng-deep .mat-basic-chip .td-chip{
padding:0 12px 0 0;
unicode-bidi:embed; }
[dir=rtl] :host ::ng-deep .mat-basic-chip .td-chip{
padding:0 12px 0 0;
unicode-bidi:embed; }
:host ::ng-deep .mat-basic-chip .td-chip bdo[dir=rtl]{
direction:rtl;
unicode-bidi:bidi-override; }
:host ::ng-deep .mat-basic-chip .td-chip bdo[dir=ltr]{
direction:ltr;
unicode-bidi:bidi-override; }
:host ::ng-deep .mat-basic-chip .td-chip [td-chip-avatar]{
display:inline-block;
-webkit-box-ordinal-group:-19;
-ms-flex-order:-20;
order:-20;
-webkit-box-pack:center;
-ms-flex-pack:center;
justify-content:center;
-webkit-box-align:center;
-ms-flex-align:center;
align-items:center;
text-align:center;
height:32px;
width:32px;
margin:0 8px 0 -12px;
border-radius:50%; }
html[dir=rtl] :host ::ng-deep .mat-basic-chip .td-chip [td-chip-avatar]{
margin:0 -12px 0 8px;
unicode-bidi:embed; }
body[dir=rtl] :host ::ng-deep .mat-basic-chip .td-chip [td-chip-avatar]{
margin:0 -12px 0 8px;
unicode-bidi:embed; }
[dir=rtl] :host ::ng-deep .mat-basic-chip .td-chip [td-chip-avatar]{
margin:0 -12px 0 8px;
unicode-bidi:embed; }
:host ::ng-deep .mat-basic-chip .td-chip [td-chip-avatar] bdo[dir=rtl]{
direction:rtl;
unicode-bidi:bidi-override; }
:host ::ng-deep .mat-basic-chip .td-chip [td-chip-avatar] bdo[dir=ltr]{
direction:ltr;
unicode-bidi:bidi-override; }
:host ::ng-deep .mat-basic-chip.td-chip-after-pad{
padding:0 12px 0 0; }
html[dir=rtl] :host ::ng-deep .mat-basic-chip.td-chip-after-pad{
padding:0 0 0 12px;
unicode-bidi:embed; }
body[dir=rtl] :host ::ng-deep .mat-basic-chip.td-chip-after-pad{
padding:0 0 0 12px;
unicode-bidi:embed; }
[dir=rtl] :host ::ng-deep .mat-basic-chip.td-chip-after-pad{
padding:0 0 0 12px;
unicode-bidi:embed; }
:host ::ng-deep .mat-basic-chip.td-chip-after-pad bdo[dir=rtl]{
direction:rtl;
unicode-bidi:bidi-override; }
:host ::ng-deep .mat-basic-chip.td-chip-after-pad bdo[dir=ltr]{
direction:ltr;
unicode-bidi:bidi-override; }
:host ::ng-deep .mat-basic-chip mat-icon.td-chip-removal{
margin:0 4px;
font-size:21px;
line-height:22px; }
:host ::ng-deep .mat-basic-chip mat-icon.td-chip-removal:hover{
cursor:pointer; }
:host ::ng-deep .td-chips-stacked .mat-basic-chip{
margin:4px 0; }
:host ::ng-deep .td-chips-stacked .mat-basic-chip:first-of-type{
margin:8px 0 4px; }
:host ::ng-deep .td-chips-stacked .mat-basic-chip:last-of-type{
margin:4px 0 8px; }
:host .mat-form-field-underline{
position:relative;
height:1px;
width:100%;
bottom:0; }
:host .mat-form-field-underline.mat-disabled{
background-position:0;
bottom:-4px;
background-color:transparent; }
:host .mat-form-field-underline .mat-form-field-ripple{
position:absolute;
height:2px;
top:0;
width:100%;
-webkit-transform-origin:50%;
transform-origin:50%;
-webkit-transform:scaleX(0.5);
transform:scaleX(0.5);
visibility:hidden;
opacity:0;
-webkit-transition:background-color 0.3s cubic-bezier(0.55, 0, 0.55, 0.2);
transition:background-color 0.3s cubic-bezier(0.55, 0, 0.55, 0.2); }
:host .mat-form-field-underline .mat-form-field-ripple.mat-focused{
visibility:visible;
opacity:1;
-webkit-transform:scaleX(1);
transform:scaleX(1);
-webkit-transition:background-color 0.3s cubic-bezier(0.55, 0, 0.55, 0.2), -webkit-transform 150ms linear;
transition:background-color 0.3s cubic-bezier(0.55, 0, 0.55, 0.2), -webkit-transform 150ms linear;
transition:transform 150ms linear, background-color 0.3s cubic-bezier(0.55, 0, 0.55, 0.2);
transition:transform 150ms linear, background-color 0.3s cubic-bezier(0.55, 0, 0.55, 0.2), -webkit-transform 150ms linear; }
:host ::ng-deep mat-form-field .mat-form-field-underline{
display:none; }
`],
template: `<div class="td-chips-wrapper"
[class.td-chips-stacked]="stacked"
[class.td-chips-input-before-position]="inputPosition === 'before'">
<ng-template let-chip let-first="first" let-index="index" ngFor [ngForOf]="value">
<mat-basic-chip [class.td-chip-disabled]="disabled"
[class.td-chip-after-pad]="!canRemoveChip"
[color]="color"
(keydown)="_chipKeydown($event, index)"
(blur)="_handleChipBlur($event, chip)"
(focus)="_handleChipFocus($event, chip)">
<div class="td-chip" [class.td-chip-stacked]="stacked">
<span class="td-chip-content">
<span *ngIf="!_chipTemplate?.templateRef">{{chip}}</span>
<ng-template
*ngIf="_chipTemplate?.templateRef"
[ngTemplateOutlet]="_chipTemplate?.templateRef"
[ngTemplateOutletContext]="{ chip: chip }">
</ng-template>
</span>
<mat-icon *ngIf="canRemoveChip" class="td-chip-removal" (click)="_internalClick = removeChip(index)">
cancel
</mat-icon>
</div>
</mat-basic-chip>
</ng-template>
<mat-form-field floatPlaceholder="never"
class="td-chips-form-field"
[style.width.px]="canAddChip ? null : 0"
[style.height.px]="canAddChip ? null : 0"
[color]="color">
<input matInput
#input
[tabIndex]="-1"
[matAutocomplete]="autocomplete"
[formControl]="inputControl"
[placeholder]="canAddChip? placeholder : ''"
(keydown)="_inputKeydown($event)"
(keyup.enter)="_handleAddChip()"
(focus)="_handleFocus()">
</mat-form-field>
<mat-autocomplete #autocomplete="matAutocomplete"
[displayWith]="_removeInputDisplay"
(optionSelected)="addChip($event.option.value)">
<ng-template let-item let-first="first" ngFor [ngForOf]="items">
<mat-option (click)="_setInternalClick()" [value]="item">
<span *ngIf="!_autocompleteOptionTemplate?.templateRef">{{item}}</span>
<ng-template
*ngIf="_autocompleteOptionTemplate?.templateRef"
[ngTemplateOutlet]="_autocompleteOptionTemplate?.templateRef"
[ngTemplateOutletContext]="{ option: item }">
</ng-template>
</mat-option>
</ng-template>
</mat-autocomplete>
</div>
<div *ngIf="chipAddition" class="mat-form-field-underline"
[class.mat-disabled]="disabled">
<span class="mat-form-field-ripple"
[class.mat-focused]="focused"></span>
</div>
<ng-content></ng-content>`,
changeDetection: ChangeDetectionStrategy.OnPush,
},] },
];
/** @nocollapse */
TdChipsComponent.ctorParameters = () => [
{ type: ElementRef, },
{ type: Renderer2, },
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [DOCUMENT,] },] },
{ type: ChangeDetectorRef, },
];
TdChipsComponent.propDecorators = {
"_nativeInput": [{ type: ViewChild, args: ['input',] },],
"_inputChild": [{ type: ViewChild, args: [MatInput,] },],
"_autocompleteTrigger": [{ type: ViewChild, args: [MatAutocompleteTrigger,] },],
"_chipsChildren": [{ type: ViewChildren, args: [MatChip,] },],
"_chipTemplate": [{ type: ContentChild, args: [TdChipDirective,] },],
"_autocompleteOptionTemplate": [{ type: ContentChild, args: [TdAutocompleteOptionDirective,] },],
"_options": [{ type: ViewChildren, args: [MatOption,] },],
"items": [{ type: Input, args: ['items',] },],
"stacked": [{ type: Input, args: ['stacked',] },],
"inputPosition": [{ type: Input, args: ['inputPosition',] },],
"requireMatch": [{ type: Input, args: ['requireMatch',] },],
"chipAddition": [{ type: Input, args: ['chipAddition',] },],
"chipRemoval": [{ type: Input, args: ['chipRemoval',] },],
"placeholder": [{ type: Input, args: ['placeholder',] },],
"debounce": [{ type: Input, args: ['debounce',] },],
"color": [{ type: Input, args: ['color',] },],
"onAdd": [{ type: Output, args: ['add',] },],
"onRemove": [{ type: Output, args: ['remove',] },],
"onInputChange": [{ type: Output, args: ['inputChange',] },],
"onChipFocus": [{ type: Output, args: ['chipFocus',] },],
"onChipBlur": [{ type: Output, args: ['chipBlur',] },],
"tabIndex": [{ type: HostBinding, args: ['attr.tabindex',] },],
"focusListener": [{ type: HostListener, args: ['focus', ['$event'],] },],
"mousedownListener": [{ type: HostListener, args: ['mousedown', ['$event'],] },],
"clickListener": [{ type: HostListener, args: ['click', ['$event'],] },],
"keydownListener": [{ type: HostListener, args: ['keydown', ['$event'],] },],
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class CovalentChipsModule {
}
CovalentChipsModule.decorators = [
{ type: NgModule, args: [{
imports: [
ReactiveFormsModule,
CommonModule,
MatInputModule,
MatIconModule,
MatChipsModule,
MatAutocompleteModule,
],
declarations: [
TdChipsComponent,
TdChipDirective,
TdAutocompleteOptionDirective,
],
exports: [
TdChipsComponent,
TdChipDirective,
TdAutocompleteOptionDirective,
],
},] },
];
/** @nocollapse */
CovalentChipsModule.ctorParameters = () => [];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* Generated bundle index. Do not edit.
*/
export { CovalentChipsModule, TdChipDirective, TdAutocompleteOptionDirective, TdChipsBase, _TdChipsMixinBase, TdChipsComponent };
//# sourceMappingURL=covalent-core-chips.js.map