UNPKG

@taiga-ui/kit

Version:
16 lines (14 loc) 8.78 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("@angular/core"),require("@angular/forms"),require("@taiga-ui/cdk"),require("@taiga-ui/core"),require("@taiga-ui/kit/components/arrow"),require("@taiga-ui/kit/components/select-option"),require("@taiga-ui/kit/providers"),require("@angular/common"),require("@tinkoff/ng-polymorpheus")):"function"==typeof define&&define.amd?define("@taiga-ui/kit/components/combo-box",["exports","@angular/core","@angular/forms","@taiga-ui/cdk","@taiga-ui/core","@taiga-ui/kit/components/arrow","@taiga-ui/kit/components/select-option","@taiga-ui/kit/providers","@angular/common","@tinkoff/ng-polymorpheus"],e):e(((t=t||self)["taiga-ui"]=t["taiga-ui"]||{},t["taiga-ui"].kit=t["taiga-ui"].kit||{},t["taiga-ui"].kit.components=t["taiga-ui"].kit.components||{},t["taiga-ui"].kit.components["combo-box"]={}),t.ng.core,t.ng.forms,t.cdk,t.core$1,t["taiga-ui"].kit.components.arrow,t["taiga-ui"].kit.components["select-option"],t["taiga-ui"].kit.providers,t.ng.common,t.ngPolymorpheus)}(this,(function(t,e,o,n,i,r,u,a,c,s){"use strict"; /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var p=function(t,e){return(p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};function d(t,e,o,n){var i,r=arguments.length,u=r<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)u=Reflect.decorate(t,e,o,n);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(u=(r<3?i(u):r>3?i(e,o,u):i(e,o))||u);return r>3&&u&&Object.defineProperty(e,o,u),u}function l(t,e){return function(o,n){e(o,n,t)}}var h=u.TUI_SELECT_OPTION,f=function(t){function u(o,i){var u=t.call(this,o,i)||this;return u.stringify=n.TUI_DEFAULT_STRINGIFY,u.strictMatcher=n.TUI_STRICT_MATCHER,u.identityMatcher=n.TUI_DEFAULT_IDENTITY_MATCHER,u.valueContent="",u.strict=!0,u.search="",u.searchChange=new e.EventEmitter,u.arrow=r.TUI_ARROW,u.open=!1,u.datalist="",u}var c;return function(t,e){function o(){this.constructor=t}p(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}(u,t),c=u,Object.defineProperty(u.prototype,"nativeFocusableElement",{get:function(){return this.textfield?this.textfield.nativeFocusableElement:null},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"focused",{get:function(){return n.isNativeFocused(this.nativeFocusableElement)||!!this.hostedDropdown&&this.hostedDropdown.focused},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"nativeValue",{get:function(){return null===this.value?this.search||"":this.stringify(this.value)},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"showValueTemplate",{get:function(){return n.isPresent(this.value)&&!this.focused},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"canOpen",{get:function(){return!this.computedDisabled&&!this.readOnly},enumerable:!0,configurable:!0}),Object.defineProperty(u.prototype,"computedContent",{get:function(){return this.valueContent||this.nativeValue},enumerable:!0,configurable:!0}),u.prototype.onActiveZone=function(t){this.updateFocused(t)},u.prototype.checkOption=function(t){this.isStrictMatch(t)&&(this.updateValue(t),this.updateSearch(null))},u.prototype.handleOption=function(t){this.focusInput(),this.close(),this.updateSearch(null),this.updateValue(t)},u.prototype.onFieldKeyDownEnter=function(t){this.open&&t.preventDefault();var e=this.accessor?this.accessor.getOptions():[];1===e.length&&(this.updateValue(e[0]),this.updateSearch(null),this.close())},u.prototype.onInput=function(t){var e=this;this.updateSearch(t);var o=this.accessor&&this.accessor.getOptions().find((function(t){return e.isStrictMatch(t)}));if(void 0!==o)return this.updateValue(o),void this.updateSearch(null);this.updateValue(this.strict||""===this.search?null:this.search),this.search&&this.hostedDropdown&&this.hostedDropdown.updateOpen(!0)},u.prototype.onHovered=function(t){this.updateHovered(t)},u.prototype.computeContext=function(t,e){return{$implicit:t,active:e}},u.prototype.toggle=function(){this.hostedDropdown&&this.hostedDropdown.updateOpen(!this.open)},u.prototype.isStrictMatch=function(t){return this.strictMatcher(t,this.search||"",this.stringify)},u.prototype.close=function(){this.hostedDropdown&&this.hostedDropdown.updateOpen(!1)},u.prototype.updateSearch=function(t){this.search!==t&&(this.search=t,this.searchChange.emit(t))},u.prototype.focusInput=function(t){void 0===t&&(t=!1),this.nativeFocusableElement&&n.setNativeFocused(this.nativeFocusableElement,!0,t)},u.ctorParameters=function(){return[{type:o.NgControl,decorators:[{type:e.Optional},{type:e.Self},{type:e.Inject,args:[o.NgControl]}]},{type:e.ChangeDetectorRef,decorators:[{type:e.Inject,args:[e.ChangeDetectorRef]}]}]},d([e.Input(),n.tuiDefaultProp()],u.prototype,"stringify",void 0),d([e.Input(),n.tuiDefaultProp()],u.prototype,"strictMatcher",void 0),d([e.Input(),n.tuiDefaultProp()],u.prototype,"identityMatcher",void 0),d([e.Input(),n.tuiDefaultProp()],u.prototype,"valueContent",void 0),d([e.Input(),n.tuiDefaultProp()],u.prototype,"strict",void 0),d([e.Input(),n.tuiDefaultProp()],u.prototype,"search",void 0),d([e.Output()],u.prototype,"searchChange",void 0),d([e.ContentChild(i.TuiDataListDirective,{read:e.TemplateRef})],u.prototype,"datalist",void 0),d([e.ContentChild(i.TUI_DATA_LIST_ACCESSOR)],u.prototype,"accessor",void 0),d([e.ViewChild(i.TuiHostedDropdownComponent)],u.prototype,"hostedDropdown",void 0),d([e.ViewChild(i.TuiPrimitiveTextfieldComponent)],u.prototype,"textfield",void 0),d([n.tuiPure],u.prototype,"computeContext",null),u=c=d([e.Component({selector:"tui-combo-box",template:'<tui-hosted-dropdown\n class="hosted"\n [canOpen]="canOpen"\n [content]="datalist || \'\'"\n [(open)]="open"\n (tuiActiveZoneChange)="onActiveZone($event)"\n>\n <tui-primitive-textfield\n automation-id="tui-combo-box__textfield"\n class="textfield"\n [pseudoFocused]="computedFocused"\n [pseudoHovered]="computedHovered"\n [invalid]="computedInvalid"\n [nativeId]="nativeId"\n [readOnly]="readOnly"\n [iconContent]="arrow"\n [disabled]="computedDisabled"\n [focusable]="computedFocusable"\n [value]="nativeValue"\n (valueChange)="onInput($event)"\n (hoveredChange)="onHovered($event)"\n (click)="toggle()"\n (keydown.enter)="onFieldKeyDownEnter($event)"\n >\n <ng-content></ng-content>\n <div\n polymorpheus-outlet\n *ngIf="showValueTemplate"\n class="value"\n automation-id="tui-combo-box__template"\n [content]="computedContent"\n [context]="computeContext(value, computedFocused)"\n ></div>\n </tui-primitive-textfield>\n</tui-hosted-dropdown>\n',changeDetection:e.ChangeDetectionStrategy.OnPush,providers:[{provide:n.TUI_FOCUSABLE_ITEM_ACCESSOR,useExisting:e.forwardRef((function(){return c}))},{provide:i.TUI_DATA_LIST_HOST,useExisting:e.forwardRef((function(){return c}))},{provide:i.TUI_OPTION_CONTENT,useValue:h},a.FIXED_DROPDOWN_CONTROLLER_PROVIDER],styles:[":host{display:block;border-radius:var(--tui-radius-m)}.hosted{display:block;border-radius:inherit}.textfield{border-radius:inherit}.value{display:flex;width:100%;align-items:center}"]}),l(0,e.Optional()),l(0,e.Self()),l(0,e.Inject(o.NgControl)),l(1,e.Inject(e.ChangeDetectorRef))],u)}(n.AbstractTuiNullableControl),g=function(){function t(){}return t=d([e.NgModule({imports:[c.CommonModule,s.PolymorpheusModule,n.TuiActiveZoneModule,i.TuiPrimitiveTextfieldModule,i.TuiHostedDropdownModule,u.TuiSelectOptionModule,r.TuiArrowModule],declarations:[f],exports:[f]})],t)}();t.TuiComboBoxComponent=f,t.TuiComboBoxModule=g,t.ɵ0=h,Object.defineProperty(t,"__esModule",{value:!0})})); //# sourceMappingURL=taiga-ui-kit-components-combo-box.umd.min.js.map