@dataloop-ai/components 0.19.167 → 0.19.169

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.167",
3
+ "version": "0.19.169",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -59,7 +59,7 @@
59
59
  ref="suggestionsDropdown"
60
60
  v-model="showSuggestions"
61
61
  :parent-id="`${uuid}`"
62
- :trigger-percentage="0.5"
62
+ :trigger-percentage="0.1"
63
63
  :disabled="disabled"
64
64
  :suggestions="suggestions"
65
65
  :offset="menuOffset"
@@ -120,7 +120,7 @@ import {
120
120
  setSelectionOffset
121
121
  } from '../../../../../utils'
122
122
  import { ColorSchema, SearchStatus, SyntaxColorSchema } from '../types'
123
- import { debounce, isEqual } from 'lodash'
123
+ import { cloneDeep, debounce, isEqual } from 'lodash'
124
124
  import { DlTooltip } from '../../../../shared'
125
125
  import SuggestionsDropdown from './SuggestionsDropdown.vue'
126
126
  import { DateInterval } from '../../../DlDateTime/types'
@@ -296,9 +296,11 @@ export default defineComponent({
296
296
 
297
297
  showSuggestions.value = false
298
298
 
299
- // to handle typing . after accepting a suggestion
300
- if (/\s+\.$/.test(value)) {
301
- value = value.replace(/\s+\.$/, '.')
299
+ // to handle typing . or , after accepting a suggestion
300
+ const dotOrCommaRegEx = /\s+([\.|\,]\s?)$/
301
+ const dotOrCommaMatch = value.match(dotOrCommaRegEx)
302
+ if (dotOrCommaMatch) {
303
+ value = value.replace(dotOrCommaRegEx, dotOrCommaMatch[1])
302
304
  }
303
305
 
304
306
  // to handle date suggestion modal to open automatically.
@@ -493,6 +495,12 @@ export default defineComponent({
493
495
  focused.value = true
494
496
  if (suggestions.value.length) {
495
497
  showSuggestions.value = true
498
+
499
+ nextTick(() => {
500
+ setMenuOffset(
501
+ isEligibleToChange(input.value, expanded.value)
502
+ )
503
+ })
496
504
  }
497
505
  emit('focus')
498
506
  }
@@ -506,7 +514,7 @@ export default defineComponent({
506
514
  emit('blur')
507
515
  }
508
516
 
509
- const blur = (e: Event) => {
517
+ const blur = () => {
510
518
  if (showDatePicker.value) {
511
519
  return
512
520
  }
@@ -583,7 +591,7 @@ export default defineComponent({
583
591
 
584
592
  const onInput = (e: Event) => {
585
593
  const text = (e.target as HTMLElement).textContent
586
- if (text.endsWith('.')) {
594
+ if (text.endsWith('.') || text.endsWith(',')) {
587
595
  setInputValue(text)
588
596
  } else {
589
597
  debouncedSetInputValue.value(text)
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <div v-if="suggestions.length > 0" class="dl-suggestions-dropdown">
3
3
  <dl-menu
4
+ ref="menu"
4
5
  :target="defaultTarget"
5
6
  :offset="offset"
6
7
  :disabled="disabled"
@@ -10,6 +11,7 @@
10
11
  :auto-close="false"
11
12
  :toggle-key="null"
12
13
  max-width="250px"
14
+ :ignore-events="['click']"
13
15
  @update:model-value="emitModelValue($event)"
14
16
  @show="onShow"
15
17
  @hide="onHide"
@@ -93,15 +95,16 @@ export default defineComponent({
93
95
  },
94
96
  emits: ['set-input-value', 'update:model-value', 'escapekey', 'enterkey'],
95
97
  setup(props, { emit }) {
98
+ const menu = ref(null)
96
99
  const { suggestions } = toRefs(props)
97
100
 
98
101
  const isMenuOpen = ref(false)
99
102
  const highlightedIndex = ref(-1)
100
- const onShow = (value: any) => {
101
- isMenuOpen.value = !!value
103
+ const onShow = () => {
104
+ isMenuOpen.value = true
102
105
  }
103
- const onHide = (value: any) => {
104
- isMenuOpen.value = !value
106
+ const onHide = () => {
107
+ isMenuOpen.value = false
105
108
  }
106
109
 
107
110
  const setHighlightedIndex = (value: any) => {
@@ -137,11 +140,16 @@ export default defineComponent({
137
140
  return match ? match[1] : str
138
141
  }
139
142
 
143
+ const updatePosition = () => {
144
+ menu.value?.updatePosition()
145
+ }
146
+
140
147
  watch(suggestions, () => {
141
148
  highlightedIndex.value = -1
142
149
  })
143
150
 
144
151
  return {
152
+ menu,
145
153
  defaultTarget,
146
154
  setHighlightedIndex,
147
155
  handleSelectedItem,
@@ -151,7 +159,8 @@ export default defineComponent({
151
159
  onHide,
152
160
  emitModelValue,
153
161
  handleOption,
154
- onEscapeKey
162
+ onEscapeKey,
163
+ updatePosition
155
164
  }
156
165
  }
157
166
  })
@@ -168,6 +168,10 @@ export default defineComponent({
168
168
  toggleKey: {
169
169
  type: String,
170
170
  default: 'Enter'
171
+ },
172
+ ignoreEvents: {
173
+ type: [String, Array] as PropType<string | string[]>,
174
+ default: null
171
175
  }
172
176
  },
173
177
 
@@ -191,7 +195,7 @@ export default defineComponent({
191
195
 
192
196
  const innerRef: Ref<HTMLElement | null> = ref(null)
193
197
  const showing = ref(false)
194
- const { toggleKey, arrowNavItems } = toRefs(props)
198
+ const { toggleKey, arrowNavItems, ignoreEvents } = toRefs(props)
195
199
 
196
200
  const { registerTick, removeTick } = useTick()
197
201
  const { registerTimeout, removeTimeout } = useTimeout()
@@ -202,7 +206,10 @@ export default defineComponent({
202
206
  unconfigureScrollTarget
203
207
  } = useScrollTarget(props, configureScrollTarget)
204
208
 
205
- const { anchorEl, canShow } = useAnchor({ toggleKey: toggleKey.value })
209
+ const { anchorEl, canShow } = useAnchor({
210
+ toggleKey: toggleKey.value,
211
+ ignoreEvents: ignoreEvents.value
212
+ })
206
213
 
207
214
  const screen = useWindowSize()
208
215
 
@@ -47,6 +47,7 @@
47
47
  :color-schema="colorSchema"
48
48
  :strict="strictState"
49
49
  :disabled="switchState"
50
+ placeholder="THIS IS A PLACEHOOOOOOOOLDER"
50
51
  @search="onSearchEmitted"
51
52
  />
52
53
 
@@ -51,11 +51,12 @@ export default function useAnchor(
51
51
  options: {
52
52
  configureAnchorEl?: Function
53
53
  toggleKey?: string | number
54
+ ignoreEvents?: string | string[]
54
55
  } = {}
55
56
  ) {
56
57
  const { props, proxy, emit } = getCurrentInstance()!
57
58
  const { toggleKey } = options
58
- let { configureAnchorEl } = options
59
+ let { configureAnchorEl, ignoreEvents } = options
59
60
 
60
61
  const anchorEl: Ref<HTMLElement | Element | null> = ref(null)
61
62
 
@@ -111,22 +112,45 @@ export default function useAnchor(
111
112
  return
112
113
  }
113
114
 
114
- let evts
115
+ let evts: any[]
116
+
117
+ const filteredEvents = (events: string[]) => {
118
+ if (!ignoreEvents) {
119
+ return events
120
+ }
121
+
122
+ ignoreEvents = Array.isArray(ignoreEvents)
123
+ ? ignoreEvents
124
+ : [ignoreEvents]
125
+
126
+ return events.filter((evt) => ignoreEvents.includes(evt))
127
+ }
115
128
 
116
129
  if (context === true) {
117
130
  evts = [
118
- [anchorEl.value, 'mousedown', 'hide', 'passive'],
119
131
  [
120
132
  anchorEl.value,
121
- 'contextmenu',
122
- 'contextClick',
123
- 'notPassive'
133
+ ...filteredEvents(['mousedown', 'hide', 'passive'])
134
+ ],
135
+ [
136
+ anchorEl.value,
137
+ ...filteredEvents([
138
+ 'contextmenu',
139
+ 'contextClick',
140
+ 'notPassive'
141
+ ])
124
142
  ]
125
143
  ]
126
144
  } else {
127
145
  evts = [
128
- [anchorEl.value, 'click', 'toggle', 'passive'],
129
- [anchorEl.value, 'keyup', 'toggleKey', 'passive']
146
+ [
147
+ anchorEl.value,
148
+ ...filteredEvents(['click', 'toggle', 'passive'])
149
+ ],
150
+ [
151
+ anchorEl.value,
152
+ ...filteredEvents(['keyup', 'toggleKey', 'passive'])
153
+ ]
130
154
  ]
131
155
  }
132
156
 
@@ -108,9 +108,10 @@ const mergeWords = (words: string[]) => {
108
108
 
109
109
  if (merging) {
110
110
  if (!result[mergeIndex]) {
111
- result[mergeIndex] = ''
111
+ result[mergeIndex] = currentItem
112
+ } else if (currentItem) {
113
+ result[mergeIndex] += ' ' + currentItem
112
114
  }
113
- result[mergeIndex] += ' ' + currentItem
114
115
  continue
115
116
  }
116
117
 
@@ -322,6 +323,10 @@ export const useSuggestions = (
322
323
 
323
324
  localSuggestions = [Logical.AND, Logical.OR]
324
325
 
326
+ if (operator === operators.$in || operator === operators.$nin) {
327
+ localSuggestions.unshift(',')
328
+ }
329
+
325
330
  if (!keyword) continue
326
331
 
327
332
  localSuggestions = getMatches(localSuggestions, keyword)
@@ -559,10 +564,23 @@ const getOperatorByDataType = (dataType: string) => {
559
564
  const getOperators = (op: string[]) => op.map((o) => operators[o])
560
565
 
561
566
  const mapWordsToExpression = (words: string[]): Expression => {
567
+ let operator = words[1] ?? null
568
+ let value = words[2] ?? null
569
+
570
+ if (operator === operators.$in || operator === operators.$nin) {
571
+ if (value && /\,\s?$/.test(value)) {
572
+ value = ''
573
+ }
574
+ }
575
+
576
+ if (value === null) {
577
+ operator = null
578
+ }
579
+
562
580
  return {
563
581
  field: words[0] ?? null,
564
- operator: words[1] ?? null,
565
- value: words[2] ?? null,
582
+ operator,
583
+ value,
566
584
  keyword: words[3] ?? null
567
585
  }
568
586
  }