nexheal-lib 0.0.59 → 0.0.61

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.
@@ -562,11 +562,28 @@ class CalendarControl {
562
562
  this.writeValueRange(value);
563
563
  return;
564
564
  }
565
- // Week mode: value is a "start - end" range string
565
+ // Week mode: value is a "start - end" range string, a single date, or ISO string
566
566
  if (this.selectionMode === "week") {
567
567
  const raw = String(value);
568
- const firstPart = raw.split(" - ")[0].trim();
569
- const parsed = this.parseDate(firstPart) || this.parseDate(raw);
568
+ const parts = raw.split(" - ");
569
+ // If we got a proper "start - end" range string, use both dates directly
570
+ // instead of recalculating via getWeekRange (which always does Sun–Sat)
571
+ if (parts.length === 2) {
572
+ const s = this.parseDate(parts[0].trim());
573
+ const e = this.parseDate(parts[1].trim());
574
+ if (s && e) {
575
+ this.selectedWeekStart = s;
576
+ this.selectedWeekEnd = e;
577
+ this.selectedDate = s;
578
+ this.displayMonth = s.getMonth();
579
+ this.displayYear = s.getFullYear();
580
+ this.inputControl.setValue(this.formatWeek(s, e), { emitEvent: false });
581
+ return;
582
+ }
583
+ }
584
+ // Single date: trust it as the week start (the parent already computed
585
+ // the correct start day), and add 6 days for the end.
586
+ const parsed = this.parseDate(parts[0]?.trim()) || this.parseDate(raw);
570
587
  if (!parsed) {
571
588
  this.selectedWeekStart = null;
572
589
  this.selectedWeekEnd = null;
@@ -574,7 +591,10 @@ class CalendarControl {
574
591
  this.inputControl.setValue("", { emitEvent: false });
575
592
  return;
576
593
  }
577
- const { start, end } = this.getWeekRange(parsed);
594
+ const start = new Date(parsed.getFullYear(), parsed.getMonth(), parsed.getDate());
595
+ const end = new Date(start);
596
+ end.setDate(start.getDate() + 6);
597
+ end.setHours(23, 59, 59, 999);
578
598
  this.selectedWeekStart = start;
579
599
  this.selectedWeekEnd = end;
580
600
  this.selectedDate = start;
@@ -739,14 +759,35 @@ class CalendarControl {
739
759
  this.blurEvent.emit();
740
760
  return;
741
761
  }
742
- // typed a different value -> recompute the week from the first date, else revert
743
- const parsed = this.parseDate(rawWeek.split(" - ")[0].trim());
744
- if (!parsed) {
745
- this.inputControl.setValue(current, { emitEvent: false });
746
- this.blurEvent.emit();
747
- return;
762
+ // typed a different value -> try to use both dates from range, else recompute
763
+ const blurParts = rawWeek.split(" - ");
764
+ let start;
765
+ let end;
766
+ if (blurParts.length === 2) {
767
+ const s = this.parseDate(blurParts[0].trim());
768
+ const e = this.parseDate(blurParts[1].trim());
769
+ if (s && e) {
770
+ start = s;
771
+ end = e;
772
+ }
773
+ else if (s) {
774
+ ({ start, end } = this.getWeekRange(s));
775
+ }
776
+ else {
777
+ this.inputControl.setValue(current, { emitEvent: false });
778
+ this.blurEvent.emit();
779
+ return;
780
+ }
781
+ }
782
+ else {
783
+ const parsed = this.parseDate(rawWeek);
784
+ if (!parsed) {
785
+ this.inputControl.setValue(current, { emitEvent: false });
786
+ this.blurEvent.emit();
787
+ return;
788
+ }
789
+ ({ start, end } = this.getWeekRange(parsed));
748
790
  }
749
- const { start, end } = this.getWeekRange(parsed);
750
791
  this.selectedWeekStart = start;
751
792
  this.selectedWeekEnd = end;
752
793
  this.selectedDate = start;
@@ -1143,6 +1184,17 @@ class CalendarControl {
1143
1184
  }
1144
1185
  /** writeValue delegate for range mode. */
1145
1186
  writeValueRange(value) {
1187
+ // Handle { start: Date, end: Date } objects directly (e.g. from parent patchValue)
1188
+ if (typeof value === 'object' && value !== null && value.start instanceof Date && value.end instanceof Date) {
1189
+ this.rangeStart = value.start;
1190
+ this.rangeEnd = value.end;
1191
+ this.selectedDate = value.start;
1192
+ this.rangePicking = 'start';
1193
+ this.displayMonth = value.start.getMonth();
1194
+ this.displayYear = value.start.getFullYear();
1195
+ this.inputControl.setValue(this.formatRange(value.start, value.end), { emitEvent: false });
1196
+ return;
1197
+ }
1146
1198
  const raw = String(value);
1147
1199
  const parts = raw.split(" - ");
1148
1200
  if (parts.length === 2) {
@@ -2606,6 +2658,8 @@ class MultiselectControl {
2606
2658
  });
2607
2659
  // Initialize filteredOptions to match all options
2608
2660
  this.filteredOptions = [...this.options];
2661
+ // Sync the input display in case selectedItems was set before init
2662
+ this._updateSelectedItemList();
2609
2663
  }
2610
2664
  ngAfterViewChecked() {
2611
2665
  if (this.isDropdownOpen && !this.dropdownInitialized) {
@@ -2649,7 +2703,10 @@ class MultiselectControl {
2649
2703
  if (value.length > 0 &&
2650
2704
  typeof value[0] === "object" &&
2651
2705
  value[0][this.optionValueProperty] != null) {
2652
- // Convert to an array of IDs, then treat exactly like CASE A
2706
+ // Immediately use the value objects for display (they have displayname)
2707
+ this.selectedItems = [...value];
2708
+ this._updateSelectedItemList();
2709
+ // Also set up pending mapping to sync with option references when available
2653
2710
  const idArray = value.map((obj) => obj[this.optionValueProperty]);
2654
2711
  this._isPrimitivePatch = true;
2655
2712
  this._pendingPrimitiveValues = idArray;