@dataloop-ai/components 0.19.133 → 0.19.134

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.19.133",
3
+ "version": "0.19.134",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -281,6 +281,11 @@ export default defineComponent({
281
281
 
282
282
  showSuggestions.value = false
283
283
 
284
+ // to handle typing . after accepting a suggestion
285
+ if (/\s+\.$/.test(value)) {
286
+ value = value.replace(/\s+\.$/, '.')
287
+ }
288
+
284
289
  // to handle date suggestion modal to open automatically.
285
290
  if (value.includes('(dd/mm/yyyy)')) {
286
291
  value = value.trimEnd()
@@ -316,6 +321,7 @@ export default defineComponent({
316
321
  }
317
322
 
318
323
  updateEditor(input.value, editorStyle.value)
324
+ setSelectionOffset(input.value, caretAt.value, caretAt.value)
319
325
  setMenuOffset(isEligibleToChange(input.value, expanded.value))
320
326
 
321
327
  if (!expanded.value) {
@@ -365,7 +371,12 @@ export default defineComponent({
365
371
  queryRightSide = leftover + queryRightSide
366
372
  } else if (value.startsWith('.')) {
367
373
  // dot notation case
368
- queryLeftSide = queryLeftSide.trimEnd().replace(/\.$/, '')
374
+ const words = queryLeftSide.trimEnd().split('.')
375
+ const lastWord = words.pop()
376
+ if (!value.startsWith('.' + lastWord)) {
377
+ words.push(lastWord)
378
+ }
379
+ queryLeftSide = words.join('.')
369
380
  } else if (queryLeftSide.endsWith(' ')) {
370
381
  // caret after space: only replace multiple spaces on the left
371
382
  queryLeftSide = queryLeftSide.trimEnd() + ' '
@@ -547,7 +558,11 @@ export default defineComponent({
547
558
 
548
559
  const onInput = (e: Event) => {
549
560
  const text = (e.target as HTMLElement).textContent
550
- debouncedSetInputValue(text)
561
+ if (text.endsWith('.')) {
562
+ setInputValue(text)
563
+ } else {
564
+ debouncedSetInputValue(text)
565
+ }
551
566
  }
552
567
 
553
568
  const onDateSelection = (value: DateInterval) => {
@@ -178,7 +178,7 @@ export const useSuggestions = (
178
178
 
179
179
  if (!field) continue
180
180
 
181
- const fieldSeparated: any = field.split('.')
181
+ const fieldSeparated: string[] = field.split('.')
182
182
 
183
183
  if (fieldSeparated.length > 1) {
184
184
  localSuggestions = []
@@ -229,21 +229,35 @@ export const useSuggestions = (
229
229
  localSuggestions = getOperators(ops)
230
230
 
231
231
  if (!operator) {
232
- const dotSeparated = matchedField.split('.').filter((el) => el)
232
+ const dotSeparated = matchedField.split('.')
233
+ const lastWord = dotSeparated.pop()
233
234
  let fieldOf = schemaValue
234
235
  for (const key of dotSeparated) {
235
236
  fieldOf = fieldOf[key] as Schema
236
237
  }
237
238
 
238
- if (isObject(fieldOf) && !Array.isArray(fieldOf)) {
239
- const toConcat: string[] = []
240
- for (const key of Object.keys(fieldOf)) {
239
+ const toAdd: string[] = []
240
+
241
+ if (fieldOf[lastWord]) {
242
+ fieldOf = fieldOf[lastWord] as Schema
243
+
244
+ if (isObject(fieldOf) && !Array.isArray(fieldOf)) {
245
+ for (const key of Object.keys(fieldOf)) {
246
+ if (key === '*') continue
247
+ toAdd.push(`.${key}`)
248
+ }
249
+ }
250
+ } else {
251
+ for (const key in fieldOf) {
241
252
  if (key === '*') continue
242
- toConcat.push(`.${key}`)
253
+ if (key.startsWith(lastWord)) {
254
+ toAdd.push(`.${key}`)
255
+ }
243
256
  }
244
- localSuggestions = localSuggestions.concat(toConcat)
245
257
  }
246
258
 
259
+ localSuggestions = toAdd.concat(localSuggestions)
260
+
247
261
  continue
248
262
  }
249
263