nexheal-lib 0.0.38 → 0.0.40
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/fesm2022/nexheal-lib.mjs
CHANGED
|
@@ -695,6 +695,50 @@ class CalendarControl {
|
|
|
695
695
|
// events
|
|
696
696
|
onBlur() {
|
|
697
697
|
this.onTouchedFn();
|
|
698
|
+
// Week mode keeps a "start - end" range string; the single-date parsing
|
|
699
|
+
// below would fail to parse it and wipe the selection, so handle it here.
|
|
700
|
+
if (this.selectionMode === "week") {
|
|
701
|
+
const rawWeek = (this.inputControl.value || "").trim();
|
|
702
|
+
const current = this.selectedWeekStart && this.selectedWeekEnd
|
|
703
|
+
? this.formatWeek(this.selectedWeekStart, this.selectedWeekEnd)
|
|
704
|
+
: "";
|
|
705
|
+
// unchanged (e.g. clicked outside) -> keep the selection
|
|
706
|
+
if (rawWeek === current) {
|
|
707
|
+
this.blurEvent.emit();
|
|
708
|
+
return;
|
|
709
|
+
}
|
|
710
|
+
// cleared by the user
|
|
711
|
+
if (!rawWeek) {
|
|
712
|
+
this.selectedWeekStart = null;
|
|
713
|
+
this.selectedWeekEnd = null;
|
|
714
|
+
this.selectedDate = null;
|
|
715
|
+
this.onChangeFn(null);
|
|
716
|
+
this.weekSelected.emit(null);
|
|
717
|
+
this.dateSelected.emit(null);
|
|
718
|
+
this.blurEvent.emit();
|
|
719
|
+
return;
|
|
720
|
+
}
|
|
721
|
+
// typed a different value -> recompute the week from the first date, else revert
|
|
722
|
+
const parsed = this.parseDate(rawWeek.split(" - ")[0].trim());
|
|
723
|
+
if (!parsed) {
|
|
724
|
+
this.inputControl.setValue(current, { emitEvent: false });
|
|
725
|
+
this.blurEvent.emit();
|
|
726
|
+
return;
|
|
727
|
+
}
|
|
728
|
+
const { start, end } = this.getWeekRange(parsed);
|
|
729
|
+
this.selectedWeekStart = start;
|
|
730
|
+
this.selectedWeekEnd = end;
|
|
731
|
+
this.selectedDate = start;
|
|
732
|
+
this.displayMonth = start.getMonth();
|
|
733
|
+
this.displayYear = start.getFullYear();
|
|
734
|
+
const out = this.formatWeek(start, end);
|
|
735
|
+
this.inputControl.setValue(out, { emitEvent: false });
|
|
736
|
+
this.onChangeFn(out);
|
|
737
|
+
this.weekSelected.emit({ start, end });
|
|
738
|
+
this.dateSelected.emit(start);
|
|
739
|
+
this.blurEvent.emit();
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
698
742
|
const raw = (this.inputControl.value || "");
|
|
699
743
|
let currentFormatted = "";
|
|
700
744
|
if (this.selectedDate) {
|