@dataloop-ai/components 0.19.275 → 0.19.277
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/DlCharts/charts/DlColumnChart/DlColumnChart.vue +8 -16
- 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/DlSearches/DlSmartSearch/components/DlSmartSearchInput.vue +10 -12
- package/src/components/compound/DlSearches/DlSmartSearch/utils/index.ts +7 -6
- package/src/hooks/use-suggestions.ts +4 -3
- package/src/utils/parse-smart-query.ts +24 -14
package/package.json
CHANGED
|
@@ -1,20 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
<dl-empty-state
|
|
7
|
-
v-if="isEmpty"
|
|
8
|
-
v-bind="emptyStateProps"
|
|
9
|
-
>
|
|
10
|
-
<template
|
|
11
|
-
v-for="(_, slot) in $slots"
|
|
12
|
-
#[slot]="props"
|
|
13
|
-
>
|
|
14
|
-
<slot
|
|
15
|
-
:name="slot"
|
|
16
|
-
v-bind="props"
|
|
17
|
-
/>
|
|
2
|
+
<div :style="cssVars" :class="chartWrapperClasses">
|
|
3
|
+
<dl-empty-state v-if="isEmpty" v-bind="emptyStateProps">
|
|
4
|
+
<template v-for="(_, slot) in $slots" #[slot]="props">
|
|
5
|
+
<slot :name="slot" v-bind="props" />
|
|
18
6
|
</template>
|
|
19
7
|
</dl-empty-state>
|
|
20
8
|
<Bar
|
|
@@ -25,6 +13,7 @@
|
|
|
25
13
|
:style="(chartStyles, `max-height: ${wrapperHeight}`)"
|
|
26
14
|
:data="chartData"
|
|
27
15
|
:options="chartOptions"
|
|
16
|
+
:plugins="chartPlugins"
|
|
28
17
|
@mouseout="onChartLeave"
|
|
29
18
|
/>
|
|
30
19
|
<slot
|
|
@@ -484,6 +473,8 @@ export default defineComponent({
|
|
|
484
473
|
)
|
|
485
474
|
)
|
|
486
475
|
|
|
476
|
+
const chartPlugins = props.plugins || []
|
|
477
|
+
|
|
487
478
|
watch(
|
|
488
479
|
() => chart.value?.scales?.x?.width,
|
|
489
480
|
(val: string) => {
|
|
@@ -627,6 +618,7 @@ export default defineComponent({
|
|
|
627
618
|
variables,
|
|
628
619
|
chartData,
|
|
629
620
|
chartOptions,
|
|
621
|
+
chartPlugins,
|
|
630
622
|
brush,
|
|
631
623
|
xLabels,
|
|
632
624
|
columnChart,
|
|
@@ -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 }
|
|
@@ -105,8 +105,9 @@
|
|
|
105
105
|
@escapekey="onEscapeKey"
|
|
106
106
|
>
|
|
107
107
|
<div class="dl-smart-search-input__date-picker-wrapper">
|
|
108
|
-
<dl-date-
|
|
109
|
-
:
|
|
108
|
+
<dl-date-time-card
|
|
109
|
+
:model-value="datePickerSelection"
|
|
110
|
+
show-time
|
|
110
111
|
@change="onDateSelection"
|
|
111
112
|
/>
|
|
112
113
|
<div class="dl-smart-search-input__date-picker-buttons">
|
|
@@ -138,7 +139,7 @@ import {
|
|
|
138
139
|
onBeforeUnmount
|
|
139
140
|
} from 'vue-demi'
|
|
140
141
|
import { DlButton } from '../../../../basic'
|
|
141
|
-
import {
|
|
142
|
+
import { DlDateTimeCard } from '../../../DlDateTime'
|
|
142
143
|
import { DlMenu, DlIcon, DlLabel } from '../../../../essential'
|
|
143
144
|
import { isEllipsisActive } from '../../../../../utils/is-ellipsis-active'
|
|
144
145
|
import { useSizeObserver } from '../../../../../hooks/use-size-observer'
|
|
@@ -173,7 +174,8 @@ import {
|
|
|
173
174
|
Data,
|
|
174
175
|
useSuggestions,
|
|
175
176
|
removeBrackets,
|
|
176
|
-
removeLeadingExpression
|
|
177
|
+
removeLeadingExpression,
|
|
178
|
+
dateSuggestionPattern
|
|
177
179
|
} from '../../../../../hooks/use-suggestions'
|
|
178
180
|
import { parseSmartQuery, stringifySmartQuery } from '../../../../../utils'
|
|
179
181
|
import { StateManager, stateManager } from '../../../../../StateManager'
|
|
@@ -184,7 +186,7 @@ export default defineComponent({
|
|
|
184
186
|
DlButton,
|
|
185
187
|
SuggestionsDropdown,
|
|
186
188
|
DlTooltip,
|
|
187
|
-
|
|
189
|
+
DlDateTimeCard,
|
|
188
190
|
DlMenu,
|
|
189
191
|
DlLabel
|
|
190
192
|
},
|
|
@@ -300,7 +302,7 @@ export default defineComponent({
|
|
|
300
302
|
const menuOffset = ref([0, 5])
|
|
301
303
|
const cancelBlur = ref(0)
|
|
302
304
|
const expanded = ref(true)
|
|
303
|
-
const datePickerSelection = ref(null)
|
|
305
|
+
const datePickerSelection = ref<Date>(null)
|
|
304
306
|
const showDatePicker = ref(false)
|
|
305
307
|
const suggestionsDropdown = ref(null)
|
|
306
308
|
//#endregion
|
|
@@ -333,7 +335,7 @@ export default defineComponent({
|
|
|
333
335
|
}
|
|
334
336
|
|
|
335
337
|
// to handle date suggestion modal to open automatically.
|
|
336
|
-
if (value.includes(
|
|
338
|
+
if (value.includes(dateSuggestionPattern)) {
|
|
337
339
|
value = value.trimEnd()
|
|
338
340
|
}
|
|
339
341
|
|
|
@@ -676,7 +678,7 @@ export default defineComponent({
|
|
|
676
678
|
debouncedSetInputValue.value(text)
|
|
677
679
|
}
|
|
678
680
|
|
|
679
|
-
const onDateSelection = (value:
|
|
681
|
+
const onDateSelection = (value: Date) => {
|
|
680
682
|
datePickerSelection.value = value
|
|
681
683
|
}
|
|
682
684
|
|
|
@@ -1333,10 +1335,6 @@ export default defineComponent({
|
|
|
1333
1335
|
max-width: 100%;
|
|
1334
1336
|
}
|
|
1335
1337
|
|
|
1336
|
-
&__date-picker-wrapper {
|
|
1337
|
-
width: 562px;
|
|
1338
|
-
}
|
|
1339
|
-
|
|
1340
1338
|
&__date-picker-buttons {
|
|
1341
1339
|
padding: 0 16px 16px;
|
|
1342
1340
|
text-align: right;
|
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
Data,
|
|
9
9
|
datePattern,
|
|
10
10
|
datePatternNoBrackets,
|
|
11
|
-
removeBrackets
|
|
11
|
+
removeBrackets,
|
|
12
|
+
pureDateSuggestionPattern
|
|
12
13
|
} from '../../../../../hooks/use-suggestions'
|
|
13
14
|
import moment from 'moment'
|
|
14
15
|
import { cloneDeep, get } from 'lodash'
|
|
@@ -37,8 +38,8 @@ export const isEndingWithDateIntervalPattern = (str: string) => {
|
|
|
37
38
|
return isEndOfString(str, datePattern, { checkWhiteSpace: true })
|
|
38
39
|
}
|
|
39
40
|
|
|
40
|
-
export const replaceDateInterval = (str: string, date:
|
|
41
|
-
const newStr = `${formatDate(date
|
|
41
|
+
export const replaceDateInterval = (str: string, date: Date) => {
|
|
42
|
+
const newStr = `${formatDate(date)}`
|
|
42
43
|
const replaced = replaceFirstOrLastOccurrence(
|
|
43
44
|
str,
|
|
44
45
|
newStr,
|
|
@@ -52,7 +53,7 @@ export const removeDateInterval = (str: string) => {
|
|
|
52
53
|
}
|
|
53
54
|
|
|
54
55
|
const formatDate = (date: Date | string | number): string => {
|
|
55
|
-
return moment(date).format(
|
|
56
|
+
return moment(date).format(pureDateSuggestionPattern)
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
const replaceFirstOrLastOccurrence = (
|
|
@@ -67,7 +68,7 @@ const replaceFirstOrLastOccurrence = (
|
|
|
67
68
|
let match
|
|
68
69
|
|
|
69
70
|
while ((match = regex.exec(string))) {
|
|
70
|
-
if (match[0] ===
|
|
71
|
+
if (match[0] === pureDateSuggestionPattern && !firstMatch) {
|
|
71
72
|
firstMatch = match
|
|
72
73
|
}
|
|
73
74
|
lastMatch = match
|
|
@@ -120,7 +121,7 @@ export function replaceStringifiedDatesWithJSDates(str: string) {
|
|
|
120
121
|
|
|
121
122
|
export function formatToNumericDate(str: string) {
|
|
122
123
|
const dateString = str.replace(/['"\(\)]+/g, '')
|
|
123
|
-
const newDate = moment(dateString,
|
|
124
|
+
const newDate = moment(dateString, pureDateSuggestionPattern)
|
|
124
125
|
const ms = newDate.toDate().getTime()
|
|
125
126
|
return ms
|
|
126
127
|
}
|
|
@@ -79,16 +79,17 @@ type Expression = {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
const space = ' '
|
|
82
|
-
const
|
|
82
|
+
export const pureDateSuggestionPattern = 'DD/MM/YYYY HH:mm:ss'
|
|
83
|
+
export const dateSuggestionPattern = `(${pureDateSuggestionPattern})`
|
|
83
84
|
|
|
84
85
|
let localSuggestions: Suggestion[] = []
|
|
85
86
|
|
|
86
87
|
export const datePattern = new RegExp(
|
|
87
|
-
/
|
|
88
|
+
/[\(']?(\d{2}\/\d{2}\/\d{4}[\)']?\s?|\s?DD\/MM\/YYYY)\s?(\d{2}:\d{2}:\d{2}|\s?HH:mm:ss)[\)']?/,
|
|
88
89
|
'gi'
|
|
89
90
|
)
|
|
90
91
|
export const datePatternNoBrackets =
|
|
91
|
-
/(\d{2}\/\d{2}\/\d{4}\s?|\s?
|
|
92
|
+
/(\d{2}\/\d{2}\/\d{4}[\)']?\s?|\s?DD\/MM\/YYYY)\s?(\d{2}:\d{2}:\d{2}|\s?HH:mm:ss)/
|
|
92
93
|
|
|
93
94
|
const existsValuePlaceholder = 'existsValuePlaceholder'
|
|
94
95
|
|
|
@@ -261,32 +261,42 @@ export const stringifySmartQuery = (query: { [key: string]: any }): string => {
|
|
|
261
261
|
[key: string]: string | number | string[] | number[]
|
|
262
262
|
}
|
|
263
263
|
)[operator]
|
|
264
|
+
|
|
265
|
+
let stringValue = ''
|
|
266
|
+
if (
|
|
267
|
+
['$eq', '$ne', '$gt', '$gte', '$lt', '$lte'].includes(
|
|
268
|
+
operator
|
|
269
|
+
)
|
|
270
|
+
) {
|
|
271
|
+
if (isNumber(operatorValue)) {
|
|
272
|
+
stringValue = `${operatorValue}`
|
|
273
|
+
} else if (isBoolean(operatorValue)) {
|
|
274
|
+
stringValue = `${operatorValue}`
|
|
275
|
+
} else if (isDatePattern(`${operatorValue}`)) {
|
|
276
|
+
stringValue = `(${operatorValue})`
|
|
277
|
+
} else {
|
|
278
|
+
stringValue = `'${operatorValue}'`
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
264
282
|
switch (operator) {
|
|
265
283
|
case '$eq':
|
|
266
|
-
result += `${key} = ${
|
|
267
|
-
isString(operatorValue)
|
|
268
|
-
? `'${operatorValue}'`
|
|
269
|
-
: operatorValue
|
|
270
|
-
}`
|
|
284
|
+
result += `${key} = ${stringValue}`
|
|
271
285
|
break
|
|
272
286
|
case '$ne':
|
|
273
|
-
result += `${key} != ${
|
|
274
|
-
isString(operatorValue)
|
|
275
|
-
? `'${operatorValue}'`
|
|
276
|
-
: operatorValue
|
|
277
|
-
}`
|
|
287
|
+
result += `${key} != ${stringValue}`
|
|
278
288
|
break
|
|
279
289
|
case '$gt':
|
|
280
|
-
result += `${key} > ${
|
|
290
|
+
result += `${key} > ${stringValue}`
|
|
281
291
|
break
|
|
282
292
|
case '$gte':
|
|
283
|
-
result += `${key} >= ${
|
|
293
|
+
result += `${key} >= ${stringValue}`
|
|
284
294
|
break
|
|
285
295
|
case '$lt':
|
|
286
|
-
result += `${key} < ${
|
|
296
|
+
result += `${key} < ${stringValue}`
|
|
287
297
|
break
|
|
288
298
|
case '$lte':
|
|
289
|
-
result += `${key} <= ${
|
|
299
|
+
result += `${key} <= ${stringValue}`
|
|
290
300
|
break
|
|
291
301
|
case '$exists':
|
|
292
302
|
result += `${key} ${
|