@savvycal/calendar 0.10.2 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +187 -20
  2. package/dist/components/day-grid-view/AllDayEventChip.d.ts.map +1 -1
  3. package/dist/components/day-grid-view/AllDayEventChip.js +47 -41
  4. package/dist/components/day-grid-view/AllDaySection.d.ts +15 -0
  5. package/dist/components/day-grid-view/AllDaySection.d.ts.map +1 -1
  6. package/dist/components/day-grid-view/AllDaySection.js +93 -29
  7. package/dist/components/day-grid-view/BackgroundEventLayer.d.ts +19 -0
  8. package/dist/components/day-grid-view/BackgroundEventLayer.d.ts.map +1 -0
  9. package/dist/components/day-grid-view/BackgroundEventLayer.js +55 -0
  10. package/dist/components/day-grid-view/DayGridView.d.ts +1 -1
  11. package/dist/components/day-grid-view/DayGridView.d.ts.map +1 -1
  12. package/dist/components/day-grid-view/DayGridView.js +375 -263
  13. package/dist/components/day-grid-view/defaults.js +1 -1
  14. package/dist/components/month-view/MonthEventItem.d.ts +22 -0
  15. package/dist/components/month-view/MonthEventItem.d.ts.map +1 -0
  16. package/dist/components/month-view/MonthEventItem.js +95 -0
  17. package/dist/components/month-view/MonthMoreButton.d.ts +22 -0
  18. package/dist/components/month-view/MonthMoreButton.d.ts.map +1 -0
  19. package/dist/components/month-view/MonthMoreButton.js +122 -0
  20. package/dist/components/month-view/MonthView.d.ts +3 -0
  21. package/dist/components/month-view/MonthView.d.ts.map +1 -0
  22. package/dist/components/month-view/MonthView.js +281 -0
  23. package/dist/components/month-view/MonthWeekRow.d.ts +40 -0
  24. package/dist/components/month-view/MonthWeekRow.d.ts.map +1 -0
  25. package/dist/components/month-view/MonthWeekRow.js +192 -0
  26. package/dist/components/month-view/defaults.d.ts +3 -0
  27. package/dist/components/month-view/defaults.d.ts.map +1 -0
  28. package/dist/components/month-view/defaults.js +32 -0
  29. package/dist/components/month-view/index.d.ts +3 -0
  30. package/dist/components/month-view/index.d.ts.map +1 -0
  31. package/dist/components/resource-grid-view/ResourceGridView.d.ts +1 -1
  32. package/dist/components/resource-grid-view/ResourceGridView.d.ts.map +1 -1
  33. package/dist/components/resource-grid-view/ResourceGridView.js +163 -155
  34. package/dist/components/resource-grid-view/defaults.js +1 -1
  35. package/dist/components/shared/AnchoredPopover.d.ts +35 -0
  36. package/dist/components/shared/AnchoredPopover.d.ts.map +1 -0
  37. package/dist/components/shared/AnchoredPopover.js +91 -0
  38. package/dist/components/shared/EventChip.d.ts.map +1 -1
  39. package/dist/components/shared/EventChip.js +58 -64
  40. package/dist/components/shared/OverflowChip.d.ts +1 -1
  41. package/dist/components/shared/OverflowChip.d.ts.map +1 -1
  42. package/dist/components/shared/OverflowChip.js +67 -89
  43. package/dist/components/shared/SelectionOverlay.d.ts +1 -0
  44. package/dist/components/shared/SelectionOverlay.d.ts.map +1 -1
  45. package/dist/components/shared/SelectionOverlay.js +28 -27
  46. package/dist/components/shared/SlotInteractionLayer.d.ts +27 -5
  47. package/dist/components/shared/SlotInteractionLayer.d.ts.map +1 -1
  48. package/dist/components/shared/SlotInteractionLayer.js +186 -145
  49. package/dist/index.d.ts +3 -1
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +14 -10
  52. package/dist/lib/accessibility.d.ts +8 -0
  53. package/dist/lib/accessibility.d.ts.map +1 -1
  54. package/dist/lib/accessibility.js +31 -4
  55. package/dist/lib/lanes.d.ts +25 -0
  56. package/dist/lib/lanes.d.ts.map +1 -0
  57. package/dist/lib/lanes.js +32 -0
  58. package/dist/lib/month.d.ts +64 -0
  59. package/dist/lib/month.d.ts.map +1 -0
  60. package/dist/lib/month.js +110 -0
  61. package/dist/lib/overlap.d.ts.map +1 -1
  62. package/dist/lib/overlap.js +157 -179
  63. package/dist/lib/time.d.ts +4 -0
  64. package/dist/lib/time.d.ts.map +1 -1
  65. package/dist/lib/time.js +20 -12
  66. package/dist/types/calendar.d.ts +164 -0
  67. package/dist/types/calendar.d.ts.map +1 -1
  68. package/package.json +8 -8
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @savvycal/calendar
2
2
 
3
- A fully-featured calendar component library built with React, Tailwind CSS v4, and the Temporal API. Includes a resource grid view (resources as columns) and a day grid view (days as columns).
3
+ A fully-featured calendar component library built with React, Tailwind CSS v4, and the Temporal API. Includes a resource grid view (resources as columns), a day grid view (days as columns), and a month view.
4
4
 
5
5
  ## Installation
6
6
 
@@ -126,11 +126,12 @@ function App() {
126
126
 
127
127
  ### Render props
128
128
 
129
- | Prop | Type | Description |
130
- | -------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
131
- | `renderHeader` | `(props: { resource: CalendarResource }) => ReactNode` | Custom renderer for resource column headers. |
132
- | `renderEvent` | `(props: { event: TimedCalendarEvent, position: PositionedEvent }) => ReactNode` | Custom renderer for timed events. |
133
- | `renderCorner` | `() => ReactNode` | Custom renderer for the top-left corner cell (e.g. time zone label). |
129
+ | Prop | Type | Description |
130
+ | ------------------- | -------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
131
+ | `renderHeader` | `(props: { resource: CalendarResource }) => ReactNode` | Custom renderer for resource column headers. |
132
+ | `renderEvent` | `(props: { event: TimedCalendarEvent, position: PositionedEvent }) => ReactNode` | Custom renderer for timed events. |
133
+ | `renderCorner` | `() => ReactNode` | Custom renderer for the top-left corner cell (e.g. time zone label). |
134
+ | `formatGutterLabel` | `(time: Temporal.PlainTime) => string` | Formats the time gutter labels. Return `""` to hide a label. Default: 12-hour labels such as "9 am". |
134
135
 
135
136
  ## DayGridView
136
137
 
@@ -192,25 +193,42 @@ The following props work identically to `ResourceGridView`: `timeAxis`, `initial
192
193
 
193
194
  #### Selection
194
195
 
195
- | Prop | Type | Description |
196
- | --------------- | ----------------------------------------------- | ----------------------------------------------- |
197
- | `selectedRange` | `DayGridSelectedRange \| null` | The currently selected time range (controlled). |
198
- | `onSelect` | `(range: DayGridSelectedRange \| null) => void` | Called when the user selects or clears a range. |
199
- | `selectionRef` | `Ref<HTMLDivElement>` | Ref attached to the selection overlay element. |
196
+ | Prop | Type | Description |
197
+ | ------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
198
+ | `selectedRange` | `DayGridSelectedRange \| null` | The currently selected time range (controlled). |
199
+ | `onSelect` | `(range: DayGridSelectedRange \| null) => void` | Called when the user selects or clears a range. |
200
+ | `selectionRef` | `Ref<HTMLDivElement>` | Ref attached to the selection overlay element (the first day of a multi-day selection). |
201
+ | `multiDaySelection` | `boolean` | Let a drag span several days. Dragging across day columns repeats the time window on each day; dragging across the all-day row selects whole days (`allDay: true`), drawn in the all-day row. The range reports its last day in `endDate`. |
202
+ | `selectionLingerMs` | `number` | How long (ms) the selection stays in the DOM after clearing, so popover close transitions keep their reference. Default: `0`. |
203
+
204
+ #### Background events
205
+
206
+ | Prop | Type | Description |
207
+ | ----------------------- | ------------------------------------------------------------------ | ----------------------------------------------------------------------------------------- |
208
+ | `backgroundEvents` | `BackgroundEvent[]` | Blocks of time drawn across the full width of their day columns. They ignore the pointer. |
209
+ | `renderBackgroundEvent` | `(props: { event: BackgroundEvent, height: number }) => ReactNode` | Renders the content of a background event inside its positioned block. |
210
+
211
+ #### Scrolling
212
+
213
+ | Prop | Type | Description |
214
+ | ----------- | -------- | ------------------------------------------------------------------------------------- |
215
+ | `scrollKey` | `string` | Re-applies `initialScrollHour` when it changes, as a change of the active range does. |
200
216
 
201
217
  #### Slot click
202
218
 
203
- | Prop | Type | Description |
204
- | ------------- | ---------------------------------------------- | ------------------------------------------------------------------------------------------ |
205
- | `onSlotClick` | `(info: { date, startTime, endTime }) => void` | Called when an empty time slot is clicked. Receives the `date` (PlainDate) and time range. |
219
+ | Prop | Type | Description |
220
+ | ------------- | ------------------------------------------------------ | ------------------------------------------------------------------------------------------------------- |
221
+ | `onSlotClick` | `(info: { date, startTime, endTime }) => void` | Called when an empty time slot is clicked. Receives the `date` (PlainDate) and time range. |
222
+ | `onSlotHover` | `(info: { date, startTime, endTime } \| null) => void` | Called when the hovered slot changes, and with `null` when the pointer leaves. Requires `snapDuration`. |
206
223
 
207
224
  #### Render props
208
225
 
209
- | Prop | Type | Description |
210
- | -------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
211
- | `renderHeader` | `(props: { date: PlainDate, isToday: boolean }) => ReactNode` | Custom renderer for day column headers. |
212
- | `renderEvent` | `(props: { event: TimedCalendarEvent, position: PositionedEvent }) => ReactNode` | Custom renderer for timed events. |
213
- | `renderCorner` | `(props: { timeZone: string }) => ReactNode` | Custom renderer for the top-left corner cell (e.g. time zone label). |
226
+ | Prop | Type | Description |
227
+ | ------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
228
+ | `renderHeader` | `(props: { date: PlainDate, isToday: boolean }) => ReactNode` | Custom renderer for day column headers. |
229
+ | `renderEvent` | `(props: { event: TimedCalendarEvent, position: PositionedEvent }) => ReactNode` | Custom renderer for timed events. |
230
+ | `renderCorner` | `(props: { timeZone: string }) => ReactNode` | Custom renderer for the top-left corner cell (e.g. time zone label). |
231
+ | `formatGutterLabel` | `(time: Temporal.PlainTime) => string` | Formats the time gutter labels. Return `""` to hide a label. |
214
232
 
215
233
  ### DayGridSelectedRange
216
234
 
@@ -218,6 +236,24 @@ The following props work identically to `ResourceGridView`: `timeAxis`, `initial
218
236
  interface DayGridSelectedRange {
219
237
  startTime: Temporal.ZonedDateTime;
220
238
  endTime: Temporal.ZonedDateTime;
239
+ // Last selected day (inclusive) of a multi-day selection, which repeats the
240
+ // startTime–endTime window on each day. Omitted for one day.
241
+ endDate?: Temporal.PlainDate;
242
+ // True for whole days selected along the all-day row. startTime and endTime
243
+ // then span the first day, midnight to midnight.
244
+ allDay?: boolean;
245
+ }
246
+ ```
247
+
248
+ ### BackgroundEvent
249
+
250
+ ```ts
251
+ interface BackgroundEvent {
252
+ id: string;
253
+ startTime: Temporal.ZonedDateTime;
254
+ endTime: Temporal.ZonedDateTime;
255
+ layer?: 'below' | 'above'; // Beneath timed events (default) or above them.
256
+ className?: string; // Applied to the positioned block.
221
257
  }
222
258
  ```
223
259
 
@@ -233,6 +269,126 @@ Extends `GridViewClassNames` with day-specific keys:
233
269
 
234
270
  All shared keys from `GridViewClassNames` (root, grid, event, etc.) also apply.
235
271
 
272
+ ## MonthView
273
+
274
+ A month grid that works like Google Calendar's month view:
275
+
276
+ - All-day events and events spanning more than one day (including overnight timed events) render as bars that wrap across week rows.
277
+ - Single-day timed events render as a colored dot, start time, and title.
278
+ - Each day shows as many event rows as its cell height allows. When a day needs more, its last row becomes a "+N more" button that opens a popover listing every event on that day. A multi-day bar is hidden in a week if it doesn't fit on every day it covers, and it's counted in "+N more" on each of those days.
279
+ - Leading and trailing days from adjacent months are shown (muted) along with their events.
280
+
281
+ ### Quick start
282
+
283
+ ```tsx
284
+ import { MonthView, Temporal } from '@savvycal/calendar';
285
+
286
+ const month = Temporal.Now.plainDateISO().toPlainYearMonth();
287
+
288
+ function App() {
289
+ return (
290
+ <div style={{ height: 720 }}>
291
+ <MonthView
292
+ month={month}
293
+ timeZone="America/Chicago"
294
+ events={events}
295
+ className="h-full"
296
+ />
297
+ </div>
298
+ );
299
+ }
300
+ ```
301
+
302
+ Week rows stretch to fill the root element's height, so give it a height (e.g. `className="h-full"` inside a sized container). Without one, rows render at `minWeekHeight`.
303
+
304
+ ### MonthView props
305
+
306
+ #### Required
307
+
308
+ | Prop | Type | Description |
309
+ | ---------- | ------------------------- | ----------------------------------------------------- |
310
+ | `month` | `Temporal.PlainYearMonth` | The month to display. |
311
+ | `timeZone` | `string` | IANA time zone identifier (e.g. `"America/Chicago"`). |
312
+ | `events` | `CalendarEvent[]` | Array of timed and/or all-day events. |
313
+
314
+ #### Layout
315
+
316
+ | Prop | Type | Default | Description |
317
+ | ---------------- | --------------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
318
+ | `weekStartsOn` | `number` | `7` | First day of the week, using Temporal's numbering (`1` = Monday … `7` = Sunday). |
319
+ | `fixedWeekCount` | `boolean` | `false` | Always render six week rows, so the grid height doesn't change between months. |
320
+ | `minWeekHeight` | `number` | `100` | Minimum height in pixels for each week row. When the container is shorter, the grid scrolls. |
321
+ | `eventHeight` | `number` | `20` | Height in pixels of each event row inside a day cell. |
322
+ | `maxEventRows` | `number` | — | Hard cap on event rows per day (including the "+N more" row). Omit to fit as many as the cell height allows. |
323
+ | `className` | `string` | — | Class name applied to the root element. |
324
+ | `classNames` | `MonthViewClassNames` | — | Override default class names for internal elements. See [MonthViewClassNames](#monthviewclassnames). |
325
+
326
+ #### Events & interaction
327
+
328
+ | Prop | Type | Description |
329
+ | ----------------------- | ------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------- |
330
+ | `onEventClick` | `(event: CalendarEvent) => void` | Called when an event is clicked (in a cell or in the "+N more" popover). |
331
+ | `onDayNumberClick` | `(date: Temporal.PlainDate) => void` | Called when a day number is clicked (e.g. to navigate to a day view). Day numbers render as buttons only when this is set. |
332
+ | `selectedEventId` | `string \| null` | ID of the currently selected event (controlled). |
333
+ | `selectedEventRef` | `Ref<HTMLElement>` | Ref attached to the selected event's first visible segment. If the event is hidden, it attaches to the "+N more" button instead. |
334
+ | `onOverflowClick` | `(info: MonthOverflowClickInfo) => void` | Called when a "+N more" button opens. `info.events` is every event on `info.date`; `info.anchor` is the button. |
335
+ | `renderOverflowPopover` | `(props: MonthOverflowPopoverRenderProps) => ReactNode` | Replace the built-in "+N more" popover content. The button still handles open/close and positioning. |
336
+ | `renderHeader` | `(props: { dayOfWeek, date }) => ReactNode` | Custom renderer for weekday header cells. `date` is the first displayed date for that column. |
337
+
338
+ #### Selection
339
+
340
+ Clicking empty space in a day selects that day; dragging across days selects a range. Press Escape to clear. By default the selection renders like Google Calendar's quick-create chip: a placeholder bar titled "(No title)" pinned to the top of each selected day, so `selectionRef` can anchor a create popover beside it.
341
+
342
+ | Prop | Type | Description |
343
+ | --------------------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
344
+ | `selectedRange` | `MonthSelectedRange \| null` | The currently selected date range (controlled). |
345
+ | `onSelect` | `(range: MonthSelectedRange \| null) => void` | Called when the user selects or clears a range. Selection is disabled when omitted. |
346
+ | `selectionRef` | `Ref<HTMLDivElement>` | Ref attached to the selection (placeholder bar or highlight) in the last selected week. |
347
+ | `selectionAppearance` | `SelectionAppearance` | Default `{ style: 'event' }` renders the placeholder bar; set `eventData` to change its title or color. `'highlight'` tints the selected day cells instead. |
348
+
349
+ ### MonthSelectedRange
350
+
351
+ ```ts
352
+ interface MonthSelectedRange {
353
+ startDate: Temporal.PlainDate;
354
+ endDate: Temporal.PlainDate; // inclusive
355
+ }
356
+ ```
357
+
358
+ ### MonthViewClassNames
359
+
360
+ | Key | Description |
361
+ | ---------------------- | -------------------------------------------------------- |
362
+ | `root` | Outermost wrapper (scroll container). |
363
+ | `grid` | The CSS grid element. |
364
+ | `headerCell` | Weekday header cell (sticky). |
365
+ | `week` | A week row. |
366
+ | `dayCell` | Day cell background (borders). |
367
+ | `dayCellOutside` | Additional classes for days outside the displayed month. |
368
+ | `dayNumber` | Day number label. |
369
+ | `dayNumberToday` | Additional classes for today's day number. |
370
+ | `dayNumberOutside` | Additional classes for day numbers outside the month. |
371
+ | `dayNumberButton` | Additional classes when the day number is clickable. |
372
+ | `event` | All-day / multi-day event bar. |
373
+ | `eventSelected` | Additional classes for a selected bar. |
374
+ | `eventColorBar` | Color bar on the left edge of a bar. |
375
+ | `eventTitle` | Bar title text. |
376
+ | `eventTime` | Start time shown on multi-day timed bars. |
377
+ | `timedEvent` | Single-day timed event item. |
378
+ | `timedEventSelected` | Additional classes for a selected timed item. |
379
+ | `timedEventDot` | Colored dot on a timed item. |
380
+ | `timedEventTime` | Start time on a timed item. |
381
+ | `timedEventTitle` | Title on a timed item. |
382
+ | `moreButton` | "+N more" button. |
383
+ | `selectionHighlight` | Selected day range highlight. |
384
+ | `morePopover` | "+N more" popover panel. |
385
+ | `morePopoverHeader` | Popover date header. |
386
+ | `morePopoverWeekday` | Weekday label in the popover header. |
387
+ | `morePopoverDayNumber` | Day number in the popover header. |
388
+ | `morePopoverEvents` | Event list inside the popover. |
389
+
390
+ The library exports `monthViewDefaults` with the default classes for every key, for use with `cn()` (see [`resourceGridViewDefaults`](#resourcegridviewdefaults)).
391
+
236
392
  ## Data types
237
393
 
238
394
  ### CalendarResource
@@ -263,6 +419,7 @@ interface TimedCalendarEvent {
263
419
  status?: 'confirmed' | 'canceled' | 'tentative';
264
420
  ariaLabel?: string;
265
421
  priority?: number;
422
+ interactive?: boolean;
266
423
  metadata?: Record<string, unknown>;
267
424
  }
268
425
 
@@ -278,12 +435,15 @@ interface AllDayCalendarEvent {
278
435
  status?: 'confirmed' | 'canceled' | 'tentative';
279
436
  ariaLabel?: string;
280
437
  priority?: number;
438
+ interactive?: boolean;
281
439
  metadata?: Record<string, unknown>;
282
440
  }
283
441
  ```
284
442
 
285
443
  The optional `ariaLabel` field provides a plain-text label used for `aria-label` attributes and screen reader announcements. When `title` or `clientName` are React elements (not plain strings), set `ariaLabel` to avoid `"[object Object]"` in accessible labels.
286
444
 
445
+ Set `interactive: false` for a display-only event: it ignores clicks and the pointer, so clicks, hovers, and drags reach the time slot beneath it.
446
+
287
447
  `priority` controls overlap packing. Higher values are placed in earlier columns, so they stay visible when `eventMaxStack` or `eventMinWidth` caps how many overlapping events are shown. Omit it (or use `0`) for the default. Use this to keep product appointments on the grid ahead of connected-calendar events.
288
448
 
289
449
  ### AvailabilityRange
@@ -548,11 +708,12 @@ const { refs, floatingStyles } = useFloating({
548
708
 
549
709
  ```ts
550
710
  // Components
551
- export { ResourceGridView, DayGridView } from '@savvycal/calendar';
711
+ export { ResourceGridView, DayGridView, MonthView } from '@savvycal/calendar';
552
712
  // Defaults
553
713
  export {
554
714
  resourceGridViewDefaults,
555
715
  dayGridViewDefaults,
716
+ monthViewDefaults,
556
717
  } from '@savvycal/calendar';
557
718
 
558
719
  // Temporal polyfill
@@ -569,6 +730,7 @@ export type {
569
730
  AllDayCalendarEvent,
570
731
  TimeSlot,
571
732
  AvailabilityRange,
733
+ BackgroundEvent,
572
734
  TimeAxisConfig,
573
735
  ResourceGridViewProps,
574
736
  ResourceGridViewClassNames,
@@ -581,6 +743,11 @@ export type {
581
743
  SelectionAppearance,
582
744
  SelectionEventData,
583
745
  EventLayout,
746
+ MonthViewProps,
747
+ MonthViewClassNames,
748
+ MonthSelectedRange,
749
+ MonthOverflowClickInfo,
750
+ MonthOverflowPopoverRenderProps,
584
751
  } from '@savvycal/calendar';
585
752
  ```
586
753
 
@@ -1 +1 @@
1
- {"version":3,"file":"AllDayEventChip.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/AllDayEventChip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,UAAU,oBAAoB;IAC5B,UAAU,EAAE,qBAAqB,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,qBAAqB,KAAK,MAAM,CAAC;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,eAAe,4DAmG1B,CAAC"}
1
+ {"version":3,"file":"AllDayEventChip.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/AllDayEventChip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AAGvC,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE3D,UAAU,oBAAoB;IAC5B,UAAU,EAAE,qBAAqB,CAAC;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,qBAAqB,KAAK,MAAM,CAAC;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,eAAe,4DA+G1B,CAAC"}
@@ -1,32 +1,32 @@
1
- import { jsxs as D, Fragment as E, jsx as n } from "react/jsx-runtime";
1
+ import { jsxs as D, Fragment as x, jsx as n } from "react/jsx-runtime";
2
2
  import { memo as L } from "react";
3
- import { cn as g } from "../../lib/utils.js";
4
- import { getEventLabel as x, getClientNameLabel as N } from "../../lib/accessibility.js";
5
- const T = L(function({
6
- positioned: b,
7
- laneOffset: y,
3
+ import { cn as o } from "../../lib/utils.js";
4
+ import { getEventLabel as N, getClientNameLabel as S } from "../../lib/accessibility.js";
5
+ const k = L(function({
6
+ positioned: v,
7
+ laneOffset: b,
8
8
  cls: t,
9
- onEventClick: a,
9
+ onEventClick: s,
10
10
  selectedEventId: h,
11
- selectedEventRef: v
11
+ selectedEventRef: C
12
12
  }) {
13
13
  const {
14
14
  event: e,
15
- gridColumnStart: i,
16
- gridColumnSpan: r,
17
- lane: C,
15
+ gridColumnStart: c,
16
+ gridColumnSpan: d,
17
+ lane: E,
18
18
  continuesBefore: l,
19
- continuesAfter: s
20
- } = b, R = e.id === h, d = C + 1 + y, o = [x(e), "all day"], c = N(e);
21
- c && o.push(c);
22
- const m = l ? 2 : 4, p = s ? 2 : 4, u = {
19
+ continuesAfter: m
20
+ } = v, R = e.id === h, p = E + 1 + b, a = [N(e), "all day"], u = S(e);
21
+ u && a.push(u);
22
+ const f = l ? 2 : 4, g = m ? 2 : 4, i = {
23
23
  ...l ? {
24
24
  borderTopLeftRadius: 0,
25
25
  borderBottomLeftRadius: 0,
26
26
  paddingLeft: 4
27
27
  } : {},
28
- ...s ? { borderTopRightRadius: 0, borderBottomRightRadius: 0 } : {}
29
- }, f = /* @__PURE__ */ D(E, { children: [
28
+ ...m ? { borderTopRightRadius: 0, borderBottomRightRadius: 0 } : {}
29
+ }, r = /* @__PURE__ */ D(x, { children: [
30
30
  e.color && !l && /* @__PURE__ */ n(
31
31
  "div",
32
32
  {
@@ -35,32 +35,44 @@ const T = L(function({
35
35
  }
36
36
  ),
37
37
  /* @__PURE__ */ n("span", { className: t("allDayEventTitle"), children: e.title })
38
- ] });
39
- return R ? /* @__PURE__ */ n(
38
+ ] }), y = {
39
+ gridColumn: `${c} / span ${d}`,
40
+ gridRow: p,
41
+ marginLeft: f,
42
+ marginRight: g
43
+ };
44
+ return e.interactive === !1 ? /* @__PURE__ */ n(
40
45
  "div",
41
46
  {
42
- ref: v,
47
+ className: o(t("allDayEvent"), "relative flex items-center gap-1"),
48
+ style: { ...y, ...i, pointerEvents: "none" },
49
+ children: r
50
+ }
51
+ ) : R ? /* @__PURE__ */ n(
52
+ "div",
53
+ {
54
+ ref: C,
43
55
  style: {
44
- gridColumn: `${i} / span ${r}`,
45
- gridRow: d,
56
+ gridColumn: `${c} / span ${d}`,
57
+ gridRow: p,
46
58
  display: "flex",
47
59
  minWidth: 0,
48
- marginLeft: m,
49
- marginRight: p
60
+ marginLeft: f,
61
+ marginRight: g
50
62
  },
51
63
  children: /* @__PURE__ */ n(
52
64
  "button",
53
65
  {
54
66
  type: "button",
55
- "aria-label": o.join(", "),
56
- className: g(
67
+ "aria-label": a.join(", "),
68
+ className: o(
57
69
  t("allDayEvent"),
58
70
  t("allDayEventSelected"),
59
71
  "relative flex items-center gap-1 w-full"
60
72
  ),
61
- style: u,
62
- onClick: () => a?.(e),
63
- children: f
73
+ style: i,
74
+ onClick: () => s?.(e),
75
+ children: r
64
76
  }
65
77
  )
66
78
  }
@@ -68,20 +80,14 @@ const T = L(function({
68
80
  "button",
69
81
  {
70
82
  type: "button",
71
- "aria-label": o.join(", "),
72
- className: g(t("allDayEvent"), "relative flex items-center gap-1"),
73
- style: {
74
- gridColumn: `${i} / span ${r}`,
75
- gridRow: d,
76
- marginLeft: m,
77
- marginRight: p,
78
- ...u
79
- },
80
- onClick: () => a?.(e),
81
- children: f
83
+ "aria-label": a.join(", "),
84
+ className: o(t("allDayEvent"), "relative flex items-center gap-1"),
85
+ style: { ...y, ...i },
86
+ onClick: () => s?.(e),
87
+ children: r
82
88
  }
83
89
  );
84
90
  });
85
91
  export {
86
- T as AllDayEventChip
92
+ k as AllDayEventChip
87
93
  };
@@ -2,6 +2,10 @@ import { Ref } from 'react';
2
2
  import { Temporal } from 'temporal-polyfill';
3
3
  import { CalendarEvent, DayGridViewClassNames } from '../../types/calendar';
4
4
  import { PositionedAllDayEvent } from '../../lib/overlap';
5
+ interface DaySpan {
6
+ startDate: Temporal.PlainDate;
7
+ endDate: Temporal.PlainDate;
8
+ }
5
9
  interface AllDaySectionProps {
6
10
  positioned: PositionedAllDayEvent[];
7
11
  dates: Temporal.PlainDate[];
@@ -10,6 +14,17 @@ interface AllDaySectionProps {
10
14
  onEventClick?: (event: CalendarEvent) => void;
11
15
  selectedEventId?: string | null;
12
16
  selectedEventRef?: Ref<HTMLDivElement>;
17
+ /**
18
+ * Enables drag selection of whole days across the row. Called with `null`
19
+ * when a drag starts, then with the selected days when it ends.
20
+ */
21
+ onSelectDays?: (days: DaySpan | null) => void;
22
+ /** Finds the date (as a string) of the day column under the pointer. */
23
+ resolveColumnId?: (clientX: number) => string | null;
24
+ /** Whole days to highlight as the current selection. */
25
+ selectedDays?: DaySpan | null;
26
+ /** Ref attached to the selected days' highlight. */
27
+ selectionRef?: Ref<HTMLDivElement>;
13
28
  }
14
29
  export declare const AllDaySection: import('react').NamedExoticComponent<AllDaySectionProps>;
15
30
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"AllDaySection.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/AllDaySection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAG3D,UAAU,kBAAkB;IAC1B,UAAU,EAAE,qBAAqB,EAAE,CAAC;IACpC,KAAK,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,qBAAqB,KAAK,MAAM,CAAC;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CACxC;AAED,eAAO,MAAM,aAAa,0DA+DxB,CAAC"}
1
+ {"version":3,"file":"AllDaySection.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/AllDaySection.tsx"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAI3D,UAAU,OAAO;IACf,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC;IAC9B,OAAO,EAAE,QAAQ,CAAC,SAAS,CAAC;CAC7B;AAED,UAAU,kBAAkB;IAC1B,UAAU,EAAE,qBAAqB,EAAE,CAAC;IACpC,KAAK,EAAE,QAAQ,CAAC,SAAS,EAAE,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,qBAAqB,KAAK,MAAM,CAAC;IAClD,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACvC;;;OAGG;IACH,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,GAAG,IAAI,KAAK,IAAI,CAAC;IAC9C,wEAAwE;IACxE,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACrD,wDAAwD;IACxD,YAAY,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,oDAAoD;IACpD,YAAY,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;CACpC;AAED,eAAO,MAAM,aAAa,0DA8JxB,CAAC"}
@@ -1,53 +1,117 @@
1
- import { jsxs as u, jsx as i } from "react/jsx-runtime";
2
- import { memo as x } from "react";
3
- import { AllDayEventChip as y } from "./AllDayEventChip.js";
4
- const C = x(function({
5
- positioned: o,
6
- dates: n,
7
- headerHeight: s,
8
- cls: a,
9
- onEventClick: m,
10
- selectedEventId: d,
11
- selectedEventRef: p
1
+ import { jsxs as k, jsx as M } from "react/jsx-runtime";
2
+ import { memo as O, useState as _, useRef as l, useEffect as w, useCallback as C } from "react";
3
+ import { DISMISS_ONLY_ATTR as z } from "../shared/AnchoredPopover.js";
4
+ import { AllDayEventChip as H } from "./AllDayEventChip.js";
5
+ const F = O(function({
6
+ positioned: c,
7
+ dates: e,
8
+ headerHeight: L,
9
+ cls: m,
10
+ onEventClick: b,
11
+ selectedEventId: y,
12
+ selectedEventRef: I,
13
+ onSelectDays: r,
14
+ resolveColumnId: R,
15
+ selectedDays: d,
16
+ selectionRef: $
12
17
  }) {
13
- const g = o.length > 0 ? Math.max(...o.map((t) => t.lane)) + 1 : 0, e = o.length > 0, r = e ? "4px" : "0px", c = e ? `${r} repeat(${g}, auto) ${r}` : "auto";
14
- return /* @__PURE__ */ u(
18
+ const [o, A] = _(
19
+ null
20
+ ), h = l(o), i = l(e), x = l(r), E = l(R);
21
+ w(() => {
22
+ i.current = e, x.current = r, E.current = R;
23
+ });
24
+ const f = (t) => {
25
+ h.current = t, A(t);
26
+ }, u = C((t) => {
27
+ const n = h.current, s = E.current?.(t.clientX);
28
+ if (!n || !s) return;
29
+ const v = i.current.findIndex((j) => j.toString() === s);
30
+ v !== -1 && v !== n.current && f({ ...n, current: v });
31
+ }, []), g = C(() => {
32
+ document.removeEventListener("mousemove", u);
33
+ const t = h.current;
34
+ if (f(null), !t) return;
35
+ const n = Math.min(t.anchor, t.current), s = Math.max(t.anchor, t.current);
36
+ x.current?.({
37
+ startDate: i.current[n],
38
+ endDate: i.current[s]
39
+ });
40
+ }, [u]);
41
+ w(() => () => {
42
+ document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", g);
43
+ }, [u, g]);
44
+ const N = (t) => (n) => {
45
+ n.button === 0 && (n.preventDefault(), r?.(null), f({ anchor: t, current: t }), document.addEventListener("mousemove", u), document.addEventListener("mouseup", g, { once: !0 }));
46
+ };
47
+ let a = null;
48
+ if (o)
49
+ a = {
50
+ first: Math.min(o.anchor, o.current),
51
+ last: Math.max(o.anchor, o.current)
52
+ };
53
+ else if (d && e.length > 0) {
54
+ const t = Math.max(0, e[0].until(d.startDate).days), n = Math.min(
55
+ e.length - 1,
56
+ e[0].until(d.endDate).days
57
+ );
58
+ t <= n && (a = { first: t, last: n });
59
+ }
60
+ const S = c.length > 0 ? Math.max(...c.map((t) => t.lane)) + 1 : 0, p = c.length > 0, D = p ? "4px" : "0px", T = p ? `${D} repeat(${S}, auto) ${D}` : "auto";
61
+ return /* @__PURE__ */ k(
15
62
  "div",
16
63
  {
17
- className: a("allDayLane"),
64
+ className: m("allDayLane"),
18
65
  style: {
19
66
  gridRow: 2,
20
67
  gridColumn: "2 / -1",
21
68
  display: "grid",
22
69
  gridTemplateColumns: "subgrid",
23
- gridTemplateRows: c,
70
+ gridTemplateRows: T,
24
71
  position: "sticky",
25
- top: s,
72
+ top: L,
26
73
  zIndex: 20,
27
74
  gap: "2px 0"
28
75
  },
29
76
  children: [
30
- n.map((t, l) => /* @__PURE__ */ i(
77
+ e.map((t, n) => /* @__PURE__ */ M(
31
78
  "div",
32
79
  {
33
- className: l < n.length - 1 ? "border-r border-cal-border" : void 0,
80
+ className: n < e.length - 1 ? "border-r border-cal-border" : void 0,
34
81
  style: {
35
- gridColumn: l + 1,
82
+ gridColumn: n + 1,
36
83
  gridRow: "1 / -1",
37
- pointerEvents: "none"
38
- }
84
+ pointerEvents: r ? "auto" : "none",
85
+ cursor: r ? "pointer" : void 0
86
+ },
87
+ "data-day-column": t.toString(),
88
+ ...r ? { [z]: "" } : {},
89
+ onMouseDown: r ? N(n) : void 0
39
90
  },
40
91
  t.toString()
41
92
  )),
42
- o.map((t) => /* @__PURE__ */ i(
43
- y,
93
+ a && /* @__PURE__ */ M(
94
+ "div",
95
+ {
96
+ ref: o ? void 0 : $,
97
+ "aria-hidden": "true",
98
+ className: m("selectionHighlight"),
99
+ style: {
100
+ gridColumn: `${a.first + 1} / ${a.last + 2}`,
101
+ gridRow: "1 / -1",
102
+ pointerEvents: "none"
103
+ }
104
+ }
105
+ ),
106
+ c.map((t) => /* @__PURE__ */ M(
107
+ H,
44
108
  {
45
109
  positioned: t,
46
- laneOffset: e ? 1 : 0,
47
- cls: a,
48
- onEventClick: m,
49
- selectedEventId: d,
50
- selectedEventRef: p
110
+ laneOffset: p ? 1 : 0,
111
+ cls: m,
112
+ onEventClick: b,
113
+ selectedEventId: y,
114
+ selectedEventRef: I
51
115
  },
52
116
  t.event.id
53
117
  ))
@@ -56,5 +120,5 @@ const C = x(function({
56
120
  );
57
121
  });
58
122
  export {
59
- C as AllDaySection
123
+ F as AllDaySection
60
124
  };
@@ -0,0 +1,19 @@
1
+ import { ReactNode } from 'react';
2
+ import { Temporal } from 'temporal-polyfill';
3
+ import { BackgroundEvent } from '../../types/calendar';
4
+ interface BackgroundEventLayerProps {
5
+ events: BackgroundEvent[];
6
+ date: Temporal.PlainDate;
7
+ column: number;
8
+ timeZone: string;
9
+ startHour: number;
10
+ endHour: number;
11
+ hourHeight: number;
12
+ renderBackgroundEvent?: (props: {
13
+ event: BackgroundEvent;
14
+ height: number;
15
+ }) => ReactNode;
16
+ }
17
+ export declare const BackgroundEventLayer: import('react').NamedExoticComponent<BackgroundEventLayerProps>;
18
+ export {};
19
+ //# sourceMappingURL=BackgroundEventLayer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BackgroundEventLayer.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/BackgroundEventLayer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAGxD,UAAU,yBAAyB;IACjC,MAAM,EAAE,eAAe,EAAE,CAAC;IAC1B,IAAI,EAAE,QAAQ,CAAC,SAAS,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,qBAAqB,CAAC,EAAE,CAAC,KAAK,EAAE;QAC9B,KAAK,EAAE,eAAe,CAAC;QACvB,MAAM,EAAE,MAAM,CAAC;KAChB,KAAK,SAAS,CAAC;CACjB;AAED,eAAO,MAAM,oBAAoB,iEAyD/B,CAAC"}