its_ui_vite 1.0.17 → 1.0.18
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/CDatepicker.vue +46 -25
- package/src/pages/index.vue +1 -1
package/package.json
CHANGED
|
@@ -36,10 +36,10 @@
|
|
|
36
36
|
|
|
37
37
|
<div
|
|
38
38
|
ref="time"
|
|
39
|
-
:class="['c-
|
|
39
|
+
:class="['c-datepicker__time_wrap', { open: isOpenTime }]"
|
|
40
40
|
>
|
|
41
41
|
<div
|
|
42
|
-
class="c-
|
|
42
|
+
class="c-datepicker__time_inps"
|
|
43
43
|
@click="isOpenTime = true"
|
|
44
44
|
>
|
|
45
45
|
<input
|
|
@@ -57,26 +57,27 @@
|
|
|
57
57
|
v-model="modelMinute"
|
|
58
58
|
@input="setTime('minute', ($event.target as HTMLInputElement).value)"
|
|
59
59
|
@focus="isOpenTime = true"
|
|
60
|
-
@blur="
|
|
60
|
+
@blur="setIsOpenTime(false)"
|
|
61
61
|
/>
|
|
62
62
|
</div>
|
|
63
63
|
<Teleport :to="teleportTo">
|
|
64
64
|
<div
|
|
65
|
-
class="c-
|
|
65
|
+
class="c-datepicker__time_list-wrap"
|
|
66
66
|
ref="timeContent"
|
|
67
67
|
:data-c-datepicker-id="datePickerId"
|
|
68
68
|
:style="timeStyle"
|
|
69
69
|
>
|
|
70
70
|
<div
|
|
71
71
|
:style="`--transition: ${transition}ms; --picker-time-indent-y: ${pickerContentIndentY}px`"
|
|
72
|
-
:class="['c-
|
|
72
|
+
:class="['c-datepicker__time_list', pickerContentPosition, {open: isOpenTime}]"
|
|
73
73
|
>
|
|
74
|
-
<div class="c-
|
|
75
|
-
<CScroll class="c-
|
|
74
|
+
<div class="c-datepicker__time_list-content">
|
|
75
|
+
<CScroll class="c-datepicker__time_list-scroll">
|
|
76
76
|
<button
|
|
77
77
|
v-for="item in hoursOptions"
|
|
78
78
|
:key="item.value"
|
|
79
|
-
:
|
|
79
|
+
:data-time-value="item.text"
|
|
80
|
+
:class="['c-datepicker__time_btn', {
|
|
80
81
|
disable: isDisableTime('hour', item.value),
|
|
81
82
|
active: item.text === modelHour
|
|
82
83
|
}]"
|
|
@@ -86,12 +87,13 @@
|
|
|
86
87
|
{{ item.text }}
|
|
87
88
|
</button>
|
|
88
89
|
</CScroll>
|
|
89
|
-
<div class="c-
|
|
90
|
-
<CScroll class="c-
|
|
90
|
+
<div class="c-datepicker__time_list-line"></div>
|
|
91
|
+
<CScroll class="c-datepicker__time_list-scroll">
|
|
91
92
|
<button
|
|
92
93
|
v-for="item in minuteOptions"
|
|
93
94
|
:key="item.value"
|
|
94
|
-
:
|
|
95
|
+
:data-time-value="item.text"
|
|
96
|
+
:class="['c-datepicker__time_btn', {
|
|
95
97
|
disable: isDisableTime('minute', item.value),
|
|
96
98
|
active: item.text === modelMinute
|
|
97
99
|
}]"
|
|
@@ -494,7 +496,7 @@ function isCurrent(target: HTMLElement | null) {
|
|
|
494
496
|
|
|
495
497
|
function handleClickTime(evt: MouseEvent) {
|
|
496
498
|
const target = (evt.target as HTMLElement);
|
|
497
|
-
const classesStr = '.c-
|
|
499
|
+
const classesStr = '.c-datepicker__time_wrap, .c-datepicker__time_list-wrap';
|
|
498
500
|
const isTimeContent = target.closest(classesStr);
|
|
499
501
|
|
|
500
502
|
const isTarget = isTimeContent === time.value;
|
|
@@ -502,7 +504,8 @@ function handleClickTime(evt: MouseEvent) {
|
|
|
502
504
|
|
|
503
505
|
if (isTarget || isContent) return;
|
|
504
506
|
|
|
505
|
-
isOpenTime.value = false;
|
|
507
|
+
// isOpenTime.value = false;
|
|
508
|
+
setIsOpenTime(false);
|
|
506
509
|
}
|
|
507
510
|
|
|
508
511
|
function handleTime(positionInfo?: any) {
|
|
@@ -513,7 +516,8 @@ function handleTime(positionInfo?: any) {
|
|
|
513
516
|
|
|
514
517
|
if (positionInfo.isVisible) return;
|
|
515
518
|
|
|
516
|
-
isOpenTime.value = false;
|
|
519
|
+
// isOpenTime.value = false;
|
|
520
|
+
setIsOpenTime(false);
|
|
517
521
|
}
|
|
518
522
|
|
|
519
523
|
function setTeleportTo() {
|
|
@@ -574,7 +578,7 @@ function isDisableDay(ISO: string): boolean {
|
|
|
574
578
|
const isMoreMax = maxDate.ts < currentDate.ts;
|
|
575
579
|
const isLessMin = minDate.ts > currentDate.ts;
|
|
576
580
|
|
|
577
|
-
const isMaxDay = maxDate.day === currentDate.day
|
|
581
|
+
const isMaxDay = maxDate.day === currentDate.day && maxDate.month === currentDate.month && maxDate.year === currentDate.year;
|
|
578
582
|
const isMinDay = minDate.day === currentDate.day && minDate.month === currentDate.month && minDate.year === currentDate.year;
|
|
579
583
|
|
|
580
584
|
if (isMaxDay || isMinDay) return false;
|
|
@@ -582,15 +586,17 @@ function isDisableDay(ISO: string): boolean {
|
|
|
582
586
|
}
|
|
583
587
|
|
|
584
588
|
function setTime(name: 'hour' | 'minute', value: string) {
|
|
585
|
-
const numValue = value.replace(/[^0-9]/g, '');
|
|
589
|
+
const numValue = getTimeStr(value.replace(/[^0-9]/g, ''));
|
|
586
590
|
|
|
587
591
|
const format = name === 'hour' ? 'HH' : 'mm';
|
|
588
592
|
|
|
589
593
|
const maxDate = DateTime.fromISO(props?.max);
|
|
590
594
|
const minDate = DateTime.fromISO(props?.min);
|
|
591
595
|
|
|
592
|
-
|
|
593
|
-
const
|
|
596
|
+
// max Day
|
|
597
|
+
const isMismatchMaxDay = maxDate.isValid && (maxDate.day === activeDate.value.day && maxDate.month === activeDate.value.month && maxDate.year === activeDate.value.year);
|
|
598
|
+
// min Day
|
|
599
|
+
const isMismatchMinDay = minDate.isValid && (minDate.day === activeDate.value.day && minDate.month === activeDate.value.month && minDate.year === activeDate.value.year);
|
|
594
600
|
|
|
595
601
|
const max = isMismatchMaxDay ? +maxDate?.toFormat(format) : (name === 'hour' ? 23 : 59);
|
|
596
602
|
const min = isMismatchMinDay ? +minDate?.toFormat(format) : 0;
|
|
@@ -608,7 +614,7 @@ function setTime(name: 'hour' | 'minute', value: string) {
|
|
|
608
614
|
dispatchEmit()
|
|
609
615
|
}
|
|
610
616
|
|
|
611
|
-
function getTimeStr(value: number) {
|
|
617
|
+
function getTimeStr(value: number | string) {
|
|
612
618
|
return `0${value}`.match(/.{2}$/)?.[0] || '00'
|
|
613
619
|
}
|
|
614
620
|
|
|
@@ -616,8 +622,11 @@ function isDisableTime(name: 'hour' | 'minute', value: number) {
|
|
|
616
622
|
const maxDate = DateTime.fromISO(props?.max);
|
|
617
623
|
const minDate = DateTime.fromISO(props?.min);
|
|
618
624
|
|
|
619
|
-
|
|
620
|
-
|
|
625
|
+
|
|
626
|
+
// max Day
|
|
627
|
+
const isMismatchMaxDay = maxDate.day !== activeDate.value.day || maxDate.month !== activeDate.value.month || maxDate.year !== activeDate.value.year;
|
|
628
|
+
// min Day
|
|
629
|
+
const isMismatchMinDay = minDate.day !== activeDate.value.day || minDate.month !== activeDate.value.month || minDate.year !== activeDate.value.year;
|
|
621
630
|
const isDisabled = maxDate.ts < activeDate.value.ts && minDate.ts > activeDate.value.ts;
|
|
622
631
|
|
|
623
632
|
if (isMismatchMinDay && isMismatchMaxDay) return isDisabled;
|
|
@@ -630,6 +639,17 @@ function isDisableTime(name: 'hour' | 'minute', value: number) {
|
|
|
630
639
|
return (!isMismatchMaxDay && max < value) || (!isMismatchMinDay && min > value);
|
|
631
640
|
}
|
|
632
641
|
|
|
642
|
+
function setIsOpenTime(value: boolean) {
|
|
643
|
+
if (value) {
|
|
644
|
+
isOpenTime.value = value;
|
|
645
|
+
} else {
|
|
646
|
+
// здесь setTimeout чтобы из-за blur на input name="minute" попап не закрывался раньше вреиени и клик роходил по попапу
|
|
647
|
+
setTimeout(() => {
|
|
648
|
+
isOpenTime.value = value;
|
|
649
|
+
}, 100);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
|
|
633
653
|
function setIsOpen(value: boolean) {
|
|
634
654
|
isOpenPicker.value = value;
|
|
635
655
|
setOldDate(value);
|
|
@@ -776,7 +796,7 @@ $timeWidth: 54px;
|
|
|
776
796
|
}
|
|
777
797
|
}
|
|
778
798
|
|
|
779
|
-
&
|
|
799
|
+
&__time {
|
|
780
800
|
|
|
781
801
|
&_inps {
|
|
782
802
|
display: flex;
|
|
@@ -833,17 +853,18 @@ $timeWidth: 54px;
|
|
|
833
853
|
}
|
|
834
854
|
}
|
|
835
855
|
|
|
836
|
-
.c-
|
|
856
|
+
.c-datepicker__time_list-wrap {
|
|
837
857
|
--max-height: 112px;
|
|
838
858
|
--scroll-height: 100px;
|
|
839
859
|
|
|
840
860
|
position: fixed;
|
|
841
861
|
z-index: 999;
|
|
842
862
|
transition: var(--transition);
|
|
863
|
+
// transform: translate(0, 50px);
|
|
843
864
|
pointer-events: none;
|
|
844
865
|
|
|
845
866
|
.c-datepicker {
|
|
846
|
-
&
|
|
867
|
+
&__time {
|
|
847
868
|
&_list-content {
|
|
848
869
|
box-sizing: border-box;
|
|
849
870
|
|
|
@@ -870,7 +891,7 @@ $timeWidth: 54px;
|
|
|
870
891
|
background: var(--black-dark);
|
|
871
892
|
box-shadow: var(--shadow);
|
|
872
893
|
|
|
873
|
-
transition: var(--transition);
|
|
894
|
+
transition: all var(--transition) ease 0s;
|
|
874
895
|
|
|
875
896
|
opacity: 0;
|
|
876
897
|
pointer-events: none;
|
package/src/pages/index.vue
CHANGED