@molecule/app-class-schedule-angular 0.0.0-stage → 0.0.1-stage

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.
@@ -0,0 +1,860 @@
1
+ /**
2
+ * ClassSchedule component (React parity).
3
+ *
4
+ * @module
5
+ */
6
+ import { NgTemplateOutlet } from '@angular/common';
7
+ import { Component, EventEmitter, Output, TemplateRef } from '@angular/core';
8
+ import { useLocale, useTranslation } from '@molecule/app-angular';
9
+ import { getClassMap } from '@molecule/app-ui';
10
+ import { assignLanes, formatHourLabel } from './helpers.js';
11
+ import * as i0 from "@angular/core";
12
+ const _forTrack0 = ($index, $item) => $item.event.id;
13
+ function ClassSchedule_For_3_Template(rf, ctx) { if (rf & 1) {
14
+ i0.ɵɵelementStart(0, "div", 5);
15
+ i0.ɵɵtext(1);
16
+ i0.ɵɵelementEnd();
17
+ } if (rf & 2) {
18
+ const weekday_r1 = ctx.$implicit;
19
+ const ctx_r1 = i0.ɵɵnextContext();
20
+ i0.ɵɵclassMap(ctx_r1.dayHeaderClasses());
21
+ i0.ɵɵattribute("id", ctx_r1.dayHeaderId(weekday_r1))("data-weekday", weekday_r1);
22
+ i0.ɵɵadvance();
23
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.weekdayLabel(weekday_r1), " ");
24
+ } }
25
+ function ClassSchedule_For_6_Template(rf, ctx) { if (rf & 1) {
26
+ i0.ɵɵelementStart(0, "div", 6);
27
+ i0.ɵɵtext(1);
28
+ i0.ɵɵelementEnd();
29
+ } if (rf & 2) {
30
+ const index_r3 = ctx.$implicit;
31
+ const ctx_r1 = i0.ɵɵnextContext();
32
+ i0.ɵɵclassMap(ctx_r1.hourLabelClasses());
33
+ i0.ɵɵattribute("style", ctx_r1.hourLabelStyle(index_r3), i0.ɵɵsanitizeStyle);
34
+ i0.ɵɵadvance();
35
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.formatHourLabel(ctx_r1.startMinutes() + index_r3 * ctx_r1.MINUTES_PER_HOUR), " ");
36
+ } }
37
+ function ClassSchedule_For_8_Conditional_1_For_1_Template(rf, ctx) { if (rf & 1) {
38
+ const _r4 = i0.ɵɵgetCurrentView();
39
+ i0.ɵɵelementStart(0, "button", 9);
40
+ i0.ɵɵlistener("click", function ClassSchedule_For_8_Conditional_1_For_1_Template_button_click_0_listener() { const index_r5 = i0.ɵɵrestoreView(_r4).$implicit; const weekday_r6 = i0.ɵɵnextContext(2).$implicit; const ctx_r1 = i0.ɵɵnextContext(); return i0.ɵɵresetView(ctx_r1.emitSlot(weekday_r6, index_r5)); });
41
+ i0.ɵɵelementEnd();
42
+ } if (rf & 2) {
43
+ const index_r5 = ctx.$implicit;
44
+ const weekday_r6 = i0.ɵɵnextContext(2).$implicit;
45
+ const ctx_r1 = i0.ɵɵnextContext();
46
+ i0.ɵɵattribute("data-weekday", weekday_r6)("data-start", ctx_r1.startMinutes() + index_r5 * ctx_r1.MINUTES_PER_HOUR)("aria-label", ctx_r1.slotLabel(weekday_r6, index_r5))("style", ctx_r1.slotStyle(index_r5), i0.ɵɵsanitizeStyle);
47
+ } }
48
+ function ClassSchedule_For_8_Conditional_1_Template(rf, ctx) { if (rf & 1) {
49
+ i0.ɵɵrepeaterCreate(0, ClassSchedule_For_8_Conditional_1_For_1_Template, 1, 4, "button", 8, i0.ɵɵrepeaterTrackByIdentity);
50
+ } if (rf & 2) {
51
+ const ctx_r1 = i0.ɵɵnextContext(2);
52
+ i0.ɵɵrepeater(ctx_r1.hours());
53
+ } }
54
+ function ClassSchedule_For_8_For_3_Conditional_0_Conditional_2_Template(rf, ctx) { if (rf & 1) {
55
+ i0.ɵɵelementContainer(0, 14);
56
+ } if (rf & 2) {
57
+ i0.ɵɵproperty("ngTemplateOutlet", ctx);
58
+ } }
59
+ function ClassSchedule_For_8_For_3_Conditional_0_Conditional_3_Template(rf, ctx) { if (rf & 1) {
60
+ i0.ɵɵtext(0);
61
+ } if (rf & 2) {
62
+ const tile_r8 = i0.ɵɵnextContext(2).$implicit;
63
+ const ctx_r1 = i0.ɵɵnextContext(2);
64
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.textOf(tile_r8.event.title), " ");
65
+ } }
66
+ function ClassSchedule_For_8_For_3_Conditional_0_Conditional_4_Conditional_1_Template(rf, ctx) { if (rf & 1) {
67
+ i0.ɵɵelementContainer(0, 14);
68
+ } if (rf & 2) {
69
+ i0.ɵɵproperty("ngTemplateOutlet", ctx);
70
+ } }
71
+ function ClassSchedule_For_8_For_3_Conditional_0_Conditional_4_Conditional_2_Template(rf, ctx) { if (rf & 1) {
72
+ i0.ɵɵtext(0);
73
+ } if (rf & 2) {
74
+ const tile_r8 = i0.ɵɵnextContext(3).$implicit;
75
+ const ctx_r1 = i0.ɵɵnextContext(2);
76
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.textOf(tile_r8.event.subtitle), " ");
77
+ } }
78
+ function ClassSchedule_For_8_For_3_Conditional_0_Conditional_4_Template(rf, ctx) { if (rf & 1) {
79
+ i0.ɵɵelementStart(0, "span", 17);
80
+ i0.ɵɵconditionalCreate(1, ClassSchedule_For_8_For_3_Conditional_0_Conditional_4_Conditional_1_Template, 1, 1, "ng-container", 14)(2, ClassSchedule_For_8_For_3_Conditional_0_Conditional_4_Conditional_2_Template, 1, 1);
81
+ i0.ɵɵelementEnd();
82
+ } if (rf & 2) {
83
+ let tmp_23_0;
84
+ const tile_r8 = i0.ɵɵnextContext(2).$implicit;
85
+ const ctx_r1 = i0.ɵɵnextContext(2);
86
+ i0.ɵɵclassMap(ctx_r1.subtitleClasses());
87
+ i0.ɵɵadvance();
88
+ i0.ɵɵconditional((tmp_23_0 = ctx_r1.templateOf(tile_r8.event.subtitle)) ? 1 : 2, tmp_23_0);
89
+ } }
90
+ function ClassSchedule_For_8_For_3_Conditional_0_Conditional_5_Conditional_1_Template(rf, ctx) { if (rf & 1) {
91
+ i0.ɵɵelementContainer(0, 14);
92
+ } if (rf & 2) {
93
+ i0.ɵɵproperty("ngTemplateOutlet", ctx);
94
+ } }
95
+ function ClassSchedule_For_8_For_3_Conditional_0_Conditional_5_Conditional_2_Template(rf, ctx) { if (rf & 1) {
96
+ i0.ɵɵtext(0);
97
+ } if (rf & 2) {
98
+ const tile_r8 = i0.ɵɵnextContext(3).$implicit;
99
+ const ctx_r1 = i0.ɵɵnextContext(2);
100
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.textOf(tile_r8.event.meta), " ");
101
+ } }
102
+ function ClassSchedule_For_8_For_3_Conditional_0_Conditional_5_Template(rf, ctx) { if (rf & 1) {
103
+ i0.ɵɵelementStart(0, "span", 18);
104
+ i0.ɵɵconditionalCreate(1, ClassSchedule_For_8_For_3_Conditional_0_Conditional_5_Conditional_1_Template, 1, 1, "ng-container", 14)(2, ClassSchedule_For_8_For_3_Conditional_0_Conditional_5_Conditional_2_Template, 1, 1);
105
+ i0.ɵɵelementEnd();
106
+ } if (rf & 2) {
107
+ let tmp_23_0;
108
+ const tile_r8 = i0.ɵɵnextContext(2).$implicit;
109
+ const ctx_r1 = i0.ɵɵnextContext(2);
110
+ i0.ɵɵclassMap(ctx_r1.metaClasses(tile_r8.event));
111
+ i0.ɵɵadvance();
112
+ i0.ɵɵconditional((tmp_23_0 = ctx_r1.templateOf(tile_r8.event.meta)) ? 1 : 2, tmp_23_0);
113
+ } }
114
+ function ClassSchedule_For_8_For_3_Conditional_0_Template(rf, ctx) { if (rf & 1) {
115
+ const _r7 = i0.ɵɵgetCurrentView();
116
+ i0.ɵɵelementStart(0, "button", 12);
117
+ i0.ɵɵlistener("click", function ClassSchedule_For_8_For_3_Conditional_0_Template_button_click_0_listener() { i0.ɵɵrestoreView(_r7); const tile_r8 = i0.ɵɵnextContext().$implicit; const ctx_r1 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r1.eventClick.emit(tile_r8.event)); });
118
+ i0.ɵɵelementStart(1, "span", 13);
119
+ i0.ɵɵconditionalCreate(2, ClassSchedule_For_8_For_3_Conditional_0_Conditional_2_Template, 1, 1, "ng-container", 14)(3, ClassSchedule_For_8_For_3_Conditional_0_Conditional_3_Template, 1, 1);
120
+ i0.ɵɵelementEnd();
121
+ i0.ɵɵconditionalCreate(4, ClassSchedule_For_8_For_3_Conditional_0_Conditional_4_Template, 3, 3, "span", 15);
122
+ i0.ɵɵconditionalCreate(5, ClassSchedule_For_8_For_3_Conditional_0_Conditional_5_Template, 3, 3, "span", 16);
123
+ i0.ɵɵelementStart(6, "span");
124
+ i0.ɵɵtext(7);
125
+ i0.ɵɵelementEnd()();
126
+ } if (rf & 2) {
127
+ let tmp_24_0;
128
+ const tile_r8 = i0.ɵɵnextContext().$implicit;
129
+ const ctx_r1 = i0.ɵɵnextContext(2);
130
+ i0.ɵɵclassMap(ctx_r1.tileClasses(tile_r8.event));
131
+ i0.ɵɵattribute("data-event-id", tile_r8.event.id)("style", ctx_r1.tileStyle(tile_r8), i0.ɵɵsanitizeStyle);
132
+ i0.ɵɵadvance(2);
133
+ i0.ɵɵconditional((tmp_24_0 = ctx_r1.templateOf(tile_r8.event.title)) ? 2 : 3, tmp_24_0);
134
+ i0.ɵɵadvance(2);
135
+ i0.ɵɵconditional(tile_r8.event.subtitle ? 4 : -1);
136
+ i0.ɵɵadvance();
137
+ i0.ɵɵconditional(tile_r8.event.meta ? 5 : -1);
138
+ i0.ɵɵadvance();
139
+ i0.ɵɵclassMap(ctx_r1.srOnlyClasses());
140
+ i0.ɵɵadvance();
141
+ i0.ɵɵtextInterpolate(tile_r8.label);
142
+ } }
143
+ function ClassSchedule_For_8_For_3_Conditional_1_Conditional_2_Template(rf, ctx) { if (rf & 1) {
144
+ i0.ɵɵelementContainer(0, 14);
145
+ } if (rf & 2) {
146
+ i0.ɵɵproperty("ngTemplateOutlet", ctx);
147
+ } }
148
+ function ClassSchedule_For_8_For_3_Conditional_1_Conditional_3_Template(rf, ctx) { if (rf & 1) {
149
+ i0.ɵɵtext(0);
150
+ } if (rf & 2) {
151
+ const tile_r8 = i0.ɵɵnextContext(2).$implicit;
152
+ const ctx_r1 = i0.ɵɵnextContext(2);
153
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.textOf(tile_r8.event.title), " ");
154
+ } }
155
+ function ClassSchedule_For_8_For_3_Conditional_1_Conditional_4_Conditional_1_Template(rf, ctx) { if (rf & 1) {
156
+ i0.ɵɵelementContainer(0, 14);
157
+ } if (rf & 2) {
158
+ i0.ɵɵproperty("ngTemplateOutlet", ctx);
159
+ } }
160
+ function ClassSchedule_For_8_For_3_Conditional_1_Conditional_4_Conditional_2_Template(rf, ctx) { if (rf & 1) {
161
+ i0.ɵɵtext(0);
162
+ } if (rf & 2) {
163
+ const tile_r8 = i0.ɵɵnextContext(3).$implicit;
164
+ const ctx_r1 = i0.ɵɵnextContext(2);
165
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.textOf(tile_r8.event.subtitle), " ");
166
+ } }
167
+ function ClassSchedule_For_8_For_3_Conditional_1_Conditional_4_Template(rf, ctx) { if (rf & 1) {
168
+ i0.ɵɵelementStart(0, "span", 17);
169
+ i0.ɵɵconditionalCreate(1, ClassSchedule_For_8_For_3_Conditional_1_Conditional_4_Conditional_1_Template, 1, 1, "ng-container", 14)(2, ClassSchedule_For_8_For_3_Conditional_1_Conditional_4_Conditional_2_Template, 1, 1);
170
+ i0.ɵɵelementEnd();
171
+ } if (rf & 2) {
172
+ let tmp_23_0;
173
+ const tile_r8 = i0.ɵɵnextContext(2).$implicit;
174
+ const ctx_r1 = i0.ɵɵnextContext(2);
175
+ i0.ɵɵclassMap(ctx_r1.subtitleClasses());
176
+ i0.ɵɵadvance();
177
+ i0.ɵɵconditional((tmp_23_0 = ctx_r1.templateOf(tile_r8.event.subtitle)) ? 1 : 2, tmp_23_0);
178
+ } }
179
+ function ClassSchedule_For_8_For_3_Conditional_1_Conditional_5_Conditional_1_Template(rf, ctx) { if (rf & 1) {
180
+ i0.ɵɵelementContainer(0, 14);
181
+ } if (rf & 2) {
182
+ i0.ɵɵproperty("ngTemplateOutlet", ctx);
183
+ } }
184
+ function ClassSchedule_For_8_For_3_Conditional_1_Conditional_5_Conditional_2_Template(rf, ctx) { if (rf & 1) {
185
+ i0.ɵɵtext(0);
186
+ } if (rf & 2) {
187
+ const tile_r8 = i0.ɵɵnextContext(3).$implicit;
188
+ const ctx_r1 = i0.ɵɵnextContext(2);
189
+ i0.ɵɵtextInterpolate1(" ", ctx_r1.textOf(tile_r8.event.meta), " ");
190
+ } }
191
+ function ClassSchedule_For_8_For_3_Conditional_1_Conditional_5_Template(rf, ctx) { if (rf & 1) {
192
+ i0.ɵɵelementStart(0, "span", 18);
193
+ i0.ɵɵconditionalCreate(1, ClassSchedule_For_8_For_3_Conditional_1_Conditional_5_Conditional_1_Template, 1, 1, "ng-container", 14)(2, ClassSchedule_For_8_For_3_Conditional_1_Conditional_5_Conditional_2_Template, 1, 1);
194
+ i0.ɵɵelementEnd();
195
+ } if (rf & 2) {
196
+ let tmp_23_0;
197
+ const tile_r8 = i0.ɵɵnextContext(2).$implicit;
198
+ const ctx_r1 = i0.ɵɵnextContext(2);
199
+ i0.ɵɵclassMap(ctx_r1.metaClasses(tile_r8.event));
200
+ i0.ɵɵadvance();
201
+ i0.ɵɵconditional((tmp_23_0 = ctx_r1.templateOf(tile_r8.event.meta)) ? 1 : 2, tmp_23_0);
202
+ } }
203
+ function ClassSchedule_For_8_For_3_Conditional_1_Template(rf, ctx) { if (rf & 1) {
204
+ i0.ɵɵelementStart(0, "div", 19)(1, "span", 13);
205
+ i0.ɵɵconditionalCreate(2, ClassSchedule_For_8_For_3_Conditional_1_Conditional_2_Template, 1, 1, "ng-container", 14)(3, ClassSchedule_For_8_For_3_Conditional_1_Conditional_3_Template, 1, 1);
206
+ i0.ɵɵelementEnd();
207
+ i0.ɵɵconditionalCreate(4, ClassSchedule_For_8_For_3_Conditional_1_Conditional_4_Template, 3, 3, "span", 15);
208
+ i0.ɵɵconditionalCreate(5, ClassSchedule_For_8_For_3_Conditional_1_Conditional_5_Template, 3, 3, "span", 16);
209
+ i0.ɵɵelementStart(6, "span");
210
+ i0.ɵɵtext(7);
211
+ i0.ɵɵelementEnd()();
212
+ } if (rf & 2) {
213
+ let tmp_24_0;
214
+ const tile_r8 = i0.ɵɵnextContext().$implicit;
215
+ const ctx_r1 = i0.ɵɵnextContext(2);
216
+ i0.ɵɵclassMap(ctx_r1.tileClasses(tile_r8.event));
217
+ i0.ɵɵattribute("data-event-id", tile_r8.event.id)("style", ctx_r1.tileStyle(tile_r8), i0.ɵɵsanitizeStyle);
218
+ i0.ɵɵadvance(2);
219
+ i0.ɵɵconditional((tmp_24_0 = ctx_r1.templateOf(tile_r8.event.title)) ? 2 : 3, tmp_24_0);
220
+ i0.ɵɵadvance(2);
221
+ i0.ɵɵconditional(tile_r8.event.subtitle ? 4 : -1);
222
+ i0.ɵɵadvance();
223
+ i0.ɵɵconditional(tile_r8.event.meta ? 5 : -1);
224
+ i0.ɵɵadvance();
225
+ i0.ɵɵclassMap(ctx_r1.srOnlyClasses());
226
+ i0.ɵɵadvance();
227
+ i0.ɵɵtextInterpolate(tile_r8.label);
228
+ } }
229
+ function ClassSchedule_For_8_For_3_Template(rf, ctx) { if (rf & 1) {
230
+ i0.ɵɵconditionalCreate(0, ClassSchedule_For_8_For_3_Conditional_0_Template, 8, 10, "button", 10)(1, ClassSchedule_For_8_For_3_Conditional_1_Template, 8, 10, "div", 11);
231
+ } if (rf & 2) {
232
+ const ctx_r1 = i0.ɵɵnextContext(2);
233
+ i0.ɵɵconditional(ctx_r1.hasEventClick() ? 0 : 1);
234
+ } }
235
+ function ClassSchedule_For_8_Template(rf, ctx) { if (rf & 1) {
236
+ i0.ɵɵelementStart(0, "div", 7);
237
+ i0.ɵɵconditionalCreate(1, ClassSchedule_For_8_Conditional_1_Template, 2, 0);
238
+ i0.ɵɵrepeaterCreate(2, ClassSchedule_For_8_For_3_Template, 2, 1, null, null, _forTrack0);
239
+ i0.ɵɵelementEnd();
240
+ } if (rf & 2) {
241
+ const weekday_r6 = ctx.$implicit;
242
+ const ctx_r1 = i0.ɵɵnextContext();
243
+ i0.ɵɵclassMap(ctx_r1.relativeClasses());
244
+ i0.ɵɵattribute("aria-labelledby", ctx_r1.dayHeaderId(weekday_r6))("data-weekday", weekday_r6)("style", ctx_r1.columnStyle(), i0.ɵɵsanitizeStyle);
245
+ i0.ɵɵadvance();
246
+ i0.ɵɵconditional(ctx_r1.hasSlotClick() ? 1 : -1);
247
+ i0.ɵɵadvance();
248
+ i0.ɵɵrepeater(ctx_r1.tilesFor(weekday_r6));
249
+ } }
250
+ /** Minutes in one hour. */
251
+ const MINUTES_PER_HOUR = 60;
252
+ /** Weekday numbers that fall on the weekend (`0` = Sunday, `6` = Saturday). */
253
+ const WEEKEND_DAYS = new Set([0, 6]);
254
+ /** The ISO weekday numbers, Sunday first. */
255
+ const ALL_WEEKDAYS = [0, 1, 2, 3, 4, 5, 6];
256
+ /**
257
+ * Next value of the module-wide schedule id counter (React `useId()`'s
258
+ * counterpart): the day headers' ids are derived from it, and each day column
259
+ * names its header through `aria-labelledby`.
260
+ */
261
+ let nextBaseId = 0;
262
+ /**
263
+ * Weekly class-schedule grid. Renders a 7-column (or 5-column when
264
+ * `showWeekendCols` is `false`) timetable with hour rows down the left
265
+ * and absolutely positioned event tiles inside each day column. Events
266
+ * that overlap on the same weekday are split into side-by-side lanes.
267
+ *
268
+ * The host IS the outer `<div>` (`div[mol-class-schedule]`), matching React's
269
+ * root exactly. Node-valued event lines (`title`, `subtitle`, `meta`) take a
270
+ * `TemplateRef`, rendered through `NgTemplateOutlet`.
271
+ */
272
+ export class ClassSchedule {
273
+ /** Events to render. */
274
+ events = [];
275
+ /** First day-of-week (`0` = Sunday, `1` = Monday). Defaults to `1` at read time. */
276
+ weekStartsOn;
277
+ /** Visible hour range `[start, end]`. Defaults to `[8, 18]` at read time. */
278
+ dayHours;
279
+ /** Pixel height of one hour row. Defaults to `60` at read time. */
280
+ cellHeight;
281
+ /** Whether to show Saturday + Sunday columns. Defaults to `true` at read time. */
282
+ showWeekendCols;
283
+ /**
284
+ * Locale for weekday name formatting. Defaults to the app's active locale
285
+ * (`useLocale()`), so the names follow a locale switch; an explicit `locale`
286
+ * still wins.
287
+ */
288
+ locale;
289
+ /** Extra classes for the root container. */
290
+ className;
291
+ /** Called when an event tile is clicked (React's `onEventClick`). */
292
+ eventClick = new EventEmitter();
293
+ /** Called when an empty grid cell is clicked (React's `onSlotClick`). */
294
+ slotClick = new EventEmitter();
295
+ /** The i18n handle (locale-reactive), read in an injection context. */
296
+ i18n = useTranslation();
297
+ /** The app's active locale — the weekday names' default, read in the template. */
298
+ activeLocale = useLocale();
299
+ /**
300
+ * Base of the day headers' ids, which the columns' `aria-labelledby` name
301
+ * (React derives it from `useId()`; a per-instance counter gives each
302
+ * instance its own).
303
+ */
304
+ baseId = `class-schedule-${nextBaseId++}`;
305
+ /** Minutes in one hour, exposed to the template. */
306
+ MINUTES_PER_HOUR = MINUTES_PER_HOUR;
307
+ /** Formats a minute-of-day value as `HH:MM`, exposed to the template. */
308
+ formatHourLabel = formatHourLabel;
309
+ /**
310
+ * The current class map.
311
+ * @returns The UIClassMap.
312
+ */
313
+ cm() {
314
+ return getClassMap();
315
+ }
316
+ /**
317
+ * The clamped first visible hour.
318
+ * @returns The hour (0–23).
319
+ */
320
+ safeStart() {
321
+ const startHour = (this.dayHours ?? [8, 18])[0];
322
+ return Math.max(0, Math.min(23, Math.floor(startHour)));
323
+ }
324
+ /**
325
+ * The clamped last visible hour (at least one hour after {@link safeStart}).
326
+ * @returns The hour (1–24).
327
+ */
328
+ safeEnd() {
329
+ const endHour = (this.dayHours ?? [8, 18])[1];
330
+ return Math.max(this.safeStart() + 1, Math.min(24, Math.floor(endHour)));
331
+ }
332
+ /**
333
+ * The first visible minute of the day.
334
+ * @returns Minutes from midnight.
335
+ */
336
+ startMinutes() {
337
+ return this.safeStart() * MINUTES_PER_HOUR;
338
+ }
339
+ /**
340
+ * The last visible minute of the day.
341
+ * @returns Minutes from midnight.
342
+ */
343
+ endMinutes() {
344
+ return this.safeEnd() * MINUTES_PER_HOUR;
345
+ }
346
+ /**
347
+ * The number of visible minutes.
348
+ * @returns Minutes covered by the grid.
349
+ */
350
+ totalMinutes() {
351
+ return this.endMinutes() - this.startMinutes();
352
+ }
353
+ /**
354
+ * The number of visible hour rows.
355
+ * @returns The hour-row count.
356
+ */
357
+ hourCount() {
358
+ return this.safeEnd() - this.safeStart();
359
+ }
360
+ /**
361
+ * The visible hour row indexes.
362
+ * @returns `0 … hourCount() - 1`.
363
+ */
364
+ hours() {
365
+ return Array.from({ length: this.hourCount() }, (_, i) => i);
366
+ }
367
+ /**
368
+ * The pixel height of one hour row (React's default parameter).
369
+ * @returns The row height in pixels.
370
+ */
371
+ rowHeight() {
372
+ return this.cellHeight ?? 60;
373
+ }
374
+ /**
375
+ * The total pixel height of the grid.
376
+ * @returns The height in pixels.
377
+ */
378
+ totalHeightPx() {
379
+ return this.hourCount() * this.rowHeight();
380
+ }
381
+ /**
382
+ * The weekday columns, rotated so `weekStartsOn` is first and filtered to
383
+ * weekdays when weekends are hidden.
384
+ * @returns The visible weekday numbers.
385
+ */
386
+ visibleWeekdays() {
387
+ const weekStartsOn = this.weekStartsOn ?? 1;
388
+ const rotated = [...ALL_WEEKDAYS.slice(weekStartsOn), ...ALL_WEEKDAYS.slice(0, weekStartsOn)];
389
+ return (this.showWeekendCols ?? true) ? rotated : rotated.filter((d) => !WEEKEND_DAYS.has(d));
390
+ }
391
+ /**
392
+ * Localized short weekday name for a given ISO weekday number.
393
+ *
394
+ * Locale data, not phrases: the name is Intl output in the app's active
395
+ * locale (an explicit `locale` input still wins), and it follows a locale
396
+ * switch — the signal read here makes the template re-render on one.
397
+ *
398
+ * @param weekday - ISO weekday number (0 = Sunday … 6 = Saturday).
399
+ * @returns Localized short weekday name, e.g. `"Mon"`.
400
+ */
401
+ weekdayLabel(weekday) {
402
+ // 1970-01-04 = Sunday → add `weekday` days to get the right name.
403
+ const fmt = new Intl.DateTimeFormat(this.locale ?? this.activeLocale(), { weekday: 'short' });
404
+ return fmt.format(new Date(Date.UTC(1970, 0, 4 + weekday)));
405
+ }
406
+ /**
407
+ * Events grouped by visible weekday.
408
+ * @returns A map from weekday number to its events, in input order.
409
+ */
410
+ eventsByDay() {
411
+ const byDay = new Map();
412
+ const visible = this.visibleWeekdays();
413
+ for (const event of this.events) {
414
+ if (!visible.includes(event.weekday))
415
+ continue;
416
+ const list = byDay.get(event.weekday) ?? [];
417
+ list.push(event);
418
+ byDay.set(event.weekday, list);
419
+ }
420
+ return byDay;
421
+ }
422
+ /**
423
+ * The positioned event tiles of one day column, in input order (events
424
+ * outside the visible hours are dropped, as React returns `null` for them).
425
+ *
426
+ * @param weekday - The day column.
427
+ * @returns The tiles to render.
428
+ */
429
+ tilesFor(weekday) {
430
+ const startMinutes = this.startMinutes();
431
+ const endMinutes = this.endMinutes();
432
+ const totalMinutes = this.totalMinutes();
433
+ const totalHeightPx = this.totalHeightPx();
434
+ const tiles = [];
435
+ for (const { event, lane, lanes } of assignLanes(this.eventsByDay().get(weekday) ?? [])) {
436
+ const eventStart = Math.max(event.start, startMinutes);
437
+ const eventEnd = Math.min(event.end, endMinutes);
438
+ if (eventEnd <= eventStart)
439
+ continue;
440
+ tiles.push({
441
+ event,
442
+ topPx: ((eventStart - startMinutes) / totalMinutes) * totalHeightPx,
443
+ heightPx: ((eventEnd - eventStart) / totalMinutes) * totalHeightPx,
444
+ leftPct: (lane / lanes) * 100,
445
+ widthPct: (1 / lanes) * 100,
446
+ label: this.i18n.t('classSchedule.aria.event', {
447
+ weekday: this.weekdayLabel(weekday),
448
+ start: formatHourLabel(event.start),
449
+ end: formatHourLabel(event.end),
450
+ }, { defaultValue: '{{weekday}} {{start}} – {{end}}' }),
451
+ });
452
+ }
453
+ return tiles;
454
+ }
455
+ /**
456
+ * The accessible label of one empty-slot hit target.
457
+ *
458
+ * @param weekday - The day column.
459
+ * @param index - The hour row.
460
+ * @returns The translated label.
461
+ */
462
+ slotLabel(weekday, index) {
463
+ const start = this.startMinutes() + index * MINUTES_PER_HOUR;
464
+ return this.i18n.t('classSchedule.aria.slot', { weekday: this.weekdayLabel(weekday), time: formatHourLabel(start) }, { defaultValue: 'Empty slot, {{weekday}} {{time}}' });
465
+ }
466
+ /**
467
+ * Emits the slot click payload for one empty grid cell.
468
+ *
469
+ * @param weekday - The day column.
470
+ * @param index - The hour row.
471
+ */
472
+ emitSlot(weekday, index) {
473
+ this.slotClick.emit({ weekday, start: this.startMinutes() + index * MINUTES_PER_HOUR });
474
+ }
475
+ /**
476
+ * The translated region label for the root element.
477
+ * @returns The label text.
478
+ */
479
+ regionLabel() {
480
+ return this.i18n.t('classSchedule.aria.region', {}, {
481
+ defaultValue: 'Weekly class schedule',
482
+ });
483
+ }
484
+ /**
485
+ * The id of one weekday header (React's `useId()`-derived
486
+ * `${baseId}-day-${weekday}`); the day column names it through
487
+ * `aria-labelledby`.
488
+ *
489
+ * @param weekday - The day column.
490
+ * @returns The generated id.
491
+ */
492
+ dayHeaderId(weekday) {
493
+ return `${this.baseId}-day-${weekday}`;
494
+ }
495
+ /**
496
+ * Whether a `slotClick` listener is set (React's `onSlotClick`): the slot
497
+ * buttons render only then.
498
+ * @returns True when the host listens for `slotClick`.
499
+ */
500
+ hasSlotClick() {
501
+ return this.slotClick.observed;
502
+ }
503
+ /**
504
+ * Whether an `eventClick` listener is set (React's `onEventClick`): the
505
+ * event tiles are buttons only then.
506
+ * @returns True when the host listens for `eventClick`.
507
+ */
508
+ hasEventClick() {
509
+ return this.eventClick.observed;
510
+ }
511
+ /**
512
+ * The visually hidden run's class (`cm.cn(cm.srOnly)`), which carries a
513
+ * tile's time label into the accessible name.
514
+ * @returns The class string.
515
+ */
516
+ srOnlyClasses() {
517
+ return this.cm().cn(this.cm().srOnly);
518
+ }
519
+ /**
520
+ * Whether a node-valued line is a `TemplateRef` the template renders.
521
+ *
522
+ * @param value - The line's value.
523
+ * @returns The template, or `null` for a plain value.
524
+ */
525
+ templateOf(value) {
526
+ return value instanceof TemplateRef ? value : null;
527
+ }
528
+ /**
529
+ * The text of a plain node-valued line.
530
+ *
531
+ * @param value - The line's value.
532
+ * @returns Its text, empty for a nullish value.
533
+ */
534
+ textOf(value) {
535
+ return value === null || value === undefined ? '' : String(value);
536
+ }
537
+ /**
538
+ * The wrapper class list (React's `cm.cn(className)`).
539
+ * @returns The class string.
540
+ */
541
+ rootClasses() {
542
+ return this.cm().cn(this.className);
543
+ }
544
+ /**
545
+ * The header row's empty spacer classes.
546
+ * @returns The class string.
547
+ */
548
+ spacerClasses() {
549
+ const cm = this.cm();
550
+ return cm.cn(cm.textSize('xs'), cm.fontWeight('semibold'), cm.sp('p', 2));
551
+ }
552
+ /**
553
+ * The grid wrapper classes.
554
+ * @returns The class string.
555
+ */
556
+ gridClasses() {
557
+ const cm = this.cm();
558
+ return cm.cn(cm.grid({ cols: this.visibleWeekdays().length + 1, gap: 'none' }));
559
+ }
560
+ /**
561
+ * The grid wrapper's inline style.
562
+ * @returns The style declarations.
563
+ */
564
+ gridStyle() {
565
+ return `grid-template-columns: auto repeat(${this.visibleWeekdays().length}, minmax(0, 1fr))`;
566
+ }
567
+ /**
568
+ * The day header cells' classes.
569
+ * @returns The class string.
570
+ */
571
+ dayHeaderClasses() {
572
+ const cm = this.cm();
573
+ return cm.cn(cm.textSize('xs'), cm.fontWeight('semibold'), cm.textCenter, cm.sp('p', 2));
574
+ }
575
+ /**
576
+ * The hour label cells' classes.
577
+ * @returns The class string.
578
+ */
579
+ hourLabelClasses() {
580
+ const cm = this.cm();
581
+ return cm.cn(cm.textSize('xs'), cm.sp('px', 2));
582
+ }
583
+ /**
584
+ * The `position: relative` wrapper classes (time axis + day columns).
585
+ * @returns The class string.
586
+ */
587
+ relativeClasses() {
588
+ const cm = this.cm();
589
+ return cm.cn(cm.position('relative'));
590
+ }
591
+ /**
592
+ * The time axis's inline style.
593
+ * @returns The style declarations.
594
+ */
595
+ axisStyle() {
596
+ return `height: ${this.totalHeightPx()}px`;
597
+ }
598
+ /**
599
+ * One day column's inline style.
600
+ * @returns The style declarations.
601
+ */
602
+ columnStyle() {
603
+ return `height: ${this.totalHeightPx()}px`;
604
+ }
605
+ /**
606
+ * One hour label's inline style.
607
+ *
608
+ * @param index - The hour row.
609
+ * @returns The style declarations.
610
+ */
611
+ hourLabelStyle(index) {
612
+ const height = this.rowHeight();
613
+ return `position: absolute; top: ${index * height}px; height: ${height}px; right: 0px; left: 0px; text-align: right;`;
614
+ }
615
+ /**
616
+ * One slot hit target's inline style (an invisible overlay).
617
+ *
618
+ * @param index - The hour row.
619
+ * @returns The style declarations.
620
+ */
621
+ slotStyle(index) {
622
+ const height = this.rowHeight();
623
+ return `position: absolute; top: ${index * height}px; left: 0px; right: 0px; height: ${height}px; background: transparent; border: 0px; padding: 0px; cursor: pointer`;
624
+ }
625
+ /**
626
+ * One event tile's inline style.
627
+ *
628
+ * @param tile - The tile to style.
629
+ * @returns The style declarations.
630
+ */
631
+ tileStyle(tile) {
632
+ const style = `position: absolute; top: ${tile.topPx}px; height: ${tile.heightPx}px; left: calc(${tile.leftPct}% + 2px); width: calc(${tile.widthPct}% - 4px); overflow: hidden; text-align: left; cursor: ${this.eventClick.observed ? 'pointer' : 'default'}`;
633
+ // The caller's accentColor drives an inset bar (DESIGN.md → "Accent
634
+ // bars") through the CSS variable, not a hard border-left.
635
+ return tile.event.accentColor ? `${style}; --mol-accent: ${tile.event.accentColor}` : style;
636
+ }
637
+ /**
638
+ * One event tile's classes.
639
+ *
640
+ * @param event - The tile's event.
641
+ * @returns The class string.
642
+ */
643
+ tileClasses(event) {
644
+ const cm = this.cm();
645
+ return cm.cn(cm.flex({ direction: 'col', align: 'start' }), cm.sp('p', 1), cm.textSize('xs'), cm.fontWeight('semibold'), event.accentColor && cm.accentCard({ tone: 'custom' }));
646
+ }
647
+ /**
648
+ * The subtitle line's classes.
649
+ * @returns The class string.
650
+ */
651
+ subtitleClasses() {
652
+ const cm = this.cm();
653
+ return cm.cn(cm.textSize('xs'), cm.fontWeight('normal'));
654
+ }
655
+ /**
656
+ * The meta line's classes (the accent label when the tile carries a color).
657
+ *
658
+ * @param event - The tile's event.
659
+ * @returns The class string.
660
+ */
661
+ metaClasses(event) {
662
+ const cm = this.cm();
663
+ return event.accentColor
664
+ ? cm.accentCardLabel({ tone: 'custom' })
665
+ : cm.cn(cm.textSize('xs'), cm.fontWeight('normal'));
666
+ }
667
+ static ɵfac = function ClassSchedule_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || ClassSchedule)(); };
668
+ static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: ClassSchedule, selectors: [["div", "mol-class-schedule", ""]], hostAttrs: ["data-mol-id", "class-schedule", "role", "group"], hostVars: 3, hostBindings: function ClassSchedule_HostBindings(rf, ctx) { if (rf & 2) {
669
+ i0.ɵɵattribute("aria-label", ctx.regionLabel());
670
+ i0.ɵɵclassMap(ctx.rootClasses());
671
+ } }, inputs: { events: "events", weekStartsOn: "weekStartsOn", dayHours: "dayHours", cellHeight: "cellHeight", showWeekendCols: "showWeekendCols", locale: "locale", className: "className" }, outputs: { eventClick: "eventClick", slotClick: "slotClick" }, decls: 9, vars: 8, consts: [["aria-hidden", "true"], ["data-mol-id", "class-schedule-day-header", 3, "class"], ["data-mol-id", "class-schedule-time-axis"], ["data-mol-id", "class-schedule-hour-label", 3, "class"], ["role", "group", "data-mol-id", "class-schedule-day-column", 3, "class"], ["data-mol-id", "class-schedule-day-header"], ["data-mol-id", "class-schedule-hour-label"], ["role", "group", "data-mol-id", "class-schedule-day-column"], ["type", "button", "data-mol-id", "class-schedule-slot"], ["type", "button", "data-mol-id", "class-schedule-slot", 3, "click"], ["type", "button", "data-mol-id", "class-schedule-event", 3, "class"], ["data-mol-id", "class-schedule-event", 3, "class"], ["type", "button", "data-mol-id", "class-schedule-event", 3, "click"], ["data-mol-id", "class-schedule-event-title"], [3, "ngTemplateOutlet"], ["data-mol-id", "class-schedule-event-subtitle", 3, "class"], ["data-mol-id", "class-schedule-event-meta", 3, "class"], ["data-mol-id", "class-schedule-event-subtitle"], ["data-mol-id", "class-schedule-event-meta"], ["data-mol-id", "class-schedule-event"]], template: function ClassSchedule_Template(rf, ctx) { if (rf & 1) {
672
+ i0.ɵɵelementStart(0, "div");
673
+ i0.ɵɵelement(1, "div", 0);
674
+ i0.ɵɵrepeaterCreate(2, ClassSchedule_For_3_Template, 2, 5, "div", 1, i0.ɵɵrepeaterTrackByIdentity);
675
+ i0.ɵɵelementStart(4, "div", 2);
676
+ i0.ɵɵrepeaterCreate(5, ClassSchedule_For_6_Template, 2, 4, "div", 3, i0.ɵɵrepeaterTrackByIdentity);
677
+ i0.ɵɵelementEnd();
678
+ i0.ɵɵrepeaterCreate(7, ClassSchedule_For_8_Template, 4, 6, "div", 4, i0.ɵɵrepeaterTrackByIdentity);
679
+ i0.ɵɵelementEnd();
680
+ } if (rf & 2) {
681
+ i0.ɵɵclassMap(ctx.gridClasses());
682
+ i0.ɵɵattribute("style", ctx.gridStyle(), i0.ɵɵsanitizeStyle);
683
+ i0.ɵɵadvance();
684
+ i0.ɵɵclassMap(ctx.spacerClasses());
685
+ i0.ɵɵadvance();
686
+ i0.ɵɵrepeater(ctx.visibleWeekdays());
687
+ i0.ɵɵadvance(2);
688
+ i0.ɵɵclassMap(ctx.relativeClasses());
689
+ i0.ɵɵattribute("style", ctx.axisStyle(), i0.ɵɵsanitizeStyle);
690
+ i0.ɵɵadvance();
691
+ i0.ɵɵrepeater(ctx.hours());
692
+ i0.ɵɵadvance(2);
693
+ i0.ɵɵrepeater(ctx.visibleWeekdays());
694
+ } }, dependencies: [NgTemplateOutlet], encapsulation: 2 });
695
+ }
696
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(ClassSchedule, [{
697
+ type: Component,
698
+ args: [{
699
+ selector: 'div[mol-class-schedule]',
700
+ standalone: true,
701
+ imports: [NgTemplateOutlet],
702
+ inputs: [
703
+ 'events',
704
+ 'weekStartsOn',
705
+ 'dayHours',
706
+ 'cellHeight',
707
+ 'showWeekendCols',
708
+ 'locale',
709
+ 'className',
710
+ ],
711
+ host: {
712
+ 'data-mol-id': 'class-schedule',
713
+ role: 'group',
714
+ '[class]': 'rootClasses()',
715
+ '[attr.aria-label]': 'regionLabel()',
716
+ },
717
+ template: `<div [class]="gridClasses()" [attr.style]="gridStyle()">
718
+ <div [class]="spacerClasses()" aria-hidden="true"></div>
719
+ @for (weekday of visibleWeekdays(); track weekday) {
720
+ <div
721
+ [attr.id]="dayHeaderId(weekday)"
722
+ data-mol-id="class-schedule-day-header"
723
+ [attr.data-weekday]="weekday"
724
+ [class]="dayHeaderClasses()"
725
+ >
726
+ {{ weekdayLabel(weekday) }}
727
+ </div>
728
+ }
729
+ <div
730
+ data-mol-id="class-schedule-time-axis"
731
+ [class]="relativeClasses()"
732
+ [attr.style]="axisStyle()"
733
+ >
734
+ @for (index of hours(); track index) {
735
+ <div
736
+ data-mol-id="class-schedule-hour-label"
737
+ [class]="hourLabelClasses()"
738
+ [attr.style]="hourLabelStyle(index)"
739
+ >
740
+ {{ formatHourLabel(startMinutes() + index * MINUTES_PER_HOUR) }}
741
+ </div>
742
+ }
743
+ </div>
744
+ <!-- Day columns — each one a "group" named by its weekday header. -->
745
+ @for (weekday of visibleWeekdays(); track weekday) {
746
+ <div
747
+ role="group"
748
+ [attr.aria-labelledby]="dayHeaderId(weekday)"
749
+ data-mol-id="class-schedule-day-column"
750
+ [attr.data-weekday]="weekday"
751
+ [class]="relativeClasses()"
752
+ [attr.style]="columnStyle()"
753
+ >
754
+ <!-- Empty-slot click targets — one button per hour row, only while a
755
+ "slotClick" listener is set: a focusable button that does nothing
756
+ would be a keyboard trap. -->
757
+ @if (hasSlotClick()) {
758
+ @for (index of hours(); track index) {
759
+ <button
760
+ type="button"
761
+ data-mol-id="class-schedule-slot"
762
+ [attr.data-weekday]="weekday"
763
+ [attr.data-start]="startMinutes() + index * MINUTES_PER_HOUR"
764
+ [attr.aria-label]="slotLabel(weekday, index)"
765
+ (click)="emitSlot(weekday, index)"
766
+ [attr.style]="slotStyle(index)"
767
+ ></button>
768
+ }
769
+ }
770
+ @for (tile of tilesFor(weekday); track tile.event.id) {
771
+ <!-- A button only while an "eventClick" listener is set:
772
+ without a handler the tile is static content — a focusable
773
+ button that does nothing would be a keyboard trap. -->
774
+ @if (hasEventClick()) {
775
+ <button
776
+ type="button"
777
+ data-mol-id="class-schedule-event"
778
+ [attr.data-event-id]="tile.event.id"
779
+ (click)="eventClick.emit(tile.event)"
780
+ [class]="tileClasses(tile.event)"
781
+ [attr.style]="tileStyle(tile)"
782
+ >
783
+ <span data-mol-id="class-schedule-event-title">
784
+ @if (templateOf(tile.event.title); as tpl) {
785
+ <ng-container [ngTemplateOutlet]="tpl" />
786
+ } @else {
787
+ {{ textOf(tile.event.title) }}
788
+ }
789
+ </span>
790
+ @if (tile.event.subtitle) {
791
+ <span data-mol-id="class-schedule-event-subtitle" [class]="subtitleClasses()">
792
+ @if (templateOf(tile.event.subtitle); as tpl) {
793
+ <ng-container [ngTemplateOutlet]="tpl" />
794
+ } @else {
795
+ {{ textOf(tile.event.subtitle) }}
796
+ }
797
+ </span>
798
+ }
799
+ @if (tile.event.meta) {
800
+ <span data-mol-id="class-schedule-event-meta" [class]="metaClasses(tile.event)">
801
+ @if (templateOf(tile.event.meta); as tpl) {
802
+ <ng-container [ngTemplateOutlet]="tpl" />
803
+ } @else {
804
+ {{ textOf(tile.event.meta) }}
805
+ }
806
+ </span>
807
+ }
808
+ <!-- The tile's accessible name is its content — title,
809
+ subtitle, meta, then the time, through a visually hidden
810
+ run (the former "aria-label" REPLACED that content as the
811
+ name, so a screen reader never heard the class). -->
812
+ <span [class]="srOnlyClasses()">{{ tile.label }}</span>
813
+ </button>
814
+ } @else {
815
+ <div
816
+ data-mol-id="class-schedule-event"
817
+ [attr.data-event-id]="tile.event.id"
818
+ [class]="tileClasses(tile.event)"
819
+ [attr.style]="tileStyle(tile)"
820
+ >
821
+ <span data-mol-id="class-schedule-event-title">
822
+ @if (templateOf(tile.event.title); as tpl) {
823
+ <ng-container [ngTemplateOutlet]="tpl" />
824
+ } @else {
825
+ {{ textOf(tile.event.title) }}
826
+ }
827
+ </span>
828
+ @if (tile.event.subtitle) {
829
+ <span data-mol-id="class-schedule-event-subtitle" [class]="subtitleClasses()">
830
+ @if (templateOf(tile.event.subtitle); as tpl) {
831
+ <ng-container [ngTemplateOutlet]="tpl" />
832
+ } @else {
833
+ {{ textOf(tile.event.subtitle) }}
834
+ }
835
+ </span>
836
+ }
837
+ @if (tile.event.meta) {
838
+ <span data-mol-id="class-schedule-event-meta" [class]="metaClasses(tile.event)">
839
+ @if (templateOf(tile.event.meta); as tpl) {
840
+ <ng-container [ngTemplateOutlet]="tpl" />
841
+ } @else {
842
+ {{ textOf(tile.event.meta) }}
843
+ }
844
+ </span>
845
+ }
846
+ <span [class]="srOnlyClasses()">{{ tile.label }}</span>
847
+ </div>
848
+ }
849
+ }
850
+ </div>
851
+ }
852
+ </div>`,
853
+ }]
854
+ }], null, { eventClick: [{
855
+ type: Output
856
+ }], slotClick: [{
857
+ type: Output
858
+ }] }); })();
859
+ (() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(ClassSchedule, { className: "ClassSchedule", filePath: "class-schedule.component.ts", lineNumber: 212 }); })();
860
+ //# sourceMappingURL=class-schedule.component.js.map