vueless 0.0.169 → 0.0.170
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/directive.clickOutside/index.js +10 -2
- package/package.json +1 -1
- package/ui.form-calendar/components/DayView.vue +21 -13
- package/ui.form-calendar/index.stories.js +1 -1
- package/ui.form-calendar/index.vue +11 -5
- package/ui.form-date-picker-range/configs/default.config.js +2 -1
- package/ui.form-date-picker-range/index.vue +97 -67
- package/ui.form-date-picker-range/services/validation.service.js +7 -7
- package/web-types.json +1 -1
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { unref } from "vue";
|
|
2
2
|
|
|
3
3
|
function clickOutside(target, handler, options) {
|
|
4
|
-
const { capture = true } = options;
|
|
4
|
+
const { capture = true, ignore = [] } = options;
|
|
5
5
|
|
|
6
6
|
let shouldListen = true;
|
|
7
7
|
|
|
8
|
+
const ignoreList = unref(ignore).map((item) => unref(item));
|
|
8
9
|
const el = unref(target);
|
|
9
10
|
|
|
10
11
|
function onClick(event) {
|
|
11
|
-
if (
|
|
12
|
+
if (
|
|
13
|
+
!el ||
|
|
14
|
+
el === event.target ||
|
|
15
|
+
event.composedPath().includes(el) ||
|
|
16
|
+
ignoreList.includes(event.target)
|
|
17
|
+
) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
12
20
|
|
|
13
21
|
if (!shouldListen) {
|
|
14
22
|
shouldListen = true;
|
package/package.json
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
<script setup>
|
|
22
22
|
import { computed } from "vue";
|
|
23
23
|
|
|
24
|
+
import { cx } from "../../service.ui";
|
|
24
25
|
import { formatDate, dateIsOutOfRange } from "../services/calendar.service";
|
|
25
26
|
import {
|
|
26
27
|
isToday,
|
|
@@ -210,33 +211,40 @@ function getDay(date, dayNumber) {
|
|
|
210
211
|
}
|
|
211
212
|
|
|
212
213
|
function getDayClasses(day) {
|
|
214
|
+
const isDayInRange =
|
|
215
|
+
props.range &&
|
|
216
|
+
localSelectedDate.value &&
|
|
217
|
+
props.selectedDateTo &&
|
|
218
|
+
!dateIsOutOfRange(
|
|
219
|
+
day,
|
|
220
|
+
props.selectedDate,
|
|
221
|
+
props.selectedDateTo,
|
|
222
|
+
props.locale,
|
|
223
|
+
props.dateFormat,
|
|
224
|
+
);
|
|
225
|
+
|
|
213
226
|
const isNotSelectedDate =
|
|
214
227
|
(!isSelectedDay(day) && !isSelectedToDay(day)) || props.selectedDate === null;
|
|
215
228
|
|
|
216
229
|
if (isToday(day) && isNotSelectedDate) {
|
|
217
|
-
return [currentDayAttrs.value.class];
|
|
230
|
+
return cx([isDayInRange && inRangeDayAttrs.value.class, currentDayAttrs.value.class]);
|
|
218
231
|
}
|
|
219
232
|
|
|
220
233
|
if (props.range && isSelectedDay(day)) {
|
|
221
|
-
return [
|
|
222
|
-
inRangeFirstDayAttrs.value.class,
|
|
234
|
+
return cx([
|
|
223
235
|
isAnotherMothDay(day, activeMonthDate.value) && anotherMonthDayAttrs.value.class,
|
|
224
|
-
|
|
236
|
+
inRangeFirstDayAttrs.value.class,
|
|
237
|
+
]);
|
|
225
238
|
}
|
|
226
239
|
|
|
227
240
|
if (props.range && isSelectedToDay(day)) {
|
|
228
|
-
return [
|
|
229
|
-
inRangeLastDayAttrs.value.class,
|
|
241
|
+
return cx([
|
|
230
242
|
isAnotherMothDay(day, activeMonthDate.value) && anotherMonthDayAttrs.value.class,
|
|
231
|
-
|
|
243
|
+
inRangeLastDayAttrs.value.class,
|
|
244
|
+
]);
|
|
232
245
|
}
|
|
233
246
|
|
|
234
|
-
if (
|
|
235
|
-
props.range &&
|
|
236
|
-
localSelectedDate.value &&
|
|
237
|
-
props.selectedDateTo &&
|
|
238
|
-
!dateIsOutOfRange(day, props.selectedDate, props.selectedDateTo, props.locale, props.dateFormat)
|
|
239
|
-
) {
|
|
247
|
+
if (isDayInRange) {
|
|
240
248
|
return [inRangeDayAttrs.value.class];
|
|
241
249
|
}
|
|
242
250
|
|
|
@@ -64,7 +64,7 @@ Timepicker.args = { value: new Date(2024, 2, 14, 12, 24, 14), timepicker: true }
|
|
|
64
64
|
|
|
65
65
|
export const MinMax = DefaultTemplate.bind({});
|
|
66
66
|
MinMax.args = {
|
|
67
|
-
minDate:
|
|
67
|
+
minDate: new Date(2022, 2, 22),
|
|
68
68
|
maxDate: new Date(2022, 2, 26),
|
|
69
69
|
value: new Date(2022, 2, 24),
|
|
70
70
|
};
|
|
@@ -579,17 +579,23 @@ function onInputDate(newDate) {
|
|
|
579
579
|
const isFullReset =
|
|
580
580
|
localValue.value.to || !localValue.value.from || date <= localValue.value.from;
|
|
581
581
|
|
|
582
|
-
|
|
582
|
+
const updatedValue = isFullReset
|
|
583
583
|
? { from: date, to: null }
|
|
584
584
|
: { from: localValue.value.from, to: date };
|
|
585
|
+
|
|
586
|
+
localValue.value = updatedValue;
|
|
587
|
+
|
|
588
|
+
emit("input", updatedValue);
|
|
585
589
|
} else {
|
|
586
590
|
localValue.value = date;
|
|
587
|
-
}
|
|
588
591
|
|
|
589
|
-
|
|
590
|
-
|
|
592
|
+
emit("input", localValue.value);
|
|
593
|
+
}
|
|
591
594
|
|
|
592
|
-
|
|
595
|
+
if (!props.range) {
|
|
596
|
+
activeDate.value = null;
|
|
597
|
+
activeMonth.value = null;
|
|
598
|
+
}
|
|
593
599
|
|
|
594
600
|
wrapperRef.value.focus();
|
|
595
601
|
}
|
|
@@ -102,7 +102,6 @@ export default /*tw*/ {
|
|
|
102
102
|
},
|
|
103
103
|
},
|
|
104
104
|
day: "font-medium w-full h-10 text-sm mb-0.5",
|
|
105
|
-
currentDay: "text-white bg-brand-900 hover:bg-brand-900 hover:text-white",
|
|
106
105
|
weekDay: "text-sm size-10",
|
|
107
106
|
month: "font-medium",
|
|
108
107
|
selectedMonth: "bg-zinc-100 text-brand-900 hover:text-white",
|
|
@@ -119,6 +118,8 @@ export default /*tw*/ {
|
|
|
119
118
|
dateFormatWithDot: "Date should be in format 'dd.mm.yyyy'.",
|
|
120
119
|
notCorrectMonthNumber: "Wrong month number.",
|
|
121
120
|
notCorrectDayNumber: "Wrong day in month.",
|
|
121
|
+
fromDateGraterThanSecond: "The first date should be less than the second.",
|
|
122
|
+
toDateSmallerThanFirst: "The second date should be greater than the first.",
|
|
122
123
|
weekdays: {
|
|
123
124
|
shorthand: {
|
|
124
125
|
sunday: "Sun",
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
<div v-if="isVariant.button" v-bind="buttonWrapperAttrs">
|
|
31
31
|
<UButton
|
|
32
|
+
ref="buttonPrevRef"
|
|
32
33
|
square
|
|
33
34
|
:size="size"
|
|
34
35
|
:disabled="disabled"
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
|
|
41
42
|
<UButton
|
|
42
43
|
:id="id"
|
|
44
|
+
ref="buttonRef"
|
|
43
45
|
:size="size"
|
|
44
46
|
:disabled="disabled"
|
|
45
47
|
:label="userFormatDate"
|
|
@@ -48,6 +50,7 @@
|
|
|
48
50
|
/>
|
|
49
51
|
|
|
50
52
|
<UButton
|
|
53
|
+
ref="buttonNextRef"
|
|
51
54
|
square
|
|
52
55
|
:size="size"
|
|
53
56
|
:disabled="disabled"
|
|
@@ -62,11 +65,10 @@
|
|
|
62
65
|
<div
|
|
63
66
|
v-if="isShownMenu"
|
|
64
67
|
ref="menuRef"
|
|
68
|
+
v-click-outside="[deactivate, clickOutsideOptions]"
|
|
65
69
|
tabindex="-1"
|
|
66
70
|
v-bind="menuAttrs"
|
|
67
|
-
@blur="onBlur"
|
|
68
71
|
@keydown.esc="deactivate"
|
|
69
|
-
@mouseleave="onMouseoutMenu"
|
|
70
72
|
>
|
|
71
73
|
<div v-bind="periodsRowAttrs">
|
|
72
74
|
<div
|
|
@@ -146,28 +148,26 @@
|
|
|
146
148
|
<UInput
|
|
147
149
|
ref="rangeInputStartRef"
|
|
148
150
|
v-model="rangeStart"
|
|
149
|
-
:error="
|
|
151
|
+
:error="inputRangeFromError"
|
|
150
152
|
size="sm"
|
|
151
153
|
v-bind="rangeInputAttrs"
|
|
152
154
|
:name="rangeInputName"
|
|
153
155
|
@input="onInputRangeInput($event, INPUT_RANGE_TYPE.start)"
|
|
154
|
-
@blur="onBlurRangeInput"
|
|
155
156
|
/>
|
|
156
157
|
|
|
157
158
|
<UInput
|
|
158
159
|
ref="rangeInputEndRef"
|
|
159
160
|
v-model="rangeEnd"
|
|
160
|
-
:error="
|
|
161
|
+
:error="inputRangeToError"
|
|
161
162
|
size="sm"
|
|
162
163
|
v-bind="rangeInputAttrs"
|
|
163
164
|
:name="rangeInputName"
|
|
164
165
|
@input="onInputRangeInput($event, INPUT_RANGE_TYPE.end)"
|
|
165
|
-
@blur="onBlurRangeInput"
|
|
166
166
|
/>
|
|
167
167
|
</div>
|
|
168
168
|
|
|
169
169
|
<div v-bind="inputRangeErrorAttrs">
|
|
170
|
-
{{
|
|
170
|
+
{{ inputRangeToError || inputRangeFromError }}
|
|
171
171
|
</div>
|
|
172
172
|
|
|
173
173
|
<UCalendar
|
|
@@ -179,6 +179,7 @@
|
|
|
179
179
|
:date-format="dateFormat"
|
|
180
180
|
range
|
|
181
181
|
@mouseenter="onMouseoverCalendar"
|
|
182
|
+
@input="onInputCalendar"
|
|
182
183
|
/>
|
|
183
184
|
</div>
|
|
184
185
|
</Transition>
|
|
@@ -195,6 +196,8 @@ import UButton from "../ui.button";
|
|
|
195
196
|
import UCalendar from "../ui.form-calendar";
|
|
196
197
|
import { LOCALE_TYPE } from "../ui.form-calendar/constants";
|
|
197
198
|
|
|
199
|
+
import vClickOutside from "../directive.clickOutside";
|
|
200
|
+
|
|
198
201
|
import UIService, { getRandomId } from "../service.ui";
|
|
199
202
|
|
|
200
203
|
import {
|
|
@@ -227,7 +230,11 @@ import {
|
|
|
227
230
|
getMonthsDateList,
|
|
228
231
|
} from "./services/dateRange.service";
|
|
229
232
|
|
|
230
|
-
import {
|
|
233
|
+
import {
|
|
234
|
+
isWrongDateFormat,
|
|
235
|
+
isWrongMonthNumber,
|
|
236
|
+
isWrongDayNumber,
|
|
237
|
+
} from "./services/validation.service";
|
|
231
238
|
import useAttrs from "./composables/attrs.composable";
|
|
232
239
|
import { useLocale } from "../composable.locale";
|
|
233
240
|
import useBreakpoint from "../composable.breakpoint";
|
|
@@ -395,6 +402,8 @@ const props = defineProps({
|
|
|
395
402
|
},
|
|
396
403
|
});
|
|
397
404
|
|
|
405
|
+
const inputRangeFormat = "d.m.Y";
|
|
406
|
+
|
|
398
407
|
const emit = defineEmits(["update:modelValue"]);
|
|
399
408
|
|
|
400
409
|
const isShownMenu = ref(false);
|
|
@@ -402,6 +411,9 @@ const wrapperRef = ref(null);
|
|
|
402
411
|
const menuRef = ref(null);
|
|
403
412
|
const rangeInputStartRef = ref(null);
|
|
404
413
|
const rangeInputEndRef = ref(null);
|
|
414
|
+
const buttonRef = ref(null);
|
|
415
|
+
const buttonPrevRef = ref(null);
|
|
416
|
+
const buttonNextRef = ref(null);
|
|
405
417
|
|
|
406
418
|
const { isTop, isRight, adjustPositionY, adjustPositionX } = useAdjustElementPosition(
|
|
407
419
|
wrapperRef,
|
|
@@ -444,6 +456,10 @@ const i18nGlobal = tm(UDatePickerRange);
|
|
|
444
456
|
|
|
445
457
|
const currentLocale = computed(() => merge(defaultConfig.i18n, i18nGlobal, props.config.i18n));
|
|
446
458
|
|
|
459
|
+
const clickOutsideOptions = computed(() => ({
|
|
460
|
+
ignore: [buttonRef.value.buttonRef, buttonPrevRef.value.buttonRef, buttonNextRef.value.buttonRef],
|
|
461
|
+
}));
|
|
462
|
+
|
|
447
463
|
const locale = computed(() => {
|
|
448
464
|
const { months, weekdays } = currentLocale.value;
|
|
449
465
|
|
|
@@ -470,9 +486,9 @@ const activeDate = ref(
|
|
|
470
486
|
const period = ref(PERIOD.ownRange);
|
|
471
487
|
const rangeStart = ref("");
|
|
472
488
|
const rangeEnd = ref("");
|
|
473
|
-
const
|
|
474
|
-
const
|
|
475
|
-
const
|
|
489
|
+
const inputRangeFromError = ref("");
|
|
490
|
+
const inputRangeToError = ref("");
|
|
491
|
+
const calendarInnerValue = ref({ from: "", to: "" });
|
|
476
492
|
const periodDateList = ref(null);
|
|
477
493
|
|
|
478
494
|
const { isMobileBreakpoint } = useBreakpoint();
|
|
@@ -611,9 +627,19 @@ const userFormatDate = computed(() => {
|
|
|
611
627
|
startYear = "";
|
|
612
628
|
}
|
|
613
629
|
|
|
614
|
-
const
|
|
615
|
-
|
|
616
|
-
|
|
630
|
+
const isDatesToSameMonth = isSameMonth(from, to);
|
|
631
|
+
const isDatesToSameYear = from.getFullYear() === to.getFullYear();
|
|
632
|
+
|
|
633
|
+
let fromTitle = `${from.getDate()} ${startMonthName} ${startYear}`;
|
|
634
|
+
|
|
635
|
+
if (isDatesToSameMonth && isDatesToSameYear) {
|
|
636
|
+
fromTitle = from.getDate();
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
if (!isDatesToSameMonth && isDatesToSameYear) {
|
|
640
|
+
fromTitle = `${from.getDate()} ${startMonthName}`;
|
|
641
|
+
}
|
|
642
|
+
|
|
617
643
|
const toTitle = to ? `${to.getDate()} ${endMonthName} ${endYear}` : "";
|
|
618
644
|
|
|
619
645
|
title = `${fromTitle} – ${toTitle}`;
|
|
@@ -680,13 +706,15 @@ watch(
|
|
|
680
706
|
const parsedDateTo = parseDate(props.modelValue.to, props.dateFormat, locale.value);
|
|
681
707
|
|
|
682
708
|
rangeStart.value = props.modelValue.from
|
|
683
|
-
? formatDate(parsedDateFrom,
|
|
709
|
+
? formatDate(parsedDateFrom, inputRangeFormat, locale.value)
|
|
684
710
|
: "";
|
|
685
711
|
|
|
686
|
-
rangeEnd.value = props.modelValue.to
|
|
712
|
+
rangeEnd.value = props.modelValue.to
|
|
713
|
+
? formatDate(parsedDateTo, inputRangeFormat, locale.value)
|
|
714
|
+
: "";
|
|
687
715
|
|
|
688
|
-
|
|
689
|
-
|
|
716
|
+
inputRangeFromError.value = "";
|
|
717
|
+
inputRangeToError.value = "";
|
|
690
718
|
},
|
|
691
719
|
{ deep: true, immediate: true },
|
|
692
720
|
);
|
|
@@ -820,72 +848,75 @@ function activate() {
|
|
|
820
848
|
|
|
821
849
|
function deactivate() {
|
|
822
850
|
isShownMenu.value = false;
|
|
823
|
-
|
|
824
|
-
isHoverEvent.value = false;
|
|
825
851
|
}
|
|
826
852
|
|
|
827
|
-
function
|
|
828
|
-
|
|
853
|
+
function isGraterThanTo(value) {
|
|
854
|
+
if (!value) return false;
|
|
829
855
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
833
|
-
}
|
|
856
|
+
const parsedValue = parseDate(value, inputRangeFormat, locale.value);
|
|
857
|
+
const parsedTo = parseDate(localValue.value.to, props.dateFormat, locale.value);
|
|
834
858
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
const isRangeInputFocus = relatedTarget?.name === rangeInputName.value;
|
|
859
|
+
return parsedValue > parsedTo;
|
|
860
|
+
}
|
|
838
861
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
}
|
|
862
|
+
function isSmallerThanFrom(value) {
|
|
863
|
+
if (!value) return false;
|
|
842
864
|
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
}
|
|
865
|
+
const parsedValue = parseDate(value, inputRangeFormat, locale.value);
|
|
866
|
+
const parsedFrom = parseDate(localValue.value.from, props.dateFormat, locale.value);
|
|
846
867
|
|
|
847
|
-
|
|
868
|
+
return parsedValue < parsedFrom;
|
|
848
869
|
}
|
|
849
870
|
|
|
850
871
|
function onInputRangeInput(value, type) {
|
|
851
|
-
const isInvalidDateFormat =
|
|
852
|
-
const isInvalidMonthNumber = !wrongMonthNumber(value);
|
|
853
|
-
const isInvalidDayNumber = !wrongDayNumber(value);
|
|
872
|
+
const isInvalidDateFormat = isWrongDateFormat(value);
|
|
854
873
|
|
|
855
874
|
let error = "";
|
|
856
875
|
|
|
857
876
|
if (isInvalidDateFormat && value) {
|
|
858
877
|
error = locale.value.dateFormatWithDot;
|
|
859
|
-
} else if (
|
|
878
|
+
} else if (isWrongMonthNumber(value) && value) {
|
|
860
879
|
error = locale.value.notCorrectMonthNumber;
|
|
861
|
-
} else if (
|
|
880
|
+
} else if (isWrongDayNumber(value) && value) {
|
|
862
881
|
error = locale.value.notCorrectDayNumber;
|
|
882
|
+
} else if (isGraterThanTo(value) && type === INPUT_RANGE_TYPE.start) {
|
|
883
|
+
error = locale.value.fromDateGraterThanSecond;
|
|
884
|
+
} else if (isSmallerThanFrom(value) && type === INPUT_RANGE_TYPE.end) {
|
|
885
|
+
error = locale.value.toDateSmallerThanFirst;
|
|
863
886
|
}
|
|
864
887
|
|
|
865
888
|
if (type === INPUT_RANGE_TYPE.start) {
|
|
866
|
-
|
|
889
|
+
inputRangeFromError.value = error;
|
|
867
890
|
}
|
|
868
891
|
|
|
869
892
|
if (type === INPUT_RANGE_TYPE.end) {
|
|
870
|
-
|
|
893
|
+
inputRangeToError.value = error;
|
|
871
894
|
}
|
|
872
895
|
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
parsedValue,
|
|
876
|
-
props.minDate,
|
|
877
|
-
props.maxDate,
|
|
878
|
-
locale.value,
|
|
879
|
-
props.dateFormat,
|
|
880
|
-
);
|
|
881
|
-
const isToLessThanFrom = parsedValue <= localValue.value.from;
|
|
896
|
+
if (!isInvalidDateFormat) {
|
|
897
|
+
const parsedValue = parseDate(value || new Date(), inputRangeFormat, locale.value);
|
|
882
898
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
899
|
+
const isOutOfRange = dateIsOutOfRange(
|
|
900
|
+
parsedValue,
|
|
901
|
+
props.minDate,
|
|
902
|
+
props.maxDate,
|
|
903
|
+
locale.value,
|
|
904
|
+
props.dateFormat,
|
|
905
|
+
);
|
|
906
|
+
|
|
907
|
+
if (type === INPUT_RANGE_TYPE.start && !error && !isOutOfRange) {
|
|
908
|
+
localValue.value = {
|
|
909
|
+
from: value ? parsedValue : "",
|
|
910
|
+
to: localValue.value.to,
|
|
911
|
+
};
|
|
912
|
+
}
|
|
886
913
|
|
|
887
|
-
|
|
888
|
-
|
|
914
|
+
if (type === INPUT_RANGE_TYPE.end && !error && !isOutOfRange) {
|
|
915
|
+
localValue.value = {
|
|
916
|
+
from: localValue.value.from,
|
|
917
|
+
to: value ? parsedValue : "",
|
|
918
|
+
};
|
|
919
|
+
}
|
|
889
920
|
}
|
|
890
921
|
}
|
|
891
922
|
|
|
@@ -1009,26 +1040,25 @@ function onMouseoverCalendar() {
|
|
|
1009
1040
|
|
|
1010
1041
|
if (isRangeInputFocus || !rangeInputStartRef.value || !rangeInputEndRef.value) return;
|
|
1011
1042
|
|
|
1012
|
-
|
|
1043
|
+
const hasValues =
|
|
1044
|
+
calendarInnerValue.value.from && calendarInnerValue.value.to && !inputRangeToError.value;
|
|
1045
|
+
const hasOnlyFromValue =
|
|
1046
|
+
calendarInnerValue.value.from && !calendarInnerValue.value.to && !inputRangeFromError.value;
|
|
1047
|
+
|
|
1048
|
+
if (hasValues || !rangeStart.value) {
|
|
1013
1049
|
rangeInputStartRef.value.input.focus();
|
|
1014
1050
|
|
|
1015
1051
|
return;
|
|
1016
1052
|
}
|
|
1017
1053
|
|
|
1018
|
-
if (
|
|
1054
|
+
if (hasOnlyFromValue) {
|
|
1019
1055
|
rangeInputEndRef.value.input.focus();
|
|
1020
1056
|
|
|
1021
1057
|
return;
|
|
1022
1058
|
}
|
|
1023
1059
|
}
|
|
1024
1060
|
|
|
1025
|
-
function
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
if (isRangeInputFocus) {
|
|
1029
|
-
isHoverEvent.value = true;
|
|
1030
|
-
|
|
1031
|
-
document.activeElement.blur();
|
|
1032
|
-
}
|
|
1061
|
+
function onInputCalendar(value) {
|
|
1062
|
+
calendarInnerValue.value = value;
|
|
1033
1063
|
}
|
|
1034
1064
|
</script>
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { getDaysInMonth } from "../../ui.form-calendar/services/date.service";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const datePattern = /^\d{1,2}\.\d{1,2}\.\d{4}$/;
|
|
4
4
|
|
|
5
|
-
export function
|
|
6
|
-
return
|
|
5
|
+
export function isWrongDateFormat(value) {
|
|
6
|
+
return !datePattern.test(value);
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function
|
|
9
|
+
export function isWrongMonthNumber(value) {
|
|
10
10
|
const splitDate = value.split(".");
|
|
11
11
|
const month = splitDate[1];
|
|
12
12
|
|
|
13
|
-
return Number(month) >= 1 && Number(month) <= 12;
|
|
13
|
+
return !(Number(month) >= 1 && Number(month) <= 12);
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function
|
|
16
|
+
export function isWrongDayNumber(value) {
|
|
17
17
|
const [day, month, year] = value.split(".");
|
|
18
18
|
|
|
19
19
|
const daysInMonth = getDaysInMonth(new Date(year, month - 1));
|
|
20
20
|
|
|
21
|
-
return Number(day) >= 1 && Number(day) <= Number(daysInMonth);
|
|
21
|
+
return !(Number(day) >= 1 && Number(day) <= Number(daysInMonth));
|
|
22
22
|
}
|