@verdnatura/vn-front-lib 0.1.3 → 0.1.5
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/README.md +0 -9
- package/dist/components-DNcJf2vk.cjs +15 -0
- package/dist/components-TYH6aw6P.js +8124 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{composables-C8hw-mbt.js → composables-BJrEMtL8.js} +988 -996
- package/dist/{composables-yeEr4YMb.cjs → composables-CdGu2cUF.cjs} +15 -15
- package/dist/composables.cjs +1 -1
- package/dist/composables.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.js +20 -14
- package/dist/vn-front-lib.cjs +1 -1
- package/dist/vn-front-lib.css +1 -1
- package/dist/vn-front-lib.js +2 -2
- package/lib/components/dialogs/VnConfirm.vue +14 -1
- package/lib/components/feedback/VnSkeletonForm.vue +3 -0
- package/lib/components/inputs/VnDate.vue +25 -24
- package/lib/components/inputs/VnInput.vue +1 -0
- package/lib/components/inputs/VnInputDate.vue +212 -212
- package/lib/components/models/VnForm.vue +1 -0
- package/lib/composables/useNotify.js +2 -2
- package/lib/utils/advancedFilters.js +21 -8
- package/package.json +1 -2
- package/dist/components-CrAKAINn.js +0 -9547
- package/dist/components-Db6HFd9F.cjs +0 -15
|
@@ -1,39 +1,39 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import {nextTick, watch, computed, ref, useAttrs} from
|
|
3
|
-
import {useI18n} from
|
|
4
|
-
import {date, getCssVar} from
|
|
5
|
-
import VnDate from
|
|
2
|
+
import { nextTick, watch, computed, ref, useAttrs } from 'vue';
|
|
3
|
+
import { useI18n } from 'vue-i18n';
|
|
4
|
+
import { date, getCssVar, QInput, QIcon, QTooltip, QMenu, QDialog } from 'quasar';
|
|
5
|
+
import VnDate from './VnDate.vue';
|
|
6
6
|
import { useRequired } from '@verdnatura/vn-front-lib/composables';
|
|
7
7
|
|
|
8
8
|
const $attrs = useAttrs();
|
|
9
|
-
const {t} = useI18n();
|
|
10
|
-
const {isRequired, requiredFieldRule} = useRequired($attrs);
|
|
11
|
-
const model = defineModel({type: [String, Date, Object]});
|
|
9
|
+
const { t } = useI18n();
|
|
10
|
+
const { isRequired, requiredFieldRule } = useRequired($attrs);
|
|
11
|
+
const model = defineModel({ type: [String, Date, Object] });
|
|
12
12
|
|
|
13
13
|
const $props = defineProps({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
14
|
+
isOutlined: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: false,
|
|
17
|
+
},
|
|
18
|
+
showEvent: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: true,
|
|
21
|
+
},
|
|
22
|
+
hideYearNavigation: {
|
|
23
|
+
type: Boolean,
|
|
24
|
+
default: false,
|
|
25
|
+
},
|
|
26
|
+
clearOnHover: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false,
|
|
29
|
+
},
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
const vnInputDateRef = ref(null);
|
|
33
|
-
const errColor = getCssVar(
|
|
34
|
-
const textColor = ref(
|
|
33
|
+
const errColor = getCssVar('negative');
|
|
34
|
+
const textColor = ref('');
|
|
35
35
|
|
|
36
|
-
const dateFormat =
|
|
36
|
+
const dateFormat = 'DD/MM/YYYY';
|
|
37
37
|
const isPopupOpen = ref();
|
|
38
38
|
const hover = ref();
|
|
39
39
|
|
|
@@ -41,232 +41,232 @@ const mixinRules = [requiredFieldRule, ...($attrs.rules ?? [])];
|
|
|
41
41
|
|
|
42
42
|
const val = computed(() => model.value?.neq || model.value?.nin || model.value);
|
|
43
43
|
const inputTitle = computed(() => {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
if (!val.value) return;
|
|
45
|
+
return Array.isArray(val.value)
|
|
46
|
+
? val.value.map((v) => date.formatDate(new Date(v), dateFormat)).join(', ')
|
|
47
|
+
: date.formatDate(new Date(val.value), dateFormat);
|
|
48
48
|
});
|
|
49
49
|
const popupDate = computed(() => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const dateToFormat = Array.isArray(val.value) ? val.value[0] : val.value;
|
|
51
|
+
return dateToFormat
|
|
52
|
+
? date.formatDate(new Date(dateToFormat), 'YYYY/MM/DD')
|
|
53
|
+
: dateToFormat;
|
|
54
54
|
});
|
|
55
55
|
const styleAttrs = computed(() => {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
return $props.isOutlined
|
|
57
|
+
? {
|
|
58
|
+
dense: true,
|
|
59
|
+
outlined: true,
|
|
60
|
+
rounded: true,
|
|
61
|
+
}
|
|
62
|
+
: {};
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
const inputValue = ref(
|
|
66
|
-
const dataCy = $attrs[
|
|
67
|
-
const menuDataCy = dataCy +
|
|
68
|
-
const inputDataCy = dataCy +
|
|
65
|
+
const inputValue = ref('');
|
|
66
|
+
const dataCy = $attrs['data-cy'] ?? $attrs.label;
|
|
67
|
+
const menuDataCy = dataCy + '_menu';
|
|
68
|
+
const inputDataCy = dataCy + '_inputDate';
|
|
69
69
|
|
|
70
70
|
const validateAndCleanInput = (value) => {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
if (!value && $attrs.clearable) {
|
|
72
|
+
inputValue.value = null;
|
|
73
|
+
model.value = null;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
inputValue.value = value.replace(/[^0-9./-]/g, '');
|
|
77
77
|
};
|
|
78
78
|
|
|
79
79
|
const manageDate = (date) => {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
80
|
+
if (!date) return;
|
|
81
|
+
inputValue.value = date.split('/').reverse().join('/');
|
|
82
|
+
formatDate();
|
|
83
|
+
isPopupOpen.value = false;
|
|
84
84
|
};
|
|
85
85
|
|
|
86
86
|
watch(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
87
|
+
() => model.value,
|
|
88
|
+
() => {
|
|
89
|
+
const dateToFormat = Array.isArray(val.value) ? val.value[0] : val.value;
|
|
90
|
+
inputValue.value = dateToFormat
|
|
91
|
+
? date.formatDate(new Date(dateToFormat), dateFormat)
|
|
92
|
+
: '';
|
|
93
|
+
},
|
|
94
|
+
{ immediate: true },
|
|
95
95
|
);
|
|
96
96
|
|
|
97
97
|
watch(isPopupOpen, (val) => {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
98
|
+
if (val && $props.hideYearNavigation) {
|
|
99
|
+
nextTick(() => {
|
|
100
|
+
const navButtons = ['back', 'type', 'forward'];
|
|
101
|
+
document.querySelectorAll(`.q-date__navigation`).forEach((parent) => {
|
|
102
|
+
for (let i = 0; i < navButtons.length; i++) {
|
|
103
|
+
if (parent.lastElementChild)
|
|
104
|
+
parent.removeChild(parent.lastElementChild);
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
109
|
});
|
|
110
110
|
|
|
111
111
|
const formatDate = () => {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
112
|
+
let value = inputValue.value;
|
|
113
|
+
if (!value || value === model.value) {
|
|
114
|
+
textColor.value = '';
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
const regex =
|
|
118
|
+
/^([0]?[1-9]|[12][0-9]|3[01])([./-])([0]?[1-9]|1[0-2])([./-](\d{1,4}))?$/;
|
|
119
|
+
if (!regex.test(value)) {
|
|
120
|
+
textColor.value = errColor;
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
124
|
+
value = value.replace(/[.-]/g, '/');
|
|
125
|
+
const parts = value.split('/');
|
|
126
|
+
if (parts.length < 2) {
|
|
127
|
+
textColor.value = errColor;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
131
|
+
let [day, month, year] = parts;
|
|
132
|
+
if (day.length === 1) day = '0' + day;
|
|
133
|
+
if (month.length === 1) month = '0' + month;
|
|
134
134
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
135
|
+
const currentYear = Date.vnNew().getFullYear();
|
|
136
|
+
if (!year) year = currentYear;
|
|
137
|
+
const millennium = currentYear.toString().slice(0, 1);
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
139
|
+
switch (year.length) {
|
|
140
|
+
case 1:
|
|
141
|
+
year = `${millennium}00${year}`;
|
|
142
|
+
break;
|
|
143
|
+
case 2:
|
|
144
|
+
year = `${millennium}0${year}`;
|
|
145
|
+
break;
|
|
146
|
+
case 3:
|
|
147
|
+
year = `${millennium}${year}`;
|
|
148
|
+
break;
|
|
149
|
+
case 4:
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
152
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
153
|
+
let isoCandidate = `${year}/${month}/${day}`;
|
|
154
|
+
isoCandidate = date.formatDate(
|
|
155
|
+
new Date(isoCandidate).toISOString(),
|
|
156
|
+
'YYYY-MM-DDTHH:mm:ss.SSSZ',
|
|
157
|
+
);
|
|
158
|
+
const [isoYear, isoMonth, isoDay] = isoCandidate.split('-').map((e) => parseInt(e));
|
|
159
|
+
const parsedDate = new Date(isoYear, isoMonth - 1, isoDay);
|
|
160
160
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
161
|
+
const isValidDate =
|
|
162
|
+
parsedDate instanceof Date &&
|
|
163
|
+
!isNaN(parsedDate) &&
|
|
164
|
+
parsedDate.getFullYear() === parseInt(year) &&
|
|
165
|
+
parsedDate.getMonth() === parseInt(month) - 1 &&
|
|
166
|
+
parsedDate.getDate() === parseInt(day);
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
if (!isValidDate) {
|
|
169
|
+
textColor.value = errColor;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
172
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
173
|
+
if (val.value) {
|
|
174
|
+
const originalVal = Array.isArray(val.value) ? val.value[0] : val.value;
|
|
175
|
+
const original =
|
|
176
|
+
originalVal instanceof Date ? originalVal : new Date(originalVal);
|
|
177
|
+
parsedDate.setHours(
|
|
178
|
+
original.getHours(),
|
|
179
|
+
original.getMinutes(),
|
|
180
|
+
original.getSeconds(),
|
|
181
|
+
original.getMilliseconds(),
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
184
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
185
|
+
const iso = parsedDate.toISOString();
|
|
186
|
+
if (model.value?.neq) model.value = { neq: iso };
|
|
187
|
+
else if (model.value?.nin) model.value = { nin: [...model.value.nin, iso] };
|
|
188
|
+
else model.value = iso;
|
|
189
189
|
|
|
190
|
-
|
|
190
|
+
textColor.value = '';
|
|
191
191
|
};
|
|
192
192
|
|
|
193
193
|
const handleEnter = (event) => {
|
|
194
|
-
|
|
194
|
+
formatDate();
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
196
|
+
nextTick(() => {
|
|
197
|
+
const newEvent = new KeyboardEvent('keydown', {
|
|
198
|
+
key: 'Enter',
|
|
199
|
+
code: 'Enter',
|
|
200
|
+
bubbles: true,
|
|
201
|
+
cancelable: true,
|
|
202
|
+
});
|
|
203
|
+
vnInputDateRef.value?.$el?.dispatchEvent(newEvent);
|
|
202
204
|
});
|
|
203
|
-
vnInputDateRef.value?.$el?.dispatchEvent(newEvent);
|
|
204
|
-
});
|
|
205
205
|
};
|
|
206
206
|
</script>
|
|
207
207
|
|
|
208
208
|
<template>
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
>
|
|
231
|
-
<template #append>
|
|
232
|
-
<QIcon
|
|
233
|
-
name="close"
|
|
234
|
-
size="xs"
|
|
235
|
-
class="cursor-pointer"
|
|
236
|
-
v-if="
|
|
237
|
-
($attrs.clearable == undefined || $attrs.clearable) &&
|
|
238
|
-
(!clearOnHover || hover) &&
|
|
239
|
-
inputValue &&
|
|
240
|
-
!$attrs.disable
|
|
241
|
-
"
|
|
242
|
-
@click="
|
|
243
|
-
vnInputDateRef.focus();
|
|
244
|
-
inputValue = null;
|
|
245
|
-
model = null;
|
|
246
|
-
isPopupOpen = false;
|
|
247
|
-
"
|
|
209
|
+
<div @mouseover="hover = true" @mouseleave="hover = false">
|
|
210
|
+
<QInput
|
|
211
|
+
ref="vnInputDateRef"
|
|
212
|
+
v-model="inputValue"
|
|
213
|
+
class="vn-input-date"
|
|
214
|
+
placeholder="dd/mm/aaaa"
|
|
215
|
+
v-bind="{ ...$attrs, ...styleAttrs }"
|
|
216
|
+
:class="{ required: isRequired }"
|
|
217
|
+
:rules="mixinRules"
|
|
218
|
+
:clearable="false"
|
|
219
|
+
:input-style="{ color: textColor }"
|
|
220
|
+
:input-class="{ 'text-strike': !!(model?.neq || model?.nin) }"
|
|
221
|
+
:title="inputTitle"
|
|
222
|
+
@click="isPopupOpen = !isPopupOpen"
|
|
223
|
+
@keydown="isPopupOpen = false"
|
|
224
|
+
@focusout="formatDate"
|
|
225
|
+
@keydown.enter.prevent="handleEnter"
|
|
226
|
+
hide-bottom-space
|
|
227
|
+
:data-cy="inputDataCy"
|
|
228
|
+
@update:model-value="validateAndCleanInput"
|
|
229
|
+
autocomplete="off"
|
|
248
230
|
>
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
231
|
+
<template #append>
|
|
232
|
+
<QIcon
|
|
233
|
+
name="close"
|
|
234
|
+
size="xs"
|
|
235
|
+
class="cursor-pointer"
|
|
236
|
+
v-if="
|
|
237
|
+
($attrs.clearable == undefined || $attrs.clearable) &&
|
|
238
|
+
(!clearOnHover || hover) &&
|
|
239
|
+
inputValue &&
|
|
240
|
+
!$attrs.disable
|
|
241
|
+
"
|
|
242
|
+
@click="
|
|
243
|
+
vnInputDateRef.focus();
|
|
244
|
+
inputValue = null;
|
|
245
|
+
model = null;
|
|
246
|
+
isPopupOpen = false;
|
|
247
|
+
"
|
|
248
|
+
>
|
|
249
|
+
<QTooltip>{{ t('Remove') }}</QTooltip>
|
|
250
|
+
</QIcon>
|
|
251
|
+
</template>
|
|
252
|
+
<QMenu
|
|
253
|
+
v-if="$q.screen.gt.xs"
|
|
254
|
+
transition-show="scale"
|
|
255
|
+
transition-hide="scale"
|
|
256
|
+
v-model="isPopupOpen"
|
|
257
|
+
anchor="bottom left"
|
|
258
|
+
self="top start"
|
|
259
|
+
:no-focus="true"
|
|
260
|
+
:no-parent-event="true"
|
|
261
|
+
:data-cy="menuDataCy"
|
|
262
|
+
>
|
|
263
|
+
<VnDate v-model="popupDate" @update:model-value="manageDate" />
|
|
264
|
+
</QMenu>
|
|
265
|
+
<QDialog v-else v-model="isPopupOpen">
|
|
266
|
+
<VnDate v-model="popupDate" @update:model-value="manageDate" />
|
|
267
|
+
</QDialog>
|
|
268
|
+
</QInput>
|
|
269
|
+
</div>
|
|
270
270
|
</template>
|
|
271
271
|
<i18n>
|
|
272
272
|
es:
|
|
@@ -4,6 +4,7 @@ import { onMounted, onUnmounted, computed, ref, watch, nextTick } from 'vue';
|
|
|
4
4
|
import { onBeforeRouteLeave, useRouter, useRoute } from 'vue-router';
|
|
5
5
|
import { useI18n } from 'vue-i18n';
|
|
6
6
|
import * as quasarPkg from 'quasar';
|
|
7
|
+
import { QInnerLoading, QForm, QCard, QCardSection, QBtnGroup, QBtn } from 'quasar';
|
|
7
8
|
import {
|
|
8
9
|
useState,
|
|
9
10
|
useValidator,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Notify } from 'quasar';
|
|
2
2
|
import { i18n } from './useGlobalMessages';
|
|
3
3
|
|
|
4
4
|
export function useNotify() {
|
|
@@ -14,7 +14,7 @@ export function useNotify() {
|
|
|
14
14
|
icon: icon ? icon : defaultIcons[type],
|
|
15
15
|
...opts,
|
|
16
16
|
};
|
|
17
|
-
|
|
17
|
+
Notify.create(payload);
|
|
18
18
|
};
|
|
19
19
|
|
|
20
20
|
return {
|
|
@@ -6,7 +6,7 @@ export const advancedFilters = {
|
|
|
6
6
|
label: 'equal',
|
|
7
7
|
operator: defaultOperator,
|
|
8
8
|
default: true,
|
|
9
|
-
expr: (value) => value,
|
|
9
|
+
expr: (value) => parseValue(value),
|
|
10
10
|
localEval: (a, b) => a == b,
|
|
11
11
|
isBasic: true,
|
|
12
12
|
},
|
|
@@ -14,7 +14,7 @@ export const advancedFilters = {
|
|
|
14
14
|
icon: '≠',
|
|
15
15
|
label: 'distinct',
|
|
16
16
|
operator: 'neq',
|
|
17
|
-
expr: (value) => ({ neq: value }),
|
|
17
|
+
expr: (value) => ({ neq: parseValue(value) }),
|
|
18
18
|
isNegation: true,
|
|
19
19
|
localEval: (a, b) => a != b,
|
|
20
20
|
},
|
|
@@ -23,7 +23,7 @@ export const advancedFilters = {
|
|
|
23
23
|
label: 'include',
|
|
24
24
|
operator: 'inq',
|
|
25
25
|
isArray: true,
|
|
26
|
-
expr: (value) => ({ inq: value }),
|
|
26
|
+
expr: (value) => ({ inq: parseValue(value) }),
|
|
27
27
|
localEval: (a, b) => b.includes(a),
|
|
28
28
|
},
|
|
29
29
|
nin: {
|
|
@@ -31,7 +31,7 @@ export const advancedFilters = {
|
|
|
31
31
|
label: 'exclude',
|
|
32
32
|
operator: 'nin',
|
|
33
33
|
isArray: true,
|
|
34
|
-
expr: (value) => ({ nin: value }),
|
|
34
|
+
expr: (value) => ({ nin: parseValue(value) }),
|
|
35
35
|
isNegation: true,
|
|
36
36
|
localEval: (a, b) => !b.includes(a),
|
|
37
37
|
},
|
|
@@ -56,7 +56,7 @@ export const advancedFilters = {
|
|
|
56
56
|
icon: '<',
|
|
57
57
|
label: 'lessThan',
|
|
58
58
|
operator: 'lt',
|
|
59
|
-
expr: (value) => ({ lt: value }),
|
|
59
|
+
expr: (value) => ({ lt: parseValue(value) }),
|
|
60
60
|
localEval: (a, b) => a < b,
|
|
61
61
|
isInput: true,
|
|
62
62
|
},
|
|
@@ -65,7 +65,7 @@ export const advancedFilters = {
|
|
|
65
65
|
label: 'greaterThan',
|
|
66
66
|
operator: 'gt',
|
|
67
67
|
isInput: true,
|
|
68
|
-
expr: (value) => ({ gt: value }),
|
|
68
|
+
expr: (value) => ({ gt: parseValue(value) }),
|
|
69
69
|
localEval: (a, b) => a > b,
|
|
70
70
|
},
|
|
71
71
|
lte: {
|
|
@@ -73,7 +73,7 @@ export const advancedFilters = {
|
|
|
73
73
|
label: 'lessThanEqualTo',
|
|
74
74
|
operator: 'lte',
|
|
75
75
|
isInput: true,
|
|
76
|
-
expr: (value) => ({ lte: value }),
|
|
76
|
+
expr: (value) => ({ lte: parseValue(value) }),
|
|
77
77
|
localEval: (a, b) => a <= b,
|
|
78
78
|
},
|
|
79
79
|
gte: {
|
|
@@ -81,7 +81,7 @@ export const advancedFilters = {
|
|
|
81
81
|
label: 'greaterThanEqualTo',
|
|
82
82
|
operator: 'gte',
|
|
83
83
|
isInput: true,
|
|
84
|
-
expr: (value) => ({ gte: value }),
|
|
84
|
+
expr: (value) => ({ gte: parseValue(value) }),
|
|
85
85
|
localEval: (a, b) => a >= b,
|
|
86
86
|
},
|
|
87
87
|
null: {
|
|
@@ -123,3 +123,16 @@ function matchesLike(a, b) {
|
|
|
123
123
|
|
|
124
124
|
return new RegExp(`^${pattern}$`, 'i').test(source);
|
|
125
125
|
}
|
|
126
|
+
|
|
127
|
+
function parseValue(value) {
|
|
128
|
+
if (!isDate(value)) return value;
|
|
129
|
+
// YYYY-MM-DD
|
|
130
|
+
return new Intl.DateTimeFormat('en-CA').format(new Date(value));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function isDate(value) {
|
|
134
|
+
return (
|
|
135
|
+
value instanceof Date ||
|
|
136
|
+
(typeof value === 'string' && /^\d{4}-\d{2}-\d{2}$/.test(value?.split('T')[0]))
|
|
137
|
+
);
|
|
138
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verdnatura/vn-front-lib",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Vue 3 component and composable library",
|
|
5
5
|
"license": "GPL-3.0",
|
|
6
6
|
"author": "Verdnatura Levante SL",
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@intlify/unplugin-vue-i18n": "^11.2.5",
|
|
59
|
-
"@quasar/vite-plugin": "^1.12.0",
|
|
60
59
|
"@vitejs/plugin-vue": "^6.0.8",
|
|
61
60
|
"@vue/test-utils": "^2.4.11",
|
|
62
61
|
"axios": "^1.18.1",
|