@bagelink/vue 1.22.1 → 1.22.5

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 (43) hide show
  1. package/dist/{StructuredEditor-BiBhDIf8.js → StructuredEditor-1mcyEtzh.js} +143 -143
  2. package/dist/{StructuredEditor-Cdl9_djZ.cjs → StructuredEditor-yW9FO5Tn.cjs} +1 -1
  3. package/dist/components/FilterQuery.vue.d.ts +5 -0
  4. package/dist/components/FilterQuery.vue.d.ts.map +1 -1
  5. package/dist/components/FilterQueryBuilder.vue.d.ts +47 -0
  6. package/dist/components/FilterQueryBuilder.vue.d.ts.map +1 -0
  7. package/dist/components/Icon/baseline.d.ts +14 -0
  8. package/dist/components/Icon/baseline.d.ts.map +1 -0
  9. package/dist/components/index.d.ts +1 -0
  10. package/dist/components/index.d.ts.map +1 -1
  11. package/dist/components/layout/AppLayout.vue.d.ts.map +1 -1
  12. package/dist/composables/index.d.ts +1 -0
  13. package/dist/composables/index.d.ts.map +1 -1
  14. package/dist/composables/useKeyboardInset.d.ts +5 -0
  15. package/dist/composables/useKeyboardInset.d.ts.map +1 -0
  16. package/dist/core.css +1 -1
  17. package/dist/dialog/Dialog.vue.d.ts.map +1 -1
  18. package/dist/i18n/index.d.ts +2 -0
  19. package/dist/i18n/index.d.ts.map +1 -1
  20. package/dist/index.cjs +1 -1
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.mjs +312 -310
  24. package/dist/src-BHNIZfpF.cjs +764 -0
  25. package/dist/{src-lXTK29UB.js → src-CtOtibj7.js} +13464 -13199
  26. package/dist/src.css +1 -1
  27. package/dist/style.css +1 -1
  28. package/dist/utils/useKeyboardInset.d.ts +7 -0
  29. package/dist/utils/useKeyboardInset.d.ts.map +1 -0
  30. package/package.json +3 -3
  31. package/src/components/FilterQuery.vue +139 -750
  32. package/src/components/FilterQueryBuilder.vue +797 -0
  33. package/src/components/Icon/baseline.ts +80 -0
  34. package/src/components/index.ts +1 -0
  35. package/src/components/layout/AppLayout.vue +3 -1
  36. package/src/composables/index.ts +1 -0
  37. package/src/composables/useKeyboardInset.ts +89 -0
  38. package/src/dialog/Dialog.vue +15 -6
  39. package/src/i18n/locales/en.json +2 -1
  40. package/src/i18n/locales/he.json +2 -1
  41. package/src/index.ts +1 -0
  42. package/src/utils/useKeyboardInset.ts +36 -0
  43. package/dist/src-CyUKZxJV.cjs +0 -764
@@ -0,0 +1,797 @@
1
+ <script lang="ts">
2
+ import type { FilterField, QueryOption, OptionsSource } from './FilterQuery.types'
3
+ export type { FilterField, QueryOption, OptionsSource }
4
+ </script>
5
+
6
+ <script setup lang="ts" generic="T extends Record<string, any>">
7
+ import type { ComparisonOperator, LogicalOperator, QueryConditions } from '../utils/queryFilter'
8
+ import { parseQuery } from '../utils/queryFilter'
9
+ import { Btn, DateInput, Icon, SelectInput, TextInput, useI18n, useDebounceFn } from '../index'
10
+ import { computed, ref } from 'vue'
11
+
12
+ interface UICondition {
13
+ id: string
14
+ field: string
15
+ operator: ComparisonOperator
16
+ value: string | number | boolean | null | Array<string | number | boolean | null>
17
+ connector: LogicalOperator | ''
18
+ }
19
+
20
+ const props = withDefaults(defineProps<{
21
+ fields: FilterField[]
22
+ /**
23
+ * Keep the desktop multi-column row layout even on narrow screens
24
+ * (and stack action buttons less aggressively).
25
+ */
26
+ desktopLayoutOnMobile?: boolean
27
+ /**
28
+ * Hide the in-panel Clear/Save row — the parent sheet footer owns those
29
+ * actions (mobile bottom sheet).
30
+ */
31
+ hideFooterActions?: boolean
32
+ /** Show the Save button (parent detected an `@save` listener). */
33
+ showSave?: boolean
34
+ }>(), {
35
+ desktopLayoutOnMobile: false,
36
+ hideFooterActions: false,
37
+ showSave: false,
38
+ })
39
+
40
+ const emit = defineEmits<{
41
+ change: [value: QueryConditions<T>]
42
+ save: [value: QueryConditions<T>]
43
+ }>()
44
+
45
+ const model = defineModel<QueryConditions<T>>({ default: () => [] })
46
+
47
+ // Internal working copy — may contain incomplete conditions for UI purposes.
48
+ // On init, detect any queryOption presets from the incoming model.
49
+ const internalModel = ref<QueryConditions<T>>(collapseToPresets([...model.value] as QueryConditions<T>))
50
+
51
+ const { $t } = useI18n()
52
+ const hasSaveListener = computed(() => props.showSave)
53
+
54
+ function isComplete(c: { field: string, op: ComparisonOperator, value?: any }) {
55
+ if (!c.field || !c.op) return false
56
+ // queryOption presets are complete if they have a selected value
57
+ if (isQueryOptionField(c.field as string)) return c.value !== '' && c.value != null
58
+ if (c.op === 'pr' || c.op === 'is_null') return true
59
+ if (c.op === 'in' || c.op === 'nin' || c.op === 'sw_any') return Array.isArray(c.value) && c.value.length > 0
60
+ if (c.op === 'between') {
61
+ return Array.isArray(c.value) && c.value.length === 2
62
+ && c.value[0] !== '' && c.value[0] != null
63
+ && c.value[1] !== '' && c.value[1] != null
64
+ }
65
+ return c.value !== '' && c.value !== null && c.value !== undefined
66
+ }
67
+
68
+ const debouncedFlush = useDebounceFn(() => {
69
+ const complete = internalModel.value.filter(isComplete) as QueryConditions<T>
70
+ const expanded = expandQueryOptions(complete)
71
+ model.value = expanded
72
+ emit('change', expanded)
73
+ }, 400)
74
+
75
+ let conditionIdCounter = 0
76
+ function generateId() {
77
+ return `cond_${++conditionIdCounter}_${Date.now()}`
78
+ }
79
+
80
+ // Computed texts using i18n
81
+ const currentTexts = computed(() => ({
82
+ filter: $t('filter.filter'),
83
+ noActiveFilters: $t('filter.noActiveFilters'),
84
+ connectors: {
85
+ and: $t('filter.connectors.and'),
86
+ or: $t('filter.connectors.or'),
87
+ },
88
+ operators: {
89
+ eq: $t('filter.operators.eq'),
90
+ ne: $t('filter.operators.ne'),
91
+ gt: $t('filter.operators.gt'),
92
+ ge: $t('filter.operators.ge'),
93
+ lt: $t('filter.operators.lt'),
94
+ le: $t('filter.operators.le'),
95
+ co: $t('filter.operators.co'),
96
+ sw: $t('filter.operators.sw'),
97
+ sw_any: $t('filter.operators.swAny'),
98
+ ew: $t('filter.operators.ew'),
99
+ pr: $t('filter.operators.pr'),
100
+ is_null: $t('filter.operators.isNull'),
101
+ in: $t('filter.operators.in'),
102
+ nin: $t('filter.operators.nin'),
103
+ between: $t('filter.operators.between'),
104
+ },
105
+ placeholders: {
106
+ selectField: $t('filter.placeholders.selectField'),
107
+ selectOption: $t('filter.placeholders.selectOption'),
108
+ selectDate: $t('filter.placeholders.selectDate'),
109
+ enterValue: $t('filter.placeholders.enterValue'),
110
+ from: $t('filter.placeholders.from'),
111
+ to: $t('filter.placeholders.to'),
112
+ commaSeparated: $t('filter.placeholders.commaSeparated'),
113
+ },
114
+ buttons: {
115
+ addCondition: $t('filter.buttons.addCondition'),
116
+ clearAll: $t('filter.buttons.clearAll'),
117
+ },
118
+ boolean: {
119
+ true: $t('select.yes'),
120
+ false: $t('select.no'),
121
+ },
122
+ }))
123
+
124
+ // Map model conditions to UI conditions with stable IDs
125
+ const conditionIds = new Map<number, string>()
126
+
127
+ const conditions = computed(() => {
128
+ const arr = internalModel.value || []
129
+ return arr.map((cond, index) => {
130
+ // Get or create stable ID for this index
131
+ if (!conditionIds.has(index)) {
132
+ conditionIds.set(index, generateId())
133
+ }
134
+ const id = conditionIds.get(index)!
135
+
136
+ const uiCond: UICondition = {
137
+ id,
138
+ field: cond.field as string,
139
+ operator: cond.op,
140
+ value: Array.isArray(cond.value)
141
+ ? [...cond.value]
142
+ : (cond.value === undefined ? '' : cond.value),
143
+ connector: index > 0 ? (cond.connector || 'and') : '',
144
+ }
145
+ return uiCond
146
+ })
147
+ })
148
+
149
+ const allOperatorOptions = computed(() => [
150
+ { label: currentTexts.value.operators.eq, value: 'eq' as ComparisonOperator },
151
+ { label: currentTexts.value.operators.ne, value: 'ne' as ComparisonOperator },
152
+ { label: currentTexts.value.operators.gt, value: 'gt' as ComparisonOperator },
153
+ { label: currentTexts.value.operators.ge, value: 'ge' as ComparisonOperator },
154
+ { label: currentTexts.value.operators.lt, value: 'lt' as ComparisonOperator },
155
+ { label: currentTexts.value.operators.le, value: 'le' as ComparisonOperator },
156
+ { label: currentTexts.value.operators.co, value: 'co' as ComparisonOperator },
157
+ { label: currentTexts.value.operators.sw, value: 'sw' as ComparisonOperator },
158
+ { label: currentTexts.value.operators.sw_any, value: 'sw_any' as ComparisonOperator },
159
+ { label: currentTexts.value.operators.ew, value: 'ew' as ComparisonOperator },
160
+ { label: currentTexts.value.operators.pr, value: 'pr' as ComparisonOperator },
161
+ { label: currentTexts.value.operators.is_null, value: 'is_null' as ComparisonOperator },
162
+ { label: currentTexts.value.operators.in, value: 'in' as ComparisonOperator },
163
+ { label: currentTexts.value.operators.nin, value: 'nin' as ComparisonOperator },
164
+ { label: currentTexts.value.operators.between, value: 'between' as ComparisonOperator },
165
+ ])
166
+
167
+ function getOperatorsForType(fieldType: string, hasOptions: boolean, isMultiple: boolean, fieldValue: string) {
168
+ const allow = (ops: string[]) => allOperatorOptions.value.filter(o => ops.includes(o.value))
169
+ const withAdditional = (ops: string[]) => [
170
+ ...ops,
171
+ ...(getFieldDef(fieldValue)?.additionalOperators ?? []),
172
+ ]
173
+ if (isMultiple && hasOptions) {
174
+ return allow(withAdditional(['in', 'nin', 'pr', 'is_null']))
175
+ }
176
+ if (hasOptions) {
177
+ return allow(withAdditional(['eq', 'ne', 'in', 'nin', 'pr', 'is_null']))
178
+ }
179
+ switch (fieldType) {
180
+ case 'boolean':
181
+ return allow(withAdditional(['eq', 'ne', 'pr', 'is_null']))
182
+ case 'number':
183
+ case 'date':
184
+ return allow(withAdditional(['eq', 'ne', 'gt', 'ge', 'lt', 'le', 'between', 'in', 'nin', 'pr', 'is_null']))
185
+ default:
186
+ return allow(withAdditional(['eq', 'ne', 'co', 'sw', 'ew', 'in', 'nin', 'pr', 'is_null']))
187
+ }
188
+ }
189
+
190
+ function getFieldDef(fieldValue: string) {
191
+ return props.fields.find(f => f.value === fieldValue)
192
+ }
193
+
194
+ function getFieldOptions(fieldValue: string): OptionsSource | undefined {
195
+ return getFieldDef(fieldValue)?.options
196
+ }
197
+
198
+ function isQueryOptionField(fieldValue: string): boolean {
199
+ const def = getFieldDef(fieldValue)
200
+ return !!(def?.queryOptions && def.queryOptions.length > 0)
201
+ }
202
+
203
+ function isMultipleField(fieldValue: string): boolean {
204
+ const def = getFieldDef(fieldValue)
205
+ return !!(def?.multiple && def?.options)
206
+ }
207
+
208
+ /** On flush: replace queryOption markers with parsed conditions from the raw SCIM string */
209
+ function expandQueryOptions(conditions: QueryConditions<T>): QueryConditions<T> {
210
+ const result: QueryConditions<T> = []
211
+ for (const c of conditions) {
212
+ const def = getFieldDef(c.field as string)
213
+ const opt = def?.queryOptions?.find(o => o.value === c.value)
214
+ if (opt) {
215
+ const parsed = parseQuery(opt.query) as QueryConditions<T>
216
+ if (parsed.length) {
217
+ // Preserve the original connector on the first parsed condition
218
+ parsed[0] = { ...parsed[0], connector: c.connector }
219
+ result.push(...parsed)
220
+ }
221
+ } else {
222
+ result.push(c)
223
+ }
224
+ }
225
+ return result
226
+ }
227
+
228
+ /** On init: detect consecutive conditions that match a queryOption's SCIM string and collapse to a single marker */
229
+ function collapseToPresets(conditions: QueryConditions<T>): QueryConditions<T> {
230
+ const queryOptionFields = props.fields.filter(f => f.queryOptions?.length)
231
+ if (!queryOptionFields.length) return conditions
232
+
233
+ const result: QueryConditions<T> = []
234
+ let i = 0
235
+ while (i < conditions.length) {
236
+ let matched = false
237
+ for (const fieldDef of queryOptionFields) {
238
+ for (const opt of fieldDef.queryOptions!) {
239
+ const parsed = parseQuery(opt.query)
240
+ const qLen = parsed.length
241
+ if (!qLen || i + qLen > conditions.length) continue
242
+ const slice = conditions.slice(i, i + qLen)
243
+ const matches = slice.every((c, idx) => {
244
+ const expected = parsed[idx]
245
+ return c.field === expected.field
246
+ && c.op === expected.op
247
+ && c.value === expected.value
248
+ && (idx === 0 || c.connector === expected.connector)
249
+ })
250
+ if (matches) {
251
+ result.push({
252
+ field: fieldDef.value,
253
+ op: 'eq',
254
+ value: opt.value,
255
+ connector: slice[0].connector,
256
+ } as any)
257
+ i += qLen
258
+ matched = true
259
+ break
260
+ }
261
+ }
262
+ if (matched) break
263
+ }
264
+ if (!matched) {
265
+ result.push(conditions[i])
266
+ i++
267
+ }
268
+ }
269
+ return result
270
+ }
271
+
272
+ const booleanOptions = computed(() => [
273
+ { label: currentTexts.value.boolean.true, value: true },
274
+ { label: currentTexts.value.boolean.false, value: false },
275
+ ])
276
+
277
+ function parseValue(value: string | number | boolean | null, fieldType: string): string | number | boolean | null {
278
+ if (typeof value === 'number' || typeof value === 'boolean' || value === null) return value
279
+ if (fieldType === 'boolean') {
280
+ if (value === 'true') return true
281
+ if (value === 'false') return false
282
+ }
283
+ if (fieldType === 'number' && !Number.isNaN(Number(value)) && value.trim() !== '') return Number(value)
284
+ return value
285
+ }
286
+
287
+ function updateConditionAtIndex(index: number, updates: Partial<{ field: string, op: ComparisonOperator, value: UICondition['value'], connector: LogicalOperator }>) {
288
+ const newModel = [...internalModel.value]
289
+ const existing = newModel[index]
290
+ if (!existing) return
291
+
292
+ const updated = { ...existing }
293
+ if (updates.field !== undefined) updated.field = updates.field
294
+ if (updates.op !== undefined) updated.op = updates.op
295
+ if (updates.value !== undefined) {
296
+ const fieldType = getFieldType(updated.field as string)
297
+ updated.value = Array.isArray(updates.value)
298
+ // Coerce each list/range element (e.g. "18" → 18) so numeric filters
299
+ // emit bare numbers in the bracket literal.
300
+ ? updates.value.map(v => parseValue(v, fieldType))
301
+ : parseValue(updates.value, fieldType)
302
+ }
303
+ if (updates.connector !== undefined) updated.connector = updates.connector
304
+
305
+ newModel[index] = updated
306
+ internalModel.value = newModel as QueryConditions<T>
307
+ debouncedFlush()
308
+ }
309
+
310
+ function addCondition() {
311
+ const field = props.fields[0]?.value || 'field'
312
+ const multi = isMultipleField(field)
313
+ const newCondition = {
314
+ field,
315
+ op: (multi ? 'in' : 'eq') as ComparisonOperator,
316
+ value: (multi ? [] : '') as any,
317
+ connector: model.value.length > 0 ? 'and' as LogicalOperator : undefined,
318
+ }
319
+ const newModel = [...internalModel.value, newCondition]
320
+ internalModel.value = newModel as QueryConditions<T>
321
+ console.log('[Filter] addCondition - skipping flush (incomplete)')
322
+ }
323
+
324
+ function removeCondition(index: number) {
325
+ const newModel = [...internalModel.value]
326
+ newModel.splice(index, 1)
327
+ if (newModel.length > 0 && newModel[0].connector) {
328
+ newModel[0] = { ...newModel[0], connector: undefined }
329
+ }
330
+ conditionIds.delete(index)
331
+ internalModel.value = newModel as QueryConditions<T>
332
+ debouncedFlush()
333
+ }
334
+
335
+ function clearAll() {
336
+ conditionIds.clear()
337
+ internalModel.value = [] as unknown as QueryConditions<T>
338
+ model.value = [] as unknown as QueryConditions<T>
339
+ console.log('[Filter] clearAll')
340
+ emit('change', [] as unknown as QueryConditions<T>)
341
+ }
342
+
343
+ function getFieldType(fieldValue: string): string {
344
+ return props.fields.find(f => f.value === fieldValue)?.type || 'string'
345
+ }
346
+
347
+ function needsValue(operator: ComparisonOperator): boolean {
348
+ return operator !== 'pr' && operator !== 'is_null'
349
+ }
350
+
351
+ function isMultiOperator(operator: ComparisonOperator): boolean {
352
+ return operator === 'in' || operator === 'nin' || operator === 'sw_any'
353
+ }
354
+
355
+ function isBetweenOperator(operator: ComparisonOperator): boolean {
356
+ return operator === 'between'
357
+ }
358
+
359
+ /** in/nin on a field WITHOUT predefined options → comma-separated free text. */
360
+ function isFreeListOperator(condition: UICondition): boolean {
361
+ return isMultiOperator(condition.operator) && !getFieldOptions(condition.field)
362
+ }
363
+
364
+ /** Convert an array value to comma-separated text for the free-list input. */
365
+ function listToText(value: UICondition['value']): string {
366
+ return Array.isArray(value) ? value.join(', ') : String(value ?? '')
367
+ }
368
+
369
+ function selectModelValue(value: UICondition['value']): any {
370
+ return value ?? undefined
371
+ }
372
+
373
+ function selectMultiModelValue(value: UICondition['value']): any[] {
374
+ return Array.isArray(value) ? value.filter(item => item != null) : []
375
+ }
376
+
377
+ /** Split comma-separated free-list text into a trimmed string[]. */
378
+ function textToList(text: string): string[] {
379
+ return text.split(',').map(s => s.trim()).filter(s => s !== '')
380
+ }
381
+
382
+ /** Read one bound of a `between` value ([lo, hi]); index 0 = lo, 1 = hi. */
383
+ function betweenBound(condition: UICondition, index: 0 | 1): string {
384
+ return Array.isArray(condition.value) ? String(condition.value[index] ?? '') : ''
385
+ }
386
+
387
+ /** Update one bound of a `between` value, preserving the other. */
388
+ function onBetweenBoundChange(id: string, index: 0 | 1, v: string) {
389
+ const cond = conditions.value.find(c => c.id === id)
390
+ const current = cond && Array.isArray(cond.value) ? [...cond.value] : ['', '']
391
+ current[index] = v
392
+ onValueChange(id, [current[0] ?? '', current[1] ?? ''])
393
+ }
394
+
395
+ const activeFiltersCount = computed(() => {
396
+ return conditions.value.filter(c => isComplete({ field: c.field, op: c.operator, value: c.value })).length
397
+ })
398
+
399
+ const filterLabel = computed(() =>
400
+ activeFiltersCount.value > 0
401
+ ? `${currentTexts.value.filter} (${activeFiltersCount.value})`
402
+ : currentTexts.value.filter,
403
+ )
404
+
405
+ function getConditionIndex(id: string): number {
406
+ return conditions.value.findIndex((c: UICondition) => c.id === id)
407
+ }
408
+
409
+ function onFieldChange(id: string, newField: string) {
410
+ const index = getConditionIndex(id)
411
+ if (index < 0) return
412
+ const fieldDef = getFieldDef(newField)
413
+ if (fieldDef?.queryOptions?.length) {
414
+ updateConditionAtIndex(index, { field: newField, op: 'eq', value: '' })
415
+ return
416
+ }
417
+ const multi = !!(fieldDef?.multiple && fieldDef?.options)
418
+ const validOps = getOperatorsForType(fieldDef?.type || 'string', !!fieldDef?.options, multi, newField)
419
+ const defaultOp = (multi ? 'in' : validOps[0]?.value ?? 'eq') as ComparisonOperator
420
+ updateConditionAtIndex(index, {
421
+ field: newField,
422
+ op: defaultOp,
423
+ value: multi ? [] : '',
424
+ })
425
+ }
426
+
427
+ function onOperatorChange(id: string, operator: ComparisonOperator) {
428
+ const index = getConditionIndex(id)
429
+ if (index < 0) return
430
+ const current = conditions.value[index]
431
+ const prevOp = current?.operator
432
+ const updates: Parameters<typeof updateConditionAtIndex>[1] = { op: operator }
433
+
434
+ // Reset the value shape when the operator's expected value type changes.
435
+ const wasList = prevOp === 'in' || prevOp === 'nin' || prevOp === 'sw_any'
436
+ const wasBetween = prevOp === 'between'
437
+ const isList = operator === 'in' || operator === 'nin' || operator === 'sw_any'
438
+ const isBetween = operator === 'between'
439
+
440
+ if (isBetween && !wasBetween) updates.value = ['', '']
441
+ else if (isList && !wasList) updates.value = []
442
+ else if (!isList && !isBetween && (wasList || wasBetween)) updates.value = ''
443
+
444
+ updateConditionAtIndex(index, updates)
445
+ }
446
+
447
+ function onValueChange(id: string, value: UICondition['value']) {
448
+ const index = getConditionIndex(id)
449
+ if (index >= 0) updateConditionAtIndex(index, { value })
450
+ }
451
+
452
+ function onQueryOptionChange(id: string, optionValue: string) {
453
+ const index = getConditionIndex(id)
454
+ if (index >= 0) updateConditionAtIndex(index, { value: optionValue })
455
+ }
456
+
457
+ function getQueryOptionValue(condition: UICondition): string {
458
+ return Array.isArray(condition.value) ? '' : String(condition.value ?? '')
459
+ }
460
+
461
+ function onConnectorChange(id: string, connector: LogicalOperator) {
462
+ const index = getConditionIndex(id)
463
+ if (index >= 0) updateConditionAtIndex(index, { connector })
464
+ }
465
+
466
+ defineExpose({
467
+ filterLabel,
468
+ activeFiltersCount,
469
+ clearAll,
470
+ hasSaveListener,
471
+ })
472
+ </script>
473
+
474
+ <template>
475
+ <div
476
+ class="filter-query-wrap filter-query-inline"
477
+ :class="{ 'filter-query-desktop-mobile': props.desktopLayoutOnMobile }"
478
+ >
479
+ <div class="p-025 bg-bg radius-1 mb-05 m_max-h-300px m_overflow m_border">
480
+ <!-- Empty state -->
481
+ <div v-if="conditions.length === 0" class="opacity-3 flex gap-05 p-025 min-w-450px m_min-0">
482
+ <Icon name="info" />
483
+ <div class="">
484
+ {{ currentTexts.noActiveFilters }}
485
+ </div>
486
+ </div>
487
+ <TransitionGroup name="condition">
488
+ <div
489
+ v-for="(condition, index) in conditions" :key="condition.id"
490
+ class="grid gap-025 align-items-center py-025" :class="{
491
+ '': index > 0 && condition.connector === 'or',
492
+ 'pt-075 border-top-or': index > 0 && condition.connector === 'or',
493
+ 'first-filter-row': index === 0,
494
+ 'filter-row': index > 0,
495
+ }"
496
+ >
497
+ <!-- Connector (AND/OR) -->
498
+ <div v-if="index > 0" class="w-fit">
499
+ <SelectInput
500
+ :model-value="condition.connector || 'and'" :options="[
501
+ { label: currentTexts.connectors.and, value: 'and' },
502
+ { label: currentTexts.connectors.or, value: 'or' },
503
+ ]" class="m-0 and-or-select txt-12"
504
+ @update:model-value="(v: LogicalOperator) => onConnectorChange(condition.id, v)"
505
+ />
506
+ </div>
507
+
508
+ <!-- Field selector -->
509
+ <SelectInput
510
+ :model-value="condition.field" :options="fields"
511
+ :placeholder="currentTexts.placeholders.selectField"
512
+ class="m-0 light-input borderHover"
513
+ :class="{ 'first-filter-field': index === 0 }"
514
+ searchable
515
+ @update:model-value="(v: string) => onFieldChange(condition.id, v)"
516
+ />
517
+
518
+ <!-- Query-option preset: single select spanning operator+value columns -->
519
+ <template v-if="isQueryOptionField(condition.field)">
520
+ <SelectInput
521
+ :key="`${condition.id}-${condition.field}-qpreset`"
522
+ :model-value="getQueryOptionValue(condition)"
523
+ :options="getFieldDef(condition.field)!.queryOptions!"
524
+ :placeholder="currentTexts.placeholders.selectOption"
525
+ class="m-0 light-input borderHover" style="grid-column: span 2"
526
+ @update:model-value="(v: string) => onQueryOptionChange(condition.id, v)"
527
+ />
528
+ </template>
529
+
530
+ <!-- Standard: Operator + Value -->
531
+ <template v-else>
532
+ <!-- Operator selector -->
533
+ <SelectInput
534
+ :model-value="condition.operator"
535
+ :options="getOperatorsForType(getFieldType(condition.field), !!getFieldOptions(condition.field), isMultipleField(condition.field), condition.field)"
536
+ class="m-0 light-input borderHover"
537
+ @update:model-value="(v: ComparisonOperator) => onOperatorChange(condition.id, v)"
538
+ />
539
+
540
+ <!-- Value input - type-specific -->
541
+ <template v-if="needsValue(condition.operator)">
542
+ <!-- between: two type-aware bound inputs (min / max) -->
543
+ <div
544
+ v-if="isBetweenOperator(condition.operator)"
545
+ :key="`${condition.id}-${condition.field}-between`"
546
+ class="flex gap-025 align-items-center between-inputs"
547
+ >
548
+ <DateInput
549
+ v-if="getFieldType(condition.field) === 'date'"
550
+ :model-value="betweenBound(condition, 0)"
551
+ :placeholder="currentTexts.placeholders.from" class="m-0 light-input borderHover"
552
+ @update:model-value="(v: any) => onBetweenBoundChange(condition.id, 0, String(v))"
553
+ />
554
+ <TextInput
555
+ v-else
556
+ :model-value="betweenBound(condition, 0)" placeholder="0"
557
+ :type="getFieldType(condition.field) === 'number' ? 'number' : 'text'"
558
+ class="m-0 light-input borderHover"
559
+ @update:model-value="(v: string) => onBetweenBoundChange(condition.id, 0, v)"
560
+ />
561
+ <span class="opacity-4 txt-12">–</span>
562
+ <DateInput
563
+ v-if="getFieldType(condition.field) === 'date'"
564
+ :model-value="betweenBound(condition, 1)"
565
+ :placeholder="currentTexts.placeholders.to" class="m-0 light-input borderHover"
566
+ @update:model-value="(v: any) => onBetweenBoundChange(condition.id, 1, String(v))"
567
+ />
568
+ <TextInput
569
+ v-else
570
+ :model-value="betweenBound(condition, 1)" placeholder="0"
571
+ :type="getFieldType(condition.field) === 'number' ? 'number' : 'text'"
572
+ class="m-0 light-input borderHover"
573
+ @update:model-value="(v: string) => onBetweenBoundChange(condition.id, 1, v)"
574
+ />
575
+ </div>
576
+ <!-- in/nin with predefined options: multiselect -->
577
+ <SelectInput
578
+ v-else-if="getFieldOptions(condition.field) && isMultiOperator(condition.operator)"
579
+ :key="`${condition.id}-${condition.field}-multi`"
580
+ :model-value="selectMultiModelValue(condition.value)"
581
+ :options="getFieldOptions(condition.field)!"
582
+ :placeholder="currentTexts.placeholders.selectOption"
583
+ class="m-0 light-input borderHover" searchable multiselect
584
+ @update:model-value="(v: string[]) => onValueChange(condition.id, v)"
585
+ />
586
+ <!-- in/nin without options: comma-separated free-text list -->
587
+ <TextInput
588
+ v-else-if="isFreeListOperator(condition)"
589
+ :key="`${condition.id}-${condition.field}-freelist`"
590
+ :model-value="listToText(condition.value)"
591
+ :placeholder="currentTexts.placeholders.commaSeparated"
592
+ class="m-0 light-input borderHover"
593
+ @update:model-value="(v: string) => onValueChange(condition.id, textToList(v))"
594
+ />
595
+ <SelectInput
596
+ v-else-if="getFieldOptions(condition.field)"
597
+ :key="`${condition.id}-${condition.field}-single`"
598
+ :model-value="selectModelValue(condition.value)"
599
+ :options="getFieldOptions(condition.field)!"
600
+ :placeholder="currentTexts.placeholders.selectOption"
601
+ class="m-0 light-input borderHover" searchable
602
+ @update:model-value="(v: string) => onValueChange(condition.id, v)"
603
+ />
604
+ <SelectInput
605
+ v-else-if="getFieldType(condition.field) === 'boolean'"
606
+ :key="`${condition.id}-${condition.field}-bool`"
607
+ :model-value="selectModelValue(condition.value)" :options="booleanOptions"
608
+ :placeholder="currentTexts.placeholders.selectOption"
609
+ class="m-0 light-input borderHover"
610
+ @update:model-value="(v: boolean) => onValueChange(condition.id, v)"
611
+ />
612
+ <DateInput
613
+ v-else-if="getFieldType(condition.field) === 'date'"
614
+ :key="`${condition.id}-${condition.field}-date`"
615
+ :model-value="(condition.value as string)"
616
+ :placeholder="currentTexts.placeholders.selectDate" class="m-0 light-input borderHover"
617
+ @update:model-value="(v: any) => onValueChange(condition.id, String(v))"
618
+ />
619
+ <TextInput
620
+ v-else-if="getFieldType(condition.field) === 'number'"
621
+ :key="`${condition.id}-${condition.field}-number`"
622
+ :model-value="(condition.value as string)" placeholder="0" type="number"
623
+ class="m-0 light-input borderHover"
624
+ @update:model-value="(v: string) => onValueChange(condition.id, v)"
625
+ />
626
+ <TextInput
627
+ v-else :model-value="(condition.value as string)"
628
+ :placeholder="currentTexts.placeholders.enterValue" class="m-0 light-input borderHover"
629
+ @update:model-value="(v: string) => onValueChange(condition.id, v)"
630
+ />
631
+ </template>
632
+ <div v-else />
633
+ </template>
634
+
635
+ <!-- Remove button -->
636
+ <Btn
637
+ icon="close" sm flat size="sm"
638
+ :class="{ 'm_bg-gray-40 m_px-3 m_mx-auto': !props.desktopLayoutOnMobile }"
639
+ @click="removeCondition(index)"
640
+ />
641
+ </div>
642
+ </TransitionGroup>
643
+ </div>
644
+
645
+ <div class="flex gap-1 space-between m_flex-wrap">
646
+ <Btn icon="add" flat sm :value="currentTexts.buttons.addCondition" @click="addCondition" />
647
+ <div v-if="!props.hideFooterActions" class="flex gap-05">
648
+ <Btn
649
+ v-if="conditions.length > 0" icon="delete_sweep" flat sm color="gray"
650
+ :value="currentTexts.buttons.clearAll" @click="clearAll"
651
+ />
652
+ <Btn
653
+ v-if="hasSaveListener" :disabled="conditions.length === 0" class="color-green" icon="save" sm
654
+ color="green-light" :value="$t('filter.buttons.save')"
655
+ @click="emit('save', internalModel.filter(isComplete))"
656
+ />
657
+ </div>
658
+ </div>
659
+ </div>
660
+ </template>
661
+
662
+ <style>
663
+ .filter-query-wrap{
664
+ font-size: var(--bgl-input-font-size);
665
+ }
666
+ .and-or-select {
667
+ --bgl-input-font-size: 12px !important;
668
+ --input-background-color: transparent !important;
669
+ min-width: 60px !important;
670
+ }
671
+
672
+ .between-inputs {
673
+ min-width: 0;
674
+ }
675
+ .between-inputs > * {
676
+ min-width: 0;
677
+ flex: 1 1 0;
678
+ }
679
+ .between-inputs > span {
680
+ flex: 0 0 auto;
681
+ }
682
+
683
+ .and-or-select .selectinput-btn {
684
+ border: none;
685
+ width: 100%;
686
+ box-shadow: none;
687
+ padding: 0 0.5rem !important;
688
+ font-size: 12px !important;
689
+ width: 100%;
690
+ }
691
+
692
+ .first-filter-row {
693
+ grid-template-columns: minmax(calc(140px + 0.25rem), 0.5fr) minmax(170px, 0.75fr) minmax(120px, 0.5fr) auto;
694
+ padding-top: 0 !important;
695
+ }
696
+
697
+ .filter-row {
698
+ grid-template-columns: 50px minmax(90px, 0.5fr) minmax(170px, 0.75fr) minmax(120px, 0.5fr) auto;
699
+ }
700
+
701
+ .filter-query-inline {
702
+ width: 100%;
703
+ max-width: 100%;
704
+ min-width: 0;
705
+ box-sizing: border-box;
706
+ }
707
+
708
+ .filter-query-inline > *,
709
+ .filter-query-inline .m_overflow,
710
+ .filter-query-inline .first-filter-row > *,
711
+ .filter-query-inline .filter-row > * {
712
+ max-width: 100%;
713
+ min-width: 0;
714
+ box-sizing: border-box;
715
+ }
716
+
717
+ .filter-query-inline .m_overflow {
718
+ overflow-x: hidden;
719
+ overflow-y: visible;
720
+ max-height: none;
721
+ }
722
+
723
+ .filter-query-inline .filter-row {
724
+ grid-template-columns: 60px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
725
+ }
726
+
727
+ .filter-query-inline .first-filter-row {
728
+ grid-template-columns: 60px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
729
+ }
730
+
731
+ .filter-query-inline .first-filter-field {
732
+ grid-column: span 2;
733
+ }
734
+
735
+ .filter-query-inline .min-w-450px {
736
+ min-width: 0 !important;
737
+ }
738
+
739
+ /* Transition animations */
740
+ .condition-enter-active,
741
+ .condition-leave-active {
742
+ transition: all 0.25s ease;
743
+ }
744
+
745
+ .condition-enter-from {
746
+ opacity: 0;
747
+ transform: translateX(-10px);
748
+ }
749
+
750
+ .condition-leave-to {
751
+ opacity: 0;
752
+ transform: translateX(10px);
753
+ }
754
+
755
+ :dir(rtl) .condition-enter-from {
756
+ transform: translateX(10px);
757
+ }
758
+
759
+ :dir(rtl) .condition-leave-to {
760
+ transform: translateX(-10px);
761
+ }
762
+
763
+ @media (max-width: 910px) {
764
+
765
+ .filter-row,
766
+ .first-filter-row {
767
+ grid-template-columns: auto;
768
+ }
769
+
770
+ .filter-query-desktop-mobile .filter-row,
771
+ .filter-query-desktop-mobile .first-filter-row {
772
+ grid-template-columns: 50px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) auto;
773
+ }
774
+
775
+ .filter-query-desktop-mobile .first-filter-row > *,
776
+ .filter-query-desktop-mobile .filter-row > * {
777
+ min-width: 0;
778
+ }
779
+
780
+ .filter-query-desktop-mobile .first-filter-field {
781
+ grid-column: span 2;
782
+ }
783
+ }
784
+
785
+ </style>
786
+
787
+ <style>
788
+
789
+ .borderHover * {
790
+ transition: all 0.2s ease-in-out !important;
791
+ }
792
+
793
+ .borderHover:hover {
794
+ --bgl-border-color: var(--bgl-primary);
795
+ }
796
+
797
+ </style>