ud-components 0.7.0 → 0.7.2
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.
- package/fesm2022/ud-components.mjs +455 -9
- package/fesm2022/ud-components.mjs.map +1 -1
- package/lib/occupancy-grid/occupancy-grid.component.d.ts +139 -3
- package/lib/occupancy-grid/occupancy-grid.interface.d.ts +12 -0
- package/lib/occupancy-grid/occupancy-grid.layout.d.ts +22 -0
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DestroyRef } from '@angular/core';
|
|
2
|
+
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
2
3
|
import { TranslateService } from '@ngx-translate/core';
|
|
3
|
-
import { OccupancyBar, OccupancyBarClick, OccupancyBarMove, OccupancyBarResize, OccupancyCellClick, OccupancyClosure, OccupancyClosureClick, OccupancyRoom } from './occupancy-grid.interface';
|
|
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';
|
|
5
6
|
import * as i0 from "@angular/core";
|
|
6
7
|
export declare const OCCUPANCY_GRID_HEADER_HEIGHT = 52;
|
|
@@ -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>;
|
|
@@ -74,6 +83,13 @@ export declare class OccupancyGridComponent {
|
|
|
74
83
|
* `OccupancyBarMove` — this reports the proposal; it never applies it.
|
|
75
84
|
*/
|
|
76
85
|
barMove: import("@angular/core").OutputEmitterRef<OccupancyBarMove>;
|
|
86
|
+
/**
|
|
87
|
+
* A new booking's dates were proposed by dragging across empty lane cells,
|
|
88
|
+
* or by the keyboard-driven create flow (see `onLaneKeydown`). See
|
|
89
|
+
* `OccupancyBarCreate` — this reports the proposal; it never creates a bar
|
|
90
|
+
* itself.
|
|
91
|
+
*/
|
|
92
|
+
barCreate: import("@angular/core").OutputEmitterRef<OccupancyBarCreate>;
|
|
77
93
|
protected readonly headerHeight = 52;
|
|
78
94
|
private readonly scroller;
|
|
79
95
|
private readonly collapsed;
|
|
@@ -123,9 +139,61 @@ export declare class OccupancyGridComponent {
|
|
|
123
139
|
private moveMoveListener;
|
|
124
140
|
private moveUpListener;
|
|
125
141
|
private moveKeyListener;
|
|
142
|
+
/**
|
|
143
|
+
* The in-progress drag-to-create, if any — null the rest of the time.
|
|
144
|
+
* `startDate` is the anchor the drag began from (mouse) or the focused
|
|
145
|
+
* cell it started from (keyboard); `previewStart`/`previewEnd` are what
|
|
146
|
+
* gets emitted. `viaKeyboard` distinguishes the two sources: a mouse
|
|
147
|
+
* create only commits on mouseup and only once it clears the same
|
|
148
|
+
* click-vs-drag threshold `move` uses, while a keyboard create is live the
|
|
149
|
+
* instant Enter starts it (there is no "release" to wait for) and commits
|
|
150
|
+
* on a second Enter.
|
|
151
|
+
*/
|
|
152
|
+
protected readonly create: import("@angular/core").WritableSignal<{
|
|
153
|
+
room: OccupancyRoom;
|
|
154
|
+
lane: number;
|
|
155
|
+
startDate: string;
|
|
156
|
+
startClientX: number;
|
|
157
|
+
previewStart: string;
|
|
158
|
+
previewEnd: string;
|
|
159
|
+
dragging: boolean;
|
|
160
|
+
viaKeyboard: boolean;
|
|
161
|
+
} | null>;
|
|
162
|
+
private createMoveListener;
|
|
163
|
+
private createUpListener;
|
|
164
|
+
private createKeyListener;
|
|
165
|
+
/**
|
|
166
|
+
* The keyboard-focused empty cell, if any — a room and a date, tracked so
|
|
167
|
+
* Tab can reach an empty lane and arrow keys have somewhere to move from.
|
|
168
|
+
* Cleared on blur unless a keyboard create (see `create`) is in progress,
|
|
169
|
+
* so the highlighted cell does not vanish out from under an active
|
|
170
|
+
* gesture.
|
|
171
|
+
*/
|
|
172
|
+
protected readonly laneFocus: import("@angular/core").WritableSignal<{
|
|
173
|
+
roomId: string;
|
|
174
|
+
date: string;
|
|
175
|
+
} | null>;
|
|
176
|
+
/**
|
|
177
|
+
* The empty cell the mouse is currently over, if any — the pointer
|
|
178
|
+
* equivalent of `laneFocus`, so a mouse user gets the same "here's what
|
|
179
|
+
* you're about to create on" cue a keyboard user gets from Tab. Cleared
|
|
180
|
+
* whenever any gesture (create, resize, or a whole-bar move) is live, so
|
|
181
|
+
* it never competes with that gesture's own preview.
|
|
182
|
+
*/
|
|
183
|
+
protected readonly laneHover: import("@angular/core").WritableSignal<{
|
|
184
|
+
roomId: string;
|
|
185
|
+
date: string;
|
|
186
|
+
lane: number;
|
|
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;
|
|
126
194
|
private suppressNextClick;
|
|
127
195
|
private suppressNextClickTimer;
|
|
128
|
-
constructor(translate: TranslateService, destroyRef: DestroyRef);
|
|
196
|
+
constructor(translate: TranslateService, snackBar: MatSnackBar, destroyRef: DestroyRef);
|
|
129
197
|
protected readonly dayCount: import("@angular/core").Signal<number>;
|
|
130
198
|
protected readonly canvasWidth: import("@angular/core").Signal<number>;
|
|
131
199
|
protected readonly rows: import("@angular/core").Signal<GridRow[]>;
|
|
@@ -156,6 +224,28 @@ export declare class OccupancyGridComponent {
|
|
|
156
224
|
label: string;
|
|
157
225
|
state: import("ud-components").OccupancyBarState;
|
|
158
226
|
} | null>;
|
|
227
|
+
/** The in-progress drag-to-create's preview span, once it clears the drag threshold (mouse) or as soon as it starts (keyboard). */
|
|
228
|
+
protected readonly createGhost: import("@angular/core").Signal<{
|
|
229
|
+
left: number;
|
|
230
|
+
top: number;
|
|
231
|
+
width: number;
|
|
232
|
+
height: number;
|
|
233
|
+
} | null>;
|
|
234
|
+
/**
|
|
235
|
+
* The empty cell to outline — the mouse hover position if the pointer is
|
|
236
|
+
* over one, otherwise the keyboard-focused cell — whenever no create
|
|
237
|
+
* gesture is overriding it with its own live preview.
|
|
238
|
+
*/
|
|
239
|
+
protected readonly laneCursorGeometry: import("@angular/core").Signal<{
|
|
240
|
+
left: number;
|
|
241
|
+
top: number;
|
|
242
|
+
width: number;
|
|
243
|
+
height: number;
|
|
244
|
+
} | null>;
|
|
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. */
|
|
246
|
+
private ghostGeometry;
|
|
247
|
+
/** Where a keyboard create lands: the room's free lane when it has one, else lane 0. */
|
|
248
|
+
private createLane;
|
|
159
249
|
private monthLabels;
|
|
160
250
|
protected geometryOf(bar: OccupancyBar): BarGeometry | null;
|
|
161
251
|
/** The in-progress drag's proposed dates for this bar, or null if it is not the one being dragged. */
|
|
@@ -202,6 +292,12 @@ export declare class OccupancyGridComponent {
|
|
|
202
292
|
private onDragMove;
|
|
203
293
|
/** Mouseup (commit) or Escape (cancel). Emits `barResize` only on commit with an actual change. */
|
|
204
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;
|
|
205
301
|
private removeDragListeners;
|
|
206
302
|
/**
|
|
207
303
|
* Mousedown on a bar's own body (never the edge handles — those stop
|
|
@@ -216,6 +312,46 @@ export declare class OccupancyGridComponent {
|
|
|
216
312
|
/** Mouseup (commit) or Escape (cancel). Emits `barMove` only on commit with an actual change. */
|
|
217
313
|
private endBarMove;
|
|
218
314
|
private removeMoveListeners;
|
|
315
|
+
/**
|
|
316
|
+
* Mousedown on a lane's empty background arms a possible drag-to-create,
|
|
317
|
+
* on the same click-vs-drag threshold as `startBarMove` — a plain click
|
|
318
|
+
* still falls through to `onLaneClick`'s `cellClick` unchanged, since
|
|
319
|
+
* `endCreate` only emits once `dragging` has flipped true.
|
|
320
|
+
*/
|
|
321
|
+
protected startCreate(event: MouseEvent, room: OccupancyRoom, lane?: number): void;
|
|
322
|
+
private onCreateDragMove;
|
|
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. */
|
|
324
|
+
private endCreate;
|
|
325
|
+
private removeCreateListeners;
|
|
326
|
+
/**
|
|
327
|
+
* Focus lands on an empty lane (Tab, or a mouse click on it) — arm a
|
|
328
|
+
* keyboard cursor at today (or the window's first day, if today is out of
|
|
329
|
+
* view) unless this room already has one. Left alone while a keyboard
|
|
330
|
+
* create is in progress on this lane, so refocusing mid-gesture cannot
|
|
331
|
+
* reset it.
|
|
332
|
+
*/
|
|
333
|
+
protected onLaneFocus(room: OccupancyRoom): void;
|
|
334
|
+
/**
|
|
335
|
+
* The pointer moved over a lane's empty background — update the hover
|
|
336
|
+
* cursor to the date under it. Ignored while a create, resize, or
|
|
337
|
+
* whole-bar move is live (that gesture already draws its own preview),
|
|
338
|
+
* and when the event bubbled up from a bar or closure rather than
|
|
339
|
+
* landing on the background itself, so hovering an existing booking does
|
|
340
|
+
* not also outline the empty-cell cursor underneath it.
|
|
341
|
+
*/
|
|
342
|
+
protected onLaneMouseMove(event: MouseEvent, room: OccupancyRoom, lane?: number): void;
|
|
343
|
+
protected onLaneMouseLeave(room: OccupancyRoom): void;
|
|
344
|
+
protected onLaneBlur(): void;
|
|
345
|
+
private defaultCursorDate;
|
|
346
|
+
/**
|
|
347
|
+
* Keyboard path for drag-to-create: with no create in progress, plain
|
|
348
|
+
* ArrowLeft/ArrowRight move the focused cell one day and Enter/Space marks
|
|
349
|
+
* it as the start of a new booking; once that create is live, the same
|
|
350
|
+
* arrow keys extend or shorten the departure date (mirroring
|
|
351
|
+
* `onBarKeydownResize`'s departure-only convention) and a second Enter
|
|
352
|
+
* commits, Escape cancels.
|
|
353
|
+
*/
|
|
354
|
+
protected onLaneKeydown(event: KeyboardEvent, room: OccupancyRoom): void;
|
|
219
355
|
/** Whatever room row (if any) is actually rendered under this point — see `.occ__row--room`'s `data-room-id`. */
|
|
220
356
|
private roomUnderPoint;
|
|
221
357
|
private armSuppressNextClick;
|
|
@@ -232,5 +368,5 @@ export declare class OccupancyGridComponent {
|
|
|
232
368
|
*/
|
|
233
369
|
protected onBarKeydownResize(event: KeyboardEvent, room: OccupancyRoom, bar: OccupancyBar, laneBars: LaneBar[]): void;
|
|
234
370
|
static ɵfac: i0.ɵɵFactoryDeclaration<OccupancyGridComponent, never>;
|
|
235
|
-
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"; }, 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>;
|
|
236
372
|
}
|
|
@@ -103,3 +103,15 @@ export interface OccupancyBarMove {
|
|
|
103
103
|
proposedStartDate: string;
|
|
104
104
|
proposedEndDate: string;
|
|
105
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
|
+
}
|
|
@@ -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;
|