@dataloop-ai/components 0.20.145 → 0.20.147

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.145",
3
+ "version": "0.20.147",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -646,7 +646,8 @@ export default defineComponent({
646
646
  'enter',
647
647
  'file-update',
648
648
  'update:model-value',
649
- 'suggestion-click'
649
+ 'suggestion-click',
650
+ 'keydown'
650
651
  ],
651
652
  setup(props, { emit }) {
652
653
  const mouseOverClear = ref(false)
@@ -1155,6 +1156,8 @@ export default defineComponent({
1155
1156
  return
1156
1157
  }
1157
1158
 
1159
+ this.$emit('keydown', e)
1160
+
1158
1161
  if (e.key !== 'Backspace') {
1159
1162
  /**
1160
1163
  * Allow only numbers
@@ -1640,3 +1643,4 @@ export default defineComponent({
1640
1643
  }
1641
1644
  }
1642
1645
  </style>
1646
+
@@ -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
- const logicalOperatorsRegEx = /\s(and|or)\s/g
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 = ''
@@ -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
+ }
@@ -80,6 +80,7 @@
80
80
  @blur="handleSearchBlur"
81
81
  @keyup.enter="handleSearchEnter"
82
82
  @keyup.esc="handleSearchEscape"
83
+ @keydown="handleSearchKeyDown"
83
84
  />
84
85
  <dl-tooltip v-if="disabled && disabledTooltip">
85
86
  {{ disabledTooltip }}
@@ -518,6 +519,7 @@ export default defineComponent({
518
519
  'search-blur',
519
520
  'search-enter',
520
521
  'search-escape',
522
+ 'search-keydown',
521
523
  'filter',
522
524
  'change',
523
525
  'search-input',
@@ -1117,6 +1119,11 @@ export default defineComponent({
1117
1119
  this.$emit('search-enter', e, this.searchInputValue)
1118
1120
  }
1119
1121
  },
1122
+ handleSearchKeyDown(e: KeyboardEvent): void {
1123
+ if (this.searchable) {
1124
+ this.$emit('search-keydown', e)
1125
+ }
1126
+ },
1120
1127
  handleSearchEscape(e: Event): void {
1121
1128
  if (this.searchable) {
1122
1129
  this.$emit('search-escape', e, this.searchInputValue)