@savvycal/calendar 0.9.1 → 0.10.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.
Files changed (41) hide show
  1. package/README.md +60 -41
  2. package/dist/components/day-grid-view/DayColumn.d.ts +5 -1
  3. package/dist/components/day-grid-view/DayColumn.d.ts.map +1 -1
  4. package/dist/components/day-grid-view/DayColumn.js +6 -48
  5. package/dist/components/day-grid-view/DayGridView.d.ts +1 -1
  6. package/dist/components/day-grid-view/DayGridView.d.ts.map +1 -1
  7. package/dist/components/day-grid-view/DayGridView.js +168 -155
  8. package/dist/components/day-grid-view/defaults.d.ts.map +1 -1
  9. package/dist/components/day-grid-view/defaults.js +7 -1
  10. package/dist/components/resource-grid-view/ResourceColumn.d.ts +5 -1
  11. package/dist/components/resource-grid-view/ResourceColumn.d.ts.map +1 -1
  12. package/dist/components/resource-grid-view/ResourceColumn.js +8 -49
  13. package/dist/components/resource-grid-view/ResourceGridView.d.ts +1 -1
  14. package/dist/components/resource-grid-view/ResourceGridView.d.ts.map +1 -1
  15. package/dist/components/resource-grid-view/ResourceGridView.js +182 -169
  16. package/dist/components/resource-grid-view/defaults.d.ts.map +1 -1
  17. package/dist/components/resource-grid-view/defaults.js +7 -1
  18. package/dist/components/shared/EventChip.d.ts.map +1 -1
  19. package/dist/components/shared/EventChip.js +42 -42
  20. package/dist/components/shared/OverflowChip.d.ts +13 -0
  21. package/dist/components/shared/OverflowChip.d.ts.map +1 -0
  22. package/dist/components/shared/OverflowChip.js +125 -0
  23. package/dist/components/shared/SlotInteractionLayer.d.ts.map +1 -1
  24. package/dist/components/shared/SlotInteractionLayer.js +138 -125
  25. package/dist/components/shared/TimedEventLayer.d.ts +26 -0
  26. package/dist/components/shared/TimedEventLayer.d.ts.map +1 -0
  27. package/dist/components/shared/TimedEventLayer.js +83 -0
  28. package/dist/components/shared/useColumnWidth.d.ts +5 -0
  29. package/dist/components/shared/useColumnWidth.d.ts.map +1 -0
  30. package/dist/components/shared/useColumnWidth.js +17 -0
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/lib/autoScroll.d.ts +44 -0
  34. package/dist/lib/autoScroll.d.ts.map +1 -0
  35. package/dist/lib/autoScroll.js +78 -0
  36. package/dist/lib/overlap.d.ts +13 -0
  37. package/dist/lib/overlap.d.ts.map +1 -1
  38. package/dist/lib/overlap.js +216 -118
  39. package/dist/types/calendar.d.ts +56 -0
  40. package/dist/types/calendar.d.ts.map +1 -1
  41. package/package.json +1 -1
@@ -1,11 +1,11 @@
1
- import { jsx as o, jsxs as v, Fragment as I } from "react/jsx-runtime";
2
- import { memo as P } from "react";
3
- import { cn as z } from "../../lib/utils.js";
4
- import { formatEventStartTime as B, formatTimeRange as K } from "../../lib/time.js";
5
- import { getEventLabel as O, getClientNameLabel as q } from "../../lib/accessibility.js";
6
- const R = P(function({
7
- positioned: h,
8
- fallbackColor: L,
1
+ import { jsx as o, jsxs as h, Fragment as P } from "react/jsx-runtime";
2
+ import { memo as z } from "react";
3
+ import { cn as B } from "../../lib/utils.js";
4
+ import { formatEventStartTime as K, formatTimeRange as O } from "../../lib/time.js";
5
+ import { getEventLabel as q, getClientNameLabel as A } from "../../lib/accessibility.js";
6
+ const U = z(function({
7
+ positioned: c,
8
+ fallbackColor: S,
9
9
  timeZone: x,
10
10
  cls: n,
11
11
  onClick: g,
@@ -17,19 +17,19 @@ const R = P(function({
17
17
  isSelected: T,
18
18
  selectedEventRef: C
19
19
  }) {
20
- const { event: e, top: $, height: l, subColumn: s, totalSubColumns: a } = h, c = e.color ?? L;
21
- let m, d, p;
20
+ const { event: e, top: $, height: m, subColumn: s, totalSubColumns: a } = c, y = c.colSpan ?? 1, d = e.color ?? S;
21
+ let p, u, l;
22
22
  if (w === "stacked") {
23
23
  const t = (a - 1) * b;
24
- m = s > 0 ? `${s * b}px` : "0", d = t > 0 ? `calc(100% - ${t}px)` : "100%", p = s + 1;
24
+ p = s > 0 ? `${s * b}px` : "0", u = t > 0 ? `calc(100% - ${t}px)` : "100%", l = s + 1;
25
25
  } else {
26
- const t = s / a * 100, r = 1 / a * 100, y = k, F = s * y / a, f = (a - 1) * y / a;
27
- m = f ? `calc(${t}% + ${F}px)` : `${t}%`, d = f ? `calc(${r}% - ${f}px)` : `${r}%`;
26
+ const t = s / a * 100, r = y / a * 100, L = k, I = s * L / a, v = (a - y) * L / a;
27
+ p = v ? `calc(${t}% + ${I}px)` : `${t}%`, u = v ? `calc(${r}% - ${v}px)` : `${r}%`;
28
28
  }
29
- T && (p = 10);
30
- const E = l >= 36, S = l >= 52, j = e.status === "canceled";
29
+ c.overlay && (l = 8), T && (l = 20);
30
+ const E = m >= 36, j = m >= 52, D = e.status === "canceled";
31
31
  if (N) {
32
- const t = N({ event: e, position: h });
32
+ const t = N({ event: e, position: c });
33
33
  if (t)
34
34
  return /* @__PURE__ */ o(
35
35
  "div",
@@ -38,35 +38,35 @@ const R = P(function({
38
38
  style: {
39
39
  position: "absolute",
40
40
  top: $,
41
- height: l,
42
- left: m,
43
- width: d,
44
- zIndex: p,
41
+ height: m,
42
+ left: p,
43
+ width: u,
44
+ zIndex: l,
45
45
  pointerEvents: i ? "auto" : "none"
46
46
  },
47
47
  children: t
48
48
  }
49
49
  );
50
50
  }
51
- const u = B(e.startTime, x), D = i ? (() => {
51
+ const f = K(e.startTime, x), F = i ? (() => {
52
52
  const t = [
53
- O(e),
54
- K(e.startTime, e.endTime, x)
55
- ], r = q(e);
53
+ q(e),
54
+ O(e.startTime, e.endTime, x)
55
+ ], r = A(e);
56
56
  return r && t.push(r), e.status === "canceled" ? t.push("canceled") : e.status === "tentative" && t.push("tentative"), t.join(", ");
57
57
  })() : void 0;
58
- return /* @__PURE__ */ v(
58
+ return /* @__PURE__ */ h(
59
59
  "div",
60
60
  {
61
61
  ref: C,
62
- ...i ? { role: "button", tabIndex: 0, "aria-label": D } : {},
63
- className: z(n("event"), T && n("eventSelected")),
62
+ ...i ? { role: "button", tabIndex: 0, "aria-label": F } : {},
63
+ className: B(n("event"), T && n("eventSelected")),
64
64
  style: {
65
65
  top: $,
66
- height: l,
67
- left: m,
68
- width: d,
69
- zIndex: p,
66
+ height: m,
67
+ left: p,
68
+ width: u,
69
+ zIndex: l,
70
70
  pointerEvents: i ? "auto" : "none"
71
71
  },
72
72
  ...i ? {
@@ -76,41 +76,41 @@ const R = P(function({
76
76
  }
77
77
  } : {},
78
78
  children: [
79
- c && /* @__PURE__ */ o(
79
+ d && /* @__PURE__ */ o(
80
80
  "div",
81
81
  {
82
82
  className: n("eventColorBar"),
83
83
  style: e.status === "tentative" ? {
84
84
  backgroundImage: `repeating-linear-gradient(
85
85
  -45deg,
86
- ${c},
87
- ${c} 3px,
86
+ ${d},
87
+ ${d} 3px,
88
88
  transparent 3px,
89
89
  transparent 6px
90
90
  )`
91
- } : { backgroundColor: c }
91
+ } : { backgroundColor: d }
92
92
  }
93
93
  ),
94
94
  /* @__PURE__ */ o(
95
95
  "div",
96
96
  {
97
97
  className: n("eventTitle"),
98
- style: j ? { textDecoration: "line-through" } : void 0,
98
+ style: D ? { textDecoration: "line-through" } : void 0,
99
99
  children: e.title
100
100
  }
101
101
  ),
102
- E && (S ? /* @__PURE__ */ v(I, { children: [
103
- /* @__PURE__ */ o("div", { className: n("eventTime"), children: u }),
102
+ E && (j ? /* @__PURE__ */ h(P, { children: [
103
+ /* @__PURE__ */ o("div", { className: n("eventTime"), children: f }),
104
104
  e.clientName && /* @__PURE__ */ o("div", { className: n("eventClientName"), children: e.clientName })
105
- ] }) : e.clientName ? /* @__PURE__ */ v("div", { className: n("eventTime"), children: [
106
- u,
105
+ ] }) : e.clientName ? /* @__PURE__ */ h("div", { className: n("eventTime"), children: [
106
+ f,
107
107
  ", ",
108
108
  e.clientName
109
- ] }) : /* @__PURE__ */ o("div", { className: n("eventTime"), children: u }))
109
+ ] }) : /* @__PURE__ */ o("div", { className: n("eventTime"), children: f }))
110
110
  ]
111
111
  }
112
112
  );
113
113
  });
114
114
  export {
115
- R as EventChip
115
+ U as EventChip
116
116
  };
@@ -0,0 +1,13 @@
1
+ import { CalendarEvent, GridViewClassNames, OverflowClickInfo, OverflowPopoverRenderProps } from '../../types/calendar';
2
+ import { OverflowGroup } from '../../lib/overlap';
3
+ interface OverflowChipProps {
4
+ group: OverflowGroup;
5
+ timeZone: string;
6
+ cls: (key: keyof GridViewClassNames) => string;
7
+ onEventClick?: (event: CalendarEvent) => void;
8
+ onOverflowClick?: (info: OverflowClickInfo) => void;
9
+ renderOverflowPopover?: (props: OverflowPopoverRenderProps) => React.ReactNode;
10
+ }
11
+ export declare function OverflowChip({ group, timeZone, cls, onEventClick, onOverflowClick, renderOverflowPopover, }: OverflowChipProps): import("react/jsx-runtime").JSX.Element;
12
+ export {};
13
+ //# sourceMappingURL=OverflowChip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OverflowChip.d.ts","sourceRoot":"","sources":["../../../src/components/shared/OverflowChip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,EAE3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAInD,UAAU,iBAAiB;IACzB,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,kBAAkB,KAAK,MAAM,CAAC;IAC/C,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACpD,qBAAqB,CAAC,EAAE,CACtB,KAAK,EAAE,0BAA0B,KAC9B,KAAK,CAAC,SAAS,CAAC;CACtB;AAID,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,GAAG,EACH,YAAY,EACZ,eAAe,EACf,qBAAqB,GACtB,EAAE,iBAAiB,2CAqInB"}
@@ -0,0 +1,125 @@
1
+ import { jsx as a, jsxs as x, Fragment as R } from "react/jsx-runtime";
2
+ import { useState as g, useRef as L, useLayoutEffect as k, useEffect as O } from "react";
3
+ import { createPortal as z } from "react-dom";
4
+ import { formatTimeRange as H } from "../../lib/time.js";
5
+ import { getEventLabel as I } from "../../lib/accessibility.js";
6
+ const P = 256;
7
+ function F({
8
+ group: o,
9
+ timeZone: v,
10
+ cls: t,
11
+ onEventClick: f,
12
+ onOverflowClick: r,
13
+ renderOverflowPopover: y
14
+ }) {
15
+ const [n, u] = g(!1), l = L(null), w = L(null), [h, C] = g({ top: 0, left: 0 }), c = o.events.length, T = `+${c}`, E = `${c} more event${c === 1 ? "" : "s"}`, p = () => u(!1);
16
+ k(() => {
17
+ if (!n) return;
18
+ const e = () => {
19
+ const i = l.current?.getBoundingClientRect();
20
+ if (!i) return;
21
+ let s = i.right + 8;
22
+ s + P > window.innerWidth - 8 && (s = Math.max(8, i.left - P - 8));
23
+ const d = Math.min(320, 16 + c * 52);
24
+ let m = i.top;
25
+ m + d > window.innerHeight - 8 && (m = Math.max(8, window.innerHeight - d - 8)), C({ top: m, left: s });
26
+ };
27
+ return e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
28
+ window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
29
+ };
30
+ }, [n, c]), O(() => {
31
+ if (!n) return;
32
+ const e = (s) => {
33
+ s.key === "Escape" && p();
34
+ }, i = (s) => {
35
+ const d = s.target;
36
+ l.current?.contains(d) || w.current?.contains(d) || p();
37
+ };
38
+ return document.addEventListener("keydown", e), document.addEventListener("pointerdown", i), () => {
39
+ document.removeEventListener("keydown", e), document.removeEventListener("pointerdown", i);
40
+ };
41
+ }, [n]);
42
+ const N = () => {
43
+ const e = !n;
44
+ u(e), e && l.current && r?.({
45
+ events: o.events,
46
+ anchor: l.current
47
+ });
48
+ }, b = n ? y?.({
49
+ events: o.events,
50
+ onClose: p,
51
+ onEventClick: f
52
+ }) ?? /* @__PURE__ */ a(
53
+ M,
54
+ {
55
+ events: o.events,
56
+ timeZone: v,
57
+ cls: t,
58
+ onEventClick: (e) => {
59
+ f?.(e), p();
60
+ }
61
+ }
62
+ ) : null;
63
+ return /* @__PURE__ */ x(R, { children: [
64
+ /* @__PURE__ */ a(
65
+ "button",
66
+ {
67
+ ref: l,
68
+ type: "button",
69
+ className: t("overflowChip"),
70
+ style: {
71
+ top: o.top,
72
+ zIndex: 25,
73
+ pointerEvents: "auto"
74
+ },
75
+ "aria-label": E,
76
+ "aria-expanded": n,
77
+ "aria-haspopup": "dialog",
78
+ onClick: N,
79
+ children: /* @__PURE__ */ a("span", { className: t("overflowChipLabel"), children: T })
80
+ }
81
+ ),
82
+ n && b && z(
83
+ /* @__PURE__ */ a(
84
+ "div",
85
+ {
86
+ ref: w,
87
+ role: "dialog",
88
+ "aria-label": E,
89
+ className: t("overflowPopover"),
90
+ style: {
91
+ position: "fixed",
92
+ top: h.top,
93
+ left: h.left,
94
+ zIndex: 50
95
+ },
96
+ children: b
97
+ }
98
+ ),
99
+ document.body
100
+ )
101
+ ] });
102
+ }
103
+ function M({
104
+ events: o,
105
+ timeZone: v,
106
+ cls: t,
107
+ onEventClick: f
108
+ }) {
109
+ return /* @__PURE__ */ a("div", { children: o.map((r) => /* @__PURE__ */ x(
110
+ "button",
111
+ {
112
+ type: "button",
113
+ className: t("overflowPopoverEvent"),
114
+ onClick: () => f?.(r),
115
+ children: [
116
+ /* @__PURE__ */ a("div", { className: t("overflowPopoverTitle"), children: I(r) }),
117
+ /* @__PURE__ */ a("div", { className: t("overflowPopoverTime"), children: H(r.startTime, r.endTime, v) })
118
+ ]
119
+ },
120
+ r.id
121
+ )) });
122
+ }
123
+ export {
124
+ F as OverflowChip
125
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"SlotInteractionLayer.d.ts","sourceRoot":"","sources":["../../../src/components/shared/SlotInteract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,oBAAoB,iEA6V/B,CAAC"}
@@ -1,206 +1,219 @@
1
- import { jsxs as ot, jsx as b } from "react/jsx-runtime";
2
- import { memo as st, useState as Q, useRef as o, useCallback as d, useLayoutEffect as it, useEffect as ut } from "react";
3
- import { buildSyntheticEvent as ct } from "../../lib/selection.js";
4
- import { EventChip as at } from "./EventChip.js";
5
- function R(H, m, T) {
6
- const h = Math.floor(m / 60), i = m % 60;
7
- return h >= 24 ? H.add({ days: Math.floor(h / 24) }).toPlainDateTime({ hour: h % 24, minute: i }).toZonedDateTime(T) : H.toPlainDateTime({ hour: h, minute: i }).toZonedDateTime(T);
1
+ import { jsxs as lt, jsx as B } from "react/jsx-runtime";
2
+ import { memo as at, useState as X, useRef as e, useCallback as l, useLayoutEffect as ft, useEffect as dt } from "react";
3
+ import { computeAutoScrollIntensity as mt, findVerticalScrollParent as Mt, createVerticalAutoScroller as ht } from "../../lib/autoScroll.js";
4
+ import { buildSyntheticEvent as gt } from "../../lib/selection.js";
5
+ import { EventChip as vt } from "./EventChip.js";
6
+ function S(w, M, L) {
7
+ const h = Math.floor(M / 60), s = M % 60;
8
+ return h >= 24 ? w.add({ days: Math.floor(h / 24) }).toPlainDateTime({ hour: h % 24, minute: s }).toZonedDateTime(L) : w.toPlainDateTime({ hour: h, minute: s }).toZonedDateTime(L);
8
9
  }
9
- const ht = st(function({
10
- columnId: m,
11
- fallbackColor: T,
10
+ const Ct = at(function({
11
+ columnId: M,
12
+ fallbackColor: L,
12
13
  column: h,
13
- date: i,
14
+ date: s,
14
15
  timeZone: a,
15
- startHour: V,
16
- endHour: W,
17
- hourHeight: X,
18
- snapDuration: S,
19
- placeholderDuration: c,
20
- cls: L,
16
+ startHour: _,
17
+ endHour: $,
18
+ hourHeight: Z,
19
+ snapDuration: y,
20
+ placeholderDuration: i,
21
+ cls: Y,
21
22
  onSlotClick: x,
22
- onSelect: M,
23
- dragPreviewAppearance: k = "highlight",
24
- renderEvent: _
23
+ onSelect: g,
24
+ dragPreviewAppearance: q = "highlight",
25
+ renderEvent: tt
25
26
  }) {
26
- const [w, q] = Q(null), [u, B] = Q(null), y = o(null), v = o(null), D = o(!1), z = o(M), G = o(m), O = o(i), P = o(a), g = V * 60, C = W * 60, l = X / 60, f = d(
27
+ const [H, z] = X(null), [u, O] = X(null), C = e(null), v = e(null), F = e(!1), P = e(0), b = e(null), p = e(null), G = e(() => {
28
+ }), J = e(g), K = e(M), N = e(s), j = e(a), R = _ * 60, D = $ * 60, f = Z / 60, d = l(
27
29
  (n) => {
28
- const t = n / l, r = Math.floor(t / S) * S, e = g + r;
29
- return e + c > C || e < g ? null : e;
30
+ const t = n / f, r = Math.floor(t / y) * y, o = R + r;
31
+ return o + i > D || o < R ? null : o;
30
32
  },
31
33
  [
32
- l,
33
- S,
34
- c,
35
- g,
36
- C
34
+ f,
35
+ y,
36
+ i,
37
+ R,
38
+ D
37
39
  ]
38
- ), J = o(f), Y = o(C), $ = o(S), N = o(c), K = d((n, t) => {
39
- const r = Math.min(n, t), e = Math.min(
40
- Math.max(n, t) + N.current,
41
- Y.current
40
+ ), Q = e(d), I = e(D), nt = e(y), U = e(i), W = l((n, t) => {
41
+ const r = Math.min(n, t), o = Math.min(
42
+ Math.max(n, t) + U.current,
43
+ I.current
42
44
  );
43
- return { startMin: r, endMin: e };
44
- }, []), p = d(
45
+ return { startMin: r, endMin: o };
46
+ }, []), V = l(
45
47
  (n) => {
46
- const t = v.current, r = y.current;
48
+ const t = v.current, r = C.current;
47
49
  if (!t || !r) return;
48
- const e = r.getBoundingClientRect(), s = e.height, E = Math.max(
49
- 0,
50
- Math.min(n.clientY - e.top, s)
51
- );
52
- let F = J.current(E);
53
- F == null && (F = Y.current - N.current);
54
- const I = K(t.anchorSlotStart, F);
55
- t.currentStartMin = I.startMin, t.currentEndMin = I.endMin, t.moved = !0, B(I);
50
+ const o = r.getBoundingClientRect(), c = Math.max(0, Math.min(n - o.top, o.height));
51
+ let m = Q.current(c);
52
+ m == null && (m = I.current - U.current);
53
+ const T = W(t.anchorSlotStart, m), it = t.moved && t.currentStartMin === T.startMin && t.currentEndMin === T.endMin;
54
+ t.currentStartMin = T.startMin, t.currentEndMin = T.endMin, t.moved = !0, it || O(T);
56
55
  },
57
- [K]
58
- ), j = o(() => {
59
- }), U = d(() => {
56
+ [W]
57
+ ), E = l(
58
+ (n) => {
59
+ P.current = n.clientY, V(n.clientY);
60
+ const t = b.current;
61
+ if (!t) return;
62
+ const r = t.getBoundingClientRect();
63
+ mt(n.clientY, r.top, r.bottom) !== 0 && p.current?.ensure();
64
+ },
65
+ [V]
66
+ ), A = e(() => {
67
+ }), k = l(() => {
68
+ p.current?.stop(), p.current = null, b.current = null;
60
69
  const n = v.current;
61
- n && (n.moved && (D.current = !0), z.current?.({
62
- columnId: G.current,
63
- startTime: R(
64
- O.current,
70
+ n && (n.moved && (F.current = !0), J.current?.({
71
+ columnId: K.current,
72
+ startTime: S(
73
+ N.current,
65
74
  n.currentStartMin,
66
- P.current
75
+ j.current
67
76
  ),
68
- endTime: R(
69
- O.current,
77
+ endTime: S(
78
+ N.current,
70
79
  n.currentEndMin,
71
- P.current
80
+ j.current
72
81
  )
73
- })), v.current = null, B(null), document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", j.current);
74
- }, [p]);
75
- it(() => {
76
- z.current = M, G.current = m, O.current = i, P.current = a, J.current = f, Y.current = C, $.current = S, N.current = c, j.current = U;
77
- }), ut(() => () => {
78
- document.removeEventListener("mousemove", p), document.removeEventListener("mouseup", j.current);
79
- }, [p]);
80
- const A = d(
82
+ })), v.current = null, O(null), document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", A.current);
83
+ }, [E]);
84
+ ft(() => {
85
+ J.current = g, K.current = M, N.current = s, j.current = a, Q.current = d, I.current = D, nt.current = y, U.current = i, A.current = k, G.current = V;
86
+ }), dt(() => () => {
87
+ p.current?.stop(), document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", A.current);
88
+ }, [E]);
89
+ const et = l(
81
90
  (n) => {
82
- if (!M) return;
83
- const t = y.current;
91
+ if (!g) return;
92
+ const t = C.current;
84
93
  if (!t) return;
85
- const r = t.getBoundingClientRect(), e = n.clientY - r.top, s = f(e);
86
- if (s == null) return;
87
- n.preventDefault(), M(null);
88
- const E = s + c;
94
+ const r = t.getBoundingClientRect(), o = n.clientY - r.top, c = d(o);
95
+ if (c == null) return;
96
+ n.preventDefault(), g(null);
97
+ const m = c + i;
89
98
  v.current = {
90
- anchorSlotStart: s,
91
- currentStartMin: s,
92
- currentEndMin: E,
99
+ anchorSlotStart: c,
100
+ currentStartMin: c,
101
+ currentEndMin: m,
93
102
  moved: !1
94
- }, B({ startMin: s, endMin: E }), document.addEventListener("mousemove", p), document.addEventListener("mouseup", U);
103
+ }, P.current = n.clientY, b.current = Mt(t), p.current?.stop(), p.current = ht({
104
+ getPointerY: () => P.current,
105
+ getScrollParent: () => b.current,
106
+ onScroll: () => G.current(P.current)
107
+ }), O({ startMin: c, endMin: m }), document.addEventListener("mousemove", E), document.addEventListener("mouseup", k);
95
108
  },
96
109
  [
97
- M,
98
- f,
99
- c,
100
- p,
101
- U
110
+ g,
111
+ d,
112
+ i,
113
+ E,
114
+ k
102
115
  ]
103
- ), Z = d(
116
+ ), rt = l(
104
117
  (n) => {
105
118
  if (v.current) return;
106
- const t = y.current;
119
+ const t = C.current;
107
120
  if (!t) return;
108
- const r = t.getBoundingClientRect(), e = n.clientY - r.top;
109
- q(f(e));
121
+ const r = t.getBoundingClientRect(), o = n.clientY - r.top;
122
+ z(d(o));
110
123
  },
111
- [f]
112
- ), tt = d(() => {
113
- v.current || q(null);
114
- }, []), nt = d(
124
+ [d]
125
+ ), ot = l(() => {
126
+ v.current || z(null);
127
+ }, []), ct = l(
115
128
  (n) => {
116
- if (D.current) {
117
- D.current = !1;
129
+ if (F.current) {
130
+ F.current = !1;
118
131
  return;
119
132
  }
120
- const t = y.current;
133
+ const t = C.current;
121
134
  if (!t) return;
122
- const r = t.getBoundingClientRect(), e = n.clientY - r.top, s = f(e);
123
- if (s == null) return;
124
- const E = s + c;
135
+ const r = t.getBoundingClientRect(), o = n.clientY - r.top, c = d(o);
136
+ if (c == null) return;
137
+ const m = c + i;
125
138
  x && x({
126
- columnId: m,
127
- startTime: R(i, s, a),
128
- endTime: R(i, E, a)
139
+ columnId: M,
140
+ startTime: S(s, c, a),
141
+ endTime: S(s, m, a)
129
142
  });
130
143
  },
131
- [x, f, c, m, i, a]
132
- ), et = w != null ? (w - g) * l : 0, rt = c * l;
133
- return /* @__PURE__ */ ot(
144
+ [x, d, i, M, s, a]
145
+ ), st = H != null ? (H - R) * f : 0, ut = i * f;
146
+ return /* @__PURE__ */ lt(
134
147
  "div",
135
148
  {
136
- ref: y,
149
+ ref: C,
137
150
  style: {
138
151
  gridRow: "3 / -1",
139
152
  gridColumn: h,
140
153
  position: "relative",
141
154
  pointerEvents: "auto",
142
- cursor: x || M ? "pointer" : void 0
155
+ cursor: x || g ? "pointer" : void 0
143
156
  },
144
- onMouseDown: A,
145
- onMouseMove: Z,
146
- onMouseLeave: tt,
147
- onClick: nt,
157
+ onMouseDown: et,
158
+ onMouseMove: rt,
159
+ onMouseLeave: ot,
160
+ onClick: ct,
148
161
  children: [
149
- w != null && !u && /* @__PURE__ */ b(
162
+ H != null && !u && /* @__PURE__ */ B(
150
163
  "div",
151
164
  {
152
165
  "aria-hidden": "true",
153
- className: L("slotHighlight"),
166
+ className: Y("slotHighlight"),
154
167
  style: {
155
168
  position: "absolute",
156
- top: et,
169
+ top: st,
157
170
  left: 0,
158
171
  right: 0,
159
- height: rt,
172
+ height: ut,
160
173
  pointerEvents: "none"
161
174
  }
162
175
  }
163
176
  ),
164
- u && (k !== "highlight" ? /* @__PURE__ */ b(
177
+ u && (q !== "highlight" ? /* @__PURE__ */ B(
165
178
  "div",
166
179
  {
167
180
  "aria-hidden": "true",
168
- className: L("eventColumn"),
181
+ className: Y("eventColumn"),
169
182
  style: { pointerEvents: "none" },
170
- children: /* @__PURE__ */ b(
171
- at,
183
+ children: /* @__PURE__ */ B(
184
+ vt,
172
185
  {
173
186
  interactive: !1,
174
187
  positioned: {
175
- event: ct(
188
+ event: gt(
176
189
  "",
177
- R(i, u.startMin, a),
178
- R(i, u.endMin, a),
179
- k.eventData
190
+ S(s, u.startMin, a),
191
+ S(s, u.endMin, a),
192
+ q.eventData
180
193
  ),
181
- top: (u.startMin - g) * l,
182
- height: (u.endMin - u.startMin) * l,
194
+ top: (u.startMin - R) * f,
195
+ height: (u.endMin - u.startMin) * f,
183
196
  subColumn: 0,
184
197
  totalSubColumns: 1
185
198
  },
186
- fallbackColor: T,
199
+ fallbackColor: L,
187
200
  timeZone: a,
188
- cls: L,
189
- renderEvent: _
201
+ cls: Y,
202
+ renderEvent: tt
190
203
  }
191
204
  )
192
205
  }
193
- ) : /* @__PURE__ */ b(
206
+ ) : /* @__PURE__ */ B(
194
207
  "div",
195
208
  {
196
209
  "aria-hidden": "true",
197
- className: L("selectionHighlight"),
210
+ className: Y("selectionHighlight"),
198
211
  style: {
199
212
  position: "absolute",
200
- top: (u.startMin - g) * l,
213
+ top: (u.startMin - R) * f,
201
214
  left: 0,
202
215
  right: 0,
203
- height: (u.endMin - u.startMin) * l,
216
+ height: (u.endMin - u.startMin) * f,
204
217
  pointerEvents: "none"
205
218
  }
206
219
  }
@@ -210,5 +223,5 @@ const ht = st(function({
210
223
  );
211
224
  });
212
225
  export {
213
- ht as SlotInteractionLayer
226
+ Ct as SlotInteractionLayer
214
227
  };