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