@dataloop-ai/components 0.20.99 → 0.20.100

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.99",
3
+ "version": "0.20.100",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -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: this.type,
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
- this.updateDateInterval(null)
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
  },