@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.19.17",
3
+ "version": "0.19.19",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -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
- return match[0] === removeQuotes(str.trim())
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
- export const removeBrackets = (str: string) => {
599
+ const removeAllBrackets = (str: string) => {
599
600
  return str.replace(/\(/g, '').replace(/\)/g, '')
600
601
  }
601
602
 
602
- const removeQuotes = (str: string) => {
603
- return str.replaceAll('"', '').replaceAll("'", '')
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) => {
@@ -18,6 +18,7 @@ export * from './get-element-above'
18
18
  export * from './resizable-table'
19
19
  export * from './draggable-table'
20
20
  export * from './table-columns'
21
+ export * from './formatNumber'
21
22
 
22
23
  export const isMobileOrTablet = () => {
23
24
  let check = false
package/src/utils.ts DELETED
@@ -1,3 +0,0 @@
1
- import { abbreviateNumber } from './utils/formatNumber'
2
-
3
- export { abbreviateNumber }