@savvycal/calendar 0.13.0 → 0.15.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 (58) hide show
  1. package/README.md +112 -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 +113 -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 +347 -289
  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/lib/lanes.d.ts +2 -2
  54. package/dist/lib/lanes.d.ts.map +1 -1
  55. package/dist/lib/lanes.js +18 -18
  56. package/dist/types/calendar.d.ts +56 -0
  57. package/dist/types/calendar.d.ts.map +1 -1
  58. package/package.json +2 -2
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,21 @@ 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
+ | Prop | Type | Description |
203
+ | ------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
204
+ | `hiddenDates` | `PlainDate[]` | Days in `activeRange` to leave out, such as a weekend. The remaining days sit side by side. An all-day event spans the shown days it covers; one that covers only hidden days isn't drawn. |
205
+
206
+ 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
207
 
194
208
  #### Selection
195
209
 
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`. |
210
+ | Prop | Type | Description |
211
+ | ------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
212
+ | `selectedRange` | `DayGridSelectedRange \| null` | The currently selected time range (controlled). |
213
+ | `onSelect` | `(range: DayGridSelectedRange \| null) => void` | Called when the user selects or clears a range. |
214
+ | `selectionRef` | `Ref<HTMLDivElement>` | Ref attached to the selection overlay element (the first day of a multi-day selection). |
215
+ | `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. |
216
+ | `selectionLingerMs` | `number` | How long (ms) the selection stays in the DOM after clearing, so popover close transitions keep their reference. Default: `0`. |
203
217
 
204
218
  #### Background events
205
219
 
@@ -423,6 +437,7 @@ interface TimedCalendarEvent {
423
437
  ariaLabel?: string;
424
438
  priority?: number;
425
439
  interactive?: boolean;
440
+ draggable?: boolean;
426
441
  appearance?: 'filled' | 'outline';
427
442
  metadata?: Record<string, unknown>;
428
443
  }
@@ -449,6 +464,8 @@ The optional `ariaLabel` field provides a plain-text label used for `aria-label`
449
464
 
450
465
  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
466
 
467
+ Set `draggable: false` to keep an interactive timed event from being dragged when the view has `onEventDrop`. It can still be clicked.
468
+
452
469
  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
470
 
454
471
  `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 +561,39 @@ The preset uses a `.dark` class convention (matching Tailwind's `@custom-variant
544
561
 
545
562
  Every internal element can be restyled via the `classNames` prop. Each key maps to a specific part of the calendar:
546
563
 
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. |
564
+ | Key | Description |
565
+ | ---------------------- | ------------------------------------------------------------------------------------ |
566
+ | `root` | Outermost wrapper (scroll container). |
567
+ | `grid` | The CSS grid element. |
568
+ | `cornerCell` | Top-left corner cell (sticky). |
569
+ | `headerCell` | Resource column header cell (sticky). |
570
+ | `headerName` | Resource name text inside the header. |
571
+ | `headerAvatar` | Avatar image inside the header. |
572
+ | `gutterCell` | Time gutter cell for hour labels (sticky). |
573
+ | `gutterCellMinor` | Time gutter cell for sub-hour intervals. |
574
+ | `gutterLabel` | Text label inside gutter cells. |
575
+ | `bodyCell` | Hour-start body cell in the grid. |
576
+ | `bodyCellMinor` | Sub-hour body cell in the grid. |
577
+ | `eventColumn` | Container for events within a resource column. |
578
+ | `event` | Individual event element. |
579
+ | `eventSelected` | Additional classes applied to a selected event. |
580
+ | `eventOutline` | Additional classes for an event with `appearance: 'outline'`. |
581
+ | `eventDragSource` | An event being dragged, or awaiting confirmation of its drop, in its original place. |
582
+ | `eventColorBar` | Vertical color bar on the left edge of an event. |
583
+ | `eventTitle` | Event title text. |
584
+ | `eventTime` | Event time text. |
585
+ | `eventClientName` | Client name text on the event. |
586
+ | `nowIndicator` | Horizontal "now" indicator line. |
587
+ | `slotHighlight` | Hover highlight on time slots. |
588
+ | `selectionHighlight` | Drag selection highlight overlay. |
589
+ | `allDayCell` | All-day event row cell. |
590
+ | `unavailableOverlay` | Unavailable time cross-hatch overlay. |
591
+ | `overflowChip` | "+N more" chip shown when overlapping events exceed the cap. |
592
+ | `overflowChipLabel` | Label text inside the overflow chip. |
593
+ | `overflowPopover` | Built-in overflow popover panel. |
594
+ | `overflowPopoverEvent` | A single event row inside the overflow popover. |
595
+ | `overflowPopoverTitle` | Event title inside an overflow popover row. |
596
+ | `overflowPopoverTime` | Event time range inside an overflow popover row. |
579
597
 
580
598
  ### `resourceGridViewDefaults`
581
599
 
@@ -606,6 +624,8 @@ The `cn()` utility (re-exported from the library) merges Tailwind classes with c
606
624
 
607
625
  ## Selection & interaction
608
626
 
627
+ 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.
628
+
609
629
  ### Controlled selection
610
630
 
611
631
  Selection is controlled via `selectedRange` and `onSelect`:
@@ -707,6 +727,57 @@ const { refs, floatingStyles } = useFloating({
707
727
  }
708
728
  ```
709
729
 
730
+ ### Drag and drop with confirmation
731
+
732
+ 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.
733
+
734
+ 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.
735
+
736
+ ```tsx
737
+ const [pendingDrop, setPendingDrop] = useState<EventDrop | null>(null);
738
+
739
+ const { refs, floatingStyles } = useFloating({
740
+ open: pendingDrop !== null,
741
+ onOpenChange: (open) => {
742
+ if (!open) setPendingDrop(null);
743
+ },
744
+ placement: 'right',
745
+ whileElementsMounted: autoUpdate,
746
+ });
747
+
748
+ <ResourceGridView
749
+ onEventDrop={setPendingDrop}
750
+ pendingDrop={pendingDrop}
751
+ pendingDropRef={refs.setReference}
752
+ // ...
753
+ />;
754
+
755
+ {
756
+ pendingDrop && (
757
+ <div ref={refs.setFloating} style={floatingStyles}>
758
+ <button
759
+ onClick={() => {
760
+ moveEvent(pendingDrop); // update your events
761
+ setPendingDrop(null);
762
+ }}
763
+ >
764
+ Move
765
+ </button>
766
+ <button onClick={() => setPendingDrop(null)}>Cancel</button>
767
+ </div>
768
+ );
769
+ }
770
+ ```
771
+
772
+ ```ts
773
+ interface EventDrop {
774
+ event: TimedCalendarEvent; // The event before the drag
775
+ resourceId: string; // Where it was dropped (its own resource in DayGridView)
776
+ startTime: Temporal.ZonedDateTime;
777
+ endTime: Temporal.ZonedDateTime; // startTime plus the original duration
778
+ }
779
+ ```
780
+
710
781
  ### Slot and event clicks
711
782
 
712
783
  - `onSlotClick` fires when clicking an empty time slot, receiving the `resource`, `startTime`, and `endTime`.
@@ -750,6 +821,7 @@ export type {
750
821
  DayGridSelectedRange,
751
822
  PositionedEvent,
752
823
  SelectedRange,
824
+ EventDrop,
753
825
  SelectionAppearance,
754
826
  SelectionEventData,
755
827
  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;AAW3D,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,0DA6NxB,CAAC"}
@@ -1,117 +1,155 @@
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 q, jsx as M } from "react/jsx-runtime";
2
+ import { memo as y, useState as B, useRef as c, useEffect as N, useCallback as m } from "react";
3
+ import { clipDateSpan as F } from "../../lib/lanes.js";
4
+ import { findVerticalScrollParent as J, createAutoScroller as K } from "../../lib/autoScroll.js";
5
+ import { DISMISS_ONLY_ATTR as Q } from "../shared/AnchoredPopover.js";
6
+ import { AllDayEventChip as W } from "./AllDayEventChip.js";
7
+ import { useTouchDrag as Z, TOUCH_DRAG_STYLE as tt } from "../shared/useTouchDrag.js";
8
+ const lt = y(function({
9
+ positioned: d,
10
+ dates: s,
11
+ headerHeight: X,
12
+ cls: h,
13
+ onEventClick: _,
14
+ selectedEventId: O,
15
+ selectedEventRef: j,
16
+ onSelectDays: n,
17
+ resolveColumnId: T,
18
+ getScrollViewportLeft: L,
19
+ selectedDays: v,
20
+ selectionRef: k
17
21
  }) {
18
- const [o, A] = _(
22
+ const [u, z] = B(
19
23
  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;
24
+ ), R = c(u), f = c(s), b = c(n), S = c(T), A = c(L), g = c(0), a = c(null);
25
+ N(() => {
26
+ f.current = s, b.current = n, S.current = T, A.current = L;
23
27
  });
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]
28
+ const D = (t) => {
29
+ R.current = t, z(t);
30
+ }, w = m(() => {
31
+ const t = R.current, r = S.current?.(g.current);
32
+ if (!t || !r) return;
33
+ const e = f.current.findIndex((o) => o.toString() === r);
34
+ e !== -1 && e !== t.current && D({ ...t, current: e });
35
+ }, []), x = m(
36
+ (t) => {
37
+ g.current = t, w(), a.current?.ensure();
38
+ },
39
+ [w]
40
+ ), l = m(
41
+ (t) => x(t.clientX),
42
+ [x]
43
+ ), p = m(
44
+ (t) => {
45
+ a.current?.stop(), a.current = null, document.removeEventListener("mousemove", l);
46
+ const r = R.current;
47
+ if (D(null), !r || !t) return;
48
+ const e = Math.min(r.anchor, r.current), o = Math.max(r.anchor, r.current);
49
+ b.current?.({
50
+ startDate: f.current[e],
51
+ endDate: f.current[o]
52
+ });
53
+ },
54
+ [l]
55
+ ), C = m(() => p(!0), [p]);
56
+ N(() => () => {
57
+ a.current?.stop(), document.removeEventListener("mousemove", l), document.removeEventListener("mouseup", C);
58
+ }, [l, C]);
59
+ const P = (t, r, e) => {
60
+ n?.(null), D({ anchor: t, current: t }), g.current = r;
61
+ const o = J(e);
62
+ a.current?.stop(), a.current = K({
63
+ getScrollParent: () => o,
64
+ horizontal: {
65
+ getPointerX: () => g.current,
66
+ getViewportLeft: () => A.current?.()
67
+ },
68
+ onScroll: w
69
+ });
70
+ }, H = (t) => (r) => {
71
+ r.button === 0 && (r.preventDefault(), P(t, r.clientX, r.currentTarget), document.addEventListener("mousemove", l), document.addEventListener("mouseup", C, { once: !0 }));
72
+ }, I = c(null), U = Z(I, n != null), V = (t) => (r) => {
73
+ const e = r.currentTarget;
74
+ U(r, {
75
+ start: (o) => P(t, o, e),
76
+ move: (o) => x(o),
77
+ end: () => p(!0),
78
+ cancel: () => p(!1)
39
79
  });
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
80
  };
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)
81
+ let i = null;
82
+ if (u)
83
+ i = {
84
+ first: Math.min(u.anchor, u.current),
85
+ last: Math.max(u.anchor, u.current)
52
86
  };
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
87
+ else if (v) {
88
+ const t = F(
89
+ v.startDate,
90
+ v.endDate,
91
+ s
57
92
  );
58
- t <= n && (a = { first: t, last: n });
93
+ t && (i = { first: t.startCol, last: t.startCol + t.span - 1 });
59
94
  }
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(
95
+ const Y = d.length > 0 ? Math.max(...d.map((t) => t.lane)) + 1 : 0, E = d.length > 0, $ = E ? "4px" : "0px", G = E ? `${$} repeat(${Y}, auto) ${$}` : "auto";
96
+ return /* @__PURE__ */ q(
62
97
  "div",
63
98
  {
64
- className: m("allDayLane"),
99
+ ref: I,
100
+ className: h("allDayLane"),
65
101
  style: {
66
102
  gridRow: 2,
67
103
  gridColumn: "2 / -1",
68
104
  display: "grid",
69
105
  gridTemplateColumns: "subgrid",
70
- gridTemplateRows: T,
106
+ gridTemplateRows: G,
71
107
  position: "sticky",
72
- top: L,
108
+ top: X,
73
109
  zIndex: 20,
74
110
  gap: "2px 0"
75
111
  },
76
112
  children: [
77
- e.map((t, n) => /* @__PURE__ */ M(
113
+ s.map((t, r) => /* @__PURE__ */ M(
78
114
  "div",
79
115
  {
80
- className: n < e.length - 1 ? "border-r border-cal-border" : void 0,
116
+ className: r < s.length - 1 ? "border-r border-cal-border" : void 0,
81
117
  style: {
82
- gridColumn: n + 1,
118
+ gridColumn: r + 1,
83
119
  gridRow: "1 / -1",
84
- pointerEvents: r ? "auto" : "none",
85
- cursor: r ? "pointer" : void 0
120
+ pointerEvents: n ? "auto" : "none",
121
+ cursor: n ? "pointer" : void 0,
122
+ ...n && tt
86
123
  },
87
124
  "data-day-column": t.toString(),
88
- ...r ? { [z]: "" } : {},
89
- onMouseDown: r ? N(n) : void 0
125
+ ...n ? { [Q]: "" } : {},
126
+ onMouseDown: n ? H(r) : void 0,
127
+ onPointerDown: n ? V(r) : void 0
90
128
  },
91
129
  t.toString()
92
130
  )),
93
- a && /* @__PURE__ */ M(
131
+ i && /* @__PURE__ */ M(
94
132
  "div",
95
133
  {
96
- ref: o ? void 0 : $,
134
+ ref: u ? void 0 : k,
97
135
  "aria-hidden": "true",
98
- className: m("selectionHighlight"),
136
+ className: h("selectionHighlight"),
99
137
  style: {
100
- gridColumn: `${a.first + 1} / ${a.last + 2}`,
138
+ gridColumn: `${i.first + 1} / ${i.last + 2}`,
101
139
  gridRow: "1 / -1",
102
140
  pointerEvents: "none"
103
141
  }
104
142
  }
105
143
  ),
106
- c.map((t) => /* @__PURE__ */ M(
107
- H,
144
+ d.map((t) => /* @__PURE__ */ M(
145
+ W,
108
146
  {
109
147
  positioned: t,
110
- laneOffset: p ? 1 : 0,
111
- cls: m,
112
- onEventClick: b,
113
- selectedEventId: y,
114
- selectedEventRef: I
148
+ laneOffset: E ? 1 : 0,
149
+ cls: h,
150
+ onEventClick: _,
151
+ selectedEventId: O,
152
+ selectedEventRef: j
115
153
  },
116
154
  t.event.id
117
155
  ))
@@ -120,5 +158,5 @@ const F = O(function({
120
158
  );
121
159
  });
122
160
  export {
123
- F as AllDaySection
161
+ lt as AllDaySection
124
162
  };
@@ -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, hiddenDates, 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,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,+BA2pBlB"}