@dataloop-ai/components 0.19.161 → 0.19.163
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 +1 -1
- package/src/hooks/use-suggestions.ts +34 -17
package/package.json
CHANGED
|
@@ -123,7 +123,11 @@ const mergeWords = (words: string[]) => {
|
|
|
123
123
|
export const useSuggestions = (
|
|
124
124
|
schema: Ref<Schema>,
|
|
125
125
|
aliases: Ref<Alias[]>,
|
|
126
|
-
options: {
|
|
126
|
+
options: {
|
|
127
|
+
strict?: Ref<boolean>
|
|
128
|
+
forbiddenKeys?: Ref<string[]>
|
|
129
|
+
omitSuggestions?: Ref<string[]>
|
|
130
|
+
} = {}
|
|
127
131
|
) => {
|
|
128
132
|
const { strict, forbiddenKeys, omitSuggestions } = options
|
|
129
133
|
const aliasesArray = aliases.value ?? []
|
|
@@ -159,7 +163,10 @@ export const useSuggestions = (
|
|
|
159
163
|
const expressions = mapWordsToExpressions(mergedWords)
|
|
160
164
|
|
|
161
165
|
error.value = input.length
|
|
162
|
-
? getError(schemaValue, aliasesArray, expressions, {
|
|
166
|
+
? getError(schemaValue, aliasesArray, expressions, {
|
|
167
|
+
strict,
|
|
168
|
+
forbiddenKeys
|
|
169
|
+
})
|
|
163
170
|
: null
|
|
164
171
|
}
|
|
165
172
|
|
|
@@ -191,7 +198,9 @@ export const useSuggestions = (
|
|
|
191
198
|
if (!matchedField && isNextCharSpace(input, field)) {
|
|
192
199
|
localSuggestions =
|
|
193
200
|
value && input.endsWith(space)
|
|
194
|
-
?
|
|
201
|
+
? keyword
|
|
202
|
+
? sortedSuggestions
|
|
203
|
+
: [Logical.AND, Logical.OR]
|
|
195
204
|
: []
|
|
196
205
|
continue
|
|
197
206
|
}
|
|
@@ -274,19 +283,25 @@ export const useSuggestions = (
|
|
|
274
283
|
}
|
|
275
284
|
|
|
276
285
|
if (Array.isArray(dataType)) {
|
|
277
|
-
|
|
278
|
-
.
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
)
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
+
const filteredTypes = dataType.filter(
|
|
287
|
+
(type) => !knownDataTypes.includes(type as string)
|
|
288
|
+
)
|
|
289
|
+
const mappedTypes: string[] = []
|
|
290
|
+
for (const type of filteredTypes) {
|
|
291
|
+
if (typeof type === 'string') {
|
|
292
|
+
mappedTypes.push(`'${type}'`)
|
|
293
|
+
} else if (typeof type === 'object') {
|
|
294
|
+
mappedTypes.push(
|
|
295
|
+
...Object.keys(type).map((key) => `'${key}'`)
|
|
296
|
+
)
|
|
297
|
+
} else {
|
|
298
|
+
mappedTypes.push(type)
|
|
299
|
+
}
|
|
300
|
+
}
|
|
286
301
|
|
|
287
302
|
if (!value) continue
|
|
288
303
|
|
|
289
|
-
localSuggestions = getMatches(
|
|
304
|
+
localSuggestions = getMatches(mappedTypes, value)
|
|
290
305
|
} else if (
|
|
291
306
|
dataType === 'datetime' ||
|
|
292
307
|
dataType === 'date' ||
|
|
@@ -362,7 +377,7 @@ const getError = (
|
|
|
362
377
|
schema: Schema,
|
|
363
378
|
aliases: Alias[],
|
|
364
379
|
expressions: Expression[],
|
|
365
|
-
options: { strict?: Ref<boolean>; forbiddenKeys?: Ref<string[]
|
|
380
|
+
options: { strict?: Ref<boolean>; forbiddenKeys?: Ref<string[]> } = {}
|
|
366
381
|
): string | null => {
|
|
367
382
|
const { strict, forbiddenKeys } = options
|
|
368
383
|
const hasErrorInStructure = expressions
|
|
@@ -438,7 +453,7 @@ const getError = (
|
|
|
438
453
|
return (acc = errors.INVALID_VALUE(field))
|
|
439
454
|
}
|
|
440
455
|
|
|
441
|
-
return
|
|
456
|
+
return acc === 'warning' ? acc : (acc = null)
|
|
442
457
|
}, null)
|
|
443
458
|
}
|
|
444
459
|
|
|
@@ -628,10 +643,12 @@ const getValueMatch = (
|
|
|
628
643
|
}
|
|
629
644
|
return null
|
|
630
645
|
}
|
|
631
|
-
const getMatches = (strArr: string[], str: string | number | boolean) =>
|
|
632
|
-
strArr.filter((val) =>
|
|
646
|
+
const getMatches = (strArr: string[], str: string | number | boolean) => {
|
|
647
|
+
const filtered = strArr.filter((val) =>
|
|
633
648
|
insensitive(val.toString()).includes(insensitive(str.toString()))
|
|
634
649
|
)
|
|
650
|
+
return filtered
|
|
651
|
+
}
|
|
635
652
|
|
|
636
653
|
const isNextCharSpace = (input: string, str: string) => {
|
|
637
654
|
const insensitiveInput = insensitive(input)
|