@dataloop-ai/components 0.20.99 → 0.20.101
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,8 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
:id="uuid"
|
|
4
|
-
class="dl-date-time-range"
|
|
5
|
-
>
|
|
2
|
+
<div :id="uuid" class="dl-date-time-range">
|
|
6
3
|
<date-input
|
|
7
4
|
:text="dateInputText"
|
|
8
5
|
:input-style="dateInputStyle"
|
|
@@ -136,6 +133,14 @@ export default defineComponent({
|
|
|
136
133
|
width: {
|
|
137
134
|
type: String,
|
|
138
135
|
default: 'fit-content'
|
|
136
|
+
},
|
|
137
|
+
disabledType: {
|
|
138
|
+
type: String,
|
|
139
|
+
default: null
|
|
140
|
+
},
|
|
141
|
+
skipAvailableRangeIntervalUpdate: {
|
|
142
|
+
type: Boolean,
|
|
143
|
+
default: false
|
|
139
144
|
}
|
|
140
145
|
},
|
|
141
146
|
emits: ['update:model-value', 'set-type', 'change'],
|
|
@@ -147,10 +152,14 @@ export default defineComponent({
|
|
|
147
152
|
isInputDisabled: boolean
|
|
148
153
|
currentSidebarOption: DAY_SIDEBAR_OPTION | MONTH_SIDEBAR_OPTION
|
|
149
154
|
} {
|
|
155
|
+
let type: 'day' | 'month' = this.type
|
|
156
|
+
if (this.disabledType === this.type) {
|
|
157
|
+
type = this.type === 'day' ? 'month' : 'day'
|
|
158
|
+
}
|
|
150
159
|
return {
|
|
151
160
|
uuid: `dl-date-time-range-${v4()}`,
|
|
152
161
|
dateInterval: this.modelValue,
|
|
153
|
-
typeState:
|
|
162
|
+
typeState: type,
|
|
154
163
|
isOpen: false,
|
|
155
164
|
isInputDisabled: false,
|
|
156
165
|
currentSidebarOption: DAY_SIDEBAR_OPTION.custom
|
|
@@ -221,7 +230,8 @@ export default defineComponent({
|
|
|
221
230
|
to: new CalendarDate(this.dateInterval.from)
|
|
222
231
|
.startOf('month')
|
|
223
232
|
.toDate()
|
|
224
|
-
}
|
|
233
|
+
},
|
|
234
|
+
disabled: this.disabledType === 'month'
|
|
225
235
|
}
|
|
226
236
|
]
|
|
227
237
|
},
|
|
@@ -285,7 +295,8 @@ export default defineComponent({
|
|
|
285
295
|
to: new CalendarDate(this.dateInterval.from)
|
|
286
296
|
.startOf('day')
|
|
287
297
|
.toDate()
|
|
288
|
-
}
|
|
298
|
+
},
|
|
299
|
+
disabled: this.disabledType === 'day'
|
|
289
300
|
},
|
|
290
301
|
{ title: 'custom by month', key: MONTH_SIDEBAR_OPTION.custom }
|
|
291
302
|
]
|
|
@@ -293,13 +304,13 @@ export default defineComponent({
|
|
|
293
304
|
sidebarDayOptions(): DayTypeOption[] {
|
|
294
305
|
return this.dayTypeOptions.map((o) => ({
|
|
295
306
|
...o,
|
|
296
|
-
disabled: !isInRange(this.availableRange, o.value)
|
|
307
|
+
disabled: !isInRange(this.availableRange, o.value) || o.disabled
|
|
297
308
|
}))
|
|
298
309
|
},
|
|
299
310
|
sidebarMonthOptions(): MonthTypeOption[] {
|
|
300
311
|
return this.monthTypeOptions.map((o) => ({
|
|
301
312
|
...o,
|
|
302
|
-
disabled: !isInRange(this.availableRange, o.value)
|
|
313
|
+
disabled: !isInRange(this.availableRange, o.value) || o.disabled
|
|
303
314
|
}))
|
|
304
315
|
},
|
|
305
316
|
dateInputStyle(): Record<string, any> {
|
|
@@ -396,6 +407,7 @@ export default defineComponent({
|
|
|
396
407
|
},
|
|
397
408
|
watch: {
|
|
398
409
|
type(value: 'day' | 'month') {
|
|
410
|
+
if (value === this.disabledType) return
|
|
399
411
|
this.typeState = value
|
|
400
412
|
|
|
401
413
|
if (this.dateInterval === null) return
|
|
@@ -421,8 +433,23 @@ export default defineComponent({
|
|
|
421
433
|
this.typeState === 'day'
|
|
422
434
|
? DAY_SIDEBAR_OPTION.custom
|
|
423
435
|
: MONTH_SIDEBAR_OPTION.custom
|
|
424
|
-
|
|
425
|
-
|
|
436
|
+
if (this.dateInterval) {
|
|
437
|
+
if (
|
|
438
|
+
isInRange(
|
|
439
|
+
this.availableRange,
|
|
440
|
+
new CustomDate(this.dateInterval.from)
|
|
441
|
+
) &&
|
|
442
|
+
isInRange(
|
|
443
|
+
this.availableRange,
|
|
444
|
+
new CustomDate(this.dateInterval.to)
|
|
445
|
+
)
|
|
446
|
+
) {
|
|
447
|
+
return
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
if (!this.skipAvailableRangeIntervalUpdate) {
|
|
451
|
+
this.updateDateInterval(null)
|
|
452
|
+
}
|
|
426
453
|
},
|
|
427
454
|
deep: true
|
|
428
455
|
},
|
|
@@ -246,7 +246,7 @@ export default defineComponent({
|
|
|
246
246
|
default: () => [] as string[]
|
|
247
247
|
},
|
|
248
248
|
operatorsOverride: {
|
|
249
|
-
type: Object as PropType<{[name: string]: string[]}>,
|
|
249
|
+
type: Object as PropType<{ [name: string]: string[] }>,
|
|
250
250
|
default: () => ({})
|
|
251
251
|
},
|
|
252
252
|
forbiddenKeys: {
|
|
@@ -335,28 +335,7 @@ export default defineComponent({
|
|
|
335
335
|
|
|
336
336
|
showSuggestions.value = false
|
|
337
337
|
|
|
338
|
-
|
|
339
|
-
const dotOrCommaRegEx = /\s+([\.|\,]\s?)$/
|
|
340
|
-
const dotOrCommaMatch = value.match(dotOrCommaRegEx)
|
|
341
|
-
if (dotOrCommaMatch) {
|
|
342
|
-
value = value.replace(dotOrCommaRegEx, dotOrCommaMatch[1])
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// to handle date suggestion modal to open automatically.
|
|
346
|
-
if (value.includes(dateSuggestionPattern)) {
|
|
347
|
-
value = value.trimEnd()
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
const specialSuggestions = suggestions.value.filter(
|
|
351
|
-
(suggestion) =>
|
|
352
|
-
typeof suggestion === 'string' && suggestion.startsWith('.')
|
|
353
|
-
)
|
|
354
|
-
|
|
355
|
-
for (const suggestion of specialSuggestions) {
|
|
356
|
-
if (value.includes(suggestion)) {
|
|
357
|
-
value = value.replace(` ${suggestion}`, suggestion)
|
|
358
|
-
}
|
|
359
|
-
}
|
|
338
|
+
value = _normalizeInputValue(value)
|
|
360
339
|
|
|
361
340
|
searchQuery.value = value
|
|
362
341
|
|
|
@@ -408,6 +387,43 @@ export default defineComponent({
|
|
|
408
387
|
}
|
|
409
388
|
}
|
|
410
389
|
|
|
390
|
+
const _normalizeInputValue = (value: string): string => {
|
|
391
|
+
// Normalize logical operators (' and ' -> ' AND ', ' or ' -> ' OR ')
|
|
392
|
+
const logicalOperatorsRegEx = /\s(and|or)\s/g
|
|
393
|
+
const logicalMatch = value.match(logicalOperatorsRegEx)
|
|
394
|
+
if (logicalMatch) {
|
|
395
|
+
value = value.replace(
|
|
396
|
+
logicalOperatorsRegEx,
|
|
397
|
+
(_, match) => ` ${match.toUpperCase()} `
|
|
398
|
+
)
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Handle typing '.' or ',' after accepting a suggestion
|
|
402
|
+
const dotOrCommaRegEx = /\s+([.,]\s?)$/
|
|
403
|
+
const dotOrCommaMatch = value.match(dotOrCommaRegEx)
|
|
404
|
+
if (dotOrCommaMatch) {
|
|
405
|
+
value = value.replace(dotOrCommaRegEx, dotOrCommaMatch[1])
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// Handle date suggestion modal to open automatically.
|
|
409
|
+
if (value.includes(dateSuggestionPattern)) {
|
|
410
|
+
value = value.trimEnd()
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
// Handle special suggestions (suggestions that start with '.')
|
|
414
|
+
const specialSuggestions = suggestions.value.filter(
|
|
415
|
+
(suggestion) =>
|
|
416
|
+
typeof suggestion === 'string' && suggestion.startsWith('.')
|
|
417
|
+
)
|
|
418
|
+
for (const suggestion of specialSuggestions) {
|
|
419
|
+
if (value.includes(suggestion)) {
|
|
420
|
+
value = value.replace(` ${suggestion}`, suggestion)
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
return value
|
|
425
|
+
}
|
|
426
|
+
|
|
411
427
|
const setInputFromSuggestion = (suggestion: any) => {
|
|
412
428
|
const value = '' + suggestion
|
|
413
429
|
let stringValue = ''
|
|
@@ -639,18 +655,7 @@ export default defineComponent({
|
|
|
639
655
|
}
|
|
640
656
|
|
|
641
657
|
const endsWithOperator = computed(() => {
|
|
642
|
-
const operators = [
|
|
643
|
-
'>=',
|
|
644
|
-
'<=',
|
|
645
|
-
'!=',
|
|
646
|
-
'=',
|
|
647
|
-
'>',
|
|
648
|
-
'<',
|
|
649
|
-
'IN',
|
|
650
|
-
'NOT-IN',
|
|
651
|
-
'EXISTS',
|
|
652
|
-
'DOESNT-EXIST'
|
|
653
|
-
]
|
|
658
|
+
const operators = ['>=', '<=', '!=', '=', '>', '<', 'IN', 'NOT-IN']
|
|
654
659
|
|
|
655
660
|
for (const op of operators) {
|
|
656
661
|
if (
|
|
@@ -689,7 +694,9 @@ export default defineComponent({
|
|
|
689
694
|
const onPaste = (e: ClipboardEvent) => {
|
|
690
695
|
const selection = window.getSelection()
|
|
691
696
|
if (selection.rangeCount) {
|
|
692
|
-
let text = (
|
|
697
|
+
let text = (
|
|
698
|
+
e.clipboardData || (window as any).clipboardData
|
|
699
|
+
).getData('text')
|
|
693
700
|
if (text?.length > 0) {
|
|
694
701
|
const range = selection.getRangeAt(0)
|
|
695
702
|
|
|
@@ -701,19 +708,27 @@ export default defineComponent({
|
|
|
701
708
|
|
|
702
709
|
const stringOperators = getStringOperators()
|
|
703
710
|
if (
|
|
704
|
-
new RegExp(
|
|
711
|
+
new RegExp(
|
|
712
|
+
`(,|\\s(${stringOperators.join('|')}))\\s*$`
|
|
713
|
+
).test(preceedingText) &&
|
|
705
714
|
!/^\s*['"]/.test(text) &&
|
|
706
715
|
isNaN(Number(text)) &&
|
|
707
|
-
text !==
|
|
708
|
-
text !==
|
|
716
|
+
text !== 'false' &&
|
|
717
|
+
text !== 'true'
|
|
709
718
|
) {
|
|
710
719
|
text = enquoteString(text)
|
|
711
720
|
}
|
|
712
721
|
|
|
713
722
|
selection.deleteFromDocument()
|
|
714
|
-
selection
|
|
715
|
-
|
|
716
|
-
|
|
723
|
+
selection
|
|
724
|
+
.getRangeAt(0)
|
|
725
|
+
.insertNode(
|
|
726
|
+
document.createTextNode(
|
|
727
|
+
(preceedingText.endsWith(' ') ? '' : ' ') +
|
|
728
|
+
text +
|
|
729
|
+
' '
|
|
730
|
+
)
|
|
731
|
+
)
|
|
717
732
|
selection.collapseToEnd()
|
|
718
733
|
|
|
719
734
|
e.preventDefault()
|
|
@@ -893,7 +908,11 @@ export default defineComponent({
|
|
|
893
908
|
|
|
894
909
|
//#region computed
|
|
895
910
|
const editorStyle = computed((): SyntaxColorSchema => {
|
|
896
|
-
return createColorSchema(
|
|
911
|
+
return createColorSchema(
|
|
912
|
+
colorSchema.value,
|
|
913
|
+
aliases.value,
|
|
914
|
+
schema.value
|
|
915
|
+
)
|
|
897
916
|
})
|
|
898
917
|
|
|
899
918
|
const defaultIcon = 'icon-dl-stars'
|