@dataloop-ai/components 0.20.237 → 0.20.239

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@dataloop-ai/components",
3
- "version": "0.20.237",
3
+ "version": "0.20.239",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -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 = { from: date, to: date }
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
- from: value.toDate(),
124
- to: value.toDate()
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)
@@ -189,10 +212,10 @@ export default defineComponent({
189
212
  ) {
190
213
  style.cursor = 'not-allowed'
191
214
  if (isToday && this.disabled) {
192
- style.color = 'var(--dl-color-secondary)'
215
+ style.color = 'var(--dell-blue-500)'
193
216
  style.opacity = disabledOpacity
194
217
  } else if (isToday) {
195
- style.color = 'var(--dl-color-secondary)'
218
+ style.color = 'var(--dell-blue-500)'
196
219
  } else {
197
220
  style.color = 'var(--dl-color-disabled)'
198
221
  }
@@ -238,9 +261,13 @@ export default defineComponent({
238
261
  // All other dates (including those outside range) should use dell-gray-800
239
262
  style.color = 'var(--dell-gray-800)'
240
263
  }
264
+ if (isToday) {
265
+ if (!style.backgroundColor?.includes('blue'))
266
+ style.color = 'var(--dell-blue-500)'
267
+ }
241
268
  } else {
242
269
  if (isToday) {
243
- style.color = 'var(--dl-color-secondary)'
270
+ style.color = 'var(--dell-blue-500)'
244
271
 
245
272
  if (this.disabled) {
246
273
  style.opacity = disabledOpacity
@@ -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: [
@@ -13,9 +13,11 @@
13
13
  self="top middle"
14
14
  :offset="[0, 5]"
15
15
  :disabled="disabled"
16
+ menu-class="dl-date-time-range--menu"
16
17
  >
17
18
  <date-time-range-content
18
19
  v-bind="dateTimeRangeContentProps"
20
+ :is-first-click="isFirstClick"
19
21
  @day-type-option-click="handleDayTypeOptionClick"
20
22
  @month-type-option-click="handleMonthTypeOptionClick"
21
23
  @update-date-interval="updateDateInterval"
@@ -31,6 +33,7 @@
31
33
  <template v-else>
32
34
  <date-time-range-content
33
35
  v-bind="dateTimeRangeContentProps"
36
+ :is-first-click="isFirstClick"
34
37
  @day-type-option-click="handleDayTypeOptionClick"
35
38
  @month-type-option-click="handleMonthTypeOptionClick"
36
39
  @update-date-interval="updateDateInterval"
@@ -58,6 +61,7 @@ import DateInput from './DateInput.vue'
58
61
  import DateTimeRangeContent from './DateTimeRangeContent.vue'
59
62
  import { DlMenu } from '../../../essential'
60
63
  import { defineComponent, PropType } from 'vue-demi'
64
+ import { debounce } from 'lodash'
61
65
  import { isInRange } from '../DlDatePicker/utils'
62
66
  import { v4 } from 'uuid'
63
67
 
@@ -131,6 +135,10 @@ export default defineComponent({
131
135
  enabledWholePeriod: {
132
136
  type: Boolean,
133
137
  default: false
138
+ },
139
+ shouldSelectByClick: {
140
+ type: Boolean,
141
+ default: true
134
142
  }
135
143
  },
136
144
  emits: ['update:model-value', 'set-type', 'change'],
@@ -143,6 +151,8 @@ export default defineComponent({
143
151
  currentSidebarOption: DAY_SIDEBAR_OPTION | MONTH_SIDEBAR_OPTION
144
152
  activeDateTo: CalendarDate | null
145
153
  activeDateFrom: CalendarDate | null
154
+ isFirstClick: boolean
155
+ debouncedUpdateFromToDate: (() => void) & { cancel: () => void }
146
156
  } {
147
157
  let type: 'day' | 'month' = this.type
148
158
  if (this.disabledType === this.type) {
@@ -156,7 +166,11 @@ export default defineComponent({
156
166
  isInputDisabled: false,
157
167
  currentSidebarOption: DAY_SIDEBAR_OPTION.custom,
158
168
  activeDateTo: null,
159
- activeDateFrom: null
169
+ activeDateFrom: null,
170
+ isFirstClick: true,
171
+ debouncedUpdateFromToDate: (() => {}) as (() => void) & {
172
+ cancel: () => void
173
+ }
160
174
  }
161
175
  },
162
176
  computed: {
@@ -508,6 +522,16 @@ export default defineComponent({
508
522
  this.dateInterval = value
509
523
  }
510
524
  },
525
+ created() {
526
+ this.debouncedUpdateFromToDate = debounce(() => {
527
+ if (this.shouldSelectByClick) {
528
+ this.isFirstClick = !this.isFirstClick
529
+ }
530
+ }, 100)
531
+ },
532
+ beforeUnmount() {
533
+ this.debouncedUpdateFromToDate?.cancel?.()
534
+ },
511
535
  methods: {
512
536
  handleClearAction() {
513
537
  this.updateFromToDate()
@@ -559,6 +583,7 @@ export default defineComponent({
559
583
  updateFromToDate(value?: { from: CalendarDate; to: CalendarDate }) {
560
584
  this.activeDateFrom = value?.from || null
561
585
  this.activeDateTo = value?.to || null
586
+ this.debouncedUpdateFromToDate()
562
587
  },
563
588
  updateDateIntervalWithAutoClose(
564
589
  value: DateInterval,
@@ -621,3 +646,9 @@ export default defineComponent({
621
646
  justify-content: center;
622
647
  }
623
648
  </style>
649
+ <style lang="scss" global>
650
+ div.dl-menu.dl-date-time-range--menu {
651
+ border: 1px solid var(--dell-gray-200);
652
+ box-shadow: 0 8px 8px 0 var(--dell-shadow, rgba(0, 0, 0, 0.14));
653
+ }
654
+ </style>
@@ -71,7 +71,10 @@ export default defineComponent({
71
71
  cursor: pointer;
72
72
  color: var(--dl-color-darker);
73
73
  }
74
-
74
+ &--item:not(&--item-active):hover {
75
+ background-color: var(--dell-blue-100);
76
+ border-radius: 11px;
77
+ }
75
78
  &--item-active {
76
79
  font-size: 12px;
77
80
  color: var(--dl-color-text-buttons);
@@ -4,10 +4,7 @@
4
4
  class="dl-time-picker-input--clock_img"
5
5
  :class="{ 'dl-time-picker-input--clock_img-disabled': disabled }"
6
6
  >
7
- <dl-icon
8
- icon="icon-dl-time"
9
- size="16px"
10
- />
7
+ <dl-icon icon="icon-dl-time" size="16px" />
11
8
  </div>
12
9
  <div
13
10
  class="dl-time-picker-input--text"
@@ -61,9 +58,7 @@
61
58
  @click="handleMinuteDownChevronClick"
62
59
  />
63
60
  </div>
64
- <div class="dl-time-picker-input--dots">
65
- :
66
- </div>
61
+ <div class="dl-time-picker-input--dots">:</div>
67
62
  </div>
68
63
  </dl-menu>
69
64
  </div>
@@ -310,5 +305,8 @@ export default defineComponent({
310
305
  top: 46%;
311
306
  left: 49%;
312
307
  }
308
+ &:hover {
309
+ border-color: var(--dell-gray-800);
310
+ }
313
311
  }
314
312
  </style>
@@ -109,6 +109,7 @@
109
109
  :should-clear-select-first-option="
110
110
  shouldClearSelectFirstOption
111
111
  "
112
+ should-select-by-click
112
113
  @set-type="handleSetType"
113
114
  @change="handleModelValueUpdate"
114
115
  />