@savvycal/calendar 0.10.3 → 0.11.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 (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 +49 -49
  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.d.ts.map +1 -1
  14. package/dist/components/day-grid-view/defaults.js +2 -2
  15. package/dist/components/month-view/MonthEventItem.d.ts +22 -0
  16. package/dist/components/month-view/MonthEventItem.d.ts.map +1 -0
  17. package/dist/components/month-view/MonthEventItem.js +95 -0
  18. package/dist/components/month-view/MonthMoreButton.d.ts +22 -0
  19. package/dist/components/month-view/MonthMoreButton.d.ts.map +1 -0
  20. package/dist/components/month-view/MonthMoreButton.js +122 -0
  21. package/dist/components/month-view/MonthView.d.ts +3 -0
  22. package/dist/components/month-view/MonthView.d.ts.map +1 -0
  23. package/dist/components/month-view/MonthView.js +281 -0
  24. package/dist/components/month-view/MonthWeekRow.d.ts +40 -0
  25. package/dist/components/month-view/MonthWeekRow.d.ts.map +1 -0
  26. package/dist/components/month-view/MonthWeekRow.js +192 -0
  27. package/dist/components/month-view/defaults.d.ts +3 -0
  28. package/dist/components/month-view/defaults.d.ts.map +1 -0
  29. package/dist/components/month-view/defaults.js +32 -0
  30. package/dist/components/month-view/index.d.ts +3 -0
  31. package/dist/components/month-view/index.d.ts.map +1 -0
  32. package/dist/components/resource-grid-view/ResourceGridView.d.ts +1 -1
  33. package/dist/components/resource-grid-view/ResourceGridView.d.ts.map +1 -1
  34. package/dist/components/resource-grid-view/ResourceGridView.js +163 -155
  35. package/dist/components/resource-grid-view/defaults.js +1 -1
  36. package/dist/components/shared/AnchoredPopover.d.ts +35 -0
  37. package/dist/components/shared/AnchoredPopover.d.ts.map +1 -0
  38. package/dist/components/shared/AnchoredPopover.js +91 -0
  39. package/dist/components/shared/EventChip.d.ts.map +1 -1
  40. package/dist/components/shared/EventChip.js +58 -64
  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 +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,qBAAqB,CAqD/D,CAAC"}
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAE9D,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,qBAAqB,CAsD/D,CAAC"}
@@ -28,10 +28,10 @@ const e = {
28
28
  allDayEvent: "rounded-md pl-2.5 pr-1.5 py-0.5 overflow-hidden cursor-pointer select-none text-left bg-cal-event-bg ring-1 ring-inset ring-cal-event-ring min-w-0",
29
29
  allDayEventSelected: "shadow-lg shadow-cal-event-shadow ring-cal-event-ring-selected",
30
30
  allDayEventColorBar: "absolute left-0 top-0 bottom-0 w-1",
31
- allDayEventTitle: "text-cal-text-body text-xs/4 font-medium truncate",
31
+ allDayEventTitle: "text-cal-text-body text-xs/4 font-medium whitespace-nowrap",
32
32
  overflowChip: "absolute right-0.5 min-w-9 h-[22px] p-0 border-0 cursor-pointer select-none text-center rounded-md bg-cal-surface ring-1 ring-cal-event-ring shadow-lg shadow-cal-event-shadow hover:ring-cal-event-ring-selected",
33
33
  overflowChipLabel: "block px-1 py-0.5 text-cal-text-body text-xs/4 font-medium",
34
- overflowPopover: "w-64 rounded-lg bg-cal-surface p-1 shadow-lg shadow-cal-event-shadow ring-1 ring-cal-event-ring max-h-80 overflow-auto",
34
+ overflowPopover: "w-64 rounded-lg bg-cal-surface p-1 shadow-lg shadow-cal-event-shadow ring-1 ring-cal-event-ring max-h-[min(20rem,calc(100dvh-1rem))] overflow-auto",
35
35
  overflowPopoverEvent: "block w-full rounded-md px-2 py-1.5 text-left cursor-pointer hover:bg-cal-event-bg",
36
36
  overflowPopoverTitle: "text-cal-text-body text-xs/4 font-medium truncate",
37
37
  overflowPopoverTime: "text-cal-text-muted text-xs/4"
@@ -0,0 +1,22 @@
1
+ import { CSSProperties, Ref } from 'react';
2
+ import { CalendarEvent, MonthViewClassNames } from '../../types/calendar';
3
+ interface MonthEventItemProps {
4
+ event: CalendarEvent;
5
+ isBar: boolean;
6
+ continuesBefore?: boolean;
7
+ continuesAfter?: boolean;
8
+ timeZone: string;
9
+ cls: (key: keyof MonthViewClassNames) => string;
10
+ onClick?: (event: CalendarEvent) => void;
11
+ isSelected?: boolean;
12
+ /** When false, renders an inert placeholder that passes pointer events through. Default: true. */
13
+ interactive?: boolean;
14
+ itemRef?: Ref<HTMLElement>;
15
+ /** Grid placement, as primitives so memo can skip unchanged items */
16
+ gridRow?: number;
17
+ gridColumn?: string;
18
+ style?: CSSProperties;
19
+ }
20
+ export declare const MonthEventItem: import('react').NamedExoticComponent<MonthEventItemProps>;
21
+ export {};
22
+ //# sourceMappingURL=MonthEventItem.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthEventItem.d.ts","sourceRoot":"","sources":["../../../src/components/month-view/MonthEventItem.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,aAAa,EAAkB,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAI3E,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE3E,UAAU,mBAAmB;IAC3B,KAAK,EAAE,aAAa,CAAC;IACrB,KAAK,EAAE,OAAO,CAAC;IACf,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,mBAAmB,KAAK,MAAM,CAAC;IAChD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,kGAAkG;IAClG,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,OAAO,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3B,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAMD,eAAO,MAAM,cAAc,2DAyHzB,CAAC"}
@@ -0,0 +1,95 @@
1
+ import { jsxs as x, Fragment as E, jsx as r } from "react/jsx-runtime";
2
+ import { memo as D } from "react";
3
+ import { cn as T } from "../../lib/utils.js";
4
+ import { formatEventStartTime as L } from "../../lib/time.js";
5
+ import { describeEvent as S } from "../../lib/accessibility.js";
6
+ function k(d) {
7
+ return `repeating-linear-gradient(-45deg, ${d}, ${d} 3px, transparent 3px, transparent 6px)`;
8
+ }
9
+ const F = D(function({
10
+ event: t,
11
+ isBar: y,
12
+ continuesBefore: a = !1,
13
+ continuesAfter: c = !1,
14
+ timeZone: p,
15
+ cls: e,
16
+ onClick: N,
17
+ isSelected: m,
18
+ interactive: R = !0,
19
+ itemRef: u,
20
+ gridRow: h,
21
+ gridColumn: g,
22
+ style: f
23
+ }) {
24
+ const C = t.status === "canceled", b = t.status === "tentative", v = C ? { textDecoration: "line-through" } : void 0, o = !t.allDay && !a ? L(t.startTime, p) : null;
25
+ let n, i, s;
26
+ if (y)
27
+ n = T(e("event"), m && e("eventSelected")), i = {
28
+ marginLeft: a ? 0 : 4,
29
+ marginRight: c ? 0 : 4,
30
+ ...a ? { borderTopLeftRadius: 0, borderBottomLeftRadius: 0, paddingLeft: 6 } : {},
31
+ ...c ? { borderTopRightRadius: 0, borderBottomRightRadius: 0 } : {}
32
+ }, s = /* @__PURE__ */ x(E, { children: [
33
+ t.color && !a && /* @__PURE__ */ r(
34
+ "span",
35
+ {
36
+ className: e("eventColorBar"),
37
+ style: {
38
+ borderRadius: "inherit",
39
+ ...b ? { backgroundImage: k(t.color) } : { backgroundColor: t.color }
40
+ }
41
+ }
42
+ ),
43
+ o && /* @__PURE__ */ r("span", { className: e("eventTime"), children: o }),
44
+ /* @__PURE__ */ r("span", { className: e("eventTitle"), style: v, children: t.title })
45
+ ] });
46
+ else {
47
+ const l = t.color ?? "var(--color-cal-text-muted)";
48
+ n = T(e("timedEvent"), m && e("timedEventSelected")), i = { marginLeft: 4, marginRight: 4 }, s = /* @__PURE__ */ x(E, { children: [
49
+ /* @__PURE__ */ r(
50
+ "span",
51
+ {
52
+ className: e("timedEventDot"),
53
+ style: b ? { boxShadow: `inset 0 0 0 1.5px ${l}` } : { backgroundColor: l }
54
+ }
55
+ ),
56
+ o && /* @__PURE__ */ r("span", { className: e("timedEventTime"), children: o }),
57
+ /* @__PURE__ */ r("span", { className: e("timedEventTitle"), style: v, children: t.title })
58
+ ] });
59
+ }
60
+ return R ? /* @__PURE__ */ r(
61
+ "button",
62
+ {
63
+ ref: u,
64
+ type: "button",
65
+ "aria-label": S(t, p, {
66
+ includeStatus: !0,
67
+ includeDate: !0
68
+ }),
69
+ "aria-pressed": m || void 0,
70
+ className: n,
71
+ style: { ...i, gridRow: h, gridColumn: g, ...f },
72
+ onClick: () => N?.(t),
73
+ onMouseDown: (l) => l.stopPropagation(),
74
+ children: s
75
+ }
76
+ ) : /* @__PURE__ */ r(
77
+ "div",
78
+ {
79
+ ref: u,
80
+ "aria-hidden": "true",
81
+ className: n,
82
+ style: {
83
+ ...i,
84
+ gridRow: h,
85
+ gridColumn: g,
86
+ pointerEvents: "none",
87
+ ...f
88
+ },
89
+ children: s
90
+ }
91
+ );
92
+ });
93
+ export {
94
+ F as MonthEventItem
95
+ };
@@ -0,0 +1,22 @@
1
+ import { CSSProperties, ReactNode, Ref, RefObject } from 'react';
2
+ import { Temporal } from 'temporal-polyfill';
3
+ import { CalendarEvent, MonthOverflowClickInfo, MonthOverflowPopoverRenderProps, MonthViewClassNames } from '../../types/calendar';
4
+ interface MonthMoreButtonProps {
5
+ date: Temporal.PlainDate;
6
+ events: CalendarEvent[];
7
+ count: number;
8
+ col: number;
9
+ weekRef: RefObject<HTMLDivElement | null>;
10
+ timeZone: string;
11
+ cls: (key: keyof MonthViewClassNames) => string;
12
+ onEventClick?: (event: CalendarEvent) => void;
13
+ onOverflowClick?: (info: MonthOverflowClickInfo) => void;
14
+ renderOverflowPopover?: (props: MonthOverflowPopoverRenderProps) => ReactNode;
15
+ selectedEventId?: string | null;
16
+ /** Receives the button when it stands in for a hidden selected event. */
17
+ anchorRef?: Ref<HTMLElement>;
18
+ style?: CSSProperties;
19
+ }
20
+ export declare function MonthMoreButton({ date, events, count, col, weekRef, timeZone, cls, onEventClick, onOverflowClick, renderOverflowPopover, selectedEventId, anchorRef, style, }: MonthMoreButtonProps): import("react").JSX.Element;
21
+ export {};
22
+ //# sourceMappingURL=MonthMoreButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthMoreButton.d.ts","sourceRoot":"","sources":["../../../src/components/month-view/MonthMoreButton.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,GAAG,EACR,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG7C,OAAO,KAAK,EACV,aAAa,EACb,sBAAsB,EACtB,+BAA+B,EAC/B,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAM1B,UAAU,oBAAoB;IAC5B,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC;IACzB,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,mBAAmB,KAAK,MAAM,CAAC;IAChD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACzD,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE,+BAA+B,KAAK,SAAS,CAAC;IAC9E,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,yEAAyE;IACzE,SAAS,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;IAC7B,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB;AAOD,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,MAAM,EACN,KAAK,EACL,GAAG,EACH,OAAO,EACP,QAAQ,EACR,GAAG,EACH,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,eAAe,EACf,SAAS,EACT,KAAK,GACN,EAAE,oBAAoB,+BAkItB"}
@@ -0,0 +1,122 @@
1
+ import { jsxs as c, Fragment as M, jsx as a } from "react/jsx-runtime";
2
+ import { useState as I, useRef as O, useCallback as R } from "react";
3
+ import { Temporal as b } from "temporal-polyfill";
4
+ import { formatDayOfWeek as T } from "../../lib/time.js";
5
+ import { getMonthEventSpan as _, DAYS_PER_WEEK as j } from "../../lib/month.js";
6
+ import { AnchoredPopover as H } from "../shared/AnchoredPopover.js";
7
+ import { MonthEventItem as F } from "./MonthEventItem.js";
8
+ const m = 8;
9
+ function G(o, t) {
10
+ typeof o == "function" ? o(t) : o && (o.current = t);
11
+ }
12
+ function X({
13
+ date: o,
14
+ events: t,
15
+ count: p,
16
+ col: C,
17
+ weekRef: D,
18
+ timeZone: f,
19
+ cls: n,
20
+ onEventClick: h,
21
+ onOverflowClick: N,
22
+ renderOverflowPopover: k,
23
+ selectedEventId: v,
24
+ anchorRef: d,
25
+ style: w
26
+ }) {
27
+ const [i, g] = I(!1), s = O(null), x = R(
28
+ (e) => {
29
+ s.current = e, G(d, e);
30
+ },
31
+ [d]
32
+ ), u = R(() => g(!1), []), B = ({
33
+ width: e,
34
+ height: r
35
+ }) => {
36
+ const l = D.current?.getBoundingClientRect();
37
+ if (!l) return null;
38
+ const L = l.width / j, A = l.left + L * (C + 0.5), $ = Math.max(
39
+ m,
40
+ Math.min(
41
+ A - e / 2,
42
+ window.innerWidth - e - m
43
+ )
44
+ );
45
+ return { top: Math.max(
46
+ m,
47
+ Math.min(l.top, window.innerHeight - r - m)
48
+ ), left: $ };
49
+ }, E = () => {
50
+ const e = !i;
51
+ g(e), e && s.current && N?.({ date: o, events: t, anchor: s.current });
52
+ }, S = (e) => {
53
+ h?.(e), u();
54
+ }, W = `${p} more event${p === 1 ? "" : "s"}`, P = o.toLocaleString("en-US", {
55
+ weekday: "long",
56
+ month: "long",
57
+ day: "numeric"
58
+ }), y = i ? k?.({
59
+ date: o,
60
+ events: t,
61
+ onClose: u,
62
+ onEventClick: h
63
+ }) ?? /* @__PURE__ */ c(M, { children: [
64
+ /* @__PURE__ */ c("div", { className: n("morePopoverHeader"), children: [
65
+ /* @__PURE__ */ a("span", { className: n("morePopoverWeekday"), children: T(o) }),
66
+ /* @__PURE__ */ a("span", { className: n("morePopoverDayNumber"), children: o.day })
67
+ ] }),
68
+ /* @__PURE__ */ a("div", { className: n("morePopoverEvents"), children: t.map((e) => {
69
+ const r = _(e, f);
70
+ return /* @__PURE__ */ a(
71
+ F,
72
+ {
73
+ event: e,
74
+ isBar: r.isBar,
75
+ continuesBefore: b.PlainDate.compare(r.startDate, o) < 0,
76
+ continuesAfter: b.PlainDate.compare(r.endDate, o) > 0,
77
+ timeZone: f,
78
+ cls: n,
79
+ onClick: S,
80
+ isSelected: e.id === v,
81
+ style: { height: 22, marginLeft: 0, marginRight: 0 }
82
+ },
83
+ e.id
84
+ );
85
+ }) })
86
+ ] }) : null;
87
+ return /* @__PURE__ */ c(M, { children: [
88
+ /* @__PURE__ */ c(
89
+ "button",
90
+ {
91
+ ref: x,
92
+ type: "button",
93
+ className: n("moreButton"),
94
+ style: { marginLeft: 4, marginRight: 4, ...w },
95
+ "aria-label": `${W} on ${P}`,
96
+ "aria-expanded": i,
97
+ "aria-haspopup": "dialog",
98
+ onMouseDown: (e) => e.stopPropagation(),
99
+ onClick: E,
100
+ children: [
101
+ "+",
102
+ p,
103
+ " more"
104
+ ]
105
+ }
106
+ ),
107
+ i && y && /* @__PURE__ */ a(
108
+ H,
109
+ {
110
+ triggerRef: s,
111
+ onClose: u,
112
+ getPosition: B,
113
+ ariaLabel: P,
114
+ className: n("morePopover"),
115
+ children: y
116
+ }
117
+ )
118
+ ] });
119
+ }
120
+ export {
121
+ X as MonthMoreButton
122
+ };
@@ -0,0 +1,3 @@
1
+ import { MonthViewProps } from '../../types/calendar';
2
+ export declare function MonthView({ month, timeZone, events, weekStartsOn, fixedWeekCount, minWeekHeight, eventHeight, maxEventRows, onEventClick, onDayNumberClick, selectedRange, onSelect, selectionRef, selectionAppearance, selectedEventId, selectedEventRef, onOverflowClick, renderOverflowPopover, renderHeader, className, classNames, }: MonthViewProps): import("react").JSX.Element;
3
+ //# sourceMappingURL=MonthView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthView.d.ts","sourceRoot":"","sources":["../../../src/components/month-view/MonthView.tsx"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,kBAAkB,CAAC;AAkC1B,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,QAAQ,EACR,MAAM,EACN,YAAgB,EAChB,cAAsB,EACtB,aAAmB,EACnB,WAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACb,QAAQ,EACR,YAAY,EACZ,mBAAkD,EAClD,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,SAAS,EACT,UAAU,GACX,EAAE,cAAc,+BA0VhB"}
@@ -0,0 +1,281 @@
1
+ import { jsxs as Q, jsx as T } from "react/jsx-runtime";
2
+ import { useCallback as w, useMemo as i, useRef as d, useState as Z, useLayoutEffect as ee, useEffect as te } from "react";
3
+ import { Temporal as R } from "temporal-polyfill";
4
+ import { cn as ne } from "../../lib/utils.js";
5
+ import { formatDayOfWeek as Me } from "../../lib/time.js";
6
+ import { getMonthWeeks as Re, getMonthEventSpan as Ce, DAYS_PER_WEEK as M, applyMonthOverflow as Ae, layoutMonthWeek as Se } from "../../lib/month.js";
7
+ import { describeEvent as be } from "../../lib/accessibility.js";
8
+ import { clipDateSpan as _e } from "../../lib/lanes.js";
9
+ import { useAnnouncer as We } from "../shared/useAnnouncer.js";
10
+ import { monthViewDefaults as Oe } from "./defaults.js";
11
+ import { MonthWeekRow as Pe, DAY_HEADER_HEIGHT as xe, LANE_GAP as re } from "./MonthWeekRow.js";
12
+ const Ne = 2, Te = "__month-view-selection__", Ie = { style: "event" };
13
+ function oe(o, a) {
14
+ return R.PlainDate.compare(o, a) <= 0 ? { startDate: o, endDate: a } : { startDate: a, endDate: o };
15
+ }
16
+ function ae(o, a) {
17
+ const l = o && _e(o.startDate, o.endDate, a);
18
+ return l ? { startCol: l.startCol, endCol: l.startCol + l.span - 1 } : null;
19
+ }
20
+ function qe({
21
+ month: o,
22
+ timeZone: a,
23
+ events: l,
24
+ weekStartsOn: I = 7,
25
+ fixedWeekCount: $ = !1,
26
+ minWeekHeight: H = 100,
27
+ eventHeight: U = 20,
28
+ maxEventRows: se,
29
+ onEventClick: B,
30
+ onDayNumberClick: ce,
31
+ selectedRange: m,
32
+ onSelect: c,
33
+ selectionRef: ie,
34
+ selectionAppearance: K = Ie,
35
+ selectedEventId: f,
36
+ selectedEventRef: le,
37
+ onOverflowClick: ue,
38
+ renderOverflowPopover: de,
39
+ renderHeader: G,
40
+ className: me,
41
+ classNames: Y
42
+ }) {
43
+ const y = w(
44
+ (e) => ne(Oe[e], Y?.[e]),
45
+ [Y]
46
+ ), he = i(
47
+ () => R.Now.plainDateISO(a).toString(),
48
+ [a]
49
+ ), s = i(
50
+ () => Re(o, I, $),
51
+ [o, I, $]
52
+ ), C = d(null), [fe, pe] = Z(H);
53
+ ee(() => {
54
+ const e = C.current?.querySelector("[data-month-week]");
55
+ if (!e) return;
56
+ const t = () => pe(e.getBoundingClientRect().height);
57
+ t();
58
+ const n = new ResizeObserver(t);
59
+ return n.observe(e), () => n.disconnect();
60
+ }, [s]);
61
+ const A = Math.max(
62
+ 1,
63
+ Math.min(
64
+ se ?? 1 / 0,
65
+ Math.floor(
66
+ (fe - xe - re - Ne) / (U + re)
67
+ )
68
+ )
69
+ ), S = i(
70
+ () => l.map((e) => Ce(e, a)),
71
+ [l, a]
72
+ ), { message: ge, announce: E } = We(), De = w(
73
+ (e) => {
74
+ c?.(null), B?.(e), E(
75
+ `Selected: ${be(e, a, { includeDate: !0 })}`
76
+ );
77
+ },
78
+ [c, B, a, E]
79
+ ), [b, _] = Z(null), k = d(null), h = d(null), j = d(s), F = d(c), V = d(E), W = w((e) => {
80
+ const t = k.current, n = C.current;
81
+ if (!t || !n) return;
82
+ const r = document.elementFromPoint(e.clientX, e.clientY)?.closest("[data-month-week]");
83
+ if (!r || !n.contains(r)) return;
84
+ const u = j.current[Number(r.dataset.monthWeek)];
85
+ if (!u) return;
86
+ const L = r.getBoundingClientRect(), Le = Math.min(
87
+ M - 1,
88
+ Math.max(
89
+ 0,
90
+ Math.floor((e.clientX - L.left) / (L.width / M))
91
+ )
92
+ ), N = u[Le];
93
+ h.current && R.PlainDate.compare(h.current, N) === 0 || (h.current = N, _(oe(t, N)));
94
+ }, []), p = d(() => {
95
+ }), O = w(() => {
96
+ const e = k.current, t = h.current;
97
+ if (p.current(), !e || !t) return;
98
+ const n = oe(e, t);
99
+ F.current?.(n);
100
+ const r = n.startDate.toLocaleString("en-US", {
101
+ month: "long",
102
+ day: "numeric"
103
+ }), u = n.endDate.toLocaleString("en-US", {
104
+ month: "long",
105
+ day: "numeric"
106
+ });
107
+ V.current(
108
+ R.PlainDate.compare(n.startDate, n.endDate) === 0 ? `Selected ${r}` : `Selected ${r} to ${u}`
109
+ );
110
+ }, []);
111
+ ee(() => {
112
+ j.current = s, F.current = c, V.current = E;
113
+ }), te(() => () => p.current(), []);
114
+ const ve = w(
115
+ (e, t) => {
116
+ if (!c || t.button !== 0 || t.ctrlKey) return;
117
+ t.preventDefault(), c(null), k.current = e, h.current = e, _({ startDate: e, endDate: e });
118
+ const n = (r) => {
119
+ r.key === "Escape" && p.current();
120
+ };
121
+ p.current = () => {
122
+ k.current = null, h.current = null, _(null), document.removeEventListener("mousemove", W), document.removeEventListener("mouseup", O), document.removeEventListener("keydown", n), p.current = () => {
123
+ };
124
+ }, document.addEventListener("mousemove", W), document.addEventListener("mouseup", O), document.addEventListener("keydown", n);
125
+ },
126
+ [c, W, O]
127
+ );
128
+ te(() => {
129
+ if (!m || !c) return;
130
+ const e = (t) => {
131
+ t.key === "Escape" && c(null);
132
+ };
133
+ return document.addEventListener("keydown", e), () => document.removeEventListener("keydown", e);
134
+ }, [m, c]);
135
+ const g = b ?? m, D = K === "highlight", P = D ? void 0 : K.eventData, X = P?.title, q = P?.color, z = P?.status, we = i(
136
+ () => s.map(
137
+ (e) => D ? ae(g, e) : null
138
+ ),
139
+ [s, g, D]
140
+ ), ye = i(() => {
141
+ if (b || !m) return -1;
142
+ for (let e = s.length - 1; e >= 0; e--)
143
+ if (ae(m, s[e])) return e;
144
+ return -1;
145
+ }, [b, m, s]), x = i(() => {
146
+ if (!g || D) return null;
147
+ const { startDate: e, endDate: t } = g;
148
+ return {
149
+ event: {
150
+ title: X ?? "(No title)",
151
+ color: q,
152
+ status: z,
153
+ id: Te,
154
+ resourceId: "",
155
+ allDay: !0,
156
+ startDate: e,
157
+ endDate: t
158
+ },
159
+ startDate: e,
160
+ endDate: t,
161
+ isBar: !0,
162
+ sortStart: 0,
163
+ pinned: !0
164
+ };
165
+ }, [
166
+ g,
167
+ D,
168
+ X,
169
+ q,
170
+ z
171
+ ]), J = i(
172
+ () => x ? [...S, x] : S,
173
+ [S, x]
174
+ ), v = i(
175
+ () => s.map(
176
+ (e) => Ae(Se(J, e), e, A)
177
+ ),
178
+ [s, J, A]
179
+ ), Ee = i(() => {
180
+ const e = /* @__PURE__ */ new Map();
181
+ if (!f) return e;
182
+ const t = v.findIndex(
183
+ (n) => n.visibleSegments.some((r) => r.event.id === f)
184
+ );
185
+ if (t !== -1)
186
+ return e.set(t, { kind: "segment" }), e;
187
+ for (let n = 0; n < v.length; n++) {
188
+ const r = v[n].days.findIndex(
189
+ (u) => u.moreCount > 0 && u.events.some((L) => L.id === f)
190
+ );
191
+ if (r !== -1) {
192
+ e.set(n, { kind: "more", col: r });
193
+ break;
194
+ }
195
+ }
196
+ return e;
197
+ }, [v, f]), ke = i(
198
+ () => o.toPlainDate({ day: 1 }).toLocaleString("en-US", { month: "long", year: "numeric" }),
199
+ [o]
200
+ );
201
+ return /* @__PURE__ */ Q("div", { className: ne(y("root"), me), children: [
202
+ /* @__PURE__ */ Q(
203
+ "div",
204
+ {
205
+ ref: C,
206
+ className: y("grid"),
207
+ role: "region",
208
+ "aria-roledescription": "calendar",
209
+ "aria-label": ke,
210
+ style: {
211
+ display: "grid",
212
+ gridTemplateColumns: `repeat(${M}, minmax(0, 1fr))`,
213
+ gridTemplateRows: `auto repeat(${s.length}, minmax(${H}px, 1fr))`
214
+ },
215
+ children: [
216
+ s[0].map((e, t) => /* @__PURE__ */ T(
217
+ "div",
218
+ {
219
+ role: "columnheader",
220
+ className: y("headerCell"),
221
+ style: {
222
+ gridRow: 1,
223
+ gridColumn: t + 1,
224
+ ...t === M - 1 ? { borderRightWidth: 0 } : {}
225
+ },
226
+ children: G ? G({ dayOfWeek: e.dayOfWeek, date: e }) : Me(e)
227
+ },
228
+ e.dayOfWeek
229
+ )),
230
+ v.map((e, t) => /* @__PURE__ */ T(
231
+ Pe,
232
+ {
233
+ weekIndex: t,
234
+ layout: e,
235
+ month: o,
236
+ todayStr: he,
237
+ lanes: A,
238
+ eventHeight: U,
239
+ timeZone: a,
240
+ cls: y,
241
+ onEventClick: De,
242
+ onDayNumberClick: ce,
243
+ onCellMouseDown: c ? ve : void 0,
244
+ onOverflowClick: ue,
245
+ renderOverflowPopover: de,
246
+ highlight: we[t],
247
+ selectionRef: t === ye ? ie : void 0,
248
+ selectedEventId: f,
249
+ selectedEventAnchor: Ee.get(t) ?? null,
250
+ selectedEventRef: le
251
+ },
252
+ e.dates[0].toString()
253
+ ))
254
+ ]
255
+ }
256
+ ),
257
+ /* @__PURE__ */ T(
258
+ "div",
259
+ {
260
+ "aria-live": "polite",
261
+ "aria-atomic": "true",
262
+ role: "status",
263
+ style: {
264
+ position: "absolute",
265
+ width: 1,
266
+ height: 1,
267
+ padding: 0,
268
+ margin: -1,
269
+ overflow: "hidden",
270
+ clip: "rect(0, 0, 0, 0)",
271
+ whiteSpace: "nowrap",
272
+ borderWidth: 0
273
+ },
274
+ children: ge
275
+ }
276
+ )
277
+ ] });
278
+ }
279
+ export {
280
+ qe as MonthView
281
+ };
@@ -0,0 +1,40 @@
1
+ import { ReactNode, Ref } from 'react';
2
+ import { Temporal } from 'temporal-polyfill';
3
+ import { MonthWeekLayout } from '../../lib/month';
4
+ import { CalendarEvent, MonthOverflowClickInfo, MonthOverflowPopoverRenderProps, MonthViewClassNames } from '../../types/calendar';
5
+ export declare const DAY_HEADER_HEIGHT = 28;
6
+ export declare const LANE_GAP = 2;
7
+ export type SelectedEventAnchor = {
8
+ kind: 'segment';
9
+ } | {
10
+ kind: 'more';
11
+ col: number;
12
+ };
13
+ interface MonthWeekRowProps {
14
+ weekIndex: number;
15
+ layout: MonthWeekLayout;
16
+ month: Temporal.PlainYearMonth;
17
+ todayStr: string;
18
+ lanes: number;
19
+ eventHeight: number;
20
+ timeZone: string;
21
+ cls: (key: keyof MonthViewClassNames) => string;
22
+ onEventClick?: (event: CalendarEvent) => void;
23
+ onDayNumberClick?: (date: Temporal.PlainDate) => void;
24
+ onCellMouseDown?: (date: Temporal.PlainDate, e: React.MouseEvent) => void;
25
+ onOverflowClick?: (info: MonthOverflowClickInfo) => void;
26
+ renderOverflowPopover?: (props: MonthOverflowPopoverRenderProps) => ReactNode;
27
+ /** Inclusive columns to highlight in this week ('highlight' selection appearance). */
28
+ highlight?: {
29
+ startCol: number;
30
+ endCol: number;
31
+ } | null;
32
+ /** Attached to the highlight, or to the selection placeholder bar. */
33
+ selectionRef?: Ref<HTMLDivElement>;
34
+ selectedEventId?: string | null;
35
+ selectedEventAnchor?: SelectedEventAnchor | null;
36
+ selectedEventRef?: Ref<HTMLElement>;
37
+ }
38
+ export declare const MonthWeekRow: import('react').NamedExoticComponent<MonthWeekRowProps>;
39
+ export {};
40
+ //# sourceMappingURL=MonthWeekRow.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthWeekRow.d.ts","sourceRoot":"","sources":["../../../src/components/month-view/MonthWeekRow.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,SAAS,EAAE,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAC/D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EAAiB,KAAK,eAAe,EAAE,MAAM,aAAa,CAAC;AAElE,OAAO,KAAK,EACV,aAAa,EACb,sBAAsB,EACtB,+BAA+B,EAC/B,mBAAmB,EACpB,MAAM,kBAAkB,CAAC;AAK1B,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,QAAQ,IAAI,CAAC;AAE1B,MAAM,MAAM,mBAAmB,GAC7B;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtD,UAAU,iBAAiB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,eAAe,CAAC;IACxB,KAAK,EAAE,QAAQ,CAAC,cAAc,CAAC;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,mBAAmB,KAAK,MAAM,CAAC;IAChD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,KAAK,IAAI,CAAC;IACtD,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAC1E,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,sBAAsB,KAAK,IAAI,CAAC;IACzD,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE,+BAA+B,KAAK,SAAS,CAAC;IAC9E,sFAAsF;IACtF,SAAS,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IACxD,sEAAsE;IACtE,YAAY,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACnC,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,mBAAmB,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACjD,gBAAgB,CAAC,EAAE,GAAG,CAAC,WAAW,CAAC,CAAC;CACrC;AAED,eAAO,MAAM,YAAY,yDA4MvB,CAAC"}