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.
@@ -1,7 +1,7 @@
1
1
  import * as i1$2 from '@angular/common';
2
2
  import { CommonModule, formatDate, NgClass, AsyncPipe, NgStyle, DatePipe, NgTemplateOutlet } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
- import { ViewChild, Input, CUSTOM_ELEMENTS_SCHEMA, Component, Inject, Pipe, inject, EventEmitter, forwardRef, Output, HostBinding, Optional, Injectable, DestroyRef, isSignal, TemplateRef, ContentChild, ViewContainerRef, Directive, ContentChildren, input, effect, ViewChildren, output, signal, ElementRef, viewChild, computed, HostListener } from '@angular/core';
4
+ import { ViewChild, Input, CUSTOM_ELEMENTS_SCHEMA, Component, Inject, Pipe, inject, EventEmitter, forwardRef, Output, HostBinding, Optional, Injectable, DestroyRef, isSignal, TemplateRef, ContentChild, ViewContainerRef, Directive, ContentChildren, input, effect, output, viewChild, signal, computed, ChangeDetectionStrategy, ViewChildren, ElementRef, HostListener } from '@angular/core';
5
5
  import * as i1 from '@angular/forms';
6
6
  import { FormsModule, ControlContainer, ReactiveFormsModule, NG_VALUE_ACCESSOR, FormControl, FormGroupDirective, FormGroup, Validators } from '@angular/forms';
7
7
  import * as i1$1 from '@angular/material/snack-bar';
@@ -3509,6 +3509,1240 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImpo
3509
3509
  type: Input
3510
3510
  }] } });
3511
3511
 
3512
+ /**
3513
+ * Calendar-date arithmetic on YYYY-MM-DD strings, with no `new Date(string)`.
3514
+ *
3515
+ * A bare date parses as UTC midnight in JavaScript, which west of Greenwich is
3516
+ * the previous evening, and a grid column that is off by one is exactly the
3517
+ * bug this component exists to make visible. Days are counted on UTC epoch
3518
+ * days from numeric parts, so DST transitions cannot move a column either.
3519
+ */
3520
+ const MS_PER_DAY = 86_400_000;
3521
+ const ISO = /^(\d{4})-(\d{2})-(\d{2})$/;
3522
+ function isIsoDate(value) {
3523
+ return typeof value === 'string' && ISO.test(value);
3524
+ }
3525
+ /** Days since 1970-01-01 for a YYYY-MM-DD string. Throws on anything else. */
3526
+ function epochDay(iso) {
3527
+ const m = ISO.exec(iso);
3528
+ if (!m) {
3529
+ throw new Error(`Not a YYYY-MM-DD date: '${iso}'`);
3530
+ }
3531
+ return Math.round(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])) / MS_PER_DAY);
3532
+ }
3533
+ /** `b - a` in whole days. Positive when b is after a. */
3534
+ function daysBetween(a, b) {
3535
+ return epochDay(b) - epochDay(a);
3536
+ }
3537
+ function addDays(iso, days) {
3538
+ const d = new Date((epochDay(iso) + days) * MS_PER_DAY);
3539
+ return `${d.getUTCFullYear()}-${String(d.getUTCMonth() + 1).padStart(2, '0')}-${String(d.getUTCDate()).padStart(2, '0')}`;
3540
+ }
3541
+ /** 0 = Sunday … 6 = Saturday, for the calendar date itself. */
3542
+ function weekday(iso) {
3543
+ // 1970-01-01 was a Thursday (4).
3544
+ return (((epochDay(iso) + 4) % 7) + 7) % 7;
3545
+ }
3546
+ function monthOf(iso) {
3547
+ return Number(iso.slice(5, 7));
3548
+ }
3549
+ function yearOf(iso) {
3550
+ return Number(iso.slice(0, 4));
3551
+ }
3552
+ function dayOfMonth(iso) {
3553
+ return Number(iso.slice(8, 10));
3554
+ }
3555
+ function maxIso(a, b) {
3556
+ return a >= b ? a : b;
3557
+ }
3558
+ function minIso(a, b) {
3559
+ return a <= b ? a : b;
3560
+ }
3561
+
3562
+ const numeric = (a, b) => a.localeCompare(b, undefined, { numeric: true, sensitivity: 'base' });
3563
+ /** Greedy interval packing. Half-open, so a bar starting the day another ends shares its lane. */
3564
+ function assignLanes(bars) {
3565
+ const sorted = [...bars].sort((a, b) => a.startDate.localeCompare(b.startDate) ||
3566
+ a.bookingId.localeCompare(b.bookingId));
3567
+ const laneEnds = [];
3568
+ return sorted.map(bar => {
3569
+ let lane = laneEnds.findIndex(end => end <= bar.startDate);
3570
+ if (lane === -1) {
3571
+ lane = laneEnds.length;
3572
+ laneEnds.push(bar.endDate);
3573
+ }
3574
+ else {
3575
+ laneEnds[lane] = bar.endDate;
3576
+ }
3577
+ return { bar, lane };
3578
+ });
3579
+ }
3580
+ /** dorm › floor › type › rooms, as a flat list with group headers. Collapsed groups hide their rooms. */
3581
+ function buildRows(rooms, dormName, collapsed) {
3582
+ const rows = [];
3583
+ if (rooms.length === 0) {
3584
+ return rows;
3585
+ }
3586
+ const dormKey = `dorm:${dormName}`;
3587
+ rows.push({
3588
+ kind: 'group',
3589
+ key: dormKey,
3590
+ depth: 0,
3591
+ label: dormName,
3592
+ roomCount: rooms.length,
3593
+ });
3594
+ if (collapsed.has(dormKey)) {
3595
+ return rows;
3596
+ }
3597
+ const byFloor = new Map();
3598
+ for (const room of rooms) {
3599
+ const list = byFloor.get(room.floorLevel) ?? [];
3600
+ list.push(room);
3601
+ byFloor.set(room.floorLevel, list);
3602
+ }
3603
+ for (const floorLevel of [...byFloor.keys()].sort(numeric)) {
3604
+ const floorRooms = byFloor.get(floorLevel);
3605
+ const floorKey = `${dormKey}/floor:${floorLevel}`;
3606
+ rows.push({
3607
+ kind: 'group',
3608
+ key: floorKey,
3609
+ depth: 1,
3610
+ label: floorLevel,
3611
+ roomCount: floorRooms.length,
3612
+ });
3613
+ if (collapsed.has(floorKey)) {
3614
+ continue;
3615
+ }
3616
+ const byType = new Map();
3617
+ for (const room of floorRooms) {
3618
+ const list = byType.get(room.type) ?? [];
3619
+ list.push(room);
3620
+ byType.set(room.type, list);
3621
+ }
3622
+ for (const type of [...byType.keys()].sort(numeric)) {
3623
+ const typeRooms = byType.get(type);
3624
+ const typeKey = `${floorKey}/type:${type}`;
3625
+ rows.push({
3626
+ kind: 'group',
3627
+ key: typeKey,
3628
+ depth: 2,
3629
+ label: type,
3630
+ roomCount: typeRooms.length,
3631
+ });
3632
+ if (collapsed.has(typeKey)) {
3633
+ continue;
3634
+ }
3635
+ for (const room of [...typeRooms].sort((a, b) => numeric(a.number, b.number) || a.roomId.localeCompare(b.roomId))) {
3636
+ const bars = assignLanes(room.bars);
3637
+ const lanes = bars.reduce((max, b) => Math.max(max, b.lane + 1), 0);
3638
+ rows.push({
3639
+ kind: 'room',
3640
+ key: `room:${room.roomId}`,
3641
+ room,
3642
+ lanes,
3643
+ bars,
3644
+ });
3645
+ }
3646
+ }
3647
+ }
3648
+ return rows;
3649
+ }
3650
+ const GROUP_ROW_HEIGHT = 28;
3651
+ function rowHeight(row, laneHeight) {
3652
+ if (row.kind === 'group') {
3653
+ return GROUP_ROW_HEIGHT;
3654
+ }
3655
+ const lanes = Math.max(1, row.lanes);
3656
+ return 8 + lanes * laneHeight + (lanes - 1) * 4;
3657
+ }
3658
+ function positionRows(rows, laneHeight) {
3659
+ let top = 0;
3660
+ return rows.map(row => {
3661
+ const height = rowHeight(row, laneHeight);
3662
+ const positioned = { row, top, height };
3663
+ top += height;
3664
+ return positioned;
3665
+ });
3666
+ }
3667
+ function totalHeight(positioned) {
3668
+ const last = positioned[positioned.length - 1];
3669
+ return last ? last.top + last.height : 0;
3670
+ }
3671
+ /** Indices [first, last] of rows intersecting the viewport, with overscan. Binary search on top. */
3672
+ function visibleRange(positioned, scrollTop, viewportHeight, overscan = 400) {
3673
+ if (positioned.length === 0) {
3674
+ return { first: 0, last: -1 };
3675
+ }
3676
+ const minTop = Math.max(0, scrollTop - overscan);
3677
+ const maxTop = scrollTop + viewportHeight + overscan;
3678
+ let lo = 0;
3679
+ let hi = positioned.length - 1;
3680
+ while (lo < hi) {
3681
+ const mid = (lo + hi) >> 1;
3682
+ if (positioned[mid].top + positioned[mid].height <= minTop) {
3683
+ lo = mid + 1;
3684
+ }
3685
+ else {
3686
+ hi = mid;
3687
+ }
3688
+ }
3689
+ const first = lo;
3690
+ let last = first;
3691
+ while (last + 1 < positioned.length && positioned[last + 1].top < maxTop) {
3692
+ last++;
3693
+ }
3694
+ return { first, last };
3695
+ }
3696
+ /** Clip to the window and convert to pixels. Returns null when the bar is entirely outside. */
3697
+ function barGeometry(bar, from, to, dayWidth) {
3698
+ const clipStart = maxIso(bar.startDate, from);
3699
+ const clipEnd = minIso(bar.endDate, to);
3700
+ const days = daysBetween(clipStart, clipEnd);
3701
+ if (days <= 0) {
3702
+ return null;
3703
+ }
3704
+ return {
3705
+ left: daysBetween(from, clipStart) * dayWidth,
3706
+ width: days * dayWidth,
3707
+ cutLeft: bar.startDate < from,
3708
+ cutRight: bar.endDate > to,
3709
+ };
3710
+ }
3711
+ function dayColumns(from, to, dayWidth) {
3712
+ const count = daysBetween(from, to);
3713
+ const columns = [];
3714
+ for (let i = 0; i < count; i++) {
3715
+ const iso = addDays(from, i);
3716
+ const wd = weekday(iso);
3717
+ columns.push({
3718
+ iso,
3719
+ left: i * dayWidth,
3720
+ dayOfMonth: dayOfMonth(iso),
3721
+ weekday: wd,
3722
+ isWeekend: wd === 0 || wd === 6,
3723
+ });
3724
+ }
3725
+ return columns;
3726
+ }
3727
+ function monthSegments(from, to, dayWidth, monthLabels) {
3728
+ const segments = [];
3729
+ const count = daysBetween(from, to);
3730
+ let i = 0;
3731
+ while (i < count) {
3732
+ const iso = addDays(from, i);
3733
+ const year = yearOf(iso);
3734
+ const month = monthOf(iso);
3735
+ let j = i;
3736
+ while (j < count) {
3737
+ const next = addDays(from, j);
3738
+ if (yearOf(next) !== year || monthOf(next) !== month) {
3739
+ break;
3740
+ }
3741
+ j++;
3742
+ }
3743
+ segments.push({
3744
+ label: `${monthLabels[month - 1]} ${year}`,
3745
+ year,
3746
+ month,
3747
+ left: i * dayWidth,
3748
+ width: (j - i) * dayWidth,
3749
+ });
3750
+ i = j;
3751
+ }
3752
+ return segments;
3753
+ }
3754
+ /** Offset in days from `from` to the first Saturday on or after it (0..6). */
3755
+ function weekendOffsetDays(from) {
3756
+ return (6 - weekday(from) + 7) % 7;
3757
+ }
3758
+ /** Bars whose nights include `today`. */
3759
+ function takenOn(room, today) {
3760
+ if (!today) {
3761
+ return null;
3762
+ }
3763
+ return room.bars.filter(b => b.startDate <= today && today < b.endDate)
3764
+ .length;
3765
+ }
3766
+ function closureGeometry(closure, from, to, dayWidth) {
3767
+ return barGeometry(closure, from, to, dayWidth);
3768
+ }
3769
+ /** The calendar date under a pixel offset inside the day canvas (an empty-cell click). */
3770
+ function dateAtOffset(offsetX, from, dayWidth) {
3771
+ return addDays(from, Math.max(0, Math.floor(offsetX / dayWidth)));
3772
+ }
3773
+ /**
3774
+ * The nearest neighboring bar's boundary on the given edge — the local
3775
+ * limit a drag on that edge must not cross without visually overlapping
3776
+ * another bar. By default only bars in the same lane count (the rule
3777
+ * `assignLanes` used to decide they belong in that slot in the first
3778
+ * place); pass `allLanes: true` (see the grid's `preventOverlap` input) to
3779
+ * widen that to every other bar in the room, so a resize can never create
3780
+ * an overlap even across lanes that are normally allowed to overlap. Not a
3781
+ * capacity or closure check: this component knows nothing about either,
3782
+ * and the consumer's own save is still the real gate — this only stops the
3783
+ * drag from proposing something the grid's own rendering model already
3784
+ * knows is wrong.
3785
+ */
3786
+ function laneNeighborBound(laneBars, bookingId, edge, allLanes = false) {
3787
+ const mine = laneBars.find(lb => lb.bar.bookingId === bookingId);
3788
+ if (!mine) {
3789
+ return null;
3790
+ }
3791
+ const others = laneBars.filter(lb => lb.bar.bookingId !== bookingId && (allLanes || lb.lane === mine.lane));
3792
+ if (edge === 'start') {
3793
+ const before = others.filter(lb => lb.bar.endDate <= mine.bar.startDate);
3794
+ if (before.length === 0) {
3795
+ return null;
3796
+ }
3797
+ return before.reduce((a, b) => (a.bar.endDate > b.bar.endDate ? a : b)).bar
3798
+ .endDate;
3799
+ }
3800
+ const after = others.filter(lb => lb.bar.startDate >= mine.bar.endDate);
3801
+ if (after.length === 0) {
3802
+ return null;
3803
+ }
3804
+ return after.reduce((a, b) => (a.bar.startDate < b.bar.startDate ? a : b)).bar
3805
+ .startDate;
3806
+ }
3807
+ /**
3808
+ * Whether `[start, end)` would overlap any OTHER bar already in the room
3809
+ * (half-open ranges, so a stay starting the day another ends does not
3810
+ * count). Used by a whole-bar move when `preventOverlap` is set — unlike
3811
+ * `laneNeighborBound`, a move can jump to any date or any room in one
3812
+ * gesture, so there is no adjacent "boundary" to clamp to; the drag either
3813
+ * lands clear of every other bar in the target room or it does not move
3814
+ * there at all.
3815
+ */
3816
+ function overlapsRoom(room, bookingId, start, end) {
3817
+ return room.bars.some(b => b.bookingId !== bookingId && start < b.endDate && b.startDate < end);
3818
+ }
3819
+
3820
+ const OCCUPANCY_GRID_HEADER_HEIGHT = 52;
3821
+ /** How far the pointer must move before a mousedown on a bar's body becomes a whole-bar drag rather than a click. */
3822
+ const MOVE_DRAG_THRESHOLD_PX = 4;
3823
+ /**
3824
+ * Rooms as rows, days as columns, one bar per stay (UC-11). It never writes
3825
+ * anywhere — `rooms` is the only source of truth and this component never
3826
+ * mutates it — but it is not read-only in the sense of being inert: a bar's
3827
+ * edge can be dragged (or, on a focused bar, Shift + arrow-keyed) to propose
3828
+ * a new date, reported via `barResize`; a bar's body can be dragged to a new
3829
+ * date, a different room, or both, reported via `barMove`. Every other
3830
+ * gesture (clicks, the nav buttons) works the same way: report what
3831
+ * happened, apply nothing.
3832
+ *
3833
+ * Owns its own row virtualization: rows have different heights (one lane per
3834
+ * overlapping stay), which the CDK's stable fixed-size strategy cannot do, and
3835
+ * the autosize strategy is still experimental. Rows are positioned from a
3836
+ * prefix sum of heights and only those intersecting the viewport are rendered.
3837
+ *
3838
+ * Every date is a YYYY-MM-DD string and every column is computed by
3839
+ * local-date.ts; `new Date(string)` is never used, so a column can never be
3840
+ * off by one west of Greenwich.
3841
+ */
3842
+ class OccupancyGridComponent {
3843
+ translate;
3844
+ rooms = input([]);
3845
+ dormName = input('');
3846
+ from = input.required();
3847
+ to = input.required();
3848
+ today = input(null);
3849
+ dayWidth = input(28);
3850
+ leftColumnWidth = input(220);
3851
+ laneHeight = input(22);
3852
+ loading = input(false);
3853
+ /** Days the ‹ / › nav buttons and the ArrowLeft/ArrowRight keys shift the window by. */
3854
+ navStepDays = input(7);
3855
+ /**
3856
+ * When true, a resize or whole-bar move drag is never allowed to leave
3857
+ * two bars in the same room overlapping in time. The default (false)
3858
+ * lets bars in different lanes of the same room legitimately overlap —
3859
+ * an outgoing stay's last few nights next to an incoming one's first, say
3860
+ * — which is exactly what the lane system exists to display. A strict
3861
+ * room grid, where a room can hold only one booking at a time, sets this
3862
+ * so a drag simply cannot propose a second one over it: a resize clamps
3863
+ * at the nearest other bar in the room (not just its own lane), and a
3864
+ * move drag ignores any candidate date/room that would overlap, sticking
3865
+ * to the last placement that did not.
3866
+ */
3867
+ preventOverlap = input(false);
3868
+ barClick = output();
3869
+ closureClick = output();
3870
+ roomClick = output();
3871
+ /** An empty day cell was clicked: the room and the date under the pointer. */
3872
+ cellClick = output();
3873
+ reachedEnd = output();
3874
+ /**
3875
+ * The nav buttons or an arrow key asked to move the window. The component
3876
+ * does not own `from`/`to` (the consumer does, same as every other input
3877
+ * here), so it reports the signed day delta — negative for earlier,
3878
+ * positive for later — rather than computing new dates itself. A consumer
3879
+ * that wants the shift applied does
3880
+ * `from = addDays(from, delta); to = addDays(to, delta)`.
3881
+ */
3882
+ windowShift = output();
3883
+ /**
3884
+ * A bar's edge was dragged, or Shift + arrow-keyed, to a new date. See
3885
+ * `OccupancyBarResize` — this reports the proposal; it never applies it.
3886
+ */
3887
+ barResize = output();
3888
+ /**
3889
+ * A bar's body was dragged to new dates, a different room, or both. See
3890
+ * `OccupancyBarMove` — this reports the proposal; it never applies it.
3891
+ */
3892
+ barMove = output();
3893
+ /**
3894
+ * A new booking's dates were proposed by dragging across empty lane cells,
3895
+ * or by the keyboard-driven create flow (see `onLaneKeydown`). See
3896
+ * `OccupancyBarCreate` — this reports the proposal; it never creates a bar
3897
+ * itself.
3898
+ */
3899
+ barCreate = output();
3900
+ headerHeight = OCCUPANCY_GRID_HEADER_HEIGHT;
3901
+ scroller = viewChild.required('scroller');
3902
+ collapsed = signal(new Set());
3903
+ scrollTop = signal(0);
3904
+ viewportHeight = signal(600);
3905
+ lastEndEmittedFor = null;
3906
+ /**
3907
+ * The in-progress drag, if any — null the rest of the time. `geometryOf`
3908
+ * and `barTitle` read the preview dates for whichever bar this names so
3909
+ * the drag renders live; nothing else about `rooms` changes, since the
3910
+ * component does not own that input.
3911
+ */
3912
+ resize = signal(null);
3913
+ dragMoveListener = null;
3914
+ dragUpListener = null;
3915
+ dragKeyListener = null;
3916
+ /**
3917
+ * The in-progress whole-bar drag, if any — null the rest of the time.
3918
+ * `dragging` only flips true once the pointer clears a small threshold, so
3919
+ * a plain click (mousedown + mouseup with no real movement) still opens
3920
+ * the drawer as `barClick` instead of being swallowed as a zero-distance
3921
+ * move. `targetRoom` starts as `fromRoom` and is re-resolved on every
3922
+ * mousemove from whatever `.occ__row--room` is actually under the
3923
+ * pointer — see `roomUnderPoint` — so dragging vertically onto another
3924
+ * room's row is exactly the gesture `roomUnderPoint` is built to read.
3925
+ */
3926
+ move = signal(null);
3927
+ moveMoveListener = null;
3928
+ moveUpListener = null;
3929
+ moveKeyListener = null;
3930
+ /**
3931
+ * The in-progress drag-to-create, if any — null the rest of the time.
3932
+ * `startDate` is the anchor the drag began from (mouse) or the focused
3933
+ * cell it started from (keyboard); `previewStart`/`previewEnd` are what
3934
+ * gets emitted. `viaKeyboard` distinguishes the two sources: a mouse
3935
+ * create only commits on mouseup and only once it clears the same
3936
+ * click-vs-drag threshold `move` uses, while a keyboard create is live the
3937
+ * instant Enter starts it (there is no "release" to wait for) and commits
3938
+ * on a second Enter.
3939
+ */
3940
+ create = signal(null);
3941
+ createMoveListener = null;
3942
+ createUpListener = null;
3943
+ createKeyListener = null;
3944
+ /**
3945
+ * The keyboard-focused empty cell, if any — a room and a date, tracked so
3946
+ * Tab can reach an empty lane and arrow keys have somewhere to move from.
3947
+ * Cleared on blur unless a keyboard create (see `create`) is in progress,
3948
+ * so the highlighted cell does not vanish out from under an active
3949
+ * gesture.
3950
+ */
3951
+ laneFocus = signal(null);
3952
+ /**
3953
+ * The empty cell the mouse is currently over, if any — the pointer
3954
+ * equivalent of `laneFocus`, so a mouse user gets the same "here's what
3955
+ * you're about to create on" cue a keyboard user gets from Tab. Cleared
3956
+ * whenever any gesture (create, resize, or a whole-bar move) is live, so
3957
+ * it never competes with that gesture's own preview.
3958
+ */
3959
+ laneHover = signal(null);
3960
+ // A drag that ends with the pointer over the lane (not back over the
3961
+ // handle, or not back over the bar's own body) still makes the browser
3962
+ // synthesize a `click` right after the `mouseup`, targeted at the nearest
3963
+ // common ancestor of the mousedown and mouseup elements — which is the
3964
+ // room's lane row, or the bar itself if the drag never left it. Left alone
3965
+ // that click would surface as a spurious cellClick or barClick the instant
3966
+ // a resize or a whole-bar move finishes. This flag is armed in endResize
3967
+ // and endBarMove and consumed by the one click that follows, wherever it
3968
+ // lands; the timer is a safety net for the rare case where no click
3969
+ // follows at all (e.g. the pointer left the window), so a stray flag never
3970
+ // survives to swallow some later, unrelated click.
3971
+ suppressNextClick = false;
3972
+ suppressNextClickTimer = null;
3973
+ constructor(translate, destroyRef) {
3974
+ this.translate = translate;
3975
+ // A drag that is still active when the component is torn down (e.g. the
3976
+ // consumer navigates away mid-drag) must not leave window-level
3977
+ // listeners behind — they would keep firing against a destroyed
3978
+ // component's signals otherwise, and never get cleaned up any other way.
3979
+ destroyRef.onDestroy(() => {
3980
+ this.removeDragListeners();
3981
+ this.removeMoveListeners();
3982
+ this.removeCreateListeners();
3983
+ if (this.suppressNextClickTimer) {
3984
+ clearTimeout(this.suppressNextClickTimer);
3985
+ }
3986
+ });
3987
+ }
3988
+ dayCount = computed(() => isIsoDate(this.from()) && isIsoDate(this.to())
3989
+ ? Math.max(0, daysBetween(this.from(), this.to()))
3990
+ : 0);
3991
+ canvasWidth = computed(() => this.leftColumnWidth() + this.dayCount() * this.dayWidth());
3992
+ rows = computed(() => buildRows(this.rooms(), this.dormName(), this.collapsed()));
3993
+ positioned = computed(() => positionRows(this.rows(), this.laneHeight()));
3994
+ bodyHeight = computed(() => totalHeight(this.positioned()));
3995
+ visible = computed(() => {
3996
+ const { first, last } = visibleRange(this.positioned(), this.scrollTop(), this.viewportHeight());
3997
+ return this.positioned().slice(first, last + 1);
3998
+ });
3999
+ days = computed(() => this.dayCount() ? dayColumns(this.from(), this.to(), this.dayWidth()) : []);
4000
+ months = computed(() => this.dayCount()
4001
+ ? monthSegments(this.from(), this.to(), this.dayWidth(), this.monthLabels())
4002
+ : []);
4003
+ weekendOffsetPx = computed(() => this.dayCount() ? weekendOffsetDays(this.from()) * this.dayWidth() : 0);
4004
+ todayLeft = computed(() => {
4005
+ const today = this.today();
4006
+ if (!today ||
4007
+ !this.dayCount() ||
4008
+ today < this.from() ||
4009
+ today >= this.to()) {
4010
+ return null;
4011
+ }
4012
+ return daysBetween(this.from(), today) * this.dayWidth();
4013
+ });
4014
+ roomsById = computed(() => {
4015
+ const map = new Map();
4016
+ for (const room of this.rooms()) {
4017
+ map.set(room.roomId, room);
4018
+ }
4019
+ return map;
4020
+ });
4021
+ /**
4022
+ * The floating copy of a bar being dragged by its body — null unless a
4023
+ * move drag has cleared the click threshold. Positioned in canvas
4024
+ * coordinates (like `.occ__today`) rather than inside a room's own lane,
4025
+ * because a move can target a room other than the one the drag started
4026
+ * in; `positioned()` already has every visible row's pixel `top`, so no
4027
+ * separate DOM lookup is needed to place it. Always drawn at lane 0 of the
4028
+ * target room — a simplification the consumer's own re-lane on save
4029
+ * supersedes anyway, same as the rest of this component's "report the
4030
+ * gesture, never own the data" contract.
4031
+ */
4032
+ moveGhost = computed(() => {
4033
+ const m = this.move();
4034
+ if (!m || !m.dragging) {
4035
+ return null;
4036
+ }
4037
+ const geometry = barGeometry({ startDate: m.previewStartDate, endDate: m.previewEndDate }, this.from(), this.to(), this.dayWidth());
4038
+ const targetRow = this.positioned().find(p => p.row.kind === 'room' &&
4039
+ p.row.room.roomId === m.targetRoom.roomId);
4040
+ if (!geometry || !targetRow) {
4041
+ return null;
4042
+ }
4043
+ return {
4044
+ left: this.leftColumnWidth() + geometry.left + 1,
4045
+ top: this.headerHeight + targetRow.top + 4,
4046
+ width: geometry.width - 2,
4047
+ height: this.laneHeight(),
4048
+ label: m.bar.studentName,
4049
+ state: m.bar.state,
4050
+ };
4051
+ });
4052
+ /** The in-progress drag-to-create's preview span, once it clears the drag threshold (mouse) or as soon as it starts (keyboard). */
4053
+ createGhost = computed(() => {
4054
+ const c = this.create();
4055
+ if (!c || !c.dragging) {
4056
+ return null;
4057
+ }
4058
+ return this.ghostGeometry(c.room, c.previewStart, c.previewEnd);
4059
+ });
4060
+ /**
4061
+ * The empty cell to outline — the mouse hover position if the pointer is
4062
+ * over one, otherwise the keyboard-focused cell — whenever no create
4063
+ * gesture is overriding it with its own live preview.
4064
+ */
4065
+ laneCursorGeometry = computed(() => {
4066
+ if (this.create()) {
4067
+ return null;
4068
+ }
4069
+ const f = this.laneHover() ?? this.laneFocus();
4070
+ if (!f) {
4071
+ return null;
4072
+ }
4073
+ const room = this.roomsById().get(f.roomId);
4074
+ if (!room) {
4075
+ return null;
4076
+ }
4077
+ return this.ghostGeometry(room, f.date, addDays(f.date, 1));
4078
+ });
4079
+ /** Canvas-coordinate box for a date span in a given room's row — shared by `createGhost` and `laneCursorGeometry`. */
4080
+ ghostGeometry(room, start, end) {
4081
+ const geometry = barGeometry({ startDate: start, endDate: end }, this.from(), this.to(), this.dayWidth());
4082
+ const targetRow = this.positioned().find(p => p.row.kind === 'room' &&
4083
+ p.row.room.roomId === room.roomId);
4084
+ if (!geometry || !targetRow) {
4085
+ return null;
4086
+ }
4087
+ return {
4088
+ left: this.leftColumnWidth() + geometry.left + 1,
4089
+ top: this.headerHeight + targetRow.top + 4,
4090
+ width: geometry.width - 2,
4091
+ height: this.laneHeight(),
4092
+ };
4093
+ }
4094
+ monthLabels() {
4095
+ const keys = [
4096
+ 'jan',
4097
+ 'feb',
4098
+ 'mar',
4099
+ 'apr',
4100
+ 'may',
4101
+ 'jun',
4102
+ 'jul',
4103
+ 'aug',
4104
+ 'sep',
4105
+ 'oct',
4106
+ 'nov',
4107
+ 'dec',
4108
+ ];
4109
+ return keys.map(k => this.translate.instant(`occupancyGrid.months.${k}`));
4110
+ }
4111
+ geometryOf(bar) {
4112
+ const preview = this.previewDatesOf(bar);
4113
+ const effective = preview
4114
+ ? { ...bar, startDate: preview.start, endDate: preview.end }
4115
+ : bar;
4116
+ return barGeometry(effective, this.from(), this.to(), this.dayWidth());
4117
+ }
4118
+ /** The in-progress drag's proposed dates for this bar, or null if it is not the one being dragged. */
4119
+ previewDatesOf(bar) {
4120
+ const r = this.resize();
4121
+ if (!r || r.bar.bookingId !== bar.bookingId) {
4122
+ return null;
4123
+ }
4124
+ return { start: r.previewStart, end: r.previewEnd };
4125
+ }
4126
+ isResizing(bookingId) {
4127
+ return this.resize()?.bar.bookingId === bookingId;
4128
+ }
4129
+ /** True once a whole-bar drag on this booking has cleared the click threshold — see `move`. */
4130
+ isBeingMoved(bookingId) {
4131
+ const m = this.move();
4132
+ return !!m && m.dragging && m.bar.bookingId === bookingId;
4133
+ }
4134
+ /** True while a whole-bar drag is hovering this room as its drop target. */
4135
+ isMoveTarget(roomId) {
4136
+ const m = this.move();
4137
+ return !!m && m.dragging && m.targetRoom.roomId === roomId;
4138
+ }
4139
+ closureGeometryOf(closure) {
4140
+ return closureGeometry(closure, this.from(), this.to(), this.dayWidth());
4141
+ }
4142
+ takenOn(room) {
4143
+ return takenOn(room, this.today());
4144
+ }
4145
+ isCollapsed(key) {
4146
+ return this.collapsed().has(key);
4147
+ }
4148
+ toggleGroup(key) {
4149
+ const next = new Set(this.collapsed());
4150
+ if (next.has(key)) {
4151
+ next.delete(key);
4152
+ }
4153
+ else {
4154
+ next.add(key);
4155
+ }
4156
+ this.collapsed.set(next);
4157
+ }
4158
+ barTitle(bar) {
4159
+ const preview = this.previewDatesOf(bar);
4160
+ const start = preview ? preview.start : bar.startDate;
4161
+ const end = preview ? preview.end : bar.endDate;
4162
+ const state = this.translate.instant(`occupancyGrid.states.${bar.state}`);
4163
+ return `${bar.studentName} · ${start} → ${end} · ${state}`;
4164
+ }
4165
+ closureTitle(closure) {
4166
+ return (this.translate.instant('occupancyGrid.closedReason', {
4167
+ reason: closure.reason,
4168
+ }) + ` · ${closure.startDate} → ${closure.endDate}`);
4169
+ }
4170
+ onScroll() {
4171
+ const el = this.scroller().nativeElement;
4172
+ this.scrollTop.set(el.scrollTop);
4173
+ this.viewportHeight.set(el.clientHeight);
4174
+ const nearEnd = el.scrollLeft + el.clientWidth >= el.scrollWidth - 2 * this.dayWidth();
4175
+ if (nearEnd && this.lastEndEmittedFor !== this.to()) {
4176
+ this.lastEndEmittedFor = this.to();
4177
+ this.reachedEnd.emit(this.to());
4178
+ }
4179
+ }
4180
+ trackRow(_, p) {
4181
+ return p.row.key;
4182
+ }
4183
+ asRoomRow(row) {
4184
+ return row;
4185
+ }
4186
+ /** ‹ / › nav buttons. Emits the signed day delta; see `windowShift`. */
4187
+ shiftWindow(direction) {
4188
+ this.windowShift.emit(direction * this.navStepDays());
4189
+ }
4190
+ /**
4191
+ * ArrowLeft/ArrowRight anywhere in the grid page the window, the same as
4192
+ * the nav buttons — a keyboard user reaching a bar via Tab should not have
4193
+ * to find the buttons to keep moving through time. Left alone otherwise:
4194
+ * a bar, room cell or group header's own Enter handling is untouched.
4195
+ */
4196
+ onGridKeydown(event) {
4197
+ // Shift+Arrow on a focused bar resizes it (onBarKeydownResize, bound on
4198
+ // the bar itself); this handler still sees the same bubbled keydown, so
4199
+ // it must decline plain-Arrow handling here or a resize would also page
4200
+ // the window on every keystroke.
4201
+ if (event.shiftKey) {
4202
+ return;
4203
+ }
4204
+ if (event.key === 'ArrowLeft') {
4205
+ event.preventDefault();
4206
+ this.shiftWindow(-1);
4207
+ }
4208
+ else if (event.key === 'ArrowRight') {
4209
+ event.preventDefault();
4210
+ this.shiftWindow(1);
4211
+ }
4212
+ }
4213
+ /**
4214
+ * A click inside a room's lane that landed on neither a bar nor a closure
4215
+ * (both stop propagation before this fires) — the room and the date under
4216
+ * the pointer. See `OccupancyCellClick`.
4217
+ */
4218
+ onLaneClick(event, room) {
4219
+ if (this.consumeSuppressNextClick()) {
4220
+ return;
4221
+ }
4222
+ const rect = event.currentTarget.getBoundingClientRect();
4223
+ const date = dateAtOffset(event.clientX - rect.left, this.from(), this.dayWidth());
4224
+ this.cellClick.emit({ room, date });
4225
+ }
4226
+ /** The bar's own click handler routes through here so it shares the same resize-click guard as `onLaneClick`. */
4227
+ onBarClick(bar, room) {
4228
+ if (this.consumeSuppressNextClick()) {
4229
+ return;
4230
+ }
4231
+ this.barClick.emit({ bar, room });
4232
+ }
4233
+ // ─────────────────────────────────────────────────────── extend / shorten
4234
+ /**
4235
+ * Mousedown on a bar's edge handle starts a drag. Listeners go on
4236
+ * `window`, not the handle, because the pointer will move well outside
4237
+ * an 8px-wide handle the instant the drag starts; `stopPropagation` keeps
4238
+ * this from also being read as a click on the bar (which would open the
4239
+ * drawer) or on the lane underneath it (a `cellClick`).
4240
+ */
4241
+ startResize(event, room, bar, edge, laneBars) {
4242
+ event.stopPropagation();
4243
+ event.preventDefault();
4244
+ const bound = laneNeighborBound(laneBars, bar.bookingId, edge, this.preventOverlap());
4245
+ this.resize.set({
4246
+ room,
4247
+ bar,
4248
+ edge,
4249
+ previewStart: bar.startDate,
4250
+ previewEnd: bar.endDate,
4251
+ minBound: edge === 'start' ? bound : null,
4252
+ maxBound: edge === 'end' ? bound : null,
4253
+ });
4254
+ this.dragMoveListener = e => this.onDragMove(e);
4255
+ this.dragUpListener = () => this.endResize(true);
4256
+ this.dragKeyListener = e => {
4257
+ if (e.key === 'Escape') {
4258
+ this.endResize(false);
4259
+ }
4260
+ };
4261
+ window.addEventListener('mousemove', this.dragMoveListener);
4262
+ window.addEventListener('mouseup', this.dragUpListener);
4263
+ window.addEventListener('keydown', this.dragKeyListener);
4264
+ }
4265
+ onDragMove(event) {
4266
+ const r = this.resize();
4267
+ if (!r) {
4268
+ return;
4269
+ }
4270
+ const date = this.clientXToDate(event.clientX);
4271
+ if (r.edge === 'start') {
4272
+ let next = date;
4273
+ if (r.minBound && next < r.minBound) {
4274
+ next = r.minBound;
4275
+ }
4276
+ if (next >= r.previewEnd) {
4277
+ next = addDays(r.previewEnd, -1); // never less than one night
4278
+ }
4279
+ this.resize.set({ ...r, previewStart: next });
4280
+ }
4281
+ else {
4282
+ let next = date;
4283
+ if (r.maxBound && next > r.maxBound) {
4284
+ next = r.maxBound;
4285
+ }
4286
+ if (next <= r.previewStart) {
4287
+ next = addDays(r.previewStart, 1);
4288
+ }
4289
+ this.resize.set({ ...r, previewEnd: next });
4290
+ }
4291
+ }
4292
+ /** Mouseup (commit) or Escape (cancel). Emits `barResize` only on commit with an actual change. */
4293
+ endResize(commit) {
4294
+ const r = this.resize();
4295
+ this.removeDragListeners();
4296
+ this.resize.set(null);
4297
+ this.armSuppressNextClick();
4298
+ if (!r || !commit) {
4299
+ return;
4300
+ }
4301
+ if (r.previewStart === r.bar.startDate && r.previewEnd === r.bar.endDate) {
4302
+ return;
4303
+ }
4304
+ this.barResize.emit({
4305
+ bar: r.bar,
4306
+ room: r.room,
4307
+ edge: r.edge,
4308
+ previousStartDate: r.bar.startDate,
4309
+ previousEndDate: r.bar.endDate,
4310
+ proposedStartDate: r.previewStart,
4311
+ proposedEndDate: r.previewEnd,
4312
+ });
4313
+ }
4314
+ removeDragListeners() {
4315
+ if (this.dragMoveListener) {
4316
+ window.removeEventListener('mousemove', this.dragMoveListener);
4317
+ }
4318
+ if (this.dragUpListener) {
4319
+ window.removeEventListener('mouseup', this.dragUpListener);
4320
+ }
4321
+ if (this.dragKeyListener) {
4322
+ window.removeEventListener('keydown', this.dragKeyListener);
4323
+ }
4324
+ this.dragMoveListener = null;
4325
+ this.dragUpListener = null;
4326
+ this.dragKeyListener = null;
4327
+ }
4328
+ // ───────────────────────────────────────────────────────── move the bar
4329
+ /**
4330
+ * Mousedown on a bar's own body (never the edge handles — those stop
4331
+ * propagation before this fires) arms a possible whole-bar move, but does
4332
+ * not yet commit to one: `dragging` stays false, and nothing is rendered
4333
+ * differently, until `onBarDragMove` sees the pointer clear a small
4334
+ * threshold. That is what lets a plain click still fall through to
4335
+ * `onBarClick` unchanged.
4336
+ */
4337
+ startBarMove(event, room, bar) {
4338
+ if (event.button !== 0) {
4339
+ return;
4340
+ }
4341
+ event.preventDefault();
4342
+ event.stopPropagation();
4343
+ this.move.set({
4344
+ bar,
4345
+ fromRoom: room,
4346
+ startClientX: event.clientX,
4347
+ startClientY: event.clientY,
4348
+ originalStartDate: bar.startDate,
4349
+ originalEndDate: bar.endDate,
4350
+ previewStartDate: bar.startDate,
4351
+ previewEndDate: bar.endDate,
4352
+ targetRoom: room,
4353
+ dragging: false,
4354
+ });
4355
+ this.moveMoveListener = e => this.onBarDragMove(e);
4356
+ this.moveUpListener = () => this.endBarMove(true);
4357
+ this.moveKeyListener = e => {
4358
+ if (e.key === 'Escape') {
4359
+ this.endBarMove(false);
4360
+ }
4361
+ };
4362
+ window.addEventListener('mousemove', this.moveMoveListener);
4363
+ window.addEventListener('mouseup', this.moveUpListener);
4364
+ window.addEventListener('keydown', this.moveKeyListener);
4365
+ }
4366
+ onBarDragMove(event) {
4367
+ const m = this.move();
4368
+ if (!m) {
4369
+ return;
4370
+ }
4371
+ const dx = event.clientX - m.startClientX;
4372
+ const dy = event.clientY - m.startClientY;
4373
+ if (!m.dragging &&
4374
+ Math.abs(dx) < MOVE_DRAG_THRESHOLD_PX &&
4375
+ Math.abs(dy) < MOVE_DRAG_THRESHOLD_PX) {
4376
+ return;
4377
+ }
4378
+ const dayDelta = Math.round(dx / this.dayWidth());
4379
+ const previewStartDate = addDays(m.originalStartDate, dayDelta);
4380
+ const previewEndDate = addDays(m.originalEndDate, dayDelta);
4381
+ const targetRoom = this.roomUnderPoint(event.clientX, event.clientY) ?? m.targetRoom;
4382
+ if (this.preventOverlap() &&
4383
+ overlapsRoom(targetRoom, m.bar.bookingId, previewStartDate, previewEndDate)) {
4384
+ // This candidate would overlap another bar in the target room — reject
4385
+ // just this update rather than the whole drag, so the ghost simply
4386
+ // stays at the last placement that did not overlap (the bar's
4387
+ // original spot, the first time a move ever conflicts) instead of
4388
+ // jumping onto an invalid one and back.
4389
+ this.move.set({ ...m, dragging: true });
4390
+ return;
4391
+ }
4392
+ this.move.set({
4393
+ ...m,
4394
+ dragging: true,
4395
+ previewStartDate,
4396
+ previewEndDate,
4397
+ targetRoom,
4398
+ });
4399
+ }
4400
+ /** Mouseup (commit) or Escape (cancel). Emits `barMove` only on commit with an actual change. */
4401
+ endBarMove(commit) {
4402
+ const m = this.move();
4403
+ this.removeMoveListeners();
4404
+ this.move.set(null);
4405
+ if (!m) {
4406
+ return;
4407
+ }
4408
+ if (m.dragging) {
4409
+ this.armSuppressNextClick();
4410
+ }
4411
+ if (!m.dragging || !commit) {
4412
+ return;
4413
+ }
4414
+ if (m.previewStartDate === m.originalStartDate &&
4415
+ m.previewEndDate === m.originalEndDate &&
4416
+ m.targetRoom.roomId === m.fromRoom.roomId) {
4417
+ return;
4418
+ }
4419
+ this.barMove.emit({
4420
+ bar: m.bar,
4421
+ fromRoom: m.fromRoom,
4422
+ toRoom: m.targetRoom,
4423
+ previousStartDate: m.originalStartDate,
4424
+ previousEndDate: m.originalEndDate,
4425
+ proposedStartDate: m.previewStartDate,
4426
+ proposedEndDate: m.previewEndDate,
4427
+ });
4428
+ }
4429
+ removeMoveListeners() {
4430
+ if (this.moveMoveListener) {
4431
+ window.removeEventListener('mousemove', this.moveMoveListener);
4432
+ }
4433
+ if (this.moveUpListener) {
4434
+ window.removeEventListener('mouseup', this.moveUpListener);
4435
+ }
4436
+ if (this.moveKeyListener) {
4437
+ window.removeEventListener('keydown', this.moveKeyListener);
4438
+ }
4439
+ this.moveMoveListener = null;
4440
+ this.moveUpListener = null;
4441
+ this.moveKeyListener = null;
4442
+ }
4443
+ // ─────────────────────────────────────────────── create over empty cells
4444
+ /**
4445
+ * Mousedown on a lane's empty background arms a possible drag-to-create,
4446
+ * on the same click-vs-drag threshold as `startBarMove` — a plain click
4447
+ * still falls through to `onLaneClick`'s `cellClick` unchanged, since
4448
+ * `endCreate` only emits once `dragging` has flipped true.
4449
+ */
4450
+ startCreate(event, room) {
4451
+ if (event.button !== 0) {
4452
+ return;
4453
+ }
4454
+ const startDate = this.clientXToDate(event.clientX);
4455
+ this.create.set({
4456
+ room,
4457
+ startDate,
4458
+ startClientX: event.clientX,
4459
+ previewStart: startDate,
4460
+ previewEnd: addDays(startDate, 1),
4461
+ dragging: false,
4462
+ viaKeyboard: false,
4463
+ });
4464
+ this.createMoveListener = e => this.onCreateDragMove(e);
4465
+ this.createUpListener = () => this.endCreate(true);
4466
+ this.createKeyListener = e => {
4467
+ if (e.key === 'Escape') {
4468
+ this.endCreate(false);
4469
+ }
4470
+ };
4471
+ window.addEventListener('mousemove', this.createMoveListener);
4472
+ window.addEventListener('mouseup', this.createUpListener);
4473
+ window.addEventListener('keydown', this.createKeyListener);
4474
+ }
4475
+ onCreateDragMove(event) {
4476
+ const c = this.create();
4477
+ if (!c || c.viaKeyboard) {
4478
+ return;
4479
+ }
4480
+ const dx = event.clientX - c.startClientX;
4481
+ if (!c.dragging && Math.abs(dx) < MOVE_DRAG_THRESHOLD_PX) {
4482
+ return;
4483
+ }
4484
+ const date = this.clientXToDate(event.clientX);
4485
+ let start = c.startDate;
4486
+ let end = date;
4487
+ if (end < start) {
4488
+ // Dragged backwards from the anchor: the anchor becomes the departure.
4489
+ start = date;
4490
+ end = c.startDate;
4491
+ }
4492
+ if (end <= start) {
4493
+ end = addDays(start, 1); // never less than one night
4494
+ }
4495
+ if (this.preventOverlap() && overlapsRoom(c.room, '', start, end)) {
4496
+ // Reject just this update, same as a whole-bar move's overlap check —
4497
+ // the preview stays at the last span that did not overlap.
4498
+ this.create.set({ ...c, dragging: true });
4499
+ return;
4500
+ }
4501
+ this.create.set({ ...c, dragging: true, previewStart: start, previewEnd: end });
4502
+ }
4503
+ /** 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. */
4504
+ endCreate(commit) {
4505
+ const c = this.create();
4506
+ this.removeCreateListeners();
4507
+ this.create.set(null);
4508
+ if (!c) {
4509
+ return;
4510
+ }
4511
+ if (c.dragging && !c.viaKeyboard) {
4512
+ this.armSuppressNextClick();
4513
+ }
4514
+ if (c.viaKeyboard) {
4515
+ // Keep the cell focused where the gesture left off, so the keyboard
4516
+ // user's position on the grid does not just disappear.
4517
+ this.laneFocus.set({
4518
+ roomId: c.room.roomId,
4519
+ date: commit ? c.previewStart : c.startDate,
4520
+ });
4521
+ }
4522
+ if (!c.dragging || !commit) {
4523
+ return;
4524
+ }
4525
+ this.barCreate.emit({
4526
+ room: c.room,
4527
+ proposedStartDate: c.previewStart,
4528
+ proposedEndDate: c.previewEnd,
4529
+ });
4530
+ }
4531
+ removeCreateListeners() {
4532
+ if (this.createMoveListener) {
4533
+ window.removeEventListener('mousemove', this.createMoveListener);
4534
+ }
4535
+ if (this.createUpListener) {
4536
+ window.removeEventListener('mouseup', this.createUpListener);
4537
+ }
4538
+ if (this.createKeyListener) {
4539
+ window.removeEventListener('keydown', this.createKeyListener);
4540
+ }
4541
+ this.createMoveListener = null;
4542
+ this.createUpListener = null;
4543
+ this.createKeyListener = null;
4544
+ }
4545
+ /**
4546
+ * Focus lands on an empty lane (Tab, or a mouse click on it) — arm a
4547
+ * keyboard cursor at today (or the window's first day, if today is out of
4548
+ * view) unless this room already has one. Left alone while a keyboard
4549
+ * create is in progress on this lane, so refocusing mid-gesture cannot
4550
+ * reset it.
4551
+ */
4552
+ onLaneFocus(room) {
4553
+ if (this.create()?.viaKeyboard) {
4554
+ return;
4555
+ }
4556
+ const existing = this.laneFocus();
4557
+ const date = existing && existing.roomId === room.roomId
4558
+ ? existing.date
4559
+ : this.defaultCursorDate();
4560
+ this.laneFocus.set({ roomId: room.roomId, date });
4561
+ }
4562
+ /**
4563
+ * The pointer moved over a lane's empty background — update the hover
4564
+ * cursor to the date under it. Ignored while a create, resize, or
4565
+ * whole-bar move is live (that gesture already draws its own preview),
4566
+ * and when the event bubbled up from a bar or closure rather than
4567
+ * landing on the background itself, so hovering an existing booking does
4568
+ * not also outline the empty-cell cursor underneath it.
4569
+ */
4570
+ onLaneMouseMove(event, room) {
4571
+ if (this.create() || this.resize() || this.move()?.dragging) {
4572
+ this.laneHover.set(null);
4573
+ return;
4574
+ }
4575
+ if (event.target !== event.currentTarget) {
4576
+ this.laneHover.set(null);
4577
+ return;
4578
+ }
4579
+ const date = this.clientXToDate(event.clientX);
4580
+ const cur = this.laneHover();
4581
+ if (cur && cur.roomId === room.roomId && cur.date === date) {
4582
+ return;
4583
+ }
4584
+ this.laneHover.set({ roomId: room.roomId, date });
4585
+ }
4586
+ onLaneMouseLeave(room) {
4587
+ const cur = this.laneHover();
4588
+ if (cur && cur.roomId === room.roomId) {
4589
+ this.laneHover.set(null);
4590
+ }
4591
+ }
4592
+ onLaneBlur() {
4593
+ if (this.create()?.viaKeyboard) {
4594
+ return;
4595
+ }
4596
+ this.laneFocus.set(null);
4597
+ }
4598
+ defaultCursorDate() {
4599
+ const today = this.today();
4600
+ if (today && today >= this.from() && today < this.to()) {
4601
+ return today;
4602
+ }
4603
+ return this.from();
4604
+ }
4605
+ /**
4606
+ * Keyboard path for drag-to-create: with no create in progress, plain
4607
+ * ArrowLeft/ArrowRight move the focused cell one day and Enter/Space marks
4608
+ * it as the start of a new booking; once that create is live, the same
4609
+ * arrow keys extend or shorten the departure date (mirroring
4610
+ * `onBarKeydownResize`'s departure-only convention) and a second Enter
4611
+ * commits, Escape cancels.
4612
+ */
4613
+ onLaneKeydown(event, room) {
4614
+ const c = this.create();
4615
+ if (c && c.viaKeyboard && c.room.roomId === room.roomId) {
4616
+ if (event.key === 'Escape') {
4617
+ event.preventDefault();
4618
+ this.endCreate(false);
4619
+ }
4620
+ else if (event.key === 'Enter') {
4621
+ event.preventDefault();
4622
+ this.endCreate(true);
4623
+ }
4624
+ else if (event.key === 'ArrowRight' || event.key === 'ArrowLeft') {
4625
+ event.preventDefault();
4626
+ event.stopPropagation();
4627
+ let next = addDays(c.previewEnd, event.key === 'ArrowRight' ? 1 : -1);
4628
+ if (next <= c.previewStart) {
4629
+ next = addDays(c.previewStart, 1);
4630
+ }
4631
+ if (this.preventOverlap() && overlapsRoom(room, '', c.previewStart, next)) {
4632
+ return;
4633
+ }
4634
+ this.create.set({ ...c, previewEnd: next });
4635
+ }
4636
+ return;
4637
+ }
4638
+ const cur = this.laneFocus();
4639
+ if (!cur || cur.roomId !== room.roomId) {
4640
+ return;
4641
+ }
4642
+ if (event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
4643
+ event.preventDefault();
4644
+ event.stopPropagation();
4645
+ let next = addDays(cur.date, event.key === 'ArrowRight' ? 1 : -1);
4646
+ if (next < this.from()) {
4647
+ next = this.from();
4648
+ }
4649
+ else if (next >= this.to()) {
4650
+ next = addDays(this.to(), -1);
4651
+ }
4652
+ this.laneFocus.set({ roomId: room.roomId, date: next });
4653
+ }
4654
+ else if (event.key === 'Enter' || event.key === ' ') {
4655
+ event.preventDefault();
4656
+ this.create.set({
4657
+ room,
4658
+ startDate: cur.date,
4659
+ startClientX: 0,
4660
+ previewStart: cur.date,
4661
+ previewEnd: addDays(cur.date, 1),
4662
+ dragging: true,
4663
+ viaKeyboard: true,
4664
+ });
4665
+ }
4666
+ }
4667
+ /** Whatever room row (if any) is actually rendered under this point — see `.occ__row--room`'s `data-room-id`. */
4668
+ roomUnderPoint(clientX, clientY) {
4669
+ const el = document.elementFromPoint(clientX, clientY);
4670
+ const rowEl = el?.closest('.occ__row--room');
4671
+ const roomId = rowEl?.dataset['roomId'];
4672
+ return roomId ? (this.roomsById().get(roomId) ?? null) : null;
4673
+ }
4674
+ armSuppressNextClick() {
4675
+ this.suppressNextClick = true;
4676
+ if (this.suppressNextClickTimer) {
4677
+ clearTimeout(this.suppressNextClickTimer);
4678
+ }
4679
+ this.suppressNextClickTimer = setTimeout(() => {
4680
+ this.suppressNextClick = false;
4681
+ this.suppressNextClickTimer = null;
4682
+ }, 0);
4683
+ }
4684
+ consumeSuppressNextClick() {
4685
+ if (!this.suppressNextClick) {
4686
+ return false;
4687
+ }
4688
+ this.suppressNextClick = false;
4689
+ if (this.suppressNextClickTimer) {
4690
+ clearTimeout(this.suppressNextClickTimer);
4691
+ this.suppressNextClickTimer = null;
4692
+ }
4693
+ return true;
4694
+ }
4695
+ clientXToDate(clientX) {
4696
+ const el = this.scroller().nativeElement;
4697
+ const rect = el.getBoundingClientRect();
4698
+ const x = clientX - rect.left + el.scrollLeft - this.leftColumnWidth();
4699
+ return dateAtOffset(x, this.from(), this.dayWidth());
4700
+ }
4701
+ /**
4702
+ * The keyboard equivalent of dragging the departure edge: Shift+ArrowRight
4703
+ * extends by a night, Shift+ArrowLeft shortens by one, each key press
4704
+ * committing immediately (there is nothing to "release" the way a mouse
4705
+ * drag has). Scoped to the departure edge only — the more common "extend a
4706
+ * stay" gesture — so one binding covers the primary case without a second
4707
+ * modifier combination to document; the arrival edge is still reachable by
4708
+ * dragging its handle with a mouse.
4709
+ */
4710
+ onBarKeydownResize(event, room, bar, laneBars) {
4711
+ if (!event.shiftKey ||
4712
+ (event.key !== 'ArrowRight' && event.key !== 'ArrowLeft')) {
4713
+ return;
4714
+ }
4715
+ event.preventDefault();
4716
+ event.stopPropagation();
4717
+ const bound = laneNeighborBound(laneBars, bar.bookingId, 'end', this.preventOverlap());
4718
+ let next = addDays(bar.endDate, event.key === 'ArrowRight' ? 1 : -1);
4719
+ if (bound && next > bound) {
4720
+ next = bound;
4721
+ }
4722
+ if (next <= bar.startDate) {
4723
+ next = addDays(bar.startDate, 1);
4724
+ }
4725
+ if (next === bar.endDate) {
4726
+ return;
4727
+ }
4728
+ this.barResize.emit({
4729
+ bar,
4730
+ room,
4731
+ edge: 'end',
4732
+ previousStartDate: bar.startDate,
4733
+ previousEndDate: bar.endDate,
4734
+ proposedStartDate: bar.startDate,
4735
+ proposedEndDate: next,
4736
+ });
4737
+ }
4738
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: OccupancyGridComponent, deps: [{ token: i1$4.TranslateService }, { token: i0.DestroyRef }], target: i0.ɵɵFactoryTarget.Component });
4739
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "19.2.19", type: OccupancyGridComponent, isStandalone: true, selector: "ud-occupancy-grid", inputs: { rooms: { classPropertyName: "rooms", publicName: "rooms", isSignal: true, isRequired: false, transformFunction: null }, dormName: { classPropertyName: "dormName", publicName: "dormName", isSignal: true, isRequired: false, transformFunction: null }, from: { classPropertyName: "from", publicName: "from", isSignal: true, isRequired: true, transformFunction: null }, to: { classPropertyName: "to", publicName: "to", isSignal: true, isRequired: true, transformFunction: null }, today: { classPropertyName: "today", publicName: "today", isSignal: true, isRequired: false, transformFunction: null }, dayWidth: { classPropertyName: "dayWidth", publicName: "dayWidth", isSignal: true, isRequired: false, transformFunction: null }, leftColumnWidth: { classPropertyName: "leftColumnWidth", publicName: "leftColumnWidth", isSignal: true, isRequired: false, transformFunction: null }, laneHeight: { classPropertyName: "laneHeight", publicName: "laneHeight", isSignal: true, isRequired: false, transformFunction: null }, loading: { classPropertyName: "loading", publicName: "loading", isSignal: true, isRequired: false, transformFunction: null }, navStepDays: { classPropertyName: "navStepDays", publicName: "navStepDays", isSignal: true, isRequired: false, transformFunction: null }, preventOverlap: { classPropertyName: "preventOverlap", publicName: "preventOverlap", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { barClick: "barClick", closureClick: "closureClick", roomClick: "roomClick", cellClick: "cellClick", reachedEnd: "reachedEnd", windowShift: "windowShift", barResize: "barResize", barMove: "barMove", barCreate: "barCreate" }, viewQueries: [{ propertyName: "scroller", first: true, predicate: ["scroller"], descendants: true, isSignal: true }], ngImport: i0, template: "<div\n class=\"occ\"\n [class.is-loading]=\"loading()\"\n [class.is-dragging-active]=\"\n resize() !== null || move()?.dragging || create()?.dragging\n \"\n [style.--dw]=\"dayWidth() + 'px'\"\n (keydown)=\"onGridKeydown($event)\">\n <div #scroller class=\"occ__scroller\" (scroll)=\"onScroll()\">\n <div\n class=\"occ__canvas\"\n [style.width.px]=\"canvasWidth()\"\n [style.height.px]=\"bodyHeight() + headerHeight\">\n <!-- Sticky two-tier header -->\n <div class=\"occ__header\" [style.height.px]=\"headerHeight\">\n <div class=\"occ__corner\" [style.width.px]=\"leftColumnWidth()\">\n <span class=\"occ__eyebrow\">{{\n 'occupancyGrid.rooms' | translate\n }}</span>\n <div class=\"occ__nav\">\n <button\n type=\"button\"\n class=\"occ__nav-btn\"\n [attr.aria-label]=\"'occupancyGrid.nav.prev' | translate\"\n [title]=\"'occupancyGrid.nav.prev' | translate\"\n (click)=\"shiftWindow(-1)\">\n \u2039\n </button>\n <button\n type=\"button\"\n class=\"occ__nav-btn\"\n [attr.aria-label]=\"'occupancyGrid.nav.next' | translate\"\n [title]=\"'occupancyGrid.nav.next' | translate\"\n (click)=\"shiftWindow(1)\">\n \u203A\n </button>\n </div>\n </div>\n <div class=\"occ__months\" [style.left.px]=\"leftColumnWidth()\">\n @for (m of months(); track m.label) {\n <div\n class=\"occ__month\"\n [style.left.px]=\"m.left\"\n [style.width.px]=\"m.width\">\n {{ m.label }}\n </div>\n }\n </div>\n <div class=\"occ__days\" [style.left.px]=\"leftColumnWidth()\">\n @for (d of days(); track d.iso) {\n <div\n class=\"occ__day\"\n [class.is-weekend]=\"d.isWeekend\"\n [class.is-today]=\"d.iso === today()\"\n [style.left.px]=\"d.left\"\n [style.width.px]=\"dayWidth()\">\n <span class=\"occ__day-num\">{{ d.dayOfMonth }}</span>\n <span class=\"occ__day-wd\">{{\n 'occupancyGrid.weekdays.' + d.weekday | translate\n }}</span>\n </div>\n }\n </div>\n </div>\n\n <!-- Today column, behind rows -->\n @if (todayLeft() !== null) {\n <div\n class=\"occ__today\"\n [style.left.px]=\"leftColumnWidth() + todayLeft()!\"\n [style.top.px]=\"headerHeight\"\n [style.width.px]=\"dayWidth()\"\n [style.height.px]=\"bodyHeight()\"></div>\n }\n\n <!-- Virtualized rows -->\n @for (p of visible(); track trackRow($index, p)) {\n @if (p.row.kind === 'group') {\n <div\n class=\"occ__row occ__row--group\"\n [attr.data-depth]=\"p.row.depth\"\n [style.top.px]=\"headerHeight + p.top\"\n [style.height.px]=\"p.height\"\n role=\"button\"\n tabindex=\"0\"\n (click)=\"toggleGroup(p.row.key)\"\n (keydown.enter)=\"toggleGroup(p.row.key)\">\n <div\n class=\"occ__cell occ__cell--sticky\"\n [style.width.px]=\"leftColumnWidth()\">\n <span\n class=\"occ__chevron\"\n [class.is-collapsed]=\"isCollapsed(p.row.key)\"\n >\u25BE</span\n >\n <span class=\"occ__eyebrow\">{{ p.row.label }}</span>\n <span class=\"occ__count\">{{ p.row.roomCount }}</span>\n </div>\n <div\n class=\"occ__lane-bg\"\n [style.left.px]=\"leftColumnWidth()\"\n [style.width.px]=\"dayCount() * dayWidth()\"\n [style.--weekend-offset]=\"weekendOffsetPx() + 'px'\"></div>\n </div>\n } @else {\n <div\n class=\"occ__row occ__row--room\"\n [class.is-inactive]=\"!asRoomRow(p.row).room.active\"\n [class.is-move-target]=\"isMoveTarget(asRoomRow(p.row).room.roomId)\"\n [attr.data-room-id]=\"asRoomRow(p.row).room.roomId\"\n [style.top.px]=\"headerHeight + p.top\"\n [style.height.px]=\"p.height\">\n <div\n class=\"occ__cell occ__cell--sticky occ__room\"\n [style.width.px]=\"leftColumnWidth()\"\n role=\"button\"\n tabindex=\"0\"\n (click)=\"roomClick.emit(asRoomRow(p.row).room)\"\n (keydown.enter)=\"roomClick.emit(asRoomRow(p.row).room)\">\n <span class=\"occ__room-number\">{{\n asRoomRow(p.row).room.number\n }}</span>\n <span class=\"occ__room-type\">{{\n asRoomRow(p.row).room.type\n }}</span>\n @if (takenOn(asRoomRow(p.row).room) !== null) {\n <span\n class=\"occ__room-occ\"\n [class.is-full]=\"\n takenOn(asRoomRow(p.row).room)! >=\n asRoomRow(p.row).room.capacity\n \">\n {{ takenOn(asRoomRow(p.row).room) }}/{{\n asRoomRow(p.row).room.capacity\n }}\n </span>\n }\n </div>\n <div\n class=\"occ__lane-bg\"\n tabindex=\"0\"\n [attr.aria-label]=\"\n 'occupancyGrid.createCell'\n | translate: { room: asRoomRow(p.row).room.number }\n \"\n [style.left.px]=\"leftColumnWidth()\"\n [style.width.px]=\"dayCount() * dayWidth()\"\n [style.--weekend-offset]=\"weekendOffsetPx() + 'px'\"\n (mousedown)=\"startCreate($event, asRoomRow(p.row).room)\"\n (click)=\"onLaneClick($event, asRoomRow(p.row).room)\"\n (mousemove)=\"onLaneMouseMove($event, asRoomRow(p.row).room)\"\n (mouseleave)=\"onLaneMouseLeave(asRoomRow(p.row).room)\"\n (focus)=\"onLaneFocus(asRoomRow(p.row).room)\"\n (blur)=\"onLaneBlur()\"\n (keydown)=\"onLaneKeydown($event, asRoomRow(p.row).room)\">\n @for (c of asRoomRow(p.row).room.closures; track c.closureId) {\n @if (closureGeometryOf(c); as g) {\n <div\n class=\"occ__closure\"\n [class.is-cut-left]=\"g.cutLeft\"\n [class.is-cut-right]=\"g.cutRight\"\n [style.left.px]=\"g.left\"\n [style.width.px]=\"g.width\"\n [title]=\"closureTitle(c)\"\n role=\"button\"\n tabindex=\"0\"\n (mousedown)=\"$event.stopPropagation()\"\n (click)=\"\n $event.stopPropagation();\n closureClick.emit({\n closure: c,\n room: asRoomRow(p.row).room,\n })\n \"\n (keydown.enter)=\"\n closureClick.emit({\n closure: c,\n room: asRoomRow(p.row).room,\n })\n \">\n <span class=\"occ__closure-label\">{{ c.reason }}</span>\n </div>\n }\n }\n @for (lb of asRoomRow(p.row).bars; track lb.bar.bookingId) {\n @if (geometryOf(lb.bar); as g) {\n <div\n class=\"occ__bar\"\n [attr.data-state]=\"lb.bar.state\"\n [class.is-cut-left]=\"g.cutLeft\"\n [class.is-cut-right]=\"g.cutRight\"\n [class.is-resizing]=\"isResizing(lb.bar.bookingId)\"\n [class.is-moving]=\"isBeingMoved(lb.bar.bookingId)\"\n [style.left.px]=\"g.left + 1\"\n [style.width.px]=\"g.width - 2\"\n [style.top.px]=\"4 + lb.lane * (laneHeight() + 4)\"\n [style.height.px]=\"laneHeight()\"\n [title]=\"barTitle(lb.bar)\"\n [attr.aria-keyshortcuts]=\"'Shift+ArrowRight Shift+ArrowLeft'\"\n role=\"button\"\n tabindex=\"0\"\n (mousedown)=\"\n startBarMove($event, asRoomRow(p.row).room, lb.bar)\n \"\n (click)=\"\n $event.stopPropagation();\n onBarClick(lb.bar, asRoomRow(p.row).room)\n \"\n (keydown.enter)=\"\n barClick.emit({\n bar: lb.bar,\n room: asRoomRow(p.row).room,\n })\n \"\n (keydown)=\"\n onBarKeydownResize(\n $event,\n asRoomRow(p.row).room,\n lb.bar,\n asRoomRow(p.row).bars\n )\n \">\n @if (!g.cutLeft) {\n <span\n class=\"occ__bar-handle occ__bar-handle--start\"\n aria-hidden=\"true\"\n (mousedown)=\"\n startResize(\n $event,\n asRoomRow(p.row).room,\n lb.bar,\n 'start',\n asRoomRow(p.row).bars\n )\n \"\n (click)=\"$event.stopPropagation()\"></span>\n }\n <span class=\"occ__bar-label\">{{ lb.bar.studentName }}</span>\n @if (!g.cutRight) {\n <span\n class=\"occ__bar-handle occ__bar-handle--end\"\n aria-hidden=\"true\"\n (mousedown)=\"\n startResize(\n $event,\n asRoomRow(p.row).room,\n lb.bar,\n 'end',\n asRoomRow(p.row).bars\n )\n \"\n (click)=\"$event.stopPropagation()\"></span>\n }\n </div>\n }\n }\n </div>\n <div class=\"occ__row-hover\" aria-hidden=\"true\"></div>\n </div>\n }\n }\n\n <!-- The floating copy of a bar being dragged by its body \u2014 see `moveGhost`. -->\n @if (moveGhost(); as g) {\n <div\n class=\"occ__bar occ__bar--ghost\"\n aria-hidden=\"true\"\n [attr.data-state]=\"g.state\"\n [style.left.px]=\"g.left\"\n [style.top.px]=\"g.top\"\n [style.width.px]=\"g.width\"\n [style.height.px]=\"g.height\">\n <span class=\"occ__bar-label\">{{ g.label }}</span>\n </div>\n }\n\n <!-- The in-progress drag-to-create's preview span \u2014 see `createGhost`. -->\n @if (createGhost(); as g) {\n <div\n class=\"occ__bar--create\"\n aria-hidden=\"true\"\n [style.left.px]=\"g.left\"\n [style.top.px]=\"g.top\"\n [style.width.px]=\"g.width\"\n [style.height.px]=\"g.height\"></div>\n }\n\n <!-- The hovered or keyboard-focused empty cell \u2014 see `laneCursorGeometry`. -->\n @if (laneCursorGeometry(); as g) {\n <div\n class=\"occ__lane-cursor\"\n aria-hidden=\"true\"\n [style.left.px]=\"g.left\"\n [style.top.px]=\"g.top\"\n [style.width.px]=\"g.width\"\n [style.height.px]=\"g.height\"></div>\n }\n\n @if (rows().length === 0 && !loading()) {\n <div class=\"occ__empty\" [style.top.px]=\"headerHeight\">\n {{ 'occupancyGrid.empty' | translate }}\n </div>\n }\n </div>\n </div>\n\n <div class=\"occ__legend\">\n @for (s of ['tentative', 'reserved', 'in_room', 'history']; track s) {\n <span class=\"occ__legend-item\"\n ><i class=\"occ__swatch\" [attr.data-state]=\"s\"></i\n >{{ 'occupancyGrid.states.' + s | translate }}</span\n >\n }\n <span class=\"occ__legend-item\"\n ><i class=\"occ__swatch occ__swatch--closed\"></i\n >{{ 'occupancyGrid.states.closed' | translate }}</span\n >\n </div>\n</div>\n", styles: ["@charset \"UTF-8\";:host{display:block;width:100%;height:var(--ud-occ-height, 640px);--ud-occ-paper: #f5f4f0;--ud-occ-surface: #ffffff;--ud-occ-ink: #1b2535;--ud-occ-muted: #6b7585;--ud-occ-rule: #ebe9e3;--ud-occ-rule-strong: #d9d5cb;--ud-occ-weekend: rgba(27, 37, 53, .035);--ud-occ-today: rgba(74, 127, 232, .1);--ud-occ-accent: #4a7fe8;--ud-occ-tentative-bg: #fff4d6;--ud-occ-tentative-rail: #d97706;--ud-occ-reserved-bg: #dbeafe;--ud-occ-reserved-rail: #1d4ed8;--ud-occ-inroom-bg: #1b2535;--ud-occ-inroom-rail: #4a7fe8;--ud-occ-inroom-ink: #f5f6f7;--ud-occ-history-bg: #ececec;--ud-occ-history-rail: #9aa1ad;--ud-occ-closed: rgba(220, 38, 38, .1);--ud-occ-closed-rail: #dc2626;--ud-occ-radius: 6px;--ud-occ-font: \"DM Sans\", system-ui, sans-serif;font-family:var(--ud-occ-font);color:var(--ud-occ-ink)}.occ{display:flex;flex-direction:column;height:100%;background:var(--ud-occ-paper);border:1px solid var(--ud-occ-rule-strong);border-radius:10px;overflow:hidden}.occ.is-loading .occ__canvas{opacity:.55}.occ.is-dragging-active{-webkit-user-select:none;user-select:none}.occ__scroller{position:relative;flex:1;min-height:0;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--ud-occ-rule-strong) transparent}.occ__scroller::-webkit-scrollbar{width:10px;height:10px}.occ__scroller::-webkit-scrollbar-track{background:transparent}.occ__scroller::-webkit-scrollbar-thumb{background-color:var(--ud-occ-rule-strong);border-radius:6px;border:2px solid var(--ud-occ-surface)}.occ__scroller::-webkit-scrollbar-thumb:hover{background-color:var(--ud-occ-muted)}.occ__canvas{position:relative}.occ__eyebrow{font-family:var(--ud-occ-font);font-weight:700;font-size:11px;letter-spacing:.09em;text-transform:uppercase;color:var(--ud-occ-muted)}.occ__header{position:sticky;top:0;z-index:4;background:var(--ud-occ-surface);border-bottom:1px solid var(--ud-occ-rule-strong);width:100%}.occ__corner{position:sticky;left:0;z-index:5;height:100%;display:flex;align-items:center;justify-content:space-between;padding:0 8px 0 12px;background:var(--ud-occ-surface);border-right:1px solid var(--ud-occ-rule-strong);box-shadow:2px 0 5px #1b25350d;box-sizing:border-box}.occ__nav{display:flex;gap:2px}.occ__nav-btn{width:22px;height:22px;display:flex;align-items:center;justify-content:center;border:1px solid var(--ud-occ-rule-strong);border-radius:var(--ud-occ-radius);background:var(--ud-occ-surface);color:var(--ud-occ-muted);font-size:14px;line-height:1;cursor:pointer;padding:0;transition:background .12s ease,color .12s ease,transform 80ms ease}.occ__nav-btn:hover{background:var(--ud-occ-weekend);color:var(--ud-occ-ink)}.occ__nav-btn:active{transform:scale(.92)}.occ__nav-btn:focus-visible{outline:2px solid var(--ud-occ-accent);outline-offset:1px}.occ__months,.occ__days{position:absolute;top:0;height:26px}.occ__days{top:26px}.occ__month{position:absolute;top:0;height:26px;line-height:26px;padding-left:8px;font-size:12px;font-weight:600;border-left:1px solid var(--ud-occ-rule-strong);box-sizing:border-box;white-space:nowrap;overflow:hidden}.occ__day{position:absolute;top:0;height:26px;display:flex;flex-direction:column;align-items:center;justify-content:center;font-variant-numeric:tabular-nums;font-size:11px;line-height:1;border-left:1px solid var(--ud-occ-rule);box-sizing:border-box}.occ__day.is-weekend{background:var(--ud-occ-weekend)}.occ__day.is-today{font-weight:700}.occ__day-num{display:inline-flex}.occ__day.is-today .occ__day-num{align-items:center;justify-content:center;width:16px;height:16px;border-radius:50%;background:var(--ud-occ-accent);color:#fff}.occ__day-wd{font-size:9px;color:var(--ud-occ-muted);margin-top:2px}.occ__today{position:absolute;z-index:1;background:var(--ud-occ-today);border-left:1px solid var(--ud-occ-accent);border-right:1px solid var(--ud-occ-accent);box-sizing:border-box;pointer-events:none}.occ__row{position:absolute;left:0;width:100%;box-sizing:border-box;border-bottom:1px solid var(--ud-occ-rule)}.occ__row--group{cursor:pointer;background:var(--ud-occ-paper);z-index:3}.occ__row--group[data-depth=\"0\"] .occ__eyebrow{color:var(--ud-occ-ink)}.occ__row--group[data-depth=\"1\"] .occ__cell--sticky{padding-left:20px}.occ__row--group[data-depth=\"2\"] .occ__cell--sticky{padding-left:32px}.occ__row--room{background:var(--ud-occ-surface);z-index:2}.occ__row--room.is-inactive .occ__room{opacity:.55}.occ__row-hover{position:absolute;inset:0;background:transparent;pointer-events:none;transition:background .1s ease}.occ__row--room:hover .occ__row-hover{background:#1b253507}.occ__cell--sticky{position:sticky;left:0;z-index:3;height:100%;display:flex;align-items:center;gap:8px;padding:0 12px;background:inherit;border-right:1px solid var(--ud-occ-rule-strong);box-shadow:2px 0 5px #1b25350a;box-sizing:border-box}.occ__chevron{display:inline-block;transition:transform .15s;font-size:12px}.occ__chevron.is-collapsed{transform:rotate(-90deg)}.occ__count{margin-left:auto;font-family:var(--ud-occ-font);font-weight:600;font-variant-numeric:tabular-nums;font-size:11px;color:var(--ud-occ-muted)}.occ__room{cursor:pointer}.occ__room-number{font-weight:600;font-size:13px}.occ__room-type{font-size:11px;color:var(--ud-occ-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.occ__room-occ{margin-left:auto;font-family:var(--ud-occ-font);font-weight:600;font-size:11px;font-variant-numeric:tabular-nums}.occ__room-occ.is-full{color:var(--ud-occ-closed-rail)}.occ__lane-bg{position:absolute;top:0;height:100%;background-image:linear-gradient(to right,var(--ud-occ-rule) 1px,transparent 1px),repeating-linear-gradient(to right,var(--ud-occ-weekend) 0 calc(var(--dw) * 2),transparent calc(var(--dw) * 2) calc(var(--dw) * 7));background-size:var(--dw) 100%,calc(var(--dw) * 7) 100%;background-position:0 0,var(--weekend-offset, 0px) 0}.occ__row--room .occ__lane-bg{cursor:pointer}.occ__bar{position:absolute;z-index:2;display:flex;align-items:center;padding:0 6px 0 8px;box-sizing:border-box;border-radius:var(--ud-occ-radius);border-left:4px solid var(--ud-occ-accent);font-size:12px;cursor:grab;overflow:hidden;white-space:nowrap;box-shadow:0 1px 2px #1b253514;transition:box-shadow .12s ease,transform .12s ease}.occ__bar:hover{box-shadow:0 3px 8px #1b25352e;transform:translateY(-1px)}.occ__bar-label{overflow:hidden;text-overflow:ellipsis}.occ__bar.is-moving{opacity:.35;cursor:grabbing}.occ__bar--ghost{z-index:6;cursor:grabbing;pointer-events:none;outline:2px dashed var(--ud-occ-accent);outline-offset:2px;box-shadow:0 8px 20px #1b253552}.occ__row--room.is-move-target .occ__lane-bg{background-color:#4a7fe814}.occ__bar--create{position:absolute;z-index:6;box-sizing:border-box;border-radius:var(--ud-occ-radius);background:#4a7fe82e;border:2px dashed var(--ud-occ-accent);pointer-events:none}.occ__lane-cursor{position:absolute;z-index:3;box-sizing:border-box;border-radius:var(--ud-occ-radius);outline:2px solid var(--ud-occ-accent);outline-offset:-2px;pointer-events:none}.occ__bar-handle{position:absolute;top:0;bottom:0;width:8px;cursor:ew-resize;opacity:0;transition:opacity .12s ease}.occ__bar-handle--start{left:0}.occ__bar-handle--end{right:0}.occ__bar:hover .occ__bar-handle,.occ__bar:focus-visible .occ__bar-handle{opacity:1}.occ__bar[data-state=in_room] .occ__bar-handle{background:#ffffff4d}.occ__bar:not([data-state=in_room]) .occ__bar-handle{background:#1b253524}.occ__bar.is-resizing{z-index:5;box-shadow:0 4px 14px #1b253547;outline:2px dashed var(--ud-occ-accent);outline-offset:2px}.occ__bar.is-resizing .occ__bar-handle{opacity:1}.occ__bar[data-state=tentative]{background:var(--ud-occ-tentative-bg);border-left-color:var(--ud-occ-tentative-rail);border-top:1px dashed var(--ud-occ-tentative-rail);border-bottom:1px dashed var(--ud-occ-tentative-rail);border-right:1px dashed var(--ud-occ-tentative-rail)}.occ__bar[data-state=reserved]{background:var(--ud-occ-reserved-bg);border-left-color:var(--ud-occ-reserved-rail)}.occ__bar[data-state=in_room]{background:var(--ud-occ-inroom-bg);border-left-color:var(--ud-occ-inroom-rail);color:var(--ud-occ-inroom-ink)}.occ__bar[data-state=history]{background:var(--ud-occ-history-bg);border-left-color:var(--ud-occ-history-rail)}.occ__bar.is-cut-left{border-top-left-radius:0;border-bottom-left-radius:0;border-left-width:0;padding-left:10px}.occ__bar.is-cut-right{border-top-right-radius:0;border-bottom-right-radius:0}.occ__bar.is-cut-left:before,.occ__bar.is-cut-right:after{content:\"\\203a\";position:absolute;top:0;bottom:0;display:flex;align-items:center;font-size:12px;opacity:.7}.occ__bar.is-cut-left:before{left:2px;content:\"\\2039\"}.occ__bar.is-cut-right:after{right:2px}.occ__closure{position:absolute;top:0;height:100%;z-index:1;box-sizing:border-box;cursor:pointer;background:repeating-linear-gradient(135deg,var(--ud-occ-closed) 0 6px,transparent 6px 12px);border-left:3px solid var(--ud-occ-closed-rail);border-right:1px solid var(--ud-occ-closed-rail);display:flex;align-items:center;padding-left:8px;font-size:11px;color:var(--ud-occ-closed-rail);overflow:hidden;white-space:nowrap}.occ__closure.is-cut-left{border-left-width:0}.occ__closure.is-cut-right{border-right-width:0}.occ__empty{position:absolute;left:0;right:0;padding:32px;text-align:center;color:var(--ud-occ-muted)}.occ__legend{display:flex;flex-wrap:wrap;align-items:center;gap:16px;padding:10px 12px;border-top:1px solid var(--ud-occ-rule-strong);background:var(--ud-occ-surface);font-size:12px;color:var(--ud-occ-muted)}.occ__legend-item{display:inline-flex;align-items:center;gap:6px}.occ__swatch{width:14px;height:10px;border-radius:2px;border-left:3px solid var(--ud-occ-accent);display:inline-block}.occ__swatch[data-state=tentative]{background:var(--ud-occ-tentative-bg);border-left-color:var(--ud-occ-tentative-rail)}.occ__swatch[data-state=reserved]{background:var(--ud-occ-reserved-bg);border-left-color:var(--ud-occ-reserved-rail)}.occ__swatch[data-state=in_room]{background:var(--ud-occ-inroom-bg);border-left-color:var(--ud-occ-inroom-rail)}.occ__swatch[data-state=history]{background:var(--ud-occ-history-bg);border-left-color:var(--ud-occ-history-rail)}.occ__swatch--closed{background:repeating-linear-gradient(135deg,var(--ud-occ-closed) 0 3px,transparent 3px 6px);border-left-color:var(--ud-occ-closed-rail)}.occ__cell--sticky:focus-visible,.occ__row--group:focus-visible,.occ__bar:focus-visible,.occ__closure:focus-visible{outline:2px solid var(--ud-occ-accent);outline-offset:-2px;z-index:6}.occ__lane-bg:focus-visible{outline:none}@media (prefers-reduced-motion: reduce){.occ__chevron,.occ__nav-btn,.occ__bar,.occ__bar-handle,.occ__row-hover{transition:none}.occ__bar:hover,.occ__nav-btn:active{transform:none}}\n"], dependencies: [{ kind: "pipe", type: TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
4740
+ }
4741
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "19.2.19", ngImport: i0, type: OccupancyGridComponent, decorators: [{
4742
+ type: Component,
4743
+ args: [{ selector: 'ud-occupancy-grid', standalone: true, imports: [TranslatePipe], changeDetection: ChangeDetectionStrategy.OnPush, template: "<div\n class=\"occ\"\n [class.is-loading]=\"loading()\"\n [class.is-dragging-active]=\"\n resize() !== null || move()?.dragging || create()?.dragging\n \"\n [style.--dw]=\"dayWidth() + 'px'\"\n (keydown)=\"onGridKeydown($event)\">\n <div #scroller class=\"occ__scroller\" (scroll)=\"onScroll()\">\n <div\n class=\"occ__canvas\"\n [style.width.px]=\"canvasWidth()\"\n [style.height.px]=\"bodyHeight() + headerHeight\">\n <!-- Sticky two-tier header -->\n <div class=\"occ__header\" [style.height.px]=\"headerHeight\">\n <div class=\"occ__corner\" [style.width.px]=\"leftColumnWidth()\">\n <span class=\"occ__eyebrow\">{{\n 'occupancyGrid.rooms' | translate\n }}</span>\n <div class=\"occ__nav\">\n <button\n type=\"button\"\n class=\"occ__nav-btn\"\n [attr.aria-label]=\"'occupancyGrid.nav.prev' | translate\"\n [title]=\"'occupancyGrid.nav.prev' | translate\"\n (click)=\"shiftWindow(-1)\">\n \u2039\n </button>\n <button\n type=\"button\"\n class=\"occ__nav-btn\"\n [attr.aria-label]=\"'occupancyGrid.nav.next' | translate\"\n [title]=\"'occupancyGrid.nav.next' | translate\"\n (click)=\"shiftWindow(1)\">\n \u203A\n </button>\n </div>\n </div>\n <div class=\"occ__months\" [style.left.px]=\"leftColumnWidth()\">\n @for (m of months(); track m.label) {\n <div\n class=\"occ__month\"\n [style.left.px]=\"m.left\"\n [style.width.px]=\"m.width\">\n {{ m.label }}\n </div>\n }\n </div>\n <div class=\"occ__days\" [style.left.px]=\"leftColumnWidth()\">\n @for (d of days(); track d.iso) {\n <div\n class=\"occ__day\"\n [class.is-weekend]=\"d.isWeekend\"\n [class.is-today]=\"d.iso === today()\"\n [style.left.px]=\"d.left\"\n [style.width.px]=\"dayWidth()\">\n <span class=\"occ__day-num\">{{ d.dayOfMonth }}</span>\n <span class=\"occ__day-wd\">{{\n 'occupancyGrid.weekdays.' + d.weekday | translate\n }}</span>\n </div>\n }\n </div>\n </div>\n\n <!-- Today column, behind rows -->\n @if (todayLeft() !== null) {\n <div\n class=\"occ__today\"\n [style.left.px]=\"leftColumnWidth() + todayLeft()!\"\n [style.top.px]=\"headerHeight\"\n [style.width.px]=\"dayWidth()\"\n [style.height.px]=\"bodyHeight()\"></div>\n }\n\n <!-- Virtualized rows -->\n @for (p of visible(); track trackRow($index, p)) {\n @if (p.row.kind === 'group') {\n <div\n class=\"occ__row occ__row--group\"\n [attr.data-depth]=\"p.row.depth\"\n [style.top.px]=\"headerHeight + p.top\"\n [style.height.px]=\"p.height\"\n role=\"button\"\n tabindex=\"0\"\n (click)=\"toggleGroup(p.row.key)\"\n (keydown.enter)=\"toggleGroup(p.row.key)\">\n <div\n class=\"occ__cell occ__cell--sticky\"\n [style.width.px]=\"leftColumnWidth()\">\n <span\n class=\"occ__chevron\"\n [class.is-collapsed]=\"isCollapsed(p.row.key)\"\n >\u25BE</span\n >\n <span class=\"occ__eyebrow\">{{ p.row.label }}</span>\n <span class=\"occ__count\">{{ p.row.roomCount }}</span>\n </div>\n <div\n class=\"occ__lane-bg\"\n [style.left.px]=\"leftColumnWidth()\"\n [style.width.px]=\"dayCount() * dayWidth()\"\n [style.--weekend-offset]=\"weekendOffsetPx() + 'px'\"></div>\n </div>\n } @else {\n <div\n class=\"occ__row occ__row--room\"\n [class.is-inactive]=\"!asRoomRow(p.row).room.active\"\n [class.is-move-target]=\"isMoveTarget(asRoomRow(p.row).room.roomId)\"\n [attr.data-room-id]=\"asRoomRow(p.row).room.roomId\"\n [style.top.px]=\"headerHeight + p.top\"\n [style.height.px]=\"p.height\">\n <div\n class=\"occ__cell occ__cell--sticky occ__room\"\n [style.width.px]=\"leftColumnWidth()\"\n role=\"button\"\n tabindex=\"0\"\n (click)=\"roomClick.emit(asRoomRow(p.row).room)\"\n (keydown.enter)=\"roomClick.emit(asRoomRow(p.row).room)\">\n <span class=\"occ__room-number\">{{\n asRoomRow(p.row).room.number\n }}</span>\n <span class=\"occ__room-type\">{{\n asRoomRow(p.row).room.type\n }}</span>\n @if (takenOn(asRoomRow(p.row).room) !== null) {\n <span\n class=\"occ__room-occ\"\n [class.is-full]=\"\n takenOn(asRoomRow(p.row).room)! >=\n asRoomRow(p.row).room.capacity\n \">\n {{ takenOn(asRoomRow(p.row).room) }}/{{\n asRoomRow(p.row).room.capacity\n }}\n </span>\n }\n </div>\n <div\n class=\"occ__lane-bg\"\n tabindex=\"0\"\n [attr.aria-label]=\"\n 'occupancyGrid.createCell'\n | translate: { room: asRoomRow(p.row).room.number }\n \"\n [style.left.px]=\"leftColumnWidth()\"\n [style.width.px]=\"dayCount() * dayWidth()\"\n [style.--weekend-offset]=\"weekendOffsetPx() + 'px'\"\n (mousedown)=\"startCreate($event, asRoomRow(p.row).room)\"\n (click)=\"onLaneClick($event, asRoomRow(p.row).room)\"\n (mousemove)=\"onLaneMouseMove($event, asRoomRow(p.row).room)\"\n (mouseleave)=\"onLaneMouseLeave(asRoomRow(p.row).room)\"\n (focus)=\"onLaneFocus(asRoomRow(p.row).room)\"\n (blur)=\"onLaneBlur()\"\n (keydown)=\"onLaneKeydown($event, asRoomRow(p.row).room)\">\n @for (c of asRoomRow(p.row).room.closures; track c.closureId) {\n @if (closureGeometryOf(c); as g) {\n <div\n class=\"occ__closure\"\n [class.is-cut-left]=\"g.cutLeft\"\n [class.is-cut-right]=\"g.cutRight\"\n [style.left.px]=\"g.left\"\n [style.width.px]=\"g.width\"\n [title]=\"closureTitle(c)\"\n role=\"button\"\n tabindex=\"0\"\n (mousedown)=\"$event.stopPropagation()\"\n (click)=\"\n $event.stopPropagation();\n closureClick.emit({\n closure: c,\n room: asRoomRow(p.row).room,\n })\n \"\n (keydown.enter)=\"\n closureClick.emit({\n closure: c,\n room: asRoomRow(p.row).room,\n })\n \">\n <span class=\"occ__closure-label\">{{ c.reason }}</span>\n </div>\n }\n }\n @for (lb of asRoomRow(p.row).bars; track lb.bar.bookingId) {\n @if (geometryOf(lb.bar); as g) {\n <div\n class=\"occ__bar\"\n [attr.data-state]=\"lb.bar.state\"\n [class.is-cut-left]=\"g.cutLeft\"\n [class.is-cut-right]=\"g.cutRight\"\n [class.is-resizing]=\"isResizing(lb.bar.bookingId)\"\n [class.is-moving]=\"isBeingMoved(lb.bar.bookingId)\"\n [style.left.px]=\"g.left + 1\"\n [style.width.px]=\"g.width - 2\"\n [style.top.px]=\"4 + lb.lane * (laneHeight() + 4)\"\n [style.height.px]=\"laneHeight()\"\n [title]=\"barTitle(lb.bar)\"\n [attr.aria-keyshortcuts]=\"'Shift+ArrowRight Shift+ArrowLeft'\"\n role=\"button\"\n tabindex=\"0\"\n (mousedown)=\"\n startBarMove($event, asRoomRow(p.row).room, lb.bar)\n \"\n (click)=\"\n $event.stopPropagation();\n onBarClick(lb.bar, asRoomRow(p.row).room)\n \"\n (keydown.enter)=\"\n barClick.emit({\n bar: lb.bar,\n room: asRoomRow(p.row).room,\n })\n \"\n (keydown)=\"\n onBarKeydownResize(\n $event,\n asRoomRow(p.row).room,\n lb.bar,\n asRoomRow(p.row).bars\n )\n \">\n @if (!g.cutLeft) {\n <span\n class=\"occ__bar-handle occ__bar-handle--start\"\n aria-hidden=\"true\"\n (mousedown)=\"\n startResize(\n $event,\n asRoomRow(p.row).room,\n lb.bar,\n 'start',\n asRoomRow(p.row).bars\n )\n \"\n (click)=\"$event.stopPropagation()\"></span>\n }\n <span class=\"occ__bar-label\">{{ lb.bar.studentName }}</span>\n @if (!g.cutRight) {\n <span\n class=\"occ__bar-handle occ__bar-handle--end\"\n aria-hidden=\"true\"\n (mousedown)=\"\n startResize(\n $event,\n asRoomRow(p.row).room,\n lb.bar,\n 'end',\n asRoomRow(p.row).bars\n )\n \"\n (click)=\"$event.stopPropagation()\"></span>\n }\n </div>\n }\n }\n </div>\n <div class=\"occ__row-hover\" aria-hidden=\"true\"></div>\n </div>\n }\n }\n\n <!-- The floating copy of a bar being dragged by its body \u2014 see `moveGhost`. -->\n @if (moveGhost(); as g) {\n <div\n class=\"occ__bar occ__bar--ghost\"\n aria-hidden=\"true\"\n [attr.data-state]=\"g.state\"\n [style.left.px]=\"g.left\"\n [style.top.px]=\"g.top\"\n [style.width.px]=\"g.width\"\n [style.height.px]=\"g.height\">\n <span class=\"occ__bar-label\">{{ g.label }}</span>\n </div>\n }\n\n <!-- The in-progress drag-to-create's preview span \u2014 see `createGhost`. -->\n @if (createGhost(); as g) {\n <div\n class=\"occ__bar--create\"\n aria-hidden=\"true\"\n [style.left.px]=\"g.left\"\n [style.top.px]=\"g.top\"\n [style.width.px]=\"g.width\"\n [style.height.px]=\"g.height\"></div>\n }\n\n <!-- The hovered or keyboard-focused empty cell \u2014 see `laneCursorGeometry`. -->\n @if (laneCursorGeometry(); as g) {\n <div\n class=\"occ__lane-cursor\"\n aria-hidden=\"true\"\n [style.left.px]=\"g.left\"\n [style.top.px]=\"g.top\"\n [style.width.px]=\"g.width\"\n [style.height.px]=\"g.height\"></div>\n }\n\n @if (rows().length === 0 && !loading()) {\n <div class=\"occ__empty\" [style.top.px]=\"headerHeight\">\n {{ 'occupancyGrid.empty' | translate }}\n </div>\n }\n </div>\n </div>\n\n <div class=\"occ__legend\">\n @for (s of ['tentative', 'reserved', 'in_room', 'history']; track s) {\n <span class=\"occ__legend-item\"\n ><i class=\"occ__swatch\" [attr.data-state]=\"s\"></i\n >{{ 'occupancyGrid.states.' + s | translate }}</span\n >\n }\n <span class=\"occ__legend-item\"\n ><i class=\"occ__swatch occ__swatch--closed\"></i\n >{{ 'occupancyGrid.states.closed' | translate }}</span\n >\n </div>\n</div>\n", styles: ["@charset \"UTF-8\";:host{display:block;width:100%;height:var(--ud-occ-height, 640px);--ud-occ-paper: #f5f4f0;--ud-occ-surface: #ffffff;--ud-occ-ink: #1b2535;--ud-occ-muted: #6b7585;--ud-occ-rule: #ebe9e3;--ud-occ-rule-strong: #d9d5cb;--ud-occ-weekend: rgba(27, 37, 53, .035);--ud-occ-today: rgba(74, 127, 232, .1);--ud-occ-accent: #4a7fe8;--ud-occ-tentative-bg: #fff4d6;--ud-occ-tentative-rail: #d97706;--ud-occ-reserved-bg: #dbeafe;--ud-occ-reserved-rail: #1d4ed8;--ud-occ-inroom-bg: #1b2535;--ud-occ-inroom-rail: #4a7fe8;--ud-occ-inroom-ink: #f5f6f7;--ud-occ-history-bg: #ececec;--ud-occ-history-rail: #9aa1ad;--ud-occ-closed: rgba(220, 38, 38, .1);--ud-occ-closed-rail: #dc2626;--ud-occ-radius: 6px;--ud-occ-font: \"DM Sans\", system-ui, sans-serif;font-family:var(--ud-occ-font);color:var(--ud-occ-ink)}.occ{display:flex;flex-direction:column;height:100%;background:var(--ud-occ-paper);border:1px solid var(--ud-occ-rule-strong);border-radius:10px;overflow:hidden}.occ.is-loading .occ__canvas{opacity:.55}.occ.is-dragging-active{-webkit-user-select:none;user-select:none}.occ__scroller{position:relative;flex:1;min-height:0;overflow:auto;scrollbar-width:thin;scrollbar-color:var(--ud-occ-rule-strong) transparent}.occ__scroller::-webkit-scrollbar{width:10px;height:10px}.occ__scroller::-webkit-scrollbar-track{background:transparent}.occ__scroller::-webkit-scrollbar-thumb{background-color:var(--ud-occ-rule-strong);border-radius:6px;border:2px solid var(--ud-occ-surface)}.occ__scroller::-webkit-scrollbar-thumb:hover{background-color:var(--ud-occ-muted)}.occ__canvas{position:relative}.occ__eyebrow{font-family:var(--ud-occ-font);font-weight:700;font-size:11px;letter-spacing:.09em;text-transform:uppercase;color:var(--ud-occ-muted)}.occ__header{position:sticky;top:0;z-index:4;background:var(--ud-occ-surface);border-bottom:1px solid var(--ud-occ-rule-strong);width:100%}.occ__corner{position:sticky;left:0;z-index:5;height:100%;display:flex;align-items:center;justify-content:space-between;padding:0 8px 0 12px;background:var(--ud-occ-surface);border-right:1px solid var(--ud-occ-rule-strong);box-shadow:2px 0 5px #1b25350d;box-sizing:border-box}.occ__nav{display:flex;gap:2px}.occ__nav-btn{width:22px;height:22px;display:flex;align-items:center;justify-content:center;border:1px solid var(--ud-occ-rule-strong);border-radius:var(--ud-occ-radius);background:var(--ud-occ-surface);color:var(--ud-occ-muted);font-size:14px;line-height:1;cursor:pointer;padding:0;transition:background .12s ease,color .12s ease,transform 80ms ease}.occ__nav-btn:hover{background:var(--ud-occ-weekend);color:var(--ud-occ-ink)}.occ__nav-btn:active{transform:scale(.92)}.occ__nav-btn:focus-visible{outline:2px solid var(--ud-occ-accent);outline-offset:1px}.occ__months,.occ__days{position:absolute;top:0;height:26px}.occ__days{top:26px}.occ__month{position:absolute;top:0;height:26px;line-height:26px;padding-left:8px;font-size:12px;font-weight:600;border-left:1px solid var(--ud-occ-rule-strong);box-sizing:border-box;white-space:nowrap;overflow:hidden}.occ__day{position:absolute;top:0;height:26px;display:flex;flex-direction:column;align-items:center;justify-content:center;font-variant-numeric:tabular-nums;font-size:11px;line-height:1;border-left:1px solid var(--ud-occ-rule);box-sizing:border-box}.occ__day.is-weekend{background:var(--ud-occ-weekend)}.occ__day.is-today{font-weight:700}.occ__day-num{display:inline-flex}.occ__day.is-today .occ__day-num{align-items:center;justify-content:center;width:16px;height:16px;border-radius:50%;background:var(--ud-occ-accent);color:#fff}.occ__day-wd{font-size:9px;color:var(--ud-occ-muted);margin-top:2px}.occ__today{position:absolute;z-index:1;background:var(--ud-occ-today);border-left:1px solid var(--ud-occ-accent);border-right:1px solid var(--ud-occ-accent);box-sizing:border-box;pointer-events:none}.occ__row{position:absolute;left:0;width:100%;box-sizing:border-box;border-bottom:1px solid var(--ud-occ-rule)}.occ__row--group{cursor:pointer;background:var(--ud-occ-paper);z-index:3}.occ__row--group[data-depth=\"0\"] .occ__eyebrow{color:var(--ud-occ-ink)}.occ__row--group[data-depth=\"1\"] .occ__cell--sticky{padding-left:20px}.occ__row--group[data-depth=\"2\"] .occ__cell--sticky{padding-left:32px}.occ__row--room{background:var(--ud-occ-surface);z-index:2}.occ__row--room.is-inactive .occ__room{opacity:.55}.occ__row-hover{position:absolute;inset:0;background:transparent;pointer-events:none;transition:background .1s ease}.occ__row--room:hover .occ__row-hover{background:#1b253507}.occ__cell--sticky{position:sticky;left:0;z-index:3;height:100%;display:flex;align-items:center;gap:8px;padding:0 12px;background:inherit;border-right:1px solid var(--ud-occ-rule-strong);box-shadow:2px 0 5px #1b25350a;box-sizing:border-box}.occ__chevron{display:inline-block;transition:transform .15s;font-size:12px}.occ__chevron.is-collapsed{transform:rotate(-90deg)}.occ__count{margin-left:auto;font-family:var(--ud-occ-font);font-weight:600;font-variant-numeric:tabular-nums;font-size:11px;color:var(--ud-occ-muted)}.occ__room{cursor:pointer}.occ__room-number{font-weight:600;font-size:13px}.occ__room-type{font-size:11px;color:var(--ud-occ-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.occ__room-occ{margin-left:auto;font-family:var(--ud-occ-font);font-weight:600;font-size:11px;font-variant-numeric:tabular-nums}.occ__room-occ.is-full{color:var(--ud-occ-closed-rail)}.occ__lane-bg{position:absolute;top:0;height:100%;background-image:linear-gradient(to right,var(--ud-occ-rule) 1px,transparent 1px),repeating-linear-gradient(to right,var(--ud-occ-weekend) 0 calc(var(--dw) * 2),transparent calc(var(--dw) * 2) calc(var(--dw) * 7));background-size:var(--dw) 100%,calc(var(--dw) * 7) 100%;background-position:0 0,var(--weekend-offset, 0px) 0}.occ__row--room .occ__lane-bg{cursor:pointer}.occ__bar{position:absolute;z-index:2;display:flex;align-items:center;padding:0 6px 0 8px;box-sizing:border-box;border-radius:var(--ud-occ-radius);border-left:4px solid var(--ud-occ-accent);font-size:12px;cursor:grab;overflow:hidden;white-space:nowrap;box-shadow:0 1px 2px #1b253514;transition:box-shadow .12s ease,transform .12s ease}.occ__bar:hover{box-shadow:0 3px 8px #1b25352e;transform:translateY(-1px)}.occ__bar-label{overflow:hidden;text-overflow:ellipsis}.occ__bar.is-moving{opacity:.35;cursor:grabbing}.occ__bar--ghost{z-index:6;cursor:grabbing;pointer-events:none;outline:2px dashed var(--ud-occ-accent);outline-offset:2px;box-shadow:0 8px 20px #1b253552}.occ__row--room.is-move-target .occ__lane-bg{background-color:#4a7fe814}.occ__bar--create{position:absolute;z-index:6;box-sizing:border-box;border-radius:var(--ud-occ-radius);background:#4a7fe82e;border:2px dashed var(--ud-occ-accent);pointer-events:none}.occ__lane-cursor{position:absolute;z-index:3;box-sizing:border-box;border-radius:var(--ud-occ-radius);outline:2px solid var(--ud-occ-accent);outline-offset:-2px;pointer-events:none}.occ__bar-handle{position:absolute;top:0;bottom:0;width:8px;cursor:ew-resize;opacity:0;transition:opacity .12s ease}.occ__bar-handle--start{left:0}.occ__bar-handle--end{right:0}.occ__bar:hover .occ__bar-handle,.occ__bar:focus-visible .occ__bar-handle{opacity:1}.occ__bar[data-state=in_room] .occ__bar-handle{background:#ffffff4d}.occ__bar:not([data-state=in_room]) .occ__bar-handle{background:#1b253524}.occ__bar.is-resizing{z-index:5;box-shadow:0 4px 14px #1b253547;outline:2px dashed var(--ud-occ-accent);outline-offset:2px}.occ__bar.is-resizing .occ__bar-handle{opacity:1}.occ__bar[data-state=tentative]{background:var(--ud-occ-tentative-bg);border-left-color:var(--ud-occ-tentative-rail);border-top:1px dashed var(--ud-occ-tentative-rail);border-bottom:1px dashed var(--ud-occ-tentative-rail);border-right:1px dashed var(--ud-occ-tentative-rail)}.occ__bar[data-state=reserved]{background:var(--ud-occ-reserved-bg);border-left-color:var(--ud-occ-reserved-rail)}.occ__bar[data-state=in_room]{background:var(--ud-occ-inroom-bg);border-left-color:var(--ud-occ-inroom-rail);color:var(--ud-occ-inroom-ink)}.occ__bar[data-state=history]{background:var(--ud-occ-history-bg);border-left-color:var(--ud-occ-history-rail)}.occ__bar.is-cut-left{border-top-left-radius:0;border-bottom-left-radius:0;border-left-width:0;padding-left:10px}.occ__bar.is-cut-right{border-top-right-radius:0;border-bottom-right-radius:0}.occ__bar.is-cut-left:before,.occ__bar.is-cut-right:after{content:\"\\203a\";position:absolute;top:0;bottom:0;display:flex;align-items:center;font-size:12px;opacity:.7}.occ__bar.is-cut-left:before{left:2px;content:\"\\2039\"}.occ__bar.is-cut-right:after{right:2px}.occ__closure{position:absolute;top:0;height:100%;z-index:1;box-sizing:border-box;cursor:pointer;background:repeating-linear-gradient(135deg,var(--ud-occ-closed) 0 6px,transparent 6px 12px);border-left:3px solid var(--ud-occ-closed-rail);border-right:1px solid var(--ud-occ-closed-rail);display:flex;align-items:center;padding-left:8px;font-size:11px;color:var(--ud-occ-closed-rail);overflow:hidden;white-space:nowrap}.occ__closure.is-cut-left{border-left-width:0}.occ__closure.is-cut-right{border-right-width:0}.occ__empty{position:absolute;left:0;right:0;padding:32px;text-align:center;color:var(--ud-occ-muted)}.occ__legend{display:flex;flex-wrap:wrap;align-items:center;gap:16px;padding:10px 12px;border-top:1px solid var(--ud-occ-rule-strong);background:var(--ud-occ-surface);font-size:12px;color:var(--ud-occ-muted)}.occ__legend-item{display:inline-flex;align-items:center;gap:6px}.occ__swatch{width:14px;height:10px;border-radius:2px;border-left:3px solid var(--ud-occ-accent);display:inline-block}.occ__swatch[data-state=tentative]{background:var(--ud-occ-tentative-bg);border-left-color:var(--ud-occ-tentative-rail)}.occ__swatch[data-state=reserved]{background:var(--ud-occ-reserved-bg);border-left-color:var(--ud-occ-reserved-rail)}.occ__swatch[data-state=in_room]{background:var(--ud-occ-inroom-bg);border-left-color:var(--ud-occ-inroom-rail)}.occ__swatch[data-state=history]{background:var(--ud-occ-history-bg);border-left-color:var(--ud-occ-history-rail)}.occ__swatch--closed{background:repeating-linear-gradient(135deg,var(--ud-occ-closed) 0 3px,transparent 3px 6px);border-left-color:var(--ud-occ-closed-rail)}.occ__cell--sticky:focus-visible,.occ__row--group:focus-visible,.occ__bar:focus-visible,.occ__closure:focus-visible{outline:2px solid var(--ud-occ-accent);outline-offset:-2px;z-index:6}.occ__lane-bg:focus-visible{outline:none}@media (prefers-reduced-motion: reduce){.occ__chevron,.occ__nav-btn,.occ__bar,.occ__bar-handle,.occ__row-hover{transition:none}.occ__bar:hover,.occ__nav-btn:active{transform:none}}\n"] }]
4744
+ }], ctorParameters: () => [{ type: i1$4.TranslateService }, { type: i0.DestroyRef }] });
4745
+
3512
4746
  class SummaryViewComponent {
3513
4747
  title = '';
3514
4748
  actions = [];
@@ -4909,6 +6143,35 @@ const en = {
4909
6143
  validPhoneNumber: 'Please enter a valid phone number.',
4910
6144
  },
4911
6145
  },
6146
+ occupancyGrid: {
6147
+ rooms: 'Rooms',
6148
+ empty: 'No rooms to show',
6149
+ closedReason: 'Closed: {{reason}}',
6150
+ createCell: 'Room {{room}}, press Enter to start a new booking',
6151
+ nav: { prev: 'Earlier', next: 'Later' },
6152
+ states: {
6153
+ tentative: 'Tentative',
6154
+ reserved: 'Reserved',
6155
+ in_room: 'In room',
6156
+ history: 'History',
6157
+ closed: 'Closed',
6158
+ },
6159
+ months: {
6160
+ jan: 'Jan',
6161
+ feb: 'Feb',
6162
+ mar: 'Mar',
6163
+ apr: 'Apr',
6164
+ may: 'May',
6165
+ jun: 'Jun',
6166
+ jul: 'Jul',
6167
+ aug: 'Aug',
6168
+ sep: 'Sep',
6169
+ oct: 'Oct',
6170
+ nov: 'Nov',
6171
+ dec: 'Dec',
6172
+ },
6173
+ weekdays: { 0: 'S', 1: 'M', 2: 'T', 3: 'W', 4: 'T', 5: 'F', 6: 'S' },
6174
+ },
4912
6175
  };
4913
6176
  const fr = {
4914
6177
  actions: {
@@ -4981,6 +6244,35 @@ const fr = {
4981
6244
  validPhoneNumber: 'Veuillez entrer un numéro de téléphone valide.',
4982
6245
  },
4983
6246
  },
6247
+ occupancyGrid: {
6248
+ rooms: 'Chambres',
6249
+ empty: 'Aucune chambre à afficher',
6250
+ closedReason: 'Fermée : {{reason}}',
6251
+ createCell: 'Chambre {{room}}, appuyez sur Entrée pour créer une réservation',
6252
+ nav: { prev: 'Plus tôt', next: 'Plus tard' },
6253
+ states: {
6254
+ tentative: 'Provisoire',
6255
+ reserved: 'Réservée',
6256
+ in_room: 'Occupée',
6257
+ history: 'Historique',
6258
+ closed: 'Fermée',
6259
+ },
6260
+ months: {
6261
+ jan: 'janv.',
6262
+ feb: 'févr.',
6263
+ mar: 'mars',
6264
+ apr: 'avr.',
6265
+ may: 'mai',
6266
+ jun: 'juin',
6267
+ jul: 'juil.',
6268
+ aug: 'août',
6269
+ sep: 'sept.',
6270
+ oct: 'oct.',
6271
+ nov: 'nov.',
6272
+ dec: 'déc.',
6273
+ },
6274
+ weekdays: { 0: 'D', 1: 'L', 2: 'M', 3: 'M', 4: 'J', 5: 'V', 6: 'S' },
6275
+ },
4984
6276
  };
4985
6277
  /** Languages the library ships strings for. */
4986
6278
  const UD_COMPONENTS_TRANSLATIONS = {
@@ -5150,5 +6442,5 @@ const generateTimeOptions = (start, end, intervalMinutes = 5) => {
5150
6442
  * Generated bundle index. Do not edit.
5151
6443
  */
5152
6444
 
5153
- export { ApplicationStatus, AutocompleteComponent, CalendarComponent, CalendarSlotColor, CapitalizePipe, CarouselComponent, ChipInputComponent, ColumnVisibilityModalComponent, CustomInputComponent, CustomSnackbarComponent, CustomTableComponent, DateInputComponent, DateOperator, DateRangeInputComponent, DynamicComponentComponent, EditViewComponent, EditViewSectionDirective, FeatureFlagKey, FileInputComponent, FilterType, IconColor, KpiComponent, KpiDataType, KpiPillType, KpiProgressBarType, KpiVariant, LoadingStatus, ModalComponent, ModalInputType, MultiSelectComponent, MultiSelectMatchMode, NumberOperator, PhoneInputComponent, PillComponent, PillToggleComponent, PluralizePipe, ProgressBarComponent, SafePipe, SingularPipe, SnackbarType, StringOperator, SummaryViewComponent, TableDisplayColumnType, TabsComponent, TelInputComponent, TextInputComponent, TextareaComponent, TimePickerComponent, ToObservablePipe, ToggleComponent, ToggleOptionComponent, TranslateWrapperService, UD_COMPONENTS_TRANSLATIONS, UdButtonComponent, UdButtonToggleComponent, UdPreviewContainerComponent, UdStepContentDirective, UdStepperComponent, capitalize, formatLocalDate, formatLocalDateTime, formatLocalDateTimeLongForm, formatLocalTime, formatLocalTimeWithMinutes, formatLocalTimeWithMinutesAmPm, formatMonthYear, formatPhoneNumber, formatStringDate, formatStringDateTime, generateTimeOptions, inListValidator, parseLocalDate, pluralize, spaceCase, udComponentsOnlyTranslateLoader, udComponentsTranslationsFor, updateArray, withLoadingState, withUdComponentsTranslations };
6445
+ export { ApplicationStatus, AutocompleteComponent, CalendarComponent, CalendarSlotColor, CapitalizePipe, CarouselComponent, ChipInputComponent, ColumnVisibilityModalComponent, CustomInputComponent, CustomSnackbarComponent, CustomTableComponent, DateInputComponent, DateOperator, DateRangeInputComponent, DynamicComponentComponent, EditViewComponent, EditViewSectionDirective, FeatureFlagKey, FileInputComponent, FilterType, GROUP_ROW_HEIGHT, IconColor, KpiComponent, KpiDataType, KpiPillType, KpiProgressBarType, KpiVariant, LoadingStatus, ModalComponent, ModalInputType, MultiSelectComponent, MultiSelectMatchMode, NumberOperator, OCCUPANCY_GRID_HEADER_HEIGHT, OccupancyGridComponent, PhoneInputComponent, PillComponent, PillToggleComponent, PluralizePipe, ProgressBarComponent, SafePipe, SingularPipe, SnackbarType, StringOperator, SummaryViewComponent, TableDisplayColumnType, TabsComponent, TelInputComponent, TextInputComponent, TextareaComponent, TimePickerComponent, ToObservablePipe, ToggleComponent, ToggleOptionComponent, TranslateWrapperService, UD_COMPONENTS_TRANSLATIONS, UdButtonComponent, UdButtonToggleComponent, UdPreviewContainerComponent, UdStepContentDirective, UdStepperComponent, addDays, assignLanes, barGeometry, buildRows, capitalize, closureGeometry, dateAtOffset, dayColumns, dayOfMonth, daysBetween, epochDay, formatLocalDate, formatLocalDateTime, formatLocalDateTimeLongForm, formatLocalTime, formatLocalTimeWithMinutes, formatLocalTimeWithMinutesAmPm, formatMonthYear, formatPhoneNumber, formatStringDate, formatStringDateTime, generateTimeOptions, inListValidator, isIsoDate, laneNeighborBound, maxIso, minIso, monthOf, monthSegments, overlapsRoom, parseLocalDate, pluralize, positionRows, rowHeight, spaceCase, takenOn, totalHeight, udComponentsOnlyTranslateLoader, udComponentsTranslationsFor, updateArray, visibleRange, weekday, weekendOffsetDays, withLoadingState, withUdComponentsTranslations, yearOf };
5154
6446
  //# sourceMappingURL=ud-components.mjs.map