@dataloop-ai/components 0.19.127 → 0.19.129
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
|
@@ -84,6 +84,18 @@
|
|
|
84
84
|
:single-selection="true"
|
|
85
85
|
@change="onDateSelection"
|
|
86
86
|
/>
|
|
87
|
+
<div class="dl-smart-search-input__date-picker-buttons">
|
|
88
|
+
<dl-button
|
|
89
|
+
label="Cancel"
|
|
90
|
+
outlined
|
|
91
|
+
@mousedown="onDateSelectionCancel"
|
|
92
|
+
/>
|
|
93
|
+
<dl-button
|
|
94
|
+
label="Apply"
|
|
95
|
+
:disabled="!datePickerSelection"
|
|
96
|
+
@mousedown="onDateSelectionApply"
|
|
97
|
+
/>
|
|
98
|
+
</div>
|
|
87
99
|
</div>
|
|
88
100
|
</dl-menu>
|
|
89
101
|
</div>
|
|
@@ -118,6 +130,7 @@ import { DateInterval } from '../../../DlDateTime/types'
|
|
|
118
130
|
import {
|
|
119
131
|
isEndingWithDateIntervalPattern,
|
|
120
132
|
replaceDateInterval,
|
|
133
|
+
removeDateInterval,
|
|
121
134
|
updateEditor,
|
|
122
135
|
isEligibleToChange,
|
|
123
136
|
createColorSchema,
|
|
@@ -255,11 +268,8 @@ export default defineComponent({
|
|
|
255
268
|
//#region hooks
|
|
256
269
|
// todo: these can be stale data. we need to update them on schema change.
|
|
257
270
|
const { hasEllipsis } = useSizeObserver(input)
|
|
258
|
-
const { suggestions, error, findSuggestions } =
|
|
259
|
-
schema,
|
|
260
|
-
aliases,
|
|
261
|
-
{ strict, omitSuggestions }
|
|
262
|
-
)
|
|
271
|
+
const { suggestions, error, findSuggestions, checkErrors } =
|
|
272
|
+
useSuggestions(schema, aliases, { strict, omitSuggestions })
|
|
263
273
|
//#endregion
|
|
264
274
|
|
|
265
275
|
//#region methods
|
|
@@ -328,6 +338,7 @@ export default defineComponent({
|
|
|
328
338
|
|
|
329
339
|
nextTick(() => {
|
|
330
340
|
findSuggestions(value.substring(0, caretAt.value))
|
|
341
|
+
checkErrors(value)
|
|
331
342
|
})
|
|
332
343
|
|
|
333
344
|
if (!noEmit) {
|
|
@@ -492,6 +503,7 @@ export default defineComponent({
|
|
|
492
503
|
}
|
|
493
504
|
nextTick(() => {
|
|
494
505
|
findSuggestions('')
|
|
506
|
+
checkErrors('')
|
|
495
507
|
})
|
|
496
508
|
}
|
|
497
509
|
|
|
@@ -539,8 +551,27 @@ export default defineComponent({
|
|
|
539
551
|
|
|
540
552
|
const onDateSelection = (value: DateInterval) => {
|
|
541
553
|
datePickerSelection.value = value
|
|
542
|
-
|
|
543
|
-
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
const onDateSelectionCancel = () => {
|
|
557
|
+
searchQuery.value = removeDateInterval(searchQuery.value)
|
|
558
|
+
showDatePicker.value = false
|
|
559
|
+
showSuggestions.value = true
|
|
560
|
+
datePickerSelection.value = null
|
|
561
|
+
setInputValue(searchQuery.value + ' ', { noEmit: true })
|
|
562
|
+
setCaretAtTheEnd(input.value)
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
const onDateSelectionApply = () => {
|
|
566
|
+
searchQuery.value = replaceDateInterval(
|
|
567
|
+
searchQuery.value,
|
|
568
|
+
datePickerSelection.value
|
|
569
|
+
)
|
|
570
|
+
showDatePicker.value = false
|
|
571
|
+
showSuggestions.value = true
|
|
572
|
+
datePickerSelection.value = null
|
|
573
|
+
setInputValue(searchQuery.value + ' ', { noEmit: true })
|
|
574
|
+
setCaretAtTheEnd(input.value)
|
|
544
575
|
}
|
|
545
576
|
|
|
546
577
|
const readModelValue = (val: { [key: string]: any }) => {
|
|
@@ -629,15 +660,6 @@ export default defineComponent({
|
|
|
629
660
|
return
|
|
630
661
|
}
|
|
631
662
|
|
|
632
|
-
if (showDatePicker.value) {
|
|
633
|
-
showDatePicker.value = false
|
|
634
|
-
showSuggestions.value = true
|
|
635
|
-
datePickerSelection.value = null
|
|
636
|
-
setInputValue(searchQuery.value + ' ', { noEmit: true })
|
|
637
|
-
setCaretAtTheEnd(input.value)
|
|
638
|
-
return
|
|
639
|
-
}
|
|
640
|
-
|
|
641
663
|
if (showSuggestions.value) {
|
|
642
664
|
showSuggestions.value = false
|
|
643
665
|
return
|
|
@@ -898,6 +920,8 @@ export default defineComponent({
|
|
|
898
920
|
onKeyPress,
|
|
899
921
|
onInput,
|
|
900
922
|
onDateSelection,
|
|
923
|
+
onDateSelectionCancel,
|
|
924
|
+
onDateSelectionApply,
|
|
901
925
|
computedStatus,
|
|
902
926
|
setInputFromSuggestion,
|
|
903
927
|
inputPlaceholder,
|
|
@@ -1130,6 +1154,14 @@ export default defineComponent({
|
|
|
1130
1154
|
&__date-picker-wrapper {
|
|
1131
1155
|
width: 562px;
|
|
1132
1156
|
}
|
|
1157
|
+
|
|
1158
|
+
&__date-picker-buttons {
|
|
1159
|
+
padding: 0 16px 16px;
|
|
1160
|
+
text-align: right;
|
|
1161
|
+
> * {
|
|
1162
|
+
margin-left: 16px;
|
|
1163
|
+
}
|
|
1164
|
+
}
|
|
1133
1165
|
}
|
|
1134
1166
|
.focus {
|
|
1135
1167
|
word-break: break-all;
|
|
@@ -47,6 +47,10 @@ export const replaceDateInterval = (str: string, date: DateInterval) => {
|
|
|
47
47
|
return replaced
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
export const removeDateInterval = (str: string) => {
|
|
51
|
+
return replaceFirstOrLastOccurrence(str, '', datePattern)
|
|
52
|
+
}
|
|
53
|
+
|
|
50
54
|
const formatDate = (date: Date | string | number): string => {
|
|
51
55
|
return moment(date).format('DD/MM/YYYY')
|
|
52
56
|
}
|
|
@@ -151,6 +151,18 @@ export const useSuggestions = (
|
|
|
151
151
|
const suggestions: Ref<Suggestion[]> = ref(sortedSuggestions)
|
|
152
152
|
const error: Ref<string | null> = ref(null)
|
|
153
153
|
|
|
154
|
+
const checkErrors = (input: string) => {
|
|
155
|
+
input = input.replace(/\s+/g, ' ').trimStart()
|
|
156
|
+
|
|
157
|
+
const words = splitByQuotes(input, space)
|
|
158
|
+
const mergedWords = mergeWords(words)
|
|
159
|
+
const expressions = mapWordsToExpressions(mergedWords)
|
|
160
|
+
|
|
161
|
+
error.value = input.length
|
|
162
|
+
? getError(schemaValue, aliasesArray, expressions, { strict })
|
|
163
|
+
: null
|
|
164
|
+
}
|
|
165
|
+
|
|
154
166
|
const findSuggestions = (input: string) => {
|
|
155
167
|
input = input.replace(/\s+/g, ' ').trimStart()
|
|
156
168
|
localSuggestions = sortedSuggestions
|
|
@@ -288,17 +300,13 @@ export const useSuggestions = (
|
|
|
288
300
|
localSuggestions = sortedSuggestions
|
|
289
301
|
}
|
|
290
302
|
|
|
291
|
-
error.value = input.length
|
|
292
|
-
? getError(schemaValue, aliasesArray, expressions, { strict })
|
|
293
|
-
: null
|
|
294
|
-
|
|
295
303
|
suggestions.value = localSuggestions.filter(
|
|
296
304
|
(value) =>
|
|
297
305
|
!omitSuggestions || !omitSuggestions.value.includes(value)
|
|
298
306
|
)
|
|
299
307
|
}
|
|
300
308
|
|
|
301
|
-
return { suggestions, findSuggestions, error }
|
|
309
|
+
return { suggestions, findSuggestions, error, checkErrors }
|
|
302
310
|
}
|
|
303
311
|
|
|
304
312
|
const errors = {
|