@dataloop-ai/components 0.20.100 → 0.20.101

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.20.100",
3
+ "version": "0.20.101",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -246,7 +246,7 @@ export default defineComponent({
246
246
  default: () => [] as string[]
247
247
  },
248
248
  operatorsOverride: {
249
- type: Object as PropType<{[name: string]: string[]}>,
249
+ type: Object as PropType<{ [name: string]: string[] }>,
250
250
  default: () => ({})
251
251
  },
252
252
  forbiddenKeys: {
@@ -335,28 +335,7 @@ export default defineComponent({
335
335
 
336
336
  showSuggestions.value = false
337
337
 
338
- // to handle typing . or , after accepting a suggestion
339
- const dotOrCommaRegEx = /\s+([\.|\,]\s?)$/
340
- const dotOrCommaMatch = value.match(dotOrCommaRegEx)
341
- if (dotOrCommaMatch) {
342
- value = value.replace(dotOrCommaRegEx, dotOrCommaMatch[1])
343
- }
344
-
345
- // to handle date suggestion modal to open automatically.
346
- if (value.includes(dateSuggestionPattern)) {
347
- value = value.trimEnd()
348
- }
349
-
350
- const specialSuggestions = suggestions.value.filter(
351
- (suggestion) =>
352
- typeof suggestion === 'string' && suggestion.startsWith('.')
353
- )
354
-
355
- for (const suggestion of specialSuggestions) {
356
- if (value.includes(suggestion)) {
357
- value = value.replace(` ${suggestion}`, suggestion)
358
- }
359
- }
338
+ value = _normalizeInputValue(value)
360
339
 
361
340
  searchQuery.value = value
362
341
 
@@ -408,6 +387,43 @@ export default defineComponent({
408
387
  }
409
388
  }
410
389
 
390
+ const _normalizeInputValue = (value: string): string => {
391
+ // Normalize logical operators (' and ' -> ' AND ', ' or ' -> ' OR ')
392
+ const logicalOperatorsRegEx = /\s(and|or)\s/g
393
+ const logicalMatch = value.match(logicalOperatorsRegEx)
394
+ if (logicalMatch) {
395
+ value = value.replace(
396
+ logicalOperatorsRegEx,
397
+ (_, match) => ` ${match.toUpperCase()} `
398
+ )
399
+ }
400
+
401
+ // Handle typing '.' or ',' after accepting a suggestion
402
+ const dotOrCommaRegEx = /\s+([.,]\s?)$/
403
+ const dotOrCommaMatch = value.match(dotOrCommaRegEx)
404
+ if (dotOrCommaMatch) {
405
+ value = value.replace(dotOrCommaRegEx, dotOrCommaMatch[1])
406
+ }
407
+
408
+ // Handle date suggestion modal to open automatically.
409
+ if (value.includes(dateSuggestionPattern)) {
410
+ value = value.trimEnd()
411
+ }
412
+
413
+ // Handle special suggestions (suggestions that start with '.')
414
+ const specialSuggestions = suggestions.value.filter(
415
+ (suggestion) =>
416
+ typeof suggestion === 'string' && suggestion.startsWith('.')
417
+ )
418
+ for (const suggestion of specialSuggestions) {
419
+ if (value.includes(suggestion)) {
420
+ value = value.replace(` ${suggestion}`, suggestion)
421
+ }
422
+ }
423
+
424
+ return value
425
+ }
426
+
411
427
  const setInputFromSuggestion = (suggestion: any) => {
412
428
  const value = '' + suggestion
413
429
  let stringValue = ''
@@ -639,18 +655,7 @@ export default defineComponent({
639
655
  }
640
656
 
641
657
  const endsWithOperator = computed(() => {
642
- const operators = [
643
- '>=',
644
- '<=',
645
- '!=',
646
- '=',
647
- '>',
648
- '<',
649
- 'IN',
650
- 'NOT-IN',
651
- 'EXISTS',
652
- 'DOESNT-EXIST'
653
- ]
658
+ const operators = ['>=', '<=', '!=', '=', '>', '<', 'IN', 'NOT-IN']
654
659
 
655
660
  for (const op of operators) {
656
661
  if (
@@ -689,7 +694,9 @@ export default defineComponent({
689
694
  const onPaste = (e: ClipboardEvent) => {
690
695
  const selection = window.getSelection()
691
696
  if (selection.rangeCount) {
692
- let text = (e.clipboardData || (window as any).clipboardData).getData('text')
697
+ let text = (
698
+ e.clipboardData || (window as any).clipboardData
699
+ ).getData('text')
693
700
  if (text?.length > 0) {
694
701
  const range = selection.getRangeAt(0)
695
702
 
@@ -701,19 +708,27 @@ export default defineComponent({
701
708
 
702
709
  const stringOperators = getStringOperators()
703
710
  if (
704
- new RegExp(`(,|\\s(${stringOperators.join('|')}))\\s*$`).test(preceedingText) &&
711
+ new RegExp(
712
+ `(,|\\s(${stringOperators.join('|')}))\\s*$`
713
+ ).test(preceedingText) &&
705
714
  !/^\s*['"]/.test(text) &&
706
715
  isNaN(Number(text)) &&
707
- text !== "false" &&
708
- text !== "true"
716
+ text !== 'false' &&
717
+ text !== 'true'
709
718
  ) {
710
719
  text = enquoteString(text)
711
720
  }
712
721
 
713
722
  selection.deleteFromDocument()
714
- selection.getRangeAt(0).insertNode(document.createTextNode(
715
- (preceedingText.endsWith(' ') ? '' : ' ') + text + ' '
716
- ))
723
+ selection
724
+ .getRangeAt(0)
725
+ .insertNode(
726
+ document.createTextNode(
727
+ (preceedingText.endsWith(' ') ? '' : ' ') +
728
+ text +
729
+ ' '
730
+ )
731
+ )
717
732
  selection.collapseToEnd()
718
733
 
719
734
  e.preventDefault()
@@ -893,7 +908,11 @@ export default defineComponent({
893
908
 
894
909
  //#region computed
895
910
  const editorStyle = computed((): SyntaxColorSchema => {
896
- return createColorSchema(colorSchema.value, aliases.value, schema.value)
911
+ return createColorSchema(
912
+ colorSchema.value,
913
+ aliases.value,
914
+ schema.value
915
+ )
897
916
  })
898
917
 
899
918
  const defaultIcon = 'icon-dl-stars'