@dataloop-ai/components 0.20.85 → 0.20.87

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.85",
3
+ "version": "0.20.87",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -32,6 +32,7 @@
32
32
  :spellcheck="false"
33
33
  @keypress="onKeyPress"
34
34
  @keyup.esc="onKeyPress"
35
+ @paste="onPaste"
35
36
  @input="onInput"
36
37
  @blur="blur"
37
38
  />
@@ -149,10 +150,9 @@ import {
149
150
  setSelectionOffset
150
151
  } from '../../../../../utils'
151
152
  import { ColorSchema, SearchStatus, SyntaxColorSchema } from '../types'
152
- import { cloneDeep, debounce, isEqual } from 'lodash'
153
+ import { debounce, isEqual } from 'lodash'
153
154
  import { DlTooltip } from '../../../../shared'
154
155
  import SuggestionsDropdown from './SuggestionsDropdown.vue'
155
- import { DateInterval } from '../../../DlDateTime/types'
156
156
  import {
157
157
  isEndingWithDateIntervalPattern,
158
158
  replaceDateInterval,
@@ -172,6 +172,8 @@ import {
172
172
  Schema,
173
173
  Alias,
174
174
  Data,
175
+ enquoteString,
176
+ getStringOperators,
175
177
  useSuggestions,
176
178
  removeBrackets,
177
179
  removeLeadingExpression,
@@ -678,6 +680,43 @@ export default defineComponent({
678
680
  }
679
681
  }
680
682
 
683
+ const onPaste = (e: ClipboardEvent) => {
684
+ const selection = window.getSelection()
685
+ if (selection.rangeCount) {
686
+ let text = (e.clipboardData || (window as any).clipboardData).getData('text')
687
+ if (text?.length > 0) {
688
+ const range = selection.getRangeAt(0)
689
+
690
+ const container = range.startContainer
691
+ const offset = range.startOffset
692
+ range.setStart(input.value, 0)
693
+ const preceedingText = selection.toString()
694
+ range.setStart(container, offset)
695
+
696
+ const stringOperators = getStringOperators()
697
+ if (
698
+ new RegExp(`(,|\\s(${stringOperators.join('|')}))\\s*$`).test(preceedingText) &&
699
+ !/^\s*['"]/.test(text) &&
700
+ isNaN(Number(text)) &&
701
+ text !== "false" &&
702
+ text !== "true"
703
+ ) {
704
+ text = enquoteString(text)
705
+ }
706
+
707
+ selection.deleteFromDocument()
708
+ selection.getRangeAt(0).insertNode(document.createTextNode(
709
+ (preceedingText.endsWith(' ') ? '' : ' ') + text + ' '
710
+ ))
711
+ selection.collapseToEnd()
712
+
713
+ e.preventDefault()
714
+
715
+ setInputValue(input.value.textContent)
716
+ }
717
+ }
718
+ }
719
+
681
720
  const onInput = (e: Event) => {
682
721
  const text = (e.target as HTMLElement).textContent
683
722
  if (text.endsWith('.') || text.endsWith(',')) {
@@ -1105,6 +1144,7 @@ export default defineComponent({
1105
1144
  blur,
1106
1145
  onClear,
1107
1146
  onKeyPress,
1147
+ onPaste,
1108
1148
  onInput,
1109
1149
  onDateSelection,
1110
1150
  onDateSelectionCancel,
@@ -12,15 +12,15 @@
12
12
  >
13
13
  {{ fullText }}
14
14
  </p>
15
- <span v-if="!multiline" ref="dlEllipsisRef" class="dl-ellipsis__left">
15
+ <span
16
+ v-if="!multiline"
17
+ ref="dlEllipsisRef"
18
+ :class="`dl-ellipsis__left ${textClass}`"
19
+ >
16
20
  <slot v-if="hasDefaultSlot" name="default" />
17
- <span
18
- v-else
19
- style="white-space: nowrap"
20
- :class="textClass"
21
- @click="onClick"
22
- >{{ leftText }}</span
23
- >
21
+ <span v-else style="white-space: nowrap" @click="onClick">{{
22
+ leftText
23
+ }}</span>
24
24
  </span>
25
25
  <span
26
26
  v-if="!multiline && rightText"
@@ -627,7 +627,7 @@ const isValidString = (str: string) => {
627
627
  return false
628
628
  }
629
629
 
630
- const enquoteString = (str: string) => {
630
+ export const enquoteString = (str: string) => {
631
631
  return `'${str.replace(/'/g, "\\'")}'`
632
632
  }
633
633
 
@@ -653,6 +653,11 @@ const getOperatorByDataType = (dataType: string) => {
653
653
 
654
654
  const getOperators = (op: string[]) => op.map((o) => operators[o])
655
655
 
656
+ export function getStringOperators() {
657
+ const keys = getOperatorByDataType('string').filter(key => !key.includes('exist'))
658
+ return getOperators(keys)
659
+ }
660
+
656
661
  const mapWordsToExpression = (words: string[]): Expression => {
657
662
  let operator = words[1] ?? null
658
663
  let value = words[2] ?? null