@bagelink/vue 1.9.63 → 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.63",
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
- import type { ComparisonOperator, LogicalOperator, QueryConditions } from './queryFilter'
4
- import { Btn, DateInput, Dropdown, Icon, SelectInput, TextInput, useI18n } from '@bagelink/vue'
3
+ import type { ComparisonOperator, LogicalOperator, QueryConditions } from '../utils/queryFilter'
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()}`
@@ -132,7 +134,8 @@ const booleanOptions = computed(() => [
132
134
  { label: currentTexts.value.boolean.false, value: 'false' },
133
135
  ])
134
136
 
135
- function parseValue(value: string): string | number | boolean | null {
137
+ function parseValue(value: string | number | boolean | null): string | number | boolean | null {
138
+ if (typeof value === 'number' || typeof value === 'boolean' || value === null) return value
136
139
  if (value === 'true') return true
137
140
  if (value === 'false') return false
138
141
  if (value === 'null') return null
@@ -140,7 +143,7 @@ function parseValue(value: string): string | number | boolean | null {
140
143
  return value
141
144
  }
142
145
 
143
- function updateConditionAtIndex(index: number, updates: Partial<{ field: string, op: ComparisonOperator, value: string, connector: LogicalOperator }>) {
146
+ function updateConditionAtIndex(index: number, updates: Partial<{ field: string, op: ComparisonOperator, value: string | number | boolean | null, connector: LogicalOperator }>) {
144
147
  const newModel = [...model.value]
145
148
  const existing = newModel[index]
146
149
  if (!existing) return
@@ -153,7 +156,8 @@ function updateConditionAtIndex(index: number, updates: Partial<{ field: string,
153
156
 
154
157
  newModel[index] = updated
155
158
  model.value = newModel
156
- 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)
157
161
  }
158
162
 
159
163
  function addCondition() {
@@ -166,7 +170,7 @@ function addCondition() {
166
170
  }
167
171
  const newModel = [...model.value, newCondition]
168
172
  model.value = newModel
169
- emit('change', newModel)
173
+ // don't emit incomplete new condition
170
174
  }
171
175
 
172
176
  function removeCondition(index: number) {
@@ -179,13 +183,13 @@ function removeCondition(index: number) {
179
183
  // Clean up ID mapping
180
184
  conditionIds.delete(index)
181
185
  model.value = newModel
182
- emit('change', newModel)
186
+ debouncedEmit(newModel)
183
187
  }
184
188
 
185
189
  function clearAll() {
186
190
  conditionIds.clear()
187
191
  model.value = []
188
- emit('change', [])
192
+ debouncedEmit([])
189
193
  }
190
194
 
191
195
  function getFieldType(fieldValue: string): string {
@@ -197,11 +201,11 @@ function needsValue(operator: ComparisonOperator): boolean {
197
201
  }
198
202
 
199
203
  const activeFiltersCount = computed(() => {
200
- return conditions.value.filter(c => Boolean(c.field) && (c.operator === 'pr' || Boolean(c.value))).length
204
+ return conditions.value.filter((c: UICondition) => Boolean(c.field) && (c.operator === 'pr' || Boolean(c.value))).length
201
205
  })
202
206
 
203
207
  function getConditionIndex(id: string): number {
204
- return conditions.value.findIndex(c => c.id === id)
208
+ return conditions.value.findIndex((c: UICondition) => c.id === id)
205
209
  }
206
210
 
207
211
  function onFieldChange(id: string, newField: string) {
@@ -244,8 +248,7 @@ function onConnectorChange(id: string, connector: LogicalOperator) {
244
248
  <TransitionGroup name="condition">
245
249
  <div
246
250
  v-for="(condition, index) in conditions" :key="condition.id"
247
- class="grid filter-row gap-025 align-items-center pt-025"
248
- :class="{
251
+ class="grid filter-row gap-025 align-items-center pt-025" :class="{
249
252
  'mt-025': index > 0 && condition.connector === 'or',
250
253
  'pt-075 border-top-or': index > 0 && condition.connector === 'or',
251
254
  }"
@@ -253,16 +256,14 @@ function onConnectorChange(id: string, connector: LogicalOperator) {
253
256
  <!-- Connector (AND/OR) -->
254
257
  <div v-if="index > 0" class="min-w-100px">
255
258
  <SelectInput
256
- :model-value="condition.connector || 'and'"
257
- :options="[
259
+ :model-value="condition.connector || 'and'" :options="[
258
260
  { label: currentTexts.connectors.and, value: 'and' },
259
261
  { label: currentTexts.connectors.or, value: 'or' },
260
- ]"
261
- class="m-0 and-or-select txt-12"
262
+ ]" class="m-0 and-or-select txt-12"
262
263
  @update:model-value="(v: LogicalOperator) => onConnectorChange(condition.id, v)"
263
264
  />
264
265
  </div>
265
- <div v-else class="" />
266
+ <div v-else />
266
267
 
267
268
  <!-- Field selector -->
268
269
  <SelectInput
@@ -340,6 +341,7 @@ function onConnectorChange(id: string, connector: LogicalOperator) {
340
341
  --input-font-size: 12px !important;
341
342
  --input-background-color: transparent !important;
342
343
  }
344
+
343
345
  .and-or-select .selectinput-btn {
344
346
  border: none;
345
347
  width: 100%;
@@ -160,6 +160,9 @@ function openModal() {
160
160
  color: var(--bgl-popup-text) !important;
161
161
  }
162
162
 
163
+ .modal .rich-text-editor .bgl_btn.bgl_btn_flat.active {
164
+ color: var(--bgl-white) !important;
165
+ }
163
166
  .modal-footer>div {
164
167
  gap: 1rem;
165
168
  display: flex;
package/src/i18n/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Composer, I18n } from 'vue-i18n'
2
- import { createI18n as createVueI18n, useI18n as useVueI18n } from 'vue-i18n'
2
+ import { createI18n as createVueI18n } from 'vue-i18n'
3
3
  import en from './locales/en.json'
4
4
  import es from './locales/es.json'
5
5
  import fr from './locales/fr.json'
@@ -91,19 +91,21 @@ interface UseI18nReturn {
91
91
  }
92
92
 
93
93
  /**
94
- * useI18n wrapper that returns bagelink's typed i18n functions
94
+ * useI18n wrapper that returns bagelink's typed i18n functions.
95
+ * Uses the global i18n instance directly to work in all contexts,
96
+ * including dialog containers mounted in a secondary app instance.
95
97
  */
96
98
  export function useI18n(): UseI18nReturn {
97
- const { t, locale, availableLocales, fallbackLocale, n, d } = useVueI18n()
99
+ const global = getI18n().global as Composer
98
100
 
99
101
  return {
100
- $t: t,
101
- t,
102
- locale,
103
- availableLocales,
104
- fallbackLocale,
105
- n,
106
- d,
102
+ $t: global.t,
103
+ t: global.t,
104
+ locale: global.locale,
105
+ availableLocales: global.availableLocales,
106
+ fallbackLocale: global.fallbackLocale,
107
+ n: global.n,
108
+ d: global.d,
107
109
  }
108
110
  }
109
111