@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,205 +1,246 @@
1
- import { jsxs as lt, jsx as B } from "react/jsx-runtime";
2
- import { memo as at, useState as X, useRef as e, useCallback as l, useLayoutEffect as ft, useEffect as dt } from "react";
3
- import { computeAutoScrollIntensity as mt, findVerticalScrollParent as Mt, createVerticalAutoScroller as ht } from "../../lib/autoScroll.js";
4
- import { buildSyntheticEvent as gt } from "../../lib/selection.js";
5
- import { EventChip as vt } from "./EventChip.js";
6
- function S(w, M, L) {
7
- const h = Math.floor(M / 60), s = M % 60;
8
- return h >= 24 ? w.add({ days: Math.floor(h / 24) }).toPlainDateTime({ hour: h % 24, minute: s }).toZonedDateTime(L) : w.toPlainDateTime({ hour: h, minute: s }).toZonedDateTime(L);
9
- }
10
- const Ct = at(function({
11
- columnId: M,
12
- fallbackColor: L,
13
- column: h,
14
- date: s,
15
- timeZone: a,
16
- startHour: _,
17
- endHour: $,
18
- hourHeight: Z,
1
+ import { jsxs as St, jsx as B } from "react/jsx-runtime";
2
+ import { memo as Ct, useState as rt, useRef as r, useCallback as l, useLayoutEffect as yt, useEffect as Tt } from "react";
3
+ import { computeAutoScrollIntensity as Lt, findVerticalScrollParent as Pt, createVerticalAutoScroller as Yt } from "../../lib/autoScroll.js";
4
+ import { buildSyntheticEvent as bt } from "../../lib/selection.js";
5
+ import { minutesToZonedDateTime as M } from "../../lib/time.js";
6
+ import { EventChip as xt } from "./EventChip.js";
7
+ import { DISMISS_ONLY_ATTR as It } from "./AnchoredPopover.js";
8
+ const At = Ct(function({
9
+ columnId: u,
10
+ fallbackColor: ot,
11
+ column: ct,
12
+ date: a,
13
+ timeZone: s,
14
+ startHour: ut,
15
+ endHour: st,
16
+ hourHeight: it,
19
17
  snapDuration: y,
20
18
  placeholderDuration: i,
21
- cls: Y,
22
- onSlotClick: x,
19
+ cls: P,
20
+ onSlotClick: Y,
23
21
  onSelect: g,
24
- dragPreviewAppearance: q = "highlight",
25
- renderEvent: tt
22
+ onSlotHover: J,
23
+ resolveColumnId: K,
24
+ onDragPreviewChange: O,
25
+ previewRange: lt,
26
+ dragPreviewAppearance: Q = "highlight",
27
+ renderEvent: at
26
28
  }) {
27
- const [H, z] = X(null), [u, O] = X(null), C = e(null), v = e(null), F = e(!1), P = e(0), b = e(null), p = e(null), G = e(() => {
28
- }), J = e(g), K = e(M), N = e(s), j = e(a), R = _ * 60, D = $ * 60, f = Z / 60, d = l(
29
- (n) => {
30
- const t = n / f, r = Math.floor(t / y) * y, o = R + r;
31
- return o + i > D || o < R ? null : o;
29
+ const [w, H] = rt(null), [ft, dt] = rt(null), f = O ? lt : ft, T = r(null), h = r(null), N = r(!1), b = r(0), X = r(0), W = r(null), x = r(null), v = r(null), $ = r(() => {
30
+ }), Z = r(g), F = r(K), tt = r(O), j = r(u), A = r(a), D = r(s), p = ut * 60, I = st * 60, d = it / 60, m = l(
31
+ (t) => {
32
+ const e = t / d, n = Math.floor(e / y) * y, c = p + n;
33
+ return c + i > I || c < p ? null : c;
32
34
  },
33
35
  [
34
- f,
36
+ d,
35
37
  y,
36
38
  i,
37
- R,
38
- D
39
+ p,
40
+ I
39
41
  ]
40
- ), Q = e(d), I = e(D), nt = e(y), U = e(i), W = l((n, t) => {
41
- const r = Math.min(n, t), o = Math.min(
42
- Math.max(n, t) + U.current,
43
- I.current
42
+ ), nt = r(m), U = r(I), mt = r(y), V = r(i), et = l((t, e) => {
43
+ const n = Math.min(t, e), c = Math.min(
44
+ Math.max(t, e) + V.current,
45
+ U.current
44
46
  );
45
- return { startMin: r, endMin: o };
46
- }, []), V = l(
47
- (n) => {
48
- const t = v.current, r = C.current;
49
- if (!t || !r) return;
50
- const o = r.getBoundingClientRect(), c = Math.max(0, Math.min(n - o.top, o.height));
51
- let m = Q.current(c);
52
- m == null && (m = I.current - U.current);
53
- const T = W(t.anchorSlotStart, m), it = t.moved && t.currentStartMin === T.startMin && t.currentEndMin === T.endMin;
54
- t.currentStartMin = T.startMin, t.currentEndMin = T.endMin, t.moved = !0, it || O(T);
47
+ return { startMin: n, endMin: c };
48
+ }, []), R = l((t) => {
49
+ const e = tt.current;
50
+ e ? e(t) : dt(
51
+ t && { startMin: t.startMin, endMin: t.endMin }
52
+ );
53
+ }, []), _ = l(
54
+ (t, e) => {
55
+ const n = h.current, c = T.current;
56
+ if (!n || !c) return;
57
+ const o = c.getBoundingClientRect(), C = Math.max(0, Math.min(e - o.top, o.height));
58
+ let z = nt.current(C);
59
+ z == null && (z = U.current - V.current);
60
+ const L = et(n.anchorSlotStart, z), G = F.current?.(t) ?? n.currentColumnId, Et = n.moved && n.currentStartMin === L.startMin && n.currentEndMin === L.endMin && n.currentColumnId === G;
61
+ n.currentStartMin = L.startMin, n.currentEndMin = L.endMin, n.currentColumnId = G, n.moved = !0, Et || R({
62
+ columnId: j.current,
63
+ endColumnId: G,
64
+ ...L
65
+ });
55
66
  },
56
- [W]
67
+ [et, R]
57
68
  ), E = l(
58
- (n) => {
59
- P.current = n.clientY, V(n.clientY);
60
- const t = b.current;
61
- if (!t) return;
62
- const r = t.getBoundingClientRect();
63
- mt(n.clientY, r.top, r.bottom) !== 0 && p.current?.ensure();
69
+ (t) => {
70
+ b.current = t.clientY, X.current = t.clientX, _(t.clientX, t.clientY);
71
+ const e = x.current;
72
+ if (!e) return;
73
+ const n = e.getBoundingClientRect();
74
+ Lt(t.clientY, n.top, n.bottom) !== 0 && v.current?.ensure();
64
75
  },
65
- [V]
66
- ), A = e(() => {
67
- }), k = l(() => {
68
- p.current?.stop(), p.current = null, b.current = null;
69
- const n = v.current;
70
- n && (n.moved && (F.current = !0), J.current?.({
71
- columnId: K.current,
72
- startTime: S(
73
- N.current,
74
- n.currentStartMin,
75
- j.current
76
+ [_]
77
+ ), k = r(() => {
78
+ }), q = l(() => {
79
+ v.current?.stop(), v.current = null, x.current = null;
80
+ const t = h.current;
81
+ t && (t.moved && (N.current = !0), Z.current?.({
82
+ columnId: j.current,
83
+ ...F.current ? { endColumnId: t.currentColumnId } : {},
84
+ startTime: M(
85
+ A.current,
86
+ t.currentStartMin,
87
+ D.current
76
88
  ),
77
- endTime: S(
78
- N.current,
79
- n.currentEndMin,
80
- j.current
89
+ endTime: M(
90
+ A.current,
91
+ t.currentEndMin,
92
+ D.current
81
93
  )
82
- })), v.current = null, O(null), document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", A.current);
94
+ })), h.current = null, R(null), document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", k.current);
95
+ }, [E, R]);
96
+ yt(() => {
97
+ Z.current = g, F.current = K, tt.current = O, j.current = u, A.current = a, D.current = s, nt.current = m, U.current = I, mt.current = y, V.current = i, k.current = q, $.current = _;
98
+ }), Tt(() => () => {
99
+ v.current?.stop(), document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", k.current);
83
100
  }, [E]);
84
- ft(() => {
85
- J.current = g, K.current = M, N.current = s, j.current = a, Q.current = d, I.current = D, nt.current = y, U.current = i, A.current = k, G.current = V;
86
- }), dt(() => () => {
87
- p.current?.stop(), document.removeEventListener("mousemove", E), document.removeEventListener("mouseup", A.current);
88
- }, [E]);
89
- const et = l(
90
- (n) => {
101
+ const S = l(
102
+ (t) => {
103
+ W.current !== t && (W.current = t, J?.(
104
+ t == null ? null : {
105
+ columnId: u,
106
+ startTime: M(a, t, s),
107
+ endTime: M(
108
+ a,
109
+ t + i,
110
+ s
111
+ )
112
+ }
113
+ ));
114
+ },
115
+ [J, u, a, s, i]
116
+ ), Mt = l(
117
+ (t) => {
91
118
  if (!g) return;
92
- const t = C.current;
93
- if (!t) return;
94
- const r = t.getBoundingClientRect(), o = n.clientY - r.top, c = d(o);
95
- if (c == null) return;
96
- n.preventDefault(), g(null);
97
- const m = c + i;
98
- v.current = {
99
- anchorSlotStart: c,
100
- currentStartMin: c,
101
- currentEndMin: m,
119
+ const e = T.current;
120
+ if (!e) return;
121
+ const n = e.getBoundingClientRect(), c = t.clientY - n.top, o = m(c);
122
+ if (o == null) return;
123
+ t.preventDefault(), g(null), H(null), S(null);
124
+ const C = o + i;
125
+ h.current = {
126
+ anchorSlotStart: o,
127
+ currentColumnId: u,
128
+ currentStartMin: o,
129
+ currentEndMin: C,
102
130
  moved: !1
103
- }, P.current = n.clientY, b.current = Mt(t), p.current?.stop(), p.current = ht({
104
- getPointerY: () => P.current,
105
- getScrollParent: () => b.current,
106
- onScroll: () => G.current(P.current)
107
- }), O({ startMin: c, endMin: m }), document.addEventListener("mousemove", E), document.addEventListener("mouseup", k);
131
+ }, b.current = t.clientY, X.current = t.clientX, x.current = Pt(e), v.current?.stop(), v.current = Yt({
132
+ getPointerY: () => b.current,
133
+ getScrollParent: () => x.current,
134
+ onScroll: () => $.current(
135
+ X.current,
136
+ b.current
137
+ )
138
+ }), R({
139
+ columnId: u,
140
+ endColumnId: u,
141
+ startMin: o,
142
+ endMin: C
143
+ }), document.addEventListener("mousemove", E), document.addEventListener("mouseup", q);
108
144
  },
109
145
  [
110
146
  g,
111
- d,
147
+ m,
112
148
  i,
113
149
  E,
114
- k
150
+ q,
151
+ u,
152
+ R,
153
+ S
115
154
  ]
116
- ), rt = l(
117
- (n) => {
118
- if (v.current) return;
119
- const t = C.current;
120
- if (!t) return;
121
- const r = t.getBoundingClientRect(), o = n.clientY - r.top;
122
- z(d(o));
155
+ ), gt = l(
156
+ (t) => {
157
+ if (h.current || t.buttons !== 0) return;
158
+ const e = T.current;
159
+ if (!e) return;
160
+ const n = e.getBoundingClientRect(), c = t.clientY - n.top, o = m(c);
161
+ H(o), S(o);
123
162
  },
124
- [d]
125
- ), ot = l(() => {
126
- v.current || z(null);
127
- }, []), ct = l(
128
- (n) => {
129
- if (F.current) {
130
- F.current = !1;
163
+ [m, S]
164
+ ), ht = l(() => {
165
+ h.current || (H(null), S(null));
166
+ }, [S]), vt = l(
167
+ (t) => {
168
+ if (N.current) {
169
+ N.current = !1;
131
170
  return;
132
171
  }
133
- const t = C.current;
134
- if (!t) return;
135
- const r = t.getBoundingClientRect(), o = n.clientY - r.top, c = d(o);
136
- if (c == null) return;
137
- const m = c + i;
138
- x && x({
139
- columnId: M,
140
- startTime: S(s, c, a),
141
- endTime: S(s, m, a)
172
+ const e = T.current;
173
+ if (!e) return;
174
+ const n = e.getBoundingClientRect(), c = t.clientY - n.top, o = m(c);
175
+ if (o == null) return;
176
+ const C = o + i;
177
+ Y && Y({
178
+ columnId: u,
179
+ startTime: M(a, o, s),
180
+ endTime: M(a, C, s)
142
181
  });
143
182
  },
144
- [x, d, i, M, s, a]
145
- ), st = H != null ? (H - R) * f : 0, ut = i * f;
146
- return /* @__PURE__ */ lt(
183
+ [Y, m, i, u, a, s]
184
+ ), pt = w != null ? (w - p) * d : 0, Rt = i * d;
185
+ return /* @__PURE__ */ St(
147
186
  "div",
148
187
  {
149
- ref: C,
188
+ ref: T,
189
+ [It]: "",
190
+ "data-slot-column": u,
150
191
  style: {
151
192
  gridRow: "3 / -1",
152
- gridColumn: h,
193
+ gridColumn: ct,
153
194
  position: "relative",
154
195
  pointerEvents: "auto",
155
- cursor: x || g ? "pointer" : void 0
196
+ cursor: Y || g ? "pointer" : void 0
156
197
  },
157
- onMouseDown: et,
158
- onMouseMove: rt,
159
- onMouseLeave: ot,
160
- onClick: ct,
198
+ onMouseDown: Mt,
199
+ onMouseMove: gt,
200
+ onMouseLeave: ht,
201
+ onClick: vt,
161
202
  children: [
162
- H != null && !u && /* @__PURE__ */ B(
203
+ w != null && !f && /* @__PURE__ */ B(
163
204
  "div",
164
205
  {
165
206
  "aria-hidden": "true",
166
- className: Y("slotHighlight"),
207
+ className: P("slotHighlight"),
167
208
  style: {
168
209
  position: "absolute",
169
- top: st,
210
+ top: pt,
170
211
  left: 0,
171
212
  right: 0,
172
- height: ut,
213
+ height: Rt,
173
214
  pointerEvents: "none"
174
215
  }
175
216
  }
176
217
  ),
177
- u && (q !== "highlight" ? /* @__PURE__ */ B(
218
+ f && (Q !== "highlight" ? /* @__PURE__ */ B(
178
219
  "div",
179
220
  {
180
221
  "aria-hidden": "true",
181
- className: Y("eventColumn"),
222
+ className: P("eventColumn"),
182
223
  style: { pointerEvents: "none" },
183
224
  children: /* @__PURE__ */ B(
184
- vt,
225
+ xt,
185
226
  {
186
227
  interactive: !1,
187
228
  positioned: {
188
- event: gt(
229
+ event: bt(
189
230
  "",
190
- S(s, u.startMin, a),
191
- S(s, u.endMin, a),
192
- q.eventData
231
+ M(a, f.startMin, s),
232
+ M(a, f.endMin, s),
233
+ Q.eventData
193
234
  ),
194
- top: (u.startMin - R) * f,
195
- height: (u.endMin - u.startMin) * f,
235
+ top: (f.startMin - p) * d,
236
+ height: (f.endMin - f.startMin) * d,
196
237
  subColumn: 0,
197
238
  totalSubColumns: 1
198
239
  },
199
- fallbackColor: L,
200
- timeZone: a,
201
- cls: Y,
202
- renderEvent: tt
240
+ fallbackColor: ot,
241
+ timeZone: s,
242
+ cls: P,
243
+ renderEvent: at
203
244
  }
204
245
  )
205
246
  }
@@ -207,13 +248,13 @@ const Ct = at(function({
207
248
  "div",
208
249
  {
209
250
  "aria-hidden": "true",
210
- className: Y("selectionHighlight"),
251
+ className: P("selectionHighlight"),
211
252
  style: {
212
253
  position: "absolute",
213
- top: (u.startMin - R) * f,
254
+ top: (f.startMin - p) * d,
214
255
  left: 0,
215
256
  right: 0,
216
- height: (u.endMin - u.startMin) * f,
257
+ height: (f.endMin - f.startMin) * d,
217
258
  pointerEvents: "none"
218
259
  }
219
260
  }
@@ -223,5 +264,5 @@ const Ct = at(function({
223
264
  );
224
265
  });
225
266
  export {
226
- Ct as SlotInteractionLayer
267
+ At as SlotInteractionLayer
227
268
  };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  export { Temporal } from 'temporal-polyfill';
2
2
  export { ResourceGridView } from './components/resource-grid-view';
3
3
  export { DayGridView } from './components/day-grid-view';
4
+ export { MonthView } from './components/month-view';
4
5
  export { resourceGridViewDefaults } from './components/resource-grid-view';
5
6
  export { dayGridViewDefaults } from './components/day-grid-view';
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
+ export { monthViewDefaults } from './components/month-view';
8
+ export type { CalendarResource, CalendarEvent, TimedCalendarEvent, AllDayCalendarEvent, TimeSlot, AvailabilityRange, BackgroundEvent, TimeAxisConfig, ResourceGridViewProps, ResourceGridViewClassNames, GridViewClassNames, DayGridViewProps, DayGridViewClassNames, DayGridSelectedRange, PositionedEvent, OverflowClickInfo, OverflowPopoverRenderProps, SelectedRange, SelectionAppearance, SelectionEventData, EventLayout, MonthViewProps, MonthViewClassNames, MonthSelectedRange, MonthOverflowClickInfo, MonthOverflowPopoverRenderProps, } from './types/calendar';
7
9
  export { cn } from './lib/utils';
8
10
  export { timedEvent, allDayEvent } from './lib/events';
9
11
  //# 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,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"}
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;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,YAAY,EACV,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,EACjB,eAAe,EACf,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,EACX,cAAc,EACd,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -1,17 +1,21 @@
1
1
  import { Temporal as o } from "temporal-polyfill";
2
2
  import { cn as f } from "./lib/utils.js";
3
- import { allDayEvent as m, timedEvent as p } from "./lib/events.js";
4
- import { DayGridView as x } from "./components/day-grid-view/DayGridView.js";
5
- import { ResourceGridView as l } from "./components/resource-grid-view/ResourceGridView.js";
6
- import { dayGridViewDefaults as u } from "./components/day-grid-view/defaults.js";
7
- import { resourceGridViewDefaults as D } from "./components/resource-grid-view/defaults.js";
3
+ import { allDayEvent as i, timedEvent as p } from "./lib/events.js";
4
+ import { DayGridView as a } from "./components/day-grid-view/DayGridView.js";
5
+ import { MonthView as l } from "./components/month-view/MonthView.js";
6
+ import { ResourceGridView as V } from "./components/resource-grid-view/ResourceGridView.js";
7
+ import { dayGridViewDefaults as s } from "./components/day-grid-view/defaults.js";
8
+ import { monthViewDefaults as D } from "./components/month-view/defaults.js";
9
+ import { resourceGridViewDefaults as c } from "./components/resource-grid-view/defaults.js";
8
10
  export {
9
- x as DayGridView,
10
- l as ResourceGridView,
11
+ a as DayGridView,
12
+ l as MonthView,
13
+ V as ResourceGridView,
11
14
  o as Temporal,
12
- m as allDayEvent,
15
+ i as allDayEvent,
13
16
  f as cn,
14
- u as dayGridViewDefaults,
15
- D as resourceGridViewDefaults,
17
+ s as dayGridViewDefaults,
18
+ D as monthViewDefaults,
19
+ c as resourceGridViewDefaults,
16
20
  p as timedEvent
17
21
  };
@@ -3,4 +3,12 @@ import { CalendarEvent } from '../types/calendar';
3
3
  export declare function getEventLabel(event: CalendarEvent): string;
4
4
  /** Returns a plain-text client name string, or undefined if not set. */
5
5
  export declare function getClientNameLabel(event: CalendarEvent): string | undefined;
6
+ /**
7
+ * Plain-text description of an event: title, optionally the date(s) it
8
+ * covers, time range (or "all day"), client name, and optionally its status.
9
+ */
10
+ export declare function describeEvent(event: CalendarEvent, timeZone: string, { includeStatus, includeDate, }?: {
11
+ includeStatus?: boolean;
12
+ includeDate?: boolean;
13
+ }): string;
6
14
  //# sourceMappingURL=accessibility.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"accessibility.d.ts","sourceRoot":"","sources":["../../src/lib/accessibility.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEtD,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAE1D;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAK3E"}
1
+ {"version":3,"file":"accessibility.d.ts","sourceRoot":"","sources":["../../src/lib/accessibility.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAItD,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,CAE1D;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAK3E;AAUD;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,KAAK,EAAE,aAAa,EACpB,QAAQ,EAAE,MAAM,EAChB,EACE,aAAqB,EACrB,WAAmB,GACpB,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,WAAW,CAAC,EAAE,OAAO,CAAA;CAAO,GACzD,MAAM,CAuBR"}
@@ -1,11 +1,38 @@
1
- function e(t) {
1
+ import { getMonthEventSpan as c } from "./month.js";
2
+ import { formatTimeRange as u } from "./time.js";
3
+ function f(t) {
2
4
  return t.ariaLabel ?? String(t.title);
3
5
  }
4
- function i(t) {
6
+ function m(t) {
5
7
  if (t.clientName)
6
8
  return typeof t.clientName == "string" ? t.clientName : String(t.clientName);
7
9
  }
10
+ function i(t) {
11
+ return t.toLocaleString("en-US", {
12
+ weekday: "long",
13
+ month: "long",
14
+ day: "numeric"
15
+ });
16
+ }
17
+ function d(t, n, {
18
+ includeStatus: o = !1,
19
+ includeDate: s = !1
20
+ } = {}) {
21
+ const a = [f(t)];
22
+ if (s) {
23
+ const { startDate: e, endDate: l } = c(t, n);
24
+ a.push(
25
+ e.equals(l) ? i(e) : `${i(e)} to ${i(l)}`
26
+ );
27
+ }
28
+ a.push(
29
+ t.allDay ? "all day" : u(t.startTime, t.endTime, n)
30
+ );
31
+ const r = m(t);
32
+ return r && a.push(r), o && (t.status === "canceled" ? a.push("canceled") : t.status === "tentative" && a.push("tentative")), a.join(", ");
33
+ }
8
34
  export {
9
- i as getClientNameLabel,
10
- e as getEventLabel
35
+ d as describeEvent,
36
+ m as getClientNameLabel,
37
+ f as getEventLabel
11
38
  };
@@ -0,0 +1,25 @@
1
+ import { Temporal } from 'temporal-polyfill';
2
+ export interface ClippedSpan {
3
+ /** 0-based first column */
4
+ startCol: number;
5
+ /** Number of columns covered */
6
+ span: number;
7
+ /** Starts before the first date */
8
+ continuesBefore: boolean;
9
+ /** Ends after the last date */
10
+ continuesAfter: boolean;
11
+ }
12
+ /**
13
+ * Clips an inclusive date range to a run of consecutive dates, or returns
14
+ * null when it doesn't overlap them.
15
+ */
16
+ export declare function clipDateSpan(startDate: Temporal.PlainDate, endDate: Temporal.PlainDate, dates: Temporal.PlainDate[]): ClippedSpan | null;
17
+ /**
18
+ * Greedily gives each item, in order, the first lane that's free across
19
+ * every column it covers. Returns the lane for each item.
20
+ */
21
+ export declare function assignLanes(items: {
22
+ startCol: number;
23
+ span: number;
24
+ }[], columnCount: number): number[];
25
+ //# sourceMappingURL=lanes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lanes.d.ts","sourceRoot":"","sources":["../../src/lib/lanes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE7C,MAAM,WAAW,WAAW;IAC1B,2BAA2B;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,mCAAmC;IACnC,eAAe,EAAE,OAAO,CAAC;IACzB,+BAA+B;IAC/B,cAAc,EAAE,OAAO,CAAC;CACzB;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,SAAS,EAAE,QAAQ,CAAC,SAAS,EAC7B,OAAO,EAAE,QAAQ,CAAC,SAAS,EAC3B,KAAK,EAAE,QAAQ,CAAC,SAAS,EAAE,GAC1B,WAAW,GAAG,IAAI,CA0BpB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,EAC3C,WAAW,EAAE,MAAM,GAClB,MAAM,EAAE,CAiBV"}
@@ -0,0 +1,32 @@
1
+ import { Temporal as s } from "temporal-polyfill";
2
+ function f(l, o, n) {
3
+ if (n.length === 0) return null;
4
+ const e = n[0], i = n[n.length - 1];
5
+ if (s.PlainDate.compare(l, i) > 0 || s.PlainDate.compare(o, e) < 0)
6
+ return null;
7
+ const a = s.PlainDate.compare(l, e) < 0, t = s.PlainDate.compare(o, i) > 0, r = a ? 0 : l.since(e, { largestUnit: "days" }).days, c = t ? n.length - 1 : o.since(e, { largestUnit: "days" }).days;
8
+ return {
9
+ startCol: r,
10
+ span: c - r + 1,
11
+ continuesBefore: a,
12
+ continuesAfter: t
13
+ };
14
+ }
15
+ function p(l, o) {
16
+ const n = [];
17
+ return l.map(({ startCol: e, span: i }) => {
18
+ const a = e + i - 1;
19
+ let t = n.findIndex((r) => {
20
+ for (let c = e; c <= a; c++)
21
+ if (r[c]) return !1;
22
+ return !0;
23
+ });
24
+ t === -1 && (t = n.length, n.push(new Array(o).fill(!1)));
25
+ for (let r = e; r <= a; r++) n[t][r] = !0;
26
+ return t;
27
+ });
28
+ }
29
+ export {
30
+ p as assignLanes,
31
+ f as clipDateSpan
32
+ };