@dataloop-ai/components 0.19.217 → 0.19.219
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
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
:style="textareaStyles"
|
|
30
30
|
:placeholder="inputPlaceholder"
|
|
31
31
|
:contenteditable="!disabled"
|
|
32
|
+
:spellcheck="false"
|
|
32
33
|
@keypress="onKeyPress"
|
|
33
34
|
@keyup.esc="onKeyPress"
|
|
34
35
|
@input="onInput"
|
|
@@ -468,28 +469,25 @@ export default defineComponent({
|
|
|
468
469
|
const forceStringsType = (data: string | Data): string | Data => {
|
|
469
470
|
const convertNode = (node: Data) => {
|
|
470
471
|
for (const key in node) {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
472
|
+
if (key !== '$exists') {
|
|
473
|
+
const value = node[key]
|
|
474
|
+
if (Array.isArray(value)) {
|
|
475
|
+
for (let i = 0; i < value.length; i++) {
|
|
476
|
+
value[i] = '' + value[i]
|
|
477
|
+
}
|
|
478
|
+
} else {
|
|
479
|
+
node[key] = '' + value
|
|
475
480
|
}
|
|
476
|
-
} else {
|
|
477
|
-
node[key] = '' + value
|
|
478
481
|
}
|
|
479
482
|
}
|
|
480
483
|
}
|
|
481
484
|
if (typeof data !== 'string' && schema.value) {
|
|
482
485
|
for (const key in data) {
|
|
483
486
|
const type = schema.value[key]
|
|
484
|
-
if (
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
} else {
|
|
489
|
-
data[key] = '' + data[key]
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
} else if (type === 'string') {
|
|
487
|
+
if (
|
|
488
|
+
(Array.isArray(type) && type.includes('string')) ||
|
|
489
|
+
type === 'string'
|
|
490
|
+
) {
|
|
493
491
|
if (typeof data[key] === 'object') {
|
|
494
492
|
convertNode(data[key])
|
|
495
493
|
} else {
|
|
@@ -425,6 +425,13 @@ export default defineComponent({
|
|
|
425
425
|
selectChildren: {
|
|
426
426
|
type: Boolean,
|
|
427
427
|
default: true
|
|
428
|
+
},
|
|
429
|
+
/**
|
|
430
|
+
* the label to show when items are selected
|
|
431
|
+
*/
|
|
432
|
+
selectedResourceLabel: {
|
|
433
|
+
type: String,
|
|
434
|
+
default: 'Selected Items'
|
|
428
435
|
}
|
|
429
436
|
},
|
|
430
437
|
emits: [
|
|
@@ -616,7 +623,7 @@ export default defineComponent({
|
|
|
616
623
|
return getLabelOfSelectedOption(valueToSearch, this.options)
|
|
617
624
|
}
|
|
618
625
|
return this.modelValueLength > 0
|
|
619
|
-
? `${this.modelValueLength}
|
|
626
|
+
? `${this.modelValueLength} ${this.selectedResourceLabel}`
|
|
620
627
|
: this.computedPlaceholder
|
|
621
628
|
},
|
|
622
629
|
computedAllItemsLabel(): string {
|
|
@@ -38,7 +38,9 @@ export const operators: Operators = {
|
|
|
38
38
|
$lt: '<', // number, date, datetime, time
|
|
39
39
|
$lte: '<=', // number, date, datetime, time
|
|
40
40
|
$in: 'IN', // all types
|
|
41
|
-
$nin: 'NOT-IN' // all types
|
|
41
|
+
$nin: 'NOT-IN', // all types
|
|
42
|
+
$exists: 'EXISTS', // all types
|
|
43
|
+
$doesnt_exist_dummy: 'DOESNT-EXIST' // all types
|
|
42
44
|
}
|
|
43
45
|
|
|
44
46
|
type OperatorToDataTypeMap = {
|
|
@@ -53,7 +55,9 @@ const operatorToDataTypeMap: OperatorToDataTypeMap = {
|
|
|
53
55
|
$lt: ['number', 'date', 'datetime', 'time'],
|
|
54
56
|
$lte: ['number', 'date', 'datetime', 'time'],
|
|
55
57
|
$in: [],
|
|
56
|
-
$nin: []
|
|
58
|
+
$nin: [],
|
|
59
|
+
$exists: [],
|
|
60
|
+
$doesnt_exist_dummy: []
|
|
57
61
|
}
|
|
58
62
|
|
|
59
63
|
const knownDataTypes = [
|
|
@@ -86,6 +90,8 @@ export const datePattern = new RegExp(
|
|
|
86
90
|
export const datePatternNoBrackets =
|
|
87
91
|
/(\d{2}\/\d{2}\/\d{4}\s?|\s?dd\/mm\/yyyy\s?)/
|
|
88
92
|
|
|
93
|
+
const existsValuePlaceholder = 'existsValuePlaceholder'
|
|
94
|
+
|
|
89
95
|
const mergeWords = (words: string[]) => {
|
|
90
96
|
const result: string[] = []
|
|
91
97
|
let merging = false
|
|
@@ -93,8 +99,18 @@ const mergeWords = (words: string[]) => {
|
|
|
93
99
|
|
|
94
100
|
for (let i = 0; i < words.length; ++i) {
|
|
95
101
|
const currentItem = words[i]
|
|
96
|
-
|
|
97
|
-
|
|
102
|
+
if (
|
|
103
|
+
currentItem === operators.$exists ||
|
|
104
|
+
currentItem === operators.$doesnt_exist_dummy
|
|
105
|
+
) {
|
|
106
|
+
merging = false
|
|
107
|
+
result.push(currentItem)
|
|
108
|
+
result.push(existsValuePlaceholder)
|
|
109
|
+
continue
|
|
110
|
+
} else if (
|
|
111
|
+
currentItem === operators.$in ||
|
|
112
|
+
currentItem === operators.$nin
|
|
113
|
+
) {
|
|
98
114
|
merging = true
|
|
99
115
|
result.push(currentItem)
|
|
100
116
|
mergeIndex = result.length
|
|
@@ -317,7 +333,12 @@ export const useSuggestions = (
|
|
|
317
333
|
localSuggestions = []
|
|
318
334
|
}
|
|
319
335
|
|
|
320
|
-
|
|
336
|
+
const lastTerm =
|
|
337
|
+
operator === operators.$exists ||
|
|
338
|
+
operator === operators.$doesnt_exist_dummy
|
|
339
|
+
? operator
|
|
340
|
+
: value
|
|
341
|
+
if (!lastTerm || !isNextCharSpace(input, lastTerm)) {
|
|
321
342
|
continue
|
|
322
343
|
}
|
|
323
344
|
|
|
@@ -35,7 +35,18 @@ const GeneratePureValue = (value: any) => {
|
|
|
35
35
|
return value
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
const Operators: string[] = [
|
|
38
|
+
const Operators: string[] = [
|
|
39
|
+
'>=',
|
|
40
|
+
'<=',
|
|
41
|
+
'!=',
|
|
42
|
+
'=',
|
|
43
|
+
'>',
|
|
44
|
+
'<',
|
|
45
|
+
'IN',
|
|
46
|
+
'NOT-IN',
|
|
47
|
+
'EXISTS',
|
|
48
|
+
'DOESNT-EXIST'
|
|
49
|
+
]
|
|
39
50
|
|
|
40
51
|
/**
|
|
41
52
|
* Method to convert a DlSmartSearch query string to Mongo based JSON query
|
|
@@ -103,51 +114,59 @@ export const parseSmartQuery = (
|
|
|
103
114
|
|
|
104
115
|
switch (true) {
|
|
105
116
|
case term.includes('>='):
|
|
106
|
-
[key, value] = term.split('>=').map((x) => x.trim())
|
|
117
|
+
;[key, value] = term.split('>=').map((x) => x.trim())
|
|
107
118
|
pureValue = GeneratePureValue(value)
|
|
108
119
|
if (pureValue !== null) {
|
|
109
120
|
andQuery.push({ [key]: { $gte: pureValue } })
|
|
110
121
|
}
|
|
111
122
|
break
|
|
112
123
|
case term.includes('<='):
|
|
113
|
-
[key, value] = term.split('<=').map((x) => x.trim())
|
|
124
|
+
;[key, value] = term.split('<=').map((x) => x.trim())
|
|
114
125
|
pureValue = GeneratePureValue(value)
|
|
115
126
|
if (pureValue !== null) {
|
|
116
127
|
andQuery.push({ [key]: { $lte: pureValue } })
|
|
117
128
|
}
|
|
118
129
|
break
|
|
119
130
|
case term.includes('>'):
|
|
120
|
-
[key, value] = term.split('>').map((x) => x.trim())
|
|
131
|
+
;[key, value] = term.split('>').map((x) => x.trim())
|
|
121
132
|
pureValue = GeneratePureValue(value)
|
|
122
133
|
if (pureValue !== null) {
|
|
123
134
|
andQuery.push({ [key]: { $gt: pureValue } })
|
|
124
135
|
}
|
|
125
136
|
break
|
|
126
137
|
case term.includes('<'):
|
|
127
|
-
[key, value] = term.split('<').map((x) => x.trim())
|
|
138
|
+
;[key, value] = term.split('<').map((x) => x.trim())
|
|
128
139
|
pureValue = GeneratePureValue(value)
|
|
129
140
|
if (pureValue !== null) {
|
|
130
141
|
andQuery.push({ [key]: { $lt: pureValue } })
|
|
131
142
|
}
|
|
132
143
|
break
|
|
133
144
|
case term.includes('!='):
|
|
134
|
-
[key, value] = term.split('!=').map((x) => x.trim())
|
|
145
|
+
;[key, value] = term.split('!=').map((x) => x.trim())
|
|
135
146
|
pureValue = GeneratePureValue(value)
|
|
136
147
|
if (pureValue !== null) {
|
|
137
148
|
andQuery.push({ [key]: { $ne: pureValue } })
|
|
138
149
|
}
|
|
139
150
|
break
|
|
140
151
|
case term.includes('='):
|
|
141
|
-
[key, value] = term.split('=').map((x) => x.trim())
|
|
152
|
+
;[key, value] = term.split('=').map((x) => x.trim())
|
|
142
153
|
pureValue = GeneratePureValue(value)
|
|
143
154
|
if (pureValue !== null) {
|
|
144
155
|
andQuery.push({ [key]: pureValue })
|
|
145
156
|
}
|
|
146
157
|
break
|
|
158
|
+
case term.includes('EXISTS'):
|
|
159
|
+
key = term.split('EXISTS')[0].trim()
|
|
160
|
+
andQuery.push({ [key]: { $exists: true } })
|
|
161
|
+
break
|
|
162
|
+
case term.includes('DOESNT-EXIST'):
|
|
163
|
+
key = term.split('DOESNT-EXIST')[0].trim()
|
|
164
|
+
andQuery.push({ [key]: { $exists: false } })
|
|
165
|
+
break
|
|
147
166
|
case term.includes('IN'):
|
|
148
|
-
[key, value] = term.split('IN').map((x) => x.trim())
|
|
167
|
+
;[key, value] = term.split('IN').map((x) => x.trim())
|
|
149
168
|
if (key.includes('NOT-')) {
|
|
150
|
-
[key, value] = term
|
|
169
|
+
;[key, value] = term
|
|
151
170
|
.split('NOT-IN')
|
|
152
171
|
.map((x) => x.trim())
|
|
153
172
|
queryValue = term
|
|
@@ -269,6 +288,11 @@ export const stringifySmartQuery = (query: { [key: string]: any }): string => {
|
|
|
269
288
|
case '$lte':
|
|
270
289
|
result += `${key} <= ${operatorValue}`
|
|
271
290
|
break
|
|
291
|
+
case '$exists':
|
|
292
|
+
result += `${key} ${
|
|
293
|
+
operatorValue ? 'EXISTS' : 'DOESNT-EXIST'
|
|
294
|
+
}`
|
|
295
|
+
break
|
|
272
296
|
case '$in':
|
|
273
297
|
if (!Array.isArray(operatorValue)) {
|
|
274
298
|
operatorValue = [operatorValue] as
|