@dataloop-ai/components 0.20.146 → 0.20.148
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
|
@@ -164,7 +164,8 @@ import {
|
|
|
164
164
|
setAliases,
|
|
165
165
|
revertAliases,
|
|
166
166
|
setValueAliases,
|
|
167
|
-
revertValueAliases
|
|
167
|
+
revertValueAliases,
|
|
168
|
+
isInsideQuotedString
|
|
168
169
|
} from '../utils'
|
|
169
170
|
import { v4 } from 'uuid'
|
|
170
171
|
import {
|
|
@@ -399,14 +400,7 @@ export default defineComponent({
|
|
|
399
400
|
|
|
400
401
|
const _normalizeInputValue = (value: string): string => {
|
|
401
402
|
// Normalize logical operators (' and ' -> ' AND ', ' or ' -> ' OR ')
|
|
402
|
-
|
|
403
|
-
const logicalMatch = value.match(logicalOperatorsRegEx)
|
|
404
|
-
if (logicalMatch) {
|
|
405
|
-
value = value.replace(
|
|
406
|
-
logicalOperatorsRegEx,
|
|
407
|
-
(_, match) => ` ${match.toUpperCase()} `
|
|
408
|
-
)
|
|
409
|
-
}
|
|
403
|
+
value = _normalizeLogicalOperators(value)
|
|
410
404
|
|
|
411
405
|
// Handle typing '.' or ',' after accepting a suggestion
|
|
412
406
|
const dotOrCommaRegEx = /\s+([.,]\s?)$/
|
|
@@ -434,6 +428,18 @@ export default defineComponent({
|
|
|
434
428
|
return value
|
|
435
429
|
}
|
|
436
430
|
|
|
431
|
+
const _normalizeLogicalOperators = (value: string): string => {
|
|
432
|
+
const logicalOperatorsRegEx = /\s(and|or)\s/g
|
|
433
|
+
return value.replace(
|
|
434
|
+
logicalOperatorsRegEx,
|
|
435
|
+
(match, op, offset) => {
|
|
436
|
+
const textBeforeTheMatch = value.substring(0, offset)
|
|
437
|
+
const isMatchInsideQuotes = isInsideQuotedString(textBeforeTheMatch)
|
|
438
|
+
return isMatchInsideQuotes ? match : ` ${op.toUpperCase()} `
|
|
439
|
+
}
|
|
440
|
+
)
|
|
441
|
+
}
|
|
442
|
+
|
|
437
443
|
const setInputFromSuggestion = (suggestion: any) => {
|
|
438
444
|
const value = '' + suggestion
|
|
439
445
|
let stringValue = ''
|
|
@@ -729,9 +735,7 @@ export default defineComponent({
|
|
|
729
735
|
.getRangeAt(0)
|
|
730
736
|
.insertNode(
|
|
731
737
|
document.createTextNode(
|
|
732
|
-
|
|
733
|
-
text +
|
|
734
|
-
' '
|
|
738
|
+
text
|
|
735
739
|
)
|
|
736
740
|
)
|
|
737
741
|
selection.collapseToEnd()
|
|
@@ -409,3 +409,11 @@ export const isEligibleToChange = (target: HTMLElement, expanded: boolean) => {
|
|
|
409
409
|
return [-target.clientWidth, 5]
|
|
410
410
|
}
|
|
411
411
|
}
|
|
412
|
+
|
|
413
|
+
export const isInsideQuotedString = (textBeforePosition: string): boolean => {
|
|
414
|
+
// Count unescaped single and double quotes (using negative lookbehind to exclude escaped quotes)
|
|
415
|
+
const unescapedSingleQuotes = (textBeforePosition.match(/(?<!\\)'/g) || []).length
|
|
416
|
+
const unescapedDoubleQuotes = (textBeforePosition.match(/(?<!\\)"/g) || []).length
|
|
417
|
+
|
|
418
|
+
return unescapedSingleQuotes % 2 === 1 || unescapedDoubleQuotes % 2 === 1
|
|
419
|
+
}
|