ngx-angular-query-builder 0.0.4 → 13.0.0

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 (25) hide show
  1. package/{esm2015/lib/ngx-angular-query-builder.module.js → esm2020/lib/ngx-angular-query-builder.module.mjs} +4 -4
  2. package/{esm2015/lib/query-builder/query-arrow-icon.directive.js → esm2020/lib/query-builder/query-arrow-icon.directive.mjs} +3 -3
  3. package/esm2020/lib/query-builder/query-builder.component.mjs +748 -0
  4. package/{esm2015/lib/query-builder/query-builder.interfaces.js → esm2020/lib/query-builder/query-builder.interfaces.mjs} +1 -1
  5. package/{esm2015/lib/query-builder/query-button-group.directive.js → esm2020/lib/query-builder/query-button-group.directive.mjs} +3 -3
  6. package/{esm2015/lib/query-builder/query-empty-warning.directive.js → esm2020/lib/query-builder/query-empty-warning.directive.mjs} +3 -3
  7. package/{esm2015/lib/query-builder/query-entity.directive.js → esm2020/lib/query-builder/query-entity.directive.mjs} +3 -3
  8. package/{esm2015/lib/query-builder/query-field.directive.js → esm2020/lib/query-builder/query-field.directive.mjs} +3 -3
  9. package/{esm2015/lib/query-builder/query-input.directive.js → esm2020/lib/query-builder/query-input.directive.mjs} +3 -3
  10. package/{esm2015/lib/query-builder/query-operator.directive.js → esm2020/lib/query-builder/query-operator.directive.mjs} +3 -3
  11. package/{esm2015/lib/query-builder/query-remove-button.directive.js → esm2020/lib/query-builder/query-remove-button.directive.mjs} +3 -3
  12. package/{esm2015/lib/query-builder/query-switch-group.directive.js → esm2020/lib/query-builder/query-switch-group.directive.mjs} +3 -3
  13. package/{esm2015/ngx-angular-query-builder.js → esm2020/ngx-angular-query-builder.mjs} +0 -0
  14. package/{esm2015/public-api.js → esm2020/public-api.mjs} +0 -0
  15. package/fesm2015/{ngx-angular-query-builder.js → ngx-angular-query-builder.mjs} +37 -43
  16. package/fesm2015/ngx-angular-query-builder.mjs.map +1 -0
  17. package/fesm2020/ngx-angular-query-builder.mjs +932 -0
  18. package/fesm2020/ngx-angular-query-builder.mjs.map +1 -0
  19. package/lib/query-builder/query-builder.component.d.ts +1 -1
  20. package/lib/query-builder/query-builder.interfaces.d.ts +1 -1
  21. package/package.json +21 -8
  22. package/bundles/ngx-angular-query-builder.umd.js +0 -1012
  23. package/bundles/ngx-angular-query-builder.umd.js.map +0 -1
  24. package/esm2015/lib/query-builder/query-builder.component.js +0 -755
  25. package/fesm2015/ngx-angular-query-builder.js.map +0 -1
@@ -1,1012 +0,0 @@
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: 'and', 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: 'and', 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
- Object.defineProperty(QueryBuilderComponent.prototype, "condintion", {
247
- get: function () {
248
- var _a;
249
- return (_a = this.data) === null || _a === void 0 ? void 0 : _a.condition;
250
- },
251
- enumerable: false,
252
- configurable: true
253
- });
254
- // ----------OnInit Implementation----------
255
- // ----------OnChanges Implementation----------
256
- QueryBuilderComponent.prototype.ngOnChanges = function (changes) {
257
- var config = this.config;
258
- var type = typeof config;
259
- if (type === 'object') {
260
- this.fields = Object.keys(config.fields).map(function (value) {
261
- var field = config.fields[value];
262
- field.value = field.value || value;
263
- return field;
264
- });
265
- if (config.entities) {
266
- this.entities = Object.keys(config.entities).map(function (value) {
267
- var entity = config.entities ? config.entities[value] : [];
268
- entity.value = entity.value || value;
269
- return entity;
270
- });
271
- }
272
- else {
273
- this.entities = [];
274
- }
275
- this.operatorsCache = {};
276
- }
277
- else {
278
- throw new Error("Expected 'config' must be a valid object, got " + type + " instead.");
279
- }
280
- };
281
- // ----------Validator Implementation----------
282
- QueryBuilderComponent.prototype.validate = function (control) {
283
- var errors = {};
284
- var ruleErrorStore = [];
285
- var hasErrors = false;
286
- if (!this.config.allowEmptyRulesets && this.checkEmptyRuleInRuleset(this.data)) {
287
- errors.empty = 'Empty rulesets are not allowed.';
288
- hasErrors = true;
289
- }
290
- this.validateRulesInRuleset(this.data, ruleErrorStore);
291
- if (ruleErrorStore.length) {
292
- errors.rules = ruleErrorStore;
293
- hasErrors = true;
294
- }
295
- return hasErrors ? errors : null;
296
- };
297
- Object.defineProperty(QueryBuilderComponent.prototype, "value", {
298
- // ----------ControlValueAccessor Implementation----------
299
- get: function () {
300
- return this.data;
301
- },
302
- set: function (value) {
303
- // When component is initialized without a formControl, null is passed to value
304
- this.data = value || { condition: 'and', rules: [] };
305
- this.handleDataChange();
306
- },
307
- enumerable: false,
308
- configurable: true
309
- });
310
- QueryBuilderComponent.prototype.writeValue = function (obj) {
311
- this.value = obj;
312
- };
313
- QueryBuilderComponent.prototype.registerOnChange = function (fn) {
314
- var _this = this;
315
- this.onChangeCallback = function () { return fn(_this.data); };
316
- };
317
- QueryBuilderComponent.prototype.registerOnTouched = function (fn) {
318
- var _this = this;
319
- this.onTouchedCallback = function () { return fn(_this.data); };
320
- };
321
- QueryBuilderComponent.prototype.setDisabledState = function (isDisabled) {
322
- this.disabled = isDisabled;
323
- this.changeDetectorRef.detectChanges();
324
- };
325
- QueryBuilderComponent.prototype.findTemplateForRule = function (rule) {
326
- var type = this.getInputType(rule.field, rule.operator);
327
- if (type) {
328
- var queryInput = this.findQueryInput(type);
329
- if (queryInput) {
330
- return queryInput.template;
331
- }
332
- else {
333
- if (this.defaultTemplateTypes.indexOf(type) === -1) {
334
- console.warn("Could not find template for field with type: " + type);
335
- }
336
- return null;
337
- }
338
- }
339
- };
340
- QueryBuilderComponent.prototype.findQueryInput = function (type) {
341
- var templates = this.parentInputTemplates || this.inputTemplates;
342
- return templates.find(function (item) { return item.queryInputType === type; });
343
- };
344
- QueryBuilderComponent.prototype.getOperators = function (field) {
345
- if (this.operatorsCache[field]) {
346
- return this.operatorsCache[field];
347
- }
348
- var operators = this.defaultEmptyList;
349
- var fieldObject = this.config.fields[field];
350
- if (this.config.getOperators) {
351
- return this.config.getOperators(field, fieldObject);
352
- }
353
- var type = fieldObject.type;
354
- if (fieldObject && fieldObject.operators) {
355
- operators = fieldObject.operators;
356
- }
357
- else if (type) {
358
- operators = (this.operatorMap && this.operatorMap[type]) || this.defaultOperatorMap[type] || this.defaultEmptyList;
359
- if (operators.length === 0) {
360
- console.warn("No operators found for field '" + field + "' with type " + fieldObject.type + ". " +
361
- "Please define an 'operators' property on the field or use the 'operatorMap' binding to fix this.");
362
- }
363
- if (fieldObject.nullable) {
364
- operators = operators.concat(['is null', 'is not null']);
365
- }
366
- }
367
- else {
368
- console.warn("No 'type' property found on field: '" + field + "'");
369
- }
370
- // Cache reference to array object, so it won't be computed next time and trigger a rerender.
371
- this.operatorsCache[field] = operators;
372
- return operators;
373
- };
374
- QueryBuilderComponent.prototype.getFields = function (entity) {
375
- if (this.entities.length && entity) {
376
- return this.fields.filter(function (field) {
377
- return field && field.entity === entity;
378
- });
379
- }
380
- else {
381
- return this.fields;
382
- }
383
- };
384
- QueryBuilderComponent.prototype.getInputType = function (field, operator) {
385
- if (this.config.getInputType) {
386
- return this.config.getInputType(field, operator);
387
- }
388
- if (!this.config.fields[field]) {
389
- throw new Error("No configuration for field '" + field + "' could be found! Please add it to config.fields.");
390
- }
391
- var type = this.config.fields[field].type;
392
- switch (operator) {
393
- case 'is null':
394
- case 'is not null':
395
- return null; // No displayed component
396
- case 'in':
397
- case 'not in':
398
- return type === 'category' || type === 'boolean' ? 'multiselect' : type;
399
- default:
400
- return type;
401
- }
402
- };
403
- QueryBuilderComponent.prototype.getOptions = function (field) {
404
- if (this.config.getOptions) {
405
- return this.config.getOptions(field);
406
- }
407
- return this.config.fields[field].options || this.defaultEmptyList;
408
- };
409
- QueryBuilderComponent.prototype.getClassNames = function () {
410
- var args = [];
411
- for (var _i = 0; _i < arguments.length; _i++) {
412
- args[_i] = arguments[_i];
413
- }
414
- var clsLookup = this.classNames ? this.classNames : this.defaultClassNames;
415
- var defaultClassNames = this.defaultClassNames;
416
- var classNames = args.map(function (id) { return clsLookup[id] || defaultClassNames[id]; }).filter(function (c) { return !!c; });
417
- return classNames.length ? classNames.join(' ') : [];
418
- };
419
- QueryBuilderComponent.prototype.getDefaultField = function (entity) {
420
- if (!entity) {
421
- return null;
422
- }
423
- else if (entity.defaultField !== undefined) {
424
- return this.getDefaultValue(entity.defaultField);
425
- }
426
- else {
427
- var entityFields = this.fields.filter(function (field) {
428
- return field && field.entity === entity.value;
429
- });
430
- if (entityFields && entityFields.length) {
431
- return entityFields[0];
432
- }
433
- else {
434
- console.warn("No fields found for entity '" + entity.name + "'. " +
435
- "A 'defaultOperator' is also not specified on the field config. Operator value will default to null.");
436
- return null;
437
- }
438
- }
439
- };
440
- QueryBuilderComponent.prototype.getDefaultOperator = function (field) {
441
- if (field && field.defaultOperator !== undefined) {
442
- return this.getDefaultValue(field.defaultOperator);
443
- }
444
- else {
445
- var operators = this.getOperators(field.value);
446
- if (operators && operators.length) {
447
- return operators[0];
448
- }
449
- else {
450
- console.warn("No operators found for field '" + field.value + "'. " +
451
- "A 'defaultOperator' is also not specified on the field config. Operator value will default to null.");
452
- return null;
453
- }
454
- }
455
- };
456
- QueryBuilderComponent.prototype.addRule = function (parent) {
457
- if (this.disabled) {
458
- return;
459
- }
460
- parent = parent || this.data;
461
- if (this.config.addRule) {
462
- this.config.addRule(parent);
463
- }
464
- else {
465
- var field = this.fields[0];
466
- parent.rules = parent.rules.concat([{
467
- field: field.value,
468
- operator: this.getDefaultOperator(field),
469
- value: this.getDefaultValue(field.defaultValue),
470
- entity: field.entity
471
- }]);
472
- }
473
- this.handleTouched();
474
- this.handleDataChange();
475
- };
476
- QueryBuilderComponent.prototype.removeRule = function (rule, parent) {
477
- if (this.disabled) {
478
- return;
479
- }
480
- parent = parent || this.data;
481
- if (this.config.removeRule) {
482
- this.config.removeRule(rule, parent);
483
- }
484
- else {
485
- parent.rules = parent.rules.filter(function (r) { return r !== rule; });
486
- }
487
- this.inputContextCache.delete(rule);
488
- this.operatorContextCache.delete(rule);
489
- this.fieldContextCache.delete(rule);
490
- this.entityContextCache.delete(rule);
491
- this.removeButtonContextCache.delete(rule);
492
- this.handleTouched();
493
- this.handleDataChange();
494
- };
495
- QueryBuilderComponent.prototype.addRuleSet = function (parent) {
496
- if (this.disabled) {
497
- return;
498
- }
499
- parent = parent || this.data;
500
- if (this.config.addRuleSet) {
501
- this.config.addRuleSet(parent);
502
- }
503
- else {
504
- parent.rules = parent.rules.concat([{ condition: 'and', rules: [] }]);
505
- }
506
- this.handleTouched();
507
- this.handleDataChange();
508
- };
509
- QueryBuilderComponent.prototype.removeRuleSet = function (ruleset, parent) {
510
- if (this.disabled) {
511
- return;
512
- }
513
- ruleset = ruleset || this.data;
514
- parent = parent || this.parentValue;
515
- if (this.config.removeRuleSet) {
516
- this.config.removeRuleSet(ruleset, parent);
517
- }
518
- else {
519
- parent.rules = parent.rules.filter(function (r) { return r !== ruleset; });
520
- }
521
- this.handleTouched();
522
- this.handleDataChange();
523
- };
524
- QueryBuilderComponent.prototype.transitionEnd = function (e) {
525
- this.treeContainer.nativeElement.style.maxHeight = null;
526
- };
527
- QueryBuilderComponent.prototype.toggleCollapse = function () {
528
- var _this = this;
529
- this.computedTreeContainerHeight();
530
- setTimeout(function () {
531
- _this.data.collapsed = !_this.data.collapsed;
532
- }, 100);
533
- };
534
- QueryBuilderComponent.prototype.computedTreeContainerHeight = function () {
535
- var nativeElement = this.treeContainer.nativeElement;
536
- if (nativeElement && nativeElement.firstElementChild) {
537
- nativeElement.style.maxHeight = (nativeElement.firstElementChild.clientHeight + 8) + 'px';
538
- }
539
- };
540
- QueryBuilderComponent.prototype.changeCondition = function (value) {
541
- if (this.disabled) {
542
- return;
543
- }
544
- this.data.condition = value;
545
- this.handleTouched();
546
- this.handleDataChange();
547
- };
548
- QueryBuilderComponent.prototype.changeOperator = function (rule) {
549
- if (this.disabled) {
550
- return;
551
- }
552
- if (this.config.coerceValueForOperator) {
553
- rule.value = this.config.coerceValueForOperator(rule.operator, rule.value, rule);
554
- }
555
- else {
556
- rule.value = this.coerceValueForOperator(rule.operator, rule.value, rule);
557
- }
558
- this.handleTouched();
559
- this.handleDataChange();
560
- };
561
- QueryBuilderComponent.prototype.coerceValueForOperator = function (operator, value, rule) {
562
- var inputType = this.getInputType(rule.field, operator);
563
- if (inputType === 'multiselect' && !Array.isArray(value)) {
564
- return [value];
565
- }
566
- return value;
567
- };
568
- QueryBuilderComponent.prototype.changeInput = function () {
569
- if (this.disabled) {
570
- return;
571
- }
572
- this.handleTouched();
573
- this.handleDataChange();
574
- };
575
- QueryBuilderComponent.prototype.changeField = function (fieldValue, rule) {
576
- if (this.disabled) {
577
- return;
578
- }
579
- var inputContext = this.inputContextCache.get(rule);
580
- var currentField = inputContext && inputContext.field;
581
- var nextField = this.config.fields[fieldValue];
582
- var nextValue = this.calculateFieldChangeValue(currentField, nextField, rule.value);
583
- if (nextValue !== undefined) {
584
- rule.value = nextValue;
585
- }
586
- else {
587
- delete rule.value;
588
- }
589
- rule.operator = this.getDefaultOperator(nextField);
590
- // Create new context objects so templates will automatically update
591
- this.inputContextCache.delete(rule);
592
- this.operatorContextCache.delete(rule);
593
- this.fieldContextCache.delete(rule);
594
- this.entityContextCache.delete(rule);
595
- this.getInputContext(rule);
596
- this.getFieldContext(rule);
597
- this.getOperatorContext(rule);
598
- this.getEntityContext(rule);
599
- this.handleTouched();
600
- this.handleDataChange();
601
- };
602
- QueryBuilderComponent.prototype.changeEntity = function (entityValue, rule, index, data) {
603
- if (this.disabled) {
604
- return;
605
- }
606
- var i = index;
607
- var rs = data;
608
- var entity = this.entities.find(function (e) { return e.value === entityValue; });
609
- var defaultField = this.getDefaultField(entity);
610
- if (!rs) {
611
- rs = this.data;
612
- i = rs.rules.findIndex(function (x) { return x === rule; });
613
- }
614
- rule.field = defaultField.value;
615
- rs.rules[i] = rule;
616
- if (defaultField) {
617
- this.changeField(defaultField.value, rule);
618
- }
619
- else {
620
- this.handleTouched();
621
- this.handleDataChange();
622
- }
623
- };
624
- QueryBuilderComponent.prototype.getDefaultValue = function (defaultValue) {
625
- switch (typeof defaultValue) {
626
- case 'function':
627
- return defaultValue();
628
- default:
629
- return defaultValue;
630
- }
631
- };
632
- QueryBuilderComponent.prototype.getOperatorTemplate = function () {
633
- var t = this.parentOperatorTemplate || this.operatorTemplate;
634
- return t ? t.template : null;
635
- };
636
- QueryBuilderComponent.prototype.getFieldTemplate = function () {
637
- var t = this.parentFieldTemplate || this.fieldTemplate;
638
- return t ? t.template : null;
639
- };
640
- QueryBuilderComponent.prototype.getEntityTemplate = function () {
641
- var t = this.parentEntityTemplate || this.entityTemplate;
642
- return t ? t.template : null;
643
- };
644
- QueryBuilderComponent.prototype.getArrowIconTemplate = function () {
645
- var t = this.parentArrowIconTemplate || this.arrowIconTemplate;
646
- return t ? t.template : null;
647
- };
648
- QueryBuilderComponent.prototype.getButtonGroupTemplate = function () {
649
- var t = this.parentButtonGroupTemplate || this.buttonGroupTemplate;
650
- return t ? t.template : null;
651
- };
652
- QueryBuilderComponent.prototype.getSwitchGroupTemplate = function () {
653
- var t = this.parentSwitchGroupTemplate || this.switchGroupTemplate;
654
- return t ? t.template : null;
655
- };
656
- QueryBuilderComponent.prototype.getRemoveButtonTemplate = function () {
657
- var t = this.parentRemoveButtonTemplate || this.removeButtonTemplate;
658
- return t ? t.template : null;
659
- };
660
- QueryBuilderComponent.prototype.getEmptyWarningTemplate = function () {
661
- var t = this.parentEmptyWarningTemplate || this.emptyWarningTemplate;
662
- return t ? t.template : null;
663
- };
664
- QueryBuilderComponent.prototype.getQueryItemClassName = function (local) {
665
- var cls = this.getClassNames('row', 'connector', 'transition');
666
- cls += ' ' + this.getClassNames(local.ruleset ? 'ruleSet' : 'rule');
667
- if (local.invalid) {
668
- cls += ' ' + this.getClassNames('invalidRuleSet');
669
- }
670
- return cls;
671
- };
672
- QueryBuilderComponent.prototype.getButtonGroupContext = function () {
673
- if (!this.buttonGroupContext) {
674
- this.buttonGroupContext = {
675
- addRule: this.addRule.bind(this),
676
- addRuleSet: this.allowRuleset && this.addRuleSet.bind(this),
677
- removeRuleSet: this.allowRuleset && this.parentValue && this.removeRuleSet.bind(this),
678
- getDisabledState: this.getDisabledState,
679
- $implicit: this.data
680
- };
681
- }
682
- return this.buttonGroupContext;
683
- };
684
- QueryBuilderComponent.prototype.getRemoveButtonContext = function (rule) {
685
- if (!this.removeButtonContextCache.has(rule)) {
686
- this.removeButtonContextCache.set(rule, {
687
- removeRule: this.removeRule.bind(this),
688
- getDisabledState: this.getDisabledState,
689
- $implicit: rule
690
- });
691
- }
692
- return this.removeButtonContextCache.get(rule);
693
- };
694
- QueryBuilderComponent.prototype.getFieldContext = function (rule) {
695
- if (!this.fieldContextCache.has(rule)) {
696
- this.fieldContextCache.set(rule, {
697
- onChange: this.changeField.bind(this),
698
- getFields: this.getFields.bind(this),
699
- getDisabledState: this.getDisabledState,
700
- fields: this.fields,
701
- $implicit: rule
702
- });
703
- }
704
- return this.fieldContextCache.get(rule);
705
- };
706
- QueryBuilderComponent.prototype.getEntityContext = function (rule) {
707
- if (!this.entityContextCache.has(rule)) {
708
- this.entityContextCache.set(rule, {
709
- onChange: this.changeEntity.bind(this),
710
- getDisabledState: this.getDisabledState,
711
- entities: this.entities,
712
- $implicit: rule
713
- });
714
- }
715
- return this.entityContextCache.get(rule);
716
- };
717
- QueryBuilderComponent.prototype.getSwitchGroupContext = function () {
718
- return {
719
- onChange: this.changeCondition.bind(this),
720
- getDisabledState: this.getDisabledState,
721
- $implicit: this.data
722
- };
723
- };
724
- QueryBuilderComponent.prototype.getArrowIconContext = function () {
725
- return {
726
- getDisabledState: this.getDisabledState,
727
- $implicit: this.data
728
- };
729
- };
730
- QueryBuilderComponent.prototype.getEmptyWarningContext = function () {
731
- return {
732
- getDisabledState: this.getDisabledState,
733
- message: this.emptyMessage,
734
- $implicit: this.data
735
- };
736
- };
737
- QueryBuilderComponent.prototype.getOperatorContext = function (rule) {
738
- if (!this.operatorContextCache.has(rule)) {
739
- this.operatorContextCache.set(rule, {
740
- onChange: this.changeOperator.bind(this),
741
- getDisabledState: this.getDisabledState,
742
- operators: this.getOperators(rule.field),
743
- $implicit: rule
744
- });
745
- }
746
- return this.operatorContextCache.get(rule);
747
- };
748
- QueryBuilderComponent.prototype.getInputContext = function (rule) {
749
- if (!this.inputContextCache.has(rule)) {
750
- this.inputContextCache.set(rule, {
751
- onChange: this.changeInput.bind(this),
752
- getDisabledState: this.getDisabledState,
753
- options: this.getOptions(rule.field),
754
- field: this.config.fields[rule.field],
755
- $implicit: rule
756
- });
757
- }
758
- return this.inputContextCache.get(rule);
759
- };
760
- QueryBuilderComponent.prototype.calculateFieldChangeValue = function (currentField, nextField, currentValue) {
761
- var _this = this;
762
- if (this.config.calculateFieldChangeValue != null) {
763
- return this.config.calculateFieldChangeValue(currentField, nextField, currentValue);
764
- }
765
- var canKeepValue = function () {
766
- if (currentField == null || nextField == null) {
767
- return false;
768
- }
769
- return currentField.type === nextField.type
770
- && _this.defaultPersistValueTypes.indexOf(currentField.type) !== -1;
771
- };
772
- if (this.persistValueOnFieldChange && canKeepValue()) {
773
- return currentValue;
774
- }
775
- if (nextField && nextField.defaultValue !== undefined) {
776
- return this.getDefaultValue(nextField.defaultValue);
777
- }
778
- return undefined;
779
- };
780
- QueryBuilderComponent.prototype.checkEmptyRuleInRuleset = function (ruleset) {
781
- var _this = this;
782
- if (!ruleset || !ruleset.rules || ruleset.rules.length === 0) {
783
- return true;
784
- }
785
- else {
786
- return ruleset.rules.some(function (item) {
787
- if (item.rules) {
788
- return _this.checkEmptyRuleInRuleset(item);
789
- }
790
- else {
791
- return false;
792
- }
793
- });
794
- }
795
- };
796
- QueryBuilderComponent.prototype.validateRulesInRuleset = function (ruleset, errorStore) {
797
- var _this = this;
798
- if (ruleset && ruleset.rules && ruleset.rules.length > 0) {
799
- ruleset.rules.forEach(function (item) {
800
- if (item.rules) {
801
- return _this.validateRulesInRuleset(item, errorStore);
802
- }
803
- else if (item.field) {
804
- var field = _this.config.fields[item.field];
805
- if (field && field.validator && field.validator.apply) {
806
- var error = field.validator(item, ruleset);
807
- if (error != null) {
808
- errorStore.push(error);
809
- }
810
- }
811
- }
812
- });
813
- }
814
- };
815
- QueryBuilderComponent.prototype.handleDataChange = function () {
816
- this.changeDetectorRef.markForCheck();
817
- if (this.onChangeCallback) {
818
- this.onChangeCallback();
819
- }
820
- if (this.parentChangeCallback) {
821
- this.parentChangeCallback();
822
- }
823
- };
824
- QueryBuilderComponent.prototype.handleTouched = function () {
825
- if (this.onTouchedCallback) {
826
- this.onTouchedCallback();
827
- }
828
- if (this.parentTouchedCallback) {
829
- this.parentTouchedCallback();
830
- }
831
- };
832
- return QueryBuilderComponent;
833
- }());
834
- 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 });
835
- 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" }, host: { properties: { "attr.query-builder-condition": "this.condintion" } }, 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, descendants: true }], 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]" }] });
836
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: QueryBuilderComponent, decorators: [{
837
- type: i0.Component,
838
- args: [{
839
- selector: 'query-builder',
840
- templateUrl: './query-builder.component.html',
841
- styleUrls: ['./query-builder.component.scss'],
842
- providers: [CONTROL_VALUE_ACCESSOR, VALIDATOR]
843
- }]
844
- }], ctorParameters: function () { return [{ type: i0__namespace.ChangeDetectorRef }]; }, propDecorators: { disabled: [{
845
- type: i0.Input
846
- }], data: [{
847
- type: i0.Input
848
- }], condintion: [{
849
- type: i0.HostBinding,
850
- args: ['attr.query-builder-condition']
851
- }], allowRuleset: [{
852
- type: i0.Input
853
- }], allowCollapse: [{
854
- type: i0.Input
855
- }], emptyMessage: [{
856
- type: i0.Input
857
- }], classNames: [{
858
- type: i0.Input
859
- }], operatorMap: [{
860
- type: i0.Input
861
- }], parentValue: [{
862
- type: i0.Input
863
- }], config: [{
864
- type: i0.Input
865
- }], parentArrowIconTemplate: [{
866
- type: i0.Input
867
- }], parentInputTemplates: [{
868
- type: i0.Input
869
- }], parentOperatorTemplate: [{
870
- type: i0.Input
871
- }], parentFieldTemplate: [{
872
- type: i0.Input
873
- }], parentEntityTemplate: [{
874
- type: i0.Input
875
- }], parentSwitchGroupTemplate: [{
876
- type: i0.Input
877
- }], parentButtonGroupTemplate: [{
878
- type: i0.Input
879
- }], parentRemoveButtonTemplate: [{
880
- type: i0.Input
881
- }], parentEmptyWarningTemplate: [{
882
- type: i0.Input
883
- }], parentChangeCallback: [{
884
- type: i0.Input
885
- }], parentTouchedCallback: [{
886
- type: i0.Input
887
- }], persistValueOnFieldChange: [{
888
- type: i0.Input
889
- }], treeContainer: [{
890
- type: i0.ViewChild,
891
- args: ['treeContainer', { static: true }]
892
- }], buttonGroupTemplate: [{
893
- type: i0.ContentChild,
894
- args: [QueryButtonGroupDirective]
895
- }], switchGroupTemplate: [{
896
- type: i0.ContentChild,
897
- args: [QuerySwitchGroupDirective]
898
- }], fieldTemplate: [{
899
- type: i0.ContentChild,
900
- args: [QueryFieldDirective]
901
- }], entityTemplate: [{
902
- type: i0.ContentChild,
903
- args: [QueryEntityDirective]
904
- }], operatorTemplate: [{
905
- type: i0.ContentChild,
906
- args: [QueryOperatorDirective]
907
- }], removeButtonTemplate: [{
908
- type: i0.ContentChild,
909
- args: [QueryRemoveButtonDirective]
910
- }], emptyWarningTemplate: [{
911
- type: i0.ContentChild,
912
- args: [QueryEmptyWarningDirective]
913
- }], inputTemplates: [{
914
- type: i0.ContentChildren,
915
- args: [QueryInputDirective, { descendants: true }]
916
- }], arrowIconTemplate: [{
917
- type: i0.ContentChild,
918
- args: [QueryArrowIconDirective]
919
- }], value: [{
920
- type: i0.Input
921
- }] } });
922
-
923
- var NgxAngularQueryBuilderModule = /** @class */ (function () {
924
- function NgxAngularQueryBuilderModule() {
925
- }
926
- return NgxAngularQueryBuilderModule;
927
- }());
928
- NgxAngularQueryBuilderModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: NgxAngularQueryBuilderModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
929
- NgxAngularQueryBuilderModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: NgxAngularQueryBuilderModule, declarations: [QueryBuilderComponent,
930
- QueryInputDirective,
931
- QueryOperatorDirective,
932
- QueryFieldDirective,
933
- QueryEntityDirective,
934
- QueryButtonGroupDirective,
935
- QuerySwitchGroupDirective,
936
- QueryRemoveButtonDirective,
937
- QueryEmptyWarningDirective,
938
- QueryArrowIconDirective], imports: [i1.CommonModule,
939
- i2.FormsModule], exports: [QueryBuilderComponent,
940
- QueryInputDirective,
941
- QueryOperatorDirective,
942
- QueryFieldDirective,
943
- QueryEntityDirective,
944
- QueryButtonGroupDirective,
945
- QuerySwitchGroupDirective,
946
- QueryRemoveButtonDirective,
947
- QueryEmptyWarningDirective,
948
- QueryArrowIconDirective] });
949
- NgxAngularQueryBuilderModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: NgxAngularQueryBuilderModule, imports: [[
950
- i1.CommonModule,
951
- i2.FormsModule
952
- ]] });
953
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.13", ngImport: i0__namespace, type: NgxAngularQueryBuilderModule, decorators: [{
954
- type: i0.NgModule,
955
- args: [{
956
- imports: [
957
- i1.CommonModule,
958
- i2.FormsModule
959
- ],
960
- declarations: [
961
- QueryBuilderComponent,
962
- QueryInputDirective,
963
- QueryOperatorDirective,
964
- QueryFieldDirective,
965
- QueryEntityDirective,
966
- QueryButtonGroupDirective,
967
- QuerySwitchGroupDirective,
968
- QueryRemoveButtonDirective,
969
- QueryEmptyWarningDirective,
970
- QueryArrowIconDirective
971
- ],
972
- exports: [
973
- QueryBuilderComponent,
974
- QueryInputDirective,
975
- QueryOperatorDirective,
976
- QueryFieldDirective,
977
- QueryEntityDirective,
978
- QueryButtonGroupDirective,
979
- QuerySwitchGroupDirective,
980
- QueryRemoveButtonDirective,
981
- QueryEmptyWarningDirective,
982
- QueryArrowIconDirective
983
- ]
984
- }]
985
- }] });
986
-
987
- /*
988
- * Public API Surface of ngx-angular-query-builder
989
- */
990
-
991
- /**
992
- * Generated bundle index. Do not edit.
993
- */
994
-
995
- exports.CONTROL_VALUE_ACCESSOR = CONTROL_VALUE_ACCESSOR;
996
- exports.NgxAngularQueryBuilderModule = NgxAngularQueryBuilderModule;
997
- exports.QueryArrowIconDirective = QueryArrowIconDirective;
998
- exports.QueryBuilderComponent = QueryBuilderComponent;
999
- exports.QueryButtonGroupDirective = QueryButtonGroupDirective;
1000
- exports.QueryEmptyWarningDirective = QueryEmptyWarningDirective;
1001
- exports.QueryEntityDirective = QueryEntityDirective;
1002
- exports.QueryFieldDirective = QueryFieldDirective;
1003
- exports.QueryInputDirective = QueryInputDirective;
1004
- exports.QueryOperatorDirective = QueryOperatorDirective;
1005
- exports.QueryRemoveButtonDirective = QueryRemoveButtonDirective;
1006
- exports.QuerySwitchGroupDirective = QuerySwitchGroupDirective;
1007
- exports.VALIDATOR = VALIDATOR;
1008
-
1009
- Object.defineProperty(exports, '__esModule', { value: true });
1010
-
1011
- }));
1012
- //# sourceMappingURL=ngx-angular-query-builder.umd.js.map