@dataloop-ai/components 0.19.274 → 0.19.276
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/moveToPublic.sh +1 -1
- package/package.json +1 -1
- package/src/components/compound/DlDateTime/DlDateTimeRange/DlDateTimeCard.vue +166 -0
- package/src/components/compound/DlDateTime/DlDateTimeRange/DlDateTimePicker.vue +22 -101
- package/src/components/compound/DlDateTime/DlDateTimeRange/index.ts +2 -1
- package/src/components/compound/DlInput/DlTextInput.vue +936 -0
- package/src/components/compound/DlInput/index.ts +2 -1
- package/src/components/compound/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +10 -12
- package/src/components/compound/DlSearches/DlSmartSearch/utils/index.ts +7 -6
- package/src/components/compound/DlStepper/components/DlStepperSidebar.vue +6 -1
- package/src/demos/DlTextInputDemo.vue +183 -0
- package/src/demos/index.ts +3 -1
- package/src/hooks/use-suggestions.ts +4 -3
- package/src/utils/parse-smart-query.ts +24 -14
package/moveToPublic.sh
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :id="uuid" class="dl-date-time-range-card" :style="computedStyles">
|
|
3
|
+
<div class="dl-date-time-range-card--content">
|
|
4
|
+
<dl-date-picker
|
|
5
|
+
:model-value="dateInterval"
|
|
6
|
+
:available-range="availableRange"
|
|
7
|
+
:disabled="disabled"
|
|
8
|
+
single-calendar
|
|
9
|
+
single-selection
|
|
10
|
+
@update:model-value="dateSelected"
|
|
11
|
+
/>
|
|
12
|
+
<dl-time-picker
|
|
13
|
+
v-if="showTime"
|
|
14
|
+
:disabled="disabled"
|
|
15
|
+
:model-value="dateInterval"
|
|
16
|
+
single-time
|
|
17
|
+
@update:model-value="updateDateInterval"
|
|
18
|
+
/>
|
|
19
|
+
|
|
20
|
+
<dl-button
|
|
21
|
+
size="s"
|
|
22
|
+
outlined
|
|
23
|
+
class="dl-date-time-range-card--button"
|
|
24
|
+
@click="handleClearAction"
|
|
25
|
+
>
|
|
26
|
+
<span style="text-transform: capitalize"> Clear </span>
|
|
27
|
+
</dl-button>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
</template>
|
|
31
|
+
|
|
32
|
+
<script lang="ts">
|
|
33
|
+
import { v4 } from 'uuid'
|
|
34
|
+
import {
|
|
35
|
+
computed,
|
|
36
|
+
defineComponent,
|
|
37
|
+
PropType,
|
|
38
|
+
ref,
|
|
39
|
+
toRefs,
|
|
40
|
+
watch
|
|
41
|
+
} from 'vue-demi'
|
|
42
|
+
import { DateInterval } from '../types'
|
|
43
|
+
import { DlTimePicker } from '../DlTimePicker'
|
|
44
|
+
import DlDatePicker from '../DlDatePicker/DlDatePicker.vue'
|
|
45
|
+
import { DlButton } from '../../../basic'
|
|
46
|
+
import { isEqual } from 'lodash'
|
|
47
|
+
|
|
48
|
+
export default defineComponent({
|
|
49
|
+
components: {
|
|
50
|
+
DlDatePicker,
|
|
51
|
+
DlTimePicker,
|
|
52
|
+
DlButton
|
|
53
|
+
},
|
|
54
|
+
model: {
|
|
55
|
+
prop: 'modelValue',
|
|
56
|
+
event: 'update:model-value'
|
|
57
|
+
},
|
|
58
|
+
props: {
|
|
59
|
+
modelValue: {
|
|
60
|
+
type: Object as PropType<Date | null>,
|
|
61
|
+
default: null
|
|
62
|
+
},
|
|
63
|
+
showTime: Boolean,
|
|
64
|
+
availableRange: {
|
|
65
|
+
type: Object as PropType<Partial<DateInterval> | null>,
|
|
66
|
+
default: null
|
|
67
|
+
},
|
|
68
|
+
disabled: Boolean,
|
|
69
|
+
width: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: 'auto'
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
emits: ['update:model-value', 'date-selected', 'change', 'clear'],
|
|
75
|
+
setup(props, { emit }) {
|
|
76
|
+
const { modelValue, availableRange, width } = toRefs(props)
|
|
77
|
+
|
|
78
|
+
const uuid = ref(`dl-date-time-card-${v4()}`)
|
|
79
|
+
const dateInterval = computed<DateInterval>({
|
|
80
|
+
get() {
|
|
81
|
+
return modelValue.value
|
|
82
|
+
? {
|
|
83
|
+
from: modelValue.value,
|
|
84
|
+
to: new Date(modelValue.value)
|
|
85
|
+
}
|
|
86
|
+
: null
|
|
87
|
+
},
|
|
88
|
+
set(val: DateInterval | null) {
|
|
89
|
+
emit('update:model-value', val ? val.from : null)
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const handleClearAction = () => {
|
|
94
|
+
emit('clear')
|
|
95
|
+
updateDateInterval(null)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const computedStyles = computed(() => {
|
|
99
|
+
return {
|
|
100
|
+
'--card-content-width': width.value
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
const updateDateInterval = (value: DateInterval | null) => {
|
|
105
|
+
if (value === null) {
|
|
106
|
+
dateInterval.value = null
|
|
107
|
+
} else {
|
|
108
|
+
const newVal = {
|
|
109
|
+
from: value.from,
|
|
110
|
+
to: new Date(value.from)
|
|
111
|
+
} as DateInterval
|
|
112
|
+
|
|
113
|
+
if (isEqual(newVal, dateInterval.value)) {
|
|
114
|
+
return
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
dateInterval.value = newVal
|
|
118
|
+
}
|
|
119
|
+
emit('change', value ? value.from : null)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const dateSelected = (value: DateInterval) => {
|
|
123
|
+
const val = {
|
|
124
|
+
from: value.from,
|
|
125
|
+
to: new Date(value.from)
|
|
126
|
+
}
|
|
127
|
+
emit('date-selected', val.from)
|
|
128
|
+
updateDateInterval(val)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
watch(availableRange, () => {
|
|
132
|
+
updateDateInterval(null)
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
uuid,
|
|
137
|
+
dateInterval,
|
|
138
|
+
handleClearAction,
|
|
139
|
+
updateDateInterval,
|
|
140
|
+
dateSelected,
|
|
141
|
+
computedStyles
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
})
|
|
145
|
+
</script>
|
|
146
|
+
|
|
147
|
+
<style lang="scss" scoped>
|
|
148
|
+
.dl-date-time-range-card {
|
|
149
|
+
background-color: var(--dl-color-bg);
|
|
150
|
+
display: flex;
|
|
151
|
+
border-radius: 2px;
|
|
152
|
+
border-radius: 2px;
|
|
153
|
+
|
|
154
|
+
&--content {
|
|
155
|
+
width: var(--card-content-width);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
&--button {
|
|
159
|
+
display: flex;
|
|
160
|
+
margin-left: auto;
|
|
161
|
+
width: fit-content;
|
|
162
|
+
margin-right: 16px;
|
|
163
|
+
margin-bottom: 16px;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
</style>
|
|
@@ -14,62 +14,36 @@
|
|
|
14
14
|
:disabled="disabled"
|
|
15
15
|
>
|
|
16
16
|
<div class="dl-date-time-range--card">
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
:
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
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>
|
|
17
|
+
<dl-date-time-card
|
|
18
|
+
ref="dateTimeRangeCard"
|
|
19
|
+
:model-value="modelValue"
|
|
20
|
+
:show-time="showTime"
|
|
21
|
+
:available-range="availableRange"
|
|
22
|
+
:width="datePickerCardWidth"
|
|
23
|
+
:disabled="disabled"
|
|
24
|
+
@update:model-value="handleModelValueChange"
|
|
25
|
+
@date-selected="onDateSelected"
|
|
26
|
+
@clear="handleClearAction"
|
|
27
|
+
/>
|
|
50
28
|
</div>
|
|
51
29
|
</dl-menu>
|
|
52
30
|
</date-input>
|
|
53
31
|
</div>
|
|
54
32
|
</template>
|
|
55
33
|
<script lang="ts">
|
|
56
|
-
import { DlTimePicker } from '../DlTimePicker'
|
|
57
34
|
import { DateInterval } from '../types'
|
|
58
35
|
import { CustomDate } from '../DlDatePicker/models/CustomDate'
|
|
59
|
-
import DlDatePicker from '../DlDatePicker/DlDatePicker.vue'
|
|
60
36
|
import DateInput from './DateInput.vue'
|
|
37
|
+
import DlDateTimeCard from './DlDateTimeCard.vue'
|
|
61
38
|
import { DlMenu } from '../../../essential'
|
|
62
|
-
import { DlButton } from '../../../basic'
|
|
63
39
|
import { defineComponent, PropType } from 'vue-demi'
|
|
64
40
|
import { v4 } from 'uuid'
|
|
65
41
|
|
|
66
42
|
export default defineComponent({
|
|
67
43
|
components: {
|
|
68
|
-
DlDatePicker,
|
|
69
|
-
DlTimePicker,
|
|
70
44
|
DateInput,
|
|
71
45
|
DlMenu,
|
|
72
|
-
|
|
46
|
+
DlDateTimeCard
|
|
73
47
|
},
|
|
74
48
|
model: {
|
|
75
49
|
prop: 'modelValue',
|
|
@@ -103,18 +77,11 @@ export default defineComponent({
|
|
|
103
77
|
emits: ['update:model-value', 'set-type', 'change'],
|
|
104
78
|
data(): {
|
|
105
79
|
uuid: string
|
|
106
|
-
dateInterval: DateInterval | null
|
|
107
80
|
isOpen: boolean
|
|
108
81
|
isInputDisabled: boolean
|
|
109
82
|
} {
|
|
110
83
|
return {
|
|
111
84
|
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
85
|
isOpen: false,
|
|
119
86
|
isInputDisabled: false
|
|
120
87
|
}
|
|
@@ -124,63 +91,30 @@ export default defineComponent({
|
|
|
124
91
|
return { width: `${this.dateInputText.length / 2}em` }
|
|
125
92
|
},
|
|
126
93
|
dateInputText(): string {
|
|
127
|
-
if (this.
|
|
94
|
+
if (this.modelValue === null) {
|
|
128
95
|
return this.placeholder
|
|
129
96
|
}
|
|
130
97
|
|
|
131
98
|
let text = ''
|
|
132
99
|
|
|
133
100
|
if (this.showTime) {
|
|
134
|
-
text = CustomDate.format(
|
|
135
|
-
this.dateInterval.from,
|
|
136
|
-
'MMM D, YYYY, HH:mm'
|
|
137
|
-
)
|
|
101
|
+
text = CustomDate.format(this.modelValue, 'MMM D, YYYY, HH:mm')
|
|
138
102
|
} else {
|
|
139
|
-
text = CustomDate.format(this.
|
|
103
|
+
text = CustomDate.format(this.modelValue, 'MMM D, YYYY')
|
|
140
104
|
}
|
|
141
105
|
|
|
142
106
|
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
107
|
}
|
|
163
108
|
},
|
|
164
109
|
methods: {
|
|
165
110
|
handleClearAction() {
|
|
166
111
|
this.isInputDisabled = false
|
|
167
|
-
this.updateDateInterval(null)
|
|
168
112
|
},
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
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)
|
|
113
|
+
handleModelValueChange(value: Date) {
|
|
114
|
+
this.$emit('update:model-value', value)
|
|
115
|
+
this.$emit('change', value)
|
|
180
116
|
},
|
|
181
|
-
|
|
182
|
-
this.updateDateInterval(value)
|
|
183
|
-
|
|
117
|
+
onDateSelected() {
|
|
184
118
|
if (this.autoClose) {
|
|
185
119
|
const dateTimeRangeMenu = this.$refs[
|
|
186
120
|
'dateTimeRangeMenu'
|
|
@@ -199,23 +133,10 @@ export default defineComponent({
|
|
|
199
133
|
justify-content: center;
|
|
200
134
|
|
|
201
135
|
&--card {
|
|
202
|
-
background-color: var(--dl-color-bg);
|
|
203
136
|
z-index: 1;
|
|
204
137
|
display: flex;
|
|
205
|
-
|
|
206
|
-
|
|
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;
|
|
138
|
+
width: 100%;
|
|
139
|
+
height: 100%;
|
|
219
140
|
}
|
|
220
141
|
}
|
|
221
142
|
</style>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import DlDateTimeRange from './DlDateTimeRange.vue'
|
|
2
2
|
import DlDateTimePicker from './DlDateTimePicker.vue'
|
|
3
|
+
import DlDateTimeCard from './DlDateTimeCard.vue'
|
|
3
4
|
|
|
4
|
-
export { DlDateTimeRange, DlDateTimePicker }
|
|
5
|
+
export { DlDateTimeRange, DlDateTimePicker, DlDateTimeCard }
|