@spartan-ng/brain 1.10.1 → 1.11.0-beta.2
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/spartan-ng-brain-calendar.mjs +32 -6
- package/fesm2022/spartan-ng-brain-calendar.mjs.map +1 -1
- package/fesm2022/spartan-ng-brain-overlay.mjs +11 -3
- package/fesm2022/spartan-ng-brain-overlay.mjs.map +1 -1
- package/fesm2022/spartan-ng-brain-popover.mjs +1 -0
- package/fesm2022/spartan-ng-brain-popover.mjs.map +1 -1
- package/package.json +1 -1
- package/types/spartan-ng-brain-calendar.d.ts +8 -0
- package/types/spartan-ng-brain-overlay.d.ts +11 -1
|
@@ -582,6 +582,8 @@ class BrnCalendarMonthSelect {
|
|
|
582
582
|
_dateAdapter = injectDateAdapter();
|
|
583
583
|
/** Access the calendar i18n */
|
|
584
584
|
_i18n = injectBrnCalendarI18n();
|
|
585
|
+
/** Whether the select value is being synced from the calendar rather than picked by the user */
|
|
586
|
+
_syncing = false;
|
|
585
587
|
_selectedMonth = computed(() => {
|
|
586
588
|
return this._i18n.config().months()[this._dateAdapter.getMonth(this._calendar.focusedDate())];
|
|
587
589
|
}, ...(ngDevMode ? [{ debugName: "_selectedMonth" }] : /* istanbul ignore next */ []));
|
|
@@ -592,12 +594,13 @@ class BrnCalendarMonthSelect {
|
|
|
592
594
|
outputToObservable(this._select.value)
|
|
593
595
|
.pipe(takeUntilDestroyed())
|
|
594
596
|
.subscribe((value) => {
|
|
595
|
-
|
|
597
|
+
// writeValue emits on the same output; only a real user selection should move focus.
|
|
598
|
+
if (!this._syncing && typeof value === 'string') {
|
|
596
599
|
this.monthSelected(value);
|
|
597
600
|
}
|
|
598
601
|
});
|
|
599
602
|
effect(() => {
|
|
600
|
-
this.
|
|
603
|
+
this._syncSelect(this._selectedMonth());
|
|
601
604
|
});
|
|
602
605
|
}
|
|
603
606
|
/** Focus selected month */
|
|
@@ -618,7 +621,17 @@ class BrnCalendarMonthSelect {
|
|
|
618
621
|
this._calendar.setFocusedDate(target);
|
|
619
622
|
// The select already shows the picked month. When the focused month did not change
|
|
620
623
|
// (target rejected or constrained back into it), the effect does not run again.
|
|
621
|
-
this.
|
|
624
|
+
this._syncSelect(this._selectedMonth());
|
|
625
|
+
}
|
|
626
|
+
/** Write the calendar's value into the select without treating it as a user selection */
|
|
627
|
+
_syncSelect(value) {
|
|
628
|
+
this._syncing = true;
|
|
629
|
+
try {
|
|
630
|
+
this._select.writeValue(value);
|
|
631
|
+
}
|
|
632
|
+
finally {
|
|
633
|
+
this._syncing = false;
|
|
634
|
+
}
|
|
622
635
|
}
|
|
623
636
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarMonthSelect, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
624
637
|
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarMonthSelect, isStandalone: true, selector: "brnSelect[brnCalendarMonthSelect],hlm-select[brnCalendarMonthSelect]", exportAs: ["brnCalendarMonthSelect"], ngImport: i0 });
|
|
@@ -905,6 +918,8 @@ class BrnCalendarYearSelect {
|
|
|
905
918
|
_dateAdapter = injectDateAdapter();
|
|
906
919
|
/** Access the calendar i18n */
|
|
907
920
|
_i18n = injectBrnCalendarI18n();
|
|
921
|
+
/** Whether the select value is being synced from the calendar rather than picked by the user */
|
|
922
|
+
_syncing = false;
|
|
908
923
|
constructor() {
|
|
909
924
|
// React to user selection through the injected select's typed `value` output rather than a
|
|
910
925
|
// host-listener `$event` (which Angular types as `Event`). The year select's values are
|
|
@@ -912,12 +927,13 @@ class BrnCalendarYearSelect {
|
|
|
912
927
|
outputToObservable(this._select.value)
|
|
913
928
|
.pipe(takeUntilDestroyed())
|
|
914
929
|
.subscribe((value) => {
|
|
915
|
-
|
|
930
|
+
// writeValue emits on the same output; only a real user selection should move focus.
|
|
931
|
+
if (!this._syncing && typeof value === 'number') {
|
|
916
932
|
this.yearSelected(value);
|
|
917
933
|
}
|
|
918
934
|
});
|
|
919
935
|
effect(() => {
|
|
920
|
-
this.
|
|
936
|
+
this._syncSelect(this._dateAdapter.getYear(this._calendar.focusedDate()));
|
|
921
937
|
});
|
|
922
938
|
}
|
|
923
939
|
/** Focus selected year */
|
|
@@ -933,7 +949,17 @@ class BrnCalendarYearSelect {
|
|
|
933
949
|
const target = this._calendar.constrainDate(this._dateAdapter.set(targetDate, { day }));
|
|
934
950
|
this._calendar.setFocusedDate(target);
|
|
935
951
|
// Keep the select on the year actually shown when the target was rejected.
|
|
936
|
-
this.
|
|
952
|
+
this._syncSelect(this._dateAdapter.getYear(this._calendar.focusedDate()));
|
|
953
|
+
}
|
|
954
|
+
/** Write the calendar's value into the select without treating it as a user selection */
|
|
955
|
+
_syncSelect(value) {
|
|
956
|
+
this._syncing = true;
|
|
957
|
+
try {
|
|
958
|
+
this._select.writeValue(value);
|
|
959
|
+
}
|
|
960
|
+
finally {
|
|
961
|
+
this._syncing = false;
|
|
962
|
+
}
|
|
937
963
|
}
|
|
938
964
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarYearSelect, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
939
965
|
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarYearSelect, isStandalone: true, selector: "brnSelect[brnCalendarYearSelect],hlm-select[brnCalendarYearSelect]", exportAs: ["brnCalendarYearSelect"], ngImport: i0 });
|