@savvycal/calendar 0.10.2 → 0.11.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.
Files changed (68) hide show
  1. package/README.md +187 -20
  2. package/dist/components/day-grid-view/AllDayEventChip.d.ts.map +1 -1
  3. package/dist/components/day-grid-view/AllDayEventChip.js +47 -41
  4. package/dist/components/day-grid-view/AllDaySection.d.ts +15 -0
  5. package/dist/components/day-grid-view/AllDaySection.d.ts.map +1 -1
  6. package/dist/components/day-grid-view/AllDaySection.js +93 -29
  7. package/dist/components/day-grid-view/BackgroundEventLayer.d.ts +19 -0
  8. package/dist/components/day-grid-view/BackgroundEventLayer.d.ts.map +1 -0
  9. package/dist/components/day-grid-view/BackgroundEventLayer.js +55 -0
  10. package/dist/components/day-grid-view/DayGridView.d.ts +1 -1
  11. package/dist/components/day-grid-view/DayGridView.d.ts.map +1 -1
  12. package/dist/components/day-grid-view/DayGridView.js +375 -263
  13. package/dist/components/day-grid-view/defaults.js +1 -1
  14. package/dist/components/month-view/MonthEventItem.d.ts +22 -0
  15. package/dist/components/month-view/MonthEventItem.d.ts.map +1 -0
  16. package/dist/components/month-view/MonthEventItem.js +95 -0
  17. package/dist/components/month-view/MonthMoreButton.d.ts +22 -0
  18. package/dist/components/month-view/MonthMoreButton.d.ts.map +1 -0
  19. package/dist/components/month-view/MonthMoreButton.js +122 -0
  20. package/dist/components/month-view/MonthView.d.ts +3 -0
  21. package/dist/components/month-view/MonthView.d.ts.map +1 -0
  22. package/dist/components/month-view/MonthView.js +281 -0
  23. package/dist/components/month-view/MonthWeekRow.d.ts +40 -0
  24. package/dist/components/month-view/MonthWeekRow.d.ts.map +1 -0
  25. package/dist/components/month-view/MonthWeekRow.js +192 -0
  26. package/dist/components/month-view/defaults.d.ts +3 -0
  27. package/dist/components/month-view/defaults.d.ts.map +1 -0
  28. package/dist/components/month-view/defaults.js +32 -0
  29. package/dist/components/month-view/index.d.ts +3 -0
  30. package/dist/components/month-view/index.d.ts.map +1 -0
  31. package/dist/components/resource-grid-view/ResourceGridView.d.ts +1 -1
  32. package/dist/components/resource-grid-view/ResourceGridView.d.ts.map +1 -1
  33. package/dist/components/resource-grid-view/ResourceGridView.js +163 -155
  34. package/dist/components/resource-grid-view/defaults.js +1 -1
  35. package/dist/components/shared/AnchoredPopover.d.ts +35 -0
  36. package/dist/components/shared/AnchoredPopover.d.ts.map +1 -0
  37. package/dist/components/shared/AnchoredPopover.js +91 -0
  38. package/dist/components/shared/EventChip.d.ts.map +1 -1
  39. package/dist/components/shared/EventChip.js +58 -64
  40. package/dist/components/shared/OverflowChip.d.ts +1 -1
  41. package/dist/components/shared/OverflowChip.d.ts.map +1 -1
  42. package/dist/components/shared/OverflowChip.js +67 -89
  43. package/dist/components/shared/SelectionOverlay.d.ts +1 -0
  44. package/dist/components/shared/SelectionOverlay.d.ts.map +1 -1
  45. package/dist/components/shared/SelectionOverlay.js +28 -27
  46. package/dist/components/shared/SlotInteractionLayer.d.ts +27 -5
  47. package/dist/components/shared/SlotInteractionLayer.d.ts.map +1 -1
  48. package/dist/components/shared/SlotInteractionLayer.js +186 -145
  49. package/dist/index.d.ts +3 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +14 -10
  52. package/dist/lib/accessibility.d.ts +8 -0
  53. package/dist/lib/accessibility.d.ts.map +1 -1
  54. package/dist/lib/accessibility.js +31 -4
  55. package/dist/lib/lanes.d.ts +25 -0
  56. package/dist/lib/lanes.d.ts.map +1 -0
  57. package/dist/lib/lanes.js +32 -0
  58. package/dist/lib/month.d.ts +64 -0
  59. package/dist/lib/month.d.ts.map +1 -0
  60. package/dist/lib/month.js +110 -0
  61. package/dist/lib/overlap.d.ts.map +1 -1
  62. package/dist/lib/overlap.js +157 -179
  63. package/dist/lib/time.d.ts +4 -0
  64. package/dist/lib/time.d.ts.map +1 -1
  65. package/dist/lib/time.js +20 -12
  66. package/dist/types/calendar.d.ts +164 -0
  67. package/dist/types/calendar.d.ts.map +1 -1
  68. package/package.json +8 -8
@@ -0,0 +1,91 @@
1
+ import { jsx as h } from "react/jsx-runtime";
2
+ import { useRef as w, useState as m, useLayoutEffect as d, useEffect as E } from "react";
3
+ import { createPortal as x } from "react-dom";
4
+ import { cn as S } from "../../lib/utils.js";
5
+ const D = "data-popover-dismiss-only";
6
+ function I() {
7
+ const t = (i) => {
8
+ i.stopPropagation(), i.preventDefault(), o();
9
+ }, o = () => {
10
+ window.removeEventListener("click", t, !0), window.removeEventListener("pointerdown", o, !0), window.removeEventListener("keydown", o, !0);
11
+ };
12
+ window.addEventListener("click", t, !0), window.addEventListener("pointerdown", o, !0), window.addEventListener("keydown", o, !0);
13
+ }
14
+ function T({
15
+ triggerRef: t,
16
+ onClose: o,
17
+ getPosition: i,
18
+ ariaLabel: L,
19
+ className: k,
20
+ children: y
21
+ }) {
22
+ const r = w(null), [v, b] = m(null), [u, P] = m(null), l = w(o), p = w(i);
23
+ d(() => {
24
+ l.current = o, p.current = i;
25
+ }), d(() => {
26
+ b(!!t.current?.closest(".dark"));
27
+ }, [t]);
28
+ const c = v !== null;
29
+ d(() => {
30
+ if (!c) return;
31
+ const e = () => {
32
+ const n = r.current;
33
+ n && P(
34
+ p.current({
35
+ width: n.offsetWidth,
36
+ height: n.offsetHeight
37
+ })
38
+ );
39
+ };
40
+ e(), window.addEventListener("scroll", e, !0), window.addEventListener("resize", e);
41
+ const s = new ResizeObserver(e);
42
+ return r.current && s.observe(r.current), () => {
43
+ window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e), s.disconnect();
44
+ };
45
+ }, [c]), d(() => {
46
+ if (!c) return;
47
+ const e = r.current, s = t.current;
48
+ return () => {
49
+ e?.contains(document.activeElement) && s?.focus({ preventScroll: !0 });
50
+ };
51
+ }, [c, t]);
52
+ const f = u !== null;
53
+ return E(() => {
54
+ f && r.current?.focus({ preventScroll: !0 });
55
+ }, [f]), E(() => {
56
+ const e = (n) => {
57
+ n.key === "Escape" && (n.stopPropagation(), l.current(), t.current?.focus());
58
+ }, s = (n) => {
59
+ const a = n.target;
60
+ t.current?.contains(a) || r.current?.contains(a) || (a.closest?.(`[${D}]`) && (n.preventDefault(), n.button === 0 && I()), l.current());
61
+ };
62
+ return window.addEventListener("keydown", e, !0), document.addEventListener("pointerdown", s), () => {
63
+ window.removeEventListener("keydown", e, !0), document.removeEventListener("pointerdown", s);
64
+ };
65
+ }, [t]), c ? x(
66
+ /* @__PURE__ */ h(
67
+ "div",
68
+ {
69
+ ref: r,
70
+ role: "dialog",
71
+ "aria-label": L,
72
+ tabIndex: -1,
73
+ className: S(k, v && "dark"),
74
+ style: {
75
+ position: "fixed",
76
+ top: u?.top ?? 0,
77
+ left: u?.left ?? 0,
78
+ visibility: u ? void 0 : "hidden",
79
+ zIndex: 50,
80
+ outline: "none"
81
+ },
82
+ children: y
83
+ }
84
+ ),
85
+ document.body
86
+ ) : null;
87
+ }
88
+ export {
89
+ T as AnchoredPopover,
90
+ D as DISMISS_ONLY_ATTR
91
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"EventChip.d.ts","sourceRoot":"","sources":["../../../src/components/shared/EventChip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAEvC,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAI1B,UAAU,cAAc;IACtB,UAAU,EAAE,eAAe,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,kBAAkB,KAAK,MAAM,CAAC;IAC/C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;QACpB,KAAK,EAAE,kBAAkB,CAAC;QAC1B,QAAQ,EAAE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O,MAAM,SAAS,sDAuJpB,CAAC"}
@@ -1,112 +1,106 @@
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
- timeZone: x,
1
+ import { jsx as i, jsxs as f, Fragment as z } from "react/jsx-runtime";
2
+ import { memo as B } from "react";
3
+ import { cn as K } from "../../lib/utils.js";
4
+ import { formatEventStartTime as O } from "../../lib/time.js";
5
+ import { describeEvent as q } from "../../lib/accessibility.js";
6
+ const U = B(function({
7
+ positioned: s,
8
+ fallbackColor: k,
9
+ timeZone: h,
10
10
  cls: n,
11
- onClick: g,
11
+ onClick: x,
12
12
  renderEvent: N,
13
- interactive: i = !0,
14
- eventGap: k = 2,
15
- eventLayout: w = "columns",
13
+ interactive: w = !0,
14
+ eventGap: E = 2,
15
+ eventLayout: I = "columns",
16
16
  stackOffset: b = 8,
17
- isSelected: T,
18
- selectedEventRef: C
17
+ isSelected: g,
18
+ selectedEventRef: $
19
19
  }) {
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
- if (w === "stacked") {
20
+ const { event: e, top: C, height: l, subColumn: o, totalSubColumns: a } = s, r = w && e.interactive !== !1, T = s.colSpan ?? 1, m = e.color ?? k;
21
+ let v, d, c;
22
+ if (I === "stacked") {
23
23
  const t = (a - 1) * b;
24
- p = s > 0 ? `${s * b}px` : "0", u = t > 0 ? `calc(100% - ${t}px)` : "100%", l = s + 1;
24
+ v = o > 0 ? `${o * b}px` : "0", d = t > 0 ? `calc(100% - ${t}px)` : "100%", c = o + 1;
25
25
  } else {
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}%`;
26
+ const t = o / a * 100, y = T / a * 100, S = E, P = o * S / a, u = (a - T) * S / a;
27
+ v = u ? `calc(${t}% + ${P}px)` : `${t}%`, d = u ? `calc(${y}% - ${u}px)` : `${y}%`;
28
28
  }
29
- c.overlay && (l = 8), T && (l = 20);
30
- const E = m >= 36, j = m >= 52, D = e.status === "canceled";
29
+ s.overlay && (c = 8), g && (c = 20);
30
+ const D = l >= 36, F = l >= 52, L = e.status === "canceled";
31
31
  if (N) {
32
- const t = N({ event: e, position: c });
32
+ const t = N({ event: e, position: s });
33
33
  if (t)
34
- return /* @__PURE__ */ o(
34
+ return /* @__PURE__ */ i(
35
35
  "div",
36
36
  {
37
- ref: C,
37
+ ref: $,
38
38
  style: {
39
39
  position: "absolute",
40
- top: $,
41
- height: m,
42
- left: p,
43
- width: u,
44
- zIndex: l,
45
- pointerEvents: i ? "auto" : "none"
40
+ top: C,
41
+ height: l,
42
+ left: v,
43
+ width: d,
44
+ zIndex: c,
45
+ pointerEvents: r ? "auto" : "none"
46
46
  },
47
47
  children: t
48
48
  }
49
49
  );
50
50
  }
51
- const f = K(e.startTime, x), F = i ? (() => {
52
- const t = [
53
- q(e),
54
- O(e.startTime, e.endTime, x)
55
- ], r = A(e);
56
- return r && t.push(r), e.status === "canceled" ? t.push("canceled") : e.status === "tentative" && t.push("tentative"), t.join(", ");
57
- })() : void 0;
58
- return /* @__PURE__ */ h(
51
+ const p = O(e.startTime, h), j = r ? q(e, h, { includeStatus: !0 }) : void 0;
52
+ return /* @__PURE__ */ f(
59
53
  "div",
60
54
  {
61
- ref: C,
62
- ...i ? { role: "button", tabIndex: 0, "aria-label": F } : {},
63
- className: B(n("event"), T && n("eventSelected")),
55
+ ref: $,
56
+ ...r ? { role: "button", tabIndex: 0, "aria-label": j } : {},
57
+ className: K(n("event"), g && n("eventSelected")),
64
58
  style: {
65
- top: $,
66
- height: m,
67
- left: p,
68
- width: u,
69
- zIndex: l,
70
- pointerEvents: i ? "auto" : "none"
59
+ top: C,
60
+ height: l,
61
+ left: v,
62
+ width: d,
63
+ zIndex: c,
64
+ pointerEvents: r ? "auto" : "none"
71
65
  },
72
- ...i ? {
73
- onClick: () => g?.(e),
66
+ ...r ? {
67
+ onClick: () => x?.(e),
74
68
  onKeyDown: (t) => {
75
- (t.key === "Enter" || t.key === " ") && (t.preventDefault(), g?.(e));
69
+ (t.key === "Enter" || t.key === " ") && (t.preventDefault(), x?.(e));
76
70
  }
77
71
  } : {},
78
72
  children: [
79
- d && /* @__PURE__ */ o(
73
+ m && /* @__PURE__ */ i(
80
74
  "div",
81
75
  {
82
76
  className: n("eventColorBar"),
83
77
  style: e.status === "tentative" ? {
84
78
  backgroundImage: `repeating-linear-gradient(
85
79
  -45deg,
86
- ${d},
87
- ${d} 3px,
80
+ ${m},
81
+ ${m} 3px,
88
82
  transparent 3px,
89
83
  transparent 6px
90
84
  )`
91
- } : { backgroundColor: d }
85
+ } : { backgroundColor: m }
92
86
  }
93
87
  ),
94
- /* @__PURE__ */ o(
88
+ /* @__PURE__ */ i(
95
89
  "div",
96
90
  {
97
91
  className: n("eventTitle"),
98
- style: D ? { textDecoration: "line-through" } : void 0,
92
+ style: L ? { textDecoration: "line-through" } : void 0,
99
93
  children: e.title
100
94
  }
101
95
  ),
102
- E && (j ? /* @__PURE__ */ h(P, { children: [
103
- /* @__PURE__ */ o("div", { className: n("eventTime"), children: f }),
104
- e.clientName && /* @__PURE__ */ o("div", { className: n("eventClientName"), children: e.clientName })
105
- ] }) : e.clientName ? /* @__PURE__ */ h("div", { className: n("eventTime"), children: [
106
- f,
96
+ D && (F ? /* @__PURE__ */ f(z, { children: [
97
+ /* @__PURE__ */ i("div", { className: n("eventTime"), children: p }),
98
+ e.clientName && /* @__PURE__ */ i("div", { className: n("eventClientName"), children: e.clientName })
99
+ ] }) : e.clientName ? /* @__PURE__ */ f("div", { className: n("eventTime"), children: [
100
+ p,
107
101
  ", ",
108
102
  e.clientName
109
- ] }) : /* @__PURE__ */ o("div", { className: n("eventTime"), children: f }))
103
+ ] }) : /* @__PURE__ */ i("div", { className: n("eventTime"), children: p }))
110
104
  ]
111
105
  }
112
106
  );
@@ -8,6 +8,6 @@ interface OverflowChipProps {
8
8
  onOverflowClick?: (info: OverflowClickInfo) => void;
9
9
  renderOverflowPopover?: (props: OverflowPopoverRenderProps) => React.ReactNode;
10
10
  }
11
- export declare function OverflowChip({ group, timeZone, cls, onEventClick, onOverflowClick, renderOverflowPopover, }: OverflowChipProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function OverflowChip({ group, timeZone, cls, onEventClick, onOverflowClick, renderOverflowPopover, }: OverflowChipProps): import("react").JSX.Element;
12
12
  export {};
13
13
  //# sourceMappingURL=OverflowChip.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"OverflowChip.d.ts","sourceRoot":"","sources":["../../../src/components/shared/OverflowChip.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,EAE3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAKnD,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;AAKD,wBAAgB,YAAY,CAAC,EAC3B,KAAK,EACL,QAAQ,EACR,GAAG,EACH,YAAY,EACZ,eAAe,EACf,qBAAqB,GACtB,EAAE,iBAAiB,+BA8FnB"}
@@ -1,125 +1,103 @@
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({
1
+ import { jsx as r, jsxs as C, Fragment as T } from "react/jsx-runtime";
2
+ import { useState as O, useRef as A } from "react";
3
+ import { formatTimeRange as E } from "../../lib/time.js";
4
+ import { getEventLabel as y } from "../../lib/accessibility.js";
5
+ import { AnchoredPopover as H } from "./AnchoredPopover.js";
6
+ const l = 8, g = 8;
7
+ function G({
8
8
  group: o,
9
- timeZone: v,
10
- cls: t,
11
- onEventClick: f,
12
- onOverflowClick: r,
13
- renderOverflowPopover: y
9
+ timeZone: f,
10
+ cls: e,
11
+ onEventClick: a,
12
+ onOverflowClick: t,
13
+ renderOverflowPopover: P
14
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?.({
15
+ const [s, u] = O(!1), i = A(null), p = o.events.length, x = `+${p}`, h = `${p} more event${p === 1 ? "" : "s"}`, m = () => u(!1), N = ({
16
+ width: n,
17
+ height: b
18
+ }) => {
19
+ const c = i.current?.getBoundingClientRect();
20
+ if (!c) return null;
21
+ let v = c.right + g;
22
+ v + n > window.innerWidth - l && (v = Math.max(l, c.left - n - g));
23
+ let d = c.top;
24
+ return d + b > window.innerHeight - l && (d = Math.max(
25
+ l,
26
+ window.innerHeight - b - l
27
+ )), { top: d, left: v };
28
+ }, R = () => {
29
+ const n = !s;
30
+ u(n), n && i.current && t?.({
45
31
  events: o.events,
46
- anchor: l.current
32
+ anchor: i.current
47
33
  });
48
- }, b = n ? y?.({
34
+ }, w = s ? P?.({
49
35
  events: o.events,
50
- onClose: p,
51
- onEventClick: f
52
- }) ?? /* @__PURE__ */ a(
53
- M,
36
+ onClose: m,
37
+ onEventClick: a
38
+ }) ?? /* @__PURE__ */ r(
39
+ I,
54
40
  {
55
41
  events: o.events,
56
- timeZone: v,
57
- cls: t,
58
- onEventClick: (e) => {
59
- f?.(e), p();
42
+ timeZone: f,
43
+ cls: e,
44
+ onEventClick: (n) => {
45
+ a?.(n), m();
60
46
  }
61
47
  }
62
48
  ) : null;
63
- return /* @__PURE__ */ x(R, { children: [
64
- /* @__PURE__ */ a(
49
+ return /* @__PURE__ */ C(T, { children: [
50
+ /* @__PURE__ */ r(
65
51
  "button",
66
52
  {
67
- ref: l,
53
+ ref: i,
68
54
  type: "button",
69
- className: t("overflowChip"),
55
+ className: e("overflowChip"),
70
56
  style: {
71
57
  top: o.top,
72
58
  zIndex: 25,
73
59
  pointerEvents: "auto"
74
60
  },
75
- "aria-label": E,
76
- "aria-expanded": n,
61
+ "aria-label": h,
62
+ "aria-expanded": s,
77
63
  "aria-haspopup": "dialog",
78
- onClick: N,
79
- children: /* @__PURE__ */ a("span", { className: t("overflowChipLabel"), children: T })
64
+ onClick: R,
65
+ children: /* @__PURE__ */ r("span", { className: e("overflowChipLabel"), children: x })
80
66
  }
81
67
  ),
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
68
+ s && w && /* @__PURE__ */ r(
69
+ H,
70
+ {
71
+ triggerRef: i,
72
+ onClose: m,
73
+ getPosition: N,
74
+ ariaLabel: h,
75
+ className: e("overflowPopover"),
76
+ children: w
77
+ }
100
78
  )
101
79
  ] });
102
80
  }
103
- function M({
81
+ function I({
104
82
  events: o,
105
- timeZone: v,
106
- cls: t,
107
- onEventClick: f
83
+ timeZone: f,
84
+ cls: e,
85
+ onEventClick: a
108
86
  }) {
109
- return /* @__PURE__ */ a("div", { children: o.map((r) => /* @__PURE__ */ x(
87
+ return /* @__PURE__ */ r("div", { children: o.map((t) => /* @__PURE__ */ C(
110
88
  "button",
111
89
  {
112
90
  type: "button",
113
- className: t("overflowPopoverEvent"),
114
- onClick: () => f?.(r),
91
+ className: e("overflowPopoverEvent"),
92
+ onClick: () => a?.(t),
115
93
  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) })
94
+ /* @__PURE__ */ r("div", { className: e("overflowPopoverTitle"), children: y(t) }),
95
+ /* @__PURE__ */ r("div", { className: e("overflowPopoverTime"), children: E(t.startTime, t.endTime, f) })
118
96
  ]
119
97
  },
120
- r.id
98
+ t.id
121
99
  )) });
122
100
  }
123
101
  export {
124
- F as OverflowChip
102
+ G as OverflowChip
125
103
  };
@@ -9,6 +9,7 @@ interface SelectionOverlayProps {
9
9
  viewDate: Temporal.PlainDate;
10
10
  timeZone: string;
11
11
  startHour: number;
12
+ endHour: number;
12
13
  hourHeight: number;
13
14
  cls: (key: keyof GridViewClassNames) => string;
14
15
  appearance?: SelectionAppearance;
@@ -1 +1 @@
1
- {"version":3,"file":"SelectionOverlay.d.ts","sourceRoot":"","sources":["../../../src/components/shared/SelectionOverlay.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EACV,kBAAkB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AAQ,CAAC,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,kBAAkB,KAAK,MAAM,CAAC;IAC/C,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,YAAY,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;QACpB,KAAK,EAAE,kBAAkB,CAAC;QAC1B,QAAQ,EAAE,eAAe,CAAC;KAC3B,KAAK,KAAK,CAAC,SAAS,CAAC;CACvB;AAED,eAAO,MAAM,gBAAgB,6DAsF3B,CAAC"}
@@ -1,53 +1,54 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { memo as y } from "react";
3
- import { getMinuteRange as S } from "../../lib/time.js";
4
- import { buildSyntheticEvent as M } from "../../lib/selection.js";
5
- import { EventChip as b } from "./EventChip.js";
6
- const w = y(function({
2
+ import { memo as b } from "react";
3
+ import { getMinuteRange as x } from "../../lib/time.js";
4
+ import { buildSyntheticEvent as C } from "../../lib/selection.js";
5
+ import { EventChip as E } from "./EventChip.js";
6
+ const P = b(function({
7
7
  startTime: o,
8
8
  endTime: r,
9
- fallbackColor: u,
10
- column: a,
11
- viewDate: c,
9
+ fallbackColor: c,
10
+ column: m,
11
+ viewDate: v,
12
12
  timeZone: l,
13
- startHour: v,
14
- hourHeight: m,
15
- cls: i,
13
+ startHour: d,
14
+ endHour: g,
15
+ hourHeight: p,
16
+ cls: e,
16
17
  appearance: s = "highlight",
17
- selectionRef: d,
18
- renderEvent: g
18
+ selectionRef: f,
19
+ renderEvent: y
19
20
  }) {
20
- const h = m / 60, p = v * 60, e = S(o, r, c, l);
21
- if (!e) return null;
22
- const f = (e.startMin - p) * h, n = (e.endMin - e.startMin) * h;
21
+ const a = p / 60, h = d * 60, i = x(o, r, v, l);
22
+ if (!i) return null;
23
+ const u = Math.max(i.startMin, h), M = Math.min(i.endMin, g * 60), S = (u - h) * a, n = (M - u) * a;
23
24
  return n <= 0 ? null : /* @__PURE__ */ t(
24
25
  "div",
25
26
  {
26
27
  "aria-hidden": "true",
27
28
  style: {
28
29
  gridRow: "3 / -1",
29
- gridColumn: a,
30
+ gridColumn: m,
30
31
  position: "relative",
31
32
  pointerEvents: "none"
32
33
  },
33
34
  children: /* @__PURE__ */ t(
34
35
  "div",
35
36
  {
36
- ref: d,
37
+ ref: f,
37
38
  style: {
38
39
  position: "absolute",
39
- top: f,
40
+ top: S,
40
41
  left: 0,
41
42
  right: 0,
42
43
  height: n
43
44
  },
44
- children: s !== "highlight" ? /* @__PURE__ */ t("div", { className: i("eventColumn"), style: { height: "100%" }, children: /* @__PURE__ */ t(
45
- b,
45
+ children: s !== "highlight" ? /* @__PURE__ */ t("div", { className: e("eventColumn"), style: { height: "100%" }, children: /* @__PURE__ */ t(
46
+ E,
46
47
  {
47
48
  interactive: !1,
48
49
  isSelected: !0,
49
50
  positioned: {
50
- event: M(
51
+ event: C(
51
52
  "",
52
53
  o,
53
54
  r,
@@ -58,15 +59,15 @@ const w = y(function({
58
59
  subColumn: 0,
59
60
  totalSubColumns: 1
60
61
  },
61
- fallbackColor: u,
62
+ fallbackColor: c,
62
63
  timeZone: l,
63
- cls: i,
64
- renderEvent: g
64
+ cls: e,
65
+ renderEvent: y
65
66
  }
66
67
  ) }) : /* @__PURE__ */ t(
67
68
  "div",
68
69
  {
69
- className: i("selectionHighlight"),
70
+ className: e("selectionHighlight"),
70
71
  style: {
71
72
  position: "absolute",
72
73
  inset: 0
@@ -79,5 +80,5 @@ const w = y(function({
79
80
  );
80
81
  });
81
82
  export {
82
- w as SelectionOverlay
83
+ P as SelectionOverlay
83
84
  };
@@ -1,5 +1,18 @@
1
1
  import { Temporal } from 'temporal-polyfill';
2
2
  import { GridViewClassNames, PositionedEvent, SelectionAppearance, TimedCalendarEvent } from '../../types/calendar';
3
+ export interface SlotRange {
4
+ columnId: string;
5
+ /** The column the drag ended in, when the drag can span columns. */
6
+ endColumnId?: string;
7
+ startTime: Temporal.ZonedDateTime;
8
+ endTime: Temporal.ZonedDateTime;
9
+ }
10
+ export interface DragPreview {
11
+ columnId: string;
12
+ endColumnId: string;
13
+ startMin: number;
14
+ endMin: number;
15
+ }
3
16
  interface SlotInteractionLayerProps {
4
17
  columnId: string;
5
18
  fallbackColor?: string;
@@ -17,11 +30,20 @@ interface SlotInteractionLayerProps {
17
30
  startTime: Temporal.ZonedDateTime;
18
31
  endTime: Temporal.ZonedDateTime;
19
32
  }) => void;
20
- onSelect?: (range: {
21
- columnId: string;
22
- startTime: Temporal.ZonedDateTime;
23
- endTime: Temporal.ZonedDateTime;
24
- } | null) => void;
33
+ onSelect?: (range: SlotRange | null) => void;
34
+ onSlotHover?: (range: SlotRange | null) => void;
35
+ /**
36
+ * Finds the column under the pointer, letting a drag span columns. The
37
+ * layer then reports its drag preview through `onDragPreviewChange` and
38
+ * draws `previewRange` instead of its own preview.
39
+ */
40
+ resolveColumnId?: (clientX: number) => string | null;
41
+ onDragPreviewChange?: (preview: DragPreview | null) => void;
42
+ /** This column's part of a drag preview that spans columns. */
43
+ previewRange?: {
44
+ startMin: number;
45
+ endMin: number;
46
+ } | null;
25
47
  dragPreviewAppearance?: SelectionAppearance;
26
48
  renderEvent?: (props: {
27
49
  event: TimedCalendarEvent;