@dataloop-ai/components 0.17.122 → 0.17.124
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/basic/DlButton/utils.ts +1 -1
- package/src/components/compound/DlSearches/DlSmartSearch/DlSmartSearch.vue +42 -39
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +25 -9
- package/src/components/compound/DlSearches/DlSmartSearch/utils/index.ts +14 -11
- package/src/components/compound/DlSlider/components/DlSliderInput.vue +16 -25
- package/src/components/compound/DlSlider/utils.ts +2 -2
- package/src/components/shared/DlItemSection/DlItemSection.vue +1 -0
- package/src/demos/SmartSearchDemo/DlSmartSearchDemo.vue +3 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getColor } from '../../../utils'
|
|
2
2
|
import { getLighterGradient } from '../../../utils/getLighterGradient'
|
|
3
3
|
|
|
4
|
-
export type ButtonSizes = 's' | 'm' | 'l' | 'xl'
|
|
4
|
+
export type ButtonSizes = 's' | 'm' | 'l' | ('xl' & string)
|
|
5
5
|
|
|
6
6
|
const paddings = {
|
|
7
7
|
s: '7px 16px',
|
|
@@ -29,42 +29,44 @@
|
|
|
29
29
|
</div>
|
|
30
30
|
<div class="dl-smart-search__buttons">
|
|
31
31
|
<slot name="buttons">
|
|
32
|
-
<div
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
32
|
+
<div style="display: flex; align-items: center">
|
|
33
|
+
<div
|
|
34
|
+
style="height: 28px"
|
|
35
|
+
class="dl-smart-search__search-btn-wrapper"
|
|
36
|
+
>
|
|
37
|
+
<dl-button
|
|
38
|
+
icon="icon-dl-search"
|
|
39
|
+
:styles="{
|
|
40
|
+
height: '28px'
|
|
41
|
+
}"
|
|
42
|
+
:disabled="disabled"
|
|
43
|
+
@click="emitSearchQuery"
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
45
46
|
|
|
46
|
-
|
|
47
|
+
<slot name="extra-actions" />
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
>
|
|
54
|
-
Saved Filters
|
|
55
|
-
<dl-menu
|
|
56
|
-
v-model="filtersModel"
|
|
57
|
-
:offset="[0, 5]"
|
|
58
|
-
anchor="bottom middle"
|
|
59
|
-
self="top middle"
|
|
49
|
+
<dl-button
|
|
50
|
+
class="dl-smart-search__buttons--filters"
|
|
51
|
+
shaded
|
|
52
|
+
outlined
|
|
53
|
+
size="s"
|
|
60
54
|
>
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
55
|
+
Saved Filters
|
|
56
|
+
<dl-menu
|
|
57
|
+
v-model="filtersModel"
|
|
58
|
+
:offset="[0, 5]"
|
|
59
|
+
anchor="bottom middle"
|
|
60
|
+
self="top middle"
|
|
61
|
+
>
|
|
62
|
+
<dl-smart-search-filters
|
|
63
|
+
:filters="filters"
|
|
64
|
+
@filters-select="handleFiltersSelect"
|
|
65
|
+
@filters-delete="handleFiltersDelete"
|
|
66
|
+
/>
|
|
67
|
+
</dl-menu>
|
|
68
|
+
</dl-button>
|
|
69
|
+
</div>
|
|
68
70
|
</slot>
|
|
69
71
|
</div>
|
|
70
72
|
<dl-dialog-box
|
|
@@ -235,7 +237,7 @@ import {
|
|
|
235
237
|
SyntaxColorSchema
|
|
236
238
|
} from './types'
|
|
237
239
|
import {
|
|
238
|
-
|
|
240
|
+
revertAliases,
|
|
239
241
|
setAliases,
|
|
240
242
|
replaceStringifiedDatesWithJSDates,
|
|
241
243
|
createColorSchema,
|
|
@@ -354,9 +356,10 @@ export default defineComponent({
|
|
|
354
356
|
)
|
|
355
357
|
|
|
356
358
|
const handleInputModel = (value: string) => {
|
|
357
|
-
|
|
359
|
+
const aliased = setAliases(value, props.aliases)
|
|
360
|
+
inputModel.value = aliased
|
|
358
361
|
const bracketless = removeBrackets(value)
|
|
359
|
-
const cleanedAliases =
|
|
362
|
+
const cleanedAliases = revertAliases(bracketless, props.aliases)
|
|
360
363
|
const json = toJSON(cleanedAliases)
|
|
361
364
|
if (!isEqual(json, props.modelValue)) {
|
|
362
365
|
emit('update:modelValue', json)
|
|
@@ -364,10 +367,10 @@ export default defineComponent({
|
|
|
364
367
|
const stringified = JSON.stringify(json)
|
|
365
368
|
activeQuery.value.query = stringified
|
|
366
369
|
nextTick(() => {
|
|
367
|
-
findSuggestions(
|
|
370
|
+
findSuggestions(aliased)
|
|
368
371
|
})
|
|
369
372
|
isQuerying.value = false
|
|
370
|
-
oldInputQuery.value =
|
|
373
|
+
oldInputQuery.value = aliased
|
|
371
374
|
}
|
|
372
375
|
|
|
373
376
|
const debouncedInputModel = debounce(handleInputModel, 300)
|
|
@@ -548,7 +551,7 @@ export default defineComponent({
|
|
|
548
551
|
const json = JSON.stringify(
|
|
549
552
|
this.toJSON(removeBrackets(this.inputModel))
|
|
550
553
|
)
|
|
551
|
-
const newQuery =
|
|
554
|
+
const newQuery = revertAliases(json, this.aliases)
|
|
552
555
|
if (newQuery && newQuery !== '{}') {
|
|
553
556
|
this.jsonEditorQuery = newQuery
|
|
554
557
|
}
|
|
@@ -268,11 +268,25 @@ export default defineComponent({
|
|
|
268
268
|
.join(' ')
|
|
269
269
|
.replace(' ', ' ')
|
|
270
270
|
} else {
|
|
271
|
-
query.
|
|
271
|
+
if (query[query.length - 1].endsWith('.')) {
|
|
272
|
+
query[query.length - 1] = query[
|
|
273
|
+
query.length - 1
|
|
274
|
+
].replace('.', '')
|
|
275
|
+
} else {
|
|
276
|
+
query.splice(-1)
|
|
277
|
+
}
|
|
272
278
|
stringValue = [...query, value, ''].join(' ')
|
|
273
279
|
}
|
|
274
280
|
} else {
|
|
275
|
-
|
|
281
|
+
if (query[query.length - 1].endsWith('.')) {
|
|
282
|
+
query[query.length - 1] = query[query.length - 1].replace(
|
|
283
|
+
'.',
|
|
284
|
+
''
|
|
285
|
+
)
|
|
286
|
+
stringValue = [...query, value, ''].join(' ')
|
|
287
|
+
} else {
|
|
288
|
+
stringValue = [value, ''].join(' ')
|
|
289
|
+
}
|
|
276
290
|
}
|
|
277
291
|
|
|
278
292
|
// to handle date suggestion modal to open automatically.
|
|
@@ -283,6 +297,7 @@ export default defineComponent({
|
|
|
283
297
|
const specialSuggestions = props.suggestions.filter((suggestion) =>
|
|
284
298
|
suggestion.startsWith('.')
|
|
285
299
|
)
|
|
300
|
+
|
|
286
301
|
for (const suggestion of specialSuggestions) {
|
|
287
302
|
if (stringValue.includes(suggestion)) {
|
|
288
303
|
stringValue = stringValue.replace(
|
|
@@ -453,14 +468,15 @@ export default defineComponent({
|
|
|
453
468
|
},
|
|
454
469
|
suggestions(val) {
|
|
455
470
|
if (this.isDatePickerVisible) return
|
|
471
|
+
nextTick(() => {
|
|
472
|
+
if (!val.length) {
|
|
473
|
+
this.suggestionModal = false
|
|
474
|
+
}
|
|
456
475
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
if (!this.suggestionModal && val.length > 0 && this.focused) {
|
|
462
|
-
this.suggestionModal = true
|
|
463
|
-
}
|
|
476
|
+
if (!this.suggestionModal && val.length > 0 && this.focused) {
|
|
477
|
+
this.suggestionModal = true
|
|
478
|
+
}
|
|
479
|
+
})
|
|
464
480
|
},
|
|
465
481
|
expanded(value) {
|
|
466
482
|
this.$nextTick(() => {
|
|
@@ -109,26 +109,29 @@ export function replaceJSDatesWithStringifiedDates(
|
|
|
109
109
|
return json
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
const
|
|
113
|
-
|
|
114
|
-
|
|
112
|
+
for (const key of Object.keys(json)) {
|
|
113
|
+
if (typeof json[key] === 'object') {
|
|
114
|
+
json[key] = replaceJSDatesWithStringifiedDates(json[key], dateKeys)
|
|
115
|
+
continue
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const value = json[key]
|
|
115
119
|
const keyToCheck = key.split('.').pop()
|
|
116
120
|
|
|
117
121
|
if (dateKeys.includes(keyToCheck)) {
|
|
118
|
-
|
|
122
|
+
json[key] = formatToStringDate(value)
|
|
119
123
|
}
|
|
120
124
|
}
|
|
121
125
|
|
|
122
|
-
return
|
|
123
|
-
[key: string]: any
|
|
124
|
-
}
|
|
126
|
+
return json
|
|
125
127
|
}
|
|
126
128
|
|
|
127
|
-
export function
|
|
129
|
+
export function revertAliases(json: string, aliases: Alias[]) {
|
|
128
130
|
let newJson = json
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
131
|
+
for (const alias of aliases) {
|
|
132
|
+
const regex = new RegExp(`${alias.alias}`, 'gi')
|
|
133
|
+
newJson = newJson.replace(regex, alias.key)
|
|
134
|
+
}
|
|
132
135
|
return newJson
|
|
133
136
|
}
|
|
134
137
|
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<input
|
|
3
3
|
ref="sliderInput"
|
|
4
|
-
:value="
|
|
4
|
+
:value="modelRef"
|
|
5
5
|
type="number"
|
|
6
6
|
:min="min"
|
|
7
7
|
:max="max"
|
|
8
8
|
:readonly="readonly"
|
|
9
9
|
:disabled="disabled"
|
|
10
|
-
@input="
|
|
10
|
+
@input="handleChange"
|
|
11
11
|
@change="handleChange"
|
|
12
12
|
>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
15
|
<script lang="ts">
|
|
16
|
-
import {
|
|
16
|
+
import { debounce } from 'lodash'
|
|
17
|
+
import { defineComponent, toRef } from 'vue-demi'
|
|
17
18
|
import { getInputValue } from '../utils'
|
|
18
19
|
|
|
19
20
|
export default defineComponent({
|
|
@@ -45,34 +46,24 @@ export default defineComponent({
|
|
|
45
46
|
}
|
|
46
47
|
},
|
|
47
48
|
emits: ['update:model-value', 'change'],
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
get(): number | undefined {
|
|
51
|
-
return this.modelValue
|
|
52
|
-
},
|
|
53
|
-
set(evt: any): void {
|
|
54
|
-
const val = evt.target.value
|
|
49
|
+
setup(props, { emit }) {
|
|
50
|
+
const modelRef = toRef(props, 'modelValue')
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const { value } = getInputValue(val, this.min, this.max)
|
|
59
|
-
|
|
60
|
-
;(this.$refs.sliderInput as HTMLInputElement).value = value
|
|
61
|
-
|
|
62
|
-
this.$emit('update:model-value', Number(value))
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
methods: {
|
|
67
|
-
handleChange(evt: any) {
|
|
52
|
+
const handleChange = (evt: any) => {
|
|
68
53
|
const val = evt.target.value
|
|
69
54
|
if (val === '') return
|
|
70
55
|
|
|
71
|
-
const { value } = getInputValue(val,
|
|
56
|
+
const { value } = getInputValue(val, props.min, props.max)
|
|
57
|
+
|
|
58
|
+
emit('change', Number(value))
|
|
59
|
+
emit('update:model-value', Number(value))
|
|
60
|
+
}
|
|
72
61
|
|
|
73
|
-
|
|
62
|
+
const debouncedHandleChange = debounce(handleChange, 300)
|
|
74
63
|
|
|
75
|
-
|
|
64
|
+
return {
|
|
65
|
+
modelRef,
|
|
66
|
+
handleChange: debouncedHandleChange
|
|
76
67
|
}
|
|
77
68
|
},
|
|
78
69
|
template: 'dl-slider-input'
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const getInputValue = (value: string, min: number, max: number) => {
|
|
2
|
-
if (
|
|
3
|
-
return { value: (
|
|
2
|
+
if (parseFloat(value) > max || parseFloat(value) < min) {
|
|
3
|
+
return { value: (parseFloat(value) > max ? max : min).toString() }
|
|
4
4
|
}
|
|
5
5
|
|
|
6
6
|
return { value }
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
style="width: 100px"
|
|
23
23
|
class="props"
|
|
24
24
|
/>
|
|
25
|
+
{ "metadata.system.width": 5 }
|
|
25
26
|
<dl-smart-search
|
|
26
27
|
v-model="queryObject"
|
|
27
28
|
:aliases="aliases"
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
<br>
|
|
45
46
|
Test second if they work on same page..
|
|
46
47
|
<dl-smart-search
|
|
47
|
-
v-model="
|
|
48
|
+
v-model="queryObject2"
|
|
48
49
|
:aliases="[]"
|
|
49
50
|
:schema="schema2"
|
|
50
51
|
:color-schema="colorSchema"
|
|
@@ -180,6 +181,7 @@ export default defineComponent({
|
|
|
180
181
|
strictState: false,
|
|
181
182
|
isLoading: false,
|
|
182
183
|
queryObject: {},
|
|
184
|
+
queryObject2: {},
|
|
183
185
|
textQuery: '',
|
|
184
186
|
filters
|
|
185
187
|
}
|