@dataloop-ai/components 0.20.236 → 0.20.238
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 +10 -1
- package/src/components/compound/DlDateTime/DlDatePicker/components/DlCalendar.vue +27 -4
- package/src/components/compound/DlDateTime/DlDateTimeRange/DateTimeRangeContent.vue +5 -0
- package/src/components/compound/DlDateTime/DlDateTimeRange/DlDateTimeRange.vue +25 -1
- package/src/components/compound/DlSelect/DlSelect.vue +6 -2
- package/src/demos/DlDateTimeRangeDemo.vue +1 -0
package/package.json
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
:available-range="availableRange"
|
|
11
11
|
:disabled="disabled"
|
|
12
12
|
:with-left-chevron="true"
|
|
13
|
+
:is-first-click="isFirstClick"
|
|
13
14
|
@prev="handleDatePrev"
|
|
14
15
|
@update:model-value="updateDateInterval"
|
|
15
16
|
@mousedown="handleMousedown"
|
|
@@ -26,6 +27,7 @@
|
|
|
26
27
|
:disabled="disabled"
|
|
27
28
|
:with-left-chevron="singleCalendar"
|
|
28
29
|
:with-right-chevron="true"
|
|
30
|
+
:is-first-click="isFirstClick"
|
|
29
31
|
@prev="handleDatePrev"
|
|
30
32
|
@next="handleDateNext"
|
|
31
33
|
@update:model-value="updateDateInterval"
|
|
@@ -113,6 +115,10 @@ export default defineComponent({
|
|
|
113
115
|
type: Object as PropType<Partial<CalendarDate> | null>,
|
|
114
116
|
default: null
|
|
115
117
|
},
|
|
118
|
+
isFirstClick: {
|
|
119
|
+
type: Boolean,
|
|
120
|
+
default: true
|
|
121
|
+
},
|
|
116
122
|
normalizeCalendars: Boolean,
|
|
117
123
|
disabled: Boolean
|
|
118
124
|
},
|
|
@@ -270,7 +276,10 @@ export default defineComponent({
|
|
|
270
276
|
|
|
271
277
|
window.addEventListener('mouseup', this.handleMouseup)
|
|
272
278
|
|
|
273
|
-
this.dateInterval =
|
|
279
|
+
this.dateInterval =
|
|
280
|
+
!this.dateInterval || this.type !== 'day' || this.isFirstClick
|
|
281
|
+
? { from: date, to: date }
|
|
282
|
+
: this.dateInterval
|
|
274
283
|
|
|
275
284
|
if (!this.singleSelection) {
|
|
276
285
|
this.isSelectionMode = true
|
|
@@ -88,6 +88,10 @@ export default defineComponent({
|
|
|
88
88
|
type: Object as PropType<DateInterval | null>,
|
|
89
89
|
default: null
|
|
90
90
|
},
|
|
91
|
+
isFirstClick: {
|
|
92
|
+
type: Boolean,
|
|
93
|
+
default: true
|
|
94
|
+
},
|
|
91
95
|
withLeftChevron: Boolean,
|
|
92
96
|
withRightChevron: Boolean,
|
|
93
97
|
disabled: Boolean
|
|
@@ -117,12 +121,31 @@ export default defineComponent({
|
|
|
117
121
|
}
|
|
118
122
|
},
|
|
119
123
|
methods: {
|
|
124
|
+
getRange(
|
|
125
|
+
a: Date | Partial<CalendarDate> | Partial<CustomDate>,
|
|
126
|
+
b: Date | Partial<CalendarDate> | Partial<CustomDate>
|
|
127
|
+
): { from: Date; to: Date } {
|
|
128
|
+
const dateA =
|
|
129
|
+
a instanceof Date
|
|
130
|
+
? new CalendarDate(a)
|
|
131
|
+
: new CalendarDate((a as CustomDate).toDate())
|
|
132
|
+
const dateB =
|
|
133
|
+
b instanceof Date
|
|
134
|
+
? new CalendarDate(b)
|
|
135
|
+
: new CalendarDate((b as CustomDate).toDate())
|
|
136
|
+
return dateA.isBefore(dateB, 'day')
|
|
137
|
+
? { from: dateA.toDate(), to: dateB.toDate() }
|
|
138
|
+
: { from: dateB.toDate(), to: dateA.toDate() }
|
|
139
|
+
},
|
|
120
140
|
handleClick(value: Partial<CustomDate>) {
|
|
121
141
|
if (!isInRange(this.availableRange, value as CustomDate)) return
|
|
122
|
-
const newDate =
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
142
|
+
const newDate =
|
|
143
|
+
this.modelValue && !this.isFirstClick
|
|
144
|
+
? this.getRange(this.modelValue?.from, value)
|
|
145
|
+
: {
|
|
146
|
+
from: value.toDate(),
|
|
147
|
+
to: value.toDate()
|
|
148
|
+
}
|
|
126
149
|
|
|
127
150
|
this.$emit('update:model-value', newDate)
|
|
128
151
|
this.$emit('change', newDate)
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
:normalize-calendars="normalizeCalendars"
|
|
27
27
|
:active-date-from="activeDateFrom"
|
|
28
28
|
:active-date-to="activeDateTo"
|
|
29
|
+
:is-first-click="isFirstClick"
|
|
29
30
|
@update:model-value="updateDateIntervalWithAutoClose"
|
|
30
31
|
@update:from-to-date="updateFromToDate"
|
|
31
32
|
/>
|
|
@@ -122,6 +123,10 @@ export default defineComponent({
|
|
|
122
123
|
hideClearButton: {
|
|
123
124
|
type: Boolean,
|
|
124
125
|
default: false
|
|
126
|
+
},
|
|
127
|
+
isFirstClick: {
|
|
128
|
+
type: Boolean,
|
|
129
|
+
default: true
|
|
125
130
|
}
|
|
126
131
|
},
|
|
127
132
|
emits: [
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
>
|
|
17
17
|
<date-time-range-content
|
|
18
18
|
v-bind="dateTimeRangeContentProps"
|
|
19
|
+
:is-first-click="isFirstClick"
|
|
19
20
|
@day-type-option-click="handleDayTypeOptionClick"
|
|
20
21
|
@month-type-option-click="handleMonthTypeOptionClick"
|
|
21
22
|
@update-date-interval="updateDateInterval"
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
<template v-else>
|
|
32
33
|
<date-time-range-content
|
|
33
34
|
v-bind="dateTimeRangeContentProps"
|
|
35
|
+
:is-first-click="isFirstClick"
|
|
34
36
|
@day-type-option-click="handleDayTypeOptionClick"
|
|
35
37
|
@month-type-option-click="handleMonthTypeOptionClick"
|
|
36
38
|
@update-date-interval="updateDateInterval"
|
|
@@ -58,6 +60,7 @@ import DateInput from './DateInput.vue'
|
|
|
58
60
|
import DateTimeRangeContent from './DateTimeRangeContent.vue'
|
|
59
61
|
import { DlMenu } from '../../../essential'
|
|
60
62
|
import { defineComponent, PropType } from 'vue-demi'
|
|
63
|
+
import { debounce } from 'lodash'
|
|
61
64
|
import { isInRange } from '../DlDatePicker/utils'
|
|
62
65
|
import { v4 } from 'uuid'
|
|
63
66
|
|
|
@@ -131,6 +134,10 @@ export default defineComponent({
|
|
|
131
134
|
enabledWholePeriod: {
|
|
132
135
|
type: Boolean,
|
|
133
136
|
default: false
|
|
137
|
+
},
|
|
138
|
+
shouldSelectByClick: {
|
|
139
|
+
type: Boolean,
|
|
140
|
+
default: true
|
|
134
141
|
}
|
|
135
142
|
},
|
|
136
143
|
emits: ['update:model-value', 'set-type', 'change'],
|
|
@@ -143,6 +150,8 @@ export default defineComponent({
|
|
|
143
150
|
currentSidebarOption: DAY_SIDEBAR_OPTION | MONTH_SIDEBAR_OPTION
|
|
144
151
|
activeDateTo: CalendarDate | null
|
|
145
152
|
activeDateFrom: CalendarDate | null
|
|
153
|
+
isFirstClick: boolean
|
|
154
|
+
debouncedUpdateFromToDate: (() => void) & { cancel: () => void }
|
|
146
155
|
} {
|
|
147
156
|
let type: 'day' | 'month' = this.type
|
|
148
157
|
if (this.disabledType === this.type) {
|
|
@@ -156,7 +165,11 @@ export default defineComponent({
|
|
|
156
165
|
isInputDisabled: false,
|
|
157
166
|
currentSidebarOption: DAY_SIDEBAR_OPTION.custom,
|
|
158
167
|
activeDateTo: null,
|
|
159
|
-
activeDateFrom: null
|
|
168
|
+
activeDateFrom: null,
|
|
169
|
+
isFirstClick: true,
|
|
170
|
+
debouncedUpdateFromToDate: (() => {}) as (() => void) & {
|
|
171
|
+
cancel: () => void
|
|
172
|
+
}
|
|
160
173
|
}
|
|
161
174
|
},
|
|
162
175
|
computed: {
|
|
@@ -508,6 +521,16 @@ export default defineComponent({
|
|
|
508
521
|
this.dateInterval = value
|
|
509
522
|
}
|
|
510
523
|
},
|
|
524
|
+
created() {
|
|
525
|
+
this.debouncedUpdateFromToDate = debounce(() => {
|
|
526
|
+
if (this.shouldSelectByClick) {
|
|
527
|
+
this.isFirstClick = !this.isFirstClick
|
|
528
|
+
}
|
|
529
|
+
}, 100)
|
|
530
|
+
},
|
|
531
|
+
beforeUnmount() {
|
|
532
|
+
this.debouncedUpdateFromToDate?.cancel?.()
|
|
533
|
+
},
|
|
511
534
|
methods: {
|
|
512
535
|
handleClearAction() {
|
|
513
536
|
this.updateFromToDate()
|
|
@@ -559,6 +582,7 @@ export default defineComponent({
|
|
|
559
582
|
updateFromToDate(value?: { from: CalendarDate; to: CalendarDate }) {
|
|
560
583
|
this.activeDateFrom = value?.from || null
|
|
561
584
|
this.activeDateTo = value?.to || null
|
|
585
|
+
this.debouncedUpdateFromToDate()
|
|
562
586
|
},
|
|
563
587
|
updateDateIntervalWithAutoClose(
|
|
564
588
|
value: DateInterval,
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
</div>
|
|
146
146
|
</div>
|
|
147
147
|
<dl-menu
|
|
148
|
-
v-if="!noOptions || !hideEmptyMenu"
|
|
148
|
+
v-if="!noOptions || !hideEmptyMenu || showAfterOptionsWhenEmpty"
|
|
149
149
|
ref="menu"
|
|
150
150
|
v-model="isExpanded"
|
|
151
151
|
fit-container
|
|
@@ -327,7 +327,7 @@
|
|
|
327
327
|
</div>
|
|
328
328
|
</dl-list>
|
|
329
329
|
<dl-list-item
|
|
330
|
-
v-if="hasAfterOptions && !noOptions"
|
|
330
|
+
v-if="hasAfterOptions && (!noOptions || showAfterOptionsWhenEmpty)"
|
|
331
331
|
:padding="afterOptionsPadding"
|
|
332
332
|
>
|
|
333
333
|
<dl-item-section>
|
|
@@ -531,6 +531,10 @@ export default defineComponent({
|
|
|
531
531
|
type: Boolean,
|
|
532
532
|
default: false
|
|
533
533
|
},
|
|
534
|
+
showAfterOptionsWhenEmpty: {
|
|
535
|
+
type: Boolean,
|
|
536
|
+
default: false
|
|
537
|
+
},
|
|
534
538
|
removeTabIndex: {
|
|
535
539
|
type: Boolean,
|
|
536
540
|
default: false
|