ud-components 0.6.2 → 0.7.1

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,13 @@
1
+ export declare function isIsoDate(value: string | null | undefined): value is string;
2
+ /** Days since 1970-01-01 for a YYYY-MM-DD string. Throws on anything else. */
3
+ export declare function epochDay(iso: string): number;
4
+ /** `b - a` in whole days. Positive when b is after a. */
5
+ export declare function daysBetween(a: string, b: string): number;
6
+ export declare function addDays(iso: string, days: number): string;
7
+ /** 0 = Sunday … 6 = Saturday, for the calendar date itself. */
8
+ export declare function weekday(iso: string): number;
9
+ export declare function monthOf(iso: string): number;
10
+ export declare function yearOf(iso: string): number;
11
+ export declare function dayOfMonth(iso: string): number;
12
+ export declare function maxIso(a: string, b: string): string;
13
+ export declare function minIso(a: string, b: string): string;
@@ -0,0 +1,347 @@
1
+ import { DestroyRef } from '@angular/core';
2
+ import { TranslateService } from '@ngx-translate/core';
3
+ import { OccupancyBar, OccupancyBarClick, OccupancyBarCreate, OccupancyBarMove, OccupancyBarResize, OccupancyCellClick, OccupancyClosure, OccupancyClosureClick, OccupancyRoom } from './occupancy-grid.interface';
4
+ import { BarGeometry, GridRow, LaneBar, PositionedRow, RoomRow } from './occupancy-grid.layout';
5
+ import * as i0 from "@angular/core";
6
+ export declare const OCCUPANCY_GRID_HEADER_HEIGHT = 52;
7
+ /**
8
+ * Rooms as rows, days as columns, one bar per stay (UC-11). It never writes
9
+ * anywhere — `rooms` is the only source of truth and this component never
10
+ * mutates it — but it is not read-only in the sense of being inert: a bar's
11
+ * edge can be dragged (or, on a focused bar, Shift + arrow-keyed) to propose
12
+ * a new date, reported via `barResize`; a bar's body can be dragged to a new
13
+ * date, a different room, or both, reported via `barMove`. Every other
14
+ * gesture (clicks, the nav buttons) works the same way: report what
15
+ * happened, apply nothing.
16
+ *
17
+ * Owns its own row virtualization: rows have different heights (one lane per
18
+ * overlapping stay), which the CDK's stable fixed-size strategy cannot do, and
19
+ * the autosize strategy is still experimental. Rows are positioned from a
20
+ * prefix sum of heights and only those intersecting the viewport are rendered.
21
+ *
22
+ * Every date is a YYYY-MM-DD string and every column is computed by
23
+ * local-date.ts; `new Date(string)` is never used, so a column can never be
24
+ * off by one west of Greenwich.
25
+ */
26
+ export declare class OccupancyGridComponent {
27
+ private readonly translate;
28
+ rooms: import("@angular/core").InputSignal<OccupancyRoom[]>;
29
+ dormName: import("@angular/core").InputSignal<string>;
30
+ from: import("@angular/core").InputSignal<string>;
31
+ to: import("@angular/core").InputSignal<string>;
32
+ today: import("@angular/core").InputSignal<string | null>;
33
+ dayWidth: import("@angular/core").InputSignal<number>;
34
+ leftColumnWidth: import("@angular/core").InputSignal<number>;
35
+ laneHeight: import("@angular/core").InputSignal<number>;
36
+ loading: import("@angular/core").InputSignal<boolean>;
37
+ /** Days the ‹ / › nav buttons and the ArrowLeft/ArrowRight keys shift the window by. */
38
+ navStepDays: import("@angular/core").InputSignal<number>;
39
+ /**
40
+ * When true, a resize or whole-bar move drag is never allowed to leave
41
+ * two bars in the same room overlapping in time. The default (false)
42
+ * lets bars in different lanes of the same room legitimately overlap —
43
+ * an outgoing stay's last few nights next to an incoming one's first, say
44
+ * — which is exactly what the lane system exists to display. A strict
45
+ * room grid, where a room can hold only one booking at a time, sets this
46
+ * so a drag simply cannot propose a second one over it: a resize clamps
47
+ * at the nearest other bar in the room (not just its own lane), and a
48
+ * move drag ignores any candidate date/room that would overlap, sticking
49
+ * to the last placement that did not.
50
+ */
51
+ preventOverlap: import("@angular/core").InputSignal<boolean>;
52
+ barClick: import("@angular/core").OutputEmitterRef<OccupancyBarClick>;
53
+ closureClick: import("@angular/core").OutputEmitterRef<OccupancyClosureClick>;
54
+ roomClick: import("@angular/core").OutputEmitterRef<OccupancyRoom>;
55
+ /** An empty day cell was clicked: the room and the date under the pointer. */
56
+ cellClick: import("@angular/core").OutputEmitterRef<OccupancyCellClick>;
57
+ reachedEnd: import("@angular/core").OutputEmitterRef<string>;
58
+ /**
59
+ * The nav buttons or an arrow key asked to move the window. The component
60
+ * does not own `from`/`to` (the consumer does, same as every other input
61
+ * here), so it reports the signed day delta — negative for earlier,
62
+ * positive for later — rather than computing new dates itself. A consumer
63
+ * that wants the shift applied does
64
+ * `from = addDays(from, delta); to = addDays(to, delta)`.
65
+ */
66
+ windowShift: import("@angular/core").OutputEmitterRef<number>;
67
+ /**
68
+ * A bar's edge was dragged, or Shift + arrow-keyed, to a new date. See
69
+ * `OccupancyBarResize` — this reports the proposal; it never applies it.
70
+ */
71
+ barResize: import("@angular/core").OutputEmitterRef<OccupancyBarResize>;
72
+ /**
73
+ * A bar's body was dragged to new dates, a different room, or both. See
74
+ * `OccupancyBarMove` — this reports the proposal; it never applies it.
75
+ */
76
+ barMove: import("@angular/core").OutputEmitterRef<OccupancyBarMove>;
77
+ /**
78
+ * A new booking's dates were proposed by dragging across empty lane cells,
79
+ * or by the keyboard-driven create flow (see `onLaneKeydown`). See
80
+ * `OccupancyBarCreate` — this reports the proposal; it never creates a bar
81
+ * itself.
82
+ */
83
+ barCreate: import("@angular/core").OutputEmitterRef<OccupancyBarCreate>;
84
+ protected readonly headerHeight = 52;
85
+ private readonly scroller;
86
+ private readonly collapsed;
87
+ private readonly scrollTop;
88
+ private readonly viewportHeight;
89
+ private lastEndEmittedFor;
90
+ /**
91
+ * The in-progress drag, if any — null the rest of the time. `geometryOf`
92
+ * and `barTitle` read the preview dates for whichever bar this names so
93
+ * the drag renders live; nothing else about `rooms` changes, since the
94
+ * component does not own that input.
95
+ */
96
+ protected readonly resize: import("@angular/core").WritableSignal<{
97
+ room: OccupancyRoom;
98
+ bar: OccupancyBar;
99
+ edge: "start" | "end";
100
+ previewStart: string;
101
+ previewEnd: string;
102
+ minBound: string | null;
103
+ maxBound: string | null;
104
+ } | null>;
105
+ private dragMoveListener;
106
+ private dragUpListener;
107
+ private dragKeyListener;
108
+ /**
109
+ * The in-progress whole-bar drag, if any — null the rest of the time.
110
+ * `dragging` only flips true once the pointer clears a small threshold, so
111
+ * a plain click (mousedown + mouseup with no real movement) still opens
112
+ * the drawer as `barClick` instead of being swallowed as a zero-distance
113
+ * move. `targetRoom` starts as `fromRoom` and is re-resolved on every
114
+ * mousemove from whatever `.occ__row--room` is actually under the
115
+ * pointer — see `roomUnderPoint` — so dragging vertically onto another
116
+ * room's row is exactly the gesture `roomUnderPoint` is built to read.
117
+ */
118
+ protected readonly move: import("@angular/core").WritableSignal<{
119
+ bar: OccupancyBar;
120
+ fromRoom: OccupancyRoom;
121
+ startClientX: number;
122
+ startClientY: number;
123
+ originalStartDate: string;
124
+ originalEndDate: string;
125
+ previewStartDate: string;
126
+ previewEndDate: string;
127
+ targetRoom: OccupancyRoom;
128
+ dragging: boolean;
129
+ } | null>;
130
+ private moveMoveListener;
131
+ private moveUpListener;
132
+ private moveKeyListener;
133
+ /**
134
+ * The in-progress drag-to-create, if any — null the rest of the time.
135
+ * `startDate` is the anchor the drag began from (mouse) or the focused
136
+ * cell it started from (keyboard); `previewStart`/`previewEnd` are what
137
+ * gets emitted. `viaKeyboard` distinguishes the two sources: a mouse
138
+ * create only commits on mouseup and only once it clears the same
139
+ * click-vs-drag threshold `move` uses, while a keyboard create is live the
140
+ * instant Enter starts it (there is no "release" to wait for) and commits
141
+ * on a second Enter.
142
+ */
143
+ protected readonly create: import("@angular/core").WritableSignal<{
144
+ room: OccupancyRoom;
145
+ startDate: string;
146
+ startClientX: number;
147
+ previewStart: string;
148
+ previewEnd: string;
149
+ dragging: boolean;
150
+ viaKeyboard: boolean;
151
+ } | null>;
152
+ private createMoveListener;
153
+ private createUpListener;
154
+ private createKeyListener;
155
+ /**
156
+ * The keyboard-focused empty cell, if any — a room and a date, tracked so
157
+ * Tab can reach an empty lane and arrow keys have somewhere to move from.
158
+ * Cleared on blur unless a keyboard create (see `create`) is in progress,
159
+ * so the highlighted cell does not vanish out from under an active
160
+ * gesture.
161
+ */
162
+ protected readonly laneFocus: import("@angular/core").WritableSignal<{
163
+ roomId: string;
164
+ date: string;
165
+ } | null>;
166
+ /**
167
+ * The empty cell the mouse is currently over, if any — the pointer
168
+ * equivalent of `laneFocus`, so a mouse user gets the same "here's what
169
+ * you're about to create on" cue a keyboard user gets from Tab. Cleared
170
+ * whenever any gesture (create, resize, or a whole-bar move) is live, so
171
+ * it never competes with that gesture's own preview.
172
+ */
173
+ protected readonly laneHover: import("@angular/core").WritableSignal<{
174
+ roomId: string;
175
+ date: string;
176
+ } | null>;
177
+ private suppressNextClick;
178
+ private suppressNextClickTimer;
179
+ constructor(translate: TranslateService, destroyRef: DestroyRef);
180
+ protected readonly dayCount: import("@angular/core").Signal<number>;
181
+ protected readonly canvasWidth: import("@angular/core").Signal<number>;
182
+ protected readonly rows: import("@angular/core").Signal<GridRow[]>;
183
+ protected readonly positioned: import("@angular/core").Signal<PositionedRow[]>;
184
+ protected readonly bodyHeight: import("@angular/core").Signal<number>;
185
+ protected readonly visible: import("@angular/core").Signal<PositionedRow[]>;
186
+ protected readonly days: import("@angular/core").Signal<import("ud-components").DayColumn[]>;
187
+ protected readonly months: import("@angular/core").Signal<import("ud-components").MonthSegment[]>;
188
+ protected readonly weekendOffsetPx: import("@angular/core").Signal<number>;
189
+ protected readonly todayLeft: import("@angular/core").Signal<number | null>;
190
+ private readonly roomsById;
191
+ /**
192
+ * The floating copy of a bar being dragged by its body — null unless a
193
+ * move drag has cleared the click threshold. Positioned in canvas
194
+ * coordinates (like `.occ__today`) rather than inside a room's own lane,
195
+ * because a move can target a room other than the one the drag started
196
+ * in; `positioned()` already has every visible row's pixel `top`, so no
197
+ * separate DOM lookup is needed to place it. Always drawn at lane 0 of the
198
+ * target room — a simplification the consumer's own re-lane on save
199
+ * supersedes anyway, same as the rest of this component's "report the
200
+ * gesture, never own the data" contract.
201
+ */
202
+ protected readonly moveGhost: import("@angular/core").Signal<{
203
+ left: number;
204
+ top: number;
205
+ width: number;
206
+ height: number;
207
+ label: string;
208
+ state: import("ud-components").OccupancyBarState;
209
+ } | null>;
210
+ /** The in-progress drag-to-create's preview span, once it clears the drag threshold (mouse) or as soon as it starts (keyboard). */
211
+ protected readonly createGhost: import("@angular/core").Signal<{
212
+ left: number;
213
+ top: number;
214
+ width: number;
215
+ height: number;
216
+ } | null>;
217
+ /**
218
+ * The empty cell to outline — the mouse hover position if the pointer is
219
+ * over one, otherwise the keyboard-focused cell — whenever no create
220
+ * gesture is overriding it with its own live preview.
221
+ */
222
+ protected readonly laneCursorGeometry: import("@angular/core").Signal<{
223
+ left: number;
224
+ top: number;
225
+ width: number;
226
+ height: number;
227
+ } | null>;
228
+ /** Canvas-coordinate box for a date span in a given room's row — shared by `createGhost` and `laneCursorGeometry`. */
229
+ private ghostGeometry;
230
+ private monthLabels;
231
+ protected geometryOf(bar: OccupancyBar): BarGeometry | null;
232
+ /** The in-progress drag's proposed dates for this bar, or null if it is not the one being dragged. */
233
+ private previewDatesOf;
234
+ protected isResizing(bookingId: string): boolean;
235
+ /** True once a whole-bar drag on this booking has cleared the click threshold — see `move`. */
236
+ protected isBeingMoved(bookingId: string): boolean;
237
+ /** True while a whole-bar drag is hovering this room as its drop target. */
238
+ protected isMoveTarget(roomId: string): boolean;
239
+ protected closureGeometryOf(closure: OccupancyClosure): BarGeometry | null;
240
+ protected takenOn(room: OccupancyRoom): number | null;
241
+ protected isCollapsed(key: string): boolean;
242
+ protected toggleGroup(key: string): void;
243
+ protected barTitle(bar: OccupancyBar): string;
244
+ protected closureTitle(closure: OccupancyClosure): string;
245
+ protected onScroll(): void;
246
+ protected trackRow(_: number, p: PositionedRow): string;
247
+ protected asRoomRow(row: GridRow): RoomRow;
248
+ /** ‹ / › nav buttons. Emits the signed day delta; see `windowShift`. */
249
+ protected shiftWindow(direction: -1 | 1): void;
250
+ /**
251
+ * ArrowLeft/ArrowRight anywhere in the grid page the window, the same as
252
+ * the nav buttons — a keyboard user reaching a bar via Tab should not have
253
+ * to find the buttons to keep moving through time. Left alone otherwise:
254
+ * a bar, room cell or group header's own Enter handling is untouched.
255
+ */
256
+ protected onGridKeydown(event: KeyboardEvent): void;
257
+ /**
258
+ * A click inside a room's lane that landed on neither a bar nor a closure
259
+ * (both stop propagation before this fires) — the room and the date under
260
+ * the pointer. See `OccupancyCellClick`.
261
+ */
262
+ protected onLaneClick(event: MouseEvent, room: OccupancyRoom): void;
263
+ /** The bar's own click handler routes through here so it shares the same resize-click guard as `onLaneClick`. */
264
+ protected onBarClick(bar: OccupancyBar, room: OccupancyRoom): void;
265
+ /**
266
+ * Mousedown on a bar's edge handle starts a drag. Listeners go on
267
+ * `window`, not the handle, because the pointer will move well outside
268
+ * an 8px-wide handle the instant the drag starts; `stopPropagation` keeps
269
+ * this from also being read as a click on the bar (which would open the
270
+ * drawer) or on the lane underneath it (a `cellClick`).
271
+ */
272
+ protected startResize(event: MouseEvent, room: OccupancyRoom, bar: OccupancyBar, edge: 'start' | 'end', laneBars: LaneBar[]): void;
273
+ private onDragMove;
274
+ /** Mouseup (commit) or Escape (cancel). Emits `barResize` only on commit with an actual change. */
275
+ private endResize;
276
+ private removeDragListeners;
277
+ /**
278
+ * Mousedown on a bar's own body (never the edge handles — those stop
279
+ * propagation before this fires) arms a possible whole-bar move, but does
280
+ * not yet commit to one: `dragging` stays false, and nothing is rendered
281
+ * differently, until `onBarDragMove` sees the pointer clear a small
282
+ * threshold. That is what lets a plain click still fall through to
283
+ * `onBarClick` unchanged.
284
+ */
285
+ protected startBarMove(event: MouseEvent, room: OccupancyRoom, bar: OccupancyBar): void;
286
+ private onBarDragMove;
287
+ /** Mouseup (commit) or Escape (cancel). Emits `barMove` only on commit with an actual change. */
288
+ private endBarMove;
289
+ private removeMoveListeners;
290
+ /**
291
+ * Mousedown on a lane's empty background arms a possible drag-to-create,
292
+ * on the same click-vs-drag threshold as `startBarMove` — a plain click
293
+ * still falls through to `onLaneClick`'s `cellClick` unchanged, since
294
+ * `endCreate` only emits once `dragging` has flipped true.
295
+ */
296
+ protected startCreate(event: MouseEvent, room: OccupancyRoom): void;
297
+ private onCreateDragMove;
298
+ /** Mouseup (commit) or Escape (cancel), for both the mouse and keyboard paths. Emits `barCreate` only once a drag actually cleared the threshold (or a keyboard create was started) and is committed. */
299
+ private endCreate;
300
+ private removeCreateListeners;
301
+ /**
302
+ * Focus lands on an empty lane (Tab, or a mouse click on it) — arm a
303
+ * keyboard cursor at today (or the window's first day, if today is out of
304
+ * view) unless this room already has one. Left alone while a keyboard
305
+ * create is in progress on this lane, so refocusing mid-gesture cannot
306
+ * reset it.
307
+ */
308
+ protected onLaneFocus(room: OccupancyRoom): void;
309
+ /**
310
+ * The pointer moved over a lane's empty background — update the hover
311
+ * cursor to the date under it. Ignored while a create, resize, or
312
+ * whole-bar move is live (that gesture already draws its own preview),
313
+ * and when the event bubbled up from a bar or closure rather than
314
+ * landing on the background itself, so hovering an existing booking does
315
+ * not also outline the empty-cell cursor underneath it.
316
+ */
317
+ protected onLaneMouseMove(event: MouseEvent, room: OccupancyRoom): void;
318
+ protected onLaneMouseLeave(room: OccupancyRoom): void;
319
+ protected onLaneBlur(): void;
320
+ private defaultCursorDate;
321
+ /**
322
+ * Keyboard path for drag-to-create: with no create in progress, plain
323
+ * ArrowLeft/ArrowRight move the focused cell one day and Enter/Space marks
324
+ * it as the start of a new booking; once that create is live, the same
325
+ * arrow keys extend or shorten the departure date (mirroring
326
+ * `onBarKeydownResize`'s departure-only convention) and a second Enter
327
+ * commits, Escape cancels.
328
+ */
329
+ protected onLaneKeydown(event: KeyboardEvent, room: OccupancyRoom): void;
330
+ /** Whatever room row (if any) is actually rendered under this point — see `.occ__row--room`'s `data-room-id`. */
331
+ private roomUnderPoint;
332
+ private armSuppressNextClick;
333
+ private consumeSuppressNextClick;
334
+ private clientXToDate;
335
+ /**
336
+ * The keyboard equivalent of dragging the departure edge: Shift+ArrowRight
337
+ * extends by a night, Shift+ArrowLeft shortens by one, each key press
338
+ * committing immediately (there is nothing to "release" the way a mouse
339
+ * drag has). Scoped to the departure edge only — the more common "extend a
340
+ * stay" gesture — so one binding covers the primary case without a second
341
+ * modifier combination to document; the arrival edge is still reachable by
342
+ * dragging its handle with a mouse.
343
+ */
344
+ protected onBarKeydownResize(event: KeyboardEvent, room: OccupancyRoom, bar: OccupancyBar, laneBars: LaneBar[]): void;
345
+ static ɵfac: i0.ɵɵFactoryDeclaration<OccupancyGridComponent, never>;
346
+ static ɵcmp: i0.ɵɵComponentDeclaration<OccupancyGridComponent, "ud-occupancy-grid", never, { "rooms": { "alias": "rooms"; "required": false; "isSignal": true; }; "dormName": { "alias": "dormName"; "required": false; "isSignal": true; }; "from": { "alias": "from"; "required": true; "isSignal": true; }; "to": { "alias": "to"; "required": true; "isSignal": true; }; "today": { "alias": "today"; "required": false; "isSignal": true; }; "dayWidth": { "alias": "dayWidth"; "required": false; "isSignal": true; }; "leftColumnWidth": { "alias": "leftColumnWidth"; "required": false; "isSignal": true; }; "laneHeight": { "alias": "laneHeight"; "required": false; "isSignal": true; }; "loading": { "alias": "loading"; "required": false; "isSignal": true; }; "navStepDays": { "alias": "navStepDays"; "required": false; "isSignal": true; }; "preventOverlap": { "alias": "preventOverlap"; "required": false; "isSignal": true; }; }, { "barClick": "barClick"; "closureClick": "closureClick"; "roomClick": "roomClick"; "cellClick": "cellClick"; "reachedEnd": "reachedEnd"; "windowShift": "windowShift"; "barResize": "barResize"; "barMove": "barMove"; "barCreate": "barCreate"; }, never, never, true, never>;
347
+ }
@@ -0,0 +1,117 @@
1
+ export type OccupancyBarState = 'tentative' | 'reserved' | 'in_room' | 'history';
2
+ export interface OccupancyBar {
3
+ bookingId: string;
4
+ registrationId: string;
5
+ studentId: string;
6
+ studentName: string;
7
+ studentEmail: string | null;
8
+ /** YYYY-MM-DD, first night. */
9
+ startDate: string;
10
+ /** YYYY-MM-DD, departure morning, EXCLUSIVE. */
11
+ endDate: string;
12
+ continuesBefore: boolean;
13
+ continuesAfter: boolean;
14
+ status: string;
15
+ state: OccupancyBarState;
16
+ stayTermId: string | null;
17
+ stayTermName: string | null;
18
+ registrationStayTermIds: string[];
19
+ }
20
+ export interface OccupancyClosure {
21
+ closureId: string;
22
+ startDate: string;
23
+ endDate: string;
24
+ reason: string;
25
+ continuesBefore: boolean;
26
+ continuesAfter: boolean;
27
+ }
28
+ export interface OccupancyRoom {
29
+ roomId: string;
30
+ number: string;
31
+ type: string;
32
+ capacity: number;
33
+ active: boolean;
34
+ floorId: string;
35
+ floorLevel: string;
36
+ floorGender: string | null;
37
+ bars: OccupancyBar[];
38
+ closures: OccupancyClosure[];
39
+ }
40
+ export interface OccupancyWindow {
41
+ dormId: string;
42
+ dormName: string;
43
+ from: string;
44
+ to: string;
45
+ today: string;
46
+ rooms: OccupancyRoom[];
47
+ }
48
+ export interface OccupancyBarClick {
49
+ bar: OccupancyBar;
50
+ room: OccupancyRoom;
51
+ }
52
+ export interface OccupancyClosureClick {
53
+ closure: OccupancyClosure;
54
+ room: OccupancyRoom;
55
+ }
56
+ /**
57
+ * An empty day cell was clicked — the room and the calendar date under the
58
+ * pointer, YYYY-MM-DD. Distinct from `roomClick` (which names the room only,
59
+ * for "go to this room") and `barClick` (an existing stay): this is the one
60
+ * that carries what "book this room on this date" needs. The component does
61
+ * not act on it — it only reports what was clicked.
62
+ */
63
+ export interface OccupancyCellClick {
64
+ room: OccupancyRoom;
65
+ date: string;
66
+ }
67
+ /**
68
+ * A stay's edge was dragged (or, on a focused bar, adjusted with Shift +
69
+ * arrow keys) to a new date — extending or shortening it. Emitted once, when
70
+ * the gesture ends with a date that actually differs from where it started;
71
+ * a drag released back where it began, or cancelled with Escape, emits
72
+ * nothing. The component only *renders* the drag live and reports the
73
+ * result — it never writes to `rooms` itself, so the bar's real position
74
+ * does not change until the consumer applies the proposal (typically after
75
+ * confirming it against whatever the server allows) and passes updated
76
+ * rooms back in.
77
+ */
78
+ export interface OccupancyBarResize {
79
+ bar: OccupancyBar;
80
+ room: OccupancyRoom;
81
+ /** Which end moved: the arrival (`'start'`) or the departure (`'end'`). */
82
+ edge: 'start' | 'end';
83
+ previousStartDate: string;
84
+ previousEndDate: string;
85
+ proposedStartDate: string;
86
+ proposedEndDate: string;
87
+ }
88
+ /**
89
+ * A whole stay was picked up by its body and dropped somewhere else —
90
+ * shifted to different dates (dragged left/right), moved to a different room
91
+ * (dragged up/down onto another room's row), or both at once. Emitted once,
92
+ * when the drop actually differs from where the drag started; a drag
93
+ * released back where it began, or cancelled with Escape, emits nothing.
94
+ * Same contract as `OccupancyBarResize`: this only reports the proposal, it
95
+ * never writes to `rooms` itself.
96
+ */
97
+ export interface OccupancyBarMove {
98
+ bar: OccupancyBar;
99
+ fromRoom: OccupancyRoom;
100
+ toRoom: OccupancyRoom;
101
+ previousStartDate: string;
102
+ previousEndDate: string;
103
+ proposedStartDate: string;
104
+ proposedEndDate: string;
105
+ }
106
+ /**
107
+ * A new booking's dates were proposed by dragging across empty lane cells in
108
+ * a room, or by the keyboard equivalent (Enter marks the start on a focused
109
+ * cell, Left/Right extend the departure date, Enter again commits). Same
110
+ * contract as `OccupancyBarResize`/`OccupancyBarMove`: the component only
111
+ * reports the proposal — it never creates a bar itself.
112
+ */
113
+ export interface OccupancyBarCreate {
114
+ room: OccupancyRoom;
115
+ proposedStartDate: string;
116
+ proposedEndDate: string;
117
+ }
@@ -0,0 +1,98 @@
1
+ import { OccupancyBar, OccupancyClosure, OccupancyRoom } from './occupancy-grid.interface';
2
+ export interface GroupRow {
3
+ kind: 'group';
4
+ key: string;
5
+ depth: 0 | 1 | 2;
6
+ label: string;
7
+ roomCount: number;
8
+ }
9
+ export interface LaneBar {
10
+ bar: OccupancyBar;
11
+ lane: number;
12
+ }
13
+ export interface RoomRow {
14
+ kind: 'room';
15
+ key: string;
16
+ room: OccupancyRoom;
17
+ lanes: number;
18
+ bars: LaneBar[];
19
+ }
20
+ export type GridRow = GroupRow | RoomRow;
21
+ export interface PositionedRow {
22
+ row: GridRow;
23
+ top: number;
24
+ height: number;
25
+ }
26
+ export interface BarGeometry {
27
+ left: number;
28
+ width: number;
29
+ cutLeft: boolean;
30
+ cutRight: boolean;
31
+ }
32
+ export interface MonthSegment {
33
+ label: string;
34
+ year: number;
35
+ month: number;
36
+ left: number;
37
+ width: number;
38
+ }
39
+ export interface DayColumn {
40
+ iso: string;
41
+ left: number;
42
+ dayOfMonth: number;
43
+ weekday: number;
44
+ isWeekend: boolean;
45
+ }
46
+ /** Greedy interval packing. Half-open, so a bar starting the day another ends shares its lane. */
47
+ export declare function assignLanes(bars: OccupancyBar[]): LaneBar[];
48
+ /** dorm › floor › type › rooms, as a flat list with group headers. Collapsed groups hide their rooms. */
49
+ export declare function buildRows(rooms: OccupancyRoom[], dormName: string, collapsed: ReadonlySet<string>): GridRow[];
50
+ export declare const GROUP_ROW_HEIGHT = 28;
51
+ export declare function rowHeight(row: GridRow, laneHeight: number): number;
52
+ export declare function positionRows(rows: GridRow[], laneHeight: number): PositionedRow[];
53
+ export declare function totalHeight(positioned: PositionedRow[]): number;
54
+ /** Indices [first, last] of rows intersecting the viewport, with overscan. Binary search on top. */
55
+ export declare function visibleRange(positioned: PositionedRow[], scrollTop: number, viewportHeight: number, overscan?: number): {
56
+ first: number;
57
+ last: number;
58
+ };
59
+ /** Clip to the window and convert to pixels. Returns null when the bar is entirely outside. */
60
+ export declare function barGeometry(bar: {
61
+ startDate: string;
62
+ endDate: string;
63
+ continuesBefore?: boolean;
64
+ continuesAfter?: boolean;
65
+ }, from: string, to: string, dayWidth: number): BarGeometry | null;
66
+ export declare function dayColumns(from: string, to: string, dayWidth: number): DayColumn[];
67
+ export declare function monthSegments(from: string, to: string, dayWidth: number, monthLabels: string[]): MonthSegment[];
68
+ /** Offset in days from `from` to the first Saturday on or after it (0..6). */
69
+ export declare function weekendOffsetDays(from: string): number;
70
+ /** Bars whose nights include `today`. */
71
+ export declare function takenOn(room: OccupancyRoom, today: string | null): number | null;
72
+ export declare function closureGeometry(closure: OccupancyClosure, from: string, to: string, dayWidth: number): BarGeometry | null;
73
+ /** The calendar date under a pixel offset inside the day canvas (an empty-cell click). */
74
+ export declare function dateAtOffset(offsetX: number, from: string, dayWidth: number): string;
75
+ /**
76
+ * The nearest neighboring bar's boundary on the given edge — the local
77
+ * limit a drag on that edge must not cross without visually overlapping
78
+ * another bar. By default only bars in the same lane count (the rule
79
+ * `assignLanes` used to decide they belong in that slot in the first
80
+ * place); pass `allLanes: true` (see the grid's `preventOverlap` input) to
81
+ * widen that to every other bar in the room, so a resize can never create
82
+ * an overlap even across lanes that are normally allowed to overlap. Not a
83
+ * capacity or closure check: this component knows nothing about either,
84
+ * and the consumer's own save is still the real gate — this only stops the
85
+ * drag from proposing something the grid's own rendering model already
86
+ * knows is wrong.
87
+ */
88
+ export declare function laneNeighborBound(laneBars: LaneBar[], bookingId: string, edge: 'start' | 'end', allLanes?: boolean): string | null;
89
+ /**
90
+ * Whether `[start, end)` would overlap any OTHER bar already in the room
91
+ * (half-open ranges, so a stay starting the day another ends does not
92
+ * count). Used by a whole-bar move when `preventOverlap` is set — unlike
93
+ * `laneNeighborBound`, a move can jump to any date or any room in one
94
+ * gesture, so there is no adjacent "boundary" to clamp to; the drag either
95
+ * lands clear of every other bar in the target room or it does not move
96
+ * there at all.
97
+ */
98
+ export declare function overlapsRoom(room: OccupancyRoom, bookingId: string, start: string, end: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ud-components",
3
- "version": "0.6.2",
3
+ "version": "0.7.1",
4
4
  "peerDependencies": {
5
5
  "@angular/cdk": ">=19",
6
6
  "@angular/common": ">=19",
@@ -21,30 +21,6 @@
21
21
  ".": {
22
22
  "types": "./index.d.ts",
23
23
  "default": "./fesm2022/ud-components.mjs"
24
- },
25
- "./enums/role.enum": {
26
- "types": "./enums/role.enum.d.ts",
27
- "default": "./enums/role.enum.js"
28
- },
29
- "./lib/kpi/kpi.enum": {
30
- "types": "./lib/kpi/kpi.enum.d.ts",
31
- "default": "./lib/kpi/kpi.enum.js"
32
- },
33
- "./lib/edit-view/edit-view-section.directive": {
34
- "types": "./lib/edit-view/edit-view-section.directive.d.ts",
35
- "default": "./lib/edit-view/edit-view-section.directive.js"
36
- },
37
- "./interfaces/page-request.interface": {
38
- "types": "./interfaces/page-request.interface.d.ts",
39
- "default": "./interfaces/page-request.interface.js"
40
- },
41
- "./interfaces/table.interface": {
42
- "types": "./interfaces/table.interface.d.ts",
43
- "default": "./interfaces/table.interface.js"
44
- },
45
- "./interfaces/table-display-column.interface": {
46
- "types": "./interfaces/table-display-column.interface.d.ts",
47
- "default": "./interfaces/table-display-column.interface.js"
48
24
  }
49
25
  }
50
- }
26
+ }
package/public-api.d.ts CHANGED
@@ -9,6 +9,10 @@ export * from './lib/edit-view/edit-view-section.directive';
9
9
  export * from './lib/file-input/file-input.component';
10
10
  export * from './lib/kpi/kpi.component';
11
11
  export * from './lib/modal/modal.component';
12
+ export * from './lib/occupancy-grid/occupancy-grid.component';
13
+ export * from './lib/occupancy-grid/occupancy-grid.interface';
14
+ export * from './lib/occupancy-grid/occupancy-grid.layout';
15
+ export * from './lib/occupancy-grid/local-date';
12
16
  export * from './lib/pill/pill.component';
13
17
  export * from './lib/progress-bar/progress-bar.component';
14
18
  export * from './lib/summary-view/summary-view.component';