@dataloop-ai/components 0.19.166 → 0.19.168
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 +1 -1
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +9 -3
- package/src/components/compound/DlSearches/DlSmartSearch/components/SuggestionsDropdown.vue +14 -5
- package/src/components/compound/DlSearches/DlSmartSearch/utils/index.ts +5 -1
- package/src/components/essential/DlMenu/DlMenu.vue +9 -2
- package/src/demos/SmartSearchDemo/DlSmartSearchDemo.vue +1 -0
- package/src/hooks/use-anchor.ts +32 -8
package/package.json
CHANGED
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
ref="suggestionsDropdown"
|
|
60
60
|
v-model="showSuggestions"
|
|
61
61
|
:parent-id="`${uuid}`"
|
|
62
|
-
:trigger-percentage="0.
|
|
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'
|
|
@@ -493,6 +493,12 @@ export default defineComponent({
|
|
|
493
493
|
focused.value = true
|
|
494
494
|
if (suggestions.value.length) {
|
|
495
495
|
showSuggestions.value = true
|
|
496
|
+
|
|
497
|
+
nextTick(() => {
|
|
498
|
+
setMenuOffset(
|
|
499
|
+
isEligibleToChange(input.value, expanded.value)
|
|
500
|
+
)
|
|
501
|
+
})
|
|
496
502
|
}
|
|
497
503
|
emit('focus')
|
|
498
504
|
}
|
|
@@ -506,7 +512,7 @@ export default defineComponent({
|
|
|
506
512
|
emit('blur')
|
|
507
513
|
}
|
|
508
514
|
|
|
509
|
-
const blur = (
|
|
515
|
+
const blur = () => {
|
|
510
516
|
if (showDatePicker.value) {
|
|
511
517
|
return
|
|
512
518
|
}
|
|
@@ -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 = (
|
|
101
|
-
isMenuOpen.value =
|
|
103
|
+
const onShow = () => {
|
|
104
|
+
isMenuOpen.value = true
|
|
102
105
|
}
|
|
103
|
-
const onHide = (
|
|
104
|
-
isMenuOpen.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
|
})
|
|
@@ -150,7 +150,11 @@ export function replaceJSDatesWithStringifiedDates(
|
|
|
150
150
|
if (dateKeys.includes(keyToCheck)) {
|
|
151
151
|
if (typeof value === 'object') {
|
|
152
152
|
const testKey = Object.keys(toReturn[key])[0]
|
|
153
|
-
if (
|
|
153
|
+
if (
|
|
154
|
+
['$gt', '$gte', '$lt', '$lte', '$eq', '$neq'].includes(
|
|
155
|
+
testKey
|
|
156
|
+
)
|
|
157
|
+
) {
|
|
154
158
|
toReturn[key][testKey] = formatToStringDate(
|
|
155
159
|
toReturn[key][testKey]
|
|
156
160
|
)
|
|
@@ -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({
|
|
209
|
+
const { anchorEl, canShow } = useAnchor({
|
|
210
|
+
toggleKey: toggleKey.value,
|
|
211
|
+
ignoreEvents: ignoreEvents.value
|
|
212
|
+
})
|
|
206
213
|
|
|
207
214
|
const screen = useWindowSize()
|
|
208
215
|
|
package/src/hooks/use-anchor.ts
CHANGED
|
@@ -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
|
-
'
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
[
|
|
129
|
-
|
|
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
|
|