@spartan-ng/brain 1.3.4 → 1.4.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/README.md CHANGED
@@ -69,7 +69,7 @@ import { BrnSelectImports } from '@spartan-ng/brain/select';
69
69
 
70
70
  Available entry points:
71
71
 
72
- `accordion`, `alert-dialog`, `autocomplete`, `avatar`, `button`, `calendar`, `checkbox`, `collapsible`, `combobox`, `command`, `core`, `date-time`, `date-time-luxon`, `dialog`, `field`, `forms`, `hover-card`, `input`, `input-otp`, `label`, `navigation-menu`, `popover`, `progress`, `radio-group`, `resizable`, `select`, `separator`, `sheet`, `slider`, `sonner`, `switch`, `tabs`, `textarea`, `toggle`, `toggle-group`, `tooltip`.
72
+ `accordion`, `alert-dialog`, `autocomplete`, `avatar`, `button`, `calendar`, `checkbox`, `collapsible`, `combobox`, `command`, `core`, `date-time`, `date-time-luxon`, `dialog`, `field`, `forms`, `hover-card`, `input`, `input-otp`, `label`, `navigation-menu`, `popover`, `progress`, `questionnaire`, `radio-group`, `resizable`, `select`, `separator`, `sheet`, `slider`, `sonner`, `switch`, `tabs`, `textarea`, `toggle`, `toggle-group`, `tooltip`.
73
73
 
74
74
  Browse the [components gallery](https://www.spartan.ng/components) for live demos, API docs, and styled helm examples for each primitive.
75
75
 
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, Directive, InjectionToken, inject, signal, Injectable, ChangeDetectorRef, Injector, booleanAttribute, model, numberAttribute, computed, contentChild, linkedSignal, afterNextRender, DestroyRef, ElementRef, effect, ViewContainerRef, TemplateRef, untracked } from '@angular/core';
2
+ import { input, Directive, InjectionToken, inject, signal, Injectable, ChangeDetectorRef, Injector, booleanAttribute, model, numberAttribute, computed, contentChild, linkedSignal, output, afterNextRender, DestroyRef, ElementRef, effect, ViewContainerRef, TemplateRef, untracked } from '@angular/core';
3
3
  import { injectDateAdapter } from '@spartan-ng/brain/date-time';
4
4
  import { outputToObservable, takeUntilDestroyed } from '@angular/core/rxjs-interop';
5
5
  import { BrnSelect } from '@spartan-ng/brain/select';
@@ -54,7 +54,12 @@ const defaultCalendarI18n = {
54
54
  return weekdays[index];
55
55
  },
56
56
  months: () => ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
57
- years: (startYear = 1925, endYear = new Date().getFullYear() + 1) => Array.from({ length: endYear - startYear + 1 }, (_, i) => startYear + i),
57
+ years: (startYear, endYear) => {
58
+ const currentYear = new Date().getFullYear();
59
+ const firstYear = startYear ?? currentYear - 100;
60
+ const lastYear = endYear ?? currentYear + 10;
61
+ return Array.from({ length: lastYear - firstYear + 1 }, (_, i) => firstYear + i);
62
+ },
58
63
  formatHeader: (month, year) => {
59
64
  return new Date(year, month).toLocaleDateString(undefined, {
60
65
  month: 'long',
@@ -141,6 +146,12 @@ class BrnCalendar {
141
146
  * The focused date.
142
147
  */
143
148
  focusedDate = linkedSignal(() => this.constrainDate(this.defaultFocusedDate() ?? this.date() ?? this._dateAdapter.now()), ...(ngDevMode ? [{ debugName: "focusedDate" }] : /* istanbul ignore next */ []));
149
+ /** Emits whenever the focused date changes. */
150
+ focusedDateChange = output();
151
+ _setFocusedDate(date) {
152
+ this.focusedDate.set(date);
153
+ this.focusedDateChange.emit(date);
154
+ }
144
155
  /**
145
156
  * Get all the days to display, this is the days of the current month
146
157
  * and the days of the previous and next month to fill the grid.
@@ -220,7 +231,7 @@ class BrnCalendar {
220
231
  else {
221
232
  this.date.set(date);
222
233
  }
223
- this.focusedDate.set(date);
234
+ this._setFocusedDate(date);
224
235
  }
225
236
  /** @internal Set the focused date */
226
237
  setFocusedDate(date) {
@@ -228,7 +239,7 @@ class BrnCalendar {
228
239
  if (this.isDateDisabled(date)) {
229
240
  return;
230
241
  }
231
- this.focusedDate.set(date);
242
+ this._setFocusedDate(date);
232
243
  // wait until the cells have all updated
233
244
  afterNextRender({
234
245
  write: () => {
@@ -280,7 +291,7 @@ class BrnCalendar {
280
291
  this._cells.push(cell);
281
292
  }
282
293
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendar, deps: [], target: i0.ɵɵFactoryTarget.Directive });
283
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendar, isStandalone: true, selector: "[brnCalendar]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange" }, providers: [provideBrnCalendar(BrnCalendar)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
294
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendar, isStandalone: true, selector: "[brnCalendar]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange", focusedDateChange: "focusedDateChange" }, providers: [provideBrnCalendar(BrnCalendar)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
284
295
  }
285
296
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendar, decorators: [{
286
297
  type: Directive,
@@ -288,7 +299,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
288
299
  selector: '[brnCalendar]',
289
300
  providers: [provideBrnCalendar(BrnCalendar)],
290
301
  }]
291
- }], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }] } });
302
+ }], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }], focusedDateChange: [{ type: i0.Output, args: ["focusedDateChange"] }] } });
292
303
 
293
304
  class BrnCalendarCell {
294
305
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarCell, deps: [], target: i0.ɵɵFactoryTarget.Directive });
@@ -520,7 +531,7 @@ class BrnCalendarMonthSelect {
520
531
  .months()
521
532
  .findIndex((month) => month === selectedMonth);
522
533
  const targetDate = this._dateAdapter.set(this._calendar.focusedDate(), { month });
523
- this._calendar.focusedDate.set(targetDate);
534
+ this._calendar.setFocusedDate(targetDate);
524
535
  }
525
536
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarMonthSelect, deps: [], target: i0.ɵɵFactoryTarget.Directive });
526
537
  /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarMonthSelect, isStandalone: true, selector: "brnSelect[brnCalendarMonthSelect],hlm-select[brnCalendarMonthSelect]", ngImport: i0 });
@@ -539,8 +550,27 @@ class BrnCalendarNextButton {
539
550
  _dateAdapter = injectDateAdapter();
540
551
  /** Access the calendar i18n */
541
552
  _i18n = injectBrnCalendarI18n();
553
+ /** Whether navigating to the next month is disabled. */
554
+ _disabled = computed(() => {
555
+ const { targetDate, possibleDate } = this.nextMonthTarget();
556
+ const effective = this._dateAdapter.isSameMonth(possibleDate, targetDate) ? possibleDate : targetDate;
557
+ return this._calendar.isDateDisabled(effective);
558
+ }, ...(ngDevMode ? [{ debugName: "_disabled" }] : /* istanbul ignore next */ []));
542
559
  /** Focus the next month */
543
560
  focusNextMonth() {
561
+ if (this._disabled()) {
562
+ return;
563
+ }
564
+ const { targetDate, possibleDate } = this.nextMonthTarget();
565
+ if (this._dateAdapter.isSameMonth(possibleDate, targetDate)) {
566
+ // if this date is within the same month, then focus it
567
+ this._calendar.setFocusedDate(possibleDate);
568
+ return;
569
+ }
570
+ this._calendar.setFocusedDate(targetDate);
571
+ }
572
+ /** @internal The target date in the next month and its constrained counterpart. */
573
+ nextMonthTarget() {
544
574
  const focusedDate = this._calendar.focusedDate();
545
575
  const date = this._dateAdapter.getDate(focusedDate);
546
576
  // go to start of month first, then add 1 month to avoid day overflow
@@ -556,25 +586,21 @@ class BrnCalendarNextButton {
556
586
  targetDate = this._dateAdapter.set(nextMonthTarget, { day: date });
557
587
  }
558
588
  // if the date is disabled, but there are available dates in the month, focus the constrained date.
559
- const possibleDate = this._calendar.constrainDate(targetDate);
560
- if (this._dateAdapter.isSameMonth(possibleDate, targetDate)) {
561
- // if this date is within the same month, then focus it
562
- this._calendar.focusedDate.set(possibleDate);
563
- return;
564
- }
565
- this._calendar.focusedDate.set(targetDate);
589
+ return { targetDate, possibleDate: this._calendar.constrainDate(targetDate) };
566
590
  }
567
591
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarNextButton, deps: [], target: i0.ɵɵFactoryTarget.Directive });
568
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarNextButton, isStandalone: true, selector: "[brnCalendarNextButton]", host: { attributes: { "type": "button", "data-slot": "calendar-next-button" }, listeners: { "click": "focusNextMonth()" }, properties: { "attr.aria-label": "_i18n.config().labelNext()" } }, ngImport: i0 });
592
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarNextButton, isStandalone: true, selector: "button[brnCalendarNextButton]", host: { attributes: { "type": "button", "data-slot": "calendar-next-button" }, listeners: { "click": "focusNextMonth()" }, properties: { "attr.aria-label": "_i18n.config().labelNext()", "attr.aria-disabled": "_disabled() ? true : null", "disabled": "_disabled()" } }, ngImport: i0 });
569
593
  }
570
594
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarNextButton, decorators: [{
571
595
  type: Directive,
572
596
  args: [{
573
- selector: '[brnCalendarNextButton]',
597
+ selector: 'button[brnCalendarNextButton]',
574
598
  host: {
575
599
  type: 'button',
576
600
  'data-slot': 'calendar-next-button',
577
601
  '[attr.aria-label]': '_i18n.config().labelNext()',
602
+ '[attr.aria-disabled]': '_disabled() ? true : null',
603
+ '[disabled]': '_disabled()',
578
604
  '(click)': 'focusNextMonth()',
579
605
  },
580
606
  }]
@@ -587,8 +613,27 @@ class BrnCalendarPreviousButton {
587
613
  _dateAdapter = injectDateAdapter();
588
614
  /** Access the calendar i18n */
589
615
  _i18n = injectBrnCalendarI18n();
616
+ /** Whether navigating to the previous month is disabled. */
617
+ _disabled = computed(() => {
618
+ const { targetDate, possibleDate } = this.previousMonthTarget();
619
+ const effective = this._dateAdapter.isSameMonth(possibleDate, targetDate) ? possibleDate : targetDate;
620
+ return this._calendar.isDateDisabled(effective);
621
+ }, ...(ngDevMode ? [{ debugName: "_disabled" }] : /* istanbul ignore next */ []));
590
622
  /** Focus the previous month */
591
623
  focusPreviousMonth() {
624
+ if (this._disabled()) {
625
+ return;
626
+ }
627
+ const { targetDate, possibleDate } = this.previousMonthTarget();
628
+ if (this._dateAdapter.isSameMonth(possibleDate, targetDate)) {
629
+ // if this date is within the same month, then focus it
630
+ this._calendar.setFocusedDate(possibleDate);
631
+ return;
632
+ }
633
+ this._calendar.setFocusedDate(targetDate);
634
+ }
635
+ /** @internal The target date in the previous month and its constrained counterpart. */
636
+ previousMonthTarget() {
592
637
  const focusedDate = this._calendar.focusedDate();
593
638
  const date = this._dateAdapter.getDate(focusedDate);
594
639
  // go to start of month first, then subtract 1 month to avoid day overflow
@@ -604,25 +649,21 @@ class BrnCalendarPreviousButton {
604
649
  targetDate = this._dateAdapter.set(previousMonthTarget, { day: date });
605
650
  }
606
651
  // if the date is disabled, but there are available dates in the month, focus the constrained date.
607
- const possibleDate = this._calendar.constrainDate(targetDate);
608
- if (this._dateAdapter.isSameMonth(possibleDate, targetDate)) {
609
- // if this date is within the same month, then focus it
610
- this._calendar.focusedDate.set(possibleDate);
611
- return;
612
- }
613
- this._calendar.focusedDate.set(targetDate);
652
+ return { targetDate, possibleDate: this._calendar.constrainDate(targetDate) };
614
653
  }
615
654
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarPreviousButton, deps: [], target: i0.ɵɵFactoryTarget.Directive });
616
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarPreviousButton, isStandalone: true, selector: "[brnCalendarPreviousButton]", host: { attributes: { "type": "button", "data-slot": "calendar-previous-button" }, listeners: { "click": "focusPreviousMonth()" }, properties: { "attr.aria-label": "_i18n.config().labelPrevious()" } }, ngImport: i0 });
655
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarPreviousButton, isStandalone: true, selector: "button[brnCalendarPreviousButton]", host: { attributes: { "type": "button", "data-slot": "calendar-previous-button" }, listeners: { "click": "focusPreviousMonth()" }, properties: { "attr.aria-label": "_i18n.config().labelPrevious()", "attr.aria-disabled": "_disabled() ? true : null", "disabled": "_disabled()" } }, ngImport: i0 });
617
656
  }
618
657
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarPreviousButton, decorators: [{
619
658
  type: Directive,
620
659
  args: [{
621
- selector: '[brnCalendarPreviousButton]',
660
+ selector: 'button[brnCalendarPreviousButton]',
622
661
  host: {
623
662
  type: 'button',
624
663
  'data-slot': 'calendar-previous-button',
625
664
  '[attr.aria-label]': '_i18n.config().labelPrevious()',
665
+ '[attr.aria-disabled]': '_disabled() ? true : null',
666
+ '[disabled]': '_disabled()',
626
667
  '(click)': 'focusPreviousMonth()',
627
668
  },
628
669
  }]
@@ -778,7 +819,7 @@ class BrnCalendarYearSelect {
778
819
  /** Focus selected year */
779
820
  yearSelected(year) {
780
821
  const targetDate = this._dateAdapter.set(this._calendar.focusedDate(), { year });
781
- this._calendar.focusedDate.set(targetDate);
822
+ this._calendar.setFocusedDate(targetDate);
782
823
  }
783
824
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarYearSelect, deps: [], target: i0.ɵɵFactoryTarget.Directive });
784
825
  /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarYearSelect, isStandalone: true, selector: "brnSelect[brnCalendarYearSelect],hlm-select[brnCalendarYearSelect]", ngImport: i0 });
@@ -853,6 +894,12 @@ class BrnCalendarMulti {
853
894
  * The focused date.
854
895
  */
855
896
  focusedDate = linkedSignal(() => this.constrainDate(this.defaultFocusedDate() ?? this._dateAdapter.now()), ...(ngDevMode ? [{ debugName: "focusedDate" }] : /* istanbul ignore next */ []));
897
+ /** Emits whenever the focused date changes. */
898
+ focusedDateChange = output();
899
+ _setFocusedDate(date) {
900
+ this.focusedDate.set(date);
901
+ this.focusedDateChange.emit(date);
902
+ }
856
903
  /**
857
904
  * Get all the days to display, this is the days of the current month
858
905
  * and the days of the previous and next month to fill the grid.
@@ -953,7 +1000,7 @@ class BrnCalendarMulti {
953
1000
  if (this.isDateDisabled(date)) {
954
1001
  return;
955
1002
  }
956
- this.focusedDate.set(date);
1003
+ this._setFocusedDate(date);
957
1004
  // wait until the cells have all updated
958
1005
  afterNextRender({
959
1006
  write: () => {
@@ -978,7 +1025,7 @@ class BrnCalendarMulti {
978
1025
  this._cells.push(cell);
979
1026
  }
980
1027
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarMulti, deps: [], target: i0.ɵɵFactoryTarget.Directive });
981
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendarMulti, isStandalone: true, selector: "[brnCalendarMulti]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, minSelection: { classPropertyName: "minSelection", publicName: "minSelection", isSignal: true, isRequired: false, transformFunction: null }, maxSelection: { classPropertyName: "maxSelection", publicName: "maxSelection", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange" }, providers: [provideBrnCalendar(BrnCalendarMulti)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
1028
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendarMulti, isStandalone: true, selector: "[brnCalendarMulti]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, minSelection: { classPropertyName: "minSelection", publicName: "minSelection", isSignal: true, isRequired: false, transformFunction: null }, maxSelection: { classPropertyName: "maxSelection", publicName: "maxSelection", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange", focusedDateChange: "focusedDateChange" }, providers: [provideBrnCalendar(BrnCalendarMulti)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
982
1029
  }
983
1030
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarMulti, decorators: [{
984
1031
  type: Directive,
@@ -986,7 +1033,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
986
1033
  selector: '[brnCalendarMulti]',
987
1034
  providers: [provideBrnCalendar(BrnCalendarMulti)],
988
1035
  }]
989
- }], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], minSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "minSelection", required: false }] }], maxSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSelection", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }] } });
1036
+ }], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], minSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "minSelection", required: false }] }], maxSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "maxSelection", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }], focusedDateChange: [{ type: i0.Output, args: ["focusedDateChange"] }] } });
990
1037
 
991
1038
  class BrnCalendarRange {
992
1039
  _cells = [];
@@ -1018,6 +1065,12 @@ class BrnCalendarRange {
1018
1065
  * The focused date.
1019
1066
  */
1020
1067
  focusedDate = linkedSignal(() => this.constrainDate(this.defaultFocusedDate() ?? this.startDate() ?? this._dateAdapter.now()), ...(ngDevMode ? [{ debugName: "focusedDate" }] : /* istanbul ignore next */ []));
1068
+ /** Emits whenever the focused date changes. */
1069
+ focusedDateChange = output();
1070
+ _setFocusedDate(date) {
1071
+ this.focusedDate.set(date);
1072
+ this.focusedDateChange.emit(date);
1073
+ }
1021
1074
  /**
1022
1075
  * The selected start date
1023
1076
  */
@@ -1135,7 +1188,7 @@ class BrnCalendarRange {
1135
1188
  if (this.isDateDisabled(date)) {
1136
1189
  return;
1137
1190
  }
1138
- this.focusedDate.set(date);
1191
+ this._setFocusedDate(date);
1139
1192
  // wait until the cells have all updated
1140
1193
  afterNextRender({
1141
1194
  write: () => {
@@ -1197,7 +1250,7 @@ class BrnCalendarRange {
1197
1250
  this._cells.push(cell);
1198
1251
  }
1199
1252
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarRange, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1200
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendarRange, isStandalone: true, selector: "[brnCalendarRange]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null }, startDate: { classPropertyName: "startDate", publicName: "startDate", isSignal: true, isRequired: false, transformFunction: null }, endDate: { classPropertyName: "endDate", publicName: "endDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { startDate: "startDateChange", endDate: "endDateChange" }, providers: [provideBrnCalendar(BrnCalendarRange)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
1253
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendarRange, isStandalone: true, selector: "[brnCalendarRange]", inputs: { highlightDays: { classPropertyName: "highlightDays", publicName: "highlightDays", isSignal: true, isRequired: false, transformFunction: null }, min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, dateDisabled: { classPropertyName: "dateDisabled", publicName: "dateDisabled", isSignal: true, isRequired: false, transformFunction: null }, weekStartsOn: { classPropertyName: "weekStartsOn", publicName: "weekStartsOn", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null }, startDate: { classPropertyName: "startDate", publicName: "startDate", isSignal: true, isRequired: false, transformFunction: null }, endDate: { classPropertyName: "endDate", publicName: "endDate", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { focusedDateChange: "focusedDateChange", startDate: "startDateChange", endDate: "endDateChange" }, providers: [provideBrnCalendar(BrnCalendarRange)], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
1201
1254
  }
1202
1255
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarRange, decorators: [{
1203
1256
  type: Directive,
@@ -1205,7 +1258,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
1205
1258
  selector: '[brnCalendarRange]',
1206
1259
  providers: [provideBrnCalendar(BrnCalendarRange)],
1207
1260
  }]
1208
- }], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }], startDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "startDate", required: false }] }, { type: i0.Output, args: ["startDateChange"] }], endDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "endDate", required: false }] }, { type: i0.Output, args: ["endDateChange"] }] } });
1261
+ }], propDecorators: { highlightDays: [{ type: i0.Input, args: [{ isSignal: true, alias: "highlightDays", required: false }] }], min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], dateDisabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "dateDisabled", required: false }] }], weekStartsOn: [{ type: i0.Input, args: [{ isSignal: true, alias: "weekStartsOn", required: false }] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }], focusedDateChange: [{ type: i0.Output, args: ["focusedDateChange"] }], startDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "startDate", required: false }] }, { type: i0.Output, args: ["startDateChange"] }], endDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "endDate", required: false }] }, { type: i0.Output, args: ["endDateChange"] }] } });
1209
1262
 
1210
1263
  const BrnMonthYearCalendarToken = new InjectionToken('BrnMonthYearCalendarToken');
1211
1264
  function provideBrnMonthYearCalendar(instance) {
@@ -1269,6 +1322,12 @@ class BrnMonthYearCalendar {
1269
1322
  header = contentChild(BrnMonthYearCalendarHeader, ...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
1270
1323
  /** The focused date. */
1271
1324
  focusedDate = linkedSignal(() => this.constrainDate(this.defaultFocusedDate() ?? this.date() ?? this._dateAdapter.now()), ...(ngDevMode ? [{ debugName: "focusedDate" }] : /* istanbul ignore next */ []));
1325
+ /** Emits whenever the focused date changes. */
1326
+ focusedDateChange = output();
1327
+ _setFocusedDate(date) {
1328
+ this.focusedDate.set(date);
1329
+ this.focusedDateChange.emit(date);
1330
+ }
1272
1331
  _cells = [];
1273
1332
  /** The 12 months of the currently focused year. */
1274
1333
  months = computed(() => {
@@ -1310,7 +1369,7 @@ class BrnMonthYearCalendar {
1310
1369
  else {
1311
1370
  this.date.set(month);
1312
1371
  }
1313
- this.focusedDate.set(month);
1372
+ this._setFocusedDate(month);
1314
1373
  }
1315
1374
  selectYear(date) {
1316
1375
  if (this.isYearDisabled(date)) {
@@ -1321,7 +1380,7 @@ class BrnMonthYearCalendar {
1321
1380
  if (this.isMonthDisabled(target)) {
1322
1381
  target = this._dateAdapter.set(target, { month: 0, day: 1 });
1323
1382
  }
1324
- this.focusedDate.set(target);
1383
+ this._setFocusedDate(target);
1325
1384
  this.view.set('month');
1326
1385
  // focus the first available month once the month view is rendered.
1327
1386
  this._focusCell((cell) => !this.isMonthDisabled(cell));
@@ -1374,7 +1433,7 @@ class BrnMonthYearCalendar {
1374
1433
  if (this.isMonthDisabled(date)) {
1375
1434
  return;
1376
1435
  }
1377
- this.focusedDate.set(this._dateAdapter.startOfMonth(date));
1436
+ this._setFocusedDate(this._dateAdapter.startOfMonth(date));
1378
1437
  this._focusCell((cell) => this._dateAdapter.isSameMonth(cell, date) && this._dateAdapter.isSameYear(cell, date));
1379
1438
  }
1380
1439
  setFocusedYear(date) {
@@ -1382,7 +1441,7 @@ class BrnMonthYearCalendar {
1382
1441
  return;
1383
1442
  }
1384
1443
  const year = this._dateAdapter.getYear(date);
1385
- this.focusedDate.set(this._dateAdapter.set(this.focusedDate(), { year }));
1444
+ this._setFocusedDate(this._dateAdapter.set(this.focusedDate(), { year }));
1386
1445
  this._focusCell((cell) => this._dateAdapter.isSameYear(cell, date));
1387
1446
  }
1388
1447
  goToPrevious() {
@@ -1390,14 +1449,14 @@ class BrnMonthYearCalendar {
1390
1449
  return;
1391
1450
  }
1392
1451
  const amount = this.view() === 'month' ? 1 : YEARS_PER_PAGE;
1393
- this.focusedDate.set(this._dateAdapter.subtract(this.focusedDate(), { years: amount }));
1452
+ this._setFocusedDate(this._dateAdapter.subtract(this.focusedDate(), { years: amount }));
1394
1453
  }
1395
1454
  goToNext() {
1396
1455
  if (this.isNextDisabled()) {
1397
1456
  return;
1398
1457
  }
1399
1458
  const amount = this.view() === 'month' ? 1 : YEARS_PER_PAGE;
1400
- this.focusedDate.set(this._dateAdapter.add(this.focusedDate(), { years: amount }));
1459
+ this._setFocusedDate(this._dateAdapter.add(this.focusedDate(), { years: amount }));
1401
1460
  }
1402
1461
  isPreviousDisabled() {
1403
1462
  if (this.disabled()) {
@@ -1448,7 +1507,7 @@ class BrnMonthYearCalendar {
1448
1507
  }
1449
1508
  }
1450
1509
  /** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendar, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1451
- /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnMonthYearCalendar, isStandalone: true, selector: "[brnMonthYearCalendar]", inputs: { min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null }, viewInput: { classPropertyName: "viewInput", publicName: "view", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange" }, providers: [provideBrnMonthYearCalendar(BrnMonthYearCalendar)], queries: [{ propertyName: "header", first: true, predicate: BrnMonthYearCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
1510
+ /** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnMonthYearCalendar, isStandalone: true, selector: "[brnMonthYearCalendar]", inputs: { min: { classPropertyName: "min", publicName: "min", isSignal: true, isRequired: false, transformFunction: null }, max: { classPropertyName: "max", publicName: "max", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, date: { classPropertyName: "date", publicName: "date", isSignal: true, isRequired: false, transformFunction: null }, defaultFocusedDate: { classPropertyName: "defaultFocusedDate", publicName: "defaultFocusedDate", isSignal: true, isRequired: false, transformFunction: null }, viewInput: { classPropertyName: "viewInput", publicName: "view", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { date: "dateChange", focusedDateChange: "focusedDateChange" }, providers: [provideBrnMonthYearCalendar(BrnMonthYearCalendar)], queries: [{ propertyName: "header", first: true, predicate: BrnMonthYearCalendarHeader, descendants: true, isSignal: true }], ngImport: i0 });
1452
1511
  }
1453
1512
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnMonthYearCalendar, decorators: [{
1454
1513
  type: Directive,
@@ -1456,7 +1515,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
1456
1515
  selector: '[brnMonthYearCalendar]',
1457
1516
  providers: [provideBrnMonthYearCalendar(BrnMonthYearCalendar)],
1458
1517
  }]
1459
- }], propDecorators: { min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], viewInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "view", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnMonthYearCalendarHeader), { isSignal: true }] }] } });
1518
+ }], propDecorators: { min: [{ type: i0.Input, args: [{ isSignal: true, alias: "min", required: false }] }], max: [{ type: i0.Input, args: [{ isSignal: true, alias: "max", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], date: [{ type: i0.Input, args: [{ isSignal: true, alias: "date", required: false }] }, { type: i0.Output, args: ["dateChange"] }], defaultFocusedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "defaultFocusedDate", required: false }] }], viewInput: [{ type: i0.Input, args: [{ isSignal: true, alias: "view", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnMonthYearCalendarHeader), { isSignal: true }] }], focusedDateChange: [{ type: i0.Output, args: ["focusedDateChange"] }] } });
1460
1519
 
1461
1520
  class BrnMonthYearCalendarGrid {
1462
1521
  /** Access the month/year selector */