angular2-query-builder
Version:
A modernized Angular 2+ query builder based on jquery QueryBuilder
16 lines (14 loc) • 34.7 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@angular/forms"),require("@angular/core"),require("@angular/common")):"function"==typeof define&&define.amd?define("angular2-query-builder",["exports","@angular/forms","@angular/core","@angular/common"],t):t((e=e||self)["angular2-query-builder"]={},e.ng.forms,e.ng.core,e.ng.common)}(this,(function(e,t,n,o){"use strict";
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */function a(e,t,n,o){var a,i=arguments.length,l=i<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)l=Reflect.decorate(e,t,n,o);else for(var r=e.length-1;r>=0;r--)(a=e[r])&&(l=(i<3?a(l):i>3?a(t,n,l):a(t,n))||l);return i>3&&l&&Object.defineProperty(t,n,l),l}function i(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}var l=function(){function e(e){this.template=e}return e.ctorParameters=function(){return[{type:n.TemplateRef}]},e=a([n.Directive({selector:"[queryOperator]"}),i("design:paramtypes",[n.TemplateRef])],e)}(),r=function(){function e(e){this.template=e}return e.ctorParameters=function(){return[{type:n.TemplateRef}]},e=a([n.Directive({selector:"[queryField]"}),i("design:paramtypes",[n.TemplateRef])],e)}(),s=function(){function e(e){this.template=e}return e.ctorParameters=function(){return[{type:n.TemplateRef}]},e=a([n.Directive({selector:"[queryEntity]"}),i("design:paramtypes",[n.TemplateRef])],e)}(),p=function(){function e(e){this.template=e}return e.ctorParameters=function(){return[{type:n.TemplateRef}]},e=a([n.Directive({selector:"[querySwitchGroup]"}),i("design:paramtypes",[n.TemplateRef])],e)}(),u=function(){function e(e){this.template=e}return e.ctorParameters=function(){return[{type:n.TemplateRef}]},e=a([n.Directive({selector:"[queryButtonGroup]"}),i("design:paramtypes",[n.TemplateRef])],e)}(),d=function(){function e(e){this.template=e}return Object.defineProperty(e.prototype,"queryInputType",{get:function(){return this._type},set:function(e){e&&(this._type=e)},enumerable:!0,configurable:!0}),e.ctorParameters=function(){return[{type:n.TemplateRef}]},a([n.Input(),i("design:type",String),i("design:paramtypes",[String])],e.prototype,"queryInputType",null),e=a([n.Directive({selector:"[queryInput]"}),i("design:paramtypes",[n.TemplateRef])],e)}(),c=function(){function e(e){this.template=e}return e.ctorParameters=function(){return[{type:n.TemplateRef}]},e=a([n.Directive({selector:"[queryRemoveButton]"}),i("design:paramtypes",[n.TemplateRef])],e)}(),g=function(){function e(e){this.template=e}return e.ctorParameters=function(){return[{type:n.TemplateRef}]},e=a([n.Directive({selector:"[queryEmptyWarning]"}),i("design:paramtypes",[n.TemplateRef])],e)}(),h=function(){function e(e){this.template=e}return e.ctorParameters=function(){return[{type:n.TemplateRef}]},e=a([n.Directive({selector:"[queryArrowIcon]"}),i("design:paramtypes",[n.TemplateRef])],e)}(),f={provide:t.NG_VALUE_ACCESSOR,useExisting:n.forwardRef((function(){return y})),multi:!0},m={provide:t.NG_VALIDATORS,useExisting:n.forwardRef((function(){return y})),multi:!0},y=function(){function e(e){var t=this;this.changeDetectorRef=e,this.defaultClassNames={arrowIconButton:"q-arrow-icon-button",arrowIcon:"q-icon q-arrow-icon",removeIcon:"q-icon q-remove-icon",addIcon:"q-icon q-add-icon",button:"q-button",buttonGroup:"q-button-group",removeButton:"q-remove-button",switchGroup:"q-switch-group",switchLabel:"q-switch-label",switchRadio:"q-switch-radio",rightAlign:"q-right-align",transition:"q-transition",collapsed:"q-collapsed",treeContainer:"q-tree-container",tree:"q-tree",row:"q-row",connector:"q-connector",rule:"q-rule",ruleSet:"q-ruleset",invalidRuleSet:"q-invalid-ruleset",emptyWarning:"q-empty-warning",fieldControl:"q-field-control",fieldControlSize:"q-control-size",entityControl:"q-entity-control",entityControlSize:"q-control-size",operatorControl:"q-operator-control",operatorControlSize:"q-control-size",inputControl:"q-input-control",inputControlSize:"q-control-size"},this.defaultOperatorMap={string:["=","!=","contains","like"],number:["=","!=",">",">=","<","<="],time:["=","!=",">",">=","<","<="],date:["=","!=",">",">=","<","<="],category:["=","!=","in","not in"],boolean:["="]},this.data={condition:"and",rules:[]},this.allowRuleset=!0,this.allowCollapse=!1,this.emptyMessage="A ruleset cannot be empty. Please add a rule or remove it all together.",this.config={fields:{}},this.persistValueOnFieldChange=!1,this.defaultTemplateTypes=["string","number","time","date","category","boolean","multiselect"],this.defaultPersistValueTypes=["string","number","time","date","boolean"],this.defaultEmptyList=[],this.inputContextCache=new Map,this.operatorContextCache=new Map,this.fieldContextCache=new Map,this.entityContextCache=new Map,this.removeButtonContextCache=new Map,this.getDisabledState=function(){return t.disabled}}return e.prototype.ngOnInit=function(){},e.prototype.ngOnChanges=function(e){var t=this.config,n=typeof t;if("object"!==n)throw new Error("Expected 'config' must be a valid object, got "+n+" instead.");this.fields=Object.keys(t.fields).map((function(e){var n=t.fields[e];return n.value=n.value||e,n})),t.entities?this.entities=Object.keys(t.entities).map((function(e){var n=t.entities[e];return n.value=n.value||e,n})):this.entities=null,this.operatorsCache={}},e.prototype.validate=function(e){var t={},n=[],o=!1;return!this.config.allowEmptyRulesets&&this.checkEmptyRuleInRuleset(this.data)&&(t.empty="Empty rulesets are not allowed.",o=!0),this.validateRulesInRuleset(this.data,n),n.length&&(t.rules=n,o=!0),o?t:null},Object.defineProperty(e.prototype,"value",{get:function(){return this.data},set:function(e){this.data=e||{condition:"and",rules:[]},this.handleDataChange()},enumerable:!0,configurable:!0}),e.prototype.writeValue=function(e){this.value=e},e.prototype.registerOnChange=function(e){var t=this;this.onChangeCallback=function(){return e(t.data)}},e.prototype.registerOnTouched=function(e){var t=this;this.onTouchedCallback=function(){return e(t.data)}},e.prototype.setDisabledState=function(e){this.disabled=e,this.changeDetectorRef.detectChanges()},e.prototype.findTemplateForRule=function(e){var t=this.getInputType(e.field,e.operator);if(t){var n=this.findQueryInput(t);return n?n.template:(-1===this.defaultTemplateTypes.indexOf(t)&&console.warn("Could not find template for field with type: "+t),null)}},e.prototype.findQueryInput=function(e){return(this.parentInputTemplates||this.inputTemplates).find((function(t){return t.queryInputType===e}))},e.prototype.getOperators=function(e){if(this.operatorsCache[e])return this.operatorsCache[e];var t=this.defaultEmptyList,n=this.config.fields[e];if(this.config.getOperators)return this.config.getOperators(e,n);var o=n.type;return n&&n.operators?t=n.operators:o?(0===(t=this.operatorMap&&this.operatorMap[o]||this.defaultOperatorMap[o]||this.defaultEmptyList).length&&console.warn("No operators found for field '"+e+"' with type "+n.type+". Please define an 'operators' property on the field or use the 'operatorMap' binding to fix this."),n.nullable&&(t=t.concat(["is null","is not null"]))):console.warn("No 'type' property found on field: '"+e+"'"),this.operatorsCache[e]=t,t},e.prototype.getFields=function(e){return this.entities&&e?this.fields.filter((function(t){return t&&t.entity===e})):this.fields},e.prototype.getInputType=function(e,t){if(this.config.getInputType)return this.config.getInputType(e,t);if(!this.config.fields[e])throw new Error("No configuration for field '"+e+"' could be found! Please add it to config.fields.");var n=this.config.fields[e].type;switch(t){case"is null":case"is not null":return null;case"in":case"not in":return"category"===n||"boolean"===n?"multiselect":n;default:return n}},e.prototype.getOptions=function(e){return this.config.getOptions?this.config.getOptions(e):this.config.fields[e].options||this.defaultEmptyList},e.prototype.getClassNames=function(){for(var e=this,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var o=this.classNames?this.classNames:this.defaultClassNames,a=t.map((function(t){return o[t]||e.defaultClassNames[t]})).filter((function(e){return!!e}));return a.length?a.join(" "):null},e.prototype.getDefaultField=function(e){if(e){if(void 0!==e.defaultField)return this.getDefaultValue(e.defaultField);var t=this.fields.filter((function(t){return t&&t.entity===e.value}));return t&&t.length?t[0]:(console.warn("No fields found for entity '"+e.name+"'. A 'defaultOperator' is also not specified on the field config. Operator value will default to null."),null)}return null},e.prototype.getDefaultOperator=function(e){if(e&&void 0!==e.defaultOperator)return this.getDefaultValue(e.defaultOperator);var t=this.getOperators(e.value);return t&&t.length?t[0]:(console.warn("No operators found for field '"+e.value+"'. A 'defaultOperator' is also not specified on the field config. Operator value will default to null."),null)},e.prototype.addRule=function(e){if(!this.disabled){if(e=e||this.data,this.config.addRule)this.config.addRule(e);else{var t=this.fields[0];e.rules=e.rules.concat([{field:t.value,operator:this.getDefaultOperator(t),value:this.getDefaultValue(t.defaultValue),entity:t.entity}])}this.handleTouched(),this.handleDataChange()}},e.prototype.removeRule=function(e,t){this.disabled||(t=t||this.data,this.config.removeRule?this.config.removeRule(e,t):t.rules=t.rules.filter((function(t){return t!==e})),this.inputContextCache.delete(e),this.operatorContextCache.delete(e),this.fieldContextCache.delete(e),this.entityContextCache.delete(e),this.removeButtonContextCache.delete(e),this.handleTouched(),this.handleDataChange())},e.prototype.addRuleSet=function(e){this.disabled||(e=e||this.data,this.config.addRuleSet?this.config.addRuleSet(e):e.rules=e.rules.concat([{condition:"and",rules:[]}]),this.handleTouched(),this.handleDataChange())},e.prototype.removeRuleSet=function(e,t){this.disabled||(e=e||this.data,t=t||this.parentValue,this.config.removeRuleSet?this.config.removeRuleSet(e,t):t.rules=t.rules.filter((function(t){return t!==e})),this.handleTouched(),this.handleDataChange())},e.prototype.transitionEnd=function(e){this.treeContainer.nativeElement.style.maxHeight=null},e.prototype.toggleCollapse=function(){var e=this;this.computedTreeContainerHeight(),setTimeout((function(){e.data.collapsed=!e.data.collapsed}),100)},e.prototype.computedTreeContainerHeight=function(){var e=this.treeContainer.nativeElement;e&&e.firstElementChild&&(e.style.maxHeight=e.firstElementChild.clientHeight+8+"px")},e.prototype.changeCondition=function(e){this.disabled||(this.data.condition=e,this.handleTouched(),this.handleDataChange())},e.prototype.changeOperator=function(e){this.disabled||(this.config.coerceValueForOperator?e.value=this.config.coerceValueForOperator(e.operator,e.value,e):e.value=this.coerceValueForOperator(e.operator,e.value,e),this.handleTouched(),this.handleDataChange())},e.prototype.coerceValueForOperator=function(e,t,n){return"multiselect"!==this.getInputType(n.field,e)||Array.isArray(t)?t:[t]},e.prototype.changeInput=function(){this.disabled||(this.handleTouched(),this.handleDataChange())},e.prototype.changeField=function(e,t){if(!this.disabled){var n=this.inputContextCache.get(t),o=n&&n.field,a=this.config.fields[e],i=this.calculateFieldChangeValue(o,a,t.value);void 0!==i?t.value=i:delete t.value,t.operator=this.getDefaultOperator(a),this.inputContextCache.delete(t),this.operatorContextCache.delete(t),this.fieldContextCache.delete(t),this.entityContextCache.delete(t),this.getInputContext(t),this.getFieldContext(t),this.getOperatorContext(t),this.getEntityContext(t),this.handleTouched(),this.handleDataChange()}},e.prototype.changeEntity=function(e,t,n,o){if(!this.disabled){var a=n,i=o,l=this.entities.find((function(t){return t.value===e})),r=this.getDefaultField(l);i||(a=(i=this.data).rules.findIndex((function(e){return e===t}))),t.field=r.value,i.rules[a]=t,r?this.changeField(r.value,t):(this.handleTouched(),this.handleDataChange())}},e.prototype.getDefaultValue=function(e){switch(typeof e){case"function":return e();default:return e}},e.prototype.getOperatorTemplate=function(){var e=this.parentOperatorTemplate||this.operatorTemplate;return e?e.template:null},e.prototype.getFieldTemplate=function(){var e=this.parentFieldTemplate||this.fieldTemplate;return e?e.template:null},e.prototype.getEntityTemplate=function(){var e=this.parentEntityTemplate||this.entityTemplate;return e?e.template:null},e.prototype.getArrowIconTemplate=function(){var e=this.parentArrowIconTemplate||this.arrowIconTemplate;return e?e.template:null},e.prototype.getButtonGroupTemplate=function(){var e=this.parentButtonGroupTemplate||this.buttonGroupTemplate;return e?e.template:null},e.prototype.getSwitchGroupTemplate=function(){var e=this.parentSwitchGroupTemplate||this.switchGroupTemplate;return e?e.template:null},e.prototype.getRemoveButtonTemplate=function(){var e=this.parentRemoveButtonTemplate||this.removeButtonTemplate;return e?e.template:null},e.prototype.getEmptyWarningTemplate=function(){var e=this.parentEmptyWarningTemplate||this.emptyWarningTemplate;return e?e.template:null},e.prototype.getQueryItemClassName=function(e){var t=this.getClassNames("row","connector","transition");return t+=" "+this.getClassNames(e.ruleset?"ruleSet":"rule"),e.invalid&&(t+=" "+this.getClassNames("invalidRuleSet")),t},e.prototype.getButtonGroupContext=function(){return this.buttonGroupContext||(this.buttonGroupContext={addRule:this.addRule.bind(this),addRuleSet:this.allowRuleset&&this.addRuleSet.bind(this),removeRuleSet:this.allowRuleset&&this.parentValue&&this.removeRuleSet.bind(this),getDisabledState:this.getDisabledState,$implicit:this.data}),this.buttonGroupContext},e.prototype.getRemoveButtonContext=function(e){return this.removeButtonContextCache.has(e)||this.removeButtonContextCache.set(e,{removeRule:this.removeRule.bind(this),getDisabledState:this.getDisabledState,$implicit:e}),this.removeButtonContextCache.get(e)},e.prototype.getFieldContext=function(e){return this.fieldContextCache.has(e)||this.fieldContextCache.set(e,{onChange:this.changeField.bind(this),getFields:this.getFields.bind(this),getDisabledState:this.getDisabledState,fields:this.fields,$implicit:e}),this.fieldContextCache.get(e)},e.prototype.getEntityContext=function(e){return this.entityContextCache.has(e)||this.entityContextCache.set(e,{onChange:this.changeEntity.bind(this),getDisabledState:this.getDisabledState,entities:this.entities,$implicit:e}),this.entityContextCache.get(e)},e.prototype.getSwitchGroupContext=function(){return{onChange:this.changeCondition.bind(this),getDisabledState:this.getDisabledState,$implicit:this.data}},e.prototype.getArrowIconContext=function(){return{getDisabledState:this.getDisabledState,$implicit:this.data}},e.prototype.getEmptyWarningContext=function(){return{getDisabledState:this.getDisabledState,message:this.emptyMessage,$implicit:this.data}},e.prototype.getOperatorContext=function(e){return this.operatorContextCache.has(e)||this.operatorContextCache.set(e,{onChange:this.changeOperator.bind(this),getDisabledState:this.getDisabledState,operators:this.getOperators(e.field),$implicit:e}),this.operatorContextCache.get(e)},e.prototype.getInputContext=function(e){return this.inputContextCache.has(e)||this.inputContextCache.set(e,{onChange:this.changeInput.bind(this),getDisabledState:this.getDisabledState,options:this.getOptions(e.field),field:this.config.fields[e.field],$implicit:e}),this.inputContextCache.get(e)},e.prototype.calculateFieldChangeValue=function(e,t,n){var o=this;if(null!=this.config.calculateFieldChangeValue)return this.config.calculateFieldChangeValue(e,t,n);return this.persistValueOnFieldChange&&null!=e&&null!=t&&e.type===t.type&&-1!==o.defaultPersistValueTypes.indexOf(e.type)?n:t&&void 0!==t.defaultValue?this.getDefaultValue(t.defaultValue):void 0},e.prototype.checkEmptyRuleInRuleset=function(e){var t=this;return!e||!e.rules||0===e.rules.length||e.rules.some((function(e){return!!e.rules&&t.checkEmptyRuleInRuleset(e)}))},e.prototype.validateRulesInRuleset=function(e,t){var n=this;e&&e.rules&&e.rules.length>0&&e.rules.forEach((function(o){if(o.rules)return n.validateRulesInRuleset(o,t);if(o.field){var a=n.config.fields[o.field];if(a&&a.validator&&a.validator.apply){var i=a.validator(o,e);null!=i&&t.push(i)}}}))},e.prototype.handleDataChange=function(){this.changeDetectorRef.markForCheck(),this.onChangeCallback&&this.onChangeCallback(),this.parentChangeCallback&&this.parentChangeCallback()},e.prototype.handleTouched=function(){this.onTouchedCallback&&this.onTouchedCallback(),this.parentTouchedCallback&&this.parentTouchedCallback()},e.ctorParameters=function(){return[{type:n.ChangeDetectorRef}]},a([n.Input(),i("design:type",Boolean)],e.prototype,"disabled",void 0),a([n.Input(),i("design:type",Object)],e.prototype,"data",void 0),a([n.Input(),i("design:type",Boolean)],e.prototype,"allowRuleset",void 0),a([n.Input(),i("design:type",Boolean)],e.prototype,"allowCollapse",void 0),a([n.Input(),i("design:type",String)],e.prototype,"emptyMessage",void 0),a([n.Input(),i("design:type",Object)],e.prototype,"classNames",void 0),a([n.Input(),i("design:type",Object)],e.prototype,"operatorMap",void 0),a([n.Input(),i("design:type",Object)],e.prototype,"parentValue",void 0),a([n.Input(),i("design:type",Object)],e.prototype,"config",void 0),a([n.Input(),i("design:type",h)],e.prototype,"parentArrowIconTemplate",void 0),a([n.Input(),i("design:type",n.QueryList)],e.prototype,"parentInputTemplates",void 0),a([n.Input(),i("design:type",l)],e.prototype,"parentOperatorTemplate",void 0),a([n.Input(),i("design:type",r)],e.prototype,"parentFieldTemplate",void 0),a([n.Input(),i("design:type",s)],e.prototype,"parentEntityTemplate",void 0),a([n.Input(),i("design:type",p)],e.prototype,"parentSwitchGroupTemplate",void 0),a([n.Input(),i("design:type",u)],e.prototype,"parentButtonGroupTemplate",void 0),a([n.Input(),i("design:type",c)],e.prototype,"parentRemoveButtonTemplate",void 0),a([n.Input(),i("design:type",g)],e.prototype,"parentEmptyWarningTemplate",void 0),a([n.Input(),i("design:type",Function)],e.prototype,"parentChangeCallback",void 0),a([n.Input(),i("design:type",Function)],e.prototype,"parentTouchedCallback",void 0),a([n.Input(),i("design:type",Boolean)],e.prototype,"persistValueOnFieldChange",void 0),a([n.ViewChild("treeContainer",{static:!0}),i("design:type",n.ElementRef)],e.prototype,"treeContainer",void 0),a([n.ContentChild(u),i("design:type",u)],e.prototype,"buttonGroupTemplate",void 0),a([n.ContentChild(p),i("design:type",p)],e.prototype,"switchGroupTemplate",void 0),a([n.ContentChild(r),i("design:type",r)],e.prototype,"fieldTemplate",void 0),a([n.ContentChild(s),i("design:type",s)],e.prototype,"entityTemplate",void 0),a([n.ContentChild(l),i("design:type",l)],e.prototype,"operatorTemplate",void 0),a([n.ContentChild(c),i("design:type",c)],e.prototype,"removeButtonTemplate",void 0),a([n.ContentChild(g),i("design:type",g)],e.prototype,"emptyWarningTemplate",void 0),a([n.ContentChildren(d),i("design:type",n.QueryList)],e.prototype,"inputTemplates",void 0),a([n.ContentChild(h),i("design:type",h)],e.prototype,"arrowIconTemplate",void 0),a([n.Input(),i("design:type",Object),i("design:paramtypes",[Object])],e.prototype,"value",null),e=a([n.Component({selector:"query-builder",template:'<div [ngClass]="getClassNames(\'switchRow\')">\n <ng-template #defaultArrowIcon>\n <i [ngClass]="getClassNames(\'arrowIcon\')"></i>\n </ng-template>\n\n <a *ngIf="allowCollapse" (click)="toggleCollapse()" [ngClass]="getClassNames(\'arrowIconButton\', data.collapsed ? \'collapsed\' : null)">\n <ng-container *ngIf="getArrowIconTemplate() as template; else defaultArrowIcon">\n <ng-container *ngTemplateOutlet="template; context: getArrowIconContext()"></ng-container>\n </ng-container>\n </a>\n\n <ng-container *ngIf="getButtonGroupTemplate() as template; else defaultButtonGroup">\n <div [ngClass]="getClassNames(\'buttonGroup\', \'rightAlign\')">\n <ng-container *ngTemplateOutlet="template; context: getButtonGroupContext()"></ng-container>\n </div>\n </ng-container>\n\n <ng-template #defaultButtonGroup>\n <div [ngClass]="getClassNames(\'buttonGroup\', \'rightAlign\')">\n <button type="button" (click)="addRule()" [ngClass]="getClassNames(\'button\')" [disabled]=disabled>\n <i [ngClass]="getClassNames(\'addIcon\')"></i> Rule\n </button>\n <button type="button" (click)="addRuleSet()" [ngClass]="getClassNames(\'button\')" *ngIf="allowRuleset" [disabled]=disabled>\n <i [ngClass]="getClassNames(\'addIcon\')"></i> Ruleset\n </button>\n <ng-container *ngIf="!!parentValue && allowRuleset">\n <button type="button" (click)="removeRuleSet()" [ngClass]="getClassNames(\'button\', \'removeButton\')" [disabled]=disabled>\n <i [ngClass]="getClassNames(\'removeIcon\')"></i>\n </button>\n </ng-container>\n </div>\n </ng-template>\n\n <ng-container *ngIf="getSwitchGroupTemplate() as template; else defaultSwitchGroup">\n <ng-container *ngTemplateOutlet="template; context: getSwitchGroupContext()"></ng-container>\n </ng-container>\n\n <ng-template #defaultSwitchGroup>\n <div [ngClass]="getClassNames(\'switchGroup\', \'transition\')" *ngIf="data">\n <div [ngClass]="getClassNames(\'switchControl\')">\n <input type="radio" [ngClass]="getClassNames(\'switchRadio\')" [(ngModel)]="data.condition" [disabled]=disabled\n value="and" #andOption />\n <label (click)="changeCondition(andOption.value)" [ngClass]="getClassNames(\'switchLabel\')">AND</label>\n </div>\n <div [ngClass]="getClassNames(\'switchControl\')">\n <input type="radio" [ngClass]="getClassNames(\'switchRadio\')" [(ngModel)]="data.condition" [disabled]=disabled\n value="or" #orOption />\n <label (click)="changeCondition(orOption.value)" [ngClass]="getClassNames(\'switchLabel\')">OR</label>\n </div>\n </div>\n </ng-template>\n</div>\n\n<div #treeContainer (transitionend)="transitionEnd($event)" [ngClass]="getClassNames(\'treeContainer\', data.collapsed ? \'collapsed\' : null)">\n <ul [ngClass]="getClassNames(\'tree\')" *ngIf="data && data.rules">\n <ng-container *ngFor="let rule of data.rules;let i=index">\n\n <ng-container *ngIf="{ruleset: !!rule.rules, invalid: !config.allowEmptyRulesets && rule.rules && rule.rules.length === 0} as local">\n <li [ngClass]="getQueryItemClassName(local)">\n <ng-container *ngIf="!local.ruleset">\n\n <ng-container *ngIf="getRemoveButtonTemplate() as template; else defaultRemoveButton">\n <div [ngClass]="getClassNames(\'buttonGroup\', \'rightAlign\')">\n <ng-container *ngTemplateOutlet="template; context: getRemoveButtonContext(rule)"></ng-container>\n </div>\n </ng-container>\n\n <ng-template #defaultRemoveButton>\n <div [ngClass]="getClassNames(\'removeButtonSize\', \'rightAlign\')">\n <button type="button" [ngClass]="getClassNames(\'button\', \'removeButton\')" (click)="removeRule(rule, data)" [disabled]=disabled>\n <i [ngClass]="getClassNames(\'removeIcon\')"></i>\n </button>\n </div>\n </ng-template>\n\n <div *ngIf="entities?.length > 0" class="q-inline-block-display">\n <ng-container *ngIf="getEntityTemplate() as template; else defaultEntity">\n <ng-container *ngTemplateOutlet="template; context: getEntityContext(rule)"></ng-container>\n </ng-container>\n </div>\n\n <ng-template #defaultEntity>\n <div [ngClass]="getClassNames(\'entityControlSize\')">\n <select [ngClass]="getClassNames(\'entityControl\')" [(ngModel)]="rule.entity" (ngModelChange)="changeEntity($event, rule,i,data)"\n [disabled]="disabled">\n <option *ngFor="let entity of entities" [ngValue]="entity.value">\n {{entity.name}}\n </option>\n </select>\n </div>\n </ng-template>\n\n <ng-container *ngIf="getFieldTemplate() as template; else defaultField">\n <ng-container *ngTemplateOutlet="template; context: getFieldContext(rule)"></ng-container>\n </ng-container>\n\n <ng-template #defaultField>\n <div [ngClass]="getClassNames(\'fieldControlSize\')">\n <select [ngClass]="getClassNames(\'fieldControl\')" [(ngModel)]="rule.field" (ngModelChange)="changeField($event, rule)"\n [disabled]="disabled">\n <option *ngFor="let field of getFields(rule.entity)" [ngValue]="field.value">\n {{field.name}}\n </option>\n </select>\n </div>\n </ng-template>\n\n <ng-container *ngIf="getOperatorTemplate() as template; else defaultOperator">\n <ng-container *ngTemplateOutlet="template; context: getOperatorContext(rule)"></ng-container>\n </ng-container>\n\n <ng-template #defaultOperator>\n <div [ngClass]="getClassNames(\'operatorControlSize\')">\n <select [ngClass]="getClassNames(\'operatorControl\')" [(ngModel)]="rule.operator" (ngModelChange)="changeOperator(rule)"\n [disabled]="disabled">\n <option *ngFor="let operator of getOperators(rule.field)" [ngValue]="operator">\n {{operator}}\n </option>\n </select>\n </div>\n </ng-template>\n\n <ng-container *ngIf="findTemplateForRule(rule) as template; else defaultInput">\n <ng-container *ngTemplateOutlet="template; context: getInputContext(rule)"></ng-container>\n </ng-container>\n\n <ng-template #defaultInput>\n <div [ngClass]="getClassNames(\'inputControlSize\')" [ngSwitch]="getInputType(rule.field, rule.operator)">\n <input [ngClass]="getClassNames(\'inputControl\')" [(ngModel)]="rule.value" (ngModelChange)="changeInput()"\n [disabled]="disabled" *ngSwitchCase="\'string\'" type="text">\n <input [ngClass]="getClassNames(\'inputControl\')" [(ngModel)]="rule.value" (ngModelChange)="changeInput()"\n [disabled]="disabled" *ngSwitchCase="\'number\'" type="number">\n <input [ngClass]="getClassNames(\'inputControl\')" [(ngModel)]="rule.value" (ngModelChange)="changeInput()"\n [disabled]="disabled" *ngSwitchCase="\'date\'" type="date">\n <input [ngClass]="getClassNames(\'inputControl\')" [(ngModel)]="rule.value" (ngModelChange)="changeInput()"\n [disabled]="disabled" *ngSwitchCase="\'time\'" type="time">\n <select [ngClass]="getClassNames(\'inputControl\')" [(ngModel)]="rule.value" (ngModelChange)="changeInput()"\n [disabled]="disabled" *ngSwitchCase="\'category\'">\n <option *ngFor="let opt of getOptions(rule.field)" [ngValue]="opt.value">\n {{opt.name}}\n </option>\n </select>\n <ng-container *ngSwitchCase="\'multiselect\'">\n <select [ngClass]="getClassNames(\'inputControl\')" [(ngModel)]="rule.value" (ngModelChange)="changeInput()"\n [disabled]="disabled" multiple>\n <option *ngFor="let opt of getOptions(rule.field)" [ngValue]="opt.value">\n {{opt.name}}\n </option>\n </select>\n </ng-container>\n <input [ngClass]="getClassNames(\'inputControl\')" [(ngModel)]="rule.value" (ngModelChange)="changeInput()"\n [disabled]="disabled" *ngSwitchCase="\'boolean\'" type="checkbox">\n </div>\n </ng-template>\n\n </ng-container>\n <query-builder *ngIf="local.ruleset" [data]="rule" [disabled]="disabled" [parentTouchedCallback]="parentTouchedCallback || onTouchedCallback"\n [parentChangeCallback]="parentChangeCallback || onChangeCallback" [parentInputTemplates]="parentInputTemplates || inputTemplates"\n [parentOperatorTemplate]="parentOperatorTemplate || operatorTemplate" [parentFieldTemplate]="parentFieldTemplate || fieldTemplate"\n [parentEntityTemplate]="parentEntityTemplate || entityTemplate" [parentSwitchGroupTemplate]="parentSwitchGroupTemplate || switchGroupTemplate"\n [parentButtonGroupTemplate]="parentButtonGroupTemplate || buttonGroupTemplate" [parentRemoveButtonTemplate]="parentRemoveButtonTemplate || removeButtonTemplate"\n [parentEmptyWarningTemplate]="parentEmptyWarningTemplate || emptyWarningTemplate" [parentArrowIconTemplate]="parentArrowIconTemplate || arrowIconTemplate"\n [parentValue]="data" [classNames]="classNames" [config]="config" [allowRuleset]="allowRuleset"\n [allowCollapse]="allowCollapse" [emptyMessage]="emptyMessage" [operatorMap]="operatorMap">\n </query-builder>\n\n <ng-container *ngIf="getEmptyWarningTemplate() as template; else defaultEmptyWarning">\n <ng-container *ngIf="local.invalid">\n <ng-container *ngTemplateOutlet="template; context: getEmptyWarningContext()"></ng-container>\n </ng-container>\n </ng-container>\n\n <ng-template #defaultEmptyWarning>\n <p [ngClass]="getClassNames(\'emptyWarning\')" *ngIf="local.invalid">\n {{emptyMessage}}\n </p>\n </ng-template>\n </li>\n </ng-container>\n </ng-container>\n </ul>\n</div>',providers:[f,m],styles:["@charset \"UTF-8\";:host{display:block;width:100%}:host .q-icon{font-style:normal;font-size:12px}:host .q-remove-icon::before{content:'❌'}:host .q-arrow-icon-button{float:left;margin:4px 6px 4px 0;-webkit-transform:rotate(90deg);transform:rotate(90deg);-webkit-transition:transform .25s linear;transition:transform .25s linear;cursor:pointer}:host .q-arrow-icon-button.q-collapsed{-webkit-transform:rotate(0);transform:rotate(0)}:host .q-arrow-icon::before{content:'▶'}:host .q-add-icon{color:#555}:host .q-add-icon::before{content:'➕'}:host .q-remove-button{color:#b3415d;width:31px}:host .q-button-group,:host .q-switch-group{font-family:\"Lucida Grande\",Tahoma,Verdana,sans-serif;overflow:hidden}:host .q-right-align{float:right}:host .q-button{margin-left:8px;padding:0 8px;background-color:#fff}:host .q-button:disabled{display:none}:host .q-control-size{display:inline-block;vertical-align:top;padding-right:10px}:host .q-entity-control,:host .q-field-control,:host .q-input-control,:host .q-operator-control{display:inline-block;padding:5px 8px;color:#555;background-color:#fff;background-image:none;border:1px solid #ccc;border-radius:4px;box-sizing:border-box;width:auto}:host .q-entity-control:disabled,:host .q-field-control:disabled,:host .q-input-control:disabled,:host .q-operator-control:disabled{border-color:transparent}:host .q-entity-control,:host .q-field-control,:host .q-input-control:not([type=checkbox]),:host .q-operator-control{min-height:32px;-webkit-appearance:none}:host .q-button,:host .q-switch-label{float:left;margin-bottom:0;font-size:14px;line-height:30px;font-weight:400;text-align:center;text-shadow:none;border:1px solid rgba(0,0,0,.2);box-sizing:border-box}:host .q-button:hover,:host .q-switch-label:hover{cursor:pointer;background-color:#f0f0f0}:host .q-switch-label{background-color:#e4e4e4;padding:0 8px}:host .q-switch-radio{position:absolute;clip:rect(0,0,0,0);height:1px;width:1px;border:0;overflow:hidden}:host .q-switch-radio:checked+.q-switch-label{border:1px solid #619ed7;background:#fff;color:#3176b3}:host .q-switch-radio:disabled+.q-switch-label{display:none}:host .q-switch-radio:checked:disabled+.q-switch-label{display:initial;color:initial;cursor:default;border-color:transparent}:host .q-invalid-ruleset{border:1px solid rgba(179,65,93,.5)!important;background:rgba(179,65,93,.1)!important}:host .q-empty-warning{color:#8d252e;text-align:center}:host .q-ruleset{border:1px solid #ccc}:host .q-rule{border:1px solid #ccc;background:#fff}:host .q-transition{-webkit-transition:.1s ease-in-out;transition:.1s ease-in-out}:host .q-tree-container{width:100%;overflow:hidden;-webkit-transition:max-height .25s ease-in;transition:max-height .25s ease-in}:host .q-tree-container.q-collapsed{max-height:0!important}:host .q-tree{list-style:none;margin:4px 0 2px}:host .q-row{padding:6px 8px;margin-top:6px}:host .q-connector{position:relative}:host .q-connector::before{top:-5px;border-width:0 0 2px 2px}:host .q-connector::after{border-width:0 0 0 2px;top:50%}:host .q-connector::after,:host .q-connector::before{content:'';left:-12px;border-color:#ccc;border-style:solid;width:9px;height:calc(50% + 6px);position:absolute}:host .q-connector:last-child::after{content:none}:host .q-inline-block-display{display:inline-block;vertical-align:top}"]}),i("design:paramtypes",[n.ChangeDetectorRef])],e)}(),C=function(){function e(){}return e=a([n.NgModule({imports:[o.CommonModule,t.FormsModule],declarations:[y,d,l,r,s,u,p,c,g,h],exports:[y,d,l,r,s,u,p,c,g,h]})],e)}();e.CONTROL_VALUE_ACCESSOR=f,e.QueryArrowIconDirective=h,e.QueryBuilderComponent=y,e.QueryBuilderModule=C,e.QueryButtonGroupDirective=u,e.QueryEmptyWarningDirective=g,e.QueryEntityDirective=s,e.QueryFieldDirective=r,e.QueryInputDirective=d,e.QueryOperatorDirective=l,e.QueryRemoveButtonDirective=c,e.QuerySwitchGroupDirective=p,e.VALIDATOR=m,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=angular2-query-builder.umd.min.js.map