@dataloop-ai/components 0.19.243 → 0.19.244

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.19.243",
3
+ "version": "0.19.244",
4
4
  "exports": {
5
5
  ".": "./index.ts",
6
6
  "./models": "./models.ts",
@@ -1,13 +1,7 @@
1
1
  <template>
2
- <div
3
- :id="uuid"
4
- class="dl-date-picker"
5
- >
6
- <div
7
- v-if="type === 'day'"
8
- class="dl-date-picker--day_picker"
9
- >
10
- <div class="dl-date-picker--calendar_from">
2
+ <div :id="uuid" class="dl-date-picker">
3
+ <div v-if="type === 'day'" class="dl-date-picker--day_picker">
4
+ <div v-if="!singleCalendar" class="dl-date-picker--calendar_from">
11
5
  <dl-calendar
12
6
  v-if="calendarFrom"
13
7
  :model-value="dateInterval"
@@ -30,7 +24,9 @@
30
24
  :dates="calendarTo.dates"
31
25
  :available-range="availableRange"
32
26
  :disabled="disabled"
27
+ :with-left-chevron="singleCalendar"
33
28
  :with-right-chevron="true"
29
+ @prev="handleDatePrev"
34
30
  @next="handleDateNext"
35
31
  @update:model-value="updateDateInterval"
36
32
  @mousedown="handleMousedown"
@@ -38,10 +34,7 @@
38
34
  />
39
35
  </div>
40
36
  </div>
41
- <div
42
- v-else
43
- class="dl-date-picker--month_picker"
44
- >
37
+ <div v-else class="dl-date-picker--month_picker">
45
38
  <div class="dl-date-picker--calendar_from">
46
39
  <dl-month-calendar
47
40
  :model-value="dateInterval"
@@ -104,6 +97,10 @@ export default defineComponent({
104
97
  type: Object as PropType<Partial<DateInterval> | null>,
105
98
  default: null
106
99
  },
100
+ singleCalendar: {
101
+ type: Boolean,
102
+ default: false
103
+ },
107
104
  singleSelection: {
108
105
  type: Boolean,
109
106
  default: false
@@ -0,0 +1,221 @@
1
+ <template>
2
+ <div :id="uuid" class="dl-date-time-range">
3
+ <date-input
4
+ :text="dateInputText"
5
+ :input-style="dateInputStyle"
6
+ :disabled="disabled"
7
+ :width="width"
8
+ >
9
+ <dl-menu
10
+ ref="dateTimeRangeMenu"
11
+ anchor="bottom middle"
12
+ self="top middle"
13
+ :offset="[0, 5]"
14
+ :disabled="disabled"
15
+ >
16
+ <div class="dl-date-time-range--card">
17
+ <div
18
+ class="dl-date-time-range--card_content"
19
+ :style="cardContentStyles"
20
+ >
21
+ <dl-date-picker
22
+ :model-value="dateInterval"
23
+ :available-range="availableRange"
24
+ :disabled="isInputDisabled"
25
+ single-calendar
26
+ single-selection
27
+ @update:model-value="
28
+ updateDateIntervalWithAutoClose
29
+ "
30
+ />
31
+ <dl-time-picker
32
+ v-if="showTime"
33
+ :disabled="isInputDisabled"
34
+ :model-value="dateInterval"
35
+ single-time
36
+ @update:model-value="updateDateInterval"
37
+ />
38
+
39
+ <dl-button
40
+ size="s"
41
+ outlined
42
+ class="dl-date-time-range--button"
43
+ @click="handleClearAction"
44
+ >
45
+ <span style="text-transform: capitalize">
46
+ Clear
47
+ </span>
48
+ </dl-button>
49
+ </div>
50
+ </div>
51
+ </dl-menu>
52
+ </date-input>
53
+ </div>
54
+ </template>
55
+ <script lang="ts">
56
+ import { DlTimePicker } from '../DlTimePicker'
57
+ import { DateInterval } from '../types'
58
+ import { CustomDate } from '../DlDatePicker/models/CustomDate'
59
+ import DlDatePicker from '../DlDatePicker/DlDatePicker.vue'
60
+ import DateInput from './DateInput.vue'
61
+ import { DlMenu } from '../../../essential'
62
+ import { DlButton } from '../../../basic'
63
+ import { defineComponent, PropType } from 'vue-demi'
64
+ import { v4 } from 'uuid'
65
+
66
+ export default defineComponent({
67
+ components: {
68
+ DlDatePicker,
69
+ DlTimePicker,
70
+ DateInput,
71
+ DlMenu,
72
+ DlButton
73
+ },
74
+ model: {
75
+ prop: 'modelValue',
76
+ event: 'update:model-value'
77
+ },
78
+ props: {
79
+ modelValue: {
80
+ type: Object as PropType<Date | null>,
81
+ default: null
82
+ },
83
+ showTime: Boolean,
84
+ datePickerCardWidth: {
85
+ type: String,
86
+ default: '300px'
87
+ },
88
+ availableRange: {
89
+ type: Object as PropType<Partial<DateInterval> | null>,
90
+ default: null
91
+ },
92
+ disabled: Boolean,
93
+ autoClose: Boolean,
94
+ placeholder: {
95
+ type: String,
96
+ default: 'Set Due Date'
97
+ },
98
+ width: {
99
+ type: String,
100
+ default: 'fit-content'
101
+ }
102
+ },
103
+ emits: ['update:model-value', 'set-type', 'change'],
104
+ data(): {
105
+ uuid: string
106
+ dateInterval: DateInterval | null
107
+ isOpen: boolean
108
+ isInputDisabled: boolean
109
+ } {
110
+ return {
111
+ uuid: `dl-date-time-range-${v4()}`,
112
+ dateInterval: this.modelValue
113
+ ? {
114
+ from: this.modelValue,
115
+ to: new Date(this.modelValue)
116
+ }
117
+ : null,
118
+ isOpen: false,
119
+ isInputDisabled: false
120
+ }
121
+ },
122
+ computed: {
123
+ dateInputStyle(): Record<string, any> {
124
+ return { width: `${this.dateInputText.length / 2}em` }
125
+ },
126
+ dateInputText(): string {
127
+ if (this.dateInterval === null) {
128
+ return this.placeholder
129
+ }
130
+
131
+ let text = ''
132
+
133
+ if (this.showTime) {
134
+ text = CustomDate.format(
135
+ this.dateInterval.from,
136
+ 'MMM D, YYYY, HH:mm'
137
+ )
138
+ } else {
139
+ text = CustomDate.format(this.dateInterval.from, 'MMM D, YYYY')
140
+ }
141
+
142
+ return text
143
+ },
144
+ cardContentStyles(): Record<string, any> {
145
+ return {
146
+ '--card-content-width': this.datePickerCardWidth
147
+ }
148
+ }
149
+ },
150
+ watch: {
151
+ availableRange: {
152
+ handler() {
153
+ this.updateDateInterval(null)
154
+ },
155
+ deep: true
156
+ },
157
+ modelValue(value: Date | null) {
158
+ this.dateInterval = value && {
159
+ from: value,
160
+ to: new Date(value)
161
+ }
162
+ }
163
+ },
164
+ methods: {
165
+ handleClearAction() {
166
+ this.isInputDisabled = false
167
+ this.updateDateInterval(null)
168
+ },
169
+ updateDateInterval(value: DateInterval | null) {
170
+ if (value === null) {
171
+ this.dateInterval = null
172
+ } else {
173
+ this.dateInterval = {
174
+ from: value.from,
175
+ to: new Date(value.from)
176
+ }
177
+ }
178
+ this.$emit('update:model-value', value?.from)
179
+ this.$emit('change', value?.from)
180
+ },
181
+ updateDateIntervalWithAutoClose(value: DateInterval) {
182
+ this.updateDateInterval(value)
183
+
184
+ if (this.autoClose) {
185
+ const dateTimeRangeMenu = this.$refs[
186
+ 'dateTimeRangeMenu'
187
+ ] as unknown as {
188
+ hide: () => void
189
+ }
190
+ dateTimeRangeMenu.hide()
191
+ }
192
+ }
193
+ }
194
+ })
195
+ </script>
196
+ <style lang="scss" scoped>
197
+ .dl-date-time-range {
198
+ display: flex;
199
+ justify-content: center;
200
+
201
+ &--card {
202
+ background-color: var(--dl-color-bg);
203
+ z-index: 1;
204
+ display: flex;
205
+ border-radius: 2px;
206
+ border-radius: 2px;
207
+ }
208
+
209
+ &--card_content {
210
+ width: var(--card-content-width);
211
+ }
212
+
213
+ &--button {
214
+ display: flex;
215
+ margin-left: auto;
216
+ width: fit-content;
217
+ margin-right: 16px;
218
+ margin-bottom: 16px;
219
+ }
220
+ }
221
+ </style>
@@ -1,3 +1,4 @@
1
1
  import DlDateTimeRange from './DlDateTimeRange.vue'
2
+ import DlDateTimePicker from './DlDateTimePicker.vue'
2
3
 
3
- export { DlDateTimeRange }
4
+ export { DlDateTimeRange, DlDateTimePicker }
@@ -1,33 +1,30 @@
1
1
  <template>
2
- <div
3
- :id="uuid"
4
- class="dl-time-picker"
5
- >
2
+ <div :id="uuid" class="dl-time-picker">
6
3
  <div
7
4
  class="dl-time-picker--input"
8
5
  :class="{ 'dl-time-picker--input-disabled': disableInput }"
9
6
  >
10
- <span>From: {{ formatedFrom }}</span>
7
+ <span>{{ singleTime ? 'On' : 'From' }}: {{ formatedFrom }}</span>
11
8
  <dl-time-picker-input
12
9
  :disabled="disableInput"
13
10
  :model-value="formatedFromValue"
14
11
  @update:model-value="handleFromTimeChange"
15
12
  />
16
13
  </div>
17
- <div class="dl-time-picker--dash">
18
- -
19
- </div>
20
- <div
21
- class="dl-time-picker--input"
22
- :class="{ 'dl-time-picker--input-disabled': disableInput }"
23
- >
24
- <span>To: {{ formatedTo }}</span>
25
- <dl-time-picker-input
26
- :disabled="disableInput"
27
- :model-value="formatedToValue"
28
- @update:model-value="handleToTimeChange"
29
- />
30
- </div>
14
+ <template v-if="!singleTime">
15
+ <div class="dl-time-picker--dash">-</div>
16
+ <div
17
+ class="dl-time-picker--input"
18
+ :class="{ 'dl-time-picker--input-disabled': disableInput }"
19
+ >
20
+ <span>To: {{ formatedTo }}</span>
21
+ <dl-time-picker-input
22
+ :disabled="disableInput"
23
+ :model-value="formatedToValue"
24
+ @update:model-value="handleToTimeChange"
25
+ />
26
+ </div>
27
+ </template>
31
28
  </div>
32
29
  </template>
33
30
  <script lang="ts">
@@ -51,6 +48,10 @@ export default defineComponent({
51
48
  type: Object as PropType<DateInterval | null>,
52
49
  default: null
53
50
  },
51
+ singleTime: {
52
+ type: Boolean,
53
+ default: false
54
+ },
54
55
  disabled: Boolean
55
56
  },
56
57
  emits: ['update:model-value'],
@@ -107,7 +108,10 @@ export default defineComponent({
107
108
  const newFrom = new CustomDate(this.modelValue.from)
108
109
  newFrom.hours(parseInt(value.hour)).minutes(parseInt(value.minute))
109
110
 
110
- if (newFrom.isBefore(new CustomDate(this.modelValue.to))) {
111
+ if (
112
+ this.singleTime ||
113
+ newFrom.isBefore(new CustomDate(this.modelValue.to))
114
+ ) {
111
115
  this.$emit('update:model-value', {
112
116
  from: newFrom.toDate(),
113
117
  to: this.modelValue.to
@@ -0,0 +1,38 @@
1
+ <template>
2
+ <div>
3
+ <div>
4
+ <dl-date-time-picker
5
+ v-model="date"
6
+ show-time
7
+ @change="handleModelValueUpdate"
8
+ />
9
+ </div>
10
+ <div>
11
+ {{ date }}
12
+ </div>
13
+ </div>
14
+ </template>
15
+ <script lang="ts">
16
+ import { defineComponent } from 'vue-demi'
17
+ import { DlDateTimePicker } from '../components'
18
+
19
+ export default defineComponent({
20
+ components: {
21
+ DlDateTimePicker
22
+ },
23
+ data(): {
24
+ date: Date
25
+ } {
26
+ return {
27
+ date: null
28
+ }
29
+ },
30
+ computed: {},
31
+ methods: {
32
+ handleModelValueUpdate(value: Date) {
33
+ console.log('Date: ', value)
34
+ }
35
+ }
36
+ })
37
+ </script>
38
+ <style lang="scss" scoped />
@@ -22,6 +22,7 @@ import DlThDemo from './DlThDemo.vue'
22
22
  import DlTdDemo from './DlTdDemo.vue'
23
23
  import DlTableDemo from './DlTableDemo.vue'
24
24
  import DlPaginationDemo from './DlPaginationDemo.vue'
25
+ import DlDateTimePickerDemo from './DlDateTimePickerDemo.vue'
25
26
  import DlDateTimeRangeDemo from './DlDateTimeRangeDemo.vue'
26
27
  import DlSmartSearchDemo from './SmartSearchDemo/DlSmartSearchDemo.vue'
27
28
  import DlSkeletonDemo from './DlSkeletonDemo.vue'
@@ -93,6 +94,7 @@ export default {
93
94
  DlTableDemo,
94
95
  DlTreeTableDemo,
95
96
  DlPaginationDemo,
97
+ DlDateTimePickerDemo,
96
98
  DlDateTimeRangeDemo,
97
99
  DlSmartSearchDemo,
98
100
  DlSkeletonDemo,