ngx-angular-query-builder 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/README.md +24 -0
  2. package/bundles/ngx-angular-query-builder.umd.js +1001 -0
  3. package/bundles/ngx-angular-query-builder.umd.js.map +1 -0
  4. package/esm2015/lib/ngx-angular-query-builder.module.js +75 -0
  5. package/esm2015/lib/query-builder/query-arrow-icon.directive.js +14 -0
  6. package/esm2015/lib/query-builder/query-builder.component.js +748 -0
  7. package/esm2015/lib/query-builder/query-builder.interfaces.js +2 -0
  8. package/esm2015/lib/query-builder/query-button-group.directive.js +14 -0
  9. package/esm2015/lib/query-builder/query-empty-warning.directive.js +14 -0
  10. package/esm2015/lib/query-builder/query-entity.directive.js +14 -0
  11. package/esm2015/lib/query-builder/query-field.directive.js +14 -0
  12. package/esm2015/lib/query-builder/query-input.directive.js +26 -0
  13. package/esm2015/lib/query-builder/query-operator.directive.js +14 -0
  14. package/esm2015/lib/query-builder/query-remove-button.directive.js +14 -0
  15. package/esm2015/lib/query-builder/query-switch-group.directive.js +14 -0
  16. package/esm2015/ngx-angular-query-builder.js +5 -0
  17. package/esm2015/public-api.js +16 -0
  18. package/fesm2015/ngx-angular-query-builder.js +932 -0
  19. package/fesm2015/ngx-angular-query-builder.js.map +1 -0
  20. package/lib/ngx-angular-query-builder.module.d.ts +18 -0
  21. package/lib/query-builder/query-arrow-icon.directive.d.ts +8 -0
  22. package/lib/query-builder/query-builder.component.d.ts +128 -0
  23. package/lib/query-builder/query-builder.interfaces.d.ts +143 -0
  24. package/lib/query-builder/query-button-group.directive.d.ts +8 -0
  25. package/lib/query-builder/query-empty-warning.directive.d.ts +8 -0
  26. package/lib/query-builder/query-entity.directive.d.ts +8 -0
  27. package/lib/query-builder/query-field.directive.d.ts +8 -0
  28. package/lib/query-builder/query-input.directive.d.ts +12 -0
  29. package/lib/query-builder/query-operator.directive.d.ts +8 -0
  30. package/lib/query-builder/query-remove-button.directive.d.ts +8 -0
  31. package/lib/query-builder/query-switch-group.directive.d.ts +8 -0
  32. package/ngx-angular-query-builder.d.ts +5 -0
  33. package/package.json +20 -0
  34. package/public-api.d.ts +12 -0
@@ -0,0 +1,1001 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/forms'), require('@angular/core'), require('@angular/common')) :
3
+ typeof define === 'function' && define.amd ? define('ngx-angular-query-builder', ['exports', '@angular/forms', '@angular/core', '@angular/common'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["ngx-angular-query-builder"] = {}, global.ng.forms, global.ng.core, global.ng.common));
5
+ })(this, (function (exports, i2, i0, i1) { 'use strict';
6
+
7
+ function _interopNamespace(e) {
8
+ if (e && e.__esModule) return e;
9
+ var n = Object.create(null);
10
+ if (e) {
11
+ Object.keys(e).forEach(function (k) {
12
+ if (k !== 'default') {
13
+ var d = Object.getOwnPropertyDescriptor(e, k);
14
+ Object.defineProperty(n, k, d.get ? d : {
15
+ enumerable: true,
16
+ get: function () { return e[k]; }
17
+ });
18
+ }
19
+ });
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var i2__namespace = /*#__PURE__*/_interopNamespace(i2);
26
+ var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
27
+ var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
28
+
29
+ var QueryOperatorDirective = /** @class */ (function () {
30
+ function QueryOperatorDirective(template) {
31
+ this.template = template;
32
+ }
33
+ return QueryOperatorDirective;
34
+ }());
35
+ QueryOperatorDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryOperatorDirective, deps: [{ token: i0__namespace.TemplateRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
36
+ QueryOperatorDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.13", type: QueryOperatorDirective, selector: "[queryOperator]", ngImport: i0__namespace });
37
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryOperatorDirective, decorators: [{
38
+ type: i0.Directive,
39
+ args: [{ selector: '[queryOperator]' }]
40
+ }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }]; } });
41
+
42
+ var QueryFieldDirective = /** @class */ (function () {
43
+ function QueryFieldDirective(template) {
44
+ this.template = template;
45
+ }
46
+ return QueryFieldDirective;
47
+ }());
48
+ QueryFieldDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryFieldDirective, deps: [{ token: i0__namespace.TemplateRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
49
+ QueryFieldDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.13", type: QueryFieldDirective, selector: "[queryField]", ngImport: i0__namespace });
50
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryFieldDirective, decorators: [{
51
+ type: i0.Directive,
52
+ args: [{ selector: '[queryField]' }]
53
+ }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }]; } });
54
+
55
+ var QueryEntityDirective = /** @class */ (function () {
56
+ function QueryEntityDirective(template) {
57
+ this.template = template;
58
+ }
59
+ return QueryEntityDirective;
60
+ }());
61
+ QueryEntityDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryEntityDirective, deps: [{ token: i0__namespace.TemplateRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
62
+ QueryEntityDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.13", type: QueryEntityDirective, selector: "[queryEntity]", ngImport: i0__namespace });
63
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryEntityDirective, decorators: [{
64
+ type: i0.Directive,
65
+ args: [{ selector: '[queryEntity]' }]
66
+ }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }]; } });
67
+
68
+ var QuerySwitchGroupDirective = /** @class */ (function () {
69
+ function QuerySwitchGroupDirective(template) {
70
+ this.template = template;
71
+ }
72
+ return QuerySwitchGroupDirective;
73
+ }());
74
+ QuerySwitchGroupDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QuerySwitchGroupDirective, deps: [{ token: i0__namespace.TemplateRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
75
+ QuerySwitchGroupDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.13", type: QuerySwitchGroupDirective, selector: "[querySwitchGroup]", ngImport: i0__namespace });
76
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QuerySwitchGroupDirective, decorators: [{
77
+ type: i0.Directive,
78
+ args: [{ selector: '[querySwitchGroup]' }]
79
+ }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }]; } });
80
+
81
+ var QueryButtonGroupDirective = /** @class */ (function () {
82
+ function QueryButtonGroupDirective(template) {
83
+ this.template = template;
84
+ }
85
+ return QueryButtonGroupDirective;
86
+ }());
87
+ QueryButtonGroupDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryButtonGroupDirective, deps: [{ token: i0__namespace.TemplateRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
88
+ QueryButtonGroupDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.13", type: QueryButtonGroupDirective, selector: "[queryButtonGroup]", ngImport: i0__namespace });
89
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryButtonGroupDirective, decorators: [{
90
+ type: i0.Directive,
91
+ args: [{ selector: '[queryButtonGroup]' }]
92
+ }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }]; } });
93
+
94
+ var QueryInputDirective = /** @class */ (function () {
95
+ function QueryInputDirective(template) {
96
+ this.template = template;
97
+ }
98
+ Object.defineProperty(QueryInputDirective.prototype, "queryInputType", {
99
+ /** Unique name for query input type. */
100
+ get: function () { return this._type; },
101
+ set: function (value) {
102
+ // If the directive is set without a type (updated programatically), then this setter will
103
+ // trigger with an empty string and should not overwrite the programatically set value.
104
+ if (!value) {
105
+ return;
106
+ }
107
+ this._type = value;
108
+ },
109
+ enumerable: false,
110
+ configurable: true
111
+ });
112
+ return QueryInputDirective;
113
+ }());
114
+ QueryInputDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryInputDirective, deps: [{ token: i0__namespace.TemplateRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
115
+ QueryInputDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.13", type: QueryInputDirective, selector: "[queryInput]", inputs: { queryInputType: "queryInputType" }, ngImport: i0__namespace });
116
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryInputDirective, decorators: [{
117
+ type: i0.Directive,
118
+ args: [{ selector: '[queryInput]' }]
119
+ }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }]; }, propDecorators: { queryInputType: [{
120
+ type: i0.Input
121
+ }] } });
122
+
123
+ var QueryRemoveButtonDirective = /** @class */ (function () {
124
+ function QueryRemoveButtonDirective(template) {
125
+ this.template = template;
126
+ }
127
+ return QueryRemoveButtonDirective;
128
+ }());
129
+ QueryRemoveButtonDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryRemoveButtonDirective, deps: [{ token: i0__namespace.TemplateRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
130
+ QueryRemoveButtonDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.13", type: QueryRemoveButtonDirective, selector: "[queryRemoveButton]", ngImport: i0__namespace });
131
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryRemoveButtonDirective, decorators: [{
132
+ type: i0.Directive,
133
+ args: [{ selector: '[queryRemoveButton]' }]
134
+ }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }]; } });
135
+
136
+ var QueryEmptyWarningDirective = /** @class */ (function () {
137
+ function QueryEmptyWarningDirective(template) {
138
+ this.template = template;
139
+ }
140
+ return QueryEmptyWarningDirective;
141
+ }());
142
+ QueryEmptyWarningDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryEmptyWarningDirective, deps: [{ token: i0__namespace.TemplateRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
143
+ QueryEmptyWarningDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.13", type: QueryEmptyWarningDirective, selector: "[queryEmptyWarning]", ngImport: i0__namespace });
144
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryEmptyWarningDirective, decorators: [{
145
+ type: i0.Directive,
146
+ args: [{ selector: '[queryEmptyWarning]' }]
147
+ }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }]; } });
148
+
149
+ var QueryArrowIconDirective = /** @class */ (function () {
150
+ function QueryArrowIconDirective(template) {
151
+ this.template = template;
152
+ }
153
+ return QueryArrowIconDirective;
154
+ }());
155
+ QueryArrowIconDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryArrowIconDirective, deps: [{ token: i0__namespace.TemplateRef }], target: i0__namespace.ɵɵFactoryTarget.Directive });
156
+ QueryArrowIconDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.13", type: QueryArrowIconDirective, selector: "[queryArrowIcon]", ngImport: i0__namespace });
157
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryArrowIconDirective, decorators: [{
158
+ type: i0.Directive,
159
+ args: [{ selector: '[queryArrowIcon]' }]
160
+ }], ctorParameters: function () { return [{ type: i0__namespace.TemplateRef }]; } });
161
+
162
+ var CONTROL_VALUE_ACCESSOR = {
163
+ provide: i2.NG_VALUE_ACCESSOR,
164
+ useExisting: i0.forwardRef(function () { return QueryBuilderComponent; }),
165
+ multi: true
166
+ };
167
+ var VALIDATOR = {
168
+ provide: i2.NG_VALIDATORS,
169
+ useExisting: i0.forwardRef(function () { return QueryBuilderComponent; }),
170
+ multi: true
171
+ };
172
+ var QueryBuilderComponent = /** @class */ (function () {
173
+ function QueryBuilderComponent(changeDetectorRef) {
174
+ var _this = this;
175
+ this.changeDetectorRef = changeDetectorRef;
176
+ this.defaultClassNames = {
177
+ arrowIconButton: 'q-arrow-icon-button',
178
+ arrowIcon: 'q-icon q-arrow-icon',
179
+ removeIcon: 'q-icon q-remove-icon',
180
+ addIcon: 'q-icon q-add-icon',
181
+ button: 'q-button',
182
+ buttonGroup: 'q-button-group',
183
+ removeButton: 'q-remove-button',
184
+ switchGroup: 'q-switch-group',
185
+ switchLabel: 'q-switch-label',
186
+ switchRadio: 'q-switch-radio',
187
+ rightAlign: 'q-right-align',
188
+ transition: 'q-transition',
189
+ collapsed: 'q-collapsed',
190
+ treeContainer: 'q-tree-container',
191
+ tree: 'q-tree',
192
+ row: 'q-row',
193
+ connector: 'q-connector',
194
+ rule: 'q-rule',
195
+ ruleSet: 'q-ruleset',
196
+ invalidRuleSet: 'q-invalid-ruleset',
197
+ emptyWarning: 'q-empty-warning',
198
+ fieldControl: 'q-field-control',
199
+ fieldControlSize: 'q-control-size',
200
+ entityControl: 'q-entity-control',
201
+ entityControlSize: 'q-control-size',
202
+ operatorControl: 'q-operator-control',
203
+ operatorControlSize: 'q-control-size',
204
+ inputControl: 'q-input-control',
205
+ inputControlSize: 'q-control-size'
206
+ };
207
+ this.defaultOperatorMap = {
208
+ string: ['=', '!=', 'contains', 'like'],
209
+ number: ['=', '!=', '>', '>=', '<', '<='],
210
+ time: ['=', '!=', '>', '>=', '<', '<='],
211
+ date: ['=', '!=', '>', '>=', '<', '<='],
212
+ category: ['=', '!=', 'in', 'not in'],
213
+ boolean: ['=']
214
+ };
215
+ this.disabled = false;
216
+ this.data = { condition: 'add', rules: [] };
217
+ this.allowRuleset = true;
218
+ this.allowCollapse = false;
219
+ this.emptyMessage = 'A ruleset cannot be empty. Please add a rule or remove it all together.';
220
+ this.classNames = {};
221
+ this.operatorMap = {};
222
+ this.parentValue = { condition: 'add', rules: [] };
223
+ this.config = { fields: {} };
224
+ this.persistValueOnFieldChange = false;
225
+ this.defaultTemplateTypes = [
226
+ 'string', 'number', 'time', 'date', 'category', 'boolean', 'multiselect'
227
+ ];
228
+ this.defaultPersistValueTypes = [
229
+ 'string', 'number', 'time', 'date', 'boolean'
230
+ ];
231
+ this.defaultEmptyList = [];
232
+ this.operatorsCache = {};
233
+ this.inputContextCache = new Map();
234
+ this.operatorContextCache = new Map();
235
+ this.fieldContextCache = new Map();
236
+ this.entityContextCache = new Map();
237
+ this.removeButtonContextCache = new Map();
238
+ // ----------END----------
239
+ this.getDisabledState = function () {
240
+ return _this.disabled;
241
+ };
242
+ this.fields = [];
243
+ this.filterFields = [];
244
+ this.entities = [];
245
+ }
246
+ // ----------OnInit Implementation----------
247
+ // ----------OnChanges Implementation----------
248
+ QueryBuilderComponent.prototype.ngOnChanges = function (changes) {
249
+ var config = this.config;
250
+ var type = typeof config;
251
+ if (type === 'object') {
252
+ this.fields = Object.keys(config.fields).map(function (value) {
253
+ var field = config.fields[value];
254
+ field.value = field.value || value;
255
+ return field;
256
+ });
257
+ if (config.entities) {
258
+ this.entities = Object.keys(config.entities).map(function (value) {
259
+ var entity = config.entities ? config.entities[value] : [];
260
+ entity.value = entity.value || value;
261
+ return entity;
262
+ });
263
+ }
264
+ else {
265
+ this.entities = [];
266
+ }
267
+ this.operatorsCache = {};
268
+ }
269
+ else {
270
+ throw new Error("Expected 'config' must be a valid object, got " + type + " instead.");
271
+ }
272
+ };
273
+ // ----------Validator Implementation----------
274
+ QueryBuilderComponent.prototype.validate = function (control) {
275
+ var errors = {};
276
+ var ruleErrorStore = [];
277
+ var hasErrors = false;
278
+ if (!this.config.allowEmptyRulesets && this.checkEmptyRuleInRuleset(this.data)) {
279
+ errors.empty = 'Empty rulesets are not allowed.';
280
+ hasErrors = true;
281
+ }
282
+ this.validateRulesInRuleset(this.data, ruleErrorStore);
283
+ if (ruleErrorStore.length) {
284
+ errors.rules = ruleErrorStore;
285
+ hasErrors = true;
286
+ }
287
+ return hasErrors ? errors : null;
288
+ };
289
+ Object.defineProperty(QueryBuilderComponent.prototype, "value", {
290
+ // ----------ControlValueAccessor Implementation----------
291
+ get: function () {
292
+ return this.data;
293
+ },
294
+ set: function (value) {
295
+ // When component is initialized without a formControl, null is passed to value
296
+ this.data = value || { condition: 'add', rules: [] };
297
+ this.handleDataChange();
298
+ },
299
+ enumerable: false,
300
+ configurable: true
301
+ });
302
+ QueryBuilderComponent.prototype.writeValue = function (obj) {
303
+ this.value = obj;
304
+ };
305
+ QueryBuilderComponent.prototype.registerOnChange = function (fn) {
306
+ var _this = this;
307
+ this.onChangeCallback = function () { return fn(_this.data); };
308
+ };
309
+ QueryBuilderComponent.prototype.registerOnTouched = function (fn) {
310
+ var _this = this;
311
+ this.onTouchedCallback = function () { return fn(_this.data); };
312
+ };
313
+ QueryBuilderComponent.prototype.setDisabledState = function (isDisabled) {
314
+ this.disabled = isDisabled;
315
+ this.changeDetectorRef.detectChanges();
316
+ };
317
+ QueryBuilderComponent.prototype.findTemplateForRule = function (rule) {
318
+ var type = this.getInputType(rule.field, rule.operator);
319
+ if (type) {
320
+ var queryInput = this.findQueryInput(type);
321
+ if (queryInput) {
322
+ return queryInput.template;
323
+ }
324
+ else {
325
+ if (this.defaultTemplateTypes.indexOf(type) === -1) {
326
+ console.warn("Could not find template for field with type: " + type);
327
+ }
328
+ return null;
329
+ }
330
+ }
331
+ };
332
+ QueryBuilderComponent.prototype.findQueryInput = function (type) {
333
+ var templates = this.parentInputTemplates || this.inputTemplates;
334
+ return templates.find(function (item) { return item.queryInputType === type; });
335
+ };
336
+ QueryBuilderComponent.prototype.getOperators = function (field) {
337
+ if (this.operatorsCache[field]) {
338
+ return this.operatorsCache[field];
339
+ }
340
+ var operators = this.defaultEmptyList;
341
+ var fieldObject = this.config.fields[field];
342
+ if (this.config.getOperators) {
343
+ return this.config.getOperators(field, fieldObject);
344
+ }
345
+ var type = fieldObject.type;
346
+ if (fieldObject && fieldObject.operators) {
347
+ operators = fieldObject.operators;
348
+ }
349
+ else if (type) {
350
+ operators = (this.operatorMap && this.operatorMap[type]) || this.defaultOperatorMap[type] || this.defaultEmptyList;
351
+ if (operators.length === 0) {
352
+ console.warn("No operators found for field '" + field + "' with type " + fieldObject.type + ". " +
353
+ "Please define an 'operators' property on the field or use the 'operatorMap' binding to fix this.");
354
+ }
355
+ if (fieldObject.nullable) {
356
+ operators = operators.concat(['is null', 'is not null']);
357
+ }
358
+ }
359
+ else {
360
+ console.warn("No 'type' property found on field: '" + field + "'");
361
+ }
362
+ // Cache reference to array object, so it won't be computed next time and trigger a rerender.
363
+ this.operatorsCache[field] = operators;
364
+ return operators;
365
+ };
366
+ QueryBuilderComponent.prototype.getFields = function (entity) {
367
+ if (this.entities.length && entity) {
368
+ return this.fields.filter(function (field) {
369
+ return field && field.entity === entity;
370
+ });
371
+ }
372
+ else {
373
+ return this.fields;
374
+ }
375
+ };
376
+ QueryBuilderComponent.prototype.getInputType = function (field, operator) {
377
+ if (this.config.getInputType) {
378
+ return this.config.getInputType(field, operator);
379
+ }
380
+ if (!this.config.fields[field]) {
381
+ throw new Error("No configuration for field '" + field + "' could be found! Please add it to config.fields.");
382
+ }
383
+ var type = this.config.fields[field].type;
384
+ switch (operator) {
385
+ case 'is null':
386
+ case 'is not null':
387
+ return null; // No displayed component
388
+ case 'in':
389
+ case 'not in':
390
+ return type === 'category' || type === 'boolean' ? 'multiselect' : type;
391
+ default:
392
+ return type;
393
+ }
394
+ };
395
+ QueryBuilderComponent.prototype.getOptions = function (field) {
396
+ if (this.config.getOptions) {
397
+ return this.config.getOptions(field);
398
+ }
399
+ return this.config.fields[field].options || this.defaultEmptyList;
400
+ };
401
+ QueryBuilderComponent.prototype.getClassNames = function () {
402
+ var args = [];
403
+ for (var _i = 0; _i < arguments.length; _i++) {
404
+ args[_i] = arguments[_i];
405
+ }
406
+ var clsLookup = this.classNames ? this.classNames : this.defaultClassNames;
407
+ var defaultClassNames = this.defaultClassNames;
408
+ var classNames = args.map(function (id) { return clsLookup[id] || defaultClassNames[id]; }).filter(function (c) { return !!c; });
409
+ return classNames.length ? classNames.join(' ') : [];
410
+ };
411
+ QueryBuilderComponent.prototype.getDefaultField = function (entity) {
412
+ if (!entity) {
413
+ return null;
414
+ }
415
+ else if (entity.defaultField !== undefined) {
416
+ return this.getDefaultValue(entity.defaultField);
417
+ }
418
+ else {
419
+ var entityFields = this.fields.filter(function (field) {
420
+ return field && field.entity === entity.value;
421
+ });
422
+ if (entityFields && entityFields.length) {
423
+ return entityFields[0];
424
+ }
425
+ else {
426
+ console.warn("No fields found for entity '" + entity.name + "'. " +
427
+ "A 'defaultOperator' is also not specified on the field config. Operator value will default to null.");
428
+ return null;
429
+ }
430
+ }
431
+ };
432
+ QueryBuilderComponent.prototype.getDefaultOperator = function (field) {
433
+ if (field && field.defaultOperator !== undefined) {
434
+ return this.getDefaultValue(field.defaultOperator);
435
+ }
436
+ else {
437
+ var operators = this.getOperators(field.value);
438
+ if (operators && operators.length) {
439
+ return operators[0];
440
+ }
441
+ else {
442
+ console.warn("No operators found for field '" + field.value + "'. " +
443
+ "A 'defaultOperator' is also not specified on the field config. Operator value will default to null.");
444
+ return null;
445
+ }
446
+ }
447
+ };
448
+ QueryBuilderComponent.prototype.addRule = function (parent) {
449
+ if (this.disabled) {
450
+ return;
451
+ }
452
+ parent = parent || this.data;
453
+ if (this.config.addRule) {
454
+ this.config.addRule(parent);
455
+ }
456
+ else {
457
+ var field = this.fields[0];
458
+ parent.rules = parent.rules.concat([{
459
+ field: field.value,
460
+ operator: this.getDefaultOperator(field),
461
+ value: this.getDefaultValue(field.defaultValue),
462
+ entity: field.entity
463
+ }]);
464
+ }
465
+ this.handleTouched();
466
+ this.handleDataChange();
467
+ };
468
+ QueryBuilderComponent.prototype.removeRule = function (rule, parent) {
469
+ if (this.disabled) {
470
+ return;
471
+ }
472
+ parent = parent || this.data;
473
+ if (this.config.removeRule) {
474
+ this.config.removeRule(rule, parent);
475
+ }
476
+ else {
477
+ parent.rules = parent.rules.filter(function (r) { return r !== rule; });
478
+ }
479
+ this.inputContextCache.delete(rule);
480
+ this.operatorContextCache.delete(rule);
481
+ this.fieldContextCache.delete(rule);
482
+ this.entityContextCache.delete(rule);
483
+ this.removeButtonContextCache.delete(rule);
484
+ this.handleTouched();
485
+ this.handleDataChange();
486
+ };
487
+ QueryBuilderComponent.prototype.addRuleSet = function (parent) {
488
+ if (this.disabled) {
489
+ return;
490
+ }
491
+ parent = parent || this.data;
492
+ if (this.config.addRuleSet) {
493
+ this.config.addRuleSet(parent);
494
+ }
495
+ else {
496
+ parent.rules = parent.rules.concat([{ condition: 'add', rules: [] }]);
497
+ }
498
+ this.handleTouched();
499
+ this.handleDataChange();
500
+ };
501
+ QueryBuilderComponent.prototype.removeRuleSet = function (ruleset, parent) {
502
+ if (this.disabled) {
503
+ return;
504
+ }
505
+ ruleset = ruleset || this.data;
506
+ parent = parent || this.parentValue;
507
+ if (this.config.removeRuleSet) {
508
+ this.config.removeRuleSet(ruleset, parent);
509
+ }
510
+ else {
511
+ parent.rules = parent.rules.filter(function (r) { return r !== ruleset; });
512
+ }
513
+ this.handleTouched();
514
+ this.handleDataChange();
515
+ };
516
+ QueryBuilderComponent.prototype.transitionEnd = function (e) {
517
+ this.treeContainer.nativeElement.style.maxHeight = null;
518
+ };
519
+ QueryBuilderComponent.prototype.toggleCollapse = function () {
520
+ var _this = this;
521
+ this.computedTreeContainerHeight();
522
+ setTimeout(function () {
523
+ _this.data.collapsed = !_this.data.collapsed;
524
+ }, 100);
525
+ };
526
+ QueryBuilderComponent.prototype.computedTreeContainerHeight = function () {
527
+ var nativeElement = this.treeContainer.nativeElement;
528
+ if (nativeElement && nativeElement.firstElementChild) {
529
+ nativeElement.style.maxHeight = (nativeElement.firstElementChild.clientHeight + 8) + 'px';
530
+ }
531
+ };
532
+ QueryBuilderComponent.prototype.changeCondition = function (value) {
533
+ if (this.disabled) {
534
+ return;
535
+ }
536
+ this.data.condition = value;
537
+ this.handleTouched();
538
+ this.handleDataChange();
539
+ };
540
+ QueryBuilderComponent.prototype.changeOperator = function (rule) {
541
+ if (this.disabled) {
542
+ return;
543
+ }
544
+ if (this.config.coerceValueForOperator) {
545
+ rule.value = this.config.coerceValueForOperator(rule.operator, rule.value, rule);
546
+ }
547
+ else {
548
+ rule.value = this.coerceValueForOperator(rule.operator, rule.value, rule);
549
+ }
550
+ this.handleTouched();
551
+ this.handleDataChange();
552
+ };
553
+ QueryBuilderComponent.prototype.coerceValueForOperator = function (operator, value, rule) {
554
+ var inputType = this.getInputType(rule.field, operator);
555
+ if (inputType === 'multiselect' && !Array.isArray(value)) {
556
+ return [value];
557
+ }
558
+ return value;
559
+ };
560
+ QueryBuilderComponent.prototype.changeInput = function () {
561
+ if (this.disabled) {
562
+ return;
563
+ }
564
+ this.handleTouched();
565
+ this.handleDataChange();
566
+ };
567
+ QueryBuilderComponent.prototype.changeField = function (fieldValue, rule) {
568
+ if (this.disabled) {
569
+ return;
570
+ }
571
+ var inputContext = this.inputContextCache.get(rule);
572
+ var currentField = inputContext && inputContext.field;
573
+ var nextField = this.config.fields[fieldValue];
574
+ var nextValue = this.calculateFieldChangeValue(currentField, nextField, rule.value);
575
+ if (nextValue !== undefined) {
576
+ rule.value = nextValue;
577
+ }
578
+ else {
579
+ delete rule.value;
580
+ }
581
+ rule.operator = this.getDefaultOperator(nextField);
582
+ // Create new context objects so templates will automatically update
583
+ this.inputContextCache.delete(rule);
584
+ this.operatorContextCache.delete(rule);
585
+ this.fieldContextCache.delete(rule);
586
+ this.entityContextCache.delete(rule);
587
+ this.getInputContext(rule);
588
+ this.getFieldContext(rule);
589
+ this.getOperatorContext(rule);
590
+ this.getEntityContext(rule);
591
+ this.handleTouched();
592
+ this.handleDataChange();
593
+ };
594
+ QueryBuilderComponent.prototype.changeEntity = function (entityValue, rule, index, data) {
595
+ if (this.disabled) {
596
+ return;
597
+ }
598
+ var i = index;
599
+ var rs = data;
600
+ var entity = this.entities.find(function (e) { return e.value === entityValue; });
601
+ var defaultField = this.getDefaultField(entity);
602
+ if (!rs) {
603
+ rs = this.data;
604
+ i = rs.rules.findIndex(function (x) { return x === rule; });
605
+ }
606
+ rule.field = defaultField.value;
607
+ rs.rules[i] = rule;
608
+ if (defaultField) {
609
+ this.changeField(defaultField.value, rule);
610
+ }
611
+ else {
612
+ this.handleTouched();
613
+ this.handleDataChange();
614
+ }
615
+ };
616
+ QueryBuilderComponent.prototype.getDefaultValue = function (defaultValue) {
617
+ switch (typeof defaultValue) {
618
+ case 'function':
619
+ return defaultValue();
620
+ default:
621
+ return defaultValue;
622
+ }
623
+ };
624
+ QueryBuilderComponent.prototype.getOperatorTemplate = function () {
625
+ var t = this.parentOperatorTemplate || this.operatorTemplate;
626
+ return t ? t.template : null;
627
+ };
628
+ QueryBuilderComponent.prototype.getFieldTemplate = function () {
629
+ var t = this.parentFieldTemplate || this.fieldTemplate;
630
+ return t ? t.template : null;
631
+ };
632
+ QueryBuilderComponent.prototype.getEntityTemplate = function () {
633
+ var t = this.parentEntityTemplate || this.entityTemplate;
634
+ return t ? t.template : null;
635
+ };
636
+ QueryBuilderComponent.prototype.getArrowIconTemplate = function () {
637
+ var t = this.parentArrowIconTemplate || this.arrowIconTemplate;
638
+ return t ? t.template : null;
639
+ };
640
+ QueryBuilderComponent.prototype.getButtonGroupTemplate = function () {
641
+ var t = this.parentButtonGroupTemplate || this.buttonGroupTemplate;
642
+ return t ? t.template : null;
643
+ };
644
+ QueryBuilderComponent.prototype.getSwitchGroupTemplate = function () {
645
+ var t = this.parentSwitchGroupTemplate || this.switchGroupTemplate;
646
+ return t ? t.template : null;
647
+ };
648
+ QueryBuilderComponent.prototype.getRemoveButtonTemplate = function () {
649
+ var t = this.parentRemoveButtonTemplate || this.removeButtonTemplate;
650
+ return t ? t.template : null;
651
+ };
652
+ QueryBuilderComponent.prototype.getEmptyWarningTemplate = function () {
653
+ var t = this.parentEmptyWarningTemplate || this.emptyWarningTemplate;
654
+ return t ? t.template : null;
655
+ };
656
+ QueryBuilderComponent.prototype.getQueryItemClassName = function (local) {
657
+ var cls = this.getClassNames('row', 'connector', 'transition');
658
+ cls += ' ' + this.getClassNames(local.ruleset ? 'ruleSet' : 'rule');
659
+ if (local.invalid) {
660
+ cls += ' ' + this.getClassNames('invalidRuleSet');
661
+ }
662
+ return cls;
663
+ };
664
+ QueryBuilderComponent.prototype.getButtonGroupContext = function () {
665
+ if (!this.buttonGroupContext) {
666
+ this.buttonGroupContext = {
667
+ addRule: this.addRule.bind(this),
668
+ addRuleSet: this.allowRuleset && this.addRuleSet.bind(this),
669
+ removeRuleSet: this.allowRuleset && this.parentValue && this.removeRuleSet.bind(this),
670
+ getDisabledState: this.getDisabledState,
671
+ $implicit: this.data
672
+ };
673
+ }
674
+ return this.buttonGroupContext;
675
+ };
676
+ QueryBuilderComponent.prototype.getRemoveButtonContext = function (rule) {
677
+ if (!this.removeButtonContextCache.has(rule)) {
678
+ this.removeButtonContextCache.set(rule, {
679
+ removeRule: this.removeRule.bind(this),
680
+ getDisabledState: this.getDisabledState,
681
+ $implicit: rule
682
+ });
683
+ }
684
+ return this.removeButtonContextCache.get(rule);
685
+ };
686
+ QueryBuilderComponent.prototype.getFieldContext = function (rule) {
687
+ if (!this.fieldContextCache.has(rule)) {
688
+ this.fieldContextCache.set(rule, {
689
+ onChange: this.changeField.bind(this),
690
+ getFields: this.getFields.bind(this),
691
+ getDisabledState: this.getDisabledState,
692
+ fields: this.fields,
693
+ $implicit: rule
694
+ });
695
+ }
696
+ return this.fieldContextCache.get(rule);
697
+ };
698
+ QueryBuilderComponent.prototype.getEntityContext = function (rule) {
699
+ if (!this.entityContextCache.has(rule)) {
700
+ this.entityContextCache.set(rule, {
701
+ onChange: this.changeEntity.bind(this),
702
+ getDisabledState: this.getDisabledState,
703
+ entities: this.entities,
704
+ $implicit: rule
705
+ });
706
+ }
707
+ return this.entityContextCache.get(rule);
708
+ };
709
+ QueryBuilderComponent.prototype.getSwitchGroupContext = function () {
710
+ return {
711
+ onChange: this.changeCondition.bind(this),
712
+ getDisabledState: this.getDisabledState,
713
+ $implicit: this.data
714
+ };
715
+ };
716
+ QueryBuilderComponent.prototype.getArrowIconContext = function () {
717
+ return {
718
+ getDisabledState: this.getDisabledState,
719
+ $implicit: this.data
720
+ };
721
+ };
722
+ QueryBuilderComponent.prototype.getEmptyWarningContext = function () {
723
+ return {
724
+ getDisabledState: this.getDisabledState,
725
+ message: this.emptyMessage,
726
+ $implicit: this.data
727
+ };
728
+ };
729
+ QueryBuilderComponent.prototype.getOperatorContext = function (rule) {
730
+ if (!this.operatorContextCache.has(rule)) {
731
+ this.operatorContextCache.set(rule, {
732
+ onChange: this.changeOperator.bind(this),
733
+ getDisabledState: this.getDisabledState,
734
+ operators: this.getOperators(rule.field),
735
+ $implicit: rule
736
+ });
737
+ }
738
+ return this.operatorContextCache.get(rule);
739
+ };
740
+ QueryBuilderComponent.prototype.getInputContext = function (rule) {
741
+ if (!this.inputContextCache.has(rule)) {
742
+ this.inputContextCache.set(rule, {
743
+ onChange: this.changeInput.bind(this),
744
+ getDisabledState: this.getDisabledState,
745
+ options: this.getOptions(rule.field),
746
+ field: this.config.fields[rule.field],
747
+ $implicit: rule
748
+ });
749
+ }
750
+ return this.inputContextCache.get(rule);
751
+ };
752
+ QueryBuilderComponent.prototype.calculateFieldChangeValue = function (currentField, nextField, currentValue) {
753
+ var _this = this;
754
+ if (this.config.calculateFieldChangeValue != null) {
755
+ return this.config.calculateFieldChangeValue(currentField, nextField, currentValue);
756
+ }
757
+ var canKeepValue = function () {
758
+ if (currentField == null || nextField == null) {
759
+ return false;
760
+ }
761
+ return currentField.type === nextField.type
762
+ && _this.defaultPersistValueTypes.indexOf(currentField.type) !== -1;
763
+ };
764
+ if (this.persistValueOnFieldChange && canKeepValue()) {
765
+ return currentValue;
766
+ }
767
+ if (nextField && nextField.defaultValue !== undefined) {
768
+ return this.getDefaultValue(nextField.defaultValue);
769
+ }
770
+ return undefined;
771
+ };
772
+ QueryBuilderComponent.prototype.checkEmptyRuleInRuleset = function (ruleset) {
773
+ var _this = this;
774
+ if (!ruleset || !ruleset.rules || ruleset.rules.length === 0) {
775
+ return true;
776
+ }
777
+ else {
778
+ return ruleset.rules.some(function (item) {
779
+ if (item.rules) {
780
+ return _this.checkEmptyRuleInRuleset(item);
781
+ }
782
+ else {
783
+ return false;
784
+ }
785
+ });
786
+ }
787
+ };
788
+ QueryBuilderComponent.prototype.validateRulesInRuleset = function (ruleset, errorStore) {
789
+ var _this = this;
790
+ if (ruleset && ruleset.rules && ruleset.rules.length > 0) {
791
+ ruleset.rules.forEach(function (item) {
792
+ if (item.rules) {
793
+ return _this.validateRulesInRuleset(item, errorStore);
794
+ }
795
+ else if (item.field) {
796
+ var field = _this.config.fields[item.field];
797
+ if (field && field.validator && field.validator.apply) {
798
+ var error = field.validator(item, ruleset);
799
+ if (error != null) {
800
+ errorStore.push(error);
801
+ }
802
+ }
803
+ }
804
+ });
805
+ }
806
+ };
807
+ QueryBuilderComponent.prototype.handleDataChange = function () {
808
+ this.changeDetectorRef.markForCheck();
809
+ if (this.onChangeCallback) {
810
+ this.onChangeCallback();
811
+ }
812
+ if (this.parentChangeCallback) {
813
+ this.parentChangeCallback();
814
+ }
815
+ };
816
+ QueryBuilderComponent.prototype.handleTouched = function () {
817
+ if (this.onTouchedCallback) {
818
+ this.onTouchedCallback();
819
+ }
820
+ if (this.parentTouchedCallback) {
821
+ this.parentTouchedCallback();
822
+ }
823
+ };
824
+ return QueryBuilderComponent;
825
+ }());
826
+ QueryBuilderComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryBuilderComponent, deps: [{ token: i0__namespace.ChangeDetectorRef }], target: i0__namespace.ɵɵFactoryTarget.Component });
827
+ QueryBuilderComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.2.13", type: QueryBuilderComponent, selector: "query-builder", inputs: { disabled: "disabled", data: "data", allowRuleset: "allowRuleset", allowCollapse: "allowCollapse", emptyMessage: "emptyMessage", classNames: "classNames", operatorMap: "operatorMap", parentValue: "parentValue", config: "config", parentArrowIconTemplate: "parentArrowIconTemplate", parentInputTemplates: "parentInputTemplates", parentOperatorTemplate: "parentOperatorTemplate", parentFieldTemplate: "parentFieldTemplate", parentEntityTemplate: "parentEntityTemplate", parentSwitchGroupTemplate: "parentSwitchGroupTemplate", parentButtonGroupTemplate: "parentButtonGroupTemplate", parentRemoveButtonTemplate: "parentRemoveButtonTemplate", parentEmptyWarningTemplate: "parentEmptyWarningTemplate", parentChangeCallback: "parentChangeCallback", parentTouchedCallback: "parentTouchedCallback", persistValueOnFieldChange: "persistValueOnFieldChange", value: "value" }, providers: [CONTROL_VALUE_ACCESSOR, VALIDATOR], queries: [{ propertyName: "buttonGroupTemplate", first: true, predicate: QueryButtonGroupDirective, descendants: true }, { propertyName: "switchGroupTemplate", first: true, predicate: QuerySwitchGroupDirective, descendants: true }, { propertyName: "fieldTemplate", first: true, predicate: QueryFieldDirective, descendants: true }, { propertyName: "entityTemplate", first: true, predicate: QueryEntityDirective, descendants: true }, { propertyName: "operatorTemplate", first: true, predicate: QueryOperatorDirective, descendants: true }, { propertyName: "removeButtonTemplate", first: true, predicate: QueryRemoveButtonDirective, descendants: true }, { propertyName: "emptyWarningTemplate", first: true, predicate: QueryEmptyWarningDirective, descendants: true }, { propertyName: "arrowIconTemplate", first: true, predicate: QueryArrowIconDirective, descendants: true }, { propertyName: "inputTemplates", predicate: QueryInputDirective }], viewQueries: [{ propertyName: "treeContainer", first: true, predicate: ["treeContainer"], descendants: true, static: true }], usesOnChanges: true, ngImport: i0__namespace, 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' : '')\">\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' : '')\">\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\" 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>\n", styles: ["@charset \"UTF-8\";:host{display:block;width:100%}:host .q-icon{font-style:normal;font-size:12px}:host .q-remove-icon:before{content:\"\\274c\"}:host .q-arrow-icon-button{float:left;margin:4px 6px 4px 0;transform:rotate(90deg);transition:linear .25s transform;cursor:pointer}:host .q-arrow-icon-button.q-collapsed{transform:rotate(0)}:host .q-arrow-icon:before{content:\"\\25b6\"}:host .q-add-icon{color:#555}:host .q-add-icon:before{content:\"\\2795\"}:host .q-remove-button{color:#b3415d;width:31px}:host .q-switch-group,:host .q-button-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-input-control,:host .q-operator-control,:host .q-field-control,:host .q-entity-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;min-width:180px}:host .q-input-control:disabled,:host .q-operator-control:disabled,:host .q-field-control:disabled,:host .q-entity-control:disabled{border-color:transparent}:host .q-operator-control,:host .q-field-control,:host .q-entity-control,:host .q-input-control:not([type=checkbox]){min-height:32px;-webkit-appearance:none}:host .q-switch-label,:host .q-button{float:left;margin-bottom:0;font-size:14px;line-height:30px;font-weight:normal;text-align:center;text-shadow:none;border:1px solid rgba(0,0,0,.2);box-sizing:border-box}:host .q-switch-label:hover,:host .q-button: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:white;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:white}:host .q-transition{transition:all .1s ease-in-out}:host .q-tree-container{width:100%;overflow:hidden;transition:ease-in .25s max-height}: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:before,:host .q-connector:after{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}\n"], components: [{ type: QueryBuilderComponent, selector: "query-builder", inputs: ["disabled", "data", "allowRuleset", "allowCollapse", "emptyMessage", "classNames", "operatorMap", "parentValue", "config", "parentArrowIconTemplate", "parentInputTemplates", "parentOperatorTemplate", "parentFieldTemplate", "parentEntityTemplate", "parentSwitchGroupTemplate", "parentButtonGroupTemplate", "parentRemoveButtonTemplate", "parentEmptyWarningTemplate", "parentChangeCallback", "parentTouchedCallback", "persistValueOnFieldChange", "value"] }], directives: [{ type: i1__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i1__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1__namespace.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i2__namespace.RadioControlValueAccessor, selector: "input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]", inputs: ["name", "formControlName", "value"] }, { type: i2__namespace.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i2__namespace.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2__namespace.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i1__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2__namespace.SelectControlValueAccessor, selector: "select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]", inputs: ["compareWith"] }, { type: i2__namespace.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2__namespace.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i1__namespace.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i1__namespace.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i2__namespace.NumberValueAccessor, selector: "input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]" }, { type: i2__namespace.SelectMultipleControlValueAccessor, selector: "select[multiple][formControlName],select[multiple][formControl],select[multiple][ngModel]", inputs: ["compareWith"] }, { type: i2__namespace.CheckboxControlValueAccessor, selector: "input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]" }] });
828
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryBuilderComponent, decorators: [{
829
+ type: i0.Component,
830
+ args: [{
831
+ selector: 'query-builder',
832
+ templateUrl: './query-builder.component.html',
833
+ styleUrls: ['./query-builder.component.scss'],
834
+ providers: [CONTROL_VALUE_ACCESSOR, VALIDATOR]
835
+ }]
836
+ }], ctorParameters: function () { return [{ type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { disabled: [{
837
+ type: i0.Input
838
+ }], data: [{
839
+ type: i0.Input
840
+ }], allowRuleset: [{
841
+ type: i0.Input
842
+ }], allowCollapse: [{
843
+ type: i0.Input
844
+ }], emptyMessage: [{
845
+ type: i0.Input
846
+ }], classNames: [{
847
+ type: i0.Input
848
+ }], operatorMap: [{
849
+ type: i0.Input
850
+ }], parentValue: [{
851
+ type: i0.Input
852
+ }], config: [{
853
+ type: i0.Input
854
+ }], parentArrowIconTemplate: [{
855
+ type: i0.Input
856
+ }], parentInputTemplates: [{
857
+ type: i0.Input
858
+ }], parentOperatorTemplate: [{
859
+ type: i0.Input
860
+ }], parentFieldTemplate: [{
861
+ type: i0.Input
862
+ }], parentEntityTemplate: [{
863
+ type: i0.Input
864
+ }], parentSwitchGroupTemplate: [{
865
+ type: i0.Input
866
+ }], parentButtonGroupTemplate: [{
867
+ type: i0.Input
868
+ }], parentRemoveButtonTemplate: [{
869
+ type: i0.Input
870
+ }], parentEmptyWarningTemplate: [{
871
+ type: i0.Input
872
+ }], parentChangeCallback: [{
873
+ type: i0.Input
874
+ }], parentTouchedCallback: [{
875
+ type: i0.Input
876
+ }], persistValueOnFieldChange: [{
877
+ type: i0.Input
878
+ }], treeContainer: [{
879
+ type: i0.ViewChild,
880
+ args: ['treeContainer', { static: true }]
881
+ }], buttonGroupTemplate: [{
882
+ type: i0.ContentChild,
883
+ args: [QueryButtonGroupDirective]
884
+ }], switchGroupTemplate: [{
885
+ type: i0.ContentChild,
886
+ args: [QuerySwitchGroupDirective]
887
+ }], fieldTemplate: [{
888
+ type: i0.ContentChild,
889
+ args: [QueryFieldDirective]
890
+ }], entityTemplate: [{
891
+ type: i0.ContentChild,
892
+ args: [QueryEntityDirective]
893
+ }], operatorTemplate: [{
894
+ type: i0.ContentChild,
895
+ args: [QueryOperatorDirective]
896
+ }], removeButtonTemplate: [{
897
+ type: i0.ContentChild,
898
+ args: [QueryRemoveButtonDirective]
899
+ }], emptyWarningTemplate: [{
900
+ type: i0.ContentChild,
901
+ args: [QueryEmptyWarningDirective]
902
+ }], inputTemplates: [{
903
+ type: i0.ContentChildren,
904
+ args: [QueryInputDirective]
905
+ }], arrowIconTemplate: [{
906
+ type: i0.ContentChild,
907
+ args: [QueryArrowIconDirective]
908
+ }], value: [{
909
+ type: i0.Input
910
+ }] } });
911
+
912
+ var NgxAngularQueryBuilderModule = /** @class */ (function () {
913
+ function NgxAngularQueryBuilderModule() {
914
+ }
915
+ return NgxAngularQueryBuilderModule;
916
+ }());
917
+ NgxAngularQueryBuilderModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: NgxAngularQueryBuilderModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
918
+ NgxAngularQueryBuilderModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: NgxAngularQueryBuilderModule, declarations: [QueryBuilderComponent,
919
+ QueryInputDirective,
920
+ QueryOperatorDirective,
921
+ QueryFieldDirective,
922
+ QueryEntityDirective,
923
+ QueryButtonGroupDirective,
924
+ QuerySwitchGroupDirective,
925
+ QueryRemoveButtonDirective,
926
+ QueryEmptyWarningDirective,
927
+ QueryArrowIconDirective], imports: [i1.CommonModule,
928
+ i2.FormsModule], exports: [QueryBuilderComponent,
929
+ QueryInputDirective,
930
+ QueryOperatorDirective,
931
+ QueryFieldDirective,
932
+ QueryEntityDirective,
933
+ QueryButtonGroupDirective,
934
+ QuerySwitchGroupDirective,
935
+ QueryRemoveButtonDirective,
936
+ QueryEmptyWarningDirective,
937
+ QueryArrowIconDirective] });
938
+ NgxAngularQueryBuilderModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: NgxAngularQueryBuilderModule, imports: [[
939
+ i1.CommonModule,
940
+ i2.FormsModule
941
+ ]] });
942
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: NgxAngularQueryBuilderModule, decorators: [{
943
+ type: i0.NgModule,
944
+ args: [{
945
+ imports: [
946
+ i1.CommonModule,
947
+ i2.FormsModule
948
+ ],
949
+ declarations: [
950
+ QueryBuilderComponent,
951
+ QueryInputDirective,
952
+ QueryOperatorDirective,
953
+ QueryFieldDirective,
954
+ QueryEntityDirective,
955
+ QueryButtonGroupDirective,
956
+ QuerySwitchGroupDirective,
957
+ QueryRemoveButtonDirective,
958
+ QueryEmptyWarningDirective,
959
+ QueryArrowIconDirective
960
+ ],
961
+ exports: [
962
+ QueryBuilderComponent,
963
+ QueryInputDirective,
964
+ QueryOperatorDirective,
965
+ QueryFieldDirective,
966
+ QueryEntityDirective,
967
+ QueryButtonGroupDirective,
968
+ QuerySwitchGroupDirective,
969
+ QueryRemoveButtonDirective,
970
+ QueryEmptyWarningDirective,
971
+ QueryArrowIconDirective
972
+ ]
973
+ }]
974
+ }] });
975
+
976
+ /*
977
+ * Public API Surface of ngx-angular-query-builder
978
+ */
979
+
980
+ /**
981
+ * Generated bundle index. Do not edit.
982
+ */
983
+
984
+ exports.CONTROL_VALUE_ACCESSOR = CONTROL_VALUE_ACCESSOR;
985
+ exports.NgxAngularQueryBuilderModule = NgxAngularQueryBuilderModule;
986
+ exports.QueryArrowIconDirective = QueryArrowIconDirective;
987
+ exports.QueryBuilderComponent = QueryBuilderComponent;
988
+ exports.QueryButtonGroupDirective = QueryButtonGroupDirective;
989
+ exports.QueryEmptyWarningDirective = QueryEmptyWarningDirective;
990
+ exports.QueryEntityDirective = QueryEntityDirective;
991
+ exports.QueryFieldDirective = QueryFieldDirective;
992
+ exports.QueryInputDirective = QueryInputDirective;
993
+ exports.QueryOperatorDirective = QueryOperatorDirective;
994
+ exports.QueryRemoveButtonDirective = QueryRemoveButtonDirective;
995
+ exports.QuerySwitchGroupDirective = QuerySwitchGroupDirective;
996
+ exports.VALIDATOR = VALIDATOR;
997
+
998
+ Object.defineProperty(exports, '__esModule', { value: true });
999
+
1000
+ }));
1001
+ //# sourceMappingURL=ngx-angular-query-builder.umd.js.map