@savvycal/calendar 0.13.0 → 0.14.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 (55) hide show
  1. package/README.md +108 -40
  2. package/dist/components/day-grid-view/AllDaySection.d.ts +2 -0
  3. package/dist/components/day-grid-view/AllDaySection.d.ts.map +1 -1
  4. package/dist/components/day-grid-view/AllDaySection.js +111 -75
  5. package/dist/components/day-grid-view/DayColumn.d.ts +2 -24
  6. package/dist/components/day-grid-view/DayColumn.d.ts.map +1 -1
  7. package/dist/components/day-grid-view/DayGridView.d.ts +1 -1
  8. package/dist/components/day-grid-view/DayGridView.d.ts.map +1 -1
  9. package/dist/components/day-grid-view/DayGridView.js +330 -275
  10. package/dist/components/day-grid-view/defaults.d.ts.map +1 -1
  11. package/dist/components/day-grid-view/defaults.js +1 -0
  12. package/dist/components/month-view/MonthView.d.ts.map +1 -1
  13. package/dist/components/month-view/MonthView.js +184 -165
  14. package/dist/components/month-view/MonthWeekRow.d.ts +1 -0
  15. package/dist/components/month-view/MonthWeekRow.d.ts.map +1 -1
  16. package/dist/components/month-view/MonthWeekRow.js +95 -89
  17. package/dist/components/resource-grid-view/ResourceColumn.d.ts +3 -21
  18. package/dist/components/resource-grid-view/ResourceColumn.d.ts.map +1 -1
  19. package/dist/components/resource-grid-view/ResourceColumn.js +13 -6
  20. package/dist/components/resource-grid-view/ResourceGridView.d.ts +1 -1
  21. package/dist/components/resource-grid-view/ResourceGridView.d.ts.map +1 -1
  22. package/dist/components/resource-grid-view/ResourceGridView.js +348 -300
  23. package/dist/components/resource-grid-view/defaults.d.ts.map +1 -1
  24. package/dist/components/resource-grid-view/defaults.js +1 -0
  25. package/dist/components/shared/AllDayRow.d.ts.map +1 -1
  26. package/dist/components/shared/AllDayRow.js +21 -22
  27. package/dist/components/shared/EventChip.d.ts +4 -0
  28. package/dist/components/shared/EventChip.d.ts.map +1 -1
  29. package/dist/components/shared/EventChip.js +77 -69
  30. package/dist/components/shared/SelectionOverlay.d.ts +4 -0
  31. package/dist/components/shared/SelectionOverlay.d.ts.map +1 -1
  32. package/dist/components/shared/SelectionOverlay.js +38 -33
  33. package/dist/components/shared/SlotInteractionLayer.d.ts +5 -0
  34. package/dist/components/shared/SlotInteractionLayer.d.ts.map +1 -1
  35. package/dist/components/shared/SlotInteractionLayer.js +201 -176
  36. package/dist/components/shared/TimedEventLayer.d.ts +5 -2
  37. package/dist/components/shared/TimedEventLayer.d.ts.map +1 -1
  38. package/dist/components/shared/TimedEventLayer.js +57 -51
  39. package/dist/components/shared/useEventDrag.d.ts +36 -0
  40. package/dist/components/shared/useEventDrag.d.ts.map +1 -0
  41. package/dist/components/shared/useEventDrag.js +156 -0
  42. package/dist/components/shared/useLingeringValue.d.ts +7 -0
  43. package/dist/components/shared/useLingeringValue.d.ts.map +1 -0
  44. package/dist/components/shared/useLingeringValue.js +17 -0
  45. package/dist/components/shared/useTouchDrag.d.ts +38 -0
  46. package/dist/components/shared/useTouchDrag.d.ts.map +1 -0
  47. package/dist/components/shared/useTouchDrag.js +51 -0
  48. package/dist/index.d.ts +1 -1
  49. package/dist/index.d.ts.map +1 -1
  50. package/dist/lib/autoScroll.d.ts +30 -9
  51. package/dist/lib/autoScroll.d.ts.map +1 -1
  52. package/dist/lib/autoScroll.js +57 -51
  53. package/dist/types/calendar.d.ts +50 -0
  54. package/dist/types/calendar.d.ts.map +1 -1
  55. package/package.json +1 -1
package/README.md CHANGED
@@ -116,6 +116,16 @@ function App() {
116
116
  | `selectedEventId` | `string \| null` | — | ID of the currently selected event (controlled). Applies selected styling and enables `selectedEventRef`. |
117
117
  | `selectedEventRef` | `Ref<HTMLDivElement>` | — | Ref attached to the selected event element, useful for positioning popovers. |
118
118
 
119
+ ### Drag and drop
120
+
121
+ | Prop | Type | Default | Description |
122
+ | ---------------- | --------------------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
123
+ | `onEventDrop` | `(drop: EventDrop) => void` | — | Called when the user drags a timed event to a new time or resource and releases it. Setting it makes interactive timed events draggable. The grid doesn't move the event. |
124
+ | `pendingDrop` | `EventDrop \| null` | — | A drop awaiting confirmation (controlled). The grid draws the event at its new place and dims it in its old one. Clear it to cancel, or after applying the move. |
125
+ | `pendingDropRef` | `Ref<HTMLDivElement>` | — | Ref attached to the event drawn at `pendingDrop`, for positioning a confirmation popover. |
126
+
127
+ See [Drag and drop with confirmation](#drag-and-drop-with-confirmation).
128
+
119
129
  ### Availability
120
130
 
121
131
  | Prop | Type | Default | Description |
@@ -189,17 +199,17 @@ function App() {
189
199
 
190
200
  #### Layout, events & interaction
191
201
 
192
- The following props work identically to `ResourceGridView`: `timeAxis`, `initialScrollHour`, `hourHeight`, `columnMinWidth`, `eventLayout`, `eventGap`, `stackOffset`, `eventMinWidth`, `eventMaxStack`, `onOverflowClick`, `renderOverflowPopover`, `className`, `classNames` (uses `DayGridViewClassNames`), `onEventClick`, `snapDuration`, `placeholderDuration`, `selectionAppearance`, `dragPreviewAppearance`, `selectedEventId`, `selectedEventRef`.
202
+ The following props work identically to `ResourceGridView`: `timeAxis`, `initialScrollHour`, `hourHeight`, `columnMinWidth`, `eventLayout`, `eventGap`, `stackOffset`, `eventMinWidth`, `eventMaxStack`, `onOverflowClick`, `renderOverflowPopover`, `className`, `classNames` (uses `DayGridViewClassNames`), `onEventClick`, `snapDuration`, `placeholderDuration`, `selectionAppearance`, `dragPreviewAppearance`, `selectedEventId`, `selectedEventRef`, `onEventDrop`, `pendingDrop`, `pendingDropRef`. In `DayGridView`, an event can be dragged to another day; `EventDrop.resourceId` is always the event's own resource.
193
203
 
194
204
  #### Selection
195
205
 
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`. |
206
+ | Prop | Type | Description |
207
+ | ------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
208
+ | `selectedRange` | `DayGridSelectedRange \| null` | The currently selected time range (controlled). |
209
+ | `onSelect` | `(range: DayGridSelectedRange \| null) => void` | Called when the user selects or clears a range. |
210
+ | `selectionRef` | `Ref<HTMLDivElement>` | Ref attached to the selection overlay element (the first day of a multi-day selection). |
211
+ | `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`. The grid scrolls sideways when the pointer nears its left or right edge. |
212
+ | `selectionLingerMs` | `number` | How long (ms) the selection stays in the DOM after clearing, so popover close transitions keep their reference. Default: `0`. |
203
213
 
204
214
  #### Background events
205
215
 
@@ -423,6 +433,7 @@ interface TimedCalendarEvent {
423
433
  ariaLabel?: string;
424
434
  priority?: number;
425
435
  interactive?: boolean;
436
+ draggable?: boolean;
426
437
  appearance?: 'filled' | 'outline';
427
438
  metadata?: Record<string, unknown>;
428
439
  }
@@ -449,6 +460,8 @@ The optional `ariaLabel` field provides a plain-text label used for `aria-label`
449
460
 
450
461
  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.
451
462
 
463
+ Set `draggable: false` to keep an interactive timed event from being dragged when the view has `onEventDrop`. It can still be clicked.
464
+
452
465
  Set `appearance: 'outline'` to draw an event as an outline in its color, with its text in that color and no fill or color bar, the way calendar apps show invitations awaiting a reply. In month view, an outlined single-day timed event gets a hollow dot and text in its color. So that every color stays readable, the text and outline keep the color's hue but cap its lightness in light mode and raise it in dark mode, where the outline is also softer. Colors that already contrast well with the surface are unchanged. The shell exposes the color as the `--cal-event-color` CSS variable; style the outline with the `eventOutline`, `allDayEventOutline`, and `timedEventOutline` class names.
453
466
 
454
467
  `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.
@@ -544,38 +557,39 @@ The preset uses a `.dark` class convention (matching Tailwind's `@custom-variant
544
557
 
545
558
  Every internal element can be restyled via the `classNames` prop. Each key maps to a specific part of the calendar:
546
559
 
547
- | Key | Description |
548
- | ---------------------- | ------------------------------------------------------------- |
549
- | `root` | Outermost wrapper (scroll container). |
550
- | `grid` | The CSS grid element. |
551
- | `cornerCell` | Top-left corner cell (sticky). |
552
- | `headerCell` | Resource column header cell (sticky). |
553
- | `headerName` | Resource name text inside the header. |
554
- | `headerAvatar` | Avatar image inside the header. |
555
- | `gutterCell` | Time gutter cell for hour labels (sticky). |
556
- | `gutterCellMinor` | Time gutter cell for sub-hour intervals. |
557
- | `gutterLabel` | Text label inside gutter cells. |
558
- | `bodyCell` | Hour-start body cell in the grid. |
559
- | `bodyCellMinor` | Sub-hour body cell in the grid. |
560
- | `eventColumn` | Container for events within a resource column. |
561
- | `event` | Individual event element. |
562
- | `eventSelected` | Additional classes applied to a selected event. |
563
- | `eventOutline` | Additional classes for an event with `appearance: 'outline'`. |
564
- | `eventColorBar` | Vertical color bar on the left edge of an event. |
565
- | `eventTitle` | Event title text. |
566
- | `eventTime` | Event time text. |
567
- | `eventClientName` | Client name text on the event. |
568
- | `nowIndicator` | Horizontal "now" indicator line. |
569
- | `slotHighlight` | Hover highlight on time slots. |
570
- | `selectionHighlight` | Drag selection highlight overlay. |
571
- | `allDayCell` | All-day event row cell. |
572
- | `unavailableOverlay` | Unavailable time cross-hatch overlay. |
573
- | `overflowChip` | "+N more" chip shown when overlapping events exceed the cap. |
574
- | `overflowChipLabel` | Label text inside the overflow chip. |
575
- | `overflowPopover` | Built-in overflow popover panel. |
576
- | `overflowPopoverEvent` | A single event row inside the overflow popover. |
577
- | `overflowPopoverTitle` | Event title inside an overflow popover row. |
578
- | `overflowPopoverTime` | Event time range inside an overflow popover row. |
560
+ | Key | Description |
561
+ | ---------------------- | ------------------------------------------------------------------------------------ |
562
+ | `root` | Outermost wrapper (scroll container). |
563
+ | `grid` | The CSS grid element. |
564
+ | `cornerCell` | Top-left corner cell (sticky). |
565
+ | `headerCell` | Resource column header cell (sticky). |
566
+ | `headerName` | Resource name text inside the header. |
567
+ | `headerAvatar` | Avatar image inside the header. |
568
+ | `gutterCell` | Time gutter cell for hour labels (sticky). |
569
+ | `gutterCellMinor` | Time gutter cell for sub-hour intervals. |
570
+ | `gutterLabel` | Text label inside gutter cells. |
571
+ | `bodyCell` | Hour-start body cell in the grid. |
572
+ | `bodyCellMinor` | Sub-hour body cell in the grid. |
573
+ | `eventColumn` | Container for events within a resource column. |
574
+ | `event` | Individual event element. |
575
+ | `eventSelected` | Additional classes applied to a selected event. |
576
+ | `eventOutline` | Additional classes for an event with `appearance: 'outline'`. |
577
+ | `eventDragSource` | An event being dragged, or awaiting confirmation of its drop, in its original place. |
578
+ | `eventColorBar` | Vertical color bar on the left edge of an event. |
579
+ | `eventTitle` | Event title text. |
580
+ | `eventTime` | Event time text. |
581
+ | `eventClientName` | Client name text on the event. |
582
+ | `nowIndicator` | Horizontal "now" indicator line. |
583
+ | `slotHighlight` | Hover highlight on time slots. |
584
+ | `selectionHighlight` | Drag selection highlight overlay. |
585
+ | `allDayCell` | All-day event row cell. |
586
+ | `unavailableOverlay` | Unavailable time cross-hatch overlay. |
587
+ | `overflowChip` | "+N more" chip shown when overlapping events exceed the cap. |
588
+ | `overflowChipLabel` | Label text inside the overflow chip. |
589
+ | `overflowPopover` | Built-in overflow popover panel. |
590
+ | `overflowPopoverEvent` | A single event row inside the overflow popover. |
591
+ | `overflowPopoverTitle` | Event title inside an overflow popover row. |
592
+ | `overflowPopoverTime` | Event time range inside an overflow popover row. |
579
593
 
580
594
  ### `resourceGridViewDefaults`
581
595
 
@@ -606,6 +620,8 @@ The `cn()` utility (re-exported from the library) merges Tailwind classes with c
606
620
 
607
621
  ## Selection & interaction
608
622
 
623
+ On touch screens, every view's drag selection starts with a 400 ms press and hold, as event drags do: a quick swipe still scrolls, and a tap still selects a slot or day.
624
+
609
625
  ### Controlled selection
610
626
 
611
627
  Selection is controlled via `selectedRange` and `onSelect`:
@@ -707,6 +723,57 @@ const { refs, floatingStyles } = useFloating({
707
723
  }
708
724
  ```
709
725
 
726
+ ### Drag and drop with confirmation
727
+
728
+ Pass `onEventDrop` to make timed events draggable. With a mouse, press an event and move the pointer a few pixels to start a drag. On touch screens, press and hold an event for 400 ms; a quick swipe across events still scrolls the grid, and a tap still opens the event. Once a drag starts, the event follows the pointer, snapped to `snapDuration` (default 15 minutes), across columns, and the grid auto-scrolls when the pointer nears any of its edges, so you can drag an event to a column or time that's scrolled out of view. Press Escape to cancel a drag. A mouse press without movement is still a click.
729
+
730
+ Releasing the event somewhere new calls `onEventDrop` with an `EventDrop`. The grid never moves the event itself, so you can confirm the move before applying it: store the drop in `pendingDrop`, which draws the event at its new place and dims its original, and anchor a popover to `pendingDropRef`. Then update `events` and clear `pendingDrop` to apply the move, or just clear `pendingDrop` to cancel it. Set `selectionLingerMs` to keep the anchor mounted while the popover closes.
731
+
732
+ ```tsx
733
+ const [pendingDrop, setPendingDrop] = useState<EventDrop | null>(null);
734
+
735
+ const { refs, floatingStyles } = useFloating({
736
+ open: pendingDrop !== null,
737
+ onOpenChange: (open) => {
738
+ if (!open) setPendingDrop(null);
739
+ },
740
+ placement: 'right',
741
+ whileElementsMounted: autoUpdate,
742
+ });
743
+
744
+ <ResourceGridView
745
+ onEventDrop={setPendingDrop}
746
+ pendingDrop={pendingDrop}
747
+ pendingDropRef={refs.setReference}
748
+ // ...
749
+ />;
750
+
751
+ {
752
+ pendingDrop && (
753
+ <div ref={refs.setFloating} style={floatingStyles}>
754
+ <button
755
+ onClick={() => {
756
+ moveEvent(pendingDrop); // update your events
757
+ setPendingDrop(null);
758
+ }}
759
+ >
760
+ Move
761
+ </button>
762
+ <button onClick={() => setPendingDrop(null)}>Cancel</button>
763
+ </div>
764
+ );
765
+ }
766
+ ```
767
+
768
+ ```ts
769
+ interface EventDrop {
770
+ event: TimedCalendarEvent; // The event before the drag
771
+ resourceId: string; // Where it was dropped (its own resource in DayGridView)
772
+ startTime: Temporal.ZonedDateTime;
773
+ endTime: Temporal.ZonedDateTime; // startTime plus the original duration
774
+ }
775
+ ```
776
+
710
777
  ### Slot and event clicks
711
778
 
712
779
  - `onSlotClick` fires when clicking an empty time slot, receiving the `resource`, `startTime`, and `endTime`.
@@ -750,6 +817,7 @@ export type {
750
817
  DayGridSelectedRange,
751
818
  PositionedEvent,
752
819
  SelectedRange,
820
+ EventDrop,
753
821
  SelectionAppearance,
754
822
  SelectionEventData,
755
823
  EventLayout,
@@ -21,6 +21,8 @@ interface AllDaySectionProps {
21
21
  onSelectDays?: (days: DaySpan | null) => void;
22
22
  /** Finds the date (as a string) of the day column under the pointer. */
23
23
  resolveColumnId?: (clientX: number) => string | null;
24
+ /** Left edge of the grid's visible area, right of its sticky gutter. */
25
+ getScrollViewportLeft?: () => number | undefined;
24
26
  /** Whole days to highlight as the current selection. */
25
27
  selectedDays?: DaySpan | null;
26
28
  /** Ref attached to the selected days' highlight. */
@@ -1 +1 @@
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
+ {"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;AAU3D,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,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;IACjD,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,0DA2NxB,CAAC"}
@@ -1,117 +1,153 @@
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: $
1
+ import { jsxs as G, jsx as T } from "react/jsx-runtime";
2
+ import { memo as q, useState as B, useRef as u, useEffect as N, useCallback as m } from "react";
3
+ import { findVerticalScrollParent as F, createAutoScroller as J } from "../../lib/autoScroll.js";
4
+ import { DISMISS_ONLY_ATTR as K } from "../shared/AnchoredPopover.js";
5
+ import { AllDayEventChip as Q } from "./AllDayEventChip.js";
6
+ import { useTouchDrag as W, TOUCH_DRAG_STYLE as Z } from "../shared/useTouchDrag.js";
7
+ const at = q(function({
8
+ positioned: d,
9
+ dates: c,
10
+ headerHeight: X,
11
+ cls: p,
12
+ onEventClick: _,
13
+ selectedEventId: O,
14
+ selectedEventRef: j,
15
+ onSelectDays: n,
16
+ resolveColumnId: C,
17
+ getScrollViewportLeft: L,
18
+ selectedDays: v,
19
+ selectionRef: k
17
20
  }) {
18
- const [o, A] = _(
21
+ const [a, y] = B(
19
22
  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
+ ), R = u(a), g = u(c), b = u(n), A = u(C), P = u(L), f = u(0), s = u(null);
24
+ N(() => {
25
+ g.current = c, b.current = n, A.current = C, P.current = L;
23
26
  });
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]
27
+ const D = (t) => {
28
+ R.current = t, y(t);
29
+ }, M = m(() => {
30
+ const t = R.current, r = A.current?.(f.current);
31
+ if (!t || !r) return;
32
+ const e = g.current.findIndex((o) => o.toString() === r);
33
+ e !== -1 && e !== t.current && D({ ...t, current: e });
34
+ }, []), x = m(
35
+ (t) => {
36
+ f.current = t, M(), s.current?.ensure();
37
+ },
38
+ [M]
39
+ ), l = m(
40
+ (t) => x(t.clientX),
41
+ [x]
42
+ ), h = m(
43
+ (t) => {
44
+ s.current?.stop(), s.current = null, document.removeEventListener("mousemove", l);
45
+ const r = R.current;
46
+ if (D(null), !r || !t) return;
47
+ const e = Math.min(r.anchor, r.current), o = Math.max(r.anchor, r.current);
48
+ b.current?.({
49
+ startDate: g.current[e],
50
+ endDate: g.current[o]
51
+ });
52
+ },
53
+ [l]
54
+ ), w = m(() => h(!0), [h]);
55
+ N(() => () => {
56
+ s.current?.stop(), document.removeEventListener("mousemove", l), document.removeEventListener("mouseup", w);
57
+ }, [l, w]);
58
+ const S = (t, r, e) => {
59
+ n?.(null), D({ anchor: t, current: t }), f.current = r;
60
+ const o = F(e);
61
+ s.current?.stop(), s.current = J({
62
+ getScrollParent: () => o,
63
+ horizontal: {
64
+ getPointerX: () => f.current,
65
+ getViewportLeft: () => P.current?.()
66
+ },
67
+ onScroll: M
68
+ });
69
+ }, z = (t) => (r) => {
70
+ r.button === 0 && (r.preventDefault(), S(t, r.clientX, r.currentTarget), document.addEventListener("mousemove", l), document.addEventListener("mouseup", w, { once: !0 }));
71
+ }, I = u(null), H = W(I, n != null), U = (t) => (r) => {
72
+ const e = r.currentTarget;
73
+ H(r, {
74
+ start: (o) => S(t, o, e),
75
+ move: (o) => x(o),
76
+ end: () => h(!0),
77
+ cancel: () => h(!1)
39
78
  });
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
79
  };
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)
80
+ let i = null;
81
+ if (a)
82
+ i = {
83
+ first: Math.min(a.anchor, a.current),
84
+ last: Math.max(a.anchor, a.current)
52
85
  };
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
86
+ else if (v && c.length > 0) {
87
+ const t = Math.max(0, c[0].until(v.startDate).days), r = Math.min(
88
+ c.length - 1,
89
+ c[0].until(v.endDate).days
57
90
  );
58
- t <= n && (a = { first: t, last: n });
91
+ t <= r && (i = { first: t, last: r });
59
92
  }
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(
93
+ const V = d.length > 0 ? Math.max(...d.map((t) => t.lane)) + 1 : 0, E = d.length > 0, $ = E ? "4px" : "0px", Y = E ? `${$} repeat(${V}, auto) ${$}` : "auto";
94
+ return /* @__PURE__ */ G(
62
95
  "div",
63
96
  {
64
- className: m("allDayLane"),
97
+ ref: I,
98
+ className: p("allDayLane"),
65
99
  style: {
66
100
  gridRow: 2,
67
101
  gridColumn: "2 / -1",
68
102
  display: "grid",
69
103
  gridTemplateColumns: "subgrid",
70
- gridTemplateRows: T,
104
+ gridTemplateRows: Y,
71
105
  position: "sticky",
72
- top: L,
106
+ top: X,
73
107
  zIndex: 20,
74
108
  gap: "2px 0"
75
109
  },
76
110
  children: [
77
- e.map((t, n) => /* @__PURE__ */ M(
111
+ c.map((t, r) => /* @__PURE__ */ T(
78
112
  "div",
79
113
  {
80
- className: n < e.length - 1 ? "border-r border-cal-border" : void 0,
114
+ className: r < c.length - 1 ? "border-r border-cal-border" : void 0,
81
115
  style: {
82
- gridColumn: n + 1,
116
+ gridColumn: r + 1,
83
117
  gridRow: "1 / -1",
84
- pointerEvents: r ? "auto" : "none",
85
- cursor: r ? "pointer" : void 0
118
+ pointerEvents: n ? "auto" : "none",
119
+ cursor: n ? "pointer" : void 0,
120
+ ...n && Z
86
121
  },
87
122
  "data-day-column": t.toString(),
88
- ...r ? { [z]: "" } : {},
89
- onMouseDown: r ? N(n) : void 0
123
+ ...n ? { [K]: "" } : {},
124
+ onMouseDown: n ? z(r) : void 0,
125
+ onPointerDown: n ? U(r) : void 0
90
126
  },
91
127
  t.toString()
92
128
  )),
93
- a && /* @__PURE__ */ M(
129
+ i && /* @__PURE__ */ T(
94
130
  "div",
95
131
  {
96
- ref: o ? void 0 : $,
132
+ ref: a ? void 0 : k,
97
133
  "aria-hidden": "true",
98
- className: m("selectionHighlight"),
134
+ className: p("selectionHighlight"),
99
135
  style: {
100
- gridColumn: `${a.first + 1} / ${a.last + 2}`,
136
+ gridColumn: `${i.first + 1} / ${i.last + 2}`,
101
137
  gridRow: "1 / -1",
102
138
  pointerEvents: "none"
103
139
  }
104
140
  }
105
141
  ),
106
- c.map((t) => /* @__PURE__ */ M(
107
- H,
142
+ d.map((t) => /* @__PURE__ */ T(
143
+ Q,
108
144
  {
109
145
  positioned: t,
110
- laneOffset: p ? 1 : 0,
111
- cls: m,
112
- onEventClick: b,
113
- selectedEventId: y,
114
- selectedEventRef: I
146
+ laneOffset: E ? 1 : 0,
147
+ cls: p,
148
+ onEventClick: _,
149
+ selectedEventId: O,
150
+ selectedEventRef: j
115
151
  },
116
152
  t.event.id
117
153
  ))
@@ -120,5 +156,5 @@ const F = O(function({
120
156
  );
121
157
  });
122
158
  export {
123
- F as AllDaySection
159
+ at as AllDaySection
124
160
  };
@@ -1,25 +1,3 @@
1
- import { Ref } from 'react';
2
- import { CalendarEvent, EventLayout, GridViewClassNames, OverflowClickInfo, OverflowPopoverRenderProps, PositionedEvent, TimedCalendarEvent } from '../../types/calendar';
3
- interface DayColumnProps {
4
- positionedEvents: PositionedEvent[];
5
- column: number;
6
- timeZone: string;
7
- cls: (key: keyof GridViewClassNames) => string;
8
- onEventClick?: (event: CalendarEvent) => void;
9
- renderEvent?: (props: {
10
- event: TimedCalendarEvent;
11
- position: PositionedEvent;
12
- }) => React.ReactNode;
13
- eventGap?: number;
14
- eventLayout?: EventLayout;
15
- stackOffset?: number;
16
- selectedEventId?: string | null;
17
- selectedEventRef?: Ref<HTMLDivElement>;
18
- eventMinWidth?: number;
19
- eventMaxStack?: number;
20
- onOverflowClick?: (info: OverflowClickInfo) => void;
21
- renderOverflowPopover?: (props: OverflowPopoverRenderProps) => React.ReactNode;
22
- }
23
- export declare const DayColumn: import('react').NamedExoticComponent<DayColumnProps>;
24
- export {};
1
+ import { TimedEventLayerProps } from '../shared/TimedEventLayer';
2
+ export declare const DayColumn: import('react').NamedExoticComponent<TimedEventLayerProps>;
25
3
  //# sourceMappingURL=DayColumn.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DayColumn.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/DayColumn.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAQ,KAAK,GAAG,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EACV,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,kBAAkB,EACnB,MAAM,kBAAkB,CAAC;AAG1B,UAAU,cAAc;IACtB,gBAAgB,EAAE,eAAe,EAAE,CAAC;IACpC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,kBAAkB,KAAK,MAAM,CAAC;IAC/C,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC9C,WAAW,CAAC,EAAE,CAAC,KAAK,EAAE;QACpB,KAAK,EAAE,kBAAkB,CAAC;QAC1B,QAAQ,EAAE,eAAe,CAAC;KAC3B,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,gBAAgB,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,IAAI,CAAC;IACpD,qBAAqB,CAAC,EAAE,CACtB,KAAK,EAAE,0BAA0B,KAC9B,KAAK,CAAC,SAAS,CAAC;CACtB;AAED,eAAO,MAAM,SAAS,sDAEpB,CAAC"}
1
+ {"version":3,"file":"DayColumn.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/DayColumn.tsx"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAEnC,eAAO,MAAM,SAAS,4DAEpB,CAAC"}
@@ -1,3 +1,3 @@
1
1
  import { DayGridViewProps } from '../../types/calendar';
2
- export declare function DayGridView({ activeRange, timeZone, events, availability, unavailability, defaultUnavailable, timeAxis, initialScrollHour, scrollKey, onEventClick, snapDuration, placeholderDuration, selectedRange, onSelect, onSlotClick, className, classNames, hourHeight, columnMinWidth, renderHeader, renderEvent, selectionAppearance, dragPreviewAppearance, selectionRef, selectionLingerMs, selectedEventId, selectedEventRef, renderCorner, formatGutterLabel, backgroundEvents, renderBackgroundEvent, onSlotHover, multiDaySelection, eventGap, eventLayout, stackOffset, eventMinWidth, eventMaxStack, onOverflowClick, renderOverflowPopover, }: DayGridViewProps): import("react").JSX.Element;
2
+ export declare function DayGridView({ activeRange, timeZone, events, availability, unavailability, defaultUnavailable, timeAxis, initialScrollHour, scrollKey, onEventClick, snapDuration, placeholderDuration, selectedRange, onSelect, onSlotClick, className, classNames, hourHeight, columnMinWidth, renderHeader, renderEvent, selectionAppearance, dragPreviewAppearance, selectionRef, selectionLingerMs, onEventDrop, pendingDrop, pendingDropRef, selectedEventId, selectedEventRef, renderCorner, formatGutterLabel, backgroundEvents, renderBackgroundEvent, onSlotHover, multiDaySelection, eventGap, eventLayout, stackOffset, eventMinWidth, eventMaxStack, onOverflowClick, renderOverflowPopover, }: DayGridViewProps): import("react").JSX.Element;
3
3
  //# sourceMappingURL=DayGridView.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DayGridView.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/DayGridView.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAMV,gBAAgB,EAEjB,MAAM,kBAAkB,CAAC;AAoB1B,wBAAgB,WAAW,CAAC,EAC1B,WAAW,EACX,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,SAAS,EACT,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,iBAAqB,EACrB,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,iBAAyB,EACzB,QAAQ,EACR,WAAuB,EACvB,WAAe,EACf,aAAa,EACb,aAAa,EACb,eAAe,EACf,qBAAqB,GACtB,EAAE,gBAAgB,+BAkmBlB"}
1
+ {"version":3,"file":"DayGridView.d.ts","sourceRoot":"","sources":["../../../src/components/day-grid-view/DayGridView.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAMV,gBAAgB,EAGjB,MAAM,kBAAkB,CAAC;AAsB1B,wBAAgB,WAAW,CAAC,EAC1B,WAAW,EACX,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,iBAAiB,EACjB,SAAS,EACT,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,iBAAqB,EACrB,WAAW,EACX,WAAW,EACX,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,iBAAyB,EACzB,QAAQ,EACR,WAAuB,EACvB,WAAe,EACf,aAAa,EACb,aAAa,EACb,eAAe,EACf,qBAAqB,GACtB,EAAE,gBAAgB,+BAypBlB"}