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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,294 @@
1
+ import { EventEmitter, TemplateRef } from '@angular/core';
2
+ import type { UIClassMap } from '@molecule/app-ui';
3
+ import { formatHourLabel } from './helpers.js';
4
+ import type { ScheduleEvent, ScheduleSlot } from './types.js';
5
+ import * as i0 from "@angular/core";
6
+ /** An ISO weekday number. */
7
+ type Weekday = 0 | 1 | 2 | 3 | 4 | 5 | 6;
8
+ /** One positioned event tile. */
9
+ interface TileModel {
10
+ event: ScheduleEvent;
11
+ topPx: number;
12
+ heightPx: number;
13
+ leftPct: number;
14
+ widthPct: number;
15
+ label: string;
16
+ }
17
+ /**
18
+ * Weekly class-schedule grid. Renders a 7-column (or 5-column when
19
+ * `showWeekendCols` is `false`) timetable with hour rows down the left
20
+ * and absolutely positioned event tiles inside each day column. Events
21
+ * that overlap on the same weekday are split into side-by-side lanes.
22
+ *
23
+ * The host IS the outer `<div>` (`div[mol-class-schedule]`), matching React's
24
+ * root exactly. Node-valued event lines (`title`, `subtitle`, `meta`) take a
25
+ * `TemplateRef`, rendered through `NgTemplateOutlet`.
26
+ */
27
+ export declare class ClassSchedule {
28
+ /** Events to render. */
29
+ events: ScheduleEvent[];
30
+ /** First day-of-week (`0` = Sunday, `1` = Monday). Defaults to `1` at read time. */
31
+ weekStartsOn?: 0 | 1 | 2 | 3 | 4 | 5 | 6;
32
+ /** Visible hour range `[start, end]`. Defaults to `[8, 18]` at read time. */
33
+ dayHours?: [number, number];
34
+ /** Pixel height of one hour row. Defaults to `60` at read time. */
35
+ cellHeight?: number;
36
+ /** Whether to show Saturday + Sunday columns. Defaults to `true` at read time. */
37
+ showWeekendCols?: boolean;
38
+ /**
39
+ * Locale for weekday name formatting. Defaults to the app's active locale
40
+ * (`useLocale()`), so the names follow a locale switch; an explicit `locale`
41
+ * still wins.
42
+ */
43
+ locale?: string;
44
+ /** Extra classes for the root container. */
45
+ className?: string;
46
+ /** Called when an event tile is clicked (React's `onEventClick`). */
47
+ readonly eventClick: EventEmitter<ScheduleEvent>;
48
+ /** Called when an empty grid cell is clicked (React's `onSlotClick`). */
49
+ readonly slotClick: EventEmitter<ScheduleSlot>;
50
+ /** The i18n handle (locale-reactive), read in an injection context. */
51
+ private readonly i18n;
52
+ /** The app's active locale — the weekday names' default, read in the template. */
53
+ private readonly activeLocale;
54
+ /**
55
+ * Base of the day headers' ids, which the columns' `aria-labelledby` name
56
+ * (React derives it from `useId()`; a per-instance counter gives each
57
+ * instance its own).
58
+ */
59
+ readonly baseId: string;
60
+ /** Minutes in one hour, exposed to the template. */
61
+ readonly MINUTES_PER_HOUR = 60;
62
+ /** Formats a minute-of-day value as `HH:MM`, exposed to the template. */
63
+ readonly formatHourLabel: typeof formatHourLabel;
64
+ /**
65
+ * The current class map.
66
+ * @returns The UIClassMap.
67
+ */
68
+ cm(): UIClassMap;
69
+ /**
70
+ * The clamped first visible hour.
71
+ * @returns The hour (0–23).
72
+ */
73
+ safeStart(): number;
74
+ /**
75
+ * The clamped last visible hour (at least one hour after {@link safeStart}).
76
+ * @returns The hour (1–24).
77
+ */
78
+ safeEnd(): number;
79
+ /**
80
+ * The first visible minute of the day.
81
+ * @returns Minutes from midnight.
82
+ */
83
+ startMinutes(): number;
84
+ /**
85
+ * The last visible minute of the day.
86
+ * @returns Minutes from midnight.
87
+ */
88
+ endMinutes(): number;
89
+ /**
90
+ * The number of visible minutes.
91
+ * @returns Minutes covered by the grid.
92
+ */
93
+ totalMinutes(): number;
94
+ /**
95
+ * The number of visible hour rows.
96
+ * @returns The hour-row count.
97
+ */
98
+ hourCount(): number;
99
+ /**
100
+ * The visible hour row indexes.
101
+ * @returns `0 … hourCount() - 1`.
102
+ */
103
+ hours(): number[];
104
+ /**
105
+ * The pixel height of one hour row (React's default parameter).
106
+ * @returns The row height in pixels.
107
+ */
108
+ rowHeight(): number;
109
+ /**
110
+ * The total pixel height of the grid.
111
+ * @returns The height in pixels.
112
+ */
113
+ totalHeightPx(): number;
114
+ /**
115
+ * The weekday columns, rotated so `weekStartsOn` is first and filtered to
116
+ * weekdays when weekends are hidden.
117
+ * @returns The visible weekday numbers.
118
+ */
119
+ visibleWeekdays(): Weekday[];
120
+ /**
121
+ * Localized short weekday name for a given ISO weekday number.
122
+ *
123
+ * Locale data, not phrases: the name is Intl output in the app's active
124
+ * locale (an explicit `locale` input still wins), and it follows a locale
125
+ * switch — the signal read here makes the template re-render on one.
126
+ *
127
+ * @param weekday - ISO weekday number (0 = Sunday … 6 = Saturday).
128
+ * @returns Localized short weekday name, e.g. `"Mon"`.
129
+ */
130
+ weekdayLabel(weekday: number): string;
131
+ /**
132
+ * Events grouped by visible weekday.
133
+ * @returns A map from weekday number to its events, in input order.
134
+ */
135
+ eventsByDay(): Map<number, ScheduleEvent[]>;
136
+ /**
137
+ * The positioned event tiles of one day column, in input order (events
138
+ * outside the visible hours are dropped, as React returns `null` for them).
139
+ *
140
+ * @param weekday - The day column.
141
+ * @returns The tiles to render.
142
+ */
143
+ tilesFor(weekday: number): TileModel[];
144
+ /**
145
+ * The accessible label of one empty-slot hit target.
146
+ *
147
+ * @param weekday - The day column.
148
+ * @param index - The hour row.
149
+ * @returns The translated label.
150
+ */
151
+ slotLabel(weekday: number, index: number): string;
152
+ /**
153
+ * Emits the slot click payload for one empty grid cell.
154
+ *
155
+ * @param weekday - The day column.
156
+ * @param index - The hour row.
157
+ */
158
+ emitSlot(weekday: Weekday, index: number): void;
159
+ /**
160
+ * The translated region label for the root element.
161
+ * @returns The label text.
162
+ */
163
+ regionLabel(): string;
164
+ /**
165
+ * The id of one weekday header (React's `useId()`-derived
166
+ * `${baseId}-day-${weekday}`); the day column names it through
167
+ * `aria-labelledby`.
168
+ *
169
+ * @param weekday - The day column.
170
+ * @returns The generated id.
171
+ */
172
+ dayHeaderId(weekday: number): string;
173
+ /**
174
+ * Whether a `slotClick` listener is set (React's `onSlotClick`): the slot
175
+ * buttons render only then.
176
+ * @returns True when the host listens for `slotClick`.
177
+ */
178
+ hasSlotClick(): boolean;
179
+ /**
180
+ * Whether an `eventClick` listener is set (React's `onEventClick`): the
181
+ * event tiles are buttons only then.
182
+ * @returns True when the host listens for `eventClick`.
183
+ */
184
+ hasEventClick(): boolean;
185
+ /**
186
+ * The visually hidden run's class (`cm.cn(cm.srOnly)`), which carries a
187
+ * tile's time label into the accessible name.
188
+ * @returns The class string.
189
+ */
190
+ srOnlyClasses(): string;
191
+ /**
192
+ * Whether a node-valued line is a `TemplateRef` the template renders.
193
+ *
194
+ * @param value - The line's value.
195
+ * @returns The template, or `null` for a plain value.
196
+ */
197
+ templateOf(value: unknown): TemplateRef<unknown> | null;
198
+ /**
199
+ * The text of a plain node-valued line.
200
+ *
201
+ * @param value - The line's value.
202
+ * @returns Its text, empty for a nullish value.
203
+ */
204
+ textOf(value: unknown): string;
205
+ /**
206
+ * The wrapper class list (React's `cm.cn(className)`).
207
+ * @returns The class string.
208
+ */
209
+ rootClasses(): string;
210
+ /**
211
+ * The header row's empty spacer classes.
212
+ * @returns The class string.
213
+ */
214
+ spacerClasses(): string;
215
+ /**
216
+ * The grid wrapper classes.
217
+ * @returns The class string.
218
+ */
219
+ gridClasses(): string;
220
+ /**
221
+ * The grid wrapper's inline style.
222
+ * @returns The style declarations.
223
+ */
224
+ gridStyle(): string;
225
+ /**
226
+ * The day header cells' classes.
227
+ * @returns The class string.
228
+ */
229
+ dayHeaderClasses(): string;
230
+ /**
231
+ * The hour label cells' classes.
232
+ * @returns The class string.
233
+ */
234
+ hourLabelClasses(): string;
235
+ /**
236
+ * The `position: relative` wrapper classes (time axis + day columns).
237
+ * @returns The class string.
238
+ */
239
+ relativeClasses(): string;
240
+ /**
241
+ * The time axis's inline style.
242
+ * @returns The style declarations.
243
+ */
244
+ axisStyle(): string;
245
+ /**
246
+ * One day column's inline style.
247
+ * @returns The style declarations.
248
+ */
249
+ columnStyle(): string;
250
+ /**
251
+ * One hour label's inline style.
252
+ *
253
+ * @param index - The hour row.
254
+ * @returns The style declarations.
255
+ */
256
+ hourLabelStyle(index: number): string;
257
+ /**
258
+ * One slot hit target's inline style (an invisible overlay).
259
+ *
260
+ * @param index - The hour row.
261
+ * @returns The style declarations.
262
+ */
263
+ slotStyle(index: number): string;
264
+ /**
265
+ * One event tile's inline style.
266
+ *
267
+ * @param tile - The tile to style.
268
+ * @returns The style declarations.
269
+ */
270
+ tileStyle(tile: TileModel): string;
271
+ /**
272
+ * One event tile's classes.
273
+ *
274
+ * @param event - The tile's event.
275
+ * @returns The class string.
276
+ */
277
+ tileClasses(event: ScheduleEvent): string;
278
+ /**
279
+ * The subtitle line's classes.
280
+ * @returns The class string.
281
+ */
282
+ subtitleClasses(): string;
283
+ /**
284
+ * The meta line's classes (the accent label when the tile carries a color).
285
+ *
286
+ * @param event - The tile's event.
287
+ * @returns The class string.
288
+ */
289
+ metaClasses(event: ScheduleEvent): string;
290
+ static ɵfac: i0.ɵɵFactoryDeclaration<ClassSchedule, never>;
291
+ static ɵcmp: i0.ɵɵComponentDeclaration<ClassSchedule, "div[mol-class-schedule]", never, { "events": { "alias": "events"; "required": false; }; "weekStartsOn": { "alias": "weekStartsOn"; "required": false; }; "dayHours": { "alias": "dayHours"; "required": false; }; "cellHeight": { "alias": "cellHeight"; "required": false; }; "showWeekendCols": { "alias": "showWeekendCols"; "required": false; }; "locale": { "alias": "locale"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, { "eventClick": "eventClick"; "slotClick": "slotClick"; }, never, never, true, never>;
292
+ }
293
+ export {};
294
+ //# sourceMappingURL=class-schedule.component.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"class-schedule.component.d.ts","sourceRoot":"","sources":["../src/class-schedule.component.ts"],"names":[],"mappings":"AAOA,OAAO,EAAa,YAAY,EAAU,WAAW,EAAE,MAAM,eAAe,CAAA;AAG5E,OAAO,KAAK,EAAE,UAAU,EAAE,MA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