@spartan-ng/brain 1.11.0-beta.2 → 1.11.0-beta.3
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.
|
@@ -373,12 +373,54 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
373
373
|
}]
|
|
374
374
|
}] });
|
|
375
375
|
|
|
376
|
+
const BrnCalendarMonthToken = new InjectionToken('BrnCalendarMonthToken');
|
|
377
|
+
/**
|
|
378
|
+
* Inject the month context, if the element is rendered within a `brnCalendarMonth`.
|
|
379
|
+
*/
|
|
380
|
+
function injectBrnCalendarMonth() {
|
|
381
|
+
return inject(BrnCalendarMonthToken, { optional: true });
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Scopes the grid, weeks, weekdays, cells, header and selects within it to a single displayed month.
|
|
385
|
+
* Use it to render multiple months, e.g. with `numberOfMonths` on `brnCalendarRange`.
|
|
386
|
+
*/
|
|
387
|
+
class BrnCalendarMonth {
|
|
388
|
+
/** Access the calendar */
|
|
389
|
+
_calendar = injectBrnCalendar();
|
|
390
|
+
/** Access the date adapter */
|
|
391
|
+
_dateAdapter = injectDateAdapter();
|
|
392
|
+
/** The offset of this month relative to the first displayed month. */
|
|
393
|
+
offset = input(0, { ...(ngDevMode ? { debugName: "offset" } : /* istanbul ignore next */ {}), transform: (value) => numberAttribute(value, 0) });
|
|
394
|
+
/** @internal The header of this month. */
|
|
395
|
+
header = contentChild(BrnCalendarHeader, ...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
|
|
396
|
+
_data = computed(() => this._calendar.months?.()[this.offset()], ...(ngDevMode ? [{ debugName: "_data" }] : /* istanbul ignore next */ []));
|
|
397
|
+
/** The first day of the displayed month. */
|
|
398
|
+
month = computed(() => this._data()?.month ?? this._dateAdapter.startOfMonth(this._calendar.focusedDate()), { ...(ngDevMode ? { debugName: "month" } : /* istanbul ignore next */ {}), equal: (a, b) => this._dateAdapter.isSameMonth(a, b) });
|
|
399
|
+
/** The days to render for this month. */
|
|
400
|
+
days = computed(() => this._data()?.days ?? this._calendar.days(), { ...(ngDevMode ? { debugName: "days" } : /* istanbul ignore next */ {}), equal: (a, b) => compareDays(a, b, this._dateAdapter) });
|
|
401
|
+
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarMonth, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
402
|
+
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.2.0", version: "21.2.16", type: BrnCalendarMonth, isStandalone: true, selector: "[brnCalendarMonth]", inputs: { offset: { classPropertyName: "offset", publicName: "offset", isSignal: true, isRequired: false, transformFunction: null } }, host: { attributes: { "data-slot": "calendar-month" } }, providers: [{ provide: BrnCalendarMonthToken, useExisting: BrnCalendarMonth }], queries: [{ propertyName: "header", first: true, predicate: BrnCalendarHeader, descendants: true, isSignal: true }], exportAs: ["brnCalendarMonth"], ngImport: i0 });
|
|
403
|
+
}
|
|
404
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarMonth, decorators: [{
|
|
405
|
+
type: Directive,
|
|
406
|
+
args: [{
|
|
407
|
+
selector: '[brnCalendarMonth]',
|
|
408
|
+
exportAs: 'brnCalendarMonth',
|
|
409
|
+
providers: [{ provide: BrnCalendarMonthToken, useExisting: BrnCalendarMonth }],
|
|
410
|
+
host: {
|
|
411
|
+
'data-slot': 'calendar-month',
|
|
412
|
+
},
|
|
413
|
+
}]
|
|
414
|
+
}], propDecorators: { offset: [{ type: i0.Input, args: [{ isSignal: true, alias: "offset", required: false }] }], header: [{ type: i0.ContentChild, args: [i0.forwardRef(() => BrnCalendarHeader), { isSignal: true }] }] } });
|
|
415
|
+
|
|
376
416
|
class BrnCalendarCellButton {
|
|
377
417
|
/** Access the date adapter */
|
|
378
418
|
_dateAdapter = injectDateAdapter();
|
|
379
419
|
_destroyRef = inject(DestroyRef);
|
|
380
420
|
/** Access the calendar component */
|
|
381
421
|
_calendar = injectBrnCalendar();
|
|
422
|
+
/** Access the month this cell belongs to, if rendering multiple months */
|
|
423
|
+
_month = injectBrnCalendarMonth();
|
|
382
424
|
/** Access the element ref */
|
|
383
425
|
_elementRef = inject(ElementRef);
|
|
384
426
|
/** The date this cell represents */
|
|
@@ -393,11 +435,15 @@ class BrnCalendarCellButton {
|
|
|
393
435
|
this._calendar.registerCalendarCell(this);
|
|
394
436
|
this._destroyRef.onDestroy(() => this._calendar.unregisterCalendarCell(this));
|
|
395
437
|
}
|
|
396
|
-
/**
|
|
397
|
-
|
|
438
|
+
/**
|
|
439
|
+
* Whether this date is focusable.
|
|
440
|
+
* Days outside of their month are never focusable, as the same date is also rendered within its own month.
|
|
441
|
+
*/
|
|
442
|
+
focusable = computed(() => !this.disabled() && !this.outside() && this._dateAdapter.isSameDay(this._calendar.focusedDate(), this.date()), ...(ngDevMode ? [{ debugName: "focusable" }] : /* istanbul ignore next */ []));
|
|
443
|
+
/** Whether this date is outside of the month it is rendered in */
|
|
398
444
|
outside = computed(() => {
|
|
399
|
-
const
|
|
400
|
-
return !this._dateAdapter.isSameMonth(this.date(),
|
|
445
|
+
const month = this._month?.month() ?? this._calendar.focusedDate();
|
|
446
|
+
return !this._dateAdapter.isSameMonth(this.date(), month);
|
|
401
447
|
}, ...(ngDevMode ? [{ debugName: "outside" }] : /* istanbul ignore next */ []));
|
|
402
448
|
/** Whether this date is today */
|
|
403
449
|
today = computed(() => this._dateAdapter.isSameDay(this.date(), this._dateAdapter.now()), ...(ngDevMode ? [{ debugName: "today" }] : /* istanbul ignore next */ []));
|
|
@@ -558,8 +604,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
558
604
|
class BrnCalendarGrid {
|
|
559
605
|
/** Access the calendar component */
|
|
560
606
|
_calendar = injectBrnCalendar();
|
|
607
|
+
/** Access the month this grid belongs to, if rendering multiple months */
|
|
608
|
+
_month = injectBrnCalendarMonth();
|
|
561
609
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarGrid, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
562
|
-
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarGrid, isStandalone: true, selector: "[brnCalendarGrid]", host: { attributes: { "role": "grid" }, properties: { "attr.aria-labelledby": "_calendar.header()?.id()" } }, exportAs: ["brnCalendarGrid"], ngImport: i0 });
|
|
610
|
+
/** @nocollapse */ static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.16", type: BrnCalendarGrid, isStandalone: true, selector: "[brnCalendarGrid]", host: { attributes: { "role": "grid" }, properties: { "attr.aria-labelledby": "(_month?.header() ?? _calendar.header())?.id()" } }, exportAs: ["brnCalendarGrid"], ngImport: i0 });
|
|
563
611
|
}
|
|
564
612
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarGrid, decorators: [{
|
|
565
613
|
type: Directive,
|
|
@@ -568,7 +616,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
568
616
|
exportAs: 'brnCalendarGrid',
|
|
569
617
|
host: {
|
|
570
618
|
role: 'grid',
|
|
571
|
-
'[attr.aria-labelledby]': '_calendar.header()?.id()',
|
|
619
|
+
'[attr.aria-labelledby]': '(_month?.header() ?? _calendar.header())?.id()',
|
|
572
620
|
},
|
|
573
621
|
}]
|
|
574
622
|
}] });
|
|
@@ -578,14 +626,18 @@ class BrnCalendarMonthSelect {
|
|
|
578
626
|
_select = inject(BrnSelect);
|
|
579
627
|
/** Access the calendar */
|
|
580
628
|
_calendar = injectBrnCalendar();
|
|
629
|
+
/** Access the month this select belongs to, if rendering multiple months */
|
|
630
|
+
_month = injectBrnCalendarMonth();
|
|
581
631
|
/** Access the date adapter */
|
|
582
632
|
_dateAdapter = injectDateAdapter();
|
|
583
633
|
/** Access the calendar i18n */
|
|
584
634
|
_i18n = injectBrnCalendarI18n();
|
|
635
|
+
/** The month displayed by this select */
|
|
636
|
+
_displayedMonth = computed(() => this._month?.month() ?? this._calendar.focusedDate(), ...(ngDevMode ? [{ debugName: "_displayedMonth" }] : /* istanbul ignore next */ []));
|
|
585
637
|
/** Whether the select value is being synced from the calendar rather than picked by the user */
|
|
586
638
|
_syncing = false;
|
|
587
639
|
_selectedMonth = computed(() => {
|
|
588
|
-
return this._i18n.config().months()[this._dateAdapter.getMonth(this.
|
|
640
|
+
return this._i18n.config().months()[this._dateAdapter.getMonth(this._displayedMonth())];
|
|
589
641
|
}, ...(ngDevMode ? [{ debugName: "_selectedMonth" }] : /* istanbul ignore next */ []));
|
|
590
642
|
constructor() {
|
|
591
643
|
// React to user selection through the injected select's typed `value` output rather than a
|
|
@@ -612,13 +664,18 @@ class BrnCalendarMonthSelect {
|
|
|
612
664
|
const focusedDate = this._calendar.focusedDate();
|
|
613
665
|
// Start from the first of the month so a day that does not exist in the target month
|
|
614
666
|
// (e.g. the 31st) cannot roll over into the following month - clamp it instead.
|
|
615
|
-
const targetDate = this._dateAdapter.set(this._dateAdapter.startOfMonth(
|
|
667
|
+
const targetDate = this._dateAdapter.set(this._dateAdapter.startOfMonth(this._displayedMonth()), { month });
|
|
616
668
|
const lastDay = this._dateAdapter.getDate(this._dateAdapter.endOfMonth(targetDate));
|
|
617
669
|
const day = Math.min(this._dateAdapter.getDate(focusedDate), lastDay);
|
|
618
670
|
// Like the previous/next buttons, constrain the target to min/max instead of letting
|
|
619
671
|
// setFocusedDate reject it: otherwise the grid stays on the old month.
|
|
620
672
|
const target = this._calendar.constrainDate(this._dateAdapter.set(targetDate, { day }));
|
|
621
673
|
this._calendar.setFocusedDate(target);
|
|
674
|
+
// Keep the selected month at the position of this select when rendering multiple months.
|
|
675
|
+
// A rejected target leaves the focused date unchanged, so the displayed months must not move.
|
|
676
|
+
if (this._dateAdapter.isSameDay(this._calendar.focusedDate(), target)) {
|
|
677
|
+
this._calendar.showMonth?.(target, this._month?.offset() ?? 0);
|
|
678
|
+
}
|
|
622
679
|
// The select already shows the picked month. When the focused month did not change
|
|
623
680
|
// (target rejected or constrained back into it), the effect does not run again.
|
|
624
681
|
this._syncSelect(this._selectedMonth());
|
|
@@ -698,7 +755,9 @@ class BrnCalendarNextButton {
|
|
|
698
755
|
const focusedDate = this._calendar.focusedDate();
|
|
699
756
|
const date = this._dateAdapter.getDate(focusedDate);
|
|
700
757
|
// go to start of month first, then add 1 month to avoid day overflow
|
|
701
|
-
|
|
758
|
+
// when rendering multiple months, navigate relative to the last displayed month
|
|
759
|
+
const displayedMonth = this._calendar.months?.().at(-1)?.month ?? focusedDate;
|
|
760
|
+
let nextMonthTarget = this._dateAdapter.startOfMonth(displayedMonth);
|
|
702
761
|
nextMonthTarget = this._dateAdapter.add(nextMonthTarget, { months: 1 });
|
|
703
762
|
const lastDay = this._dateAdapter.endOfMonth(nextMonthTarget);
|
|
704
763
|
// if we are on a date that does not exist in the next month, clamp to the last day of the month.
|
|
@@ -756,7 +815,9 @@ class BrnCalendarPreviousButton {
|
|
|
756
815
|
const focusedDate = this._calendar.focusedDate();
|
|
757
816
|
const date = this._dateAdapter.getDate(focusedDate);
|
|
758
817
|
// go to start of month first, then subtract 1 month to avoid day overflow
|
|
759
|
-
|
|
818
|
+
// when rendering multiple months, navigate relative to the first displayed month
|
|
819
|
+
const displayedMonth = this._calendar.months?.()[0]?.month ?? focusedDate;
|
|
820
|
+
let previousMonthTarget = this._dateAdapter.startOfMonth(displayedMonth);
|
|
760
821
|
previousMonthTarget = this._dateAdapter.subtract(previousMonthTarget, { months: 1 });
|
|
761
822
|
const lastDay = this._dateAdapter.endOfMonth(previousMonthTarget);
|
|
762
823
|
// if we are on a date that does not exist in the previous month, clamp to the last day of the month.
|
|
@@ -787,6 +848,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
787
848
|
class BrnCalendarWeek {
|
|
788
849
|
/** Access the calendar */
|
|
789
850
|
_calendar = injectBrnCalendar();
|
|
851
|
+
/** Access the month this week belongs to, if rendering multiple months */
|
|
852
|
+
_month = injectBrnCalendarMonth();
|
|
790
853
|
/** Access the view container ref */
|
|
791
854
|
_viewContainerRef = inject(ViewContainerRef);
|
|
792
855
|
/** Access the change detector */
|
|
@@ -795,7 +858,7 @@ class BrnCalendarWeek {
|
|
|
795
858
|
_templateRef = inject(TemplateRef);
|
|
796
859
|
// get the weeks to display.
|
|
797
860
|
_weeks = computed(() => {
|
|
798
|
-
const days = this._calendar.days();
|
|
861
|
+
const days = this._month?.days() ?? this._calendar.days();
|
|
799
862
|
const weeks = [];
|
|
800
863
|
for (let i = 0; i < days.length; i += 7) {
|
|
801
864
|
weeks.push(days.slice(i, i + 7));
|
|
@@ -851,6 +914,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
851
914
|
class BrnCalendarWeekday {
|
|
852
915
|
/** Access the calendar */
|
|
853
916
|
_calendar = injectBrnCalendar();
|
|
917
|
+
/** Access the month these weekdays belong to, if rendering multiple months */
|
|
918
|
+
_month = injectBrnCalendarMonth();
|
|
854
919
|
/** Access the date time adapter */
|
|
855
920
|
_dateAdapter = injectDateAdapter();
|
|
856
921
|
/** Access the view container ref */
|
|
@@ -860,7 +925,7 @@ class BrnCalendarWeekday {
|
|
|
860
925
|
/** Access the template ref */
|
|
861
926
|
_templateRef = inject(TemplateRef);
|
|
862
927
|
/** Get the days of the week to display in the header. */
|
|
863
|
-
_weekdays = computed(() => this._calendar.days().slice(0, 7), ...(ngDevMode ? [{ debugName: "_weekdays" }] : /* istanbul ignore next */ []));
|
|
928
|
+
_weekdays = computed(() => (this._month?.days() ?? this._calendar.days()).slice(0, 7), ...(ngDevMode ? [{ debugName: "_weekdays" }] : /* istanbul ignore next */ []));
|
|
864
929
|
/** Store the view refs */
|
|
865
930
|
_viewRefs = [];
|
|
866
931
|
// Make sure the template checker knows the type of the context with which the
|
|
@@ -914,6 +979,10 @@ class BrnCalendarYearSelect {
|
|
|
914
979
|
_select = inject(BrnSelect);
|
|
915
980
|
/** Access the calendar */
|
|
916
981
|
_calendar = injectBrnCalendar();
|
|
982
|
+
/** Access the month this select belongs to, if rendering multiple months */
|
|
983
|
+
_month = injectBrnCalendarMonth();
|
|
984
|
+
/** The month displayed by this select */
|
|
985
|
+
_displayedMonth = computed(() => this._month?.month() ?? this._calendar.focusedDate(), ...(ngDevMode ? [{ debugName: "_displayedMonth" }] : /* istanbul ignore next */ []));
|
|
917
986
|
/** Access the date adapter */
|
|
918
987
|
_dateAdapter = injectDateAdapter();
|
|
919
988
|
/** Access the calendar i18n */
|
|
@@ -933,7 +1002,7 @@ class BrnCalendarYearSelect {
|
|
|
933
1002
|
}
|
|
934
1003
|
});
|
|
935
1004
|
effect(() => {
|
|
936
|
-
this._syncSelect(this._dateAdapter.getYear(this.
|
|
1005
|
+
this._syncSelect(this._dateAdapter.getYear(this._displayedMonth()));
|
|
937
1006
|
});
|
|
938
1007
|
}
|
|
939
1008
|
/** Focus selected year */
|
|
@@ -941,15 +1010,20 @@ class BrnCalendarYearSelect {
|
|
|
941
1010
|
const focusedDate = this._calendar.focusedDate();
|
|
942
1011
|
// Start from the first of the month so a day that does not exist in the target year
|
|
943
1012
|
// (e.g. the 29th of February in a non-leap year) is clamped instead of rolling over.
|
|
944
|
-
const targetDate = this._dateAdapter.set(this._dateAdapter.startOfMonth(
|
|
1013
|
+
const targetDate = this._dateAdapter.set(this._dateAdapter.startOfMonth(this._displayedMonth()), { year });
|
|
945
1014
|
const lastDay = this._dateAdapter.getDate(this._dateAdapter.endOfMonth(targetDate));
|
|
946
1015
|
const day = Math.min(this._dateAdapter.getDate(focusedDate), lastDay);
|
|
947
1016
|
// Like the previous/next buttons, constrain the target to min/max instead of letting
|
|
948
1017
|
// setFocusedDate reject it: otherwise the grid stays on the old year.
|
|
949
1018
|
const target = this._calendar.constrainDate(this._dateAdapter.set(targetDate, { day }));
|
|
950
1019
|
this._calendar.setFocusedDate(target);
|
|
1020
|
+
// Keep the selected year at the position of this select when rendering multiple months.
|
|
1021
|
+
// A rejected target leaves the focused date unchanged, so the displayed months must not move.
|
|
1022
|
+
if (this._dateAdapter.isSameDay(this._calendar.focusedDate(), target)) {
|
|
1023
|
+
this._calendar.showMonth?.(target, this._month?.offset() ?? 0);
|
|
1024
|
+
}
|
|
951
1025
|
// Keep the select on the year actually shown when the target was rejected.
|
|
952
|
-
this._syncSelect(this._dateAdapter.getYear(this.
|
|
1026
|
+
this._syncSelect(this._dateAdapter.getYear(this._displayedMonth()));
|
|
953
1027
|
}
|
|
954
1028
|
/** Write the calendar's value into the select without treating it as a user selection */
|
|
955
1029
|
_syncSelect(value) {
|
|
@@ -1226,6 +1300,8 @@ class BrnCalendarRange {
|
|
|
1226
1300
|
_weekStartsOn = computed(() => this.weekStartsOn() ?? this._i18n.config().firstDayOfWeek(), ...(ngDevMode ? [{ debugName: "_weekStartsOn" }] : /* istanbul ignore next */ []));
|
|
1227
1301
|
/** The default focused date. */
|
|
1228
1302
|
defaultFocusedDate = input(...(ngDevMode ? [undefined, { debugName: "defaultFocusedDate" }] : /* istanbul ignore next */ []));
|
|
1303
|
+
/** The number of months to display. */
|
|
1304
|
+
numberOfMonths = input(1, { ...(ngDevMode ? { debugName: "numberOfMonths" } : /* istanbul ignore next */ {}), transform: (value) => Math.max(1, Math.floor(numberAttribute(value, 1))) });
|
|
1229
1305
|
/** @internal Access the header */
|
|
1230
1306
|
header = contentChild(BrnCalendarHeader, ...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
|
|
1231
1307
|
/**
|
|
@@ -1271,13 +1347,52 @@ class BrnCalendarRange {
|
|
|
1271
1347
|
* The selected end date
|
|
1272
1348
|
*/
|
|
1273
1349
|
endDate = model(...(ngDevMode ? [undefined, { debugName: "endDate" }] : /* istanbul ignore next */ []));
|
|
1350
|
+
/**
|
|
1351
|
+
* The first displayed month. It only moves when the focused date leaves the displayed months,
|
|
1352
|
+
* so navigating within the displayed months does not shift them.
|
|
1353
|
+
*/
|
|
1354
|
+
_firstMonth = linkedSignal({ ...(ngDevMode ? { debugName: "_firstMonth" } : /* istanbul ignore next */ {}), source: () => ({ focusedDate: this.focusedDate(), numberOfMonths: this.numberOfMonths() }),
|
|
1355
|
+
computation: ({ focusedDate, numberOfMonths }, previous) => {
|
|
1356
|
+
const focusedMonth = this._dateAdapter.startOfMonth(focusedDate);
|
|
1357
|
+
if (!previous) {
|
|
1358
|
+
return focusedMonth;
|
|
1359
|
+
}
|
|
1360
|
+
const offset = this._monthDifference(previous.value, focusedMonth);
|
|
1361
|
+
if (offset < 0) {
|
|
1362
|
+
return focusedMonth;
|
|
1363
|
+
}
|
|
1364
|
+
if (offset >= numberOfMonths) {
|
|
1365
|
+
return this._dateAdapter.subtract(focusedMonth, { months: numberOfMonths - 1 });
|
|
1366
|
+
}
|
|
1367
|
+
return previous.value;
|
|
1368
|
+
},
|
|
1369
|
+
equal: (a, b) => this._dateAdapter.isSameMonth(a, b) });
|
|
1370
|
+
/** The months to display, starting with the first displayed month. */
|
|
1371
|
+
months = computed(() => {
|
|
1372
|
+
const firstMonth = this._firstMonth();
|
|
1373
|
+
return Array.from({ length: this.numberOfMonths() }, (_, offset) => {
|
|
1374
|
+
const month = this._dateAdapter.add(firstMonth, { months: offset });
|
|
1375
|
+
return { month, days: this._getDays(month) };
|
|
1376
|
+
});
|
|
1377
|
+
}, ...(ngDevMode ? [{ debugName: "months" }] : /* istanbul ignore next */ []));
|
|
1274
1378
|
/**
|
|
1275
1379
|
* Get all the days to display, this is the days of the current month
|
|
1276
1380
|
* and the days of the previous and next month to fill the grid.
|
|
1277
1381
|
*/
|
|
1278
|
-
days = computed(() => {
|
|
1382
|
+
days = computed(() => this._getDays(this.focusedDate()), { ...(ngDevMode ? { debugName: "days" } : /* istanbul ignore next */ {}), equal: (a, b) => compareDays(a, b, this._dateAdapter) });
|
|
1383
|
+
/** Show the month of the given date at the given offset of the displayed months. */
|
|
1384
|
+
showMonth(date, offset) {
|
|
1385
|
+
const month = this._dateAdapter.startOfMonth(date);
|
|
1386
|
+
this._firstMonth.set(this._dateAdapter.subtract(month, { months: offset }));
|
|
1387
|
+
}
|
|
1388
|
+
_monthDifference(from, to) {
|
|
1389
|
+
return ((this._dateAdapter.getYear(to) - this._dateAdapter.getYear(from)) * 12 +
|
|
1390
|
+
this._dateAdapter.getMonth(to) -
|
|
1391
|
+
this._dateAdapter.getMonth(from));
|
|
1392
|
+
}
|
|
1393
|
+
/** Get the days of the month of the given date, padded to full weeks. */
|
|
1394
|
+
_getDays(month) {
|
|
1279
1395
|
const weekStartsOn = this._weekStartsOn();
|
|
1280
|
-
const month = this.focusedDate();
|
|
1281
1396
|
const days = [];
|
|
1282
1397
|
// Get the first and last day of the month.
|
|
1283
1398
|
let firstDay = this._dateAdapter.startOfMonth(month);
|
|
@@ -1297,7 +1412,7 @@ class BrnCalendarRange {
|
|
|
1297
1412
|
firstDay = this._dateAdapter.add(firstDay, { days: 1 });
|
|
1298
1413
|
}
|
|
1299
1414
|
return days;
|
|
1300
|
-
}
|
|
1415
|
+
}
|
|
1301
1416
|
isSelected(date) {
|
|
1302
1417
|
const start = this.startDate();
|
|
1303
1418
|
const end = this.endDate();
|
|
@@ -1384,7 +1499,7 @@ class BrnCalendarRange {
|
|
|
1384
1499
|
// wait until the cells have all updated
|
|
1385
1500
|
afterNextRender({
|
|
1386
1501
|
write: () => {
|
|
1387
|
-
const cell = this._cells.find((c) => this._dateAdapter.isSameDay(c.date(), date));
|
|
1502
|
+
const cell = this._cells.find((c) => !c.outside() && this._dateAdapter.isSameDay(c.date(), date));
|
|
1388
1503
|
if (cell) {
|
|
1389
1504
|
cell.focus();
|
|
1390
1505
|
}
|
|
@@ -1442,7 +1557,7 @@ class BrnCalendarRange {
|
|
|
1442
1557
|
this._cells.push(cell);
|
|
1443
1558
|
}
|
|
1444
1559
|
/** @nocollapse */ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarRange, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
1445
|
-
/** @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 }], exportAs: ["brnCalendarRange"], ngImport: i0 });
|
|
1560
|
+
/** @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 }, numberOfMonths: { classPropertyName: "numberOfMonths", publicName: "numberOfMonths", 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 }], exportAs: ["brnCalendarRange"], ngImport: i0 });
|
|
1446
1561
|
}
|
|
1447
1562
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImport: i0, type: BrnCalendarRange, decorators: [{
|
|
1448
1563
|
type: Directive,
|
|
@@ -1451,7 +1566,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.16", ngImpo
|
|
|
1451
1566
|
exportAs: 'brnCalendarRange',
|
|
1452
1567
|
providers: [provideBrnCalendar(BrnCalendarRange)],
|
|
1453
1568
|
}]
|
|
1454
|
-
}], 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"] }] } });
|
|
1569
|
+
}], 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 }] }], numberOfMonths: [{ type: i0.Input, args: [{ isSignal: true, alias: "numberOfMonths", 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"] }] } });
|
|
1455
1570
|
|
|
1456
1571
|
const BrnMonthYearCalendarToken = new InjectionToken('BrnMonthYearCalendarToken');
|
|
1457
1572
|
function provideBrnMonthYearCalendar(instance) {
|
|
@@ -1945,6 +2060,7 @@ const BrnCalendarImports = [
|
|
|
1945
2060
|
BrnCalendarWeekday,
|
|
1946
2061
|
BrnCalendar,
|
|
1947
2062
|
BrnCalendarCell,
|
|
2063
|
+
BrnCalendarMonth,
|
|
1948
2064
|
BrnCalendarMulti,
|
|
1949
2065
|
BrnCalendarRange,
|
|
1950
2066
|
BrnCalendarMonthSelect,
|
|
@@ -1962,5 +2078,5 @@ const BrnCalendarImports = [
|
|
|
1962
2078
|
* Generated bundle index. Do not edit.
|
|
1963
2079
|
*/
|
|
1964
2080
|
|
|
1965
|
-
export { BrnCalendar, BrnCalendarCell, BrnCalendarCellButton, BrnCalendarGrid, BrnCalendarHeader, BrnCalendarI18nService, BrnCalendarI18nToken, BrnCalendarImports, BrnCalendarMonthSelect, BrnCalendarMulti, BrnCalendarNextButton, BrnCalendarPreviousButton, BrnCalendarRange, BrnCalendarToken, BrnCalendarWeek, BrnCalendarWeekday, BrnCalendarYearSelect, BrnMonthYearCalendar, BrnMonthYearCalendarGrid, BrnMonthYearCalendarHeader, BrnMonthYearCalendarMonthButton, BrnMonthYearCalendarNextButton, BrnMonthYearCalendarPreviousButton, BrnMonthYearCalendarToken, BrnMonthYearCalendarYearButton, injectBrnCalendar, injectBrnCalendarI18n, injectBrnMonthYearCalendar, provideBrnCalendar, provideBrnCalendarI18n, provideBrnMonthYearCalendar };
|
|
2081
|
+
export { BrnCalendar, BrnCalendarCell, BrnCalendarCellButton, BrnCalendarGrid, BrnCalendarHeader, BrnCalendarI18nService, BrnCalendarI18nToken, BrnCalendarImports, BrnCalendarMonth, BrnCalendarMonthSelect, BrnCalendarMonthToken, BrnCalendarMulti, BrnCalendarNextButton, BrnCalendarPreviousButton, BrnCalendarRange, BrnCalendarToken, BrnCalendarWeek, BrnCalendarWeekday, BrnCalendarYearSelect, BrnMonthYearCalendar, BrnMonthYearCalendarGrid, BrnMonthYearCalendarHeader, BrnMonthYearCalendarMonthButton, BrnMonthYearCalendarNextButton, BrnMonthYearCalendarPreviousButton, BrnMonthYearCalendarToken, BrnMonthYearCalendarYearButton, injectBrnCalendar, injectBrnCalendarI18n, injectBrnCalendarMonth, injectBrnMonthYearCalendar, provideBrnCalendar, provideBrnCalendarI18n, provideBrnMonthYearCalendar };
|
|
1966
2082
|
//# sourceMappingURL=spartan-ng-brain-calendar.mjs.map
|