@limetech/lime-crm-building-blocks 1.99.0 → 1.100.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 (106) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/lime-crm-building-blocks.cjs.js +1 -1
  3. package/dist/cjs/limebb-lime-query-builder.cjs.entry.js +52 -216
  4. package/dist/cjs/{limebb-limetype-field_2.cjs.entry.js → limebb-lime-query-filter-builder_3.cjs.entry.js} +72 -1
  5. package/dist/cjs/limebb-lime-query-filter-comparison_2.cjs.entry.js +1 -1
  6. package/dist/cjs/{limebb-lime-query-filter-group_4.cjs.entry.js → limebb-lime-query-filter-group_3.cjs.entry.js} +5 -231
  7. package/dist/cjs/limebb-live-docs-info.cjs.entry.js +2 -2
  8. package/dist/cjs/limebb-locale-picker.cjs.entry.js +1 -1
  9. package/dist/cjs/limebb-mention-group-counter.cjs.entry.js +2 -2
  10. package/dist/cjs/limebb-navigation-button_2.cjs.entry.js +3 -3
  11. package/dist/cjs/limebb-notification-item.cjs.entry.js +1 -1
  12. package/dist/cjs/limebb-percentage-visualizer.cjs.entry.js +2 -2
  13. package/dist/cjs/limebb-property-selector.cjs.entry.js +234 -0
  14. package/dist/cjs/limebb-text-editor.cjs.entry.js +1 -1
  15. package/dist/cjs/limebb-trend-indicator.cjs.entry.js +1 -1
  16. package/dist/cjs/loader.cjs.js +1 -1
  17. package/dist/collection/collection-manifest.json +1 -2
  18. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-builder.css +5 -0
  19. package/dist/collection/components/lime-query-builder/expressions/{lime-query-filter-and.js → lime-query-filter-builder.js} +59 -83
  20. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-comparison.js +1 -1
  21. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-group.js +1 -1
  22. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-not.js +1 -1
  23. package/dist/collection/components/lime-query-builder/expressions/lime-query-value-input.js +7 -7
  24. package/dist/collection/components/lime-query-builder/lime-query-builder.js +9 -39
  25. package/dist/collection/components/lime-query-builder/lime-query-validation.js +46 -19
  26. package/dist/collection/components/lime-query-builder/lime-query.types.js +1 -57
  27. package/dist/collection/components/lime-query-builder/limetype-field/limetype-field.js +1 -1
  28. package/dist/collection/components/limeobject/file-viewer/live-docs-info.js +2 -2
  29. package/dist/collection/components/locale-picker/locale-picker.js +1 -1
  30. package/dist/collection/components/notification-list/notification-item/notification-item.js +1 -1
  31. package/dist/collection/components/percentage-visualizer/percentage-visualizer.js +2 -2
  32. package/dist/collection/components/summary-popover/summary-popover.js +3 -3
  33. package/dist/collection/components/text-editor/mention-group-counter.js +2 -2
  34. package/dist/collection/components/text-editor/text-editor.js +1 -1
  35. package/dist/collection/components/trend-indicator/trend-indicator.js +1 -1
  36. package/dist/components/lime-query-filter-builder.js +129 -0
  37. package/dist/components/lime-query-filter-comparison.js +1 -1
  38. package/dist/components/lime-query-filter-expression.js +2 -2
  39. package/dist/components/lime-query-value-input.js +2 -2
  40. package/dist/components/limebb-lime-query-builder.js +60 -218
  41. package/dist/components/limebb-lime-query-filter-builder.d.ts +11 -0
  42. package/dist/components/limebb-lime-query-filter-builder.js +6 -0
  43. package/dist/components/limebb-locale-picker.js +1 -1
  44. package/dist/components/limebb-mention-group-counter.js +2 -2
  45. package/dist/components/limebb-percentage-visualizer.js +2 -2
  46. package/dist/components/limebb-text-editor.js +1 -1
  47. package/dist/components/limebb-trend-indicator.js +1 -1
  48. package/dist/components/limetype-field.js +1 -1
  49. package/dist/components/live-docs-info.js +2 -2
  50. package/dist/components/notification-item.js +1 -1
  51. package/dist/components/summary-popover.js +3 -3
  52. package/dist/esm/lime-crm-building-blocks.js +1 -1
  53. package/dist/esm/limebb-lime-query-builder.entry.js +53 -217
  54. package/dist/esm/{limebb-limetype-field_2.entry.js → limebb-lime-query-filter-builder_3.entry.js} +73 -3
  55. package/dist/esm/limebb-lime-query-filter-comparison_2.entry.js +1 -1
  56. package/dist/esm/{limebb-lime-query-filter-group_4.entry.js → limebb-lime-query-filter-group_3.entry.js} +7 -232
  57. package/dist/esm/limebb-live-docs-info.entry.js +2 -2
  58. package/dist/esm/limebb-locale-picker.entry.js +1 -1
  59. package/dist/esm/limebb-mention-group-counter.entry.js +2 -2
  60. package/dist/esm/limebb-navigation-button_2.entry.js +3 -3
  61. package/dist/esm/limebb-notification-item.entry.js +1 -1
  62. package/dist/esm/limebb-percentage-visualizer.entry.js +2 -2
  63. package/dist/esm/limebb-property-selector.entry.js +230 -0
  64. package/dist/esm/limebb-text-editor.entry.js +1 -1
  65. package/dist/esm/limebb-trend-indicator.entry.js +1 -1
  66. package/dist/esm/loader.js +1 -1
  67. package/dist/lime-crm-building-blocks/lime-crm-building-blocks.esm.js +1 -1
  68. package/dist/lime-crm-building-blocks/{p-b9b954d9.entry.js → p-1034b4a5.entry.js} +1 -1
  69. package/dist/lime-crm-building-blocks/{p-93cadc1e.entry.js → p-2048ac67.entry.js} +1 -1
  70. package/dist/lime-crm-building-blocks/p-323c49bc.entry.js +1 -0
  71. package/dist/lime-crm-building-blocks/{p-631ca5a5.entry.js → p-58782467.entry.js} +1 -1
  72. package/dist/lime-crm-building-blocks/{p-aa646df7.entry.js → p-6aa216ec.entry.js} +1 -1
  73. package/dist/lime-crm-building-blocks/{p-9cac4de2.entry.js → p-76d81eee.entry.js} +1 -1
  74. package/dist/lime-crm-building-blocks/{p-e8946134.entry.js → p-79b8b09b.entry.js} +1 -1
  75. package/dist/lime-crm-building-blocks/{p-569c86b5.entry.js → p-8581245a.entry.js} +1 -1
  76. package/dist/lime-crm-building-blocks/p-89a6c396.entry.js +1 -0
  77. package/dist/lime-crm-building-blocks/{p-36ea13c0.entry.js → p-8fb2e192.entry.js} +1 -1
  78. package/dist/lime-crm-building-blocks/{p-3122ea05.entry.js → p-b57dafef.entry.js} +1 -1
  79. package/dist/lime-crm-building-blocks/p-f22b66f6.entry.js +1 -0
  80. package/dist/lime-crm-building-blocks/p-f79e354b.entry.js +1 -0
  81. package/dist/types/components/lime-query-builder/expressions/lime-query-filter-builder.d.ts +50 -0
  82. package/dist/types/components/lime-query-builder/expressions/lime-query-value-input.d.ts +2 -3
  83. package/dist/types/components/lime-query-builder/lime-query-builder.d.ts +1 -6
  84. package/dist/types/components/lime-query-builder/lime-query.types.d.ts +0 -72
  85. package/dist/types/components.d.ts +58 -198
  86. package/package.json +1 -1
  87. package/dist/cjs/limebb-lime-query-filter-and.cjs.entry.js +0 -80
  88. package/dist/cjs/limebb-lime-query-filter-or.cjs.entry.js +0 -68
  89. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-and.css +0 -121
  90. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-or.css +0 -123
  91. package/dist/collection/components/lime-query-builder/expressions/lime-query-filter-or.js +0 -237
  92. package/dist/collection/components/lime-query-builder/filter-conversion.js +0 -255
  93. package/dist/components/limebb-lime-query-filter-and.d.ts +0 -11
  94. package/dist/components/limebb-lime-query-filter-and.js +0 -135
  95. package/dist/components/limebb-lime-query-filter-or.d.ts +0 -11
  96. package/dist/components/limebb-lime-query-filter-or.js +0 -123
  97. package/dist/esm/limebb-lime-query-filter-and.entry.js +0 -76
  98. package/dist/esm/limebb-lime-query-filter-or.entry.js +0 -64
  99. package/dist/lime-crm-building-blocks/p-03accd53.entry.js +0 -1
  100. package/dist/lime-crm-building-blocks/p-4715210d.entry.js +0 -1
  101. package/dist/lime-crm-building-blocks/p-5f7644b5.entry.js +0 -1
  102. package/dist/lime-crm-building-blocks/p-67dbaa4c.entry.js +0 -1
  103. package/dist/lime-crm-building-blocks/p-91732502.entry.js +0 -1
  104. package/dist/types/components/lime-query-builder/expressions/lime-query-filter-and.d.ts +0 -57
  105. package/dist/types/components/lime-query-builder/expressions/lime-query-filter-or.d.ts +0 -56
  106. package/dist/types/components/lime-query-builder/filter-conversion.d.ts +0 -31
@@ -1,167 +1,7 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-96dd111f.js';
2
- import { T as Te, Z as Zt } from './index.esm-bb569663.js';
2
+ import { Z as Zt, T as Te } from './index.esm-bb569663.js';
3
3
  import { g as getNormalizedProperties, a as getPropertyFromPath } from './property-resolution-fde2375e.js';
4
4
 
5
- /**
6
- * TypeScript type definitions for Lime Query DSL
7
- *
8
- * These types represent the structure of Lime Query as defined in:
9
- * - lime-core/lime_query/schema.py
10
- * - lime-core/lime_filter/schema.py
11
- */
12
- /**
13
- * Available operators with display metadata
14
- */
15
- const LIME_QUERY_OPERATORS = [
16
- { value: '=', label: 'Equals', icon: 'equals' },
17
- { value: '!=', label: 'Not Equals', icon: 'not-equal' },
18
- {
19
- value: '>',
20
- label: 'Greater Than',
21
- icon: 'greater-than',
22
- applicableTypes: ['integer', 'decimal', 'date', 'time'],
23
- },
24
- {
25
- value: '>=',
26
- label: 'Greater or Equal',
27
- icon: 'greater-or-equal',
28
- applicableTypes: ['integer', 'decimal', 'date', 'time'],
29
- },
30
- {
31
- value: '<',
32
- label: 'Less Than',
33
- icon: 'less-than',
34
- applicableTypes: ['integer', 'decimal', 'date', 'time'],
35
- },
36
- {
37
- value: '<=',
38
- label: 'Less or Equal',
39
- icon: 'less-or-equal',
40
- applicableTypes: ['integer', 'decimal', 'date', 'time'],
41
- },
42
- { value: 'IN', label: 'In List', icon: 'list' },
43
- {
44
- value: '?',
45
- label: 'Contains',
46
- icon: '-lime-filter-contain',
47
- applicableTypes: ['string', 'text'],
48
- },
49
- {
50
- value: '=?',
51
- label: 'Begins With',
52
- icon: '-lime-filter-begin',
53
- applicableTypes: ['string', 'text'],
54
- },
55
- {
56
- value: '=$',
57
- label: 'Ends With',
58
- icon: '-lime-filter-end',
59
- applicableTypes: ['string', 'text'],
60
- },
61
- ];
62
-
63
- /**
64
- * Validate and convert a FilterExpression (comparison filter)
65
- * @param filter
66
- */
67
- function validateAndConvertFilterExpression(filter) {
68
- // Validate required properties exist
69
- if (!('op' in filter) || !('exp' in filter)) {
70
- throw new Error('Invalid filter: comparison must have key, op, and exp properties');
71
- }
72
- // Validate operator is supported
73
- const supportedOps = LIME_QUERY_OPERATORS.map((o) => o.value);
74
- if (!supportedOps.includes(filter.op)) {
75
- throw new Error(`Unsupported filter operator: ${filter.op}`);
76
- }
77
- // Check for unexpected properties
78
- // Note: 'type' property is allowed for filter references
79
- const knownProps = new Set(['key', 'op', 'exp', 'type']);
80
- const unexpectedProps = Object.keys(filter).filter((k) => !knownProps.has(k));
81
- if (unexpectedProps.length > 0) {
82
- throw new Error(`Unexpected properties in filter comparison: ${unexpectedProps.join(', ')}`);
83
- }
84
- return {
85
- filter_type: 'comparison',
86
- property: filter.key,
87
- operator: filter.op,
88
- value: filter.exp,
89
- };
90
- }
91
- /**
92
- * Validate and convert a FilterGroup (AND/OR/NOT filter)
93
- * @param filter
94
- */
95
- function validateAndConvertFilterGroup(filter) {
96
- // Validate it has 'op' property
97
- if (!('op' in filter)) {
98
- throw new Error('Invalid filter: filter group must have op property');
99
- }
100
- // Validate it has 'exp' property
101
- if (!('exp' in filter)) {
102
- throw new Error('Invalid filter: filter group must have exp property');
103
- }
104
- // Check for unexpected properties in filter groups
105
- const knownGroupProps = new Set(['op', 'exp']);
106
- const unexpectedGroupProps = Object.keys(filter).filter((k) => !knownGroupProps.has(k));
107
- if (unexpectedGroupProps.length > 0) {
108
- throw new Error(`Unexpected properties in filter group: ${unexpectedGroupProps.join(', ')}`);
109
- }
110
- if (filter.op === '!') {
111
- // NOT filter: exp should be a single expression (not array)
112
- if (Array.isArray(filter.exp)) {
113
- throw new TypeError('Invalid NOT filter: exp should be a single expression, not an array');
114
- }
115
- return {
116
- filter_type: 'NOT',
117
- expression: limeQueryToGuiFilter(filter.exp),
118
- };
119
- }
120
- if (filter.op === 'AND') {
121
- // AND filter: exp should be an array
122
- if (!Array.isArray(filter.exp)) {
123
- throw new TypeError('Invalid AND filter: exp must be an array');
124
- }
125
- return {
126
- filter_type: 'AND',
127
- expressions: filter.exp.map(limeQueryToGuiFilter),
128
- };
129
- }
130
- if (filter.op === 'OR') {
131
- // OR filter: exp should be an array
132
- if (!Array.isArray(filter.exp)) {
133
- throw new TypeError('Invalid OR filter: exp must be an array');
134
- }
135
- return {
136
- filter_type: 'OR',
137
- expressions: filter.exp.map(limeQueryToGuiFilter),
138
- };
139
- }
140
- // If we reach here, the operator is unsupported
141
- throw new Error(`Unsupported filter operator: ${filter.op}`);
142
- }
143
- /**
144
- * Convert Lime Query filter to UI filter representation
145
- * Throws errors for unsupported filter structures
146
- * @param filter
147
- */
148
- function limeQueryToGuiFilter(filter) {
149
- if (!filter) {
150
- // Return empty AND instead of missing expression
151
- // This ensures users see the "Add a condition" button
152
- return {
153
- filter_type: 'AND',
154
- expressions: [],
155
- };
156
- }
157
- // Check if it's a FilterExpression (has 'key' property)
158
- if ('key' in filter) {
159
- return validateAndConvertFilterExpression(filter);
160
- }
161
- // It's a FilterGroup
162
- return validateAndConvertFilterGroup(filter);
163
- }
164
-
165
5
  /**
166
6
  * Dynamic filter values and placeholders that are valid in Lime Query
167
7
  */
@@ -409,6 +249,49 @@ function validatePropertySelection(selection, limetypes, limetype, guiModeEnable
409
249
  }
410
250
  return allGuiLimitations;
411
251
  }
252
+ /**
253
+ * Validate a comparison expression (has 'key' property)
254
+ * @param filter
255
+ * @param activeLimetype
256
+ * @param limetypes
257
+ */
258
+ function validateComparisonExpression(filter, activeLimetype, limetypes) {
259
+ // Validate operator
260
+ const allValidOperators = Object.values(Zt);
261
+ if (!allValidOperators.includes(filter.op)) {
262
+ throw new Error(`Unsupported filter operator: ${filter.op}`);
263
+ }
264
+ // Validate placeholder
265
+ const result = validatePlaceholder(filter.exp, activeLimetype, limetypes);
266
+ if (!result.valid) {
267
+ throw new Error(`Invalid placeholder in filter '${filter.key}': ${result.error}`);
268
+ }
269
+ }
270
+ /**
271
+ * Validate a group expression (AND/OR/NOT)
272
+ * @param filter
273
+ * @param activeLimetype
274
+ * @param limetypes
275
+ * @param guiModeEnabled
276
+ */
277
+ function validateGroupExpression(filter, activeLimetype, limetypes, guiModeEnabled) {
278
+ // Validate operator
279
+ if (filter.op !== Zt.AND &&
280
+ filter.op !== Zt.OR &&
281
+ filter.op !== Zt.NOT) {
282
+ throw new Error(`Unsupported group operator: ${filter.op}`);
283
+ }
284
+ // Recursively validate children
285
+ if (filter.op === Zt.NOT) {
286
+ validateFilterPlaceholders(filter.exp, activeLimetype, limetypes, guiModeEnabled);
287
+ }
288
+ else if (filter.op === Zt.AND || filter.op === Zt.OR) {
289
+ const expressions = filter.exp;
290
+ for (const expr of expressions) {
291
+ validateFilterPlaceholders(expr, activeLimetype, limetypes, guiModeEnabled);
292
+ }
293
+ }
294
+ }
412
295
  /**
413
296
  * Validate placeholders in a filter expression
414
297
  * @param filter Filter expression to validate
@@ -420,27 +303,12 @@ function validateFilterPlaceholders(filter, activeLimetype, limetypes, guiModeEn
420
303
  if (!filter) {
421
304
  return;
422
305
  }
423
- // Check if it's a FilterExpression (has 'key' property)
424
306
  if ('key' in filter) {
425
- const result = validatePlaceholder(filter.exp, activeLimetype, limetypes);
426
- if (!result.valid) {
427
- throw new Error(`Invalid placeholder in filter '${filter.key}': ${result.error}`);
428
- }
307
+ validateComparisonExpression(filter, activeLimetype, limetypes);
429
308
  return;
430
309
  }
431
- // It's a FilterGroup - recursively validate children
432
310
  if ('exp' in filter) {
433
- if (filter.op === '!') {
434
- // NOT has a single expression
435
- validateFilterPlaceholders(filter.exp, activeLimetype, limetypes, guiModeEnabled);
436
- }
437
- else if (filter.op === 'AND' || filter.op === 'OR') {
438
- // AND/OR have array of expressions
439
- const expressions = filter.exp;
440
- for (const expr of expressions) {
441
- validateFilterPlaceholders(expr, activeLimetype, limetypes, guiModeEnabled);
442
- }
443
- }
311
+ validateGroupExpression(filter, activeLimetype, limetypes, guiModeEnabled);
444
312
  }
445
313
  }
446
314
  /**
@@ -454,7 +322,6 @@ function validateFilterPlaceholders(filter, activeLimetype, limetypes, guiModeEn
454
322
  function validateLimeQueryFilterInternal(filter, activeLimetype, limetypes, guiModeEnabled) {
455
323
  const errors = [];
456
324
  try {
457
- limeQueryToGuiFilter(filter);
458
325
  validateFilterPlaceholders(filter, activeLimetype, limetypes, guiModeEnabled);
459
326
  }
460
327
  catch (error) {
@@ -559,18 +426,11 @@ const LimeQueryBuilder = class {
559
426
  this.mode = 'gui';
560
427
  this.codeValue = '';
561
428
  this.limetype = '';
562
- this.filter = {
563
- op: Zt.AND,
564
- exp: [],
565
- };
566
429
  this.handleLimetypeChange = (event) => {
567
430
  event.stopPropagation();
568
431
  this.limetype = event.detail;
569
432
  // Reset filter when limetype changes
570
- this.filter = {
571
- op: Zt.AND,
572
- exp: [],
573
- };
433
+ this.filter = undefined;
574
434
  // Reset response format when limetype changes
575
435
  this.internalResponseFormat = {
576
436
  object: {
@@ -580,17 +440,9 @@ const LimeQueryBuilder = class {
580
440
  this.emitChange();
581
441
  };
582
442
  this.handleFilterChange = (event) => {
443
+ var _a;
583
444
  event.stopPropagation();
584
- const expression = event.detail;
585
- if (expression === undefined) {
586
- this.filter = {
587
- op: Zt.AND,
588
- exp: [],
589
- };
590
- }
591
- else {
592
- this.filter = expression;
593
- }
445
+ this.filter = (_a = event.detail) !== null && _a !== void 0 ? _a : undefined;
594
446
  this.emitChange();
595
447
  };
596
448
  this.handleResponseFormatChange = (event) => {
@@ -616,7 +468,7 @@ const LimeQueryBuilder = class {
616
468
  }
617
469
  // Update internal state from parsed query
618
470
  this.limetype = parsed.limetype || '';
619
- this.filter = this.normalizeFilter(parsed.filter);
471
+ this.filter = parsed.filter;
620
472
  this.internalResponseFormat = parsed.responseFormat;
621
473
  this.limit = parsed.limit;
622
474
  this.mode = 'gui';
@@ -657,7 +509,7 @@ const LimeQueryBuilder = class {
657
509
  }
658
510
  if (this.value) {
659
511
  this.limetype = this.value.limetype || '';
660
- this.filter = this.normalizeFilter(this.value.filter);
512
+ this.filter = this.value.filter;
661
513
  this.internalResponseFormat = this.value.responseFormat;
662
514
  this.limit = this.value.limit;
663
515
  }
@@ -672,26 +524,10 @@ const LimeQueryBuilder = class {
672
524
  render() {
673
525
  const guiSupported = this.checkGuiSupport();
674
526
  const showCodeMode = !this.guiModeEnabled || this.mode === 'code';
675
- return (h("div", { key: '5ff70a352e3e57ff4c51d44627bd4b5ed367fff4', class: "lime-query-builder" }, this.renderLabel(), this.renderModeControls(guiSupported), showCodeMode
527
+ return (h("div", { key: '0b4d2bb5b4d503a775d8d3215e1e4c74fdb1eceb', class: "lime-query-builder" }, this.renderLabel(), this.renderModeControls(guiSupported), showCodeMode
676
528
  ? this.renderCodeMode(guiSupported)
677
529
  : this.renderGuiMode()));
678
530
  }
679
- /**
680
- * Normalize filter to ensure top-level is an AND group.
681
- * This ensures Add buttons are available in the UI.
682
- * @param filter
683
- */
684
- normalizeFilter(filter) {
685
- if (!filter) {
686
- return { op: Zt.AND, exp: [] };
687
- }
688
- // If it's already an AND at the top level, keep it
689
- if ('op' in filter && filter.op === Zt.AND) {
690
- return filter;
691
- }
692
- // Otherwise wrap in AND
693
- return { op: Zt.AND, exp: [filter] };
694
- }
695
531
  emitChange() {
696
532
  // Only emit in GUI mode
697
533
  if (this.mode === 'code') {
@@ -813,7 +649,7 @@ const LimeQueryBuilder = class {
813
649
  if (!this.limetype) {
814
650
  return;
815
651
  }
816
- return (h("div", { class: "filter-section" }, h("h4", { class: "section-label" }, "Filter Conditions"), h("limebb-lime-query-filter-expression", { platform: this.platform, context: this.context, limetype: this.limetype, activeLimetype: this.activeLimetype, expression: this.filter, onExpressionChange: this.handleFilterChange })));
652
+ return (h("div", { class: "filter-section" }, h("h4", { class: "section-label" }, "Filter Conditions"), h("limebb-lime-query-filter-builder", { platform: this.platform, context: this.context, limetype: this.limetype, activeLimetype: this.activeLimetype, expression: this.filter, onExpressionChange: this.handleFilterChange })));
817
653
  }
818
654
  renderQueryOptionsSection() {
819
655
  var _a;
@@ -1,5 +1,5 @@
1
1
  import { r as registerInstance, c as createEvent, h } from './index-96dd111f.js';
2
- import { c } from './index.esm-bb569663.js';
2
+ import { Z as Zt, c } from './index.esm-bb569663.js';
3
3
  import { b as getIcon } from './limetype-c0e041f7.js';
4
4
  import { i as isNonNull } from './non-null-5a66a269.js';
5
5
  import { b as baseIsEqual } from './_baseIsEqual-28053b81.js';
@@ -65,6 +65,76 @@ function isEqual(value, other) {
65
65
  return baseIsEqual(value, other);
66
66
  }
67
67
 
68
+ const limeQueryFilterBuilderCss = ".expression-with-promotion{display:flex;flex-direction:column;gap:1rem}";
69
+ const LimebbLimeQueryFilterBuilderStyle0 = limeQueryFilterBuilderCss;
70
+
71
+ const LimeQueryFilterBuilderComponent = class {
72
+ constructor(hostRef) {
73
+ registerInstance(this, hostRef);
74
+ this.expressionChange = createEvent(this, "expressionChange", 7);
75
+ this.handleAddFirstCondition = () => {
76
+ const newExpression = {
77
+ key: '',
78
+ op: Zt.EQUALS,
79
+ exp: '',
80
+ };
81
+ this.expressionChange.emit(newExpression);
82
+ };
83
+ this.handlePromoteAndAdd = () => {
84
+ if (!this.expression) {
85
+ return;
86
+ }
87
+ // Wrap current expression in AND and add a new comparison
88
+ const newExpression = {
89
+ op: Zt.AND,
90
+ exp: [
91
+ this.expression,
92
+ {
93
+ key: '',
94
+ op: Zt.EQUALS,
95
+ exp: '',
96
+ },
97
+ ],
98
+ };
99
+ this.expressionChange.emit(newExpression);
100
+ };
101
+ this.handleExpressionChange = (event) => {
102
+ var _a;
103
+ event.stopPropagation();
104
+ this.expressionChange.emit((_a = event.detail) !== null && _a !== void 0 ? _a : undefined);
105
+ };
106
+ }
107
+ render() {
108
+ if (!this.expression) {
109
+ return this.renderEmptyState();
110
+ }
111
+ // Check if we need to show promotion UI (comparison or NOT)
112
+ if (this.needsPromotion()) {
113
+ return this.renderWithPromotionButton();
114
+ }
115
+ // AND/OR groups handle their own Add buttons
116
+ return (h("limebb-lime-query-filter-expression", { platform: this.platform, context: this.context, limetype: this.limetype, activeLimetype: this.activeLimetype, expression: this.expression, onExpressionChange: this.handleExpressionChange }));
117
+ }
118
+ needsPromotion() {
119
+ if (!this.expression) {
120
+ return false;
121
+ }
122
+ // Basic comparison needs promotion
123
+ if ('key' in this.expression) {
124
+ return true;
125
+ }
126
+ // NOT needs promotion
127
+ return this.expression.op === Zt.NOT;
128
+ }
129
+ renderEmptyState() {
130
+ return (h("limel-button", { label: "Add a condition", icon: "plus_math", onClick: this.handleAddFirstCondition }));
131
+ }
132
+ renderWithPromotionButton() {
133
+ return (h("div", { class: "expression-with-promotion" }, h("limebb-lime-query-filter-expression", { platform: this.platform, context: this.context, limetype: this.limetype, activeLimetype: this.activeLimetype, expression: this.expression, onExpressionChange: this.handleExpressionChange }), h("limel-button", { label: "Add another condition", icon: "plus_math", onClick: this.handlePromoteAndAdd })));
134
+ }
135
+ };
136
+ LimeQueryFilterBuilderComponent.style = LimebbLimeQueryFilterBuilderStyle0;
137
+
68
138
  const RELATION_PROPERTY_TYPES = [
69
139
  'belongsto',
70
140
  'hasone',
@@ -150,7 +220,7 @@ const LimetypeField = class {
150
220
  value: '',
151
221
  };
152
222
  options.unshift(emptyOption);
153
- return (h("limel-select", { key: 'cf27b83c4751838e85436af443a275b3d7c9dfee', label: this.label, options: options, value: selectedOption, required: this.required, helperText: this.helperText, invalid: invalid, disabled: this.disabled || this.readonly, onChange: this.handleChange }));
223
+ return (h("limel-select", { key: 'fd9522c5df730f65a5ac57140bca6c05c5acd63d', label: this.label, options: options, value: selectedOption, required: this.required, helperText: this.helperText, invalid: invalid, disabled: this.disabled || this.readonly, onChange: this.handleChange }));
154
224
  }
155
225
  componentWillRender() {
156
226
  this.updatePropertyFields(this.value || '');
@@ -429,4 +499,4 @@ const ResponseFormatEditor = class {
429
499
  };
430
500
  ResponseFormatEditor.style = LimebbResponseFormatEditorStyle0;
431
501
 
432
- export { LimetypeField as limebb_limetype_field, ResponseFormatEditor as limebb_response_format_editor };
502
+ export { LimeQueryFilterBuilderComponent as limebb_lime_query_filter_builder, LimetypeField as limebb_limetype_field, ResponseFormatEditor as limebb_response_format_editor };
@@ -78,7 +78,7 @@ const LimeQueryFilterComparisonComponent = class {
78
78
  };
79
79
  }
80
80
  render() {
81
- return (h("div", { key: '668e0f05bdb1fb25ffd652ea650c34e5431a3332', class: "expression" }, this.label && h("limel-header", { key: '5034070b58afe31cf90699dd2a27f884e647f540', heading: this.label }), h("div", { key: '14a2b1270e5e6d7e158e29ebc5f61051e5670e80', class: "expression-container" }, this.renderPropertySelector(), this.renderOperator(), this.renderValueInput(), h("limel-icon-button", { key: 'b69bde6e88c40d2623ef015794db28cec3676c73', class: "remove", icon: "trash", label: "Remove condition", onClick: this.removeExpression }))));
81
+ return (h("div", { key: 'a077c982ced9840beec3e574cd3e2e336cff6071', class: "expression" }, this.label && h("limel-header", { key: 'fbcb5cf515aac2c8e68d29947c7560684f30822c', heading: this.label }), h("div", { key: 'ffea426ea1295ae11aaa3c910f835acbeed24cd9', class: "expression-container" }, this.renderPropertySelector(), this.renderOperator(), this.renderValueInput(), h("limel-icon-button", { key: '20064f9fe42a4dfa71b2e1e2d393d50bbe20e2cb', class: "remove", icon: "trash", label: "Remove condition", onClick: this.removeExpression }))));
82
82
  }
83
83
  renderPropertySelector() {
84
84
  return (h("limebb-property-selector", { platform: this.platform, context: this.context, label: "Property", limetype: this.limetype, value: this.expression.key, required: true, onChange: this.handlePropertyChange }));