@bagelink/vue 1.9.67 → 1.9.69

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/vue",
3
3
  "type": "module",
4
- "version": "1.9.67",
4
+ "version": "1.9.69",
5
5
  "description": "Bagel core sdk packages",
6
6
  "author": {
7
7
  "name": "Bagel Studio",
@@ -1,7 +1,7 @@
1
1
  <script setup lang="ts" generic="T extends Record<string, any>">
2
2
  import type { Option } from '@bagelink/vue'
3
3
  import type { ComparisonOperator, LogicalOperator, QueryConditions } from '../utils/queryFilter'
4
- import { Btn, DateInput, Dropdown, Icon, SelectInput, TextInput, useI18n } from '@bagelink/vue'
4
+ import { Btn, DateInput, Dropdown, Icon, SelectInput, TextInput, useI18n, useDebounceFn } from '@bagelink/vue'
5
5
  import { computed } from 'vue'
6
6
 
7
7
  type OptionsSource = Option[] | ((query: string) => Promise<Option[]>)
@@ -31,6 +31,8 @@ const model = defineModel<QueryConditions<T>>({ default: () => [] })
31
31
 
32
32
  const { $t } = useI18n()
33
33
 
34
+ const debouncedEmit = useDebounceFn((value: QueryConditions<T>) => { emit('change', value) }, 400)
35
+
34
36
  let conditionIdCounter = 0
35
37
  function generateId() {
36
38
  return `cond_${++conditionIdCounter}_${Date.now()}`
@@ -154,7 +156,8 @@ function updateConditionAtIndex(index: number, updates: Partial<{ field: string,
154
156
 
155
157
  newModel[index] = updated
156
158
  model.value = newModel
157
- emit('change', newModel)
159
+ const completeConditions = newModel.filter(c => c.field && c.op && (c.op === 'pr' || (c.value !== '' && c.value !== null && c.value !== undefined)))
160
+ debouncedEmit(completeConditions)
158
161
  }
159
162
 
160
163
  function addCondition() {
@@ -167,7 +170,7 @@ function addCondition() {
167
170
  }
168
171
  const newModel = [...model.value, newCondition]
169
172
  model.value = newModel
170
- emit('change', newModel)
173
+ // don't emit incomplete new condition
171
174
  }
172
175
 
173
176
  function removeCondition(index: number) {
@@ -180,13 +183,13 @@ function removeCondition(index: number) {
180
183
  // Clean up ID mapping
181
184
  conditionIds.delete(index)
182
185
  model.value = newModel
183
- emit('change', newModel)
186
+ debouncedEmit(newModel)
184
187
  }
185
188
 
186
189
  function clearAll() {
187
190
  conditionIds.clear()
188
191
  model.value = []
189
- emit('change', [])
192
+ debouncedEmit([])
190
193
  }
191
194
 
192
195
  function getFieldType(fieldValue: string): string {