mn-angular-lib 1.0.177 → 1.0.179

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.
Files changed (66) hide show
  1. package/fesm2022/mn-angular-lib-alert.mjs +535 -0
  2. package/fesm2022/mn-angular-lib-alert.mjs.map +1 -0
  3. package/fesm2022/mn-angular-lib-bottom-sheet.mjs +356 -0
  4. package/fesm2022/mn-angular-lib-bottom-sheet.mjs.map +1 -0
  5. package/fesm2022/mn-angular-lib-button.mjs +382 -0
  6. package/fesm2022/mn-angular-lib-button.mjs.map +1 -0
  7. package/fesm2022/mn-angular-lib-calendar-core.mjs +377 -0
  8. package/fesm2022/mn-angular-lib-calendar-core.mjs.map +1 -0
  9. package/fesm2022/mn-angular-lib-calendar.mjs +1513 -0
  10. package/fesm2022/mn-angular-lib-calendar.mjs.map +1 -0
  11. package/fesm2022/mn-angular-lib-collection.mjs +2277 -0
  12. package/fesm2022/mn-angular-lib-collection.mjs.map +1 -0
  13. package/fesm2022/mn-angular-lib-core.mjs +1232 -0
  14. package/fesm2022/mn-angular-lib-core.mjs.map +1 -0
  15. package/fesm2022/mn-angular-lib-display.mjs +728 -0
  16. package/fesm2022/mn-angular-lib-display.mjs.map +1 -0
  17. package/fesm2022/mn-angular-lib-forms.mjs +4260 -0
  18. package/fesm2022/mn-angular-lib-forms.mjs.map +1 -0
  19. package/fesm2022/mn-angular-lib-keyboard.mjs +195 -0
  20. package/fesm2022/mn-angular-lib-keyboard.mjs.map +1 -0
  21. package/fesm2022/mn-angular-lib-modal-core.mjs +945 -0
  22. package/fesm2022/mn-angular-lib-modal-core.mjs.map +1 -0
  23. package/fesm2022/mn-angular-lib-modal-ui.mjs +2016 -0
  24. package/fesm2022/mn-angular-lib-modal-ui.mjs.map +1 -0
  25. package/fesm2022/mn-angular-lib-modal.mjs +126 -0
  26. package/fesm2022/mn-angular-lib-modal.mjs.map +1 -0
  27. package/fesm2022/mn-angular-lib-rich-text-editor.mjs +275 -0
  28. package/fesm2022/mn-angular-lib-rich-text-editor.mjs.map +1 -0
  29. package/fesm2022/mn-angular-lib-segmented.mjs +246 -0
  30. package/fesm2022/mn-angular-lib-segmented.mjs.map +1 -0
  31. package/fesm2022/mn-angular-lib-tab.mjs +573 -0
  32. package/fesm2022/mn-angular-lib-tab.mjs.map +1 -0
  33. package/fesm2022/mn-angular-lib.mjs +21 -15509
  34. package/fesm2022/mn-angular-lib.mjs.map +1 -1
  35. package/package.json +66 -1
  36. package/src/lib/styles/index.css +2 -2
  37. package/types/mn-angular-lib-alert.d.ts +258 -0
  38. package/types/mn-angular-lib-bottom-sheet.d.ts +173 -0
  39. package/types/mn-angular-lib-button.d.ts +318 -0
  40. package/types/mn-angular-lib-calendar-core.d.ts +378 -0
  41. package/types/mn-angular-lib-calendar.d.ts +636 -0
  42. package/types/mn-angular-lib-collection.d.ts +1550 -0
  43. package/types/mn-angular-lib-core.d.ts +756 -0
  44. package/types/mn-angular-lib-display.d.ts +1075 -0
  45. package/types/mn-angular-lib-forms.d.ts +3235 -0
  46. package/types/mn-angular-lib-keyboard.d.ts +128 -0
  47. package/types/mn-angular-lib-modal-core.d.ts +1130 -0
  48. package/types/mn-angular-lib-modal-ui.d.ts +492 -0
  49. package/types/mn-angular-lib-modal.d.ts +27 -0
  50. package/types/mn-angular-lib-rich-text-editor.d.ts +157 -0
  51. package/types/mn-angular-lib-segmented.d.ts +395 -0
  52. package/types/mn-angular-lib-tab.d.ts +313 -0
  53. package/types/mn-angular-lib.d.ts +16 -10816
  54. /package/{src/lib/features → alert/src}/mn-alert/mn-alert-outlet/mn-alert-outlet.css +0 -0
  55. /package/{src/lib/features → bottom-sheet/src}/mn-bottom-sheet/mn-bottom-sheet.component.css +0 -0
  56. /package/{src/lib/features → button/src}/mn-skeleton/mn-skeleton.css +0 -0
  57. /package/{src/lib/features → collection/src}/mn-list/mn-list.component.css +0 -0
  58. /package/{src/lib/features → forms/src}/mn-checkbox/mn-checkbox.css +0 -0
  59. /package/{src/lib/features → forms/src}/mn-dropdown/mn-dropdown.css +0 -0
  60. /package/{src/lib/features → forms/src}/mn-multi-select/mn-multi-select.css +0 -0
  61. /package/{src/lib/features → keyboard/src}/mn-keyboard/mn-keyboard.component.css +0 -0
  62. /package/{src/lib/features → modal-ui/src}/mn-modal/components/mn-confirmation-body/mn-confirmation-body.component.css +0 -0
  63. /package/{src/lib/features → modal-ui/src}/mn-modal/components/mn-form-body/mn-form-body.component.css +0 -0
  64. /package/{src/lib/features → modal-ui/src}/mn-modal/components/mn-modal-shell/mn-modal-shell.component.css +0 -0
  65. /package/{src/lib/features → modal-ui/src}/mn-modal/components/mn-wizard-body/mn-wizard-body.component.css +0 -0
  66. /package/{src/lib/features → rich-text-editor/src}/mn-rich-text-editor/mn-rich-text-editor.component.css +0 -0
@@ -0,0 +1,1513 @@
1
+ import * as i0 from '@angular/core';
2
+ import { inject, ChangeDetectorRef, EventEmitter, Output, Input, Component, ViewContainerRef, ViewChild, DestroyRef, HostListener, input, output, Injector, ElementRef, viewChildren, signal, computed, linkedSignal, afterNextRender, ChangeDetectionStrategy } from '@angular/core';
3
+ import { CommonModule } from '@angular/common';
4
+ import * as i1 from '@angular/forms';
5
+ import { FormsModule } from '@angular/forms';
6
+ import { LucideDynamicIcon } from '@lucide/angular';
7
+ import { Subject, takeUntil, BehaviorSubject, skip } from 'rxjs';
8
+ import { DEFAULT_CALENDAR_CONFIG, DefaultCalendarDateFormatter, resolveCalendarConfig, CALENDAR_DATE_FORMATTER, CalendarEventLayoutService, CalendarUtility, CalendarView, MN_CALENDAR_CONFIG, CALENDAR_CONFIG, provideMnCalendarConfig } from 'mn-angular-lib/calendar-core';
9
+ import { MnLanguageService, lucideIcons } from 'mn-angular-lib/core';
10
+ import { MnButton } from 'mn-angular-lib/button';
11
+ import { MnDatetime } from 'mn-angular-lib/forms';
12
+ import * as lucide from 'lucide';
13
+ import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
14
+
15
+ /**
16
+ * Month grid view showing a 7×6 grid of day cells.
17
+ *
18
+ * Each cell displays the day number and up to 3 coloured dots representing
19
+ * events on that day. Clicking a cell emits `dayClicked`.
20
+ */
21
+ class CalendarMonthComponent {
22
+ lang = inject(MnLanguageService);
23
+ cdr = inject(ChangeDetectorRef);
24
+ /**
25
+ * Accessible name for this control. Resolved through the conventional
26
+ * `mnCalendar.monthView` key so an app can translate it, falling back to English when the
27
+ * key is not defined rather than leaking the raw key into the UI.
28
+ */
29
+ get monthViewLabel() {
30
+ return this.lang.translateIfPresent('mnCalendar.monthView') ?? 'Month view';
31
+ }
32
+ /** The date whose month is displayed. */
33
+ focusDay;
34
+ /** Observable that emits the full event list whenever it changes. */
35
+ eventsChanged;
36
+ /** Observable that emits when the focus day changes. */
37
+ focusDayChanged;
38
+ /** Resolved calendar configuration passed from the parent view. */
39
+ config;
40
+ /** Emits the date of a clicked day cell. */
41
+ dayClicked = new EventEmitter();
42
+ monthItems = [];
43
+ /** Short weekday column headers (e.g. "Mon"), kept compact for the narrow columns. */
44
+ weekdayLabels;
45
+ /** Word shown after the "+N" overflow count (e.g. "more"), from config. */
46
+ moreEventsLabel = DEFAULT_CALENDAR_CONFIG.moreEventsLabel;
47
+ events = [];
48
+ destroy$ = new Subject();
49
+ formatter;
50
+ constructor() {
51
+ this.formatter = new DefaultCalendarDateFormatter();
52
+ this.weekdayLabels = DEFAULT_CALENDAR_CONFIG.shortDayNames;
53
+ }
54
+ ngOnInit() {
55
+ const resolved = this.config ? resolveCalendarConfig(this.config) : { ...DEFAULT_CALENDAR_CONFIG };
56
+ this.weekdayLabels = resolved.shortDayNames;
57
+ this.moreEventsLabel = resolved.moreEventsLabel;
58
+ this.buildMonth();
59
+ // Both subscriptions mark the view: the grid is rebuilt into plain fields, so in a zoneless
60
+ // app nothing else tells Angular this component has to be re-rendered. Without it a month
61
+ // whose events arrive from a stream — a fetch, a parent seeding its list — stays blank until
62
+ // some unrelated interaction happens to trigger change detection.
63
+ if (this.eventsChanged) {
64
+ this.eventsChanged.pipe(takeUntil(this.destroy$)).subscribe(events => {
65
+ this.events = events;
66
+ this.buildMonth();
67
+ this.cdr.markForCheck();
68
+ });
69
+ }
70
+ if (this.focusDayChanged) {
71
+ this.focusDayChanged.pipe(takeUntil(this.destroy$)).subscribe(date => {
72
+ this.focusDay = date;
73
+ this.buildMonth();
74
+ this.cdr.markForCheck();
75
+ });
76
+ }
77
+ }
78
+ ngOnDestroy() {
79
+ this.destroy$.next();
80
+ this.destroy$.complete();
81
+ }
82
+ /** Emits the clicked day's date. */
83
+ onDayClick(date) {
84
+ this.dayClicked.emit(date);
85
+ }
86
+ /** trackBy for day name headers. */
87
+ trackByDayName(index) {
88
+ return index;
89
+ }
90
+ /** trackBy for month grid cells. */
91
+ trackByMonthItem(_index, item) {
92
+ return item.date.getTime();
93
+ }
94
+ /** trackBy for event dots. */
95
+ trackByEventDot(_index, event) {
96
+ return event.id;
97
+ }
98
+ /** Builds the 42-cell month grid (6 rows × 7 columns). */
99
+ buildMonth() {
100
+ if (!this.focusDay)
101
+ return;
102
+ const year = this.focusDay.getFullYear();
103
+ const month = this.focusDay.getMonth();
104
+ const firstDay = new Date(year, month, 1);
105
+ const lastDay = new Date(year, month + 1, 0);
106
+ let startOffset = firstDay.getDay() - 1;
107
+ if (startOffset < 0)
108
+ startOffset = 6;
109
+ const today = new Date();
110
+ this.monthItems = [];
111
+ for (let i = startOffset - 1; i >= 0; i--) {
112
+ const date = new Date(year, month, -i);
113
+ this.monthItems.push(this.createMonthItem(date, false, today));
114
+ }
115
+ for (let d = 1; d <= lastDay.getDate(); d++) {
116
+ const date = new Date(year, month, d);
117
+ this.monthItems.push(this.createMonthItem(date, true, today));
118
+ }
119
+ const remaining = 42 - this.monthItems.length;
120
+ for (let i = 1; i <= remaining; i++) {
121
+ const date = new Date(year, month + 1, i);
122
+ this.monthItems.push(this.createMonthItem(date, false, today));
123
+ }
124
+ }
125
+ createMonthItem(date, isCurrentMonth, today) {
126
+ const isToday = this.formatter.isSameDay(date, today);
127
+ const dayEvents = this.events.filter(e => this.formatter.isSameDay(e.startTime, date) ||
128
+ this.formatter.isSameDay(e.endTime, date) ||
129
+ (e.startTime < date && e.endTime > date));
130
+ return {
131
+ date,
132
+ dayNumber: date.getDate(),
133
+ isCurrentMonth,
134
+ isToday,
135
+ events: dayEvents
136
+ };
137
+ }
138
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarMonthComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
139
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: CalendarMonthComponent, isStandalone: true, selector: "mn-calendar-month", inputs: { focusDay: "focusDay", eventsChanged: "eventsChanged", focusDayChanged: "focusDayChanged", config: "config" }, outputs: { dayClicked: "dayClicked" }, ngImport: i0, template: "<!-- Month grid. Cells are grouped by space rather than boxed by borders, in\n keeping with the date-selector-bar: no rules, soft rounded cells, a hover\n wash, and today marked by a tinted number alone (no circle). -->\n<!-- Rows are a compact fixed height rather than stretched to fill the container:\n a month with few events shouldn't leave each cell mostly empty. The panel\n scrolls if the grid is taller than the space it's given. -->\n<div [attr.aria-label]=\"monthViewLabel\" class=\"w-full flex flex-col\" role=\"grid\">\n <div class=\"grid grid-cols-7 pb-2\">\n @for (day of weekdayLabels; track day) {\n <div class=\"pl-2 text-left text-[11px] font-semibold uppercase tracking-wide opacity-45\" role=\"columnheader\">{{ day }}</div>\n }\n </div>\n <div class=\"grid grid-cols-7 gap-1 auto-rows-[minmax(92px,auto)]\">\n @for (item of monthItems; track item.date.getTime()) {\n <div\n class=\"flex flex-col gap-1 min-h-0 overflow-hidden rounded-xl p-1.5 cursor-pointer transition-colors hover:bg-base-200 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-primary motion-reduce:transition-none\"\n [class.opacity-40]=\"!item.isCurrentMonth\"\n (keyup.enter)=\"onDayClick(item.date)\"\n (click)=\"onDayClick(item.date)\"\n tabindex=\"0\"\n role=\"gridcell\"\n [attr.aria-label]=\"item.date.toDateString()\">\n <span class=\"text-[13px] font-bold leading-none tabular-nums\" [class.text-primary]=\"item.isToday\">{{ item.dayNumber }}</span>\n <div class=\"flex flex-col gap-0.5 min-h-0\">\n @for (event of item.events.slice(0, 3); track $index) {\n <div\n class=\"flex items-center overflow-hidden rounded-md border-l-[3px] px-1.5 py-0.5 text-[11px] leading-tight\"\n [style.background-color]=\"event.color.secondaryColor\"\n [style.border-left-color]=\"event.color.primaryColor\"\n [style.color]=\"event.color.primaryColor\"\n [title]=\"event.title\">\n <span class=\"truncate font-semibold\">{{ event.title }}</span>\n </div>\n }\n <!-- Overflow indicator. Styled as a pill that lights up on hover so it\n reads as actionable; the whole cell already navigates to the Day\n view for this date on click / Enter, where every event is listed. -->\n @if (item.events.length > 3) {\n <span class=\"mt-0.5 inline-flex w-fit items-center rounded-md px-1.5 py-0.5 text-[10.5px] font-semibold opacity-60 transition-colors hover:bg-base-300 hover:opacity-100 motion-reduce:transition-none\">\n +{{ item.events.length - 3 }} {{ moreEventsLabel }}\n </span>\n }\n </div>\n </div>\n }\n </div>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }] });
140
+ }
141
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarMonthComponent, decorators: [{
142
+ type: Component,
143
+ args: [{ selector: 'mn-calendar-month', standalone: true, imports: [CommonModule], template: "<!-- Month grid. Cells are grouped by space rather than boxed by borders, in\n keeping with the date-selector-bar: no rules, soft rounded cells, a hover\n wash, and today marked by a tinted number alone (no circle). -->\n<!-- Rows are a compact fixed height rather than stretched to fill the container:\n a month with few events shouldn't leave each cell mostly empty. The panel\n scrolls if the grid is taller than the space it's given. -->\n<div [attr.aria-label]=\"monthViewLabel\" class=\"w-full flex flex-col\" role=\"grid\">\n <div class=\"grid grid-cols-7 pb-2\">\n @for (day of weekdayLabels; track day) {\n <div class=\"pl-2 text-left text-[11px] font-semibold uppercase tracking-wide opacity-45\" role=\"columnheader\">{{ day }}</div>\n }\n </div>\n <div class=\"grid grid-cols-7 gap-1 auto-rows-[minmax(92px,auto)]\">\n @for (item of monthItems; track item.date.getTime()) {\n <div\n class=\"flex flex-col gap-1 min-h-0 overflow-hidden rounded-xl p-1.5 cursor-pointer transition-colors hover:bg-base-200 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-primary motion-reduce:transition-none\"\n [class.opacity-40]=\"!item.isCurrentMonth\"\n (keyup.enter)=\"onDayClick(item.date)\"\n (click)=\"onDayClick(item.date)\"\n tabindex=\"0\"\n role=\"gridcell\"\n [attr.aria-label]=\"item.date.toDateString()\">\n <span class=\"text-[13px] font-bold leading-none tabular-nums\" [class.text-primary]=\"item.isToday\">{{ item.dayNumber }}</span>\n <div class=\"flex flex-col gap-0.5 min-h-0\">\n @for (event of item.events.slice(0, 3); track $index) {\n <div\n class=\"flex items-center overflow-hidden rounded-md border-l-[3px] px-1.5 py-0.5 text-[11px] leading-tight\"\n [style.background-color]=\"event.color.secondaryColor\"\n [style.border-left-color]=\"event.color.primaryColor\"\n [style.color]=\"event.color.primaryColor\"\n [title]=\"event.title\">\n <span class=\"truncate font-semibold\">{{ event.title }}</span>\n </div>\n }\n <!-- Overflow indicator. Styled as a pill that lights up on hover so it\n reads as actionable; the whole cell already navigates to the Day\n view for this date on click / Enter, where every event is listed. -->\n @if (item.events.length > 3) {\n <span class=\"mt-0.5 inline-flex w-fit items-center rounded-md px-1.5 py-0.5 text-[10.5px] font-semibold opacity-60 transition-colors hover:bg-base-300 hover:opacity-100 motion-reduce:transition-none\">\n +{{ item.events.length - 3 }} {{ moreEventsLabel }}\n </span>\n }\n </div>\n </div>\n }\n </div>\n</div>\n" }]
144
+ }], ctorParameters: () => [], propDecorators: { focusDay: [{
145
+ type: Input
146
+ }], eventsChanged: [{
147
+ type: Input
148
+ }], focusDayChanged: [{
149
+ type: Input
150
+ }], config: [{
151
+ type: Input
152
+ }], dayClicked: [{
153
+ type: Output
154
+ }] } });
155
+
156
+ /**
157
+ * Default event renderer used when no custom component is provided.
158
+ *
159
+ * Displays the event title, formatted time range, and optional description
160
+ * with the event's colour scheme applied as background and left-border accent.
161
+ */
162
+ class CalendarEventDefaultComponent {
163
+ cdr = inject(ChangeDetectorRef);
164
+ /** The event to render. Set by {@link CalendarEventComponent} after creation. */
165
+ event;
166
+ formattedTime = '';
167
+ formatter;
168
+ constructor() {
169
+ const formatter = inject(CALENDAR_DATE_FORMATTER, { optional: true });
170
+ this.formatter = formatter ?? new DefaultCalendarDateFormatter();
171
+ }
172
+ async ngOnInit() {
173
+ if (this.event) {
174
+ const start = await this.formatter.formatTime(this.event.startTime);
175
+ const end = await this.formatter.formatTime(this.event.endTime);
176
+ this.formattedTime = `${start} - ${end}`;
177
+ this.cdr.markForCheck();
178
+ }
179
+ }
180
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarEventDefaultComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
181
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: CalendarEventDefaultComponent, isStandalone: true, selector: "mn-calendar-event-default", ngImport: i0, template: "<!-- The shared event chip: a colored spine and a tinted fill from the event's own\n colours, so it reads the same in week, day and month. Text inherits the\n event's primary colour, keeping it legible on either theme. -->\n<div class=\"h-full overflow-hidden cursor-pointer rounded-lg border-l-[3px] px-2 py-1 text-xs\"\n [style.background-color]=\"event.color.secondaryColor\"\n [style.border-left-color]=\"event.color.primaryColor\"\n [style.color]=\"event.color.primaryColor\">\n <div class=\"truncate font-semibold\">{{ event.title }}</div>\n <div class=\"truncate text-[11px] opacity-85\">{{ formattedTime }}</div>\n @if (event.description) {\n <div class=\"truncate text-[11px] opacity-75\">{{ event.description }}</div>\n }\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }] });
182
+ }
183
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarEventDefaultComponent, decorators: [{
184
+ type: Component,
185
+ args: [{ selector: 'mn-calendar-event-default', standalone: true, imports: [CommonModule], template: "<!-- The shared event chip: a colored spine and a tinted fill from the event's own\n colours, so it reads the same in week, day and month. Text inherits the\n event's primary colour, keeping it legible on either theme. -->\n<div class=\"h-full overflow-hidden cursor-pointer rounded-lg border-l-[3px] px-2 py-1 text-xs\"\n [style.background-color]=\"event.color.secondaryColor\"\n [style.border-left-color]=\"event.color.primaryColor\"\n [style.color]=\"event.color.primaryColor\">\n <div class=\"truncate font-semibold\">{{ event.title }}</div>\n <div class=\"truncate text-[11px] opacity-85\">{{ formattedTime }}</div>\n @if (event.description) {\n <div class=\"truncate text-[11px] opacity-75\">{{ event.description }}</div>\n }\n</div>\n" }]
186
+ }], ctorParameters: () => [] });
187
+
188
+ /**
189
+ * Dynamic event renderer that injects a custom or default event component
190
+ * into its view container.
191
+ *
192
+ * The component to render is resolved in this order:
193
+ * 1. `customComponent` input (set on the parent week/day view)
194
+ * 2. `event.component` (per-event override)
195
+ * 3. {@link CalendarEventDefaultComponent} (library default)
196
+ */
197
+ class CalendarEventComponent {
198
+ /** The event data to render. */
199
+ event;
200
+ /** Optional custom component type that overrides the default renderer. */
201
+ customComponent;
202
+ /** Emits when the rendered event is clicked. */
203
+ eventClicked = new EventEmitter();
204
+ eventContainer;
205
+ rendered = false;
206
+ ngAfterViewInit() {
207
+ this.renderComponent();
208
+ }
209
+ ngOnChanges(changes) {
210
+ if (this.rendered && (changes['event'] || changes['customComponent'])) {
211
+ this.renderComponent();
212
+ }
213
+ }
214
+ /** Emits the event click. */
215
+ onEventClick() {
216
+ this.eventClicked.emit(this.event);
217
+ }
218
+ /** Creates the event component dynamically and sets its `event` property. */
219
+ renderComponent() {
220
+ if (!this.eventContainer)
221
+ return;
222
+ this.eventContainer.clear();
223
+ const component = this.customComponent ?? this.event?.component ?? CalendarEventDefaultComponent;
224
+ const ref = this.eventContainer.createComponent(component);
225
+ ref.instance.event = this.event;
226
+ ref.changeDetectorRef.detectChanges();
227
+ this.rendered = true;
228
+ }
229
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarEventComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
230
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "21.1.3", type: CalendarEventComponent, isStandalone: true, selector: "mn-calendar-event", inputs: { event: "event", customComponent: "customComponent" }, outputs: { eventClicked: "eventClicked" }, viewQueries: [{ propertyName: "eventContainer", first: true, predicate: ["eventContainer"], descendants: true, read: ViewContainerRef, static: true }], usesOnChanges: true, ngImport: i0, template: "<!-- Host for the dynamically-rendered event component. Click/keyboard handling and\n the focus ring live on the week/day event wrapper, so this stays presentational\n to avoid a second, redundant tab stop per event. -->\n<div class=\"h-full w-full\">\n <ng-template #eventContainer></ng-template>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }] });
231
+ }
232
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarEventComponent, decorators: [{
233
+ type: Component,
234
+ args: [{ selector: 'mn-calendar-event', standalone: true, imports: [CommonModule], template: "<!-- Host for the dynamically-rendered event component. Click/keyboard handling and\n the focus ring live on the week/day event wrapper, so this stays presentational\n to avoid a second, redundant tab stop per event. -->\n<div class=\"h-full w-full\">\n <ng-template #eventContainer></ng-template>\n</div>\n" }]
235
+ }], propDecorators: { event: [{
236
+ type: Input
237
+ }], customComponent: [{
238
+ type: Input
239
+ }], eventClicked: [{
240
+ type: Output
241
+ }], eventContainer: [{
242
+ type: ViewChild,
243
+ args: ['eventContainer', { read: ViewContainerRef, static: true }]
244
+ }] } });
245
+
246
+ /**
247
+ * Week grid view showing 7 day columns with half-hour time slots.
248
+ *
249
+ * Overlapping events within the same day are laid out in sub-columns
250
+ * so they appear side-by-side rather than stacked.
251
+ */
252
+ class CalendarWeekComponent {
253
+ lang = inject(MnLanguageService);
254
+ /**
255
+ * Accessible name for this control. Resolved through the conventional
256
+ * `mnCalendar.weekView` key so an app can translate it, falling back to English when the
257
+ * key is not defined rather than leaking the raw key into the UI.
258
+ */
259
+ get weekViewLabel() {
260
+ return this.lang.translateIfPresent('mnCalendar.weekView') ?? 'Week view';
261
+ }
262
+ layoutService = inject(CalendarEventLayoutService);
263
+ cdr = inject(ChangeDetectorRef);
264
+ /** The date around which the week is centred. */
265
+ focusDay;
266
+ /** Observable that emits the full event list whenever it changes. */
267
+ eventsChanged;
268
+ /** Observable that emits when the focus day changes. */
269
+ focusDayChanged;
270
+ /** Resolved calendar configuration passed from the parent view. */
271
+ config;
272
+ /** Optional custom event renderer component. */
273
+ calendarEventComponent;
274
+ /** Emits when a calendar event is clicked. */
275
+ eventClicked = new EventEmitter();
276
+ columns = [];
277
+ hourRows = [];
278
+ displayEvents = [];
279
+ totalRows = 0;
280
+ currentTimeRow = 0;
281
+ currentTimeCol = '';
282
+ /** The current time, formatted for the label riding the now-line. */
283
+ currentTimeLabel = '';
284
+ gridTemplateColumns = 'repeat(7, 1fr)';
285
+ dayColumnMap = [];
286
+ events = [];
287
+ destroy$ = new Subject();
288
+ formatter;
289
+ resolvedConfig;
290
+ currentTimeInterval;
291
+ constructor() {
292
+ this.formatter = new DefaultCalendarDateFormatter();
293
+ }
294
+ ngOnInit() {
295
+ this.resolvedConfig = this.config ? resolveCalendarConfig(this.config) : { ...DEFAULT_CALENDAR_CONFIG };
296
+ this.buildColumns();
297
+ this.updateCurrentTime();
298
+ this.currentTimeInterval = setInterval(() => this.updateCurrentTime(), 60000);
299
+ if (this.eventsChanged) {
300
+ this.eventsChanged.pipe(takeUntil(this.destroy$)).subscribe(events => {
301
+ this.events = events;
302
+ this.refreshEvents();
303
+ this.cdr.markForCheck();
304
+ });
305
+ }
306
+ if (this.focusDayChanged) {
307
+ this.focusDayChanged.pipe(takeUntil(this.destroy$)).subscribe(date => {
308
+ this.focusDay = date;
309
+ this.buildColumns();
310
+ this.refreshEvents();
311
+ this.updateCurrentTime();
312
+ this.cdr.markForCheck();
313
+ });
314
+ }
315
+ // Build hour rows asynchronously (formatTimeI returns a Promise).
316
+ this.buildHourRows().then(() => this.cdr.markForCheck());
317
+ }
318
+ ngOnDestroy() {
319
+ this.destroy$.next();
320
+ this.destroy$.complete();
321
+ if (this.currentTimeInterval)
322
+ clearInterval(this.currentTimeInterval);
323
+ }
324
+ /** Returns the CSS `grid-row` value for an event based on its start/end times. */
325
+ getEventRow(event) {
326
+ const startRow = CalendarUtility.getCorrectRow(event.startTime.getHours(), event.startTime.getMinutes(), this.resolvedConfig.startHour);
327
+ const endRow = CalendarUtility.getCorrectRow(event.endTime.getHours(), event.endTime.getMinutes(), this.resolvedConfig.startHour);
328
+ return `${startRow} / ${Math.max(endRow, startRow + 1)}`;
329
+ }
330
+ /** Returns the CSS `grid-column` span for a day header, accounting for sub-columns. */
331
+ getHeaderColumn(dayIndex) {
332
+ if (!this.dayColumnMap.length)
333
+ return `${dayIndex + 2} / span 1`;
334
+ const dayInfo = this.dayColumnMap[dayIndex];
335
+ return `${dayInfo.startCol + 1} / span ${dayInfo.subColumns}`;
336
+ }
337
+ /** Returns the CSS `grid-column` value for an event within its day's sub-columns. */
338
+ getEventColumn(event) {
339
+ const dayIdx = this.columns.findIndex(c => this.formatter.isSameDay(c.date, event.startTime));
340
+ if (dayIdx < 0)
341
+ return '1 / span 1';
342
+ const dayInfo = this.dayColumnMap[dayIdx];
343
+ const subCol = (event.column ?? 0) + dayInfo.startCol;
344
+ const width = event.width ?? 1;
345
+ return `${subCol} / span ${width}`;
346
+ }
347
+ /** Forwards event click to parent. */
348
+ onEventClick(event) {
349
+ this.eventClicked.emit(event);
350
+ }
351
+ /** trackBy for hour rows. */
352
+ trackByHour(_index, row) {
353
+ return row.hour;
354
+ }
355
+ /** trackBy for day columns. */
356
+ trackByColumn(_index, col) {
357
+ return col.date.getTime();
358
+ }
359
+ /** trackBy for events. */
360
+ trackByEvent(_index, event) {
361
+ return event.id;
362
+ }
363
+ async buildHourRows() {
364
+ const hours = this.resolvedConfig.endHour - this.resolvedConfig.startHour;
365
+ this.totalRows = hours * 2;
366
+ const rows = [];
367
+ for (let i = 0; i < hours; i++) {
368
+ const hour = this.resolvedConfig.startHour + i;
369
+ const label = await this.formatter.formatTimeI(hour, 0);
370
+ rows.push({
371
+ hour,
372
+ topRow: i * 2 + 1,
373
+ bottomRow: i * 2 + 3,
374
+ hourLabel: label
375
+ });
376
+ }
377
+ this.hourRows = rows;
378
+ }
379
+ /** Builds the 7 day columns for the current week (Monday–Sunday). */
380
+ buildColumns() {
381
+ if (!this.focusDay)
382
+ return;
383
+ const shortNames = this.resolvedConfig.shortDayNames;
384
+ const today = new Date();
385
+ const day = this.focusDay.getDay();
386
+ const mondayOffset = day === 0 ? -6 : 1 - day;
387
+ const monday = new Date(this.focusDay);
388
+ monday.setDate(this.focusDay.getDate() + mondayOffset);
389
+ this.columns = [];
390
+ for (let i = 0; i < 7; i++) {
391
+ const date = new Date(monday);
392
+ date.setDate(monday.getDate() + i);
393
+ this.columns.push({
394
+ date,
395
+ dayName: shortNames[i],
396
+ dayNumber: date.getDate(),
397
+ isToday: this.formatter.isSameDay(date, today)
398
+ });
399
+ }
400
+ }
401
+ /** Filters, splits, and lays out events for the current week. */
402
+ refreshEvents() {
403
+ if (!this.columns.length)
404
+ return;
405
+ const rangeStart = this.columns[0].date;
406
+ const rangeEnd = new Date(this.columns[6].date);
407
+ rangeEnd.setHours(23, 59, 59, 999);
408
+ const filtered = this.events.filter(e => this.layoutService.eventsOverlap(e.startTime, e.endTime, rangeStart, rangeEnd));
409
+ this.displayEvents = this.layoutService.calculateMultiDayEvents(filtered, this.resolvedConfig.startHour, this.resolvedConfig.endHour, rangeStart, rangeEnd);
410
+ // Assign columns per day so overlapping events within a day get sub-columns
411
+ for (let i = 0; i < 7; i++) {
412
+ const dayStart = new Date(this.columns[i].date);
413
+ dayStart.setHours(0, 0, 0, 0);
414
+ const dayEnd = new Date(this.columns[i].date);
415
+ dayEnd.setHours(23, 59, 59, 999);
416
+ const dayEvents = this.displayEvents.filter(e => this.formatter.isSameDay(e.startTime, this.columns[i].date));
417
+ this.layoutService.assignColumnsToEvents(dayEvents);
418
+ this.layoutService.assignWidthsToEvents(dayEvents, dayStart, dayEnd);
419
+ }
420
+ this.buildGridColumns();
421
+ this.updateCurrentTime();
422
+ }
423
+ /** Computes the CSS grid-template-columns string based on per-day sub-column counts. */
424
+ buildGridColumns() {
425
+ this.dayColumnMap = [];
426
+ let currentCol = 1;
427
+ for (let i = 0; i < 7; i++) {
428
+ const dayEvents = this.displayEvents.filter(e => this.formatter.isSameDay(e.startTime, this.columns[i].date));
429
+ let maxSubCols = 1;
430
+ for (const e of dayEvents) {
431
+ maxSubCols = Math.max(maxSubCols, (e.column ?? 0) + (e.width ?? 1));
432
+ }
433
+ this.dayColumnMap.push({ subColumns: maxSubCols, startCol: currentCol });
434
+ currentCol += maxSubCols;
435
+ }
436
+ const parts = [];
437
+ for (const day of this.dayColumnMap) {
438
+ for (let j = 0; j < day.subColumns; j++) {
439
+ parts.push(`${1 / day.subColumns}fr`);
440
+ }
441
+ }
442
+ this.gridTemplateColumns = parts.join(' ');
443
+ }
444
+ /** Updates the current-time red line position. */
445
+ updateCurrentTime() {
446
+ const now = new Date();
447
+ const dayIdx = this.columns.findIndex(c => this.formatter.isSameDay(c.date, now));
448
+ if (dayIdx >= 0 && this.dayColumnMap.length > 0) {
449
+ const dayInfo = this.dayColumnMap[dayIdx];
450
+ this.currentTimeCol = `${dayInfo.startCol} / span ${dayInfo.subColumns}`;
451
+ this.currentTimeRow = CalendarUtility.getCorrectRow(now.getHours(), now.getMinutes(), this.resolvedConfig.startHour);
452
+ // formatTime is async; refresh the label and re-render when it resolves.
453
+ this.formatter.formatTime(now).then(label => {
454
+ this.currentTimeLabel = label;
455
+ this.cdr.markForCheck();
456
+ });
457
+ }
458
+ else {
459
+ this.currentTimeCol = '';
460
+ this.currentTimeRow = 0;
461
+ this.currentTimeLabel = '';
462
+ }
463
+ }
464
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarWeekComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
465
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: CalendarWeekComponent, isStandalone: true, selector: "mn-calendar-week", inputs: { focusDay: "focusDay", eventsChanged: "eventsChanged", focusDayChanged: "focusDayChanged", config: "config", calendarEventComponent: "calendarEventComponent" }, outputs: { eventClicked: "eventClicked" }, providers: [CalendarEventLayoutService], ngImport: i0, template: "<!-- Week grid. Hour rules are quiet hairlines; today's column header is a tinted\n number (no fill); the current time is a line carrying a small time bubble.\n Dynamic row/column placement stays inline \u2014 the layout maths lives in TS. -->\n<div [attr.aria-label]=\"weekViewLabel\" class=\"w-full h-full flex flex-col overflow-hidden\" role=\"grid\">\n <div class=\"grid\" [style.grid-template-columns]=\"'60px ' + gridTemplateColumns\">\n <div></div>\n @for (col of columns; track col.dayName; let i = $index) {\n <div class=\"py-2 px-1 text-center\"\n [style.grid-column]=\"getHeaderColumn(i)\"\n role=\"columnheader\">\n <span class=\"block text-[11px] font-semibold uppercase tracking-wide opacity-50\">{{ col.dayName }}</span>\n <span class=\"text-lg font-bold tabular-nums\" [class.text-primary]=\"col.isToday\">{{ col.dayNumber }}</span>\n </div>\n }\n </div>\n <div class=\"grid grid-cols-[60px_1fr] flex-1 min-h-0 overflow-hidden items-stretch\">\n <div class=\"grid h-full min-h-0\" [style.grid-template-rows]=\"'repeat(' + totalRows + ', minmax(1.5rem, 1fr))'\">\n @for (row of hourRows; track row.topRow) {\n <div class=\"flex items-start justify-end min-h-0 overflow-hidden pr-2 text-[11px] tabular-nums opacity-50\"\n [style.grid-row]=\"row.topRow + '/' + row.bottomRow\">\n {{ row.hourLabel }}\n </div>\n }\n </div>\n <div class=\"grid relative auto-rows-fr h-full min-h-0\"\n [style.grid-template-rows]=\"'repeat(' + totalRows + ', minmax(1.5rem, 1fr))'\"\n [style.grid-template-columns]=\"gridTemplateColumns\">\n @for (row of hourRows; track row.topRow) {\n <div class=\"border-t border-base-200 pointer-events-none min-h-0\"\n [style.grid-row]=\"row.topRow + '/' + row.bottomRow\"\n [style.grid-column]=\"'1 / -1'\">\n </div>\n }\n @if (currentTimeRow > 0 && currentTimeCol) {\n <div class=\"relative z-[2] pointer-events-none\"\n [style.grid-row]=\"currentTimeRow\"\n [style.grid-column]=\"currentTimeCol\">\n <div class=\"absolute -left-1 -top-1 h-2 w-2 rounded-full bg-error\"></div>\n <div class=\"h-0.5 w-full bg-error\"></div>\n <div class=\"absolute left-0 top-0 -translate-x-2 -translate-y-1/2 rounded-full bg-error px-1.5 py-0.5 text-[10px] font-bold tabular-nums text-error-content shadow\">{{ currentTimeLabel }}</div>\n </div>\n }\n @for (event of displayEvents; track $index) {\n <div class=\"z-[1] min-h-0 overflow-hidden rounded-lg p-0.5 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary\"\n [style.grid-row]=\"getEventRow(event)\"\n [style.grid-column]=\"getEventColumn(event)\"\n (click)=\"onEventClick(event)\"\n (keyup.enter)=\"onEventClick(event)\"\n tabindex=\"0\">\n <mn-calendar-event [customComponent]=\"calendarEventComponent\" [event]=\"event\"></mn-calendar-event>\n </div>\n }\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: CalendarEventComponent, selector: "mn-calendar-event", inputs: ["event", "customComponent"], outputs: ["eventClicked"] }] });
466
+ }
467
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarWeekComponent, decorators: [{
468
+ type: Component,
469
+ args: [{ selector: 'mn-calendar-week', standalone: true, imports: [CommonModule, CalendarEventComponent], providers: [CalendarEventLayoutService], template: "<!-- Week grid. Hour rules are quiet hairlines; today's column header is a tinted\n number (no fill); the current time is a line carrying a small time bubble.\n Dynamic row/column placement stays inline \u2014 the layout maths lives in TS. -->\n<div [attr.aria-label]=\"weekViewLabel\" class=\"w-full h-full flex flex-col overflow-hidden\" role=\"grid\">\n <div class=\"grid\" [style.grid-template-columns]=\"'60px ' + gridTemplateColumns\">\n <div></div>\n @for (col of columns; track col.dayName; let i = $index) {\n <div class=\"py-2 px-1 text-center\"\n [style.grid-column]=\"getHeaderColumn(i)\"\n role=\"columnheader\">\n <span class=\"block text-[11px] font-semibold uppercase tracking-wide opacity-50\">{{ col.dayName }}</span>\n <span class=\"text-lg font-bold tabular-nums\" [class.text-primary]=\"col.isToday\">{{ col.dayNumber }}</span>\n </div>\n }\n </div>\n <div class=\"grid grid-cols-[60px_1fr] flex-1 min-h-0 overflow-hidden items-stretch\">\n <div class=\"grid h-full min-h-0\" [style.grid-template-rows]=\"'repeat(' + totalRows + ', minmax(1.5rem, 1fr))'\">\n @for (row of hourRows; track row.topRow) {\n <div class=\"flex items-start justify-end min-h-0 overflow-hidden pr-2 text-[11px] tabular-nums opacity-50\"\n [style.grid-row]=\"row.topRow + '/' + row.bottomRow\">\n {{ row.hourLabel }}\n </div>\n }\n </div>\n <div class=\"grid relative auto-rows-fr h-full min-h-0\"\n [style.grid-template-rows]=\"'repeat(' + totalRows + ', minmax(1.5rem, 1fr))'\"\n [style.grid-template-columns]=\"gridTemplateColumns\">\n @for (row of hourRows; track row.topRow) {\n <div class=\"border-t border-base-200 pointer-events-none min-h-0\"\n [style.grid-row]=\"row.topRow + '/' + row.bottomRow\"\n [style.grid-column]=\"'1 / -1'\">\n </div>\n }\n @if (currentTimeRow > 0 && currentTimeCol) {\n <div class=\"relative z-[2] pointer-events-none\"\n [style.grid-row]=\"currentTimeRow\"\n [style.grid-column]=\"currentTimeCol\">\n <div class=\"absolute -left-1 -top-1 h-2 w-2 rounded-full bg-error\"></div>\n <div class=\"h-0.5 w-full bg-error\"></div>\n <div class=\"absolute left-0 top-0 -translate-x-2 -translate-y-1/2 rounded-full bg-error px-1.5 py-0.5 text-[10px] font-bold tabular-nums text-error-content shadow\">{{ currentTimeLabel }}</div>\n </div>\n }\n @for (event of displayEvents; track $index) {\n <div class=\"z-[1] min-h-0 overflow-hidden rounded-lg p-0.5 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary\"\n [style.grid-row]=\"getEventRow(event)\"\n [style.grid-column]=\"getEventColumn(event)\"\n (click)=\"onEventClick(event)\"\n (keyup.enter)=\"onEventClick(event)\"\n tabindex=\"0\">\n <mn-calendar-event [customComponent]=\"calendarEventComponent\" [event]=\"event\"></mn-calendar-event>\n </div>\n }\n </div>\n </div>\n</div>\n" }]
470
+ }], ctorParameters: () => [], propDecorators: { focusDay: [{
471
+ type: Input
472
+ }], eventsChanged: [{
473
+ type: Input
474
+ }], focusDayChanged: [{
475
+ type: Input
476
+ }], config: [{
477
+ type: Input
478
+ }], calendarEventComponent: [{
479
+ type: Input
480
+ }], eventClicked: [{
481
+ type: Output
482
+ }] } });
483
+
484
+ /**
485
+ * Day grid view showing a single day with half-hour time slots.
486
+ *
487
+ * Shares the same layout algorithm as the week view via
488
+ * {@link CalendarEventLayoutService}.
489
+ */
490
+ class CalendarDayComponent {
491
+ lang = inject(MnLanguageService);
492
+ /**
493
+ * Accessible name for this control. Resolved through the conventional
494
+ * `mnCalendar.dayView` key so an app can translate it, falling back to English when the
495
+ * key is not defined rather than leaking the raw key into the UI.
496
+ */
497
+ get dayViewLabel() {
498
+ return this.lang.translateIfPresent('mnCalendar.dayView') ?? 'Day view';
499
+ }
500
+ layoutService = inject(CalendarEventLayoutService);
501
+ cdr = inject(ChangeDetectorRef);
502
+ /** The date to display. */
503
+ focusDay;
504
+ /** Observable that emits the full event list whenever it changes. */
505
+ eventsChanged;
506
+ /** Observable that emits when the focus day changes. */
507
+ focusDayChanged;
508
+ /** Resolved calendar configuration passed from the parent view. */
509
+ config;
510
+ /** Optional custom event renderer component. */
511
+ calendarEventComponent;
512
+ /** Emits when a calendar event is clicked. */
513
+ eventClicked = new EventEmitter();
514
+ hourRows = [];
515
+ displayEvents = [];
516
+ totalRows = 0;
517
+ totalColumns = 1;
518
+ currentTimeRow = 0;
519
+ /** The current time, formatted for the label riding the now-line. */
520
+ currentTimeLabel = '';
521
+ isToday = false;
522
+ dayName = '';
523
+ events = [];
524
+ destroy$ = new Subject();
525
+ formatter;
526
+ resolvedConfig;
527
+ currentTimeInterval;
528
+ constructor() {
529
+ this.formatter = new DefaultCalendarDateFormatter();
530
+ }
531
+ ngOnInit() {
532
+ this.resolvedConfig = this.config ? resolveCalendarConfig(this.config) : { ...DEFAULT_CALENDAR_CONFIG };
533
+ this.updateDayInfo();
534
+ this.updateCurrentTime();
535
+ this.currentTimeInterval = setInterval(() => this.updateCurrentTime(), 60000);
536
+ if (this.eventsChanged) {
537
+ this.eventsChanged.pipe(takeUntil(this.destroy$)).subscribe(events => {
538
+ this.events = events;
539
+ this.refreshEvents();
540
+ this.cdr.markForCheck();
541
+ });
542
+ }
543
+ if (this.focusDayChanged) {
544
+ this.focusDayChanged.pipe(takeUntil(this.destroy$)).subscribe(date => {
545
+ this.focusDay = date;
546
+ this.updateDayInfo();
547
+ this.refreshEvents();
548
+ this.updateCurrentTime();
549
+ this.cdr.markForCheck();
550
+ });
551
+ }
552
+ // Build hour rows asynchronously (formatTimeI returns a Promise).
553
+ this.buildHourRows().then(() => this.cdr.markForCheck());
554
+ }
555
+ ngOnDestroy() {
556
+ this.destroy$.next();
557
+ this.destroy$.complete();
558
+ if (this.currentTimeInterval)
559
+ clearInterval(this.currentTimeInterval);
560
+ }
561
+ /** Returns the CSS `grid-row` value for an event. */
562
+ getEventRow(event) {
563
+ const startRow = CalendarUtility.getCorrectRow(event.startTime.getHours(), event.startTime.getMinutes(), this.resolvedConfig.startHour);
564
+ const endRow = CalendarUtility.getCorrectRow(event.endTime.getHours(), event.endTime.getMinutes(), this.resolvedConfig.startHour);
565
+ return `${startRow} / ${Math.max(endRow, startRow + 1)}`;
566
+ }
567
+ /** Returns the CSS `grid-column` value for an event within its sub-columns. */
568
+ getEventColumn(event) {
569
+ const col = (event.column ?? 0) + 1;
570
+ const width = event.width ?? 1;
571
+ return `${col} / span ${width}`;
572
+ }
573
+ /** Forwards event click to parent. */
574
+ onEventClick(event) {
575
+ this.eventClicked.emit(event);
576
+ }
577
+ /** trackBy for hour rows. */
578
+ trackByHour(_index, row) {
579
+ return row.hour;
580
+ }
581
+ /** trackBy for events. */
582
+ trackByEvent(_index, event) {
583
+ return event.id;
584
+ }
585
+ async buildHourRows() {
586
+ const hours = this.resolvedConfig.endHour - this.resolvedConfig.startHour;
587
+ this.totalRows = hours * 2;
588
+ const rows = [];
589
+ for (let i = 0; i < hours; i++) {
590
+ const hour = this.resolvedConfig.startHour + i;
591
+ const label = await this.formatter.formatTimeI(hour, 0);
592
+ rows.push({
593
+ hour,
594
+ topRow: i * 2 + 1,
595
+ bottomRow: i * 2 + 3,
596
+ hourLabel: label
597
+ });
598
+ }
599
+ this.hourRows = rows;
600
+ }
601
+ /** Updates the day name and isToday flag. */
602
+ updateDayInfo() {
603
+ if (!this.focusDay)
604
+ return;
605
+ const today = new Date();
606
+ this.isToday = this.formatter.isSameDay(this.focusDay, today);
607
+ const longNames = this.resolvedConfig.longDayNames;
608
+ const dayIdx = this.focusDay.getDay();
609
+ const mondayIdx = dayIdx === 0 ? 6 : dayIdx - 1;
610
+ this.dayName = longNames[mondayIdx];
611
+ }
612
+ /** Filters, splits, and lays out events for the focus day. */
613
+ refreshEvents() {
614
+ if (!this.focusDay)
615
+ return;
616
+ const rangeStart = new Date(this.focusDay);
617
+ rangeStart.setHours(0, 0, 0, 0);
618
+ const rangeEnd = new Date(this.focusDay);
619
+ rangeEnd.setHours(23, 59, 59, 999);
620
+ const filtered = this.events.filter(e => this.layoutService.eventsOverlap(e.startTime, e.endTime, rangeStart, rangeEnd));
621
+ this.displayEvents = this.layoutService.calculateMultiDayEvents(filtered, this.resolvedConfig.startHour, this.resolvedConfig.endHour, rangeStart, rangeEnd);
622
+ this.layoutService.assignColumnsToEvents(this.displayEvents);
623
+ this.layoutService.assignWidthsToEvents(this.displayEvents, rangeStart, rangeEnd);
624
+ this.totalColumns = this.displayEvents.reduce((max, e) => Math.max(max, (e.column ?? 0) + (e.width ?? 1)), 1);
625
+ }
626
+ /** Updates the current-time red line position. */
627
+ updateCurrentTime() {
628
+ const now = new Date();
629
+ if (this.focusDay && this.formatter.isSameDay(this.focusDay, now)) {
630
+ this.currentTimeRow = CalendarUtility.getCorrectRow(now.getHours(), now.getMinutes(), this.resolvedConfig.startHour);
631
+ this.isToday = true;
632
+ // formatTime is async; refresh the label and re-render when it resolves.
633
+ this.formatter.formatTime(now).then(label => {
634
+ this.currentTimeLabel = label;
635
+ this.cdr.markForCheck();
636
+ });
637
+ }
638
+ else {
639
+ this.currentTimeRow = 0;
640
+ this.isToday = false;
641
+ this.currentTimeLabel = '';
642
+ }
643
+ }
644
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarDayComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
645
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: CalendarDayComponent, isStandalone: true, selector: "mn-calendar-day", inputs: { focusDay: "focusDay", eventsChanged: "eventsChanged", focusDayChanged: "focusDayChanged", config: "config", calendarEventComponent: "calendarEventComponent" }, outputs: { eventClicked: "eventClicked" }, providers: [CalendarEventLayoutService], ngImport: i0, template: "<!-- Day grid. One column, its header centered over that column (the toolbar\n already names the date). Today's number is tinted, not filled; the now-line\n carries a time bubble that overhangs into the gutter. -->\n<div [attr.aria-label]=\"dayViewLabel\" class=\"w-full h-full flex flex-col overflow-hidden\" role=\"grid\">\n <div class=\"grid grid-cols-[60px_1fr]\">\n <div></div>\n <div class=\"flex items-center justify-center gap-2 py-2 px-1\" role=\"columnheader\">\n <span class=\"text-[11px] font-semibold uppercase tracking-wide opacity-50\">{{ dayName }}</span>\n <span class=\"text-base font-bold tabular-nums\" [class.text-primary]=\"isToday\">{{ focusDay.getDate() }}</span>\n </div>\n </div>\n <div class=\"grid grid-cols-[60px_1fr] flex-1 min-h-0 overflow-hidden items-stretch\">\n <div class=\"grid h-full min-h-0\" [style.grid-template-rows]=\"'repeat(' + totalRows + ', minmax(1.5rem, 1fr))'\">\n @for (row of hourRows; track row.topRow) {\n <div class=\"flex items-start justify-end min-h-0 overflow-hidden pr-2 text-[11px] tabular-nums opacity-50\"\n [style.grid-row]=\"row.topRow + '/' + row.bottomRow\">\n {{ row.hourLabel }}\n </div>\n }\n </div>\n <div class=\"grid relative auto-rows-fr h-full min-h-0\"\n [style.grid-template-rows]=\"'repeat(' + totalRows + ', minmax(1.5rem, 1fr))'\"\n [style.grid-template-columns]=\"'repeat(' + totalColumns + ', 1fr)'\">\n @for (row of hourRows; track row.topRow) {\n <div class=\"border-t border-base-200 pointer-events-none min-h-0\"\n [style.grid-row]=\"row.topRow + '/' + row.bottomRow\"\n [style.grid-column]=\"'1 / -1'\">\n </div>\n }\n @if (currentTimeRow > 0 && isToday) {\n <div class=\"relative z-[2] pointer-events-none\"\n [style.grid-row]=\"currentTimeRow\"\n [style.grid-column]=\"'1 / -1'\">\n <div class=\"absolute -left-1 -top-1 h-2 w-2 rounded-full bg-error\"></div>\n <div class=\"h-0.5 w-full bg-error\"></div>\n <div class=\"absolute left-0 top-0 -translate-x-2 -translate-y-1/2 rounded-full bg-error px-1.5 py-0.5 text-[10px] font-bold tabular-nums text-error-content shadow\">{{ currentTimeLabel }}</div>\n </div>\n }\n @for (event of displayEvents; track $index) {\n <div class=\"z-[1] min-h-0 overflow-hidden rounded-lg p-0.5 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary\"\n [style.grid-row]=\"getEventRow(event)\"\n [style.grid-column]=\"getEventColumn(event)\"\n (click)=\"onEventClick(event)\"\n (keyup.enter)=\"onEventClick(event)\"\n tabindex=\"0\">\n <mn-calendar-event [customComponent]=\"calendarEventComponent\" [event]=\"event\"></mn-calendar-event>\n </div>\n }\n </div>\n </div>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: CalendarEventComponent, selector: "mn-calendar-event", inputs: ["event", "customComponent"], outputs: ["eventClicked"] }] });
646
+ }
647
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarDayComponent, decorators: [{
648
+ type: Component,
649
+ args: [{ selector: 'mn-calendar-day', standalone: true, imports: [CommonModule, CalendarEventComponent], providers: [CalendarEventLayoutService], template: "<!-- Day grid. One column, its header centered over that column (the toolbar\n already names the date). Today's number is tinted, not filled; the now-line\n carries a time bubble that overhangs into the gutter. -->\n<div [attr.aria-label]=\"dayViewLabel\" class=\"w-full h-full flex flex-col overflow-hidden\" role=\"grid\">\n <div class=\"grid grid-cols-[60px_1fr]\">\n <div></div>\n <div class=\"flex items-center justify-center gap-2 py-2 px-1\" role=\"columnheader\">\n <span class=\"text-[11px] font-semibold uppercase tracking-wide opacity-50\">{{ dayName }}</span>\n <span class=\"text-base font-bold tabular-nums\" [class.text-primary]=\"isToday\">{{ focusDay.getDate() }}</span>\n </div>\n </div>\n <div class=\"grid grid-cols-[60px_1fr] flex-1 min-h-0 overflow-hidden items-stretch\">\n <div class=\"grid h-full min-h-0\" [style.grid-template-rows]=\"'repeat(' + totalRows + ', minmax(1.5rem, 1fr))'\">\n @for (row of hourRows; track row.topRow) {\n <div class=\"flex items-start justify-end min-h-0 overflow-hidden pr-2 text-[11px] tabular-nums opacity-50\"\n [style.grid-row]=\"row.topRow + '/' + row.bottomRow\">\n {{ row.hourLabel }}\n </div>\n }\n </div>\n <div class=\"grid relative auto-rows-fr h-full min-h-0\"\n [style.grid-template-rows]=\"'repeat(' + totalRows + ', minmax(1.5rem, 1fr))'\"\n [style.grid-template-columns]=\"'repeat(' + totalColumns + ', 1fr)'\">\n @for (row of hourRows; track row.topRow) {\n <div class=\"border-t border-base-200 pointer-events-none min-h-0\"\n [style.grid-row]=\"row.topRow + '/' + row.bottomRow\"\n [style.grid-column]=\"'1 / -1'\">\n </div>\n }\n @if (currentTimeRow > 0 && isToday) {\n <div class=\"relative z-[2] pointer-events-none\"\n [style.grid-row]=\"currentTimeRow\"\n [style.grid-column]=\"'1 / -1'\">\n <div class=\"absolute -left-1 -top-1 h-2 w-2 rounded-full bg-error\"></div>\n <div class=\"h-0.5 w-full bg-error\"></div>\n <div class=\"absolute left-0 top-0 -translate-x-2 -translate-y-1/2 rounded-full bg-error px-1.5 py-0.5 text-[10px] font-bold tabular-nums text-error-content shadow\">{{ currentTimeLabel }}</div>\n </div>\n }\n @for (event of displayEvents; track $index) {\n <div class=\"z-[1] min-h-0 overflow-hidden rounded-lg p-0.5 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary\"\n [style.grid-row]=\"getEventRow(event)\"\n [style.grid-column]=\"getEventColumn(event)\"\n (click)=\"onEventClick(event)\"\n (keyup.enter)=\"onEventClick(event)\"\n tabindex=\"0\">\n <mn-calendar-event [customComponent]=\"calendarEventComponent\" [event]=\"event\"></mn-calendar-event>\n </div>\n }\n </div>\n </div>\n</div>\n" }]
650
+ }], ctorParameters: () => [], propDecorators: { focusDay: [{
651
+ type: Input
652
+ }], eventsChanged: [{
653
+ type: Input
654
+ }], focusDayChanged: [{
655
+ type: Input
656
+ }], config: [{
657
+ type: Input
658
+ }], calendarEventComponent: [{
659
+ type: Input
660
+ }], eventClicked: [{
661
+ type: Output
662
+ }] } });
663
+
664
+ /**
665
+ * Renders a single row in the upcoming-events sidebar.
666
+ * Shows the event title, formatted date/time, and optional description.
667
+ */
668
+ class UpcomingEventRowComponent {
669
+ /** The event to display. */
670
+ event;
671
+ /** Emits the event when this row is clicked. */
672
+ eventClicked = new EventEmitter();
673
+ formattedDate = '';
674
+ formatter;
675
+ constructor() {
676
+ const formatter = inject(CALENDAR_DATE_FORMATTER, { optional: true });
677
+ this.formatter = formatter ?? new DefaultCalendarDateFormatter();
678
+ }
679
+ async ngOnInit() {
680
+ if (this.event) {
681
+ const start = await this.formatter.formatTime(this.event.startTime);
682
+ const end = await this.formatter.formatTime(this.event.endTime);
683
+ this.formattedDate = `${start} - ${end}`;
684
+ }
685
+ }
686
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: UpcomingEventRowComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
687
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: UpcomingEventRowComponent, isStandalone: true, selector: "mn-upcoming-event-row", inputs: { event: "event" }, outputs: { eventClicked: "eventClicked" }, ngImport: i0, template: "<!-- Sidebar row in the shared chip language: a colored rail from the event's own\n colour, a hover wash, and space-grouped content \u2014 no boxed borders. -->\n<div (click)=\"eventClicked.emit(event)\"\n (keyup.enter)=\"eventClicked.emit(event)\"\n class=\"grid grid-cols-[3px_1fr] items-stretch gap-2.5 mb-1.5 cursor-pointer rounded-lg p-2 transition-colors hover:bg-base-200 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-primary motion-reduce:transition-none\"\n tabindex=\"0\">\n <div class=\"rounded-full\" [style.background-color]=\"event.color.primaryColor\"></div>\n <div class=\"min-w-0\">\n <div class=\"truncate text-[13px] font-semibold\">{{ event.title }}</div>\n <div class=\"text-xs tabular-nums opacity-60\">{{ formattedDate }}</div>\n @if (event.description) {\n <div class=\"truncate text-xs opacity-50\">{{ event.description }}</div>\n }\n </div>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }] });
688
+ }
689
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: UpcomingEventRowComponent, decorators: [{
690
+ type: Component,
691
+ args: [{ selector: 'mn-upcoming-event-row', standalone: true, imports: [CommonModule], template: "<!-- Sidebar row in the shared chip language: a colored rail from the event's own\n colour, a hover wash, and space-grouped content \u2014 no boxed borders. -->\n<div (click)=\"eventClicked.emit(event)\"\n (keyup.enter)=\"eventClicked.emit(event)\"\n class=\"grid grid-cols-[3px_1fr] items-stretch gap-2.5 mb-1.5 cursor-pointer rounded-lg p-2 transition-colors hover:bg-base-200 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-primary motion-reduce:transition-none\"\n tabindex=\"0\">\n <div class=\"rounded-full\" [style.background-color]=\"event.color.primaryColor\"></div>\n <div class=\"min-w-0\">\n <div class=\"truncate text-[13px] font-semibold\">{{ event.title }}</div>\n <div class=\"text-xs tabular-nums opacity-60\">{{ formattedDate }}</div>\n @if (event.description) {\n <div class=\"truncate text-xs opacity-50\">{{ event.description }}</div>\n }\n </div>\n</div>\n" }]
692
+ }], ctorParameters: () => [], propDecorators: { event: [{
693
+ type: Input
694
+ }], eventClicked: [{
695
+ type: Output
696
+ }] } });
697
+
698
+ /**
699
+ * Sidebar component that lists the next 10 upcoming events
700
+ * (events whose end time is in the future), sorted by start time.
701
+ */
702
+ class UpcomingEventsComponent {
703
+ lang = inject(MnLanguageService);
704
+ cdr = inject(ChangeDetectorRef);
705
+ /**
706
+ * Accessible name for this control. Resolved through the conventional
707
+ * `mnCalendar.upcomingEvents` key so an app can translate it, falling back to English when the
708
+ * key is not defined rather than leaking the raw key into the UI.
709
+ */
710
+ get upcomingEventsLabel() {
711
+ return this.lang.translateIfPresent('mnCalendar.upcomingEvents') ?? 'Upcoming events';
712
+ }
713
+ /** Observable that emits the full event list whenever it changes. */
714
+ eventsChanged;
715
+ /** Resolved calendar configuration passed from the parent view. */
716
+ config;
717
+ /** Emits when an upcoming event row is clicked. */
718
+ eventClicked = new EventEmitter();
719
+ upcomingEvents = [];
720
+ title;
721
+ noEventsMessage;
722
+ destroy$ = new Subject();
723
+ constructor() {
724
+ this.title = DEFAULT_CALENDAR_CONFIG.upcomingEventsTitle;
725
+ this.noEventsMessage = DEFAULT_CALENDAR_CONFIG.noUpcomingEvents;
726
+ }
727
+ /** Re-read labels when the config input changes (e.g. after a locale switch). */
728
+ ngOnChanges(changes) {
729
+ if (changes['config'] && this.config) {
730
+ const resolved = resolveCalendarConfig(this.config);
731
+ this.title = resolved.upcomingEventsTitle;
732
+ this.noEventsMessage = resolved.noUpcomingEvents;
733
+ }
734
+ }
735
+ ngOnInit() {
736
+ const resolved = this.config ? resolveCalendarConfig(this.config) : { ...DEFAULT_CALENDAR_CONFIG };
737
+ this.title = resolved.upcomingEventsTitle;
738
+ this.noEventsMessage = resolved.noUpcomingEvents;
739
+ // Marked because the list is a plain field: in a zoneless app a stream emission is not by
740
+ // itself a reason for Angular to re-render, so the sidebar would keep showing the events it
741
+ // was first given.
742
+ if (this.eventsChanged) {
743
+ this.eventsChanged.pipe(takeUntil(this.destroy$)).subscribe(events => {
744
+ const now = new Date();
745
+ this.upcomingEvents = events
746
+ .filter(e => e.endTime > now)
747
+ .sort((a, b) => a.startTime.getTime() - b.startTime.getTime())
748
+ .slice(0, 10);
749
+ this.cdr.markForCheck();
750
+ });
751
+ }
752
+ }
753
+ ngOnDestroy() {
754
+ this.destroy$.next();
755
+ this.destroy$.complete();
756
+ }
757
+ /** trackBy for upcoming event rows. */
758
+ trackByEvent(_index, event) {
759
+ return event.id;
760
+ }
761
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: UpcomingEventsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
762
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: UpcomingEventsComponent, isStandalone: true, selector: "mn-upcoming-events", inputs: { eventsChanged: "eventsChanged", config: "config" }, outputs: { eventClicked: "eventClicked" }, usesOnChanges: true, ngImport: i0, template: "<div [attr.aria-label]=\"upcomingEventsLabel\" class=\"p-4\" role=\"complementary\">\n <div class=\"mb-3 flex items-center gap-2\">\n <h3 class=\"text-sm font-bold tracking-wide\">{{ title }}</h3>\n @if (upcomingEvents.length) {\n <span class=\"text-xs font-semibold tabular-nums opacity-45\">{{ upcomingEvents.length }}</span>\n }\n </div>\n @for (event of upcomingEvents; track $index) {\n <mn-upcoming-event-row\n [event]=\"event\"\n (eventClicked)=\"eventClicked.emit($event)\">\n </mn-upcoming-event-row>\n }\n @if (upcomingEvents.length === 0) {\n <div class=\"text-sm opacity-50\">{{ noEventsMessage }}</div>\n }\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "component", type: UpcomingEventRowComponent, selector: "mn-upcoming-event-row", inputs: ["event"], outputs: ["eventClicked"] }] });
763
+ }
764
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: UpcomingEventsComponent, decorators: [{
765
+ type: Component,
766
+ args: [{ selector: 'mn-upcoming-events', standalone: true, imports: [CommonModule, UpcomingEventRowComponent], template: "<div [attr.aria-label]=\"upcomingEventsLabel\" class=\"p-4\" role=\"complementary\">\n <div class=\"mb-3 flex items-center gap-2\">\n <h3 class=\"text-sm font-bold tracking-wide\">{{ title }}</h3>\n @if (upcomingEvents.length) {\n <span class=\"text-xs font-semibold tabular-nums opacity-45\">{{ upcomingEvents.length }}</span>\n }\n </div>\n @for (event of upcomingEvents; track $index) {\n <mn-upcoming-event-row\n [event]=\"event\"\n (eventClicked)=\"eventClicked.emit($event)\">\n </mn-upcoming-event-row>\n }\n @if (upcomingEvents.length === 0) {\n <div class=\"text-sm opacity-50\">{{ noEventsMessage }}</div>\n }\n</div>\n" }]
767
+ }], ctorParameters: () => [], propDecorators: { eventsChanged: [{
768
+ type: Input
769
+ }], config: [{
770
+ type: Input
771
+ }], eventClicked: [{
772
+ type: Output
773
+ }] } });
774
+
775
+ /** Lucide icons this file renders. */
776
+ const ICONS$1 = lucideIcons({ ChevronLeft: lucide.ChevronLeft, ChevronRight: lucide.ChevronRight });
777
+ /** Gives each calendar instance a unique id to tie its tabs to its view panel. */
778
+ let instanceCounter$1 = 0;
779
+ /**
780
+ * Main calendar orchestrator component.
781
+ *
782
+ * Provides a toolbar with view switching (month / week / day), date navigation,
783
+ * and an optional action button. The active view and an upcoming-events sidebar
784
+ * are rendered inside a responsive grid layout.
785
+ *
786
+ * All configuration (visible hours, locale, labels, mobile breakpoint) is read
787
+ * from the `mn-config.json5` system via {@link MN_CALENDAR_CONFIG}, falling back
788
+ * to the legacy {@link CALENDAR_CONFIG} injection token, then to built-in defaults.
789
+ * Date formatting is delegated to the {@link CALENDAR_DATE_FORMATTER} token.
790
+ *
791
+ * @example
792
+ * ```html
793
+ * <mn-calendar-view
794
+ * [showButton]="true"
795
+ * [buttonTitle]="'New Event'"
796
+ * [NewCalendarItemsEvent]="eventsEmitter"
797
+ * (RequestNewCalendarItemsEvent)="loadEvents($event)"
798
+ * (CalendarItemClickedEvent)="onEventClick($event)"
799
+ * (ButtonClickedEvent)="openModal()">
800
+ * </mn-calendar-view>
801
+ * ```
802
+ */
803
+ class CalendarViewComponent {
804
+ /** Lucide icons the template renders. */
805
+ icons = ICONS$1;
806
+ /**
807
+ * Accessible name for this control. Resolved through the conventional
808
+ * `mnCalendar.calendarView` key so an app can translate it, falling back to English when the
809
+ * key is not defined rather than leaking the raw key into the UI.
810
+ */
811
+ get calendarViewLabel() {
812
+ return this.lang.translateIfPresent('mnCalendar.calendarView') ?? 'Calendar view';
813
+ }
814
+ /** Whether to show the action button in the toolbar. */
815
+ showButton = false;
816
+ /** Label text for the action button. */
817
+ buttonTitle = '';
818
+ /** Array of buttons to display in the toolbar's top-right area. */
819
+ buttons = [];
820
+ /** Custom event renderer component type. */
821
+ CalendarEventComponent;
822
+ /** Observable or EventEmitter that pushes new event arrays into the calendar. */
823
+ NewCalendarItemsEvent;
824
+ /** Emits when the calendar needs fresh event data (e.g. after navigation). */
825
+ RequestNewCalendarItemsEvent = new EventEmitter();
826
+ /** Emits when a calendar event is clicked. */
827
+ CalendarItemClickedEvent = new EventEmitter();
828
+ /** Emits when the action button is clicked. */
829
+ ButtonClickedEvent = new EventEmitter();
830
+ CalendarView = CalendarView;
831
+ /** Ties the view tabs to the panel they control, uniquely per calendar. */
832
+ panelId = `mn-calendar-panel-${++instanceCounter$1}`;
833
+ currentView = CalendarView.WEEK;
834
+ focusDay = new Date();
835
+ viewOptions = [];
836
+ isMobileView = false;
837
+ /** BehaviorSubject so late-subscribing child views receive the last emitted events. */
838
+ internalEventsChanged = new BehaviorSubject([]);
839
+ /** Subject for broadcasting focus-day changes to child views. */
840
+ internalFocusDayChanged = new Subject();
841
+ destroy$ = new Subject();
842
+ config;
843
+ /** Reference to the injected mn-config object (mutated in-place on locale change). */
844
+ mnConfigRef;
845
+ destroyRef = inject(DestroyRef);
846
+ lang = inject(MnLanguageService);
847
+ cdr = inject(ChangeDetectorRef);
848
+ constructor() {
849
+ const mnConfig = inject(MN_CALENDAR_CONFIG, { optional: true });
850
+ const legacyConfig = inject(CALENDAR_CONFIG, { optional: true });
851
+ // Keep a reference to the injected config so we can re-read it after locale changes.
852
+ this.mnConfigRef = mnConfig;
853
+ // Priority: mn-config system > legacy CALENDAR_CONFIG > built-in defaults
854
+ const raw = mnConfig ?? legacyConfig ?? undefined;
855
+ this.config = resolveCalendarConfig(raw);
856
+ }
857
+ onResize() {
858
+ this.checkMobileView();
859
+ }
860
+ ngOnInit() {
861
+ this.rebuildFromConfig();
862
+ // Re-resolve config when locale changes (supports $translate in mn-config). Marked because
863
+ // the labels it rebuilds are plain fields: a locale switch arrives on a stream, which in a
864
+ // zoneless app is not by itself a reason for Angular to re-render the toolbar.
865
+ const sub = this.lang.locale$.pipe(skip(1)).subscribe(() => {
866
+ this.rebuildFromConfig();
867
+ this.cdr.markForCheck();
868
+ });
869
+ this.destroyRef.onDestroy(() => sub.unsubscribe());
870
+ this.checkMobileView();
871
+ this.RequestNewCalendarItemsEvent.emit(this.focusDay);
872
+ if (this.NewCalendarItemsEvent) {
873
+ this.NewCalendarItemsEvent.pipe(takeUntil(this.destroy$)).subscribe(events => {
874
+ this.internalEventsChanged.next(events);
875
+ });
876
+ }
877
+ }
878
+ ngOnDestroy() {
879
+ this.destroy$.next();
880
+ this.destroy$.complete();
881
+ }
882
+ /** Switches the active view. On mobile, forces day view. */
883
+ switchView(view) {
884
+ if (this.isMobileView) {
885
+ this.currentView = CalendarView.DAY;
886
+ return;
887
+ }
888
+ this.currentView = view;
889
+ }
890
+ /**
891
+ * Names the stretch of time on screen — the day, the week, or the month. It is
892
+ * the toolbar's orientation: without it, navigating leaves you somewhere with
893
+ * no label. Announced politely, so stepping through says where you landed.
894
+ */
895
+ get periodLabel() {
896
+ const locale = this.config.locale;
897
+ if (this.currentView === CalendarView.MONTH) {
898
+ return this.focusDay.toLocaleDateString(locale, { month: 'long', year: 'numeric' });
899
+ }
900
+ if (this.currentView === CalendarView.DAY) {
901
+ // No weekday: the view's own column header already says which day it is,
902
+ // and the year only earns its place once it stops being the obvious one.
903
+ return this.focusDay.toLocaleDateString(locale, {
904
+ day: 'numeric',
905
+ month: 'long',
906
+ ...(this.focusDay.getFullYear() !== new Date().getFullYear() ? { year: 'numeric' } : {}),
907
+ });
908
+ }
909
+ const start = this.startOfWeek(this.focusDay);
910
+ const end = new Date(start);
911
+ end.setDate(end.getDate() + 6);
912
+ // Only repeat what actually changes across the week's two ends.
913
+ const from = start.getFullYear() !== end.getFullYear()
914
+ ? start.toLocaleDateString(locale, { day: 'numeric', month: 'short', year: 'numeric' })
915
+ : start.toLocaleDateString(locale, {
916
+ day: 'numeric',
917
+ ...(start.getMonth() !== end.getMonth() ? { month: 'short' } : {}),
918
+ });
919
+ const to = end.toLocaleDateString(locale, { day: 'numeric', month: 'short', year: 'numeric' });
920
+ return `${from} – ${to}`;
921
+ }
922
+ /** The focus day as YYYY-MM-DD, for the toolbar's date picker. */
923
+ get focusDayString() {
924
+ const pad = (n) => n.toString().padStart(2, '0');
925
+ const d = this.focusDay;
926
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
927
+ }
928
+ /**
929
+ * Steps the calendar by one unit of whatever is on screen: a day in day view,
930
+ * a week in week view, a month in month view. Navigating by the visible unit is
931
+ * what makes one pair of arrows serve all three.
932
+ */
933
+ navigate(step) {
934
+ const next = new Date(this.focusDay);
935
+ switch (this.currentView) {
936
+ case CalendarView.DAY:
937
+ next.setDate(next.getDate() + step);
938
+ break;
939
+ case CalendarView.WEEK:
940
+ next.setDate(next.getDate() + step * 7);
941
+ break;
942
+ default:
943
+ this.setFocusDay(this.addMonths(this.focusDay, step));
944
+ return;
945
+ }
946
+ this.setFocusDay(next);
947
+ }
948
+ /** Returns the calendar to today. */
949
+ goToToday() {
950
+ this.setFocusDay(new Date());
951
+ }
952
+ /**
953
+ * Handles the toolbar date picker.
954
+ * @param value The date string in YYYY-MM-DD format.
955
+ */
956
+ onPickDate(value) {
957
+ if (!value)
958
+ return;
959
+ const picked = new Date(value + 'T00:00:00');
960
+ if (isNaN(picked.getTime()))
961
+ return;
962
+ this.setFocusDay(picked);
963
+ }
964
+ /** Handles a day click from the month view — switches to day view. */
965
+ onMonthDayClick(date) {
966
+ this.currentView = CalendarView.DAY;
967
+ this.setFocusDay(date);
968
+ }
969
+ /** Forwards a child event click to the parent output. */
970
+ onEventClick(event) {
971
+ this.CalendarItemClickedEvent.emit(event);
972
+ }
973
+ /** trackBy for view option buttons. */
974
+ trackByView(_index, item) {
975
+ return item.value;
976
+ }
977
+ /** Rebuilds view options and labels from the current config. */
978
+ rebuildFromConfig() {
979
+ // Re-resolve from the injected config reference which is mutated in-place by the provider on locale change.
980
+ if (this.mnConfigRef) {
981
+ this.config = resolveCalendarConfig(this.mnConfigRef);
982
+ }
983
+ this.viewOptions = [
984
+ { value: CalendarView.MONTH, label: this.config.viewLabels['MONTH'] ?? 'Month' },
985
+ { value: CalendarView.WEEK, label: this.config.viewLabels['WEEK'] ?? 'Week' },
986
+ { value: CalendarView.DAY, label: this.config.viewLabels['DAY'] ?? 'Day' }
987
+ ];
988
+ }
989
+ checkMobileView() {
990
+ const wasMobile = this.isMobileView;
991
+ const width = window.innerWidth;
992
+ // Honour the configured mobile breakpoint (default 768) rather than a hard-coded
993
+ // width: a seven-column week is cramped well before a phone's width, so the day
994
+ // view takes over earlier — and consumers can tune where via `mobileBreakpoint`.
995
+ const breakpoint = this.config.mobileBreakpoint;
996
+ this.isMobileView = width < breakpoint;
997
+ if (this.isMobileView && !wasMobile) {
998
+ this.currentView = CalendarView.DAY;
999
+ }
1000
+ }
1001
+ /**
1002
+ * Adds months without the end-of-month overflow `setMonth` alone produces —
1003
+ * 31 January plus one month is 28 February, not 3 March.
1004
+ */
1005
+ addMonths(date, months) {
1006
+ const day = date.getDate();
1007
+ const shifted = new Date(date);
1008
+ shifted.setDate(1);
1009
+ shifted.setMonth(shifted.getMonth() + months);
1010
+ const lastDayOfMonth = new Date(shifted.getFullYear(), shifted.getMonth() + 1, 0).getDate();
1011
+ shifted.setDate(Math.min(day, lastDayOfMonth));
1012
+ return shifted;
1013
+ }
1014
+ /** Monday of the week containing `date`, matching the grid the views draw. */
1015
+ startOfWeek(date) {
1016
+ const start = new Date(date);
1017
+ start.setHours(0, 0, 0, 0);
1018
+ start.setDate(start.getDate() - ((start.getDay() + 6) % 7));
1019
+ return start;
1020
+ }
1021
+ setFocusDay(date) {
1022
+ this.focusDay = date;
1023
+ this.internalFocusDayChanged.next(date);
1024
+ this.RequestNewCalendarItemsEvent.emit(date);
1025
+ }
1026
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarViewComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
1027
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: CalendarViewComponent, isStandalone: true, selector: "mn-calendar-view", inputs: { showButton: "showButton", buttonTitle: "buttonTitle", buttons: "buttons", CalendarEventComponent: "CalendarEventComponent", NewCalendarItemsEvent: "NewCalendarItemsEvent" }, outputs: { RequestNewCalendarItemsEvent: "RequestNewCalendarItemsEvent", CalendarItemClickedEvent: "CalendarItemClickedEvent", ButtonClickedEvent: "ButtonClickedEvent" }, host: { listeners: { "window:resize": "onResize()" } }, providers: [
1028
+ provideMnCalendarConfig(DEFAULT_CALENDAR_CONFIG),
1029
+ ], ngImport: i0, template: "<div class=\"w-full h-full flex flex-col\" role=\"application\" aria-label=\"Calendar\">\n\n <!-- Toolbar has one layout below the desktop (`lg`) width and one at it. Below\n `lg`: a controls row (Today anchored left, the right-hand cluster anchored\n right) with the \u2039 date \u203A nav centred on its own row beneath \u2014 the same\n shape from phone through tablet, so nothing wraps into a lopsided diagonal.\n At `lg`, where the upcoming-events sidebar also appears, the nav folds up\n inline after Today and the whole toolbar becomes a single row. The one JS\n breakpoint (`mobileBreakpoint`) governs the phone controls \u2014 icon-only\n picker, hidden view-switcher, forced day view \u2014 not the toolbar's shape. -->\n <div class=\"flex flex-wrap items-center gap-x-3 gap-y-2 py-3\">\n\n <button (click)=\"goToToday()\"\n [data]=\"{ variant: 'outline', size: 'md', color: 'primary' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n {{ config.todayLabel }}\n </button>\n\n <!-- Stepping through time. The arrows sit either side of the date they move,\n so the control and the thing it controls read as one unit. Below `lg` it\n sits centred on its own row (basis-full, ordered last) \u2014 a period header\n above the grid, tight rather than flinging the arrows to the row's edges.\n At `lg` it folds inline right after Today, taking a stable min-width so\n the arrows don't jitter as the label's length changes. -->\n <div class=\"flex basis-full order-last justify-center items-center gap-1\n lg:basis-auto lg:order-none lg:justify-start\">\n <button (click)=\"navigate(-1)\"\n [attr.aria-label]=\"config.previousLabel\"\n [data]=\"{ variant: 'text', size: 'md', color: 'gray' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n <svg [size]=\"18\" [lucideIcon]=\"icons.ChevronLeft\"></svg>\n </button>\n\n <h2 aria-live=\"polite\"\n class=\"text-center text-base font-semibold whitespace-nowrap px-1 lg:min-w-56\">\n {{ periodLabel }}\n </h2>\n\n <button (click)=\"navigate(1)\"\n [attr.aria-label]=\"config.nextLabel\"\n [data]=\"{ variant: 'text', size: 'md', color: 'gray' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n <svg [size]=\"18\" [lucideIcon]=\"icons.ChevronRight\"></svg>\n </button>\n </div>\n\n <!-- Right-hand controls travel together as one cluster with `ml-auto`, so they\n hold to the right of the row on every width \u2014 and when space runs short the\n whole group wraps to a new line as a unit rather than stranding a lone\n button. On desktop the cluster lands above the upcoming-events sidebar,\n using that otherwise-empty space. -->\n <div class=\"ml-auto flex items-center gap-2\">\n <!-- On mobile the picker collapses to its icon-only variant. -->\n <mn-lib-datetime (ngModelChange)=\"onPickDate($event)\"\n [ngModel]=\"focusDayString\"\n [props]=\"{ id: panelId + '-date', mode: 'date', placeholder: config.pickDateLabel, size: 'md', borderRadius: 'lg', hover: true, iconOnly: isMobileView }\"\n class=\"block\"></mn-lib-datetime>\n\n <!-- View switcher (month / week / day) \u2014 hidden on mobile, which is forced to day view. -->\n @if (!isMobileView) {\n <div [attr.aria-label]=\"calendarViewLabel\" class=\"flex border border-base-300 rounded-md overflow-hidden\"\n role=\"tablist\">\n @for (view of viewOptions; track view.value) {\n <button\n (click)=\"switchView(view.value)\"\n [attr.aria-controls]=\"panelId\"\n [attr.aria-selected]=\"currentView === view.value\"\n [data]=\"{ size: 'md', variant: currentView === view.value ? 'fill' : 'text', color: 'primary' }\"\n mnButton\n role=\"tab\"\n type=\"button\">\n {{ view.label }}\n </button>\n }\n </div>\n }\n\n <!-- Action buttons (custom buttons + optional showButton CTA). -->\n @if (buttons.length || showButton) {\n @for (btn of buttons; track btn.label) {\n <button (click)=\"btn.onClick()\" [data]=\"btn.buttonData || {}\" mnButton type=\"button\">\n {{ btn.label }}\n </button>\n }\n @if (showButton) {\n <button (click)=\"ButtonClickedEvent.emit()\" [data]=\"{}\" mnButton type=\"button\">\n {{ buttonTitle }}\n </button>\n }\n }\n </div>\n\n </div>\n\n <div class=\"grid grid-cols-1 lg:grid-cols-[1fr_220px] gap-3 flex-1 min-h-0\">\n <div [id]=\"panelId\" class=\"min-w-0 min-h-0 overflow-hidden overflow-y-auto\" role=\"tabpanel\">\n @if (currentView === CalendarView.MONTH) {\n <mn-calendar-month\n [focusDay]=\"focusDay\"\n [eventsChanged]=\"internalEventsChanged\"\n [focusDayChanged]=\"internalFocusDayChanged\"\n [config]=\"config\"\n (dayClicked)=\"onMonthDayClick($event)\">\n </mn-calendar-month>\n }\n @if (currentView === CalendarView.WEEK) {\n <mn-calendar-week\n [focusDay]=\"focusDay\"\n [eventsChanged]=\"internalEventsChanged\"\n [focusDayChanged]=\"internalFocusDayChanged\"\n [config]=\"config\"\n [calendarEventComponent]=\"CalendarEventComponent\"\n (eventClicked)=\"onEventClick($event)\">\n </mn-calendar-week>\n }\n @if (currentView === CalendarView.DAY) {\n <mn-calendar-day\n [focusDay]=\"focusDay\"\n [eventsChanged]=\"internalEventsChanged\"\n [focusDayChanged]=\"internalFocusDayChanged\"\n [config]=\"config\"\n [calendarEventComponent]=\"CalendarEventComponent\"\n (eventClicked)=\"onEventClick($event)\">\n </mn-calendar-day>\n }\n </div>\n <div class=\"hidden lg:block border-l border-base-300 overflow-auto\">\n <mn-upcoming-events\n [eventsChanged]=\"internalEventsChanged\"\n [config]=\"config\"\n (eventClicked)=\"onEventClick($event)\">\n </mn-upcoming-events>\n </div>\n </div>\n\n</div>\n", styles: [":host{display:flex;flex-direction:column;width:100%;height:100%}\n"], dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: CalendarMonthComponent, selector: "mn-calendar-month", inputs: ["focusDay", "eventsChanged", "focusDayChanged", "config"], outputs: ["dayClicked"] }, { kind: "component", type: CalendarWeekComponent, selector: "mn-calendar-week", inputs: ["focusDay", "eventsChanged", "focusDayChanged", "config", "calendarEventComponent"], outputs: ["eventClicked"] }, { kind: "component", type: CalendarDayComponent, selector: "mn-calendar-day", inputs: ["focusDay", "eventsChanged", "focusDayChanged", "config", "calendarEventComponent"], outputs: ["eventClicked"] }, { kind: "component", type: UpcomingEventsComponent, selector: "mn-upcoming-events", inputs: ["eventsChanged", "config"], outputs: ["eventClicked"] }, { kind: "component", type: MnButton, selector: "button[mnButton], a[mnButton]", inputs: ["data"] }, { kind: "component", type: MnDatetime, selector: "mn-lib-datetime", inputs: ["props"] }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }] });
1030
+ }
1031
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: CalendarViewComponent, decorators: [{
1032
+ type: Component,
1033
+ args: [{ selector: 'mn-calendar-view', standalone: true, imports: [
1034
+ CommonModule,
1035
+ FormsModule,
1036
+ CalendarMonthComponent,
1037
+ CalendarWeekComponent,
1038
+ CalendarDayComponent,
1039
+ UpcomingEventsComponent,
1040
+ MnButton,
1041
+ MnDatetime,
1042
+ LucideDynamicIcon,
1043
+ ], providers: [
1044
+ provideMnCalendarConfig(DEFAULT_CALENDAR_CONFIG),
1045
+ ], template: "<div class=\"w-full h-full flex flex-col\" role=\"application\" aria-label=\"Calendar\">\n\n <!-- Toolbar has one layout below the desktop (`lg`) width and one at it. Below\n `lg`: a controls row (Today anchored left, the right-hand cluster anchored\n right) with the \u2039 date \u203A nav centred on its own row beneath \u2014 the same\n shape from phone through tablet, so nothing wraps into a lopsided diagonal.\n At `lg`, where the upcoming-events sidebar also appears, the nav folds up\n inline after Today and the whole toolbar becomes a single row. The one JS\n breakpoint (`mobileBreakpoint`) governs the phone controls \u2014 icon-only\n picker, hidden view-switcher, forced day view \u2014 not the toolbar's shape. -->\n <div class=\"flex flex-wrap items-center gap-x-3 gap-y-2 py-3\">\n\n <button (click)=\"goToToday()\"\n [data]=\"{ variant: 'outline', size: 'md', color: 'primary' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n {{ config.todayLabel }}\n </button>\n\n <!-- Stepping through time. The arrows sit either side of the date they move,\n so the control and the thing it controls read as one unit. Below `lg` it\n sits centred on its own row (basis-full, ordered last) \u2014 a period header\n above the grid, tight rather than flinging the arrows to the row's edges.\n At `lg` it folds inline right after Today, taking a stable min-width so\n the arrows don't jitter as the label's length changes. -->\n <div class=\"flex basis-full order-last justify-center items-center gap-1\n lg:basis-auto lg:order-none lg:justify-start\">\n <button (click)=\"navigate(-1)\"\n [attr.aria-label]=\"config.previousLabel\"\n [data]=\"{ variant: 'text', size: 'md', color: 'gray' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n <svg [size]=\"18\" [lucideIcon]=\"icons.ChevronLeft\"></svg>\n </button>\n\n <h2 aria-live=\"polite\"\n class=\"text-center text-base font-semibold whitespace-nowrap px-1 lg:min-w-56\">\n {{ periodLabel }}\n </h2>\n\n <button (click)=\"navigate(1)\"\n [attr.aria-label]=\"config.nextLabel\"\n [data]=\"{ variant: 'text', size: 'md', color: 'gray' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n <svg [size]=\"18\" [lucideIcon]=\"icons.ChevronRight\"></svg>\n </button>\n </div>\n\n <!-- Right-hand controls travel together as one cluster with `ml-auto`, so they\n hold to the right of the row on every width \u2014 and when space runs short the\n whole group wraps to a new line as a unit rather than stranding a lone\n button. On desktop the cluster lands above the upcoming-events sidebar,\n using that otherwise-empty space. -->\n <div class=\"ml-auto flex items-center gap-2\">\n <!-- On mobile the picker collapses to its icon-only variant. -->\n <mn-lib-datetime (ngModelChange)=\"onPickDate($event)\"\n [ngModel]=\"focusDayString\"\n [props]=\"{ id: panelId + '-date', mode: 'date', placeholder: config.pickDateLabel, size: 'md', borderRadius: 'lg', hover: true, iconOnly: isMobileView }\"\n class=\"block\"></mn-lib-datetime>\n\n <!-- View switcher (month / week / day) \u2014 hidden on mobile, which is forced to day view. -->\n @if (!isMobileView) {\n <div [attr.aria-label]=\"calendarViewLabel\" class=\"flex border border-base-300 rounded-md overflow-hidden\"\n role=\"tablist\">\n @for (view of viewOptions; track view.value) {\n <button\n (click)=\"switchView(view.value)\"\n [attr.aria-controls]=\"panelId\"\n [attr.aria-selected]=\"currentView === view.value\"\n [data]=\"{ size: 'md', variant: currentView === view.value ? 'fill' : 'text', color: 'primary' }\"\n mnButton\n role=\"tab\"\n type=\"button\">\n {{ view.label }}\n </button>\n }\n </div>\n }\n\n <!-- Action buttons (custom buttons + optional showButton CTA). -->\n @if (buttons.length || showButton) {\n @for (btn of buttons; track btn.label) {\n <button (click)=\"btn.onClick()\" [data]=\"btn.buttonData || {}\" mnButton type=\"button\">\n {{ btn.label }}\n </button>\n }\n @if (showButton) {\n <button (click)=\"ButtonClickedEvent.emit()\" [data]=\"{}\" mnButton type=\"button\">\n {{ buttonTitle }}\n </button>\n }\n }\n </div>\n\n </div>\n\n <div class=\"grid grid-cols-1 lg:grid-cols-[1fr_220px] gap-3 flex-1 min-h-0\">\n <div [id]=\"panelId\" class=\"min-w-0 min-h-0 overflow-hidden overflow-y-auto\" role=\"tabpanel\">\n @if (currentView === CalendarView.MONTH) {\n <mn-calendar-month\n [focusDay]=\"focusDay\"\n [eventsChanged]=\"internalEventsChanged\"\n [focusDayChanged]=\"internalFocusDayChanged\"\n [config]=\"config\"\n (dayClicked)=\"onMonthDayClick($event)\">\n </mn-calendar-month>\n }\n @if (currentView === CalendarView.WEEK) {\n <mn-calendar-week\n [focusDay]=\"focusDay\"\n [eventsChanged]=\"internalEventsChanged\"\n [focusDayChanged]=\"internalFocusDayChanged\"\n [config]=\"config\"\n [calendarEventComponent]=\"CalendarEventComponent\"\n (eventClicked)=\"onEventClick($event)\">\n </mn-calendar-week>\n }\n @if (currentView === CalendarView.DAY) {\n <mn-calendar-day\n [focusDay]=\"focusDay\"\n [eventsChanged]=\"internalEventsChanged\"\n [focusDayChanged]=\"internalFocusDayChanged\"\n [config]=\"config\"\n [calendarEventComponent]=\"CalendarEventComponent\"\n (eventClicked)=\"onEventClick($event)\">\n </mn-calendar-day>\n }\n </div>\n <div class=\"hidden lg:block border-l border-base-300 overflow-auto\">\n <mn-upcoming-events\n [eventsChanged]=\"internalEventsChanged\"\n [config]=\"config\"\n (eventClicked)=\"onEventClick($event)\">\n </mn-upcoming-events>\n </div>\n </div>\n\n</div>\n", styles: [":host{display:flex;flex-direction:column;width:100%;height:100%}\n"] }]
1046
+ }], ctorParameters: () => [], propDecorators: { showButton: [{
1047
+ type: Input
1048
+ }], buttonTitle: [{
1049
+ type: Input
1050
+ }], buttons: [{
1051
+ type: Input
1052
+ }], CalendarEventComponent: [{
1053
+ type: Input
1054
+ }], NewCalendarItemsEvent: [{
1055
+ type: Input
1056
+ }], RequestNewCalendarItemsEvent: [{
1057
+ type: Output
1058
+ }], CalendarItemClickedEvent: [{
1059
+ type: Output
1060
+ }], ButtonClickedEvent: [{
1061
+ type: Output
1062
+ }], onResize: [{
1063
+ type: HostListener,
1064
+ args: ['window:resize']
1065
+ }] } });
1066
+
1067
+ /** Lucide icons this file renders. */
1068
+ const ICONS = lucideIcons({ ChevronLeft: lucide.ChevronLeft, ChevronRight: lucide.ChevronRight });
1069
+ /** A full week: the most days the strip shows, and the size it aligns to. */
1070
+ const DAYS_IN_WEEK = 7;
1071
+ /** Fewest days worth showing before the picker takes over instead. */
1072
+ const MIN_TILE_COUNT = 3;
1073
+ /** `Date.getDay()` value for Monday. */
1074
+ const MONDAY = 1;
1075
+ /**
1076
+ * Width one day occupies. Days are sized by their content: a three-letter weekday
1077
+ * and a two-digit number at their set sizes measure about 72px including padding,
1078
+ * plus the `gap-1` beside it. Rounded up, because coming in under the real width
1079
+ * overflows the strip into the arrow beside it.
1080
+ */
1081
+ const TILE_SLOT_WIDTH = 80;
1082
+ /** Space reserved for the two borderless window arrows and their gaps. */
1083
+ const ARROWS_ZONE_WIDTH = 88;
1084
+ /**
1085
+ * Space the Today button claims, including the bar's own horizontal padding and
1086
+ * the gap beside it.
1087
+ */
1088
+ const CONTROLS_ZONE_WIDTH = 150;
1089
+ /**
1090
+ * Everything on the controls row that isn't a day tile. The month is a full-width
1091
+ * header on its own line now, so it no longer competes with the days for room —
1092
+ * which is why more of them fit at a given width than they used to.
1093
+ */
1094
+ const RESERVED_WIDTH = ARROWS_ZONE_WIDTH + CONTROLS_ZONE_WIDTH;
1095
+ /** Below this the strip can't hold even {@link MIN_TILE_COUNT} days. */
1096
+ const COMPACT_MAX_WIDTH = MIN_TILE_COUNT * TILE_SLOT_WIDTH + RESERVED_WIDTH;
1097
+ /** Assumed width before the first measurement (and during server-side rendering). */
1098
+ const UNMEASURED_WIDTH = 960;
1099
+ /** Counter used to give each bar instance a unique date-picker id. */
1100
+ let instanceCounter = 0;
1101
+ /**
1102
+ * Reusable, responsive date selector bar.
1103
+ *
1104
+ * Renders a "Today" button, a month header, previous/next arrows and a strip of
1105
+ * day tiles. Selecting a tile or pressing "Today" emits the chosen day via
1106
+ * {@link dateSelected}. The arrows only shift the visible days and never emit.
1107
+ *
1108
+ * Given room, the strip is a whole week running Monday to Sunday, so the weekday
1109
+ * columns hold still as you page and no weekday appears twice. As the bar narrows
1110
+ * it shows fewer days rather than adding a second row — a partial strip has no
1111
+ * week to align to, so it slides to keep the selection in view instead. Narrower
1112
+ * still, and the days give way to a date picker beside Today, which keeps every
1113
+ * date reachable on a phone rather than leaving a strip too cramped to use.
1114
+ *
1115
+ * Selecting a day already on the strip leaves it exactly where it is; a selection
1116
+ * from outside moves the strip to where that day is. The arrows page by whatever
1117
+ * is on show, without touching the selection.
1118
+ *
1119
+ * The component carries no hard-coded copy: button, placeholder and assistive
1120
+ * text are supplied through the label inputs, and day/month names follow
1121
+ * {@link locale} (falling back to the active {@link MnLanguageService} locale).
1122
+ *
1123
+ * @example
1124
+ * ```html
1125
+ * <mn-date-selector-bar
1126
+ * [selectedDate]="focusDay"
1127
+ * [todayLabel]="'Today'"
1128
+ * [pickDateLabel]="'Pick a date'"
1129
+ * [locale]="'nl-NL'"
1130
+ * (dateSelected)="onDaySelected($event)">
1131
+ * </mn-date-selector-bar>
1132
+ * ```
1133
+ */
1134
+ class MnDateSelectorBar {
1135
+ /** Lucide icons the template renders. */
1136
+ icons = ICONS;
1137
+ /** The currently selected date, provided by the parent. */
1138
+ selectedDate = input(this.getToday(), ...(ngDevMode ? [{ debugName: "selectedDate" }] : []));
1139
+ /** Label for the "Today" button. */
1140
+ todayLabel = input('Today', ...(ngDevMode ? [{ debugName: "todayLabel" }] : []));
1141
+ /** Placeholder for the date picker shown in place of a too-cramped week strip. */
1142
+ pickDateLabel = input('Pick a date', ...(ngDevMode ? [{ debugName: "pickDateLabel" }] : []));
1143
+ /** Accessible name for the previous-week arrow. */
1144
+ previousLabel = input('Show the previous week', ...(ngDevMode ? [{ debugName: "previousLabel" }] : []));
1145
+ /** Accessible name for the next-week arrow. */
1146
+ nextLabel = input('Show the next week', ...(ngDevMode ? [{ debugName: "nextLabel" }] : []));
1147
+ /** Accessible name for the day strip as a whole. */
1148
+ dayStripLabel = input('Select a day', ...(ngDevMode ? [{ debugName: "dayStripLabel" }] : []));
1149
+ /**
1150
+ * BCP 47 locale used to format day/month names. When empty, the active
1151
+ * {@link MnLanguageService} locale is used.
1152
+ */
1153
+ locale = input('', ...(ngDevMode ? [{ debugName: "locale" }] : []));
1154
+ /** Emits when the user selects a new date. */
1155
+ dateSelected = output();
1156
+ /** Unique id for this instance's date picker, so several bars can coexist. */
1157
+ pickerId = `mn-dsb-date-${++instanceCounter}`;
1158
+ destroyRef = inject(DestroyRef);
1159
+ injector = inject(Injector);
1160
+ host = inject((ElementRef));
1161
+ lang = inject(MnLanguageService);
1162
+ tileButtons = viewChildren('tileButton', ...(ngDevMode ? [{ debugName: "tileButtons" }] : []));
1163
+ /** The bar's own width in px, tracked so the layout follows its container. */
1164
+ containerWidth = signal(0, ...(ngDevMode ? [{ debugName: "containerWidth" }] : []));
1165
+ /** Bumped whenever the active language changes so name formatting re-runs. */
1166
+ localeTick = signal(0, ...(ngDevMode ? [{ debugName: "localeTick" }] : []));
1167
+ /** How the bar is arranged at the current width. */
1168
+ layout = computed(() => (this.containerWidth() || UNMEASURED_WIDTH) >= COMPACT_MAX_WIDTH ? 'inline' : 'compact', ...(ngDevMode ? [{ debugName: "layout" }] : []));
1169
+ /** Whether the day strip is shown, or the picker has taken its place. */
1170
+ showDayStrip = computed(() => this.layout() === 'inline', ...(ngDevMode ? [{ debugName: "showDayStrip" }] : []));
1171
+ /**
1172
+ * Days in the visible strip: a full week where there's room, fewer as the bar
1173
+ * narrows. The bar drops days rather than adding a second row, so it stays one
1174
+ * line at every width it can.
1175
+ */
1176
+ tileCount = computed(() => {
1177
+ if (!this.showDayStrip())
1178
+ return 0;
1179
+ const width = this.containerWidth() || UNMEASURED_WIDTH;
1180
+ const fits = Math.floor((width - RESERVED_WIDTH) / TILE_SLOT_WIDTH);
1181
+ return Math.min(DAYS_IN_WEEK, Math.max(MIN_TILE_COUNT, fits));
1182
+ }, ...(ngDevMode ? [{ debugName: "tileCount" }] : []));
1183
+ /** Effective locale: explicit input, else the active app locale. */
1184
+ effectiveLocale = computed(() => {
1185
+ this.localeTick();
1186
+ return this.locale() || this.lang.locale;
1187
+ }, ...(ngDevMode ? [{ debugName: "effectiveLocale" }] : []));
1188
+ /**
1189
+ * First day of the visible strip — the week's Monday when a whole week is on
1190
+ * show, otherwise whatever start keeps the selection in view.
1191
+ *
1192
+ * The strip holds still while the selection stays on screen; a selection
1193
+ * outside it moves to where that day is. The arrows write here directly to page
1194
+ * away from the selection.
1195
+ */
1196
+ windowStart = linkedSignal({ ...(ngDevMode ? { debugName: "windowStart" } : {}), source: () => ({ selected: this.selectedDate().getTime(), count: this.tileCount() }),
1197
+ computation: (source, previous) => {
1198
+ const selected = new Date(source.selected);
1199
+ const { count } = source;
1200
+ const anchored = this.anchorFor(selected, count);
1201
+ if (!previous || count === 0)
1202
+ return anchored;
1203
+ const current = previous.value;
1204
+ const holdsSelection = (() => {
1205
+ const offset = this.daysBetween(current, selected);
1206
+ return offset >= 0 && offset < count;
1207
+ })();
1208
+ // A whole week must also still be Monday-aligned to be worth keeping —
1209
+ // otherwise a strip that grew back to seven would keep a stale start.
1210
+ const stillValid = count === DAYS_IN_WEEK
1211
+ ? holdsSelection && current.getDay() === MONDAY
1212
+ : holdsSelection;
1213
+ return stillValid ? current : anchored;
1214
+ } });
1215
+ /**
1216
+ * Index of the tile that is currently keyboard-reachable (roving tabindex).
1217
+ * Tracks the selection so Tab lands on the selected day, falling back to Monday
1218
+ * when the selection has been paged out of sight.
1219
+ */
1220
+ focusedIndex = linkedSignal({ ...(ngDevMode ? { debugName: "focusedIndex" } : {}), source: () => this.selectedDate().getTime(),
1221
+ computation: () => Math.max(0, this.indexOfSelected()) });
1222
+ /** The visible days, derived from the window start and the current selection. */
1223
+ dayTiles = computed(() => {
1224
+ const count = this.tileCount();
1225
+ if (count === 0)
1226
+ return [];
1227
+ const start = this.windowStart();
1228
+ const selected = this.selectedDate();
1229
+ const today = this.getToday();
1230
+ const locale = this.effectiveLocale();
1231
+ const tiles = [];
1232
+ let previousMonth = -1;
1233
+ let previousYear = -1;
1234
+ for (let i = 0; i < count; i++) {
1235
+ const date = new Date(start);
1236
+ date.setDate(start.getDate() + i);
1237
+ const month = date.getMonth();
1238
+ const year = date.getFullYear();
1239
+ const startsNewMonth = i > 0 && (month !== previousMonth || year !== previousYear);
1240
+ tiles.push({
1241
+ date,
1242
+ dayName: date.toLocaleDateString(locale, { weekday: 'short' }),
1243
+ dayNumber: date.getDate(),
1244
+ monthName: date.toLocaleDateString(locale, { month: 'short' }),
1245
+ startsNewMonth,
1246
+ isSelected: this.isSameDay(date, selected),
1247
+ isToday: this.isSameDay(date, today),
1248
+ accessibleLabel: date.toLocaleDateString(locale, {
1249
+ weekday: 'long',
1250
+ day: 'numeric',
1251
+ month: 'long',
1252
+ year: 'numeric',
1253
+ }),
1254
+ });
1255
+ previousMonth = month;
1256
+ previousYear = year;
1257
+ }
1258
+ return tiles;
1259
+ }, ...(ngDevMode ? [{ debugName: "dayTiles" }] : []));
1260
+ /**
1261
+ * The month the strip is currently in, spelled out for the header that titles
1262
+ * the bar — so the days below are never just loose numbers. Reads as a range
1263
+ * when the strip straddles two months, and carries both years when it straddles
1264
+ * two of those.
1265
+ */
1266
+ monthCaption = computed(() => {
1267
+ const locale = this.effectiveLocale();
1268
+ const tiles = this.dayTiles();
1269
+ // With no strip to describe — the compact layout — the header names the
1270
+ // month the selection sits in, so the bar is never unlabelled.
1271
+ if (!tiles.length) {
1272
+ return this.selectedDate().toLocaleDateString(locale, { month: 'long', year: 'numeric' });
1273
+ }
1274
+ const first = tiles[0].date;
1275
+ const last = tiles[tiles.length - 1].date;
1276
+ if (first.getFullYear() !== last.getFullYear()) {
1277
+ const from = first.toLocaleDateString(locale, { month: 'long', year: 'numeric' });
1278
+ const to = last.toLocaleDateString(locale, { month: 'long', year: 'numeric' });
1279
+ return `${from} – ${to}`;
1280
+ }
1281
+ if (first.getMonth() !== last.getMonth()) {
1282
+ const from = first.toLocaleDateString(locale, { month: 'long' });
1283
+ const to = last.toLocaleDateString(locale, { month: 'long', year: 'numeric' });
1284
+ return `${from} – ${to}`;
1285
+ }
1286
+ return first.toLocaleDateString(locale, { month: 'long', year: 'numeric' });
1287
+ }, ...(ngDevMode ? [{ debugName: "monthCaption" }] : []));
1288
+ /** The selected date formatted as YYYY-MM-DD for the date-picker input. */
1289
+ selectedDateString = computed(() => {
1290
+ const d = this.selectedDate();
1291
+ const pad = (n) => n.toString().padStart(2, '0');
1292
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
1293
+ }, ...(ngDevMode ? [{ debugName: "selectedDateString" }] : []));
1294
+ /**
1295
+ * Props for the compact-layout date picker. Sized to match the Today button it
1296
+ * sits beside, and filling the rest of the row so it stays an easy tap target.
1297
+ */
1298
+ pickerProps = computed(() => ({
1299
+ id: this.pickerId,
1300
+ mode: 'date',
1301
+ placeholder: this.pickDateLabel(),
1302
+ size: 'md',
1303
+ borderRadius: 'lg',
1304
+ hover: true,
1305
+ fullWidth: true,
1306
+ }), ...(ngDevMode ? [{ debugName: "pickerProps" }] : []));
1307
+ ngOnInit() {
1308
+ // Re-format names when the active language changes.
1309
+ this.lang.locale$
1310
+ .pipe(takeUntilDestroyed(this.destroyRef))
1311
+ .subscribe(() => this.localeTick.update((v) => v + 1));
1312
+ this.observeOwnWidth();
1313
+ }
1314
+ /** Shows the days before the visible ones, without changing the selection. */
1315
+ navigatePrevious() {
1316
+ this.shiftWindow(-1);
1317
+ }
1318
+ /** Shows the days after the visible ones, without changing the selection. */
1319
+ navigateNext() {
1320
+ this.shiftWindow(1);
1321
+ }
1322
+ /** Returns to today: brings today into the strip and selects it. */
1323
+ goToToday() {
1324
+ const today = this.getToday();
1325
+ // Move explicitly: when today is already selected the window signal has no new
1326
+ // source value to react to, but the user still expects to land on it.
1327
+ this.windowStart.set(this.anchorFor(today, this.tileCount()));
1328
+ // Only emit when today isn't already selected, so pressing "Today" while on
1329
+ // today doesn't trigger a redundant reload.
1330
+ if (!this.isSameDay(today, this.selectedDate())) {
1331
+ this.dateSelected.emit(today);
1332
+ }
1333
+ }
1334
+ /** Selects a date and emits it, unless it is already the selected day. */
1335
+ selectDate(date) {
1336
+ // Re-selecting the current day is a no-op: emitting again would make
1337
+ // consumers reload for no change.
1338
+ if (this.isSameDay(date, this.selectedDate()))
1339
+ return;
1340
+ this.dateSelected.emit(date);
1341
+ }
1342
+ /**
1343
+ * Handles the date-picker model change: shows the picked day's week and emits
1344
+ * it (unless it is already the selected day).
1345
+ * @param value The date string in YYYY-MM-DD format.
1346
+ */
1347
+ onDateModelChanged(value) {
1348
+ if (!value)
1349
+ return;
1350
+ const picked = new Date(value + 'T00:00:00');
1351
+ if (isNaN(picked.getTime()))
1352
+ return;
1353
+ this.windowStart.set(this.anchorFor(picked, this.tileCount()));
1354
+ // Picking the day that's already selected shouldn't re-emit.
1355
+ if (!this.isSameDay(picked, this.selectedDate())) {
1356
+ this.dateSelected.emit(picked);
1357
+ }
1358
+ }
1359
+ /** Whether the tile at `index` is the one reachable with Tab. */
1360
+ isTabbable(index) {
1361
+ return index === this.focusedIndex();
1362
+ }
1363
+ /** Remembers which tile last held focus, so Tab returns to it. */
1364
+ onTileFocus(index) {
1365
+ this.focusedIndex.set(index);
1366
+ }
1367
+ /**
1368
+ * Moves focus across the week with the arrow keys. Running off either end turns
1369
+ * the page to the neighbouring week and lands on the day that continues the run,
1370
+ * so the weeks read as one continuous calendar.
1371
+ */
1372
+ onTileKeydown(event, index) {
1373
+ const lastIndex = this.tileCount() - 1;
1374
+ switch (event.key) {
1375
+ case 'ArrowRight':
1376
+ event.preventDefault();
1377
+ if (index < lastIndex) {
1378
+ this.moveFocusTo(index + 1);
1379
+ }
1380
+ else {
1381
+ // Off the end: turn the page and land on the day that continues the run.
1382
+ this.shiftWindow(1);
1383
+ this.moveFocusTo(0);
1384
+ }
1385
+ break;
1386
+ case 'ArrowLeft':
1387
+ event.preventDefault();
1388
+ if (index > 0) {
1389
+ this.moveFocusTo(index - 1);
1390
+ }
1391
+ else {
1392
+ this.shiftWindow(-1);
1393
+ this.moveFocusTo(lastIndex);
1394
+ }
1395
+ break;
1396
+ case 'Home':
1397
+ event.preventDefault();
1398
+ this.moveFocusTo(0);
1399
+ break;
1400
+ case 'End':
1401
+ event.preventDefault();
1402
+ this.moveFocusTo(lastIndex);
1403
+ break;
1404
+ default:
1405
+ break;
1406
+ }
1407
+ }
1408
+ /** trackBy key for day tiles. */
1409
+ trackByTile(_index, tile) {
1410
+ return tile.date.getTime();
1411
+ }
1412
+ /**
1413
+ * Moves the strip by `pages` of whatever it is currently showing. Paging by the
1414
+ * visible count is what keeps a full week Monday-aligned — seven days forward
1415
+ * from a Monday is the next Monday.
1416
+ */
1417
+ shiftWindow(pages) {
1418
+ const next = new Date(this.windowStart());
1419
+ next.setDate(next.getDate() + pages * this.tileCount());
1420
+ this.windowStart.set(next);
1421
+ }
1422
+ /** Focuses the tile at `index` once the week has rendered. */
1423
+ moveFocusTo(index) {
1424
+ this.focusedIndex.set(index);
1425
+ afterNextRender(() => this.tileButtons()[index]?.nativeElement.focus(), { injector: this.injector });
1426
+ }
1427
+ /** Index of the selected day within the visible week, or -1 when off-week. */
1428
+ indexOfSelected() {
1429
+ return this.dayTiles().findIndex((tile) => tile.isSelected);
1430
+ }
1431
+ /**
1432
+ * Where the strip should start to show `date` among `count` days: the week's
1433
+ * Monday when a whole week is on show, otherwise centred on the day, since a
1434
+ * partial strip has no week to align to.
1435
+ */
1436
+ anchorFor(date, count) {
1437
+ if (count === DAYS_IN_WEEK)
1438
+ return this.startOfWeek(date);
1439
+ const start = new Date(date);
1440
+ start.setHours(0, 0, 0, 0);
1441
+ start.setDate(start.getDate() - Math.floor(count / 2));
1442
+ return start;
1443
+ }
1444
+ /**
1445
+ * Returns the Monday of the week containing `date`. `getDay()` counts from
1446
+ * Sunday, so the shift maps Sunday to the end of the week rather than the start.
1447
+ */
1448
+ startOfWeek(date) {
1449
+ const start = new Date(date);
1450
+ start.setHours(0, 0, 0, 0);
1451
+ start.setDate(start.getDate() - ((start.getDay() + 6) % 7));
1452
+ return start;
1453
+ }
1454
+ /** Whole calendar days from `from` to `to`, ignoring time of day and DST. */
1455
+ daysBetween(from, to) {
1456
+ const a = Date.UTC(from.getFullYear(), from.getMonth(), from.getDate());
1457
+ const b = Date.UTC(to.getFullYear(), to.getMonth(), to.getDate());
1458
+ return Math.round((b - a) / 86400000);
1459
+ }
1460
+ /** Tracks the bar's own width so the layout responds to its container. */
1461
+ observeOwnWidth() {
1462
+ const element = this.host.nativeElement;
1463
+ this.containerWidth.set(element.getBoundingClientRect().width);
1464
+ if (typeof ResizeObserver === 'undefined')
1465
+ return;
1466
+ const observer = new ResizeObserver((entries) => {
1467
+ const width = entries[0]?.contentRect.width ?? 0;
1468
+ if (width > 0)
1469
+ this.containerWidth.set(width);
1470
+ });
1471
+ observer.observe(element);
1472
+ this.destroyRef.onDestroy(() => observer.disconnect());
1473
+ }
1474
+ /** Returns a Date object for today at midnight. */
1475
+ getToday() {
1476
+ const now = new Date();
1477
+ now.setHours(0, 0, 0, 0);
1478
+ return now;
1479
+ }
1480
+ /** Checks whether two dates fall on the same calendar day. */
1481
+ isSameDay(a, b) {
1482
+ return (a.getFullYear() === b.getFullYear() &&
1483
+ a.getMonth() === b.getMonth() &&
1484
+ a.getDate() === b.getDate());
1485
+ }
1486
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnDateSelectorBar, deps: [], target: i0.ɵɵFactoryTarget.Component });
1487
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "21.1.3", type: MnDateSelectorBar, isStandalone: true, selector: "mn-date-selector-bar", inputs: { selectedDate: { classPropertyName: "selectedDate", publicName: "selectedDate", isSignal: true, isRequired: false, transformFunction: null }, todayLabel: { classPropertyName: "todayLabel", publicName: "todayLabel", isSignal: true, isRequired: false, transformFunction: null }, pickDateLabel: { classPropertyName: "pickDateLabel", publicName: "pickDateLabel", isSignal: true, isRequired: false, transformFunction: null }, previousLabel: { classPropertyName: "previousLabel", publicName: "previousLabel", isSignal: true, isRequired: false, transformFunction: null }, nextLabel: { classPropertyName: "nextLabel", publicName: "nextLabel", isSignal: true, isRequired: false, transformFunction: null }, dayStripLabel: { classPropertyName: "dayStripLabel", publicName: "dayStripLabel", isSignal: true, isRequired: false, transformFunction: null }, locale: { classPropertyName: "locale", publicName: "locale", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { dateSelected: "dateSelected" }, host: { classAttribute: "block" }, viewQueries: [{ propertyName: "tileButtons", predicate: ["tileButton"], descendants: true, isSignal: true }], ngImport: i0, template: "<!-- Date selector bar. Layout is driven by the bar's own measured width, so it\n rearranges for the space the bar was given, not for the viewport. The strip\n never stacks: as room runs out it shows fewer days, then hands over to the\n picker. Nothing here is boxed \u2014 spacing does the grouping, not borders. -->\n<div class=\"flex flex-col gap-2 px-4 py-3\">\n\n <!-- Month header. Titles the whole bar so the day numbers below are never loose:\n it names the month the strip is in (or, when compact, the month the\n selection sits in), reading as a range where the strip crosses a boundary.\n On its own line it has room to be spelled out, and no longer steals width\n from the days the way the old inline caption did. -->\n <div aria-hidden=\"true\"\n class=\"text-center text-sm font-semibold tracking-wide whitespace-nowrap opacity-80\">\n {{ monthCaption() }}\n </div>\n\n <!-- Controls row. Today and the strip travel together as one centred cluster, so\n Today sits right beside the days instead of stranded against the far edge;\n the gap between them matches the strip's own spacing. When the strip gives\n way to the picker, the picker fills the row and Today anchors its left. -->\n <div class=\"flex items-center justify-center gap-3\">\n\n <!-- Today: returns the strip and the selection to the current day. Outlined\n rather than filled, so the one filled-primary element on the bar is the\n selected day \u2014 Today shares the primary accent without competing with it. -->\n <button (click)=\"goToToday()\"\n [data]=\"{ variant: 'outline', color: 'primary', size: 'md' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n {{ todayLabel() }}\n </button>\n\n <!-- Too narrow for a usable strip, so the picker takes its place beside Today.\n Every date stays reachable on a phone, in one tap rather than by paging;\n the month header above keeps the compact bar labelled like the wide one. -->\n @if (!showDayStrip()) {\n <mn-lib-datetime (ngModelChange)=\"onDateModelChanged($event)\"\n [ngModel]=\"selectedDateString()\"\n [props]=\"pickerProps()\"\n class=\"block min-w-0 flex-1\"></mn-lib-datetime>\n }\n\n <!-- Arrows and days, sized to their own content so the row can centre them\n together with Today as a single cluster \u2014 rather than the days drifting to\n the middle of the leftover space, away from the button. -->\n @if (showDayStrip()) {\n <div [attr.aria-label]=\"dayStripLabel()\"\n class=\"flex min-w-0 items-center gap-3\"\n role=\"group\">\n <button (click)=\"navigatePrevious()\"\n [attr.aria-label]=\"previousLabel()\"\n [data]=\"{ variant: 'text', size: 'md', color: 'gray' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n <svg [size]=\"18\" [lucideIcon]=\"icons.ChevronLeft\"></svg>\n </button>\n\n <!-- Days read on one line so each sits at the same height as the buttons\n either side of it. Roving tabindex: one day is in the tab order, the\n arrow keys move between the rest and page the strip at either end. -->\n <div class=\"flex min-w-0 gap-1\">\n @for (tile of dayTiles(); track tile.date.getTime(); let i = $index) {\n <!-- Selected is the filled pill; today is called out by its number\n alone, tinted primary \u2014 no box, in keeping with a bar that groups\n by spacing rather than borders. When today is also the selected\n day the fill takes over, since there is nothing left to tell apart.\n A month break is marked by extra breathing room rather than a rule,\n so the run of days stays unbroken; the header names both months. -->\n <button #tileButton\n (click)=\"selectDate(tile.date)\"\n (focus)=\"onTileFocus(i)\"\n (keydown)=\"onTileKeydown($event, i)\"\n [attr.aria-current]=\"tile.isToday ? 'date' : null\"\n [attr.aria-label]=\"tile.accessibleLabel\"\n [attr.aria-pressed]=\"tile.isSelected\"\n [attr.tabindex]=\"isTabbable(i) ? 0 : -1\"\n [class.bg-primary]=\"tile.isSelected\"\n [class.hover:bg-base-200]=\"!tile.isSelected\"\n [class.ml-3]=\"tile.startsNewMonth\"\n [class.text-primary-content]=\"tile.isSelected\"\n class=\"flex min-w-16 shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none\"\n type=\"button\">\n <span [class.opacity-60]=\"!tile.isSelected\"\n [class.opacity-90]=\"tile.isSelected\"\n aria-hidden=\"true\"\n class=\"text-xs font-medium uppercase\">\n {{ tile.dayName }}\n </span>\n <!-- Today's number carries the primary tint, unless the tile is\n filled \u2014 then it wears the fill's own text colour instead. -->\n <span [class.text-primary]=\"tile.isToday && !tile.isSelected\"\n aria-hidden=\"true\"\n class=\"font-bold tabular-nums\">{{ tile.dayNumber }}</span>\n </button>\n }\n </div>\n\n <button (click)=\"navigateNext()\"\n [attr.aria-label]=\"nextLabel()\"\n [data]=\"{ variant: 'text', size: 'md', color: 'gray' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n <svg [size]=\"18\" [lucideIcon]=\"icons.ChevronRight\"></svg>\n </button>\n </div>\n }\n </div>\n</div>\n", dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: FormsModule }, { kind: "directive", type: i1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: MnButton, selector: "button[mnButton], a[mnButton]", inputs: ["data"] }, { kind: "component", type: MnDatetime, selector: "mn-lib-datetime", inputs: ["props"] }, { kind: "component", type: LucideDynamicIcon, selector: "svg[lucideIcon]", inputs: ["lucideIcon"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1488
+ }
1489
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.1.3", ngImport: i0, type: MnDateSelectorBar, decorators: [{
1490
+ type: Component,
1491
+ args: [{ selector: 'mn-date-selector-bar', standalone: true, imports: [
1492
+ CommonModule,
1493
+ FormsModule,
1494
+ MnButton,
1495
+ MnDatetime,
1496
+ LucideDynamicIcon,
1497
+ ], changeDetection: ChangeDetectionStrategy.OnPush, host: { class: 'block' }, template: "<!-- Date selector bar. Layout is driven by the bar's own measured width, so it\n rearranges for the space the bar was given, not for the viewport. The strip\n never stacks: as room runs out it shows fewer days, then hands over to the\n picker. Nothing here is boxed \u2014 spacing does the grouping, not borders. -->\n<div class=\"flex flex-col gap-2 px-4 py-3\">\n\n <!-- Month header. Titles the whole bar so the day numbers below are never loose:\n it names the month the strip is in (or, when compact, the month the\n selection sits in), reading as a range where the strip crosses a boundary.\n On its own line it has room to be spelled out, and no longer steals width\n from the days the way the old inline caption did. -->\n <div aria-hidden=\"true\"\n class=\"text-center text-sm font-semibold tracking-wide whitespace-nowrap opacity-80\">\n {{ monthCaption() }}\n </div>\n\n <!-- Controls row. Today and the strip travel together as one centred cluster, so\n Today sits right beside the days instead of stranded against the far edge;\n the gap between them matches the strip's own spacing. When the strip gives\n way to the picker, the picker fills the row and Today anchors its left. -->\n <div class=\"flex items-center justify-center gap-3\">\n\n <!-- Today: returns the strip and the selection to the current day. Outlined\n rather than filled, so the one filled-primary element on the bar is the\n selected day \u2014 Today shares the primary accent without competing with it. -->\n <button (click)=\"goToToday()\"\n [data]=\"{ variant: 'outline', color: 'primary', size: 'md' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n {{ todayLabel() }}\n </button>\n\n <!-- Too narrow for a usable strip, so the picker takes its place beside Today.\n Every date stays reachable on a phone, in one tap rather than by paging;\n the month header above keeps the compact bar labelled like the wide one. -->\n @if (!showDayStrip()) {\n <mn-lib-datetime (ngModelChange)=\"onDateModelChanged($event)\"\n [ngModel]=\"selectedDateString()\"\n [props]=\"pickerProps()\"\n class=\"block min-w-0 flex-1\"></mn-lib-datetime>\n }\n\n <!-- Arrows and days, sized to their own content so the row can centre them\n together with Today as a single cluster \u2014 rather than the days drifting to\n the middle of the leftover space, away from the button. -->\n @if (showDayStrip()) {\n <div [attr.aria-label]=\"dayStripLabel()\"\n class=\"flex min-w-0 items-center gap-3\"\n role=\"group\">\n <button (click)=\"navigatePrevious()\"\n [attr.aria-label]=\"previousLabel()\"\n [data]=\"{ variant: 'text', size: 'md', color: 'gray' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n <svg [size]=\"18\" [lucideIcon]=\"icons.ChevronLeft\"></svg>\n </button>\n\n <!-- Days read on one line so each sits at the same height as the buttons\n either side of it. Roving tabindex: one day is in the tab order, the\n arrow keys move between the rest and page the strip at either end. -->\n <div class=\"flex min-w-0 gap-1\">\n @for (tile of dayTiles(); track tile.date.getTime(); let i = $index) {\n <!-- Selected is the filled pill; today is called out by its number\n alone, tinted primary \u2014 no box, in keeping with a bar that groups\n by spacing rather than borders. When today is also the selected\n day the fill takes over, since there is nothing left to tell apart.\n A month break is marked by extra breathing room rather than a rule,\n so the run of days stays unbroken; the header names both months. -->\n <button #tileButton\n (click)=\"selectDate(tile.date)\"\n (focus)=\"onTileFocus(i)\"\n (keydown)=\"onTileKeydown($event, i)\"\n [attr.aria-current]=\"tile.isToday ? 'date' : null\"\n [attr.aria-label]=\"tile.accessibleLabel\"\n [attr.aria-pressed]=\"tile.isSelected\"\n [attr.tabindex]=\"isTabbable(i) ? 0 : -1\"\n [class.bg-primary]=\"tile.isSelected\"\n [class.hover:bg-base-200]=\"!tile.isSelected\"\n [class.ml-3]=\"tile.startsNewMonth\"\n [class.text-primary-content]=\"tile.isSelected\"\n class=\"flex min-w-16 shrink-0 cursor-pointer items-center justify-center gap-1.5 rounded-lg px-3 py-2 text-sm transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary motion-reduce:transition-none\"\n type=\"button\">\n <span [class.opacity-60]=\"!tile.isSelected\"\n [class.opacity-90]=\"tile.isSelected\"\n aria-hidden=\"true\"\n class=\"text-xs font-medium uppercase\">\n {{ tile.dayName }}\n </span>\n <!-- Today's number carries the primary tint, unless the tile is\n filled \u2014 then it wears the fill's own text colour instead. -->\n <span [class.text-primary]=\"tile.isToday && !tile.isSelected\"\n aria-hidden=\"true\"\n class=\"font-bold tabular-nums\">{{ tile.dayNumber }}</span>\n </button>\n }\n </div>\n\n <button (click)=\"navigateNext()\"\n [attr.aria-label]=\"nextLabel()\"\n [data]=\"{ variant: 'text', size: 'md', color: 'gray' }\"\n class=\"shrink-0\"\n mnButton\n type=\"button\">\n <svg [size]=\"18\" [lucideIcon]=\"icons.ChevronRight\"></svg>\n </button>\n </div>\n }\n </div>\n</div>\n" }]
1498
+ }], propDecorators: { selectedDate: [{ type: i0.Input, args: [{ isSignal: true, alias: "selectedDate", required: false }] }], todayLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "todayLabel", required: false }] }], pickDateLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "pickDateLabel", required: false }] }], previousLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "previousLabel", required: false }] }], nextLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "nextLabel", required: false }] }], dayStripLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "dayStripLabel", required: false }] }], locale: [{ type: i0.Input, args: [{ isSignal: true, alias: "locale", required: false }] }], dateSelected: [{ type: i0.Output, args: ["dateSelected"] }], tileButtons: [{ type: i0.ViewChildren, args: ['tileButton', { isSignal: true }] }] } });
1499
+
1500
+ /**
1501
+ * Public API of the `mn-angular-lib/calendar` entry point: calendar views and the date selector bar.
1502
+ *
1503
+ * Each entry point is its own module in the published package, so a consumer's bundler
1504
+ * splits it into the chunk that uses it instead of loading the whole library at startup.
1505
+ * The root `mn-angular-lib` entry re-exports every entry point.
1506
+ */
1507
+
1508
+ /**
1509
+ * Generated bundle index. Do not edit.
1510
+ */
1511
+
1512
+ export { CalendarDayComponent, CalendarEventComponent, CalendarEventDefaultComponent, CalendarMonthComponent, CalendarViewComponent, CalendarWeekComponent, MnDateSelectorBar, UpcomingEventRowComponent, UpcomingEventsComponent };
1513
+ //# sourceMappingURL=mn-angular-lib-calendar.mjs.map