@dataloop-ai/components 0.19.17 → 0.19.19
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 +53 -4
- package/src/utils/index.ts +1 -0
- package/src/utils.ts +0 -3
package/package.json
CHANGED
|
@@ -465,7 +465,8 @@ const isValidBoolean = (str: string) => {
|
|
|
465
465
|
const isValidString = (str: string) => {
|
|
466
466
|
const match = str.match(/(?<=\")(.*?)(?=\")|(?<=\')(.*?)(?=\')/)
|
|
467
467
|
if (!match) return false
|
|
468
|
-
|
|
468
|
+
const trimmed = str.trim()
|
|
469
|
+
return match[0] === trimmed.substring(1, trimmed.length - 1)
|
|
469
470
|
}
|
|
470
471
|
|
|
471
472
|
const getOperatorByDataType = (dataType: string) => {
|
|
@@ -595,12 +596,60 @@ const isNextCharSpace = (input: string, str: string) => {
|
|
|
595
596
|
const matchStringEnd = (input: string, str: string) =>
|
|
596
597
|
input.lastIndexOf(str + '" ') > -1 || input.lastIndexOf(str + "' ") > -1
|
|
597
598
|
|
|
598
|
-
|
|
599
|
+
const removeAllBrackets = (str: string) => {
|
|
599
600
|
return str.replace(/\(/g, '').replace(/\)/g, '')
|
|
600
601
|
}
|
|
601
602
|
|
|
602
|
-
const
|
|
603
|
-
|
|
603
|
+
export const removeBrackets = (str: string) => {
|
|
604
|
+
const quotesAt = []
|
|
605
|
+
for (let i = 0; i < str.length; i++) {
|
|
606
|
+
if (/['"]/.test(str.charAt(i))) {
|
|
607
|
+
quotesAt.push(i)
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
let result = removeAllBrackets(str.substring(0, quotesAt[0]))
|
|
612
|
+
|
|
613
|
+
let skipFrom = 0;
|
|
614
|
+
let skipTo = 1
|
|
615
|
+
while (quotesAt[skipFrom] !== undefined) {
|
|
616
|
+
// skip as far as isValidString fails
|
|
617
|
+
while (
|
|
618
|
+
!isValidString(
|
|
619
|
+
str.substring(
|
|
620
|
+
quotesAt[skipFrom],
|
|
621
|
+
(quotesAt[skipTo] || str.length) + 1
|
|
622
|
+
)
|
|
623
|
+
)
|
|
624
|
+
) {
|
|
625
|
+
skipTo++
|
|
626
|
+
if (!quotesAt[skipTo]) break
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
// this is either unifished invalid string or finished valid string - keep it as is
|
|
630
|
+
result += str.substring(
|
|
631
|
+
quotesAt[skipFrom],
|
|
632
|
+
(quotesAt[skipTo] || str.length) + 1
|
|
633
|
+
)
|
|
634
|
+
|
|
635
|
+
if (quotesAt[skipTo]) {
|
|
636
|
+
// there might still be something after the string
|
|
637
|
+
skipFrom = skipTo + 1
|
|
638
|
+
result += removeAllBrackets(
|
|
639
|
+
str.substring(
|
|
640
|
+
quotesAt[skipTo] + 1,
|
|
641
|
+
quotesAt[skipFrom] || str.length
|
|
642
|
+
)
|
|
643
|
+
)
|
|
644
|
+
|
|
645
|
+
skipTo = skipFrom + 1
|
|
646
|
+
} else {
|
|
647
|
+
// there is nothing left
|
|
648
|
+
break
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
return result
|
|
604
653
|
}
|
|
605
654
|
|
|
606
655
|
const getValueSuggestions = (dataType: string | string[], operator: string) => {
|
package/src/utils/index.ts
CHANGED
package/src/utils.ts
DELETED