@dataloop-ai/components 0.18.114 → 0.18.116
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/DlDateTime/DlDatePicker/DlDatePicker.vue +1 -0
- package/src/components/compound/DlDateTime/DlDatePicker/components/DlMonthCalendar.vue +13 -6
- package/src/components/compound/DlSearches/DlSmartSearch/DlSmartSearch.vue +18 -6
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +58 -17
- package/src/components/compound/DlSearches/DlSmartSearch/components/SuggestionsDropdown.vue +1 -0
- package/src/components/essential/DlMenu/DlMenu.vue +8 -2
- package/src/demos/SmartSearchDemo/DlSmartSearchDemo.vue +13 -1
- package/src/hooks/use-anchor.ts +9 -6
- package/src/utils/key-composition.ts +10 -2
package/package.json
CHANGED
|
@@ -100,19 +100,26 @@ export default defineComponent({
|
|
|
100
100
|
methods: {
|
|
101
101
|
handleClick(value: number) {
|
|
102
102
|
const d = new CalendarDate()
|
|
103
|
-
d.year(parseInt(this.title)).month(value)
|
|
103
|
+
d.year(parseInt(this.title)).month(value)
|
|
104
104
|
|
|
105
|
-
|
|
105
|
+
const from = new CalendarDate(d)
|
|
106
|
+
const to = new CalendarDate(d)
|
|
107
|
+
|
|
108
|
+
from.startOf('month')
|
|
109
|
+
from.startOf('day')
|
|
110
|
+
to.endOf('month')
|
|
111
|
+
to.endOf('day')
|
|
112
|
+
|
|
113
|
+
if (!isInRange(this.availableRange, new CalendarDate(from))) return
|
|
114
|
+
if (!isInRange(this.availableRange, new CalendarDate(to))) return
|
|
106
115
|
|
|
107
|
-
const date = d.toDate()
|
|
108
116
|
const newDate = {
|
|
109
|
-
from:
|
|
110
|
-
to:
|
|
117
|
+
from: from.toDate(),
|
|
118
|
+
to: to.toDate()
|
|
111
119
|
}
|
|
112
120
|
this.$emit('update:model-value', newDate)
|
|
113
121
|
this.$emit('change', newDate)
|
|
114
122
|
},
|
|
115
|
-
|
|
116
123
|
handleMouseenter(value: number) {
|
|
117
124
|
if (this.modelValue === null) return
|
|
118
125
|
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
:placeholder="placeholder"
|
|
21
21
|
@focus="isFocused = true"
|
|
22
22
|
@blur="isFocused = false"
|
|
23
|
+
@search="emitSearchQuery"
|
|
24
|
+
@error="$emit('error', $event)"
|
|
23
25
|
/>
|
|
24
26
|
</div>
|
|
25
27
|
<div class="dl-smart-search__buttons">
|
|
@@ -35,7 +37,7 @@
|
|
|
35
37
|
height: '28px'
|
|
36
38
|
}"
|
|
37
39
|
:disabled="disabled"
|
|
38
|
-
@click="$emit('search
|
|
40
|
+
@click="$emit('search', queryObject)"
|
|
39
41
|
/>
|
|
40
42
|
</div>
|
|
41
43
|
<div
|
|
@@ -63,10 +65,9 @@
|
|
|
63
65
|
<dl-smart-search-json-editor-dialog
|
|
64
66
|
v-model="showJSONEditor"
|
|
65
67
|
:json="stringifiedJSON"
|
|
66
|
-
@search="
|
|
68
|
+
@search="handleJSONSearch"
|
|
67
69
|
@change="handleJSONChange"
|
|
68
70
|
/>
|
|
69
|
-
<!-- todo: Add support for saved queries-->
|
|
70
71
|
</div>
|
|
71
72
|
</template>
|
|
72
73
|
<script lang="ts">
|
|
@@ -137,7 +138,13 @@ export default defineComponent({
|
|
|
137
138
|
default: ''
|
|
138
139
|
}
|
|
139
140
|
},
|
|
140
|
-
emits: [
|
|
141
|
+
emits: [
|
|
142
|
+
'save-filter',
|
|
143
|
+
'remove-filter',
|
|
144
|
+
'update:model-value',
|
|
145
|
+
'search',
|
|
146
|
+
'error'
|
|
147
|
+
],
|
|
141
148
|
setup(props, { emit }) {
|
|
142
149
|
//#region props
|
|
143
150
|
const { modelValue, filters, width } = toRefs(props)
|
|
@@ -226,11 +233,15 @@ export default defineComponent({
|
|
|
226
233
|
}
|
|
227
234
|
}
|
|
228
235
|
|
|
229
|
-
const emitSearchQuery = (
|
|
236
|
+
const emitSearchQuery = (value?: { [key: string]: any }) => {
|
|
237
|
+
emit('search', value ?? queryObject.value)
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
const handleJSONSearch = (query: string) => {
|
|
230
241
|
const json = toObject(query)
|
|
231
242
|
if (!json) return
|
|
232
243
|
queryObject.value = json
|
|
233
|
-
|
|
244
|
+
emitSearchQuery(json)
|
|
234
245
|
}
|
|
235
246
|
|
|
236
247
|
const handleJSONChange = (val: string) => {
|
|
@@ -264,6 +275,7 @@ export default defineComponent({
|
|
|
264
275
|
emitSearchQuery,
|
|
265
276
|
showJSONEditor,
|
|
266
277
|
stringifiedJSON,
|
|
278
|
+
handleJSONSearch,
|
|
267
279
|
handleJSONChange
|
|
268
280
|
}
|
|
269
281
|
}
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
:style="cssVars"
|
|
5
5
|
class="dl-smart-search-input"
|
|
6
6
|
>
|
|
7
|
-
<div
|
|
7
|
+
<div
|
|
8
|
+
class="dl-smart-search-input__search-bar-wrapper"
|
|
9
|
+
@click="focus()"
|
|
10
|
+
>
|
|
8
11
|
<div
|
|
9
12
|
ref="searchBar"
|
|
10
13
|
:class="searchBarClasses"
|
|
@@ -191,7 +194,7 @@ export default defineComponent({
|
|
|
191
194
|
default: false
|
|
192
195
|
}
|
|
193
196
|
},
|
|
194
|
-
emits: ['update:model-value', 'focus', 'blur', 'input'],
|
|
197
|
+
emits: ['update:model-value', 'focus', 'blur', 'input', 'search', 'error'],
|
|
195
198
|
setup(props, { emit }) {
|
|
196
199
|
//#region refs
|
|
197
200
|
const input = ref<HTMLInputElement>(null)
|
|
@@ -355,11 +358,20 @@ export default defineComponent({
|
|
|
355
358
|
const debouncedSetInputValue = debounce(setInputValue, 300)
|
|
356
359
|
|
|
357
360
|
const updateJSONQuery = () => {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
361
|
+
try {
|
|
362
|
+
const bracketless = removeBrackets(searchQuery.value)
|
|
363
|
+
const cleanedAliases = revertAliases(bracketless, aliases.value)
|
|
364
|
+
const json = toJSON(cleanedAliases)
|
|
365
|
+
if (!isEqual(json, modelValue.value)) {
|
|
366
|
+
emit('update:model-value', json)
|
|
367
|
+
}
|
|
368
|
+
return json
|
|
369
|
+
} catch (e) {
|
|
370
|
+
emit('error', {
|
|
371
|
+
error: e,
|
|
372
|
+
message: 'Could not translate given JSON to a valid Scheme'
|
|
373
|
+
})
|
|
374
|
+
return modelValue.value
|
|
363
375
|
}
|
|
364
376
|
}
|
|
365
377
|
|
|
@@ -385,6 +397,10 @@ export default defineComponent({
|
|
|
385
397
|
return
|
|
386
398
|
}
|
|
387
399
|
|
|
400
|
+
if (focused.value) {
|
|
401
|
+
return
|
|
402
|
+
}
|
|
403
|
+
|
|
388
404
|
input.value.scrollTo(0, input.value.scrollHeight)
|
|
389
405
|
input.value.scrollLeft = input.value.scrollWidth
|
|
390
406
|
|
|
@@ -394,7 +410,12 @@ export default defineComponent({
|
|
|
394
410
|
emit('focus')
|
|
395
411
|
}
|
|
396
412
|
|
|
397
|
-
const blur = (
|
|
413
|
+
const blur = (
|
|
414
|
+
e: Event | null = null,
|
|
415
|
+
options: { force?: boolean } = {}
|
|
416
|
+
) => {
|
|
417
|
+
const { force } = options
|
|
418
|
+
|
|
398
419
|
if (showDatePicker.value) {
|
|
399
420
|
return
|
|
400
421
|
}
|
|
@@ -405,6 +426,10 @@ export default defineComponent({
|
|
|
405
426
|
return
|
|
406
427
|
}
|
|
407
428
|
|
|
429
|
+
if (!focused.value && !force) {
|
|
430
|
+
return
|
|
431
|
+
}
|
|
432
|
+
|
|
408
433
|
input.value.scrollLeft = 0
|
|
409
434
|
input.value.scrollTop = 0
|
|
410
435
|
focused.value = false
|
|
@@ -430,6 +455,10 @@ export default defineComponent({
|
|
|
430
455
|
const onKeyPress = (e: KeyboardEvent) => {
|
|
431
456
|
if (e.key === 'Enter') {
|
|
432
457
|
e.preventDefault()
|
|
458
|
+
e.stopPropagation()
|
|
459
|
+
emit('search', updateJSONQuery())
|
|
460
|
+
showSuggestions.value = false
|
|
461
|
+
return
|
|
433
462
|
}
|
|
434
463
|
|
|
435
464
|
if (!focused.value) {
|
|
@@ -438,6 +467,10 @@ export default defineComponent({
|
|
|
438
467
|
}
|
|
439
468
|
|
|
440
469
|
const onInput = (e: Event) => {
|
|
470
|
+
if ((e as KeyboardEvent).key === 'Enter') {
|
|
471
|
+
return
|
|
472
|
+
}
|
|
473
|
+
|
|
441
474
|
const text = (e.target as HTMLElement).textContent
|
|
442
475
|
debouncedSetInputValue(text)
|
|
443
476
|
}
|
|
@@ -480,14 +513,22 @@ export default defineComponent({
|
|
|
480
513
|
}
|
|
481
514
|
|
|
482
515
|
const fromJSON = (value: { [key: string]: any }) => {
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
516
|
+
try {
|
|
517
|
+
const replacedDate = replaceJSDatesWithStringifiedDates(
|
|
518
|
+
value,
|
|
519
|
+
dateKeys.value
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
const stringQuery = stringifySmartQuery(replacedDate)
|
|
523
|
+
const aliased = setAliases(stringQuery, aliases.value)
|
|
524
|
+
return aliased
|
|
525
|
+
} catch (e) {
|
|
526
|
+
emit('error', {
|
|
527
|
+
error: e,
|
|
528
|
+
message: 'Could not translate given JSON to a valid Scheme'
|
|
529
|
+
})
|
|
530
|
+
return ''
|
|
531
|
+
}
|
|
491
532
|
}
|
|
492
533
|
//#endregion
|
|
493
534
|
|
|
@@ -682,7 +723,7 @@ export default defineComponent({
|
|
|
682
723
|
isEllipsisActive(input.value) || hasEllipsis.value
|
|
683
724
|
}
|
|
684
725
|
window.addEventListener('mousemove', () => (isTyping.value = false))
|
|
685
|
-
blur()
|
|
726
|
+
blur(null, { force: true })
|
|
686
727
|
})
|
|
687
728
|
onBeforeUnmount(() => {
|
|
688
729
|
window.removeEventListener(
|
|
@@ -33,7 +33,8 @@ import {
|
|
|
33
33
|
computed,
|
|
34
34
|
PropType,
|
|
35
35
|
Ref,
|
|
36
|
-
isVue2
|
|
36
|
+
isVue2,
|
|
37
|
+
toRefs
|
|
37
38
|
} from 'vue-demi'
|
|
38
39
|
|
|
39
40
|
import useWindowSize from '../../../hooks/use-window-size'
|
|
@@ -159,6 +160,10 @@ export default defineComponent({
|
|
|
159
160
|
triggerPercentage: {
|
|
160
161
|
type: Number,
|
|
161
162
|
default: 1
|
|
163
|
+
},
|
|
164
|
+
toggleKey: {
|
|
165
|
+
type: String,
|
|
166
|
+
default: 'Enter'
|
|
162
167
|
}
|
|
163
168
|
},
|
|
164
169
|
|
|
@@ -183,6 +188,7 @@ export default defineComponent({
|
|
|
183
188
|
|
|
184
189
|
const innerRef: Ref<HTMLElement | null> = ref(null)
|
|
185
190
|
const showing = ref(false)
|
|
191
|
+
const { toggleKey } = toRefs(props)
|
|
186
192
|
|
|
187
193
|
const { registerTick, removeTick } = useTick()
|
|
188
194
|
const { registerTimeout, removeTimeout } = useTimeout()
|
|
@@ -193,7 +199,7 @@ export default defineComponent({
|
|
|
193
199
|
unconfigureScrollTarget
|
|
194
200
|
} = useScrollTarget(props, configureScrollTarget)
|
|
195
201
|
|
|
196
|
-
const { anchorEl, canShow } = useAnchor({})
|
|
202
|
+
const { anchorEl, canShow } = useAnchor({ toggleKey: toggleKey.value })
|
|
197
203
|
|
|
198
204
|
const screen = useWindowSize()
|
|
199
205
|
|
|
@@ -58,8 +58,14 @@
|
|
|
58
58
|
:color-schema="colorSchema"
|
|
59
59
|
:strict="strictState"
|
|
60
60
|
:disabled="switchState"
|
|
61
|
+
@search="onSearchEmitted"
|
|
61
62
|
/>
|
|
62
63
|
|
|
64
|
+
<div>
|
|
65
|
+
<div>EMITED SEARCH:</div>
|
|
66
|
+
<div>count {{ searchEmitted }} last: {{ lastSearch }}</div>
|
|
67
|
+
</div>
|
|
68
|
+
|
|
63
69
|
<dl-smart-search-input
|
|
64
70
|
v-model="queryObject2"
|
|
65
71
|
:aliases="aliases"
|
|
@@ -224,7 +230,9 @@ export default defineComponent({
|
|
|
224
230
|
queryObject: {},
|
|
225
231
|
queryObject2: {},
|
|
226
232
|
textQuery: '',
|
|
227
|
-
filters
|
|
233
|
+
filters,
|
|
234
|
+
lastSearch: null,
|
|
235
|
+
searchEmitted: 0
|
|
228
236
|
}
|
|
229
237
|
},
|
|
230
238
|
watch: {
|
|
@@ -262,6 +270,10 @@ export default defineComponent({
|
|
|
262
270
|
this.filters[type] = this.filters[type].filter(
|
|
263
271
|
(q: Query) => q.name !== query.name
|
|
264
272
|
)
|
|
273
|
+
},
|
|
274
|
+
onSearchEmitted(query: Query) {
|
|
275
|
+
this.searchEmitted++
|
|
276
|
+
this.lastSearch = query
|
|
265
277
|
}
|
|
266
278
|
}
|
|
267
279
|
})
|
package/src/hooks/use-anchor.ts
CHANGED
|
@@ -47,12 +47,15 @@ export function CheckAnchorElVisibility(
|
|
|
47
47
|
})
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
export default function useAnchor(
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
50
|
+
export default function useAnchor(
|
|
51
|
+
options: {
|
|
52
|
+
configureAnchorEl?: Function
|
|
53
|
+
toggleKey?: string | number
|
|
54
|
+
} = {}
|
|
55
|
+
) {
|
|
55
56
|
const { props, proxy, emit } = getCurrentInstance()!
|
|
57
|
+
const { toggleKey } = options
|
|
58
|
+
let { configureAnchorEl } = options
|
|
56
59
|
|
|
57
60
|
const anchorEl: Ref<HTMLElement | Element | null> = ref(null)
|
|
58
61
|
|
|
@@ -84,7 +87,7 @@ export default function useAnchor({
|
|
|
84
87
|
},
|
|
85
88
|
|
|
86
89
|
toggleKey(evt: AnchorEvent) {
|
|
87
|
-
if (isKeyCode(evt,
|
|
90
|
+
if (isKeyCode(evt, toggleKey) && anchorEvents.toggle) {
|
|
88
91
|
anchorEvents.toggle(evt)
|
|
89
92
|
}
|
|
90
93
|
},
|
|
@@ -8,8 +8,16 @@ export function shouldIgnoreKey(evt: KeyboardEvent) {
|
|
|
8
8
|
)
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
export function isKeyCode(evt: KeyboardEvent,
|
|
12
|
-
|
|
11
|
+
export function isKeyCode(evt: KeyboardEvent, key: number | string) {
|
|
12
|
+
if (!key) {
|
|
13
|
+
return false
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return shouldIgnoreKey(evt)
|
|
17
|
+
? false
|
|
18
|
+
: [key].includes(evt.key) ||
|
|
19
|
+
[key].includes(evt.keyCode) ||
|
|
20
|
+
[key].includes(evt.code)
|
|
13
21
|
}
|
|
14
22
|
|
|
15
23
|
export function onKeyDownComposition(evt: KeyboardEvent) {
|