@nanahoshi/mona-ui 0.31.0 → 0.32.0
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/date-range-picker/package.json +4 -0
- package/docs/api/calendar.md +3 -2
- package/docs/api/common.md +1 -1
- package/docs/api/date-input.md +1 -1
- package/docs/api/date-range-picker.md +137 -0
- package/docs/api/i18n.md +53 -0
- package/docs/api/list.md +1 -1
- package/docs/api/locales.md +14 -14
- package/docs/api/popup.md +1 -1
- package/docs/calendar.md +47 -3
- package/docs/date-picker.md +1 -1
- package/docs/date-range-picker.md +420 -0
- package/docs/forms.md +1 -0
- package/docs/label.md +1 -0
- package/fesm2022/nanahoshi-mona-ui-calendar.mjs +171 -59
- package/fesm2022/nanahoshi-mona-ui-date-picker.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-date-range-picker.mjs +1331 -0
- package/fesm2022/nanahoshi-mona-ui-datetime-picker.mjs +1 -0
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +19 -0
- package/fesm2022/nanahoshi-mona-ui-i18n.mjs +7 -1
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +23 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +19 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +19 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +19 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +16 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +19 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +16 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +16 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +21 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +19 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +21 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +19 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +16 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +16 -0
- package/i18n/catalogs/en-US.messages.json +16 -0
- package/llms.txt +3 -1
- package/locales/ar-sa/ar-sa.messages.json +16 -0
- package/locales/de-de/de-de.messages.json +16 -0
- package/locales/es-es/es-es.messages.json +16 -0
- package/locales/fr-fr/fr-fr.messages.json +16 -0
- package/locales/id-id/id-id.messages.json +16 -0
- package/locales/it-it/it-it.messages.json +16 -0
- package/locales/ja-jp/ja-jp.messages.json +16 -0
- package/locales/ko-kr/ko-kr.messages.json +16 -0
- package/locales/pl-pl/pl-pl.messages.json +16 -0
- package/locales/pt-br/pt-br.messages.json +16 -0
- package/locales/ru-ru/ru-ru.messages.json +16 -0
- package/locales/tr-tr/tr-tr.messages.json +16 -0
- package/locales/zh-cn/zh-cn.messages.json +16 -0
- package/locales/zh-tw/zh-tw.messages.json +16 -0
- package/package.json +5 -1
- package/types/nanahoshi-mona-ui-calendar.d.ts +66 -8
- package/types/nanahoshi-mona-ui-date-range-picker.d.ts +462 -0
- package/types/nanahoshi-mona-ui-i18n.d.ts +39 -0
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +16 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +16 -0
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { NgTemplateOutlet } from "@angular/common";
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
|
-
import { Component, DestroyRef, Directive, ElementRef, TemplateRef, afterNextRender, booleanAttribute, computed, contentChild, effect, inject, input, linkedSignal, model, output, signal, untracked } from "@angular/core";
|
|
3
|
+
import { Component, DestroyRef, Directive, ElementRef, TemplateRef, afterNextRender, booleanAttribute, computed, contentChild, effect, inject, input, linkedSignal, model, numberAttribute, output, signal, untracked } from "@angular/core";
|
|
4
4
|
import { takeUntilDestroyed, toObservable } from "@angular/core/rxjs-interop";
|
|
5
5
|
import { LucideChevronLeft, LucideChevronRight } from "@lucide/angular";
|
|
6
|
-
import {
|
|
6
|
+
import { firstOrDefault, index, lastOrDefault, range, select } from "@mirei/ts-collections";
|
|
7
7
|
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
8
|
-
import { PreventableEvent
|
|
8
|
+
import { PreventableEvent } from "@nanahoshi/mona-ui/common";
|
|
9
9
|
import { CalendarService } from "@nanahoshi/mona-ui/date-input";
|
|
10
10
|
import { createElementControlId, injectEffectiveDisabled, rxTimeout, themeRaisedBackdropClasses } from "@nanahoshi/mona-ui/internal";
|
|
11
11
|
import { DateTime } from "luxon";
|
|
12
12
|
import { fromEvent, skip } from "rxjs";
|
|
13
13
|
import { twMerge } from "tailwind-merge";
|
|
14
|
-
import { MonaI18nService, formatGregorianDateToLocaleString, formatNumber, getLocaleFirstDayOfWeek, gregorianDateTime, gregorianDateTimeFromObject, injectComponentDirection } from "@nanahoshi/mona-ui/i18n";
|
|
14
|
+
import { MonaI18nService, formatGregorianDateRangeToLocaleString, formatGregorianDateToLocaleString, formatNumber, getLocaleFirstDayOfWeek, gregorianDateTime, gregorianDateTimeFromObject, injectComponentDirection } from "@nanahoshi/mona-ui/i18n";
|
|
15
15
|
import { cva } from "class-variance-authority";
|
|
16
16
|
function localizeNumber(value, options) {
|
|
17
17
|
return formatNumber(value, "en-US", options);
|
|
@@ -173,6 +173,11 @@ const calendarMonthViewDayThemeVariants = cva(`
|
|
|
173
173
|
disabled: { true: "pointer-events-none cursor-not-allowed text-disabled-foreground" },
|
|
174
174
|
focused: { true: "bg-hover outline-none focus-visible:outline-hidden ring-2 ring-inset ring-focus-indicator/35" },
|
|
175
175
|
outside: { true: "text-muted-foreground" },
|
|
176
|
+
rangeMiddle: { true: `
|
|
177
|
+
bg-(--color-selected) text-(--color-selected-foreground)
|
|
178
|
+
hover:bg-(--color-selected-hover) hover:text-(--color-selected-hover-foreground)
|
|
179
|
+
forced-color-adjust-none forced-colors:bg-[Highlight]! forced-colors:text-[HighlightText]
|
|
180
|
+
` },
|
|
176
181
|
rangePreview: { true: "bg-active hover:bg-active" },
|
|
177
182
|
rounded: {
|
|
178
183
|
none: "rounded-none",
|
|
@@ -191,6 +196,8 @@ const calendarMonthViewDayThemeVariants = cva(`
|
|
|
191
196
|
}],
|
|
192
197
|
defaultVariants: { rounded: "medium" }
|
|
193
198
|
});
|
|
199
|
+
const calendarMonthViewThemeVariants = cva(`flex flex-wrap items-start justify-center gap-x-4 gap-y-3`);
|
|
200
|
+
const calendarMonthCaptionThemeVariants = cva(`pb-1 text-center text-sm font-semibold text-foreground`);
|
|
194
201
|
const calendarMonthViewGridThemeVariants = cva(`
|
|
195
202
|
grid justify-center gap-0.5
|
|
196
203
|
[&>div]:aspect-square
|
|
@@ -454,14 +461,16 @@ var MonthDayDirective = class MonthDayDirective {
|
|
|
454
461
|
const disabled = this.dayDisabled();
|
|
455
462
|
const focused = this.focused();
|
|
456
463
|
const outside = this.outside();
|
|
464
|
+
const rangeMiddle = this.rangePart() === "middle";
|
|
457
465
|
const rangePreview = this.rangePreviewed();
|
|
458
466
|
const rounded = this.rounded();
|
|
459
|
-
const selected = this.selected();
|
|
467
|
+
const selected = this.selected() && !rangeMiddle;
|
|
460
468
|
const today = this.isToday();
|
|
461
469
|
return calendarMonthViewDayThemeVariants({
|
|
462
470
|
disabled,
|
|
463
471
|
focused,
|
|
464
472
|
outside,
|
|
473
|
+
rangeMiddle,
|
|
465
474
|
rangePreview,
|
|
466
475
|
rounded,
|
|
467
476
|
selected,
|
|
@@ -477,6 +486,13 @@ var MonthDayDirective = class MonthDayDirective {
|
|
|
477
486
|
const monthEnd = this.monthBounds()[1];
|
|
478
487
|
return compareDates(entry.key, monthStart, "<") || compareDates(entry.key, monthEnd, ">");
|
|
479
488
|
}, ...ngDevMode ? [{ debugName: "outside" }] : /* istanbul ignore next */ []);
|
|
489
|
+
this.rangePart = computed(() => {
|
|
490
|
+
const ends = this.rangeEnds();
|
|
491
|
+
if (!ends || !this.selected()) return null;
|
|
492
|
+
const key = this.#key();
|
|
493
|
+
if (key === ends.start) return "start";
|
|
494
|
+
return key === ends.end ? "end" : "middle";
|
|
495
|
+
}, ...ngDevMode ? [{ debugName: "rangePart" }] : /* istanbul ignore next */ []);
|
|
480
496
|
this.rangePreviewed = computed(() => !this.selected() && this.rangePreviewKeys().has(this.#key()), ...ngDevMode ? [{ debugName: "rangePreviewed" }] : /* istanbul ignore next */ []);
|
|
481
497
|
this.selected = computed(() => this.selectedKeys().has(this.#key()), ...ngDevMode ? [{ debugName: "selected" }] : /* istanbul ignore next */ []);
|
|
482
498
|
this.dayPointerEnter = output();
|
|
@@ -486,6 +502,7 @@ var MonthDayDirective = class MonthDayDirective {
|
|
|
486
502
|
this.isDayUnavailable = input.required(...ngDevMode ? [{ debugName: "isDayUnavailable" }] : /* istanbul ignore next */ []);
|
|
487
503
|
this.monthBounds = input.required(...ngDevMode ? [{ debugName: "monthBounds" }] : /* istanbul ignore next */ []);
|
|
488
504
|
this.navigatedDate = input.required(...ngDevMode ? [{ debugName: "navigatedDate" }] : /* istanbul ignore next */ []);
|
|
505
|
+
this.rangeEnds = input(null, ...ngDevMode ? [{ debugName: "rangeEnds" }] : /* istanbul ignore next */ []);
|
|
489
506
|
this.rangePreviewKeys = input.required(...ngDevMode ? [{ debugName: "rangePreviewKeys" }] : /* istanbul ignore next */ []);
|
|
490
507
|
this.rounded = input.required(...ngDevMode ? [{ debugName: "rounded" }] : /* istanbul ignore next */ []);
|
|
491
508
|
this.selectedKeys = input.required(...ngDevMode ? [{ debugName: "selectedKeys" }] : /* istanbul ignore next */ []);
|
|
@@ -558,6 +575,13 @@ var MonthDayDirective = class MonthDayDirective {
|
|
|
558
575
|
isRequired: true,
|
|
559
576
|
transformFunction: null
|
|
560
577
|
},
|
|
578
|
+
rangeEnds: {
|
|
579
|
+
classPropertyName: "rangeEnds",
|
|
580
|
+
publicName: "rangeEnds",
|
|
581
|
+
isSignal: true,
|
|
582
|
+
isRequired: false,
|
|
583
|
+
transformFunction: null
|
|
584
|
+
},
|
|
561
585
|
rangePreviewKeys: {
|
|
562
586
|
classPropertyName: "rangePreviewKeys",
|
|
563
587
|
publicName: "rangePreviewKeys",
|
|
@@ -603,6 +627,7 @@ var MonthDayDirective = class MonthDayDirective {
|
|
|
603
627
|
"attr.aria-disabled": "dayDisabled() ? 'true' : null",
|
|
604
628
|
"attr.aria-label": "ariaLabel()",
|
|
605
629
|
"attr.aria-selected": "selected() ? 'true' : null",
|
|
630
|
+
"attr.data-range": "rangePart()",
|
|
606
631
|
"attr.data-range-preview": "rangePreviewed() ? 'true' : null",
|
|
607
632
|
"class": "baseClass()"
|
|
608
633
|
}
|
|
@@ -626,6 +651,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
626
651
|
"[attr.aria-disabled]": "dayDisabled() ? 'true' : null",
|
|
627
652
|
"[attr.aria-label]": "ariaLabel()",
|
|
628
653
|
"[attr.aria-selected]": "selected() ? 'true' : null",
|
|
654
|
+
"[attr.data-range]": "rangePart()",
|
|
629
655
|
"[attr.data-range-preview]": "rangePreviewed() ? 'true' : null",
|
|
630
656
|
"[class]": "baseClass()",
|
|
631
657
|
"(click)": "onClick($event)",
|
|
@@ -683,6 +709,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
683
709
|
required: true
|
|
684
710
|
}]
|
|
685
711
|
}],
|
|
712
|
+
rangeEnds: [{
|
|
713
|
+
type: i0.Input,
|
|
714
|
+
args: [{
|
|
715
|
+
isSignal: true,
|
|
716
|
+
alias: "rangeEnds",
|
|
717
|
+
required: false
|
|
718
|
+
}]
|
|
719
|
+
}],
|
|
686
720
|
rangePreviewKeys: [{
|
|
687
721
|
type: i0.Input,
|
|
688
722
|
args: [{
|
|
@@ -896,6 +930,11 @@ function startOfDay(date) {
|
|
|
896
930
|
function calendarDaysBetween(start, end) {
|
|
897
931
|
return Math.round(end.startOf("day").diff(start.startOf("day"), "days").days);
|
|
898
932
|
}
|
|
933
|
+
const MAX_MONTHS = 12;
|
|
934
|
+
function monthCount(value) {
|
|
935
|
+
const count = Math.trunc(numberAttribute(value, 1));
|
|
936
|
+
return Number.isFinite(count) ? Math.min(MAX_MONTHS, Math.max(1, count)) : 1;
|
|
937
|
+
}
|
|
899
938
|
const FIRST_DAY_OF_WEEK_TO_ISO = {
|
|
900
939
|
monday: 1,
|
|
901
940
|
tuesday: 2,
|
|
@@ -911,7 +950,6 @@ var CalendarComponent = class CalendarComponent {
|
|
|
911
950
|
#direction;
|
|
912
951
|
#hostElementRef;
|
|
913
952
|
#i18n;
|
|
914
|
-
#monthDict;
|
|
915
953
|
#outputValue;
|
|
916
954
|
constructor() {
|
|
917
955
|
this.#calendarService = inject(CalendarService, { optional: true });
|
|
@@ -919,19 +957,6 @@ var CalendarComponent = class CalendarComponent {
|
|
|
919
957
|
this.#direction = injectComponentDirection();
|
|
920
958
|
this.#hostElementRef = inject(ElementRef);
|
|
921
959
|
this.#i18n = inject(MonaI18nService);
|
|
922
|
-
this.#monthDict = computed(() => {
|
|
923
|
-
const day = this.navigatedDate();
|
|
924
|
-
const firstDayOfMonth = gregorianDateTime(day, this.#i18n.localeId()).startOf("month");
|
|
925
|
-
const lastDayOfMonth = gregorianDateTime(day, this.#i18n.localeId()).endOf("month");
|
|
926
|
-
const firstDayIso = FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()];
|
|
927
|
-
const daysToSubtract = (firstDayOfMonth.weekday - firstDayIso + 7) % 7;
|
|
928
|
-
const firstDayOfCalendar = firstDayOfMonth.minus({ days: daysToSubtract });
|
|
929
|
-
const daysToAdd = ((firstDayIso + 5) % 7 + 1 - lastDayOfMonth.weekday + 7) % 7;
|
|
930
|
-
const lastDayOfCalendar = lastDayOfMonth.plus({ days: daysToAdd });
|
|
931
|
-
const dictionary = new Dictionary();
|
|
932
|
-
for (let i = firstDayOfCalendar; i <= lastDayOfCalendar; i = i.plus({ days: 1 })) dictionary.add(i.toJSDate(), i.day);
|
|
933
|
-
return dictionary.toImmutableDictionary((e) => e.key, (e) => e.value);
|
|
934
|
-
}, ...ngDevMode ? [{ debugName: "#monthDict" }] : /* istanbul ignore next */ []);
|
|
935
960
|
this.#outputValue = computed(() => {
|
|
936
961
|
const selection = this.selection();
|
|
937
962
|
const selectedDates = this.selectedDates();
|
|
@@ -950,10 +975,7 @@ var CalendarComponent = class CalendarComponent {
|
|
|
950
975
|
const locale = this.#i18n.localeId();
|
|
951
976
|
const messages = this.messages();
|
|
952
977
|
switch (view) {
|
|
953
|
-
case "month": return messages.calendarLabel(
|
|
954
|
-
year: "numeric",
|
|
955
|
-
month: "long"
|
|
956
|
-
}));
|
|
978
|
+
case "month": return messages.calendarLabel(this.headerMonthYear());
|
|
957
979
|
case "year": return messages.yearViewLabel(formatGregorianDateToLocaleString(navigatedDate, locale, { year: "numeric" }));
|
|
958
980
|
case "decade": return messages.decadeViewLabel(this.decadeStart(), this.decadeEnd());
|
|
959
981
|
}
|
|
@@ -997,10 +1019,15 @@ var CalendarComponent = class CalendarComponent {
|
|
|
997
1019
|
}, ...ngDevMode ? [{ debugName: "headerClass" }] : /* istanbul ignore next */ []);
|
|
998
1020
|
this.headerMonthYear = computed(() => {
|
|
999
1021
|
const locale = this.#i18n.localeId();
|
|
1000
|
-
|
|
1022
|
+
const options = {
|
|
1001
1023
|
year: "numeric",
|
|
1002
1024
|
month: "long"
|
|
1003
|
-
}
|
|
1025
|
+
};
|
|
1026
|
+
const count = this.months();
|
|
1027
|
+
if (count === 1) return formatGregorianDateToLocaleString(this.navigatedDate(), locale, options);
|
|
1028
|
+
const first = this.viewStart();
|
|
1029
|
+
const last = DateTime.fromJSDate(first).plus({ months: count - 1 }).toJSDate();
|
|
1030
|
+
return formatGregorianDateRangeToLocaleString(first, last, locale, options);
|
|
1004
1031
|
}, ...ngDevMode ? [{ debugName: "headerMonthYear" }] : /* istanbul ignore next */ []);
|
|
1005
1032
|
this.headerYear = computed(() => {
|
|
1006
1033
|
const locale = this.#i18n.localeId();
|
|
@@ -1018,34 +1045,54 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1018
1045
|
return (date) => isOutOfRange(date) || keys.has(toDayKey(date));
|
|
1019
1046
|
}, ...ngDevMode ? [{ debugName: "isDayUnavailable" }] : /* istanbul ignore next */ []);
|
|
1020
1047
|
this.messages = this.#i18n.componentMessages("calendar", CALENDAR_DEFAULT_MESSAGES);
|
|
1021
|
-
this.
|
|
1022
|
-
const navigatedDate = this.navigatedDate();
|
|
1023
|
-
const firstDayOfMonth = gregorianDateTime(navigatedDate, this.#i18n.localeId()).startOf("month");
|
|
1024
|
-
const lastDayOfMonth = gregorianDateTime(navigatedDate, this.#i18n.localeId()).endOf("month");
|
|
1025
|
-
return {
|
|
1026
|
-
start: firstDayOfMonth.toJSDate(),
|
|
1027
|
-
end: lastDayOfMonth.toJSDate()
|
|
1028
|
-
};
|
|
1029
|
-
}, ...ngDevMode ? [{ debugName: "monthBounds" }] : /* istanbul ignore next */ []);
|
|
1048
|
+
this.monthCaptionClass = calendarMonthCaptionThemeVariants();
|
|
1030
1049
|
this.monthCellTemplate = contentChild(CalendarMonthCellTemplateDirective, ...ngDevMode ? [{ debugName: "monthCellTemplate" }] : /* istanbul ignore next */ []);
|
|
1031
|
-
this.monthDictChunked = computed(() => {
|
|
1032
|
-
return this.#monthDict().chunk(7).select((e) => e.toImmutableDictionary((e) => e.key, (e) => e.value)).toImmutableSet();
|
|
1033
|
-
}, ...ngDevMode ? [{ debugName: "monthDictChunked" }] : /* istanbul ignore next */ []);
|
|
1034
1050
|
this.monthGridClass = computed(() => {
|
|
1035
1051
|
return calendarMonthViewGridThemeVariants();
|
|
1036
1052
|
}, ...ngDevMode ? [{ debugName: "monthGridClass" }] : /* istanbul ignore next */ []);
|
|
1037
1053
|
this.monthGridHeaderClass = computed(() => {
|
|
1038
1054
|
return calendarMonthViewGridHeaderThemeVariants();
|
|
1039
1055
|
}, ...ngDevMode ? [{ debugName: "monthGridHeaderClass" }] : /* istanbul ignore next */ []);
|
|
1040
|
-
this.
|
|
1056
|
+
this.monthGrids = computed(() => {
|
|
1041
1057
|
const locale = this.#i18n.localeId();
|
|
1042
|
-
const
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1058
|
+
const count = this.months();
|
|
1059
|
+
const firstDayIso = FIRST_DAY_OF_WEEK_TO_ISO[this.effectiveFirstDay()];
|
|
1060
|
+
const lastDayOfWeekIso = (firstDayIso + 5) % 7 + 1;
|
|
1061
|
+
const start = gregorianDateTime(this.viewStart(), locale).startOf("month");
|
|
1062
|
+
return range(0, count).select((offset) => {
|
|
1063
|
+
const firstDayOfMonth = start.plus({ months: offset });
|
|
1064
|
+
const lastDayOfMonth = firstDayOfMonth.endOf("month");
|
|
1065
|
+
const firstDayOfGrid = firstDayOfMonth.minus({ days: (firstDayOfMonth.weekday - firstDayIso + 7) % 7 });
|
|
1066
|
+
const lastDayOfGrid = lastDayOfMonth.plus({ days: (lastDayOfWeekIso - lastDayOfMonth.weekday + 7) % 7 });
|
|
1067
|
+
const days = [];
|
|
1068
|
+
for (let day = firstDayOfGrid; day <= lastDayOfGrid; day = day.plus({ days: 1 })) {
|
|
1069
|
+
const blank = count > 1 && !day.hasSame(firstDayOfMonth, "month");
|
|
1070
|
+
days.push(blank ? null : {
|
|
1071
|
+
key: day.toJSDate(),
|
|
1072
|
+
value: day.day
|
|
1073
|
+
});
|
|
1074
|
+
}
|
|
1075
|
+
const weeks = range(0, days.length / 7).select((week) => {
|
|
1076
|
+
const firstDay = firstDayOfGrid.plus({ weeks: week });
|
|
1077
|
+
return {
|
|
1078
|
+
days: days.slice(week * 7, week * 7 + 7),
|
|
1079
|
+
key: firstDay.toMillis(),
|
|
1080
|
+
weekNumber: this.getWeekNumber(firstDay.toJSDate())
|
|
1081
|
+
};
|
|
1082
|
+
}).toArray();
|
|
1083
|
+
return {
|
|
1084
|
+
bounds: [firstDayOfMonth.toJSDate(), lastDayOfMonth.toJSDate()],
|
|
1085
|
+
caption: formatGregorianDateToLocaleString(firstDayOfMonth.toJSDate(), locale, {
|
|
1086
|
+
year: "numeric",
|
|
1087
|
+
month: "long"
|
|
1088
|
+
}),
|
|
1089
|
+
captionId: `${this.gridId}-month-${offset}`,
|
|
1090
|
+
key: firstDayOfMonth.toMillis(),
|
|
1091
|
+
weeks
|
|
1092
|
+
};
|
|
1093
|
+
}).toArray();
|
|
1094
|
+
}, ...ngDevMode ? [{ debugName: "monthGrids" }] : /* istanbul ignore next */ []);
|
|
1095
|
+
this.monthViewClass = calendarMonthViewThemeVariants();
|
|
1049
1096
|
this.navigatedDate = signal(startOfDay(/* @__PURE__ */ new Date()), ...ngDevMode ? [{ debugName: "navigatedDate" }] : /* istanbul ignore next */ []);
|
|
1050
1097
|
this.nextButtonLabel = computed(() => {
|
|
1051
1098
|
const view = this.calendarView();
|
|
@@ -1066,6 +1113,15 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1066
1113
|
case "decade": return messages.previousDecade;
|
|
1067
1114
|
}
|
|
1068
1115
|
}, ...ngDevMode ? [{ debugName: "prevButtonLabel" }] : /* istanbul ignore next */ []);
|
|
1116
|
+
this.rangeEnds = computed(() => {
|
|
1117
|
+
if (this.selection() !== "range") return null;
|
|
1118
|
+
const first = firstOrDefault(this.selectedDates());
|
|
1119
|
+
const last = lastOrDefault(this.selectedDates());
|
|
1120
|
+
return first && last ? {
|
|
1121
|
+
start: toDayKey(first),
|
|
1122
|
+
end: toDayKey(last)
|
|
1123
|
+
} : null;
|
|
1124
|
+
}, ...ngDevMode ? [{ debugName: "rangeEnds" }] : /* istanbul ignore next */ []);
|
|
1069
1125
|
this.rangePreviewDate = signal(null, ...ngDevMode ? [{ debugName: "rangePreviewDate" }] : /* istanbul ignore next */ []);
|
|
1070
1126
|
this.rangePreviewDates = computed(() => {
|
|
1071
1127
|
if (this.selection() !== "range") return [];
|
|
@@ -1099,16 +1155,31 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1099
1155
|
return this.messages().goToToday(todayStr);
|
|
1100
1156
|
}, ...ngDevMode ? [{ debugName: "todayButtonLabel" }] : /* istanbul ignore next */ []);
|
|
1101
1157
|
this.todayUnavailable = computed(() => this.isDayUnavailable()(this.today()), ...ngDevMode ? [{ debugName: "todayUnavailable" }] : /* istanbul ignore next */ []);
|
|
1158
|
+
this.viewStart = linkedSignal({
|
|
1159
|
+
...ngDevMode ? { debugName: "viewStart" } : /* istanbul ignore next */ {},
|
|
1160
|
+
source: () => ({
|
|
1161
|
+
count: this.months(),
|
|
1162
|
+
date: this.navigatedDate()
|
|
1163
|
+
}),
|
|
1164
|
+
computation: (source, previous) => {
|
|
1165
|
+
const month = DateTime.fromJSDate(source.date).startOf("month");
|
|
1166
|
+
if (previous) {
|
|
1167
|
+
const first = DateTime.fromJSDate(previous.value);
|
|
1168
|
+
const last = first.plus({ months: source.count - 1 });
|
|
1169
|
+
if (month < first) return month.toJSDate();
|
|
1170
|
+
if (month > last) return month.minus({ months: source.count - 1 }).toJSDate();
|
|
1171
|
+
return previous.value;
|
|
1172
|
+
}
|
|
1173
|
+
return month.toJSDate();
|
|
1174
|
+
}
|
|
1175
|
+
});
|
|
1102
1176
|
this.viewSwitchButtonLabel = computed(() => {
|
|
1103
1177
|
const view = this.calendarView();
|
|
1104
1178
|
const locale = this.#i18n.localeId();
|
|
1105
1179
|
const navigatedDate = this.navigatedDate();
|
|
1106
1180
|
const messages = this.messages();
|
|
1107
1181
|
switch (view) {
|
|
1108
|
-
case "month": return messages.switchToYearView(
|
|
1109
|
-
year: "numeric",
|
|
1110
|
-
month: "long"
|
|
1111
|
-
}));
|
|
1182
|
+
case "month": return messages.switchToYearView(this.headerMonthYear());
|
|
1112
1183
|
case "year": return messages.switchToDecadeView(formatGregorianDateToLocaleString(navigatedDate, locale, { year: "numeric" }));
|
|
1113
1184
|
case "decade": return messages.decadeRange(this.decadeStart(), this.decadeEnd());
|
|
1114
1185
|
}
|
|
@@ -1140,6 +1211,15 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1140
1211
|
this.yearGridClass = computed(() => {
|
|
1141
1212
|
return calendarYearViewGridThemeVariants();
|
|
1142
1213
|
}, ...ngDevMode ? [{ debugName: "yearGridClass" }] : /* istanbul ignore next */ []);
|
|
1214
|
+
this.yearViewMonths = computed(() => {
|
|
1215
|
+
const locale = this.#i18n.localeId();
|
|
1216
|
+
const names = range(1, 12).select((m) => gregorianDateTimeFromObject({
|
|
1217
|
+
year: 2024,
|
|
1218
|
+
month: m,
|
|
1219
|
+
day: 1
|
|
1220
|
+
}, locale).toFormat("LLL")).toArray();
|
|
1221
|
+
return index(names).chunk(3).select((e) => e.select((m) => [m[0] + 1, m[1]]).toImmutableSet()).toImmutableSet();
|
|
1222
|
+
}, ...ngDevMode ? [{ debugName: "yearViewMonths" }] : /* istanbul ignore next */ []);
|
|
1143
1223
|
this.disabled = input(false, {
|
|
1144
1224
|
...ngDevMode ? { debugName: "disabled" } : /* istanbul ignore next */ {},
|
|
1145
1225
|
transform: booleanAttribute
|
|
@@ -1156,6 +1236,10 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1156
1236
|
});
|
|
1157
1237
|
this.maxDate = input(...ngDevMode ? [void 0, { debugName: "maxDate" }] : /* istanbul ignore next */ []);
|
|
1158
1238
|
this.minDate = input(...ngDevMode ? [void 0, { debugName: "minDate" }] : /* istanbul ignore next */ []);
|
|
1239
|
+
this.months = input(1, {
|
|
1240
|
+
...ngDevMode ? { debugName: "months" } : /* istanbul ignore next */ {},
|
|
1241
|
+
transform: monthCount
|
|
1242
|
+
});
|
|
1159
1243
|
this.readonly = input(false, {
|
|
1160
1244
|
...ngDevMode ? { debugName: "readonly" } : /* istanbul ignore next */ {},
|
|
1161
1245
|
transform: booleanAttribute
|
|
@@ -1196,8 +1280,15 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1196
1280
|
effect(() => {
|
|
1197
1281
|
const v = this.value();
|
|
1198
1282
|
untracked(() => {
|
|
1283
|
+
if (this.selection() === "range") {
|
|
1284
|
+
this.pendingRangeStart.set(Array.isArray(v) && v.length === 1 ? startOfDay(v[0]) : null);
|
|
1285
|
+
this.rangePreviewDate.set(null);
|
|
1286
|
+
}
|
|
1199
1287
|
const lastDate = Array.isArray(v) ? lastOrDefault(v) : v;
|
|
1200
|
-
if (lastDate)
|
|
1288
|
+
if (lastDate) {
|
|
1289
|
+
this.navigatedDate.set(lastDate);
|
|
1290
|
+
this.showSelectionStart(Array.isArray(v) ? firstOrDefault(v) : null, lastDate);
|
|
1291
|
+
}
|
|
1201
1292
|
});
|
|
1202
1293
|
});
|
|
1203
1294
|
toObservable(this.calendarView).pipe(skip(1)).subscribe(() => this.focusActiveCell());
|
|
@@ -1240,7 +1331,9 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1240
1331
|
this.touch.emit();
|
|
1241
1332
|
}
|
|
1242
1333
|
onMonthClick(month) {
|
|
1243
|
-
|
|
1334
|
+
const date = DateTime.fromJSDate(this.navigatedDate()).set({ month });
|
|
1335
|
+
this.navigatedDate.set(date.toJSDate());
|
|
1336
|
+
this.viewStart.set(date.startOf("month").toJSDate());
|
|
1244
1337
|
this.calendarView.set("month");
|
|
1245
1338
|
}
|
|
1246
1339
|
onMonthGridPointerLeave() {
|
|
@@ -1249,6 +1342,7 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1249
1342
|
onNavigationClick(direction) {
|
|
1250
1343
|
this.rangePreviewDate.set(null);
|
|
1251
1344
|
const date = DateTime.fromJSDate(this.navigatedDate());
|
|
1345
|
+
const viewStart = DateTime.fromJSDate(this.viewStart());
|
|
1252
1346
|
let unit;
|
|
1253
1347
|
switch (this.calendarView()) {
|
|
1254
1348
|
case "month":
|
|
@@ -1260,6 +1354,7 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1260
1354
|
case "decade": unit = { years: 10 };
|
|
1261
1355
|
}
|
|
1262
1356
|
this.navigatedDate.set(direction === "prev" ? date.minus(unit).toJSDate() : date.plus(unit).toJSDate());
|
|
1357
|
+
if (this.calendarView() === "month") this.viewStart.set(viewStart.plus({ months: direction === "prev" ? -1 : 1 }).toJSDate());
|
|
1263
1358
|
}
|
|
1264
1359
|
onTodayButtonClick() {
|
|
1265
1360
|
this.refreshToday();
|
|
@@ -1673,6 +1768,13 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1673
1768
|
setupKeyboardNavigation() {
|
|
1674
1769
|
fromEvent(this.#hostElementRef.nativeElement, "keydown").pipe(takeUntilDestroyed(this.#destroyRef)).subscribe((event) => this.handleKeydown(event));
|
|
1675
1770
|
}
|
|
1771
|
+
showSelectionStart(firstDate, lastDate) {
|
|
1772
|
+
const count = this.months();
|
|
1773
|
+
if (!firstDate || count === 1) return;
|
|
1774
|
+
const firstMonth = DateTime.fromJSDate(firstDate).startOf("month");
|
|
1775
|
+
const earliestStart = DateTime.fromJSDate(lastDate).startOf("month").minus({ months: count - 1 });
|
|
1776
|
+
this.viewStart.set((firstMonth > earliestStart ? firstMonth : earliestStart).toJSDate());
|
|
1777
|
+
}
|
|
1676
1778
|
switchToLowerView() {
|
|
1677
1779
|
switch (this.calendarView()) {
|
|
1678
1780
|
case "decade":
|
|
@@ -1766,6 +1868,13 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1766
1868
|
isRequired: false,
|
|
1767
1869
|
transformFunction: null
|
|
1768
1870
|
},
|
|
1871
|
+
months: {
|
|
1872
|
+
classPropertyName: "months",
|
|
1873
|
+
publicName: "months",
|
|
1874
|
+
isSignal: true,
|
|
1875
|
+
isRequired: false,
|
|
1876
|
+
transformFunction: null
|
|
1877
|
+
},
|
|
1769
1878
|
readonly: {
|
|
1770
1879
|
classPropertyName: "readonly",
|
|
1771
1880
|
publicName: "readonly",
|
|
@@ -1864,7 +1973,7 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1864
1973
|
}
|
|
1865
1974
|
],
|
|
1866
1975
|
ngImport: i0,
|
|
1867
|
-
template: "<div [class]=\"headerClass()\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled() || todayUnavailable()\"\n (click)=\"onTodayButtonClick()\"\n [attr.aria-label]=\"todayButtonLabel()\">\n <span>{{ messages().today }}</span>\n </button>\n @switch (calendarView()) {\n @case (\"month\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('year')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerMonthYear()\n }}</span>\n </button>\n }\n @case (\"year\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('decade')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerYear()\n }}</span>\n </button>\n }\n @case (\"decade\") {\n <!-- The decade is the top view, so its heading isn't a button. It names the grid with the locale's\n wording of the range, and shows the digits. -->\n <span\n class=\"text-primary inline-flex h-9 items-center px-4 text-sm font-semibold\"\n [id]=\"gridId + '-heading'\"\n ><span aria-hidden=\"true\">{{ formatInteger(decadeStart()) }} - {{ formatInteger(decadeEnd()) }}</span\n ><span class=\"sr-only\">{{ viewSwitchButtonLabel() }}</span></span\n >\n }\n }\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('prev')\"\n [attr.aria-label]=\"prevButtonLabel()\">\n <svg lucideChevronLeft class=\"rtl:rotate-180\"></svg>\n </button>\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('next')\"\n [attr.aria-label]=\"nextButtonLabel()\">\n <svg lucideChevronRight class=\"rtl:rotate-180\"></svg>\n </button>\n</div>\n\n<div aria-live=\"polite\" aria-atomic=\"true\" class=\"sr-only\">{{ ariaLabel() }}</div>\n\n@if (calendarView() === \"month\") {\n @let columnCount = weekNumber() ? 8 : 7;\n <div\n role=\"grid\"\n class=\"flex flex-col gap-0.5\"\n [attr.aria-labelledby]=\"gridId + '-heading'\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (pointerleave)=\"onMonthGridPointerLeave()\">\n <div role=\"row\" [class]=\"monthGridHeaderClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n <!-- Week numbers are visual only: every day is already named by its full date. -->\n <div aria-hidden=\"true\"></div>\n }\n @for (day of weekdays(); track day.full) {\n <div role=\"columnheader\">\n <span aria-hidden=\"true\">{{ day.display }}</span>\n <span class=\"sr-only\">{{ day.full }}</span>\n </div>\n }\n </div>\n @for (row of monthDictChunked(); track $index) {\n <div role=\"row\" [class]=\"monthGridClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n @let firstEntry = row | monaTakeFirst;\n @if (firstEntry) {\n @let week = getWeekNumber(firstEntry.key);\n <div aria-hidden=\"true\">{{ formatInteger(week) }}</div>\n }\n }\n <!-- Track by time: the month is rebuilt with new Date objects on every navigation. -->\n @for (entry of row; track entry.key.getTime()) {\n <div\n (dayPointerEnter)=\"onDayPointerEnter($event)\"\n (daySelect)=\"onDayClick($event.date, $event.event)\"\n monaMonthDay\n [disabled]=\"effectiveDisabled()\"\n [isDayUnavailable]=\"isDayUnavailable()\"\n [monthBounds]=\"[monthBounds().start, monthBounds().end]\"\n [navigatedDate]=\"navigatedDate()\"\n [rangePreviewKeys]=\"rangePreviewKeys()\"\n [rounded]=\"rounded()\"\n [selectedKeys]=\"selectedKeys()\"\n [today]=\"today()\"\n [entry]=\"entry\">\n @if (monthCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"monthCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: entry.value, date: entry.key }\"></ng-container>\n } @else {\n <span>{{ formatInteger(entry.value) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"year\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of months(); track $index) {\n <div role=\"row\" [class]=\"yearGridClass()\">\n @for (monthItem of row; track monthItem) {\n <div\n (click)=\"!effectiveDisabled() && onMonthClick(monthItem[0])\"\n monaYearMonth\n [disabled]=\"effectiveDisabled()\"\n [month]=\"monthItem[0]\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (yearCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"yearCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: monthItem[0], text: monthItem[1] }\">\n </ng-container>\n } @else {\n <span>{{ monthItem[1] }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"decade\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of decadeYears(); track $index) {\n <div role=\"row\" [class]=\"decadeGridClass()\">\n @for (year of row; track year) {\n <div\n (click)=\"!effectiveDisabled() && onYearClick(year)\"\n monaDecadeYear\n [disabled]=\"effectiveDisabled()\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [year]=\"year\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (decadeCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"decadeCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: year }\">\n </ng-container>\n } @else {\n <span>{{ formatInteger(year) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n}\n",
|
|
1976
|
+
template: "<div [class]=\"headerClass()\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled() || todayUnavailable()\"\n (click)=\"onTodayButtonClick()\"\n [attr.aria-label]=\"todayButtonLabel()\">\n <span>{{ messages().today }}</span>\n </button>\n @switch (calendarView()) {\n @case (\"month\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('year')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerMonthYear()\n }}</span>\n </button>\n }\n @case (\"year\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('decade')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerYear()\n }}</span>\n </button>\n }\n @case (\"decade\") {\n <!-- The decade is the top view, so its heading isn't a button. It names the grid with the locale's\n wording of the range, and shows the digits. -->\n <span\n class=\"text-primary inline-flex h-9 items-center px-4 text-sm font-semibold\"\n [id]=\"gridId + '-heading'\"\n ><span aria-hidden=\"true\">{{ formatInteger(decadeStart()) }} - {{ formatInteger(decadeEnd()) }}</span\n ><span class=\"sr-only\">{{ viewSwitchButtonLabel() }}</span></span\n >\n }\n }\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('prev')\"\n [attr.aria-label]=\"prevButtonLabel()\">\n <svg lucideChevronLeft class=\"rtl:rotate-180\"></svg>\n </button>\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('next')\"\n [attr.aria-label]=\"nextButtonLabel()\">\n <svg lucideChevronRight class=\"rtl:rotate-180\"></svg>\n </button>\n</div>\n\n<div aria-live=\"polite\" aria-atomic=\"true\" class=\"sr-only\">{{ ariaLabel() }}</div>\n\n@if (calendarView() === \"month\") {\n @let columnCount = weekNumber() ? 8 : 7;\n @let multipleMonths = monthGrids().length > 1;\n <div [class]=\"monthViewClass\">\n @for (grid of monthGrids(); track grid.key) {\n <div class=\"flex flex-col\">\n @if (multipleMonths) {\n <div [class]=\"monthCaptionClass\" [id]=\"grid.captionId\">{{ grid.caption }}</div>\n }\n <div\n role=\"grid\"\n class=\"flex flex-col gap-0.5\"\n [attr.aria-labelledby]=\"multipleMonths ? grid.captionId : gridId + '-heading'\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (pointerleave)=\"onMonthGridPointerLeave()\">\n <div\n role=\"row\"\n [class]=\"monthGridHeaderClass()\"\n [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n <!-- Week numbers are visual only: every day is already named by its full date. -->\n <div aria-hidden=\"true\"></div>\n }\n @for (day of weekdays(); track day.full) {\n <div role=\"columnheader\">\n <span aria-hidden=\"true\">{{ day.display }}</span>\n <span class=\"sr-only\">{{ day.full }}</span>\n </div>\n }\n </div>\n @for (week of grid.weeks; track week.key) {\n <div\n role=\"row\"\n [class]=\"monthGridClass()\"\n [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n <div aria-hidden=\"true\">{{ formatInteger(week.weekNumber) }}</div>\n }\n <!-- Track by time: the months are rebuilt with new Date objects on every navigation. -->\n @for (entry of week.days; track entry ? entry.key.getTime() : -$index - 1) {\n @if (entry) {\n <div\n (dayPointerEnter)=\"onDayPointerEnter($event)\"\n (daySelect)=\"onDayClick($event.date, $event.event)\"\n monaMonthDay\n [disabled]=\"effectiveDisabled()\"\n [isDayUnavailable]=\"isDayUnavailable()\"\n [monthBounds]=\"grid.bounds\"\n [navigatedDate]=\"navigatedDate()\"\n [rangeEnds]=\"rangeEnds()\"\n [rangePreviewKeys]=\"rangePreviewKeys()\"\n [rounded]=\"rounded()\"\n [selectedKeys]=\"selectedKeys()\"\n [today]=\"today()\"\n [entry]=\"entry\">\n @if (monthCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"monthCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{\n $implicit: entry.value,\n date: entry.key\n }\"></ng-container>\n } @else {\n <span>{{ formatInteger(entry.value) }}</span>\n }\n </div>\n } @else {\n <!-- A day of the month before or after, shown in its own month instead. -->\n <div role=\"gridcell\"></div>\n }\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n} @else if (calendarView() === \"year\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of yearViewMonths(); track $index) {\n <div role=\"row\" [class]=\"yearGridClass()\">\n @for (monthItem of row; track monthItem) {\n <div\n (click)=\"!effectiveDisabled() && onMonthClick(monthItem[0])\"\n monaYearMonth\n [disabled]=\"effectiveDisabled()\"\n [month]=\"monthItem[0]\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (yearCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"yearCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: monthItem[0], text: monthItem[1] }\">\n </ng-container>\n } @else {\n <span>{{ monthItem[1] }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"decade\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of decadeYears(); track $index) {\n <div role=\"row\" [class]=\"decadeGridClass()\">\n @for (year of row; track year) {\n <div\n (click)=\"!effectiveDisabled() && onYearClick(year)\"\n monaDecadeYear\n [disabled]=\"effectiveDisabled()\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [year]=\"year\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (decadeCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"decadeCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: year }\">\n </ng-container>\n } @else {\n <span>{{ formatInteger(year) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n}\n",
|
|
1868
1977
|
dependencies: [
|
|
1869
1978
|
{
|
|
1870
1979
|
kind: "directive",
|
|
@@ -1897,6 +2006,7 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1897
2006
|
"isDayUnavailable",
|
|
1898
2007
|
"monthBounds",
|
|
1899
2008
|
"navigatedDate",
|
|
2009
|
+
"rangeEnds",
|
|
1900
2010
|
"rangePreviewKeys",
|
|
1901
2011
|
"rounded",
|
|
1902
2012
|
"selectedKeys",
|
|
@@ -1947,11 +2057,6 @@ var CalendarComponent = class CalendarComponent {
|
|
|
1947
2057
|
kind: "component",
|
|
1948
2058
|
type: LucideChevronRight,
|
|
1949
2059
|
selector: "svg[lucideChevronRight]"
|
|
1950
|
-
},
|
|
1951
|
-
{
|
|
1952
|
-
kind: "pipe",
|
|
1953
|
-
type: TakeFirstPipe,
|
|
1954
|
-
name: "monaTakeFirst"
|
|
1955
2060
|
}
|
|
1956
2061
|
]
|
|
1957
2062
|
});
|
|
@@ -1972,7 +2077,6 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1972
2077
|
DecadeYearDirective,
|
|
1973
2078
|
YearMonthDirective,
|
|
1974
2079
|
NgTemplateOutlet,
|
|
1975
|
-
TakeFirstPipe,
|
|
1976
2080
|
LucideChevronLeft,
|
|
1977
2081
|
LucideChevronRight
|
|
1978
2082
|
],
|
|
@@ -1985,7 +2089,7 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
1985
2089
|
"(focusin)": "refreshToday()",
|
|
1986
2090
|
"(focusout)": "onFocusOut($event)"
|
|
1987
2091
|
},
|
|
1988
|
-
template: "<div [class]=\"headerClass()\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled() || todayUnavailable()\"\n (click)=\"onTodayButtonClick()\"\n [attr.aria-label]=\"todayButtonLabel()\">\n <span>{{ messages().today }}</span>\n </button>\n @switch (calendarView()) {\n @case (\"month\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('year')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerMonthYear()\n }}</span>\n </button>\n }\n @case (\"year\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('decade')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerYear()\n }}</span>\n </button>\n }\n @case (\"decade\") {\n <!-- The decade is the top view, so its heading isn't a button. It names the grid with the locale's\n wording of the range, and shows the digits. -->\n <span\n class=\"text-primary inline-flex h-9 items-center px-4 text-sm font-semibold\"\n [id]=\"gridId + '-heading'\"\n ><span aria-hidden=\"true\">{{ formatInteger(decadeStart()) }} - {{ formatInteger(decadeEnd()) }}</span\n ><span class=\"sr-only\">{{ viewSwitchButtonLabel() }}</span></span\n >\n }\n }\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('prev')\"\n [attr.aria-label]=\"prevButtonLabel()\">\n <svg lucideChevronLeft class=\"rtl:rotate-180\"></svg>\n </button>\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('next')\"\n [attr.aria-label]=\"nextButtonLabel()\">\n <svg lucideChevronRight class=\"rtl:rotate-180\"></svg>\n </button>\n</div>\n\n<div aria-live=\"polite\" aria-atomic=\"true\" class=\"sr-only\">{{ ariaLabel() }}</div>\n\n@if (calendarView() === \"month\") {\n @let columnCount = weekNumber() ? 8 : 7;\n <div\n role=\"grid\"\n class=\"flex flex-col gap-0.5\"\n [attr.aria-labelledby]=\"gridId + '-heading'\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (pointerleave)=\"onMonthGridPointerLeave()\">\n <div role=\"row\" [class]=\"monthGridHeaderClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n <!-- Week numbers are visual only: every day is already named by its full date. -->\n <div aria-hidden=\"true\"></div>\n }\n @for (day of weekdays(); track day.full) {\n <div role=\"columnheader\">\n <span aria-hidden=\"true\">{{ day.display }}</span>\n <span class=\"sr-only\">{{ day.full }}</span>\n </div>\n }\n </div>\n @for (row of monthDictChunked(); track $index) {\n <div role=\"row\" [class]=\"monthGridClass()\" [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n @let firstEntry = row | monaTakeFirst;\n @if (firstEntry) {\n @let week = getWeekNumber(firstEntry.key);\n <div aria-hidden=\"true\">{{ formatInteger(week) }}</div>\n }\n }\n <!-- Track by time: the month is rebuilt with new Date objects on every navigation. -->\n @for (entry of row; track entry.key.getTime()) {\n <div\n (dayPointerEnter)=\"onDayPointerEnter($event)\"\n (daySelect)=\"onDayClick($event.date, $event.event)\"\n monaMonthDay\n [disabled]=\"effectiveDisabled()\"\n [isDayUnavailable]=\"isDayUnavailable()\"\n [monthBounds]=\"[monthBounds().start, monthBounds().end]\"\n [navigatedDate]=\"navigatedDate()\"\n [rangePreviewKeys]=\"rangePreviewKeys()\"\n [rounded]=\"rounded()\"\n [selectedKeys]=\"selectedKeys()\"\n [today]=\"today()\"\n [entry]=\"entry\">\n @if (monthCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"monthCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: entry.value, date: entry.key }\"></ng-container>\n } @else {\n <span>{{ formatInteger(entry.value) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"year\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of months(); track $index) {\n <div role=\"row\" [class]=\"yearGridClass()\">\n @for (monthItem of row; track monthItem) {\n <div\n (click)=\"!effectiveDisabled() && onMonthClick(monthItem[0])\"\n monaYearMonth\n [disabled]=\"effectiveDisabled()\"\n [month]=\"monthItem[0]\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (yearCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"yearCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: monthItem[0], text: monthItem[1] }\">\n </ng-container>\n } @else {\n <span>{{ monthItem[1] }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"decade\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of decadeYears(); track $index) {\n <div role=\"row\" [class]=\"decadeGridClass()\">\n @for (year of row; track year) {\n <div\n (click)=\"!effectiveDisabled() && onYearClick(year)\"\n monaDecadeYear\n [disabled]=\"effectiveDisabled()\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [year]=\"year\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (decadeCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"decadeCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: year }\">\n </ng-container>\n } @else {\n <span>{{ formatInteger(year) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n}\n"
|
|
2092
|
+
template: "<div [class]=\"headerClass()\">\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled() || todayUnavailable()\"\n (click)=\"onTodayButtonClick()\"\n [attr.aria-label]=\"todayButtonLabel()\">\n <span>{{ messages().today }}</span>\n </button>\n @switch (calendarView()) {\n @case (\"month\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('year')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerMonthYear()\n }}</span>\n </button>\n }\n @case (\"year\") {\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onViewChangeClick('decade')\"\n [attr.aria-label]=\"viewSwitchButtonLabel()\">\n <span class=\"text-primary font-semibold\" [id]=\"gridId + '-heading'\">{{\n headerYear()\n }}</span>\n </button>\n }\n @case (\"decade\") {\n <!-- The decade is the top view, so its heading isn't a button. It names the grid with the locale's\n wording of the range, and shows the digits. -->\n <span\n class=\"text-primary inline-flex h-9 items-center px-4 text-sm font-semibold\"\n [id]=\"gridId + '-heading'\"\n ><span aria-hidden=\"true\">{{ formatInteger(decadeStart()) }} - {{ formatInteger(decadeEnd()) }}</span\n ><span class=\"sr-only\">{{ viewSwitchButtonLabel() }}</span></span\n >\n }\n }\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('prev')\"\n [attr.aria-label]=\"prevButtonLabel()\">\n <svg lucideChevronLeft class=\"rtl:rotate-180\"></svg>\n </button>\n <button\n monaButton\n look=\"ghost\"\n [rounded]=\"rounded()\"\n [iconOnly]=\"true\"\n [size]=\"'small'\"\n [disabled]=\"effectiveDisabled()\"\n (click)=\"onNavigationClick('next')\"\n [attr.aria-label]=\"nextButtonLabel()\">\n <svg lucideChevronRight class=\"rtl:rotate-180\"></svg>\n </button>\n</div>\n\n<div aria-live=\"polite\" aria-atomic=\"true\" class=\"sr-only\">{{ ariaLabel() }}</div>\n\n@if (calendarView() === \"month\") {\n @let columnCount = weekNumber() ? 8 : 7;\n @let multipleMonths = monthGrids().length > 1;\n <div [class]=\"monthViewClass\">\n @for (grid of monthGrids(); track grid.key) {\n <div class=\"flex flex-col\">\n @if (multipleMonths) {\n <div [class]=\"monthCaptionClass\" [id]=\"grid.captionId\">{{ grid.caption }}</div>\n }\n <div\n role=\"grid\"\n class=\"flex flex-col gap-0.5\"\n [attr.aria-labelledby]=\"multipleMonths ? grid.captionId : gridId + '-heading'\"\n [attr.aria-disabled]=\"effectiveDisabled() || null\"\n [attr.aria-invalid]=\"invalidState() ? 'true' : null\"\n [attr.aria-readonly]=\"readonly() || null\"\n (pointerleave)=\"onMonthGridPointerLeave()\">\n <div\n role=\"row\"\n [class]=\"monthGridHeaderClass()\"\n [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n <!-- Week numbers are visual only: every day is already named by its full date. -->\n <div aria-hidden=\"true\"></div>\n }\n @for (day of weekdays(); track day.full) {\n <div role=\"columnheader\">\n <span aria-hidden=\"true\">{{ day.display }}</span>\n <span class=\"sr-only\">{{ day.full }}</span>\n </div>\n }\n </div>\n @for (week of grid.weeks; track week.key) {\n <div\n role=\"row\"\n [class]=\"monthGridClass()\"\n [style.grid-template-columns]=\"`repeat(${columnCount}, 32px)`\">\n @if (weekNumber()) {\n <div aria-hidden=\"true\">{{ formatInteger(week.weekNumber) }}</div>\n }\n <!-- Track by time: the months are rebuilt with new Date objects on every navigation. -->\n @for (entry of week.days; track entry ? entry.key.getTime() : -$index - 1) {\n @if (entry) {\n <div\n (dayPointerEnter)=\"onDayPointerEnter($event)\"\n (daySelect)=\"onDayClick($event.date, $event.event)\"\n monaMonthDay\n [disabled]=\"effectiveDisabled()\"\n [isDayUnavailable]=\"isDayUnavailable()\"\n [monthBounds]=\"grid.bounds\"\n [navigatedDate]=\"navigatedDate()\"\n [rangeEnds]=\"rangeEnds()\"\n [rangePreviewKeys]=\"rangePreviewKeys()\"\n [rounded]=\"rounded()\"\n [selectedKeys]=\"selectedKeys()\"\n [today]=\"today()\"\n [entry]=\"entry\">\n @if (monthCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"monthCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{\n $implicit: entry.value,\n date: entry.key\n }\"></ng-container>\n } @else {\n <span>{{ formatInteger(entry.value) }}</span>\n }\n </div>\n } @else {\n <!-- A day of the month before or after, shown in its own month instead. -->\n <div role=\"gridcell\"></div>\n }\n }\n </div>\n }\n </div>\n </div>\n }\n </div>\n} @else if (calendarView() === \"year\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of yearViewMonths(); track $index) {\n <div role=\"row\" [class]=\"yearGridClass()\">\n @for (monthItem of row; track monthItem) {\n <div\n (click)=\"!effectiveDisabled() && onMonthClick(monthItem[0])\"\n monaYearMonth\n [disabled]=\"effectiveDisabled()\"\n [month]=\"monthItem[0]\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (yearCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"yearCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: monthItem[0], text: monthItem[1] }\">\n </ng-container>\n } @else {\n <span>{{ monthItem[1] }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n} @else if (calendarView() === \"decade\") {\n <div role=\"grid\" class=\"flex flex-col gap-0.5\" [attr.aria-labelledby]=\"gridId + '-heading'\">\n @for (row of decadeYears(); track $index) {\n <div role=\"row\" [class]=\"decadeGridClass()\">\n @for (year of row; track year) {\n <div\n (click)=\"!effectiveDisabled() && onYearClick(year)\"\n monaDecadeYear\n [disabled]=\"effectiveDisabled()\"\n [navigatedDate]=\"navigatedDate()\"\n [rounded]=\"rounded()\"\n [year]=\"year\"\n [selectedDate]=\"selectedDates()[0]\">\n @if (decadeCellTemplate()) {\n <ng-container\n [ngTemplateOutlet]=\"decadeCellTemplate()?.templateRef\"\n [ngTemplateOutletContext]=\"{ $implicit: year }\">\n </ng-container>\n } @else {\n <span>{{ formatInteger(year) }}</span>\n }\n </div>\n }\n </div>\n }\n </div>\n}\n"
|
|
1989
2093
|
}]
|
|
1990
2094
|
}],
|
|
1991
2095
|
ctorParameters: () => [],
|
|
@@ -2058,6 +2162,14 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
2058
2162
|
required: false
|
|
2059
2163
|
}]
|
|
2060
2164
|
}],
|
|
2165
|
+
months: [{
|
|
2166
|
+
type: i0.Input,
|
|
2167
|
+
args: [{
|
|
2168
|
+
isSignal: true,
|
|
2169
|
+
alias: "months",
|
|
2170
|
+
required: false
|
|
2171
|
+
}]
|
|
2172
|
+
}],
|
|
2061
2173
|
readonly: [{
|
|
2062
2174
|
type: i0.Input,
|
|
2063
2175
|
args: [{
|