@savvycal/calendar 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,22 +1,23 @@
1
1
  import { jsxs as F, jsx as l } from "react/jsx-runtime";
2
- import { useCallback as H, useRef as K, useState as bt, useEffect as P, useMemo as p } from "react";
3
- import { cn as I } from "../../lib/utils.js";
4
- import { generateTimeSlots as vt, formatDateLabel as Rt, formatTimeRange as q } from "../../lib/time.js";
5
- import { groupByResource as Ht, computePositionedEvents as Ct } from "../../lib/overlap.js";
6
- import { computeUnavailableBlocks as St } from "../../lib/availability.js";
7
- import { resourceGridViewDefaults as Dt } from "./defaults.js";
8
- import { GridHeader as $t } from "./GridHeader.js";
9
- import { ResourceColumn as kt } from "./ResourceColumn.js";
10
- import { TimeGutter as xt } from "../shared/TimeGutter.js";
11
- import { SlotInteractionLayer as It } from "../shared/SlotInteractionLayer.js";
12
- import { SelectionOverlay as Et } from "../shared/SelectionOverlay.js";
13
- import { UnavailabilityOverlay as jt } from "../shared/UnavailabilityOverlay.js";
14
- import { NowIndicator as Lt } from "../shared/NowIndicator.js";
15
- import { AllDayRow as Nt } from "../shared/AllDayRow.js";
16
- import { useEffectiveHourHeight as Bt } from "../shared/useEffectiveHourHeight.js";
17
- import { useAnnouncer as Mt } from "../shared/useAnnouncer.js";
18
- import { getEventLabel as J, getClientNameLabel as Q } from "../../lib/accessibility.js";
19
- function ee({
2
+ import { useCallback as R, useRef as P, useState as Ht, useEffect as q, useMemo as p } from "react";
3
+ import { cn as x } from "../../lib/utils.js";
4
+ import { generateTimeSlots as Rt, formatDateLabel as St, formatTimeRange as J } from "../../lib/time.js";
5
+ import { groupByResource as Ct, computePositionedEvents as Dt } from "../../lib/overlap.js";
6
+ import { computeUnavailableBlocks as It } from "../../lib/availability.js";
7
+ import { resourceGridViewDefaults as $t } from "./defaults.js";
8
+ import { GridHeader as kt } from "./GridHeader.js";
9
+ import { ResourceColumn as xt } from "./ResourceColumn.js";
10
+ import { TimeGutter as Et } from "../shared/TimeGutter.js";
11
+ import { SlotInteractionLayer as jt } from "../shared/SlotInteractionLayer.js";
12
+ import { SelectionOverlay as Lt } from "../shared/SelectionOverlay.js";
13
+ import { UnavailabilityOverlay as Nt } from "../shared/UnavailabilityOverlay.js";
14
+ import { NowIndicator as Bt } from "../shared/NowIndicator.js";
15
+ import { AllDayRow as Mt } from "../shared/AllDayRow.js";
16
+ import { useEffectiveHourHeight as Gt } from "../shared/useEffectiveHourHeight.js";
17
+ import { useInitialScroll as Ot } from "../shared/useInitialScroll.js";
18
+ import { useAnnouncer as Wt } from "../shared/useAnnouncer.js";
19
+ import { getEventLabel as Q, getClientNameLabel as X } from "../../lib/accessibility.js";
20
+ function ne({
20
21
  date: a,
21
22
  timeZone: n,
22
23
  resources: r,
@@ -24,75 +25,87 @@ function ee({
24
25
  availability: y,
25
26
  unavailability: T,
26
27
  defaultUnavailable: w,
27
- timeAxis: C,
28
+ timeAxis: S,
29
+ initialScrollHour: Y,
28
30
  onEventClick: j,
29
31
  snapDuration: L,
30
- placeholderDuration: X,
32
+ placeholderDuration: _,
31
33
  selectedRange: f,
32
- onSelect: c,
33
- onSlotClick: S,
34
- className: Y,
34
+ onSelect: m,
35
+ onSlotClick: C,
36
+ className: U,
35
37
  classNames: N,
36
- hourHeight: _ = 60,
37
- columnMinWidth: U = 120,
38
- renderHeader: Z,
38
+ hourHeight: Z = 60,
39
+ columnMinWidth: tt = 120,
40
+ renderHeader: et,
39
41
  renderEvent: D,
40
- selectionAppearance: tt,
41
- dragPreviewAppearance: et,
42
- selectionRef: ot,
43
- selectionLingerMs: $ = 0,
42
+ selectionAppearance: ot,
43
+ dragPreviewAppearance: rt,
44
+ selectionRef: it,
45
+ selectionLingerMs: I = 0,
44
46
  selectedEventId: B,
45
47
  selectedEventRef: M,
46
- renderCorner: rt,
47
- eventGap: it,
48
- eventLayout: nt = "columns",
49
- stackOffset: lt = 8
48
+ renderCorner: nt,
49
+ eventGap: lt,
50
+ eventLayout: at = "columns",
51
+ stackOffset: ct = 8
50
52
  }) {
51
- const d = C?.startHour ?? 0, m = C?.endHour ?? 24, k = C?.intervalMinutes ?? 60, {
53
+ const c = S?.startHour ?? 0, d = S?.endHour ?? 24, $ = S?.intervalMinutes ?? 60, {
52
54
  effectiveHourHeight: s,
53
- rootRef: at,
55
+ rootRef: G,
54
56
  headerRef: dt,
55
- allDayRef: ct,
56
- gridRef: mt,
57
- headerHeight: G
58
- } = Bt(_, m - d), i = H(
59
- (t) => I(Dt[t], N?.[t]),
57
+ allDayRef: mt,
58
+ gridRef: st,
59
+ headerHeight: O,
60
+ containerHeight: ut
61
+ } = Gt(Z, d - c);
62
+ Ot({
63
+ rootRef: G,
64
+ initialScrollHour: Y,
65
+ startHour: c,
66
+ endHour: d,
67
+ effectiveHourHeight: s,
68
+ containerHeight: ut,
69
+ scrollKey: a.toString()
70
+ });
71
+ const i = R(
72
+ (t) => x($t[t], N?.[t]),
60
73
  [N]
61
- ), b = K(null), h = K(null), [st, O] = bt(
74
+ ), b = P(null), h = P(null), [ft, W] = Ht(
62
75
  null
63
76
  );
64
- P(() => {
77
+ q(() => {
65
78
  if (f)
66
79
  h.current !== null && (clearTimeout(h.current), h.current = null), b.current = f;
67
- else if (b.current && $ > 0) {
80
+ else if (b.current && I > 0) {
68
81
  const t = b.current;
69
- b.current = null, O(t), h.current = setTimeout(() => {
70
- h.current = null, O(null);
71
- }, $);
82
+ b.current = null, W(t), h.current = setTimeout(() => {
83
+ h.current = null, W(null);
84
+ }, I);
72
85
  }
73
- }, [f, $]);
74
- const v = f ?? st, x = p(
75
- () => vt({ startHour: d, endHour: m, intervalMinutes: k }),
76
- [d, m, k]
77
- ), { allDayEvents: W, timedEvents: A } = p(() => {
86
+ }, [f, I]);
87
+ const v = f ?? ft, k = p(
88
+ () => Rt({ startHour: c, endHour: d, intervalMinutes: $ }),
89
+ [c, d, $]
90
+ ), { allDayEvents: A, timedEvents: V } = p(() => {
78
91
  const t = [], e = [];
79
92
  for (const o of E)
80
93
  o.allDay ? t.push(o) : e.push(o);
81
94
  return { allDayEvents: t, timedEvents: e };
82
- }, [E]), ut = p(
83
- () => Ht(W),
84
- [W]
85
- ), ft = p(
86
- () => Ct(
87
- A,
95
+ }, [E]), pt = p(
96
+ () => Ct(A),
97
+ [A]
98
+ ), ht = p(
99
+ () => Dt(
100
+ V,
88
101
  n,
89
102
  a,
103
+ c,
90
104
  d,
91
- m,
92
105
  s
93
106
  ),
94
- [A, n, a, d, m, s]
95
- ), pt = p(() => {
107
+ [V, n, a, c, d, s]
108
+ ), gt = p(() => {
96
109
  if (!w && !y && !T)
97
110
  return /* @__PURE__ */ new Map();
98
111
  const t = /* @__PURE__ */ new Set([
@@ -101,13 +114,13 @@ function ee({
101
114
  ...w ? r.map((o) => o.id) : []
102
115
  ]), e = /* @__PURE__ */ new Map();
103
116
  for (const o of t) {
104
- const u = y?.[o], z = St(
117
+ const u = y?.[o], z = It(
105
118
  w && u === void 0 ? [] : u,
106
119
  T?.[o],
107
120
  n,
108
121
  a,
122
+ c,
109
123
  d,
110
- m,
111
124
  s
112
125
  );
113
126
  z.length > 0 && e.set(o, z);
@@ -120,32 +133,32 @@ function ee({
120
133
  T,
121
134
  n,
122
135
  a,
136
+ c,
123
137
  d,
124
- m,
125
138
  s
126
- ]), { message: ht, announce: g } = Mt(), gt = p(
127
- () => `Schedule for ${Rt(a)}`,
139
+ ]), { message: yt, announce: g } = Wt(), Tt = p(
140
+ () => `Schedule for ${St(a)}`,
128
141
  [a]
129
- ), V = H(
142
+ ), K = R(
130
143
  (t) => {
131
- if (c?.(null), j?.(t), t.allDay) {
132
- const e = [J(t), "all day"], o = Q(t);
144
+ if (m?.(null), j?.(t), t.allDay) {
145
+ const e = [Q(t), "all day"], o = X(t);
133
146
  o && e.push(o), g(`Selected: ${e.join(", ")}`);
134
147
  } else {
135
148
  const e = [
136
- J(t),
137
- q(t.startTime, t.endTime, n)
138
- ], o = Q(t);
149
+ Q(t),
150
+ J(t.startTime, t.endTime, n)
151
+ ], o = X(t);
139
152
  o && e.push(o);
140
- const u = r.find((R) => R.id === t.resourceId);
153
+ const u = r.find((H) => H.id === t.resourceId);
141
154
  u && e.push(u.name), g(`Selected: ${e.join(", ")}`);
142
155
  }
143
156
  },
144
- [c, j, n, r, g]
145
- ), yt = H(
157
+ [m, j, n, r, g]
158
+ ), wt = R(
146
159
  (t) => {
147
160
  if (!t) {
148
- c?.(null);
161
+ m?.(null);
149
162
  return;
150
163
  }
151
164
  const e = {
@@ -153,43 +166,43 @@ function ee({
153
166
  startTime: t.startTime,
154
167
  endTime: t.endTime
155
168
  };
156
- c?.(e);
157
- const o = [q(t.startTime, t.endTime, n)], u = r.find((R) => R.id === t.columnId);
169
+ m?.(e);
170
+ const o = [J(t.startTime, t.endTime, n)], u = r.find((H) => H.id === t.columnId);
158
171
  u && o.push(u.name), g(`Selected time: ${o.join(", ")}`);
159
172
  },
160
- [c, n, r, g]
161
- ), Tt = H(
173
+ [m, n, r, g]
174
+ ), bt = R(
162
175
  (t) => {
163
176
  const e = r.find((o) => o.id === t.columnId);
164
- e && S?.({
177
+ e && C?.({
165
178
  resource: e,
166
179
  startTime: t.startTime,
167
180
  endTime: t.endTime
168
181
  });
169
182
  },
170
- [S, r]
183
+ [C, r]
171
184
  );
172
- P(() => {
173
- if (!f || !c) return;
185
+ q(() => {
186
+ if (!f || !m) return;
174
187
  const t = (e) => {
175
- e.key === "Escape" && c(null);
188
+ e.key === "Escape" && m(null);
176
189
  };
177
190
  return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
178
- }, [f, c]);
179
- const wt = s * k / 60;
180
- return /* @__PURE__ */ F("div", { ref: at, className: I(i("root"), Y), children: [
191
+ }, [f, m]);
192
+ const vt = s * $ / 60;
193
+ return /* @__PURE__ */ F("div", { ref: G, className: x(i("root"), U), children: [
181
194
  /* @__PURE__ */ F(
182
195
  "div",
183
196
  {
184
- ref: mt,
197
+ ref: st,
185
198
  className: i("grid"),
186
199
  role: "region",
187
200
  "aria-roledescription": "calendar",
188
- "aria-label": gt,
201
+ "aria-label": Tt,
189
202
  style: {
190
203
  display: "grid",
191
- gridTemplateColumns: `max-content repeat(${r.length}, minmax(${U}px, 1fr))`,
192
- gridTemplateRows: `auto auto repeat(${x.length}, ${wt}px)`
204
+ gridTemplateColumns: `max-content repeat(${r.length}, minmax(${tt}px, 1fr))`,
205
+ gridTemplateRows: `auto auto repeat(${k.length}, ${vt}px)`
193
206
  },
194
207
  children: [
195
208
  /* @__PURE__ */ l(
@@ -198,28 +211,28 @@ function ee({
198
211
  ref: dt,
199
212
  className: i("cornerCell"),
200
213
  style: { gridRow: 1, gridColumn: 1 },
201
- children: rt?.({ timeZone: n, date: a })
214
+ children: nt?.({ timeZone: n, date: a })
202
215
  }
203
216
  ),
204
217
  r.map((t, e) => /* @__PURE__ */ l(
205
- $t,
218
+ kt,
206
219
  {
207
220
  resource: t,
208
221
  column: e + 2,
209
222
  cls: i,
210
- renderHeader: Z
223
+ renderHeader: et
211
224
  },
212
225
  t.id
213
226
  )),
214
227
  /* @__PURE__ */ l(
215
228
  "div",
216
229
  {
217
- ref: ct,
218
- className: I(i("allDayCell"), "left-0 z-30"),
230
+ ref: mt,
231
+ className: x(i("allDayCell"), "left-0 z-30"),
219
232
  style: {
220
233
  gridRow: 2,
221
234
  gridColumn: 1,
222
- top: G
235
+ top: O
223
236
  }
224
237
  }
225
238
  ),
@@ -230,15 +243,15 @@ function ee({
230
243
  style: {
231
244
  gridRow: 2,
232
245
  gridColumn: e + 2,
233
- top: G,
246
+ top: O,
234
247
  ...e === r.length - 1 ? { borderRightWidth: 0 } : {}
235
248
  },
236
249
  children: /* @__PURE__ */ l(
237
- Nt,
250
+ Mt,
238
251
  {
239
- events: ut.get(t.id) ?? [],
252
+ events: pt.get(t.id) ?? [],
240
253
  cls: i,
241
- onEventClick: V,
254
+ onEventClick: K,
242
255
  selectedEventId: B,
243
256
  selectedEventRef: M
244
257
  }
@@ -246,8 +259,8 @@ function ee({
246
259
  },
247
260
  `allday-${t.id}`
248
261
  )),
249
- x.map((t) => /* @__PURE__ */ l(
250
- xt,
262
+ k.map((t) => /* @__PURE__ */ l(
263
+ Et,
251
264
  {
252
265
  label: t.label,
253
266
  row: t.index + 3,
@@ -257,7 +270,7 @@ function ee({
257
270
  },
258
271
  t.index
259
272
  )),
260
- x.map(
273
+ k.map(
261
274
  (t) => r.map((e, o) => /* @__PURE__ */ l(
262
275
  "div",
263
276
  {
@@ -274,9 +287,9 @@ function ee({
274
287
  ))
275
288
  ),
276
289
  r.map((t, e) => {
277
- const o = pt.get(t.id);
290
+ const o = gt.get(t.id);
278
291
  return o ? /* @__PURE__ */ l(
279
- jt,
292
+ Nt,
280
293
  {
281
294
  blocks: o,
282
295
  column: e + 2,
@@ -286,39 +299,39 @@ function ee({
286
299
  ) : null;
287
300
  }),
288
301
  L != null && r.map((t, e) => /* @__PURE__ */ l(
289
- It,
302
+ jt,
290
303
  {
291
304
  columnId: t.id,
292
305
  fallbackColor: t.color,
293
306
  column: e + 2,
294
307
  date: a,
295
308
  timeZone: n,
296
- startHour: d,
297
- endHour: m,
309
+ startHour: c,
310
+ endHour: d,
298
311
  hourHeight: s,
299
312
  snapDuration: L,
300
- placeholderDuration: X ?? 15,
313
+ placeholderDuration: _ ?? 15,
301
314
  cls: i,
302
- onSlotClick: S ? Tt : void 0,
303
- onSelect: c ? yt : void 0,
304
- dragPreviewAppearance: et,
315
+ onSlotClick: C ? bt : void 0,
316
+ onSelect: m ? wt : void 0,
317
+ dragPreviewAppearance: rt,
305
318
  renderEvent: D
306
319
  },
307
320
  `slot-${t.id}`
308
321
  )),
309
322
  r.map((t, e) => /* @__PURE__ */ l(
310
- kt,
323
+ xt,
311
324
  {
312
325
  resource: t,
313
- positionedEvents: ft.get(t.id) ?? [],
326
+ positionedEvents: ht.get(t.id) ?? [],
314
327
  column: e + 2,
315
328
  timeZone: n,
316
329
  cls: i,
317
- onEventClick: V,
330
+ onEventClick: K,
318
331
  renderEvent: D,
319
- eventGap: it,
320
- eventLayout: nt,
321
- stackOffset: lt,
332
+ eventGap: lt,
333
+ eventLayout: at,
334
+ stackOffset: ct,
322
335
  selectedEventId: B,
323
336
  selectedEventRef: M
324
337
  },
@@ -329,7 +342,7 @@ function ee({
329
342
  (e) => e.id === v.resourceId
330
343
  );
331
344
  return t === -1 ? null : /* @__PURE__ */ l(
332
- Et,
345
+ Lt,
333
346
  {
334
347
  startTime: v.startTime,
335
348
  endTime: v.endTime,
@@ -337,22 +350,22 @@ function ee({
337
350
  column: t + 2,
338
351
  viewDate: a,
339
352
  timeZone: n,
340
- startHour: d,
353
+ startHour: c,
341
354
  hourHeight: s,
342
355
  cls: i,
343
- appearance: tt,
344
- selectionRef: ot,
356
+ appearance: ot,
357
+ selectionRef: it,
345
358
  renderEvent: D
346
359
  }
347
360
  );
348
361
  })(),
349
362
  /* @__PURE__ */ l(
350
- Lt,
363
+ Bt,
351
364
  {
352
365
  date: a,
353
366
  timeZone: n,
354
- startHour: d,
355
- endHour: m,
367
+ startHour: c,
368
+ endHour: d,
356
369
  hourHeight: s,
357
370
  cls: i
358
371
  }
@@ -377,11 +390,11 @@ function ee({
377
390
  whiteSpace: "nowrap",
378
391
  borderWidth: 0
379
392
  },
380
- children: ht
393
+ children: yt
381
394
  }
382
395
  )
383
396
  ] });
384
397
  }
385
398
  export {
386
- ee as ResourceGridView
399
+ ne as ResourceGridView
387
400
  };
@@ -12,5 +12,6 @@ export declare function useEffectiveHourHeight(hourHeight: number, totalHours: n
12
12
  allDayRef: import('react').RefObject<HTMLDivElement | null>;
13
13
  gridRef: import('react').RefObject<HTMLDivElement | null>;
14
14
  headerHeight: number;
15
+ containerHeight: number;
15
16
  };
16
17
  //# sourceMappingURL=useEffectiveHourHeight.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useEffectiveHourHeight.d.ts","sourceRoot":"","sources":["../../../src/components/shared/useEffectiveHourHeight.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;;;;;;;EAmD5E"}
1
+ {"version":3,"file":"useEffectiveHourHeight.d.ts","sourceRoot":"","sources":["../../../src/components/shared/useEffectiveHourHeight.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;;;;;;;;EAyD5E"}
@@ -1,32 +1,34 @@
1
- import { useRef as e, useState as H, useLayoutEffect as E } from "react";
2
- function D(t, n) {
3
- const s = e(null), c = e(null), i = e(null), a = e(null), [h, v] = H(t), [R, m] = H(0);
4
- return E(() => {
5
- const o = s.current, f = c.current, l = a.current;
6
- if (!o || !f) return;
7
- function u() {
8
- const y = o.clientHeight;
9
- let r = f.offsetHeight;
10
- if (l) {
11
- const w = getComputedStyle(l).gridTemplateRows, g = parseFloat(w);
12
- g > 0 && (r = g);
1
+ import { useRef as e, useState as r, useLayoutEffect as B } from "react";
2
+ function S(t, s) {
3
+ const i = e(null), c = e(null), a = e(null), f = e(null), [v, R] = r(t), [m, y] = r(0), [b, p] = r(0);
4
+ return B(() => {
5
+ const n = i.current, l = c.current, u = f.current;
6
+ if (!n || !l) return;
7
+ function g() {
8
+ const h = n.clientHeight;
9
+ p(h);
10
+ let o = l.offsetHeight;
11
+ if (u) {
12
+ const x = getComputedStyle(u).gridTemplateRows, d = parseFloat(x);
13
+ d > 0 && (o = d);
13
14
  }
14
- m(r);
15
- const b = i.current?.offsetHeight ?? 0, p = (y - r - b) / n;
16
- v(Math.max(t, p));
15
+ y(o);
16
+ const w = a.current?.offsetHeight ?? 0, E = (h - o - w) / s;
17
+ R(Math.max(t, E));
17
18
  }
18
- u();
19
- const d = new ResizeObserver(u);
20
- return d.observe(o), () => d.disconnect();
21
- }, [t, n]), {
22
- effectiveHourHeight: h,
23
- rootRef: s,
19
+ g();
20
+ const H = new ResizeObserver(g);
21
+ return H.observe(n), () => H.disconnect();
22
+ }, [t, s]), {
23
+ effectiveHourHeight: v,
24
+ rootRef: i,
24
25
  headerRef: c,
25
- allDayRef: i,
26
- gridRef: a,
27
- headerHeight: R
26
+ allDayRef: a,
27
+ gridRef: f,
28
+ headerHeight: m,
29
+ containerHeight: b
28
30
  };
29
31
  }
30
32
  export {
31
- D as useEffectiveHourHeight
33
+ S as useEffectiveHourHeight
32
34
  };
@@ -0,0 +1,43 @@
1
+ import { RefObject } from 'react';
2
+ interface UseInitialScrollArgs {
3
+ /** The scroll container (`classNames.root`, `overflow-auto`). */
4
+ rootRef: RefObject<HTMLDivElement | null>;
5
+ /** Hour to bring to the top of the timed area, or undefined to do nothing. */
6
+ initialScrollHour: number | undefined;
7
+ /** `timeAxis.startHour ?? 0`. */
8
+ startHour: number;
9
+ /** `timeAxis.endHour ?? 24`. */
10
+ endHour: number;
11
+ /** Resolved hour height from `useEffectiveHourHeight`. */
12
+ effectiveHourHeight: number;
13
+ /**
14
+ * Measured height of the scroll container from `useEffectiveHourHeight`. Used
15
+ * to defer the scroll until the grid is actually laid out — a hidden or
16
+ * zero-height container reports 0 and can't honor a scroll.
17
+ */
18
+ containerHeight: number;
19
+ /** Stable identity of the active date/range; a change re-applies the scroll. */
20
+ scrollKey: string;
21
+ }
22
+ /**
23
+ * Scrolls the grid so `initialScrollHour` sits at the top of the visible timed
24
+ * area on initial mount and whenever the active date/range changes.
25
+ *
26
+ * The header and all-day lane are both `position: sticky` inside the scroll
27
+ * container, so they stay pinned and don't factor into `scrollTop`:
28
+ *
29
+ * clamped = clamp(initialScrollHour, startHour, endHour)
30
+ * scrollTop = (clamped - startHour) * effectiveHourHeight
31
+ *
32
+ * It only repositions on a `scrollKey` change — not on unrelated re-renders
33
+ * (events/availability arriving, selection, hover) or a resize re-measuring
34
+ * `effectiveHourHeight` — so it never fights the user's manual scrolling.
35
+ *
36
+ * When the grid first mounts in a hidden or zero-height container (an inactive
37
+ * tab, a collapsed panel, a `display: none` modal) the scroll is deferred until
38
+ * the container is laid out: `containerHeight` goes from 0 to its measured value
39
+ * on reveal, which re-runs this effect and applies the scroll then.
40
+ */
41
+ export declare function useInitialScroll({ rootRef, initialScrollHour, startHour, endHour, effectiveHourHeight, containerHeight, scrollKey, }: UseInitialScrollArgs): void;
42
+ export {};
43
+ //# sourceMappingURL=useInitialScroll.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInitialScroll.d.ts","sourceRoot":"","sources":["../../../src/components/shared/useInitialScroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEhE,UAAU,oBAAoB;IAC5B,iEAAiE;IACjE,OAAO,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC1C,8EAA8E;IAC9E,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,mBAAmB,EACnB,eAAe,EACf,SAAS,GACV,EAAE,oBAAoB,GAAG,IAAI,CA+B7B"}
@@ -0,0 +1,31 @@
1
+ import { useRef as x, useLayoutEffect as M } from "react";
2
+ function b({
3
+ rootRef: u,
4
+ initialScrollHour: n,
5
+ startHour: t,
6
+ endHour: f,
7
+ effectiveHourHeight: m,
8
+ containerHeight: r,
9
+ scrollKey: e
10
+ }) {
11
+ const c = x(null);
12
+ M(() => {
13
+ if (n == null || !Number.isFinite(n))
14
+ return;
15
+ const s = u.current;
16
+ if (!s || r <= 0 || c.current === e) return;
17
+ const p = Math.min(Math.max(n, t), f);
18
+ s.scrollTop = (p - t) * m, c.current = e;
19
+ }, [
20
+ u,
21
+ n,
22
+ t,
23
+ f,
24
+ m,
25
+ r,
26
+ e
27
+ ]);
28
+ }
29
+ export {
30
+ b as useInitialScroll
31
+ };
@@ -108,6 +108,17 @@ export interface ResourceGridViewProps {
108
108
  unavailability?: Record<string, AvailabilityRange[]>;
109
109
  defaultUnavailable?: boolean;
110
110
  timeAxis?: TimeAxisConfig;
111
+ /**
112
+ * Hour of day (in the grid's time zone) to scroll into view on initial mount,
113
+ * and whenever the active date changes. Fractional hours are allowed
114
+ * (e.g. 6.5 = 6:30 AM). Clamped to the timeAxis range. When omitted, the grid
115
+ * keeps its current default (scrolled to the top of the timeAxis).
116
+ *
117
+ * This only sets the *initial* scroll for a given date — it does not fight the
118
+ * user's manual scrolling, and it does not re-scroll on data/prop updates
119
+ * other than a date change.
120
+ */
121
+ initialScrollHour?: number;
111
122
  onEventClick?: (event: CalendarEvent) => void;
112
123
  snapDuration?: number;
113
124
  placeholderDuration?: number;
@@ -159,6 +170,17 @@ export interface DayGridViewProps {
159
170
  unavailability?: AvailabilityRange[];
160
171
  defaultUnavailable?: boolean;
161
172
  timeAxis?: TimeAxisConfig;
173
+ /**
174
+ * Hour of day (in the grid's time zone) to scroll into view on initial mount,
175
+ * and whenever the active range changes. Fractional hours are allowed
176
+ * (e.g. 6.5 = 6:30 AM). Clamped to the timeAxis range. When omitted, the grid
177
+ * keeps its current default (scrolled to the top of the timeAxis).
178
+ *
179
+ * This only sets the *initial* scroll for a given range — it does not fight
180
+ * the user's manual scrolling, and it does not re-scroll on data/prop updates
181
+ * other than a range change.
182
+ */
183
+ initialScrollHour?: number;
162
184
  onEventClick?: (event: CalendarEvent) => void;
163
185
  snapDuration?: number;
164
186
  placeholderDuration?: number;