@savvycal/calendar 0.8.1 → 0.9.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.
- package/README.md +28 -27
- package/dist/components/day-grid-view/DayGridView.d.ts +1 -1
- package/dist/components/day-grid-view/DayGridView.d.ts.map +1 -1
- package/dist/components/day-grid-view/DayGridView.js +170 -157
- package/dist/components/resource-grid-view/ResourceGridView.d.ts +1 -1
- package/dist/components/resource-grid-view/ResourceGridView.d.ts.map +1 -1
- package/dist/components/resource-grid-view/ResourceGridView.js +142 -129
- package/dist/components/shared/UnavailabilityOverlay.d.ts.map +1 -1
- package/dist/components/shared/UnavailabilityOverlay.js +14 -13
- package/dist/components/shared/useEffectiveHourHeight.d.ts +1 -0
- package/dist/components/shared/useEffectiveHourHeight.d.ts.map +1 -1
- package/dist/components/shared/useEffectiveHourHeight.js +27 -25
- package/dist/components/shared/useInitialScroll.d.ts +43 -0
- package/dist/components/shared/useInitialScroll.d.ts.map +1 -0
- package/dist/components/shared/useInitialScroll.js +31 -0
- package/dist/components.css +5 -2
- package/dist/types/calendar.d.ts +22 -0
- package/dist/types/calendar.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
import { jsxs as F, jsx as l } from "react/jsx-runtime";
|
|
2
|
-
import { useCallback as
|
|
3
|
-
import { cn as
|
|
4
|
-
import { generateTimeSlots as
|
|
5
|
-
import { groupByResource as
|
|
6
|
-
import { computeUnavailableBlocks as
|
|
7
|
-
import { resourceGridViewDefaults as
|
|
8
|
-
import { GridHeader as
|
|
9
|
-
import { ResourceColumn as
|
|
10
|
-
import { TimeGutter as
|
|
11
|
-
import { SlotInteractionLayer as
|
|
12
|
-
import { SelectionOverlay as
|
|
13
|
-
import { UnavailabilityOverlay as
|
|
14
|
-
import { NowIndicator as
|
|
15
|
-
import { AllDayRow as
|
|
16
|
-
import { useEffectiveHourHeight as
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
|
|
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:
|
|
28
|
+
timeAxis: S,
|
|
29
|
+
initialScrollHour: Y,
|
|
28
30
|
onEventClick: j,
|
|
29
31
|
snapDuration: L,
|
|
30
|
-
placeholderDuration:
|
|
32
|
+
placeholderDuration: _,
|
|
31
33
|
selectedRange: f,
|
|
32
|
-
onSelect:
|
|
33
|
-
onSlotClick:
|
|
34
|
-
className:
|
|
34
|
+
onSelect: m,
|
|
35
|
+
onSlotClick: C,
|
|
36
|
+
className: U,
|
|
35
37
|
classNames: N,
|
|
36
|
-
hourHeight:
|
|
37
|
-
columnMinWidth:
|
|
38
|
-
renderHeader:
|
|
38
|
+
hourHeight: Z = 60,
|
|
39
|
+
columnMinWidth: tt = 120,
|
|
40
|
+
renderHeader: et,
|
|
39
41
|
renderEvent: D,
|
|
40
|
-
selectionAppearance:
|
|
41
|
-
dragPreviewAppearance:
|
|
42
|
-
selectionRef:
|
|
43
|
-
selectionLingerMs:
|
|
42
|
+
selectionAppearance: ot,
|
|
43
|
+
dragPreviewAppearance: rt,
|
|
44
|
+
selectionRef: it,
|
|
45
|
+
selectionLingerMs: I = 0,
|
|
44
46
|
selectedEventId: B,
|
|
45
47
|
selectedEventRef: M,
|
|
46
|
-
renderCorner:
|
|
47
|
-
eventGap:
|
|
48
|
-
eventLayout:
|
|
49
|
-
stackOffset:
|
|
48
|
+
renderCorner: nt,
|
|
49
|
+
eventGap: lt,
|
|
50
|
+
eventLayout: at = "columns",
|
|
51
|
+
stackOffset: ct = 8
|
|
50
52
|
}) {
|
|
51
|
-
const
|
|
53
|
+
const c = S?.startHour ?? 0, d = S?.endHour ?? 24, $ = S?.intervalMinutes ?? 60, {
|
|
52
54
|
effectiveHourHeight: s,
|
|
53
|
-
rootRef:
|
|
55
|
+
rootRef: G,
|
|
54
56
|
headerRef: dt,
|
|
55
|
-
allDayRef:
|
|
56
|
-
gridRef:
|
|
57
|
-
headerHeight:
|
|
58
|
-
|
|
59
|
-
|
|
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 =
|
|
74
|
+
), b = P(null), h = P(null), [ft, W] = Ht(
|
|
62
75
|
null
|
|
63
76
|
);
|
|
64
|
-
|
|
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 &&
|
|
80
|
+
else if (b.current && I > 0) {
|
|
68
81
|
const t = b.current;
|
|
69
|
-
b.current = null,
|
|
70
|
-
h.current = 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 ??
|
|
75
|
-
() =>
|
|
76
|
-
[
|
|
77
|
-
), { allDayEvents:
|
|
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]),
|
|
83
|
-
() =>
|
|
84
|
-
[
|
|
85
|
-
),
|
|
86
|
-
() =>
|
|
87
|
-
|
|
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
|
-
[
|
|
95
|
-
),
|
|
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 =
|
|
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:
|
|
127
|
-
() => `Schedule for ${
|
|
139
|
+
]), { message: yt, announce: g } = Wt(), Tt = p(
|
|
140
|
+
() => `Schedule for ${St(a)}`,
|
|
128
141
|
[a]
|
|
129
|
-
),
|
|
142
|
+
), K = R(
|
|
130
143
|
(t) => {
|
|
131
|
-
if (
|
|
132
|
-
const e = [
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
], o =
|
|
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((
|
|
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
|
-
[
|
|
145
|
-
),
|
|
157
|
+
[m, j, n, r, g]
|
|
158
|
+
), wt = R(
|
|
146
159
|
(t) => {
|
|
147
160
|
if (!t) {
|
|
148
|
-
|
|
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
|
-
|
|
157
|
-
const o = [
|
|
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
|
-
[
|
|
161
|
-
),
|
|
173
|
+
[m, n, r, g]
|
|
174
|
+
), bt = R(
|
|
162
175
|
(t) => {
|
|
163
176
|
const e = r.find((o) => o.id === t.columnId);
|
|
164
|
-
e &&
|
|
177
|
+
e && C?.({
|
|
165
178
|
resource: e,
|
|
166
179
|
startTime: t.startTime,
|
|
167
180
|
endTime: t.endTime
|
|
168
181
|
});
|
|
169
182
|
},
|
|
170
|
-
[
|
|
183
|
+
[C, r]
|
|
171
184
|
);
|
|
172
|
-
|
|
173
|
-
if (!f || !
|
|
185
|
+
q(() => {
|
|
186
|
+
if (!f || !m) return;
|
|
174
187
|
const t = (e) => {
|
|
175
|
-
e.key === "Escape" &&
|
|
188
|
+
e.key === "Escape" && m(null);
|
|
176
189
|
};
|
|
177
190
|
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
178
|
-
}, [f,
|
|
179
|
-
const
|
|
180
|
-
return /* @__PURE__ */ F("div", { ref:
|
|
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:
|
|
197
|
+
ref: st,
|
|
185
198
|
className: i("grid"),
|
|
186
199
|
role: "region",
|
|
187
200
|
"aria-roledescription": "calendar",
|
|
188
|
-
"aria-label":
|
|
201
|
+
"aria-label": Tt,
|
|
189
202
|
style: {
|
|
190
203
|
display: "grid",
|
|
191
|
-
gridTemplateColumns: `max-content repeat(${r.length}, minmax(${
|
|
192
|
-
gridTemplateRows: `auto auto repeat(${
|
|
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:
|
|
214
|
+
children: nt?.({ timeZone: n, date: a })
|
|
202
215
|
}
|
|
203
216
|
),
|
|
204
217
|
r.map((t, e) => /* @__PURE__ */ l(
|
|
205
|
-
|
|
218
|
+
kt,
|
|
206
219
|
{
|
|
207
220
|
resource: t,
|
|
208
221
|
column: e + 2,
|
|
209
222
|
cls: i,
|
|
210
|
-
renderHeader:
|
|
223
|
+
renderHeader: et
|
|
211
224
|
},
|
|
212
225
|
t.id
|
|
213
226
|
)),
|
|
214
227
|
/* @__PURE__ */ l(
|
|
215
228
|
"div",
|
|
216
229
|
{
|
|
217
|
-
ref:
|
|
218
|
-
className:
|
|
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:
|
|
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:
|
|
246
|
+
top: O,
|
|
234
247
|
...e === r.length - 1 ? { borderRightWidth: 0 } : {}
|
|
235
248
|
},
|
|
236
249
|
children: /* @__PURE__ */ l(
|
|
237
|
-
|
|
250
|
+
Mt,
|
|
238
251
|
{
|
|
239
|
-
events:
|
|
252
|
+
events: pt.get(t.id) ?? [],
|
|
240
253
|
cls: i,
|
|
241
|
-
onEventClick:
|
|
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
|
-
|
|
250
|
-
|
|
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
|
-
|
|
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 =
|
|
290
|
+
const o = gt.get(t.id);
|
|
278
291
|
return o ? /* @__PURE__ */ l(
|
|
279
|
-
|
|
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
|
-
|
|
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:
|
|
297
|
-
endHour:
|
|
309
|
+
startHour: c,
|
|
310
|
+
endHour: d,
|
|
298
311
|
hourHeight: s,
|
|
299
312
|
snapDuration: L,
|
|
300
|
-
placeholderDuration:
|
|
313
|
+
placeholderDuration: _ ?? 15,
|
|
301
314
|
cls: i,
|
|
302
|
-
onSlotClick:
|
|
303
|
-
onSelect:
|
|
304
|
-
dragPreviewAppearance:
|
|
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
|
-
|
|
323
|
+
xt,
|
|
311
324
|
{
|
|
312
325
|
resource: t,
|
|
313
|
-
positionedEvents:
|
|
326
|
+
positionedEvents: ht.get(t.id) ?? [],
|
|
314
327
|
column: e + 2,
|
|
315
328
|
timeZone: n,
|
|
316
329
|
cls: i,
|
|
317
|
-
onEventClick:
|
|
330
|
+
onEventClick: K,
|
|
318
331
|
renderEvent: D,
|
|
319
|
-
eventGap:
|
|
320
|
-
eventLayout:
|
|
321
|
-
stackOffset:
|
|
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
|
-
|
|
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:
|
|
353
|
+
startHour: c,
|
|
341
354
|
hourHeight: s,
|
|
342
355
|
cls: i,
|
|
343
|
-
appearance:
|
|
344
|
-
selectionRef:
|
|
356
|
+
appearance: ot,
|
|
357
|
+
selectionRef: it,
|
|
345
358
|
renderEvent: D
|
|
346
359
|
}
|
|
347
360
|
);
|
|
348
361
|
})(),
|
|
349
362
|
/* @__PURE__ */ l(
|
|
350
|
-
|
|
363
|
+
Bt,
|
|
351
364
|
{
|
|
352
365
|
date: a,
|
|
353
366
|
timeZone: n,
|
|
354
|
-
startHour:
|
|
355
|
-
endHour:
|
|
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:
|
|
393
|
+
children: yt
|
|
381
394
|
}
|
|
382
395
|
)
|
|
383
396
|
] });
|
|
384
397
|
}
|
|
385
398
|
export {
|
|
386
|
-
|
|
399
|
+
ne as ResourceGridView
|
|
387
400
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnavailabilityOverlay.d.ts","sourceRoot":"","sources":["../../../src/components/shared/UnavailabilityOverlay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,UAAU,0BAA0B;IAClC,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,kBAAkB,KAAK,MAAM,CAAC;CAChD;AAED,eAAO,MAAM,qBAAqB,
|
|
1
|
+
{"version":3,"file":"UnavailabilityOverlay.d.ts","sourceRoot":"","sources":["../../../src/components/shared/UnavailabilityOverlay.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,UAAU,0BAA0B;IAClC,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,kBAAkB,KAAK,MAAM,CAAC;CAChD;AAED,eAAO,MAAM,qBAAqB,kEAiChC,CAAC"}
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { memo as
|
|
3
|
-
const
|
|
4
|
-
blocks:
|
|
5
|
-
column:
|
|
6
|
-
cls:
|
|
2
|
+
import { memo as o } from "react";
|
|
3
|
+
const v = o(function({
|
|
4
|
+
blocks: t,
|
|
5
|
+
column: n,
|
|
6
|
+
cls: r
|
|
7
7
|
}) {
|
|
8
|
-
return
|
|
8
|
+
return t.length === 0 ? null : /* @__PURE__ */ e(
|
|
9
9
|
"div",
|
|
10
10
|
{
|
|
11
11
|
"aria-hidden": "true",
|
|
12
12
|
style: {
|
|
13
13
|
gridRow: "3 / -1",
|
|
14
|
-
gridColumn:
|
|
14
|
+
gridColumn: n,
|
|
15
15
|
position: "relative",
|
|
16
16
|
pointerEvents: "none"
|
|
17
17
|
},
|
|
18
|
-
children:
|
|
18
|
+
children: t.map((i, a) => /* @__PURE__ */ e(
|
|
19
19
|
"div",
|
|
20
20
|
{
|
|
21
|
-
className:
|
|
21
|
+
className: r("unavailableOverlay"),
|
|
22
22
|
style: {
|
|
23
23
|
position: "absolute",
|
|
24
|
-
top:
|
|
24
|
+
top: i.top,
|
|
25
25
|
left: 0,
|
|
26
26
|
right: 0,
|
|
27
|
-
height:
|
|
27
|
+
height: i.height,
|
|
28
|
+
backgroundPosition: `0 ${-i.top}px`
|
|
28
29
|
}
|
|
29
30
|
},
|
|
30
|
-
|
|
31
|
+
a
|
|
31
32
|
))
|
|
32
33
|
}
|
|
33
34
|
);
|
|
34
35
|
});
|
|
35
36
|
export {
|
|
36
|
-
|
|
37
|
+
v as UnavailabilityOverlay
|
|
37
38
|
};
|
|
@@ -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
|
|
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
|
|
2
|
-
function
|
|
3
|
-
const
|
|
4
|
-
return
|
|
5
|
-
const
|
|
6
|
-
if (!
|
|
7
|
-
function
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
y(o);
|
|
16
|
+
const w = a.current?.offsetHeight ?? 0, E = (h - o - w) / s;
|
|
17
|
+
R(Math.max(t, E));
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
return
|
|
21
|
-
}, [t,
|
|
22
|
-
effectiveHourHeight:
|
|
23
|
-
rootRef:
|
|
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:
|
|
26
|
-
gridRef:
|
|
27
|
-
headerHeight:
|
|
26
|
+
allDayRef: a,
|
|
27
|
+
gridRef: f,
|
|
28
|
+
headerHeight: m,
|
|
29
|
+
containerHeight: b
|
|
28
30
|
};
|
|
29
31
|
}
|
|
30
32
|
export {
|
|
31
|
-
|
|
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"}
|