@dataloop-ai/components 0.18.119 → 0.18.121

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.18.119",
3
+ "version": "0.18.121",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -349,7 +349,7 @@ export default defineComponent({
349
349
  stringValue = value + ' '
350
350
  }
351
351
 
352
- setInputValue(
352
+ debouncedSetInputValue(
353
353
  clearPartlyTypedSuggestion(input.value.innerText, stringValue)
354
354
  )
355
355
  setCaret(input.value)
@@ -452,10 +452,38 @@ export default defineComponent({
452
452
  }
453
453
  }
454
454
 
455
+ const endsWithOperator = computed(() => {
456
+ const operators = ['>=', '<=', '!=', '=', '>', '<', 'IN', 'NOT-IN']
457
+
458
+ for (const op of operators) {
459
+ if (
460
+ searchQuery.value.endsWith(op) ||
461
+ searchQuery.value.endsWith(`${op} `)
462
+ ) {
463
+ return true
464
+ }
465
+ }
466
+
467
+ return false
468
+ })
469
+
455
470
  const onKeyPress = (e: KeyboardEvent) => {
456
- if (e.key === 'Enter') {
471
+ if (e.code === 'Enter' || e.key === 'Enter') {
457
472
  e.preventDefault()
458
473
  e.stopPropagation()
474
+
475
+ if (showSuggestions.value || showDatePicker.value) {
476
+ return
477
+ }
478
+
479
+ if (endsWithOperator.value) {
480
+ return
481
+ }
482
+
483
+ if (!input.value.innerHTML.length) {
484
+ return
485
+ }
486
+
459
487
  emit('search', updateJSONQuery())
460
488
  showSuggestions.value = false
461
489
  return
@@ -467,10 +495,6 @@ export default defineComponent({
467
495
  }
468
496
 
469
497
  const onInput = (e: Event) => {
470
- if ((e as KeyboardEvent).key === 'Enter') {
471
- return
472
- }
473
-
474
498
  const text = (e.target as HTMLElement).textContent
475
499
  debouncedSetInputValue(text)
476
500
  }
@@ -36,6 +36,16 @@ export type SyntaxColorSchema = {
36
36
  }
37
37
  }
38
38
 
39
+ export type DLSmartSearchOperators =
40
+ | '>='
41
+ | '<='
42
+ | '!='
43
+ | '='
44
+ | '>'
45
+ | '<'
46
+ | 'IN'
47
+ | 'NOT-IN'
48
+
39
49
  import {
40
50
  Alias as DlSmartSearchAlias,
41
51
  Schema as DlSmartSearchSchema
@@ -112,19 +112,25 @@ export function replaceJSDatesWithStringifiedDates(
112
112
  const toReturn = cloneDeep(json)
113
113
 
114
114
  for (const key of Object.keys(toReturn)) {
115
- if (typeof toReturn[key] === 'object') {
116
- toReturn[key] = replaceJSDatesWithStringifiedDates(
117
- toReturn[key],
118
- dateKeys
119
- )
120
- continue
121
- }
122
-
123
115
  const value = toReturn[key]
124
116
  const keyToCheck = key.split('.').pop()
125
117
 
126
118
  if (dateKeys.includes(keyToCheck)) {
127
- toReturn[key] = formatToStringDate(value)
119
+ if (typeof value === 'object') {
120
+ const testKey = Object.keys(toReturn[key])[0]
121
+ if (['$gt', '$gte', '$lt', '$lte'].includes(testKey)) {
122
+ toReturn[key][testKey] = formatToStringDate(
123
+ toReturn[key][testKey]
124
+ )
125
+ }
126
+ } else {
127
+ toReturn[key] = formatToStringDate(value)
128
+ }
129
+ } else if (typeof value === 'object') {
130
+ toReturn[key] = replaceJSDatesWithStringifiedDates(
131
+ toReturn[key],
132
+ dateKeys
133
+ )
128
134
  }
129
135
  }
130
136