@savvycal/calendar 0.1.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 (66) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +472 -0
  3. package/dist/components/resource-grid-view/AllDayRow.d.ts +12 -0
  4. package/dist/components/resource-grid-view/AllDayRow.d.ts.map +1 -0
  5. package/dist/components/resource-grid-view/AllDayRow.js +54 -0
  6. package/dist/components/resource-grid-view/EventChip.d.ts +22 -0
  7. package/dist/components/resource-grid-view/EventChip.d.ts.map +1 -0
  8. package/dist/components/resource-grid-view/EventChip.js +112 -0
  9. package/dist/components/resource-grid-view/GridHeader.d.ts +13 -0
  10. package/dist/components/resource-grid-view/GridHeader.d.ts.map +1 -0
  11. package/dist/components/resource-grid-view/GridHeader.js +31 -0
  12. package/dist/components/resource-grid-view/NowIndicator.d.ts +13 -0
  13. package/dist/components/resource-grid-view/NowIndicator.d.ts.map +1 -0
  14. package/dist/components/resource-grid-view/NowIndicator.js +43 -0
  15. package/dist/components/resource-grid-view/ResourceColumn.d.ts +22 -0
  16. package/dist/components/resource-grid-view/ResourceColumn.d.ts.map +1 -0
  17. package/dist/components/resource-grid-view/ResourceColumn.js +52 -0
  18. package/dist/components/resource-grid-view/ResourceGridView.d.ts +3 -0
  19. package/dist/components/resource-grid-view/ResourceGridView.d.ts.map +1 -0
  20. package/dist/components/resource-grid-view/ResourceGridView.js +342 -0
  21. package/dist/components/resource-grid-view/SelectionOverlay.d.ts +22 -0
  22. package/dist/components/resource-grid-view/SelectionOverlay.d.ts.map +1 -0
  23. package/dist/components/resource-grid-view/SelectionOverlay.js +87 -0
  24. package/dist/components/resource-grid-view/SlotInteractionLayer.d.ts +28 -0
  25. package/dist/components/resource-grid-view/SlotInteractionLayer.d.ts.map +1 -0
  26. package/dist/components/resource-grid-view/SlotInteractionLayer.js +213 -0
  27. package/dist/components/resource-grid-view/TimeGutter.d.ts +11 -0
  28. package/dist/components/resource-grid-view/TimeGutter.d.ts.map +1 -0
  29. package/dist/components/resource-grid-view/TimeGutter.js +25 -0
  30. package/dist/components/resource-grid-view/UnavailabilityOverlay.d.ts +10 -0
  31. package/dist/components/resource-grid-view/UnavailabilityOverlay.d.ts.map +1 -0
  32. package/dist/components/resource-grid-view/UnavailabilityOverlay.js +37 -0
  33. package/dist/components/resource-grid-view/defaults.d.ts +3 -0
  34. package/dist/components/resource-grid-view/defaults.d.ts.map +1 -0
  35. package/dist/components/resource-grid-view/defaults.js +28 -0
  36. package/dist/components/resource-grid-view/index.d.ts +3 -0
  37. package/dist/components/resource-grid-view/index.d.ts.map +1 -0
  38. package/dist/components/resource-grid-view/useAnnouncer.d.ts +5 -0
  39. package/dist/components/resource-grid-view/useAnnouncer.d.ts.map +1 -0
  40. package/dist/components/resource-grid-view/useAnnouncer.js +12 -0
  41. package/dist/components/resource-grid-view/useEffectiveHourHeight.d.ts +15 -0
  42. package/dist/components/resource-grid-view/useEffectiveHourHeight.d.ts.map +1 -0
  43. package/dist/components/resource-grid-view/useEffectiveHourHeight.js +20 -0
  44. package/dist/components.css +31 -0
  45. package/dist/index.d.ts +6 -0
  46. package/dist/index.d.ts.map +1 -0
  47. package/dist/index.js +10 -0
  48. package/dist/lib/availability.d.ts +12 -0
  49. package/dist/lib/availability.d.ts.map +1 -0
  50. package/dist/lib/availability.js +56 -0
  51. package/dist/lib/overlap.d.ts +16 -0
  52. package/dist/lib/overlap.d.ts.map +1 -0
  53. package/dist/lib/overlap.js +80 -0
  54. package/dist/lib/selection.d.ts +4 -0
  55. package/dist/lib/selection.d.ts.map +1 -0
  56. package/dist/lib/selection.js +14 -0
  57. package/dist/lib/time.d.ts +21 -0
  58. package/dist/lib/time.d.ts.map +1 -0
  59. package/dist/lib/time.js +52 -0
  60. package/dist/lib/utils.d.ts +3 -0
  61. package/dist/lib/utils.d.ts.map +1 -0
  62. package/dist/lib/utils.js +8 -0
  63. package/dist/preset.css +93 -0
  64. package/dist/types/calendar.d.ts +128 -0
  65. package/dist/types/calendar.d.ts.map +1 -0
  66. package/package.json +60 -0
@@ -0,0 +1,112 @@
1
+ import { jsx as i, jsxs as v, Fragment as L } 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
+ const J = P(function({
6
+ positioned: h,
7
+ resource: k,
8
+ timeZone: f,
9
+ cls: n,
10
+ onClick: x,
11
+ renderEvent: N,
12
+ interactive: o = !0,
13
+ eventGap: w = 2,
14
+ eventLayout: E = "columns",
15
+ stackOffset: T = 8,
16
+ isSelected: g,
17
+ selectedEventRef: $
18
+ }) {
19
+ const { event: e, top: b, height: r, subColumn: s, totalSubColumns: a } = h, l = e.color ?? k.color ?? void 0;
20
+ let c, m, d;
21
+ if (E === "stacked") {
22
+ const t = (a - 1) * T;
23
+ c = s > 0 ? `${s * T}px` : "0", m = t > 0 ? `calc(100% - ${t}px)` : "100%", d = s + 1;
24
+ } else {
25
+ const t = s / a * 100, C = 1 / a * 100, y = w, I = s * y / a, u = (a - 1) * y / a;
26
+ c = u ? `calc(${t}% + ${I}px)` : `${t}%`, m = u ? `calc(${C}% - ${u}px)` : `${C}%`;
27
+ }
28
+ g && (d = 10);
29
+ const S = r >= 36, j = r >= 52, D = e.status === "canceled";
30
+ if (N)
31
+ return /* @__PURE__ */ i(
32
+ "div",
33
+ {
34
+ ref: $,
35
+ style: {
36
+ position: "absolute",
37
+ top: b,
38
+ height: r,
39
+ left: c,
40
+ width: m,
41
+ zIndex: d,
42
+ pointerEvents: o ? "auto" : "none"
43
+ },
44
+ children: N({ event: e, position: h })
45
+ }
46
+ );
47
+ const p = B(e.startTime, f), F = o ? (() => {
48
+ const t = [
49
+ e.title,
50
+ K(e.startTime, e.endTime, f)
51
+ ];
52
+ return e.clientName && t.push(e.clientName), e.status === "canceled" ? t.push("canceled") : e.status === "tentative" && t.push("tentative"), t.join(", ");
53
+ })() : void 0;
54
+ return /* @__PURE__ */ v(
55
+ "div",
56
+ {
57
+ ref: $,
58
+ ...o ? { role: "button", tabIndex: 0, "aria-label": F } : {},
59
+ className: z(n("event"), g && n("eventSelected")),
60
+ style: {
61
+ top: b,
62
+ height: r,
63
+ left: c,
64
+ width: m,
65
+ zIndex: d,
66
+ pointerEvents: o ? "auto" : "none"
67
+ },
68
+ ...o ? {
69
+ onClick: () => x?.(e),
70
+ onKeyDown: (t) => {
71
+ (t.key === "Enter" || t.key === " ") && (t.preventDefault(), x?.(e));
72
+ }
73
+ } : {},
74
+ children: [
75
+ l && /* @__PURE__ */ i(
76
+ "div",
77
+ {
78
+ className: n("eventColorBar"),
79
+ style: e.status === "tentative" ? {
80
+ backgroundImage: `repeating-linear-gradient(
81
+ -45deg,
82
+ ${l},
83
+ ${l} 3px,
84
+ transparent 3px,
85
+ transparent 6px
86
+ )`
87
+ } : { backgroundColor: l }
88
+ }
89
+ ),
90
+ /* @__PURE__ */ i(
91
+ "div",
92
+ {
93
+ className: n("eventTitle"),
94
+ style: D ? { textDecoration: "line-through" } : void 0,
95
+ children: e.title
96
+ }
97
+ ),
98
+ S && (j ? /* @__PURE__ */ v(L, { children: [
99
+ /* @__PURE__ */ i("div", { className: n("eventTime"), children: p }),
100
+ e.clientName && /* @__PURE__ */ i("div", { className: n("eventClientName"), children: e.clientName })
101
+ ] }) : e.clientName ? /* @__PURE__ */ v("div", { className: n("eventTime"), children: [
102
+ p,
103
+ ", ",
104
+ e.clientName
105
+ ] }) : /* @__PURE__ */ i("div", { className: n("eventTime"), children: p }))
106
+ ]
107
+ }
108
+ );
109
+ });
110
+ export {
111
+ J as EventChip
112
+ };
@@ -0,0 +1,13 @@
1
+ import { ReactNode } from 'react';
2
+ import { CalendarResource, ResourceGridViewClassNames } from '../../types/calendar';
3
+ interface GridHeaderProps {
4
+ resource: CalendarResource;
5
+ column: number;
6
+ cls: (key: keyof ResourceGridViewClassNames) => string;
7
+ renderHeader?: (props: {
8
+ resource: CalendarResource;
9
+ }) => ReactNode;
10
+ }
11
+ export declare const GridHeader: import('react').NamedExoticComponent<GridHeaderProps>;
12
+ export {};
13
+ //# sourceMappingURL=GridHeader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GridHeader.d.ts","sourceRoot":"","sources":["../../../src/components/resource-grid-view/GridHeader.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,kBAAkB,CAAC;AAE1B,UAAU,eAAe;IACvB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,0BAA0B,KAAK,MAAM,CAAC;IACvD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,QAAQ,EAAE,gBAAgB,CAAA;KAAE,KAAK,SAAS,CAAC;CACrE;AAED,eAAO,MAAM,UAAU,uDA4BrB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { jsx as e, jsxs as d, Fragment as i } from "react/jsx-runtime";
2
+ import { memo as t } from "react";
3
+ const h = t(function({
4
+ resource: a,
5
+ column: l,
6
+ cls: r,
7
+ renderHeader: m
8
+ }) {
9
+ return /* @__PURE__ */ e(
10
+ "div",
11
+ {
12
+ role: "columnheader",
13
+ className: r("headerCell"),
14
+ style: { gridRow: 1, gridColumn: l },
15
+ children: m ? m({ resource: a }) : /* @__PURE__ */ d(i, { children: [
16
+ a.avatarUrl && /* @__PURE__ */ e(
17
+ "img",
18
+ {
19
+ src: a.avatarUrl,
20
+ alt: "",
21
+ className: r("headerAvatar")
22
+ }
23
+ ),
24
+ /* @__PURE__ */ e("span", { className: r("headerName"), children: a.name })
25
+ ] })
26
+ }
27
+ );
28
+ });
29
+ export {
30
+ h as GridHeader
31
+ };
@@ -0,0 +1,13 @@
1
+ import { Temporal } from 'temporal-polyfill';
2
+ import { ResourceGridViewClassNames } from '../../types/calendar';
3
+ interface NowIndicatorProps {
4
+ date: Temporal.PlainDate;
5
+ timeZone: string;
6
+ startHour: number;
7
+ endHour: number;
8
+ hourHeight: number;
9
+ cls: (key: keyof ResourceGridViewClassNames) => string;
10
+ }
11
+ export declare const NowIndicator: import('react').NamedExoticComponent<NowIndicatorProps>;
12
+ export {};
13
+ //# sourceMappingURL=NowIndicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NowIndicator.d.ts","sourceRoot":"","sources":["../../../src/components/resource-grid-view/NowIndicator.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAC;AAEnE,UAAU,iBAAiB;IACzB,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC;IACzB,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,0BAA0B,KAAK,MAAM,CAAC;CACxD;AA0BD,eAAO,MAAM,YAAY,yDAuCvB,CAAC"}
@@ -0,0 +1,43 @@
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import { memo as p, useState as I, useEffect as v } from "react";
3
+ import { Temporal as c } from "temporal-polyfill";
4
+ function w(e, n) {
5
+ const t = c.Now.plainDateISO(n);
6
+ return c.PlainDate.compare(t, e) === 0;
7
+ }
8
+ function T(e, n, t, s) {
9
+ const r = c.Now.zonedDateTimeISO(e), o = r.hour * 60 + r.minute, i = n * 60, a = t * 60;
10
+ return o < i || o >= a ? null : (o - i) / 60 * s;
11
+ }
12
+ const M = p(function({
13
+ date: n,
14
+ timeZone: t,
15
+ startHour: s,
16
+ endHour: r,
17
+ hourHeight: o,
18
+ cls: i
19
+ }) {
20
+ const [, a] = I(0), u = w(n, t), l = u ? T(t, s, r, o) : null;
21
+ return v(() => {
22
+ if (!u) return;
23
+ const f = setInterval(() => {
24
+ a((m) => m + 1);
25
+ }, 6e4);
26
+ return () => clearInterval(f);
27
+ }, [u]), l === null ? null : /* @__PURE__ */ d(
28
+ "div",
29
+ {
30
+ "aria-hidden": "true",
31
+ style: {
32
+ gridRow: "3 / -1",
33
+ gridColumn: "1 / -1",
34
+ position: "relative",
35
+ pointerEvents: "none"
36
+ },
37
+ children: /* @__PURE__ */ d("div", { className: i("nowIndicator"), style: { top: l } })
38
+ }
39
+ );
40
+ });
41
+ export {
42
+ M as NowIndicator
43
+ };
@@ -0,0 +1,22 @@
1
+ import { Ref } from 'react';
2
+ import { CalendarEvent, CalendarResource, EventLayout, PositionedEvent, ResourceGridViewClassNames, TimedCalendarEvent } from '../../types/calendar';
3
+ interface ResourceColumnProps {
4
+ resource: CalendarResource;
5
+ positionedEvents: PositionedEvent[];
6
+ column: number;
7
+ timeZone: string;
8
+ cls: (key: keyof ResourceGridViewClassNames) => 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
+ }
20
+ export declare const ResourceColumn: import('react').NamedExoticComponent<ResourceColumnProps>;
21
+ export {};
22
+ //# sourceMappingURL=ResourceColumn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResourceColumn.d.ts","sourceRoot":"","sources":["../../../src/components/resource-grid-view/ResourceColumn.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,eAAe,EACf,0BAA0B,EAC1B,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAG1B,UAAU,mBAAmB;IAC3B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,0BAA0B,KAAK,MAAM,CAAC;IACvD,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;CACxC;AAED,eAAO,MAAM,cAAc,2DA4CzB,CAAC"}
@@ -0,0 +1,52 @@
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { memo as p } from "react";
3
+ import { EventChip as R } from "./EventChip.js";
4
+ const x = p(function({
5
+ resource: t,
6
+ positionedEvents: m,
7
+ column: i,
8
+ timeZone: c,
9
+ cls: n,
10
+ onEventClick: l,
11
+ renderEvent: u,
12
+ eventGap: s,
13
+ eventLayout: v,
14
+ stackOffset: d,
15
+ selectedEventId: C,
16
+ selectedEventRef: f
17
+ }) {
18
+ return /* @__PURE__ */ r(
19
+ "div",
20
+ {
21
+ className: n("eventColumn"),
22
+ style: {
23
+ gridRow: "3 / -1",
24
+ gridColumn: i,
25
+ pointerEvents: "none"
26
+ },
27
+ children: m.map((e) => {
28
+ const o = e.event.id === C;
29
+ return /* @__PURE__ */ r(
30
+ R,
31
+ {
32
+ positioned: e,
33
+ resource: t,
34
+ timeZone: c,
35
+ cls: n,
36
+ onClick: l,
37
+ renderEvent: u,
38
+ eventGap: s,
39
+ eventLayout: v,
40
+ stackOffset: d,
41
+ isSelected: o,
42
+ selectedEventRef: o ? f : void 0
43
+ },
44
+ e.event.id
45
+ );
46
+ })
47
+ }
48
+ );
49
+ });
50
+ export {
51
+ x as ResourceColumn
52
+ };
@@ -0,0 +1,3 @@
1
+ import { ResourceGridViewProps } from '../../types/calendar';
2
+ export declare function ResourceGridView({ date, timeZone, resources, events, availability, unavailability, timeAxis, onEventClick, snapDuration, placeholderDuration, selectedRange, onSelect, onSlotClick, className, classNames, hourHeight, columnMinWidth, renderHeader, renderEvent, selectionAppearance, dragPreviewAppearance, selectionRef, selectedEventId, selectedEventRef, renderCorner, eventGap, eventLayout, stackOffset, }: ResourceGridViewProps): import("react/jsx-runtime").JSX.Element;
3
+ //# sourceMappingURL=ResourceGridView.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ResourceGridView.d.ts","sourceRoot":"","sources":["../../../src/components/resource-grid-view/ResourceGridView.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAIV,qBAAqB,EAGtB,MAAM,kBAAkB,CAAC;AAa1B,wBAAgB,gBAAgB,CAAC,EAC/B,IAAI,EACJ,QAAQ,EACR,SAAS,EACT,MAAM,EACN,YAAY,EACZ,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACV,UAAe,EACf,cAAoB,EACpB,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,qBAAqB,EACrB,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,QAAQ,EACR,WAAuB,EACvB,WAAe,GAChB,EAAE,qBAAqB,2CAkWvB"}
@@ -0,0 +1,342 @@
1
+ import { jsxs as M, jsx as n } from "react/jsx-runtime";
2
+ import { useCallback as D, useMemo as p, useEffect as no } from "react";
3
+ import { cn as R } from "../../lib/utils.js";
4
+ import { generateTimeSlots as lo, formatDateLabel as ao, formatTimeRange as B } from "../../lib/time.js";
5
+ import { groupByResource as mo, computePositionedEvents as so } from "../../lib/overlap.js";
6
+ import { computeUnavailableBlocks as co } from "../../lib/availability.js";
7
+ import { resourceGridViewDefaults as uo } from "./defaults.js";
8
+ import { GridHeader as po } from "./GridHeader.js";
9
+ import { TimeGutter as fo } from "./TimeGutter.js";
10
+ import { ResourceColumn as ho } from "./ResourceColumn.js";
11
+ import { SlotInteractionLayer as go } from "./SlotInteractionLayer.js";
12
+ import { SelectionOverlay as yo } from "./SelectionOverlay.js";
13
+ import { UnavailabilityOverlay as wo } from "./UnavailabilityOverlay.js";
14
+ import { NowIndicator as Ho } from "./NowIndicator.js";
15
+ import { AllDayRow as bo } from "./AllDayRow.js";
16
+ import { useEffectiveHourHeight as Co } from "./useEffectiveHourHeight.js";
17
+ import { useAnnouncer as Do } from "./useAnnouncer.js";
18
+ function Uo({
19
+ date: d,
20
+ timeZone: l,
21
+ resources: i,
22
+ events: $,
23
+ availability: g,
24
+ unavailability: y,
25
+ timeAxis: w,
26
+ onEventClick: v,
27
+ snapDuration: x,
28
+ placeholderDuration: L,
29
+ selectedRange: f,
30
+ onSelect: c,
31
+ onSlotClick: G,
32
+ className: O,
33
+ classNames: S,
34
+ hourHeight: W = 60,
35
+ columnMinWidth: U = 120,
36
+ renderHeader: V,
37
+ renderEvent: H,
38
+ selectionAppearance: z,
39
+ dragPreviewAppearance: A,
40
+ selectionRef: F,
41
+ selectedEventId: T,
42
+ selectedEventRef: k,
43
+ renderCorner: K,
44
+ eventGap: P,
45
+ eventLayout: q = "columns",
46
+ stackOffset: J = 8
47
+ }) {
48
+ const a = w?.startHour ?? 0, m = w?.endHour ?? 24, b = w?.intervalMinutes ?? 60, { effectiveHourHeight: s, rootRef: Q, headerRef: X, allDayRef: Y, headerHeight: N } = Co(W, m - a), e = D(
49
+ (o) => R(uo[o], S?.[o]),
50
+ [S]
51
+ ), C = p(
52
+ () => lo({ startHour: a, endHour: m, intervalMinutes: b }),
53
+ [a, m, b]
54
+ ), { allDayEvents: E, timedEvents: j } = p(() => {
55
+ const o = [], r = [];
56
+ for (const t of $)
57
+ t.allDay ? o.push(t) : r.push(t);
58
+ return { allDayEvents: o, timedEvents: r };
59
+ }, [$]), _ = p(
60
+ () => mo(E),
61
+ [E]
62
+ ), Z = p(
63
+ () => so(
64
+ j,
65
+ l,
66
+ d,
67
+ a,
68
+ m,
69
+ s
70
+ ),
71
+ [j, l, d, a, m, s]
72
+ ), oo = p(() => {
73
+ if (!g && !y)
74
+ return /* @__PURE__ */ new Map();
75
+ const o = /* @__PURE__ */ new Set([
76
+ ...Object.keys(g ?? {}),
77
+ ...Object.keys(y ?? {})
78
+ ]), r = /* @__PURE__ */ new Map();
79
+ for (const t of o) {
80
+ const u = co(
81
+ g?.[t],
82
+ y?.[t],
83
+ l,
84
+ d,
85
+ a,
86
+ m,
87
+ s
88
+ );
89
+ u.length > 0 && r.set(t, u);
90
+ }
91
+ return r;
92
+ }, [
93
+ g,
94
+ y,
95
+ l,
96
+ d,
97
+ a,
98
+ m,
99
+ s
100
+ ]), { message: ro, announce: h } = Do(), to = p(
101
+ () => `Schedule for ${ao(d)}`,
102
+ [d]
103
+ ), I = D(
104
+ (o) => {
105
+ if (c?.(null), v?.(o), o.allDay) {
106
+ const r = [o.title, "all day"];
107
+ o.clientName && r.push(o.clientName), h(`Selected: ${r.join(", ")}`);
108
+ } else {
109
+ const r = [
110
+ o.title,
111
+ B(o.startTime, o.endTime, l)
112
+ ];
113
+ o.clientName && r.push(o.clientName);
114
+ const t = i.find((u) => u.id === o.resourceId);
115
+ t && r.push(t.name), h(`Selected: ${r.join(", ")}`);
116
+ }
117
+ },
118
+ [c, v, l, i, h]
119
+ ), io = D(
120
+ (o) => {
121
+ if (c?.(o), o) {
122
+ const r = [
123
+ B(o.startTime, o.endTime, l)
124
+ ], t = i.find((u) => u.id === o.resourceId);
125
+ t && r.push(t.name), h(`Selected time: ${r.join(", ")}`);
126
+ }
127
+ },
128
+ [c, l, i, h]
129
+ );
130
+ no(() => {
131
+ if (!f || !c) return;
132
+ const o = (r) => {
133
+ r.key === "Escape" && c(null);
134
+ };
135
+ return document.addEventListener("keydown", o), () => document.removeEventListener("keydown", o);
136
+ }, [f, c]);
137
+ const eo = s * b / 60;
138
+ return /* @__PURE__ */ M("div", { ref: Q, className: R(e("root"), O), children: [
139
+ /* @__PURE__ */ M(
140
+ "div",
141
+ {
142
+ className: e("grid"),
143
+ role: "region",
144
+ "aria-roledescription": "calendar",
145
+ "aria-label": to,
146
+ style: {
147
+ display: "grid",
148
+ gridTemplateColumns: `max-content repeat(${i.length}, minmax(${U}px, 1fr))`,
149
+ gridTemplateRows: `auto auto repeat(${C.length}, ${eo}px)`
150
+ },
151
+ children: [
152
+ /* @__PURE__ */ n(
153
+ "div",
154
+ {
155
+ ref: X,
156
+ className: e("cornerCell"),
157
+ style: { gridRow: 1, gridColumn: 1 },
158
+ children: K?.()
159
+ }
160
+ ),
161
+ i.map((o, r) => /* @__PURE__ */ n(
162
+ po,
163
+ {
164
+ resource: o,
165
+ column: r + 2,
166
+ cls: e,
167
+ renderHeader: V
168
+ },
169
+ o.id
170
+ )),
171
+ /* @__PURE__ */ n(
172
+ "div",
173
+ {
174
+ ref: Y,
175
+ className: R(e("allDayCell"), "left-0 z-30"),
176
+ style: {
177
+ gridRow: 2,
178
+ gridColumn: 1,
179
+ top: N
180
+ }
181
+ }
182
+ ),
183
+ i.map((o, r) => /* @__PURE__ */ n(
184
+ "div",
185
+ {
186
+ className: e("allDayCell"),
187
+ style: {
188
+ gridRow: 2,
189
+ gridColumn: r + 2,
190
+ top: N,
191
+ ...r === i.length - 1 ? { borderRightWidth: 0 } : {}
192
+ },
193
+ children: /* @__PURE__ */ n(
194
+ bo,
195
+ {
196
+ events: _.get(o.id) ?? [],
197
+ cls: e,
198
+ onEventClick: I,
199
+ selectedEventId: T,
200
+ selectedEventRef: k
201
+ }
202
+ )
203
+ },
204
+ `allday-${o.id}`
205
+ )),
206
+ C.map((o) => /* @__PURE__ */ n(
207
+ fo,
208
+ {
209
+ label: o.label,
210
+ row: o.index + 3,
211
+ isHourStart: o.isHourStart,
212
+ isFirst: o.index === 0,
213
+ cls: e
214
+ },
215
+ o.index
216
+ )),
217
+ C.map(
218
+ (o) => i.map((r, t) => /* @__PURE__ */ n(
219
+ "div",
220
+ {
221
+ className: e(o.isHourStart ? "bodyCell" : "bodyCellMinor"),
222
+ style: {
223
+ gridRow: o.index + 3,
224
+ gridColumn: t + 2,
225
+ ...o.isHourStart ? {} : { borderTopStyle: "dotted" },
226
+ ...o.index === 0 ? { borderTopWidth: 0 } : {},
227
+ ...t === i.length - 1 ? { borderRightWidth: 0 } : {}
228
+ }
229
+ },
230
+ `${o.index}-${r.id}`
231
+ ))
232
+ ),
233
+ i.map((o, r) => {
234
+ const t = oo.get(o.id);
235
+ return t ? /* @__PURE__ */ n(
236
+ wo,
237
+ {
238
+ blocks: t,
239
+ column: r + 2,
240
+ cls: e
241
+ },
242
+ `unavail-${o.id}`
243
+ ) : null;
244
+ }),
245
+ x != null && i.map((o, r) => /* @__PURE__ */ n(
246
+ go,
247
+ {
248
+ resource: o,
249
+ column: r + 2,
250
+ date: d,
251
+ timeZone: l,
252
+ startHour: a,
253
+ endHour: m,
254
+ hourHeight: s,
255
+ snapDuration: x,
256
+ placeholderDuration: L ?? 15,
257
+ cls: e,
258
+ onSlotClick: G,
259
+ onSelect: io,
260
+ dragPreviewAppearance: A,
261
+ renderEvent: H
262
+ },
263
+ `slot-${o.id}`
264
+ )),
265
+ i.map((o, r) => /* @__PURE__ */ n(
266
+ ho,
267
+ {
268
+ resource: o,
269
+ positionedEvents: Z.get(o.id) ?? [],
270
+ column: r + 2,
271
+ timeZone: l,
272
+ cls: e,
273
+ onEventClick: I,
274
+ renderEvent: H,
275
+ eventGap: P,
276
+ eventLayout: q,
277
+ stackOffset: J,
278
+ selectedEventId: T,
279
+ selectedEventRef: k
280
+ },
281
+ o.id
282
+ )),
283
+ f != null && (() => {
284
+ const o = i.findIndex(
285
+ (r) => r.id === f.resourceId
286
+ );
287
+ return o === -1 ? null : /* @__PURE__ */ n(
288
+ yo,
289
+ {
290
+ selectedRange: f,
291
+ column: o + 2,
292
+ resource: i[o],
293
+ viewDate: d,
294
+ timeZone: l,
295
+ startHour: a,
296
+ hourHeight: s,
297
+ cls: e,
298
+ appearance: z,
299
+ selectionRef: F,
300
+ renderEvent: H
301
+ }
302
+ );
303
+ })(),
304
+ /* @__PURE__ */ n(
305
+ Ho,
306
+ {
307
+ date: d,
308
+ timeZone: l,
309
+ startHour: a,
310
+ endHour: m,
311
+ hourHeight: s,
312
+ cls: e
313
+ }
314
+ )
315
+ ]
316
+ }
317
+ ),
318
+ /* @__PURE__ */ n(
319
+ "div",
320
+ {
321
+ "aria-live": "polite",
322
+ "aria-atomic": "true",
323
+ role: "status",
324
+ style: {
325
+ position: "absolute",
326
+ width: 1,
327
+ height: 1,
328
+ padding: 0,
329
+ margin: -1,
330
+ overflow: "hidden",
331
+ clip: "rect(0, 0, 0, 0)",
332
+ whiteSpace: "nowrap",
333
+ borderWidth: 0
334
+ },
335
+ children: ro
336
+ }
337
+ )
338
+ ] });
339
+ }
340
+ export {
341
+ Uo as ResourceGridView
342
+ };
@@ -0,0 +1,22 @@
1
+ import { Ref } from 'react';
2
+ import { Temporal } from 'temporal-polyfill';
3
+ import { CalendarResource, PositionedEvent, ResourceGridViewClassNames, SelectedRange, SelectionAppearance, TimedCalendarEvent } from '../../types/calendar';
4
+ interface SelectionOverlayProps {
5
+ selectedRange: SelectedRange;
6
+ column: number;
7
+ resource: CalendarResource;
8
+ viewDate: Temporal.PlainDate;
9
+ timeZone: string;
10
+ startHour: number;
11
+ hourHeight: number;
12
+ cls: (key: keyof ResourceGridViewClassNames) => string;
13
+ appearance?: SelectionAppearance;
14
+ selectionRef?: Ref<HTMLDivElement>;
15
+ renderEvent?: (props: {
16
+ event: TimedCalendarEvent;
17
+ position: PositionedEvent;
18
+ }) => React.ReactNode;
19
+ }
20
+ export declare const SelectionOverlay: import('react').NamedExoticComponent<SelectionOverlayProps>;
21
+ export {};
22
+ //# sourceMappingURL=SelectionOverlay.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SelectionOverlay.d.ts","sourceRoot":"","sources":["../../../src/components/resource-grid-view/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,gBAAgB,EAChB,eAAe,EACf,0BAA0B,EAC1B,aAAa,EACb,mBAAmB,EACnB,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAK1B,UAAU,qBAAqB;IAC7B,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,QAAQ,CAAC,SAAS,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,0BAA0B,KAAK,MAAM,CAAC;IACvD,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"}