@savvycal/calendar 0.9.0 → 0.10.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 (39) 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/TimedEventLayer.d.ts +26 -0
  24. package/dist/components/shared/TimedEventLayer.d.ts.map +1 -0
  25. package/dist/components/shared/TimedEventLayer.js +83 -0
  26. package/dist/components/shared/UnavailabilityOverlay.d.ts.map +1 -1
  27. package/dist/components/shared/UnavailabilityOverlay.js +14 -13
  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/components.css +5 -2
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/lib/overlap.d.ts +13 -0
  35. package/dist/lib/overlap.d.ts.map +1 -1
  36. package/dist/lib/overlap.js +216 -118
  37. package/dist/types/calendar.d.ts +56 -0
  38. package/dist/types/calendar.d.ts.map +1 -1
  39. package/package.json +2 -2
@@ -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
+ };
@@ -0,0 +1,26 @@
1
+ import { Ref } from 'react';
2
+ import { CalendarEvent, EventLayout, GridViewClassNames, OverflowClickInfo, OverflowPopoverRenderProps, PositionedEvent, TimedCalendarEvent } from '../../types/calendar';
3
+ interface TimedEventLayerProps {
4
+ positionedEvents: PositionedEvent[];
5
+ column: number;
6
+ timeZone: string;
7
+ cls: (key: keyof GridViewClassNames) => string;
8
+ fallbackColor?: string;
9
+ onEventClick?: (event: CalendarEvent) => void;
10
+ renderEvent?: (props: {
11
+ event: TimedCalendarEvent;
12
+ position: PositionedEvent;
13
+ }) => React.ReactNode;
14
+ eventGap?: number;
15
+ eventLayout?: EventLayout;
16
+ stackOffset?: number;
17
+ selectedEventId?: string | null;
18
+ selectedEventRef?: Ref<HTMLDivElement>;
19
+ eventMinWidth?: number;
20
+ eventMaxStack?: number;
21
+ onOverflowClick?: (info: OverflowClickInfo) => void;
22
+ renderOverflowPopover?: (props: OverflowPopoverRenderProps) => React.ReactNode;
23
+ }
24
+ export declare const TimedEventLayer: import('react').NamedExoticComponent<TimedEventLayerProps>;
25
+ export {};
26
+ //# sourceMappingURL=TimedEventLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimedEventLayer.d.ts","sourceRoot":"","sources":["../../../src/components/shared/TimedEventLayer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAChD,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAU1B,UAAU,oBAAoB;IAC5B,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,kBAAkB,KAAK,MAAM,CAAC;IAC/C,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;QACpB,KAAK,EAAE,kBAAkB,CAAC;QAC1B,QAAQ,EAAE,eAAe,CAAC;KAC3B,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACpD,qBAAqB,CAAC,EAAE,CACtB,KAAK,EAAE,0BAA0B,KAC9B,KAAK,CAAC,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,eAAe,4DAwE1B,CAAC"}
@@ -0,0 +1,83 @@
1
+ import { jsxs as b, jsx as f } from "react/jsx-runtime";
2
+ import { memo as L, useMemo as N } from "react";
3
+ import { applyEventOverflow as V, DEFAULT_EVENT_MIN_WIDTH as _, computeMaxVisibleColumns as j } from "../../lib/overlap.js";
4
+ import { EventChip as D } from "./EventChip.js";
5
+ import { OverflowChip as I } from "./OverflowChip.js";
6
+ import { useColumnWidth as O } from "./useColumnWidth.js";
7
+ const W = L(function({
8
+ positionedEvents: r,
9
+ column: p,
10
+ timeZone: m,
11
+ cls: o,
12
+ fallbackColor: v,
13
+ onEventClick: t,
14
+ renderEvent: d,
15
+ eventGap: u,
16
+ eventLayout: a,
17
+ stackOffset: c,
18
+ selectedEventId: E,
19
+ selectedEventRef: C,
20
+ eventMinWidth: i = _,
21
+ eventMaxStack: n,
22
+ onOverflowClick: w,
23
+ renderOverflowPopover: T
24
+ }) {
25
+ const { ref: h, width: s } = O(), { visible: x, overflows: y } = N(() => {
26
+ const e = j(
27
+ s,
28
+ i,
29
+ n
30
+ );
31
+ return V(r, e);
32
+ }, [r, s, i, n]);
33
+ return /* @__PURE__ */ b(
34
+ "div",
35
+ {
36
+ ref: h,
37
+ className: o("eventColumn"),
38
+ style: {
39
+ gridRow: "3 / -1",
40
+ gridColumn: p,
41
+ pointerEvents: "none",
42
+ isolation: "isolate"
43
+ },
44
+ children: [
45
+ x.map((e) => {
46
+ const l = e.event.id === E;
47
+ return /* @__PURE__ */ f(
48
+ D,
49
+ {
50
+ positioned: e,
51
+ fallbackColor: v,
52
+ timeZone: m,
53
+ cls: o,
54
+ onClick: t,
55
+ renderEvent: d,
56
+ eventGap: u,
57
+ eventLayout: a,
58
+ stackOffset: c,
59
+ isSelected: l,
60
+ selectedEventRef: l ? C : void 0
61
+ },
62
+ e.event.id
63
+ );
64
+ }),
65
+ y.map((e) => /* @__PURE__ */ f(
66
+ I,
67
+ {
68
+ group: e,
69
+ timeZone: m,
70
+ cls: o,
71
+ onEventClick: t,
72
+ onOverflowClick: w,
73
+ renderOverflowPopover: T
74
+ },
75
+ e.id
76
+ ))
77
+ ]
78
+ }
79
+ );
80
+ });
81
+ export {
82
+ W as TimedEventLayer
83
+ };
@@ -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,kEAgChC,CAAC"}
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 l } from "react";
3
- const p = l(function({
4
- blocks: i,
5
- column: r,
6
- cls: a
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 i.length === 0 ? null : /* @__PURE__ */ e(
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: r,
14
+ gridColumn: n,
15
15
  position: "relative",
16
16
  pointerEvents: "none"
17
17
  },
18
- children: i.map((t, n) => /* @__PURE__ */ e(
18
+ children: t.map((i, a) => /* @__PURE__ */ e(
19
19
  "div",
20
20
  {
21
- className: a("unavailableOverlay"),
21
+ className: r("unavailableOverlay"),
22
22
  style: {
23
23
  position: "absolute",
24
- top: t.top,
24
+ top: i.top,
25
25
  left: 0,
26
26
  right: 0,
27
- height: t.height
27
+ height: i.height,
28
+ backgroundPosition: `0 ${-i.top}px`
28
29
  }
29
30
  },
30
- n
31
+ a
31
32
  ))
32
33
  }
33
34
  );
34
35
  });
35
36
  export {
36
- p as UnavailabilityOverlay
37
+ v as UnavailabilityOverlay
37
38
  };
@@ -0,0 +1,5 @@
1
+ export declare function useColumnWidth(): {
2
+ ref: import('react').RefObject<HTMLDivElement | null>;
3
+ width: number;
4
+ };
5
+ //# sourceMappingURL=useColumnWidth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useColumnWidth.d.ts","sourceRoot":"","sources":["../../../src/components/shared/useColumnWidth.ts"],"names":[],"mappings":"AAEA,wBAAgB,cAAc;;;EAoB7B"}
@@ -0,0 +1,17 @@
1
+ import { useRef as u, useState as c, useLayoutEffect as i } from "react";
2
+ function d() {
3
+ const t = u(null), [s, o] = c(0);
4
+ return i(() => {
5
+ const e = t.current;
6
+ if (!e) return;
7
+ function n() {
8
+ o(e.clientWidth);
9
+ }
10
+ n();
11
+ const r = new ResizeObserver(n);
12
+ return r.observe(e), () => r.disconnect();
13
+ }, []), { ref: t, width: s };
14
+ }
15
+ export {
16
+ d as useColumnWidth
17
+ };
@@ -8,9 +8,12 @@
8
8
  * @import "@savvycal/calendar/components.css";
9
9
  */
10
10
 
11
- /* Unavailable time overlay with cross-hatching */
11
+ /* Unavailable time overlay with cross-hatching.
12
+ * Do not use background-attachment: fixed — mobile browsers fail to paint
13
+ * fixed backgrounds inside overflow scrollers. Overlay blocks set
14
+ * background-position from their grid top so disjoint ranges share one
15
+ * stripe origin. */
12
16
  .cal-unavailable-overlay {
13
- background-attachment: fixed;
14
17
  background-image: repeating-linear-gradient(
15
18
  -45deg,
16
19
  oklch(0 0 0 / 0.02),
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ export { ResourceGridView } from './components/resource-grid-view';
3
3
  export { DayGridView } from './components/day-grid-view';
4
4
  export { resourceGridViewDefaults } from './components/resource-grid-view';
5
5
  export { dayGridViewDefaults } from './components/day-grid-view';
6
- export type { CalendarResource, CalendarEvent, TimedCalendarEvent, AllDayCalendarEvent, TimeSlot, AvailabilityRange, TimeAxisConfig, ResourceGridViewProps, ResourceGridViewClassNames, GridViewClassNames, DayGridViewProps, DayGridViewClassNames, DayGridSelectedRange, PositionedEvent, SelectedRange, SelectionAppearance, SelectionEventData, EventLayout, } from './types/calendar';
6
+ export type { CalendarResource, CalendarEvent, TimedCalendarEvent, AllDayCalendarEvent, TimeSlot, AvailabilityRange, TimeAxisConfig, ResourceGridViewProps, ResourceGridViewClassNames, GridViewClassNames, DayGridViewProps, DayGridViewClassNames, DayGridSelectedRange, PositionedEvent, OverflowClickInfo, OverflowPopoverRenderProps, SelectedRange, SelectionAppearance, SelectionEventData, EventLayout, } from './types/calendar';
7
7
  export { cn } from './lib/utils';
8
8
  export { timedEvent, allDayEvent } from './lib/events';
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGjE,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAC1B,kBAAkB,EAClB,gBAAgB,EAChB,qBAAqB,EACrB,oBAAoB,EACpB,eAAe,EACf,iBAAiB,EACjB,0BAA0B,EAC1B,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,GACZ,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
@@ -6,7 +6,15 @@ interface LayoutEntry {
6
6
  endMin: number;
7
7
  subColumn: number;
8
8
  totalSubColumns: number;
9
+ colSpan: number;
9
10
  }
11
+ export interface OverflowGroup {
12
+ id: string;
13
+ events: TimedCalendarEvent[];
14
+ top: number;
15
+ height: number;
16
+ }
17
+ export declare const DEFAULT_EVENT_MIN_WIDTH = 80;
10
18
  export declare function groupByResource<T extends {
11
19
  resourceId: string;
12
20
  }>(items: T[]): Map<string, T[]>;
@@ -24,5 +32,10 @@ export interface PositionedAllDayEvent {
24
32
  }
25
33
  export declare function layoutAllDayEvents(events: AllDayCalendarEvent[], dates: Temporal.PlainDate[]): PositionedAllDayEvent[];
26
34
  export declare function computePositionedEventsByDate(events: TimedCalendarEvent[], timeZone: string, dates: Temporal.PlainDate[], startHour: number, endHour: number, hourHeight: number): Map<string, PositionedEvent[]>;
35
+ export declare function computeMaxVisibleColumns(columnWidth: number, eventMinWidth: number, eventMaxStack?: number): number;
36
+ export declare function applyEventOverflow(positioned: PositionedEvent[], maxVisible: number): {
37
+ visible: PositionedEvent[];
38
+ overflows: OverflowGroup[];
39
+ };
27
40
  export {};
28
41
  //# sourceM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