ud-components 0.7.1 → 0.7.3

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.
@@ -1,4 +1,5 @@
1
1
  import { DestroyRef } from '@angular/core';
2
+ import { MatSnackBar } from '@angular/material/snack-bar';
2
3
  import { TranslateService } from '@ngx-translate/core';
3
4
  import { OccupancyBar, OccupancyBarClick, OccupancyBarCreate, OccupancyBarMove, OccupancyBarResize, OccupancyCellClick, OccupancyClosure, OccupancyClosureClick, OccupancyRoom } from './occupancy-grid.interface';
4
5
  import { BarGeometry, GridRow, LaneBar, PositionedRow, RoomRow } from './occupancy-grid.layout';
@@ -25,6 +26,7 @@ export declare const OCCUPANCY_GRID_HEADER_HEIGHT = 52;
25
26
  */
26
27
  export declare class OccupancyGridComponent {
27
28
  private readonly translate;
29
+ private readonly snackBar;
28
30
  rooms: import("@angular/core").InputSignal<OccupancyRoom[]>;
29
31
  dormName: import("@angular/core").InputSignal<string>;
30
32
  from: import("@angular/core").InputSignal<string>;
@@ -49,6 +51,13 @@ export declare class OccupancyGridComponent {
49
51
  * to the last placement that did not.
50
52
  */
51
53
  preventOverlap: import("@angular/core").InputSignal<boolean>;
54
+ /**
55
+ * Off by default, like `preventOverlap`: the grid otherwise defers capacity
56
+ * to the consumer. When set, a create, move or resize that would put more
57
+ * stays in a room than it has beds on some night is dropped instead of
58
+ * emitted, the bar stays where it was, and a snackbar says why.
59
+ */
60
+ preventOverbooking: import("@angular/core").InputSignal<boolean>;
52
61
  barClick: import("@angular/core").OutputEmitterRef<OccupancyBarClick>;
53
62
  closureClick: import("@angular/core").OutputEmitterRef<OccupancyClosureClick>;
54
63
  roomClick: import("@angular/core").OutputEmitterRef<OccupancyRoom>;
@@ -142,6 +151,7 @@ export declare class OccupancyGridComponent {
142
151
  */
143
152
  protected readonly create: import("@angular/core").WritableSignal<{
144
153
  room: OccupancyRoom;
154
+ lane: number;
145
155
  startDate: string;
146
156
  startClientX: number;
147
157
  previewStart: string;
@@ -173,10 +183,17 @@ export declare class OccupancyGridComponent {
173
183
  protected readonly laneHover: import("@angular/core").WritableSignal<{
174
184
  roomId: string;
175
185
  date: string;
186
+ lane: number;
176
187
  } | null>;
188
+ /**
189
+ * The pointer is over a bar or closure. Suppresses the focus-cursor
190
+ * fallback in `laneCursorGeometry`, so a stale keyboard cell does not show
191
+ * up elsewhere while the pointer is on a stay.
192
+ */
193
+ private readonly pointerOnBar;
177
194
  private suppressNextClick;
178
195
  private suppressNextClickTimer;
179
- constructor(translate: TranslateService, destroyRef: DestroyRef);
196
+ constructor(translate: TranslateService, snackBar: MatSnackBar, destroyRef: DestroyRef);
180
197
  protected readonly dayCount: import("@angular/core").Signal<number>;
181
198
  protected readonly canvasWidth: import("@angular/core").Signal<number>;
182
199
  protected readonly rows: import("@angular/core").Signal<GridRow[]>;
@@ -225,8 +242,10 @@ export declare class OccupancyGridComponent {
225
242
  width: number;
226
243
  height: number;
227
244
  } | null>;
228
- /** Canvas-coordinate box for a date span in a given room's row — shared by `createGhost` and `laneCursorGeometry`. */
245
+ /** Canvas-coordinate box for a date span in a given room's row — shared by `createGhost` and `laneCursorGeometry`; `lane` picks which of the row's lanes it sits in. */
229
246
  private ghostGeometry;
247
+ /** Where a keyboard create lands: the room's free lane when it has one, else lane 0. */
248
+ private createLane;
230
249
  private monthLabels;
231
250
  protected geometryOf(bar: OccupancyBar): BarGeometry | null;
232
251
  /** The in-progress drag's proposed dates for this bar, or null if it is not the one being dragged. */
@@ -273,6 +292,12 @@ export declare class OccupancyGridComponent {
273
292
  private onDragMove;
274
293
  /** Mouseup (commit) or Escape (cancel). Emits `barResize` only on commit with an actual change. */
275
294
  private endResize;
295
+ /**
296
+ * With `preventOverbooking`, a gesture that would put more stays in a room
297
+ * than it has beds is dropped here, so the bar simply stays where it was,
298
+ * with a snackbar saying why.
299
+ */
300
+ private rejectIfOverbooked;
276
301
  private removeDragListeners;
277
302
  /**
278
303
  * Mousedown on a bar's own body (never the edge handles — those stop
@@ -293,7 +318,7 @@ export declare class OccupancyGridComponent {
293
318
  * still falls through to `onLaneClick`'s `cellClick` unchanged, since
294
319
  * `endCreate` only emits once `dragging` has flipped true.
295
320
  */
296
- protected startCreate(event: MouseEvent, room: OccupancyRoom): void;
321
+ protected startCreate(event: MouseEvent, room: OccupancyRoom, lane?: number): void;
297
322
  private onCreateDragMove;
298
323
  /** 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
324
  private endCreate;
@@ -314,7 +339,7 @@ export declare class OccupancyGridComponent {
314
339
  * landing on the background itself, so hovering an existing booking does
315
340
  * not also outline the empty-cell cursor underneath it.
316
341
  */
317
- protected onLaneMouseMove(event: MouseEvent, room: OccupancyRoom): void;
342
+ protected onLaneMouseMove(event: MouseEvent, room: OccupancyRoom, lane?: number): void;
318
343
  protected onLaneMouseLeave(room: OccupancyRoom): void;
319
344
  protected onLaneBlur(): void;
320
345
  private defaultCursorDate;
@@ -343,5 +368,5 @@ export declare class OccupancyGridComponent {
343
368
  */
344
369
  protected onBarKeydownResize(event: KeyboardEvent, room: OccupancyRoom, bar: OccupancyBar, laneBars: LaneBar[]): void;
345
370
  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>;
371
+ 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; }; "preventOverbooking": { "alias": "preventOverbooking"; "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
372
  }
@@ -15,6 +15,8 @@ export interface RoomRow {
15
15
  key: string;
16
16
  room: OccupancyRoom;
17
17
  lanes: number;
18
+ /** The one empty lane a room with spare beds offers for a new stay, or null when it has none. */
19
+ freeLane: number | null;
18
20
  bars: LaneBar[];
19
21
  }
20
22
  export type GridRow = GroupRow | RoomRow;
@@ -96,3 +98,23 @@ export declare function laneNeighborBound(laneBars: LaneBar[], bookingId: string
96
98
  * there at all.
97
99
  */
98
100
  export declare function overlapsRoom(room: OccupancyRoom, bookingId: string, start: string, end: string): boolean;
101
+ /** Whether `[start, end)` overlaps any closed period of the room (half-open, like `overlapsRoom`). */
102
+ export declare function overlapsClosure(room: OccupancyRoom, start: string, end: string): boolean;
103
+ /**
104
+ * Pulls a create drag's moving edge back to the nearest closed period between
105
+ * it and the anchor, so a drag can stop at a closure but never cross it.
106
+ */
107
+ export declare function clampToClosures(room: OccupancyRoom, anchor: string, date: string): string;
108
+ /**
109
+ * The lane a new stay over `[start, end)` would sit in: the first lane of the
110
+ * row with no bar in that span (the same greedy rule `assignLanes` uses), or,
111
+ * when every lane is taken, the position just below the last one. The stay
112
+ * being moved (`ignoreBookingId`, '' for a new one) is not an obstacle.
113
+ */
114
+ export declare function laneForSpan(row: RoomRow, start: string, end: string, ignoreBookingId: string): number;
115
+ /**
116
+ * Whether putting a stay over `[start, end)` in this room would leave any
117
+ * night with more stays than beds. `bookingId` is the stay being moved or
118
+ * resized, so it does not count against itself (pass '' for a new stay).
119
+ */
120
+ export declare function overbooksRoom(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.7.1",
3
+ "version": "0.7.3",
4
4
  "peerDependencies": {
5
5
  "@angular/cdk": ">=19",
6
6
  "@angular/common": ">=19",