@weekwise/react 0.3.0 → 0.4.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 (198) hide show
  1. package/README.md +69 -9
  2. package/dist/Calendar.d.ts +4 -3
  3. package/dist/Calendar.js +20 -0
  4. package/dist/Calendar.js.map +1 -0
  5. package/dist/Calendar.module.css.js +11 -0
  6. package/dist/Calendar.module.css.js.map +1 -0
  7. package/dist/Calendar.types.d.ts +34 -6
  8. package/dist/CalendarBase.d.ts +8 -0
  9. package/dist/CalendarBase.js +161 -0
  10. package/dist/CalendarBase.js.map +1 -0
  11. package/dist/components/calendar-toolbar/CalendarToolbar.js +51 -0
  12. package/dist/components/calendar-toolbar/CalendarToolbar.js.map +1 -0
  13. package/dist/components/calendar-toolbar/CalendarToolbar.module.css.js +15 -0
  14. package/dist/components/calendar-toolbar/CalendarToolbar.module.css.js.map +1 -0
  15. package/dist/components/date-navigator/DateNavigator.js +129 -0
  16. package/dist/components/date-navigator/DateNavigator.js.map +1 -0
  17. package/dist/components/date-navigator/DateNavigator.module.css.js +25 -0
  18. package/dist/components/date-navigator/DateNavigator.module.css.js.map +1 -0
  19. package/dist/components/day-week-drawer/DayWeekDrawer.js +227 -0
  20. package/dist/components/day-week-drawer/DayWeekDrawer.js.map +1 -0
  21. package/dist/components/day-week-drawer/DayWeekDrawer.module.css.js +15 -0
  22. package/dist/components/day-week-drawer/DayWeekDrawer.module.css.js.map +1 -0
  23. package/dist/components/day-week-event/DayWeekEvent.js +154 -0
  24. package/dist/components/day-week-event/DayWeekEvent.js.map +1 -0
  25. package/dist/components/day-week-event/DayWeekEvent.module.css.js +17 -0
  26. package/dist/components/day-week-event/DayWeekEvent.module.css.js.map +1 -0
  27. package/dist/components/day-week-event/DayWeekEventPreview.js +26 -0
  28. package/dist/components/day-week-event/DayWeekEventPreview.js.map +1 -0
  29. package/dist/components/day-week-view/DayWeekView.js +226 -0
  30. package/dist/components/day-week-view/DayWeekView.js.map +1 -0
  31. package/dist/components/day-week-view/DayWeekView.module.css.js +27 -0
  32. package/dist/components/day-week-view/DayWeekView.module.css.js.map +1 -0
  33. package/dist/components/day-week-view/HiddenEvents.js +78 -0
  34. package/dist/components/day-week-view/HiddenEvents.js.map +1 -0
  35. package/dist/components/day-week-view/useTimeColumnWidth.js +34 -0
  36. package/dist/components/day-week-view/useTimeColumnWidth.js.map +1 -0
  37. package/dist/components/drag-overlay/DragOverlay.js +98 -0
  38. package/dist/components/drag-overlay/DragOverlay.js.map +1 -0
  39. package/dist/components/drag-overlay/DragOverlay.module.css.js +12 -0
  40. package/dist/components/drag-overlay/DragOverlay.module.css.js.map +1 -0
  41. package/dist/components/index.d.ts +1 -0
  42. package/dist/components/month-view/MonthView.d.ts +8 -2
  43. package/dist/components/month-view/MonthView.js +105 -0
  44. package/dist/components/month-view/MonthView.js.map +1 -0
  45. package/dist/components/month-view/MonthView.module.css.js +30 -0
  46. package/dist/components/month-view/MonthView.module.css.js.map +1 -0
  47. package/dist/components/month-view/MonthView.utils.js +14 -0
  48. package/dist/components/month-view/MonthView.utils.js.map +1 -0
  49. package/dist/components/month-view/MonthViewDay.d.ts +2 -0
  50. package/dist/components/month-view/MonthViewDay.js +75 -0
  51. package/dist/components/month-view/MonthViewDay.js.map +1 -0
  52. package/dist/components/month-view/MonthViewEvent.js +132 -0
  53. package/dist/components/month-view/MonthViewEvent.js.map +1 -0
  54. package/dist/components/month-view/MonthViewEventPreview.js +28 -0
  55. package/dist/components/month-view/MonthViewEventPreview.js.map +1 -0
  56. package/dist/components/month-view/MonthViewWeek.d.ts +5 -0
  57. package/dist/components/month-view/MonthViewWeek.js +67 -0
  58. package/dist/components/month-view/MonthViewWeek.js.map +1 -0
  59. package/dist/components/month-view/useMonthLanes.js +22 -0
  60. package/dist/components/month-view/useMonthLanes.js.map +1 -0
  61. package/dist/components/month-view/useMonthResize.js +57 -0
  62. package/dist/components/month-view/useMonthResize.js.map +1 -0
  63. package/dist/components/nav-btn/NavBtn.js +28 -0
  64. package/dist/components/nav-btn/NavBtn.js.map +1 -0
  65. package/dist/components/nav-btn/NavBtn.module.css.js +11 -0
  66. package/dist/components/nav-btn/NavBtn.module.css.js.map +1 -0
  67. package/dist/components/pointer-popover/PointerPopover.js +22 -0
  68. package/dist/components/pointer-popover/PointerPopover.js.map +1 -0
  69. package/dist/components/pointer-popover/PointerPopover.module.css.js +6 -0
  70. package/dist/components/pointer-popover/PointerPopover.module.css.js.map +1 -0
  71. package/dist/components/timeline-view/TimelineView.d.ts +6 -0
  72. package/dist/components/timeline-view/TimelineView.js +10 -0
  73. package/dist/components/timeline-view/TimelineView.js.map +1 -0
  74. package/dist/components/timeline-view/index.d.ts +1 -0
  75. package/dist/components/view-select/ViewSelect.d.ts +1 -1
  76. package/dist/components/view-select/ViewSelect.js +117 -0
  77. package/dist/components/view-select/ViewSelect.js.map +1 -0
  78. package/dist/components/view-select/ViewSelect.module.css.js +14 -0
  79. package/dist/components/view-select/ViewSelect.module.css.js.map +1 -0
  80. package/dist/contexts/CalendarContext.js +14 -0
  81. package/dist/contexts/CalendarContext.js.map +1 -0
  82. package/dist/contexts/CalendarViewportContext.js +14 -0
  83. package/dist/contexts/CalendarViewportContext.js.map +1 -0
  84. package/dist/contexts/DayWeekDrawerContext.js +14 -0
  85. package/dist/contexts/DayWeekDrawerContext.js.map +1 -0
  86. package/dist/contexts/DayWeekViewContext.js +14 -0
  87. package/dist/contexts/DayWeekViewContext.js.map +1 -0
  88. package/dist/contexts/ThemeSourceContext.js +9 -0
  89. package/dist/contexts/ThemeSourceContext.js.map +1 -0
  90. package/dist/date-localization/DateLocalizationContext.js +9 -0
  91. package/dist/date-localization/DateLocalizationContext.js.map +1 -0
  92. package/dist/date-localization/DateLocalizationProvider.js +20 -0
  93. package/dist/date-localization/DateLocalizationProvider.js.map +1 -0
  94. package/dist/date-localization/MessagesContext.js +9 -0
  95. package/dist/date-localization/MessagesContext.js.map +1 -0
  96. package/dist/date-localization/useDateUtils.js +15 -0
  97. package/dist/date-localization/useDateUtils.js.map +1 -0
  98. package/dist/date-localization/useMessages.js +13 -0
  99. package/dist/date-localization/useMessages.js.map +1 -0
  100. package/dist/hooks/useAbsEventRect.js +27 -0
  101. package/dist/hooks/useAbsEventRect.js.map +1 -0
  102. package/dist/hooks/useAutoScroller.js +83 -0
  103. package/dist/hooks/useAutoScroller.js.map +1 -0
  104. package/dist/hooks/useCalendarSize.js +20 -0
  105. package/dist/hooks/useCalendarSize.js.map +1 -0
  106. package/dist/hooks/useCalendarValue.d.ts +1 -1
  107. package/dist/hooks/useCalendarValue.js +51 -0
  108. package/dist/hooks/useCalendarValue.js.map +1 -0
  109. package/dist/hooks/useCanResizeEvent.js +29 -0
  110. package/dist/hooks/useCanResizeEvent.js.map +1 -0
  111. package/dist/hooks/useComputed.js +14 -0
  112. package/dist/hooks/useComputed.js.map +1 -0
  113. package/dist/hooks/useControlled.js +20 -0
  114. package/dist/hooks/useControlled.js.map +1 -0
  115. package/dist/hooks/useControlled.utils.js +33 -0
  116. package/dist/hooks/useControlled.utils.js.map +1 -0
  117. package/dist/hooks/useCurrentRef.js +10 -0
  118. package/dist/hooks/useCurrentRef.js.map +1 -0
  119. package/dist/hooks/useDocumentCursor.js +13 -0
  120. package/dist/hooks/useDocumentCursor.js.map +1 -0
  121. package/dist/hooks/useEventCallback.js +12 -0
  122. package/dist/hooks/useEventCallback.js.map +1 -0
  123. package/dist/hooks/useEventCallback.utils.js +20 -0
  124. package/dist/hooks/useEventCallback.utils.js.map +1 -0
  125. package/dist/hooks/useEventResize.js +106 -0
  126. package/dist/hooks/useEventResize.js.map +1 -0
  127. package/dist/hooks/useGlobalListeners.js +40 -0
  128. package/dist/hooks/useGlobalListeners.js.map +1 -0
  129. package/dist/hooks/useInterval.js +14 -0
  130. package/dist/hooks/useInterval.js.map +1 -0
  131. package/dist/hooks/useIsomorphicLayoutEffect.js +6 -0
  132. package/dist/hooks/useIsomorphicLayoutEffect.js.map +1 -0
  133. package/dist/hooks/useItemsLayout.js +53 -0
  134. package/dist/hooks/useItemsLayout.js.map +1 -0
  135. package/dist/hooks/useMergedRefs.js +10 -0
  136. package/dist/hooks/useMergedRefs.js.map +1 -0
  137. package/dist/hooks/useMove.js +180 -0
  138. package/dist/hooks/useMove.js.map +1 -0
  139. package/dist/hooks/useMoveTransform.js +118 -0
  140. package/dist/hooks/useMoveTransform.js.map +1 -0
  141. package/dist/hooks/useMutationObserver.js +16 -0
  142. package/dist/hooks/useMutationObserver.js.map +1 -0
  143. package/dist/hooks/useNavigation.js +15 -0
  144. package/dist/hooks/useNavigation.js.map +1 -0
  145. package/dist/hooks/usePrevious.js +12 -0
  146. package/dist/hooks/usePrevious.js.map +1 -0
  147. package/dist/hooks/useRect.js +37 -0
  148. package/dist/hooks/useRect.js.map +1 -0
  149. package/dist/hooks/useRefList.js +21 -0
  150. package/dist/hooks/useRefList.js.map +1 -0
  151. package/dist/hooks/useRefWithInit.js +11 -0
  152. package/dist/hooks/useRefWithInit.js.map +1 -0
  153. package/dist/hooks/useResizeObserver.js +16 -0
  154. package/dist/hooks/useResizeObserver.js.map +1 -0
  155. package/dist/hooks/useScrollBarSize.js +37 -0
  156. package/dist/hooks/useScrollBarSize.js.map +1 -0
  157. package/dist/hooks/useScrollIntent.js +41 -0
  158. package/dist/hooks/useScrollIntent.js.map +1 -0
  159. package/dist/hooks/useScrollOffsets.js +33 -0
  160. package/dist/hooks/useScrollOffsets.js.map +1 -0
  161. package/dist/hooks/useScrollOffsetsDelta.js +16 -0
  162. package/dist/hooks/useScrollOffsetsDelta.js.map +1 -0
  163. package/dist/hooks/useScrollableAncestors.js +14 -0
  164. package/dist/hooks/useScrollableAncestors.js.map +1 -0
  165. package/dist/hooks/useScrollableAncestorsRects.js +32 -0
  166. package/dist/hooks/useScrollableAncestorsRects.js.map +1 -0
  167. package/dist/hooks/useStateRef.js +16 -0
  168. package/dist/hooks/useStateRef.js.map +1 -0
  169. package/dist/hooks/useTimeInterval.js +25 -0
  170. package/dist/hooks/useTimeInterval.js.map +1 -0
  171. package/dist/hooks/useTimeOffset.js +24 -0
  172. package/dist/hooks/useTimeOffset.js.map +1 -0
  173. package/dist/hooks/useToday.js +26 -0
  174. package/dist/hooks/useToday.js.map +1 -0
  175. package/dist/icons/chevron.js +20 -0
  176. package/dist/icons/chevron.js.map +1 -0
  177. package/dist/index.cjs +1 -1
  178. package/dist/index.cjs.map +1 -1
  179. package/dist/index.d.ts +3 -0
  180. package/dist/index.js +12 -2798
  181. package/dist/portal/Portal.js +31 -0
  182. package/dist/portal/Portal.js.map +1 -0
  183. package/dist/style.css +1 -1
  184. package/dist/utils/mergeRefs.js +15 -0
  185. package/dist/utils/mergeRefs.js.map +1 -0
  186. package/dist/views/dayView.d.ts +4 -0
  187. package/dist/views/dayView.js +13 -0
  188. package/dist/views/dayView.js.map +1 -0
  189. package/dist/views/index.d.ts +4 -0
  190. package/dist/views/monthView.d.ts +9 -0
  191. package/dist/views/monthView.js +20 -0
  192. package/dist/views/monthView.js.map +1 -0
  193. package/dist/views/types.d.ts +30 -0
  194. package/dist/views/weekView.d.ts +4 -0
  195. package/dist/views/weekView.js +13 -0
  196. package/dist/views/weekView.js.map +1 -0
  197. package/package.json +7 -7
  198. package/dist/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":["createContext","isDevEnvironment","useContext","createContext","isDevEnvironment","useMemo","resolveMessages","_jsx","useContext","resolveMessages","useLayoutEffect","useEffect","useRef","useMemo","useEffect","useState","getCalendarSize","useRef","useRef","useMemo","useState","useRef","useEffect","useState","isDevEnvironment","useCallback","useEffect","useRef","isDevEnvironment","useInsertionEffect","useState","useMemo","useEffect","useEffect","Rect","getClientRect","useMemo","useState","useRef","useEffect","useMemo","useRef","useEffect","useState","startTransition","useState","useRef","useCallback","useRef","useEffect","useState","useEffect","createContext","isDevEnvironment","useContext","createContext","isDevEnvironment","useCallback","normalizeViewValue","mergeCallbacks","useRef","useEffect","transferDay","getViewChangeTarget","getNavigationTarget","_jsx","useSyncExternalStore","THEME_PROPERTIES","useContext","createPortal","_jsx","useState","useRef","useFloating","offset","flip","shift","autoUpdate","useEffect","useMemo","getViewHeading","getMonthGrid","_jsxs","styles","cx","_jsx","formatMonthYear","isInViewPeriod","mergeCallbacks","_jsx","cx","styles","useId","useState","useRef","useFloating","offset","flip","shift","autoUpdate","useEffect","_jsxs","_Fragment","cx","styles","_jsx","mergeCallbacks","cx","styles","_jsxs","_jsx","createContext","isDevEnvironment","useContext","_jsx","cx","styles","useDragAndDrop","useMemo","useRef","useState","_jsx","cx","styles","_jsxs","useRef","useDragAndDrop","useEffect","toDayMinutes","_jsx","cx","styles","useRef","useCallback","useRef","useMemo","useCallback","useEffect","getScrollDirectionAndSpeed","useRef","useMemo","useEffect","getClientRect","useReducer","isHTMLElement","shallowEqual","defaultValue","useRef","useMemo","getScrollableAncestors","useEffect","getClientRect","useReducer","getWindow","Rect","useState","useRef","useCallback","getScrollableElement","getScrollCoordinates","useEffect","isNotNull","useMemo","add","defaultCoordinates","getScrollOffsets","emptyArray","useRef","useEffect","defaultCoordinates","subtract","useReducer","useMemo","add","adjustScrollRect","applyMoveTransformModifiers","match","useRef","useDragAndDrop","MONTH_WEEK_GEOMETRY","useEffect","_jsxs","cx","styles","_jsx","_jsx","cx","styles","useRef","_jsx","_jsxs","styles","useState","getMonthLaneCount","resizeEventDays","useMemo","getEventTimeFrameFromInfo","useRef","useMemo","getMonthGrid","getWeekdayNames","arrangeMonthWeek","_jsxs","cx","styles","_jsx","useState","useRef","useCallback","resizeEventRange","getTimeFrame","isPastDay","useMemo","toDayMinutes","fromDayMinutes","createContext","isDevEnvironment","useContext","createContext","isDevEnvironment","useContext","useState","useMemo","getNowOffset","useRef","useDragAndDrop","useMemo","boundingResizableContainerModifier","getTimeStepEqualizerModifier","useEffect","toDayMinutes","TOUCH_HOLD_DELAY","formatNowOffset","_jsxs","cx","styles","_jsx","_Fragment","useState","getClientRect","subtract","round","useState","useRef","useDragAndDrop","mergeCallbacks","useEffect","omit","cx","styles","_jsx","_Fragment","_jsxs","getTimeStepEqualizerModifier","boundingDraggableContainerModifier","applyMoveTransformModifiers","_jsx","styles","useState","useEffect","useMemo","getHiddenEvents","getRevealScrollTop","formatNowOffset","_jsxs","styles","_jsx","useState","ROW_HEIGHTS","useRef","useMemo","buildTimeRows","getVisibleDays","arrangeEventsByDay","splitIntoDays","useCallback","getDayTimeFrame","styles","_jsx","_jsxs","_Fragment","cx","props","useRef","createDragAndDropApi","TOUCH_HOLD_DELAY","useMemo","buildEventMap","getEventTimeFrameFromInfo","getTimelineRange","formatTimelineRange","useEffect","_jsx","cx","styles","DragAndDropContext","_jsxs","react","_weekwise_core","_weekwise_dnd","_weekwise_dnd_react","_floating_ui_react_dom","react_jsx_runtime","react_dom","DateLocalizationContext","useDateUtils","context","useCalendarDateUtils","MessagesContext","useMessages","messages","dateUtils","useIsomorphicLayoutEffect","useResizeObserver","cb","disabled","cbRef","resizeObserver","ResizeObserver","useCalendarSize","ref","size","setSize","observer","entry","width","element","useCurrentRef","value","currentRef","useComputed","deps","valueRef","newValue","useIsControlled","controlledValue","isControlled","useAssert","defaultValue","defaultValueProp","error","useControlled","params","controlled","valueState","setValueState","setValueIfUncontrolled","useDocumentCursor","cursor","className","root","UNINITIALIZED","useRefWithInit","init","initArg","assertNotCalled","createStableCallback","stable","args","useEventCallback","callback","useGlobalListeners","globalListeners","addGlobalListener","removeGlobalListener","removeAllGlobalListeners","target","type","listener","options","fn","event","useItemsLayout","containerRef","itemsRef","layout","createItemsLayout","container","items","take","rect","item","left","top","right","bottom","x","y","axis","best","bestDistance","box","index","dx","dy","distance","toFnRef","mergeRefs","refs","useMergedRefs","useMove","state","paramsRef","clearHold","listeners","attr","stopEvent","update","coordinates","pointerId","handlers","clientX","clientY","prevClientX","prevClientY","getCommonEventData","pointerType","deltaX","deltaY","initialDeltaX","initialDeltaY","onMouseMove","onMouseUp","onTouchMove","touch","identifier","trouchEvent","onTouchEnd","removePointerListeners","onPointerMove","onPointerUp","releaseHold","TOUCH_HOLD_TOLERANCE","startPointer","touchDelay","HOLD_VIBRATION","triggerKeyboardMove","start","move","end","preventTouchScroll","node","usePrevious","useRefList","createRefList","elements","buildUseScrollbarSizeHook","count","elementFabric","resizeCallback","dimensions","setDimensions","updateState","scrollbarHeight","scrollbarWidth","currentDimensions","height","cleanup","useScrollBarSize","useStateRef","initialValue","setState","next","useTimeInterval","interval","isActive","timerRef","callbackRef","now","delay","startOfToday","useToday","current","today","nextMidnight","timer","CalendarContext","useCalendarContext","ThemeSourceContext","useCalendarValue","view","defaultView","startWeek","viewValue","defaultViewValue","onChangeView","onChangeViewValue","controlledView","setControlledView","calculateViewValue","controlledViewValue","setControlledViewValue","changeViewValue","changeView","newView","currentViewValueRef","previousViewRef","previousStartWeekRef","previousDateUtilsRef","fromView","startWeekChanged","previousDateUtils","nextValue","useNavigation","navigate","from","direction","ChevronIcon","props","subscribe","getClientSnapshot","getServerSnapshot","useIsHydrated","readTheme","source","theme","computed","name","Portal","children","hydrated","themeSource","DateNavigator_module_default","DateNavigator","renderHeading","onClick","onKeyDown","buttonProps","getStartOfWeek","getStartOfMonth","addMonths","open","setOpen","pickerMonth","setPickerMonth","rootRef","floatingStyles","handlePointerDown","heading","gridDays","handleToggleClick","prev","handleToggleKeyDown","handleSelectDay","day","isOutsideMonth","isToday","isSelected","isRangeStart","isRangeEnd","NavBtn_module_default","NavBtn","goForward","goBackward","handleClick","ViewSelect_module_default","VIEWS","ViewSelect","id","active","setActive","optionRefs","close","returnFocus","reference","openList","focused","select","handleListKeyDown","moveTo","listId","option","CalendarToolbar_module_default","CalendarToolbar","goToday","rootProps","viewTabProps","todayProps","CalendarViewportContext","useCalendarViewportContext","PointerPopover_module_default","PointerPopover","style","DragOverlay_module_default","WHOLE_EVENT","DragOverlay","showPreview","pxPerMinute","eventMap","eventRenderer","pointerPreviewRenderer","viewportRef","isDragging","canDrop","dropData","eventItem","transform","draggable","overlay","droppable","eventValue","key","lastRef","droppedRef","isPlaced","setIsPlaced","returning","setReturning","last","sourceRect","containerRect","isBlocked","cssVariables","variables","splitIntoWeeks","days","_","week","MonthView_module_default","MonthViewDay","forwardedRef","targetDate","onDoubleClick","onEventChange","onEventCreate","getIsDayDisabled","getHours","getMinutes","getNow","register","isOver","registerDropTarget","dropTargetElement","dragItem","data","eventData","sourceDay","shift","types","allowedOperations","handleDoubleClick","handleRootRef","useInterval","intervalRef","duration","defaultScrollIntent","useScrollIntent","delta","previousDelta","previousIntent","useAutoScroller","acceleration","activator","canScroll","enabled","pointerCoordinates","order","threshold","activeNodeRect","scrollableAncestors","scrollableAncestorsRects","setAutoScrollInterval","clearAutoScrollInterval","scrollIntent","scrollSpeed","scrollDirection","scrollContainerRef","sortedScrollableAncestorsWithRects","autoScroll","scrollContainer","scrollLeft","scrollTop","scrollContainerRect","speed","useMutationObserver","mutationObserver","MutationObserver","useRect","measure","fallbackRect","measureRect","reducer","records","record","currentRect","newRect","defaultValue$1","useScrollableAncestors","limit","previousNode","ancestors","useScrollableAncestorsRects","rects","measureRects","window","useScrollOffsets","scrollCoordinates","setScrollCoordinates","prevElements","handleScroll","scrollingElement","previousElements","entries","scrollableElement","acc","useScrollOffsetsDelta","scrollOffsets","dependencies","initialScrollOffsets","hasScrollOffsets","UseMoveTransformActionTypes","defaultMoveTransformState","useMoveTransform","autoScrollEnabled","modifiers","activeNode","containerNode","dispatch","defaultMoveTransformReducer","resolvedActiveNode","resolvedContainerNode","containerNodeRect","scrollAdjustment","actions","buildAction","scrollAdjustmentTranslate","scrollAdjustmentActiveNodeRect","scrollAdjustmentContainerNodeRect","action","BAR_INSET","MonthViewEvent","weekDays","weekRef","resizable","resize","isResizeSource","isAnyResizing","grabbedDayRef","attributes","overElement","setOverlayTransform","registerDragSource","setTransform","overDayRect","translate","initialTranslate","minTop","maxTop","syncTransform","getDragItems","\"event\"","column","clamped","resizeListeners","edge","resizeStartListeners","resizeEndListeners","multiDay","MonthViewEventPreview","bar","MonthViewWeek","firstDayIndex","cellRef","sourceBars","lanes","resizingKey","getMonthDay","isSameMonth","toMillis","isResizing","renderEvent","renderBar","useMonthLanes","maxLanes","setLanes","useMonthResize","cellsRef","session","setSession","sessionRef","commit","handleKeyDown","shownEventMap","date","NO_BARS","MonthView","cells","weeks","weekdayNames","layouts","shownLayouts","contextValue","weekdayName","weekIndex","DAY","useEventResize","columnsRef","bounds","timeStep","preventOutBoundsChanges","offset","timelineMinutes","viewport","minute","dayIndex","idx","original","range","DayWeekViewContext","useDayWeekViewContext","DayWeekDrawerContext","useDayWeekDrawerContext","useTimeOffset","hideMinMaxTime","hourMin","hourMax","tick","setTick","DayWeekDrawer_module_default","DayWeekDrawer","getTimeFrame","isBefore","stepPx","toMinutes","px","toTimelineMinutes","getTimeFramePx","getTransform","todayOrPast","isTodayFlag","resizingActiveNodeRect","offsetY","compensation","bottomEdge","topEdge","timeOffset","offLimits","startOfEvent","partDay","fromStart","dayShift","isPast","moveListeners","moveRef","currentTop","drawerContextValue","timeOffsetTitle","renderPreview","useAbsEventRect","relativeRect","absEventRect","setAbsEventRect","rootEl","parentEl","positions","useCanResizeEvent","eventDate","absRect","canResize","setCanResize","bottomRect","DayWeekEvent_module_default","DayWeekEvent","topBarRef","bottomBarRef","resizing","drawerRef","overData","activeDrawerRect","ctx","getEventTransformModifiers","moveEndHandler","e","resizeBottomListeners","resizeTopListeners","isDragginOverlay","rootClassName","rootStyle","DayWeekEventPreview","part","percent","minutes","DayWeekView_module_default","HiddenEvents","scrollerRef","columns","rowHeight","scroll","setScroll","scroller","hidden","events","reveal","renderButton","nearest","label","above","below","useTimeColumnWidth","labelsRef","labels","defaultWidth","setWidth","cancelled","needed","text","outside","themed","TIME_COLUMN_WIDTH","DayWeekView","rowHeightProp","scrollable","getWeekDay","weekDayShortName","bodyRef","timeRows","timeLabels","time","timeLabelElements","timeColumnWidth","eventGroups","eventColumns","previewOf","resizeParts","resizingValue","weekDayNumber","eventsByDay","scrollbarSize","headClassName","bodyClassName","viewportClassName","columnClassName","headerCellClassName","headerCellDayClassName","rowClassName","timeClassName","timeStepClassName","handleViewportRef","viewportContextValue","weekDay","steps","step","overTime","Calendar_module_default","Calendar","publicProps","timeFrame","startWeekProp","onEventDelete","onEventEdit","eventTimeFrameResolver","eventKeyResolver","pointerPreviewFormat","viewProp","defaultViewProp","viewValueProp","defaultViewValueProp","onChangeViewProp","onChangeViewValueProp","restProps","resolversRef","dragAndDropApi","handleOnEventChange","eventKey","info","handleOnEventCreate","handleOnEventEdit","handleOnEventDelete","pointerPreviewRendererRef","to","eventRendererRef","adapter","resolvedMessages"],"sources":["../src/date-localization/DateLocalizationContext.ts","../src/date-localization/useDateUtils.ts","../src/date-localization/MessagesContext.ts","../src/date-localization/DateLocalizationProvider.tsx","../src/date-localization/useMessages.ts","../src/hooks/useIsomorphicLayoutEffect.ts","../src/hooks/useResizeObserver.ts","../src/hooks/useCalendarSize.ts","../src/hooks/useCurrentRef.ts","../src/hooks/useComputed.ts","../src/hooks/useControlled.utils.ts","../src/hooks/useControlled.ts","../src/hooks/useDocumentCursor.ts","../src/hooks/useRefWithInit.ts","../src/hooks/useEventCallback.utils.ts","../src/hooks/useEventCallback.ts","../src/hooks/useGlobalListeners.ts","../src/hooks/useItemsLayout.ts","../src/utils/mergeRefs.ts","../src/hooks/useMergedRefs.ts","../src/hooks/useMove.ts","../src/hooks/usePrevious.ts","../src/hooks/useRefList.ts","../src/hooks/useScrollBarSize.ts","../src/hooks/useStateRef.ts","../src/hooks/useTimeInterval.ts","../src/hooks/useToday.ts","../src/contexts/CalendarContext.ts","../src/contexts/ThemeSourceContext.ts","../src/hooks/useCalendarValue.ts","../src/hooks/useNavigation.ts","../src/icons/chevron.tsx","../src/portal/Portal.tsx","../src/components/date-navigator/DateNavigator.tsx","../src/components/nav-btn/NavBtn.tsx","../src/components/view-select/ViewSelect.tsx","../src/components/calendar-toolbar/CalendarToolbar.tsx","../src/contexts/CalendarViewportContext.ts","../src/components/pointer-popover/PointerPopover.tsx","../src/components/drag-overlay/DragOverlay.tsx","../src/components/month-view/MonthView.utils.ts","../src/components/month-view/MonthViewDay.tsx","../src/hooks/useInterval.ts","../src/hooks/useScrollIntent.ts","../src/hooks/useAutoScroller.ts","../src/hooks/useMutationObserver.ts","../src/hooks/useRect.ts","../src/hooks/useScrollableAncestors.ts","../src/hooks/useScrollableAncestorsRects.ts","../src/hooks/useScrollOffsets.ts","../src/hooks/useScrollOffsetsDelta.ts","../src/hooks/useMoveTransform.ts","../src/components/month-view/MonthViewEvent.tsx","../src/components/month-view/MonthViewEventPreview.tsx","../src/components/month-view/MonthViewWeek.tsx","../src/components/month-view/useMonthLanes.ts","../src/components/month-view/useMonthResize.ts","../src/components/month-view/MonthView.tsx","../src/hooks/useEventResize.ts","../src/contexts/DayWeekViewContext.ts","../src/contexts/DayWeekDrawerContext.ts","../src/hooks/useTimeOffset.ts","../src/components/day-week-drawer/DayWeekDrawer.tsx","../src/hooks/useAbsEventRect.ts","../src/hooks/useCanResizeEvent.ts","../src/components/day-week-event/DayWeekEvent.tsx","../src/components/day-week-event/DayWeekEventPreview.tsx","../src/components/day-week-view/HiddenEvents.tsx","../src/components/day-week-view/useTimeColumnWidth.ts","../src/components/day-week-view/DayWeekView.tsx","../src/Calendar.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\nimport type { CalendarDate, DateAdapter } from \"@weekwise/core\";\n\n/**\n * DateLocalization context: the adapter, whatever its date type (read it with `useDateUtils<TDate>()`).\n */\nconst DateLocalizationContext = createContext<DateAdapter<CalendarDate> | undefined>(undefined);\n\nif (isDevEnvironment) {\n DateLocalizationContext.displayName = \"DateLocalizationContext\";\n}\n\nexport default DateLocalizationContext;\n","import { useContext } from \"react\";\n\nimport type { CalendarDate, DateAdapter } from \"@weekwise/core\";\n\nimport DateLocalizationContext from \"./DateLocalizationContext\";\n\n/**\n * The adapter given to `DateLocalizationProvider`. `TDate` is its date type: `Date` unless\n * the adapter works with another one, e.g. `useDateUtils<Temporal.ZonedDateTime>()`.\n */\nexport default function useDateUtils<TDate = Date>(): DateAdapter<TDate> {\n const context = useContext(DateLocalizationContext);\n\n if (!context) {\n throw new Error(\"DateLocalizationContext is required\");\n }\n\n return context as unknown as DateAdapter<TDate>;\n}\n\n/** The adapter for the calendar's own components, which never look inside a date. */\nexport function useCalendarDateUtils(): DateAdapter<CalendarDate> {\n return useDateUtils<CalendarDate>();\n}\n","import { createContext } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\nimport type { CalendarMessages } from \"@weekwise/core\";\n\n/** Interface strings, resolved by {@link DateLocalizationProvider} from the adapter's locale. */\nconst MessagesContext = createContext<CalendarMessages | undefined>(undefined);\n\nif (isDevEnvironment) {\n MessagesContext.displayName = \"MessagesContext\";\n}\n\nexport default MessagesContext;\n","import { useMemo, type PropsWithChildren } from \"react\";\n\nimport { resolveMessages } from \"@weekwise/core\";\nimport type { CalendarDate, CalendarMessages, DateAdapter } from \"@weekwise/core\";\n\nimport DateLocalizationContext from \"./DateLocalizationContext\";\nimport MessagesContext from \"./MessagesContext\";\n\nexport type DateLocalizationProviderProps<TDate = Date> = PropsWithChildren<{\n /**\n * Date adapter: an instance (`new DateFnsAdapter({ locale: ru })`) or a class\n * with a no-argument constructor (`DateFnsAdapter`). Its `locale` also selects\n * the interface language, so switching the adapter switches the whole calendar.\n * Its date type (`Date`, `Temporal.ZonedDateTime`…) is the one the calendar takes and gives.\n */\n adapter: DateAdapter<TDate> | (new () => DateAdapter<TDate>);\n /**\n * Interface strings on top of the built-in translation for the adapter's locale:\n * a few words to change, or every string for a language without a translation.\n */\n messages?: Partial<CalendarMessages>;\n}>;\n\nexport default function DateLocalizationProvider<TDate = Date>(props: DateLocalizationProviderProps<TDate>) {\n const { adapter, messages, children } = props;\n\n const dateUtils = useMemo<DateAdapter<TDate>>(\n () => (typeof adapter === \"function\" ? new adapter() : adapter),\n [adapter]\n );\n\n const resolvedMessages = useMemo(() => resolveMessages(dateUtils.locale, messages), [dateUtils.locale, messages]);\n\n return (\n <DateLocalizationContext.Provider value={dateUtils as unknown as DateAdapter<CalendarDate>}>\n <MessagesContext.Provider value={resolvedMessages}>{children}</MessagesContext.Provider>\n </DateLocalizationContext.Provider>\n );\n}\n","import { useContext } from \"react\";\n\nimport { resolveMessages } from \"@weekwise/core\";\n\nimport MessagesContext from \"./MessagesContext\";\nimport useDateUtils from \"./useDateUtils\";\n\n/** Interface strings in the language of the date adapter's locale. */\nexport default function useMessages() {\n const messages = useContext(MessagesContext);\n const dateUtils = useDateUtils();\n return messages ?? resolveMessages(dateUtils.locale);\n}\n","import { useEffect, useLayoutEffect } from \"react\";\n\nconst isBrowser = typeof window !== \"undefined\";\n\n/**\n * `useLayoutEffect` that falls back to `useEffect` during server-side\n * rendering to avoid the React SSR warning.\n */\nexport const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;\n\nexport default useIsomorphicLayoutEffect;\n","import { useEffect, useMemo, useRef } from \"react\";\n\n/**\n * Returns a new ResizeObserver instance bound to the `onResize` callback.\n * If `ResizeObserver` is undefined in the execution environment, returns `undefined`.\n */\nexport default function useResizeObserver(cb: ResizeObserverCallback, disabled = false) {\n const cbRef = useRef(cb);\n cbRef.current = cb;\n const resizeObserver = useMemo(() => {\n if (disabled || typeof window === \"undefined\" || typeof window.ResizeObserver === \"undefined\") {\n return undefined;\n }\n const { current: cb } = cbRef;\n const { ResizeObserver } = window;\n\n return new ResizeObserver(cb);\n }, [disabled]);\n\n useEffect(() => {\n return () => resizeObserver?.disconnect();\n }, [resizeObserver]);\n\n return resizeObserver;\n}\n","import { useState, type RefObject } from \"react\";\n\nimport { getCalendarSize, type CalendarSize } from \"@weekwise/core\";\n\nimport useIsomorphicLayoutEffect from \"./useIsomorphicLayoutEffect\";\nimport useResizeObserver from \"./useResizeObserver\";\n\n/**\n * Layout for the width of `ref`'s element, kept up to date as it is resized. `regular` on\n * the server and until the element is measured.\n */\nexport default function useCalendarSize(ref: RefObject<HTMLElement | null>): CalendarSize {\n const [size, setSize] = useState<CalendarSize>(\"regular\");\n\n const observer = useResizeObserver(([entry]) => {\n if (!entry) return;\n const width = entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width;\n setSize(getCalendarSize(width));\n });\n\n useIsomorphicLayoutEffect(() => {\n const element = ref.current;\n if (!element) return;\n // before the first paint, so the regular layout does not flash\n setSize(getCalendarSize(element.getBoundingClientRect().width));\n observer?.observe(element);\n return () => observer?.unobserve(element);\n }, [observer, ref]);\n\n return size;\n}\n","import { useRef } from \"react\";\n\nexport default function useCurrentRef<T>(value: T): { readonly current: T } {\n const currentRef = useRef(value);\n currentRef.current = value;\n\n return currentRef;\n}\n","import { useMemo, useRef, type DependencyList } from \"react\";\n\nimport useCurrentRef from \"./useCurrentRef\";\n\nexport default function useComputed<T>(cb: (prevValue: T | undefined) => T, deps: DependencyList) {\n const valueRef = useRef<T>(undefined);\n const cbRef = useCurrentRef(cb);\n\n return useMemo(\n () => {\n const newValue = cbRef.current(valueRef.current);\n valueRef.current = newValue;\n\n return newValue;\n },\n // cbRef can be ignored because it will never change\n // oxlint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo\n deps\n );\n}\n","import { useEffect, useRef, useState } from \"react\";\n\n/**\n * Helper hook to handle previous comparison of controlled/uncontrolled\n * Prints an error when isControlled value switches between subsequent renders\n * @returns - whether the value is controlled\n */\nexport function useIsControlled<T>(controlledValue: T | undefined): controlledValue is T {\n const [isControlled] = useState<boolean>(() => controlledValue !== undefined);\n return isControlled;\n}\n\nexport function useAssert<T>(\n isControlled: boolean,\n controlledValue: T | undefined,\n defaultValue: T | undefined,\n defaultValueProp: T | undefined\n) {\n const error = useRef(new Error());\n // We don't want these warnings in production even though it is against native behaviour\n\n useEffect(() => {\n if (isControlled !== (controlledValue !== undefined)) {\n const controlWarning = isControlled\n ? \"a controlled value to be uncontrolled\"\n : \"an uncontrolled value to be controlled\";\n\n const undefinedWarning = isControlled ? \"defined to an undefined\" : \"undefined to a defined\";\n\n throw new Error(`\n [useControlled]:\n A component is changing ${controlWarning}. This is likely caused by the value changing from ${undefinedWarning} value, which should not happen.\n Decide between using a controlled or uncontrolled input element for the lifetime of the component.\n More info: https://reactjs.org/link/controlled-components\n ${error.current.stack}\n `);\n }\n }, [isControlled, controlledValue]);\n\n useEffect(() => {\n if (!isControlled && defaultValue !== defaultValueProp) {\n throw new Error(`\n [useControlled]:\n A component is changing the default state of an uncontrolled value after being initialized.\n To suppress this warning opt to use a controlled value.\n More info: https://reactjs.org/link/controlled-components\n ${error.current.stack}`);\n }\n }, [defaultValueProp, defaultValue, isControlled]);\n}\n","import { isDevEnvironment } from \"@weekwise/core\";\nimport { useCallback, useState, type Dispatch, type SetStateAction } from \"react\";\n\nimport type { UseControlledParams, UseControlledWithInitialParams } from \"./useControlled.types\";\nimport { useAssert, useIsControlled } from \"./useControlled.utils\";\n\n/**\n * Creates a controlled state with an uncontrolled fallback.\n *\n * If `controlled` is defined, `useControlled` will return the controlled value and an\n * identity function as the update function. If `controlled` is `undefined`, `useControlled`\n * will return the `defaultValue` and a state update function.\n *\n * This hook is useful when you want to make a component that can be either controlled or\n * uncontrolled, depending on whether the user provides a `value` or `defaultValue` prop.\n *\n * @param params - The parameters of the hook.\n * @param params.controlled - The controlled value.\n * @param params.default - The default value.\n * @returns A tuple of the value and the update function.\n */\nexport default function useControlled<T>(\n params: UseControlledParams<T>\n): [T | undefined, Dispatch<SetStateAction<T | undefined>>, boolean];\n/**\n * Creates a controlled state with an uncontrolled fallback and an `initialState`.\n *\n * This hook is useful when you want to make a component that can be either controlled or\n * uncontrolled, depending on whether the user provides a `value` or `defaultValue` prop. The\n * `initialState` is used as the initial value of the state, if the component is uncontrolled.\n *\n * The third element of the returned tuple is a boolean indicating whether the component is\n * controlled or uncontrolled.\n *\n * @param params - The parameters of the hook.\n * @param params.controlled - The controlled value.\n * @param params.default - The default value.\n * @param params.initialState - The initial state.\n * @returns A tuple of the value, the update function and a boolean indicating whether the\n * component is controlled or uncontrolled.\n */\nexport default function useControlled<T>(\n params: UseControlledWithInitialParams<T>\n): [T, Dispatch<SetStateAction<T>>, boolean];\nexport default function useControlled<T>(params: UseControlledParams<T> | UseControlledWithInitialParams<T>) {\n const { controlled, default: defaultValueProp } = params;\n const [valueState, setValueState] = useState(() => {\n if (defaultValueProp === undefined && \"initialState\" in params && params.initialState !== undefined) {\n return params.initialState;\n }\n return defaultValueProp;\n });\n const [defaultValue] = useState<T | undefined>(defaultValueProp);\n\n const isControlled = useIsControlled(controlled);\n\n if (isDevEnvironment) {\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n useAssert(isControlled, controlled, defaultValue, defaultValueProp);\n }\n\n const setValueIfUncontrolled: Dispatch<SetStateAction<T | undefined>> = useCallback(\n (newValue) => {\n if (!isControlled) {\n setValueState(newValue);\n }\n },\n [isControlled]\n );\n return [isControlled ? controlled : valueState, setValueIfUncontrolled, isControlled];\n}\n","import { useEffect } from \"react\";\n\n/** Cursors set on the whole page while a gesture runs: see the `ww-cursor-*` classes in Calendar.module.css. */\nexport type DocumentCursor = \"grabbing\" | \"not-allowed\";\n\n/**\n * Shows `cursor` over the whole page, the calendar, its overlays and outside it, until it is\n * `null` or the component unmounts. The page's elements keep their own cursors otherwise.\n */\nexport default function useDocumentCursor(cursor: DocumentCursor | null) {\n useEffect(() => {\n if (!cursor) return;\n\n const className = `ww-cursor-${cursor}`;\n const root = document.documentElement;\n root.classList.add(className);\n return () => root.classList.remove(className);\n }, [cursor]);\n}\n","import { useRef } from \"react\";\n\nconst UNINITIALIZED: unknown = {};\n\n/**\n * A React.useRef() that is initialized with a function. Note that it accepts an optional\n * initialization argument, so the initialization function doesn't need to be an inline closure.\n *\n * @usage\n * const ref = useRefWithInit(sortColumns, columns)\n */\nexport default function useRefWithInit<T>(init: () => T): { readonly current: T };\nexport default function useRefWithInit<T, U>(init: (arg: U) => T, initArg: U): { readonly current: T };\nexport default function useRefWithInit<T>(\n init: (arg?: unknown) => unknown,\n initArg?: unknown\n): { readonly current: T } {\n const ref = useRef<unknown>(UNINITIALIZED);\n\n if (ref.current === UNINITIALIZED) {\n ref.current = init(initArg);\n }\n\n return ref as { readonly current: T };\n}\n","import { isDevEnvironment } from \"@weekwise/core\";\nimport type { Stable } from \"./useEventCallback.types\";\n\nfunction assertNotCalled() {\n if (isDevEnvironment) {\n throw new Error(\"useEventCallback: Cannot call an event handler while rendering.\");\n }\n}\n\nexport function createStableCallback() {\n const stable: Stable<any> = {\n next: undefined,\n callback: assertNotCalled,\n trampoline: (...args: []) => stable.callback?.(...args),\n effect: () => {\n stable.callback = stable.next;\n },\n };\n return stable;\n}\n","import { useInsertionEffect } from \"react\";\n\nimport useRefWithInit from \"./useRefWithInit\";\nimport { createStableCallback } from \"./useEventCallback.utils\";\n\nexport default function useEventCallback<T extends (...args: any[]) => any>(callback: T | undefined): T {\n const stable = useRefWithInit(createStableCallback).current;\n // oxlint-disable-next-line react-hooks/immutability\n stable.next = callback;\n useInsertionEffect(stable.effect);\n return stable.trampoline;\n}\n","import { useEffect, useMemo, useState } from \"react\";\n\nexport default function useGlobalListeners(): GlobalListeners {\n const [globalListeners] = useState(() => ({\n current: new Map<GeneralEventListener, ListenerMetadata>(),\n }));\n\n const { addGlobalListener, removeGlobalListener, removeAllGlobalListeners } = useMemo(() => {\n function addGlobalListener(\n target: EventTarget,\n type: string,\n listener: GeneralEventListener,\n options?: boolean | AddEventListenerOptions\n ) {\n const fn =\n typeof options !== \"boolean\" && options?.once\n ? (event: Event) => {\n globalListeners.current.delete(listener);\n if (target instanceof Document) listener.call(target, event);\n else (listener as EventListener)(event);\n }\n : listener;\n\n target.addEventListener(type, listener, options);\n globalListeners.current.set(listener, { type, target, fn, options });\n }\n function removeGlobalListener(\n target: EventTarget,\n type: string,\n listener: GeneralEventListener,\n options?: boolean | EventListenerOptions\n ) {\n const fn = globalListeners.current.get(listener)?.fn || listener;\n target.removeEventListener(type, fn, options);\n globalListeners.current.delete(listener);\n }\n\n function removeAllGlobalListeners() {\n globalListeners.current.forEach(({ target, type, options }, listener) => {\n removeGlobalListener(target, type, listener, options);\n });\n }\n\n return { addGlobalListener, removeGlobalListener, removeAllGlobalListeners };\n }, [globalListeners]);\n\n useEffect(() => {\n return removeAllGlobalListeners;\n }, [removeAllGlobalListeners]);\n\n return {\n addGlobalListener,\n removeGlobalListener,\n removeAllGlobalListeners,\n };\n}\n\ninterface GlobalListeners {\n addGlobalListener<K extends keyof DocumentEventMap>(\n el: EventTarget,\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ): void;\n addGlobalListener(\n el: EventTarget,\n type: string,\n listener: EventListener,\n options?: boolean | AddEventListenerOptions\n ): void;\n removeGlobalListener<K extends keyof DocumentEventMap>(\n el: EventTarget,\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | EventListenerOptions\n ): void;\n removeGlobalListener(\n el: EventTarget,\n type: string,\n listener: EventListener,\n options?: boolean | EventListenerOptions\n ): void;\n removeAllGlobalListeners(): void;\n}\n\ntype ListenerMetadata = {\n type: string;\n target: EventTarget;\n options: boolean | AddEventListenerOptions | undefined;\n fn: GeneralEventListener;\n};\n\ntype GeneralEventListener =\n EventListener | (<K extends keyof DocumentEventMap>(this: Document, ev: DocumentEventMap[K]) => any);\n","import { useEffect, type RefObject } from \"react\";\n\nimport { getClientRect, Rect } from \"@weekwise/core\";\n\nimport useRefWithInit from \"./useRefWithInit\";\n\n/** An item's box from the container's top left corner: it scrolls with the container. */\ninterface ItemBox {\n left: number;\n top: number;\n right: number;\n bottom: number;\n}\n\nexport interface ItemsLayout {\n /**\n * Measures the container and its items for a gesture, and again whenever the container\n * changes size, until {@link ItemsLayout.release}. `false` without a container.\n */\n measure: () => boolean;\n /** Ends the gesture: the measurements stop following the container's size. */\n release: () => void;\n /**\n * The container's box where it is now: it follows the scroll of the container's scrollable\n * ancestors without measuring again. `null` before {@link ItemsLayout.measure}.\n */\n container: () => Rect | null;\n /**\n * Index of the item under the point, or of the nearest one; `-1` without items. With\n * `axis: \"x\"` only the horizontal distance counts (columns as tall as the container).\n */\n nearestIndex: (x: number, y: number, axis?: \"x\" | \"xy\") => number;\n}\n\n/**\n * Where a container and the items in it (day columns, day cells) are during a pointer gesture,\n * measured once at its start instead of on every move. The items scroll with the container, so\n * their boxes are kept from its corner and only the container follows the scroll.\n */\nexport default function useItemsLayout(\n containerRef: RefObject<HTMLElement | null>,\n /** The items by index, e.g. from `useRefList`; an unmounted one is `null`. */\n itemsRef: ItemsRef\n): ItemsLayout {\n const layout = useRefWithInit(createItemsLayout, { containerRef, itemsRef }).current;\n // a gesture cut short by unmounting stops observing the container\n useEffect(() => layout.release, [layout]);\n return layout;\n}\n\ntype ItemsRef = { readonly current: readonly (HTMLElement | null)[] };\n\ninterface ItemsLayoutSources {\n containerRef: RefObject<HTMLElement | null>;\n itemsRef: ItemsRef;\n}\n\nfunction createItemsLayout({ containerRef, itemsRef }: ItemsLayoutSources): ItemsLayout {\n let container: Rect | null = null;\n let items: (ItemBox | null)[] = [];\n // a container that changes size (a window resized, a phone turned) moves its items: measure again\n let resizeObserver: ResizeObserver | null = null;\n\n function take() {\n const element = containerRef.current;\n if (!element) return false;\n\n const rect = new Rect(getClientRect(element), element);\n container = rect;\n items = itemsRef.current.map((item) => {\n if (!item) return null;\n const { left, top, right, bottom } = item.getBoundingClientRect();\n return { left: left - rect.left, top: top - rect.top, right: right - rect.left, bottom: bottom - rect.top };\n });\n return true;\n }\n\n return {\n measure() {\n if (!take()) return false;\n if (typeof ResizeObserver !== \"undefined\" && containerRef.current) {\n resizeObserver ??= new ResizeObserver(() => {\n if (container) take();\n });\n resizeObserver.observe(containerRef.current);\n }\n return true;\n },\n release() {\n resizeObserver?.disconnect();\n container = null;\n items = [];\n },\n container: () => container,\n nearestIndex(x, y, axis = \"xy\") {\n if (!container) return -1;\n\n const left = x - container.left;\n const top = y - container.top;\n let best = -1;\n let bestDistance = Infinity;\n\n items.forEach((box, index) => {\n if (!box) return;\n const dx = left < box.left ? box.left - left : left >= box.right ? left - box.right : 0;\n const dy = axis === \"x\" ? 0 : top < box.top ? box.top - top : top >= box.bottom ? top - box.bottom : 0;\n const distance = Math.hypot(dx, dy);\n if (distance < bestDistance) {\n bestDistance = distance;\n best = index;\n }\n });\n\n return best;\n },\n };\n}\n","import type { Ref } from \"react\";\n\nconst toFnRef = <T>(ref?: Ref<T | null> | null) =>\n !ref || typeof ref === \"function\"\n ? ref\n : (value: T | null) => {\n (ref as { current: T | null }).current = value;\n };\n\nexport default function mergeRefs<T>(...refs: (Ref<T | null> | null | undefined)[]): Ref<T> {\n return (value: T | null) => {\n refs.forEach((ref) => {\n toFnRef(ref)?.(value);\n });\n };\n}\n","import { useMemo, type Ref } from \"react\";\n\nimport mergeRefs from \"../utils/mergeRefs\";\n\nfunction useMergedRefs<T>(...refs: (Ref<T> | undefined)[]) {\n // oxlint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo\n return useMemo(() => mergeRefs(...refs), refs);\n}\n\nexport default useMergedRefs;\n","import {\n useEffect,\n useMemo,\n useRef,\n useState,\n type DOMAttributes,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n type TouchEvent as ReactTouchEvent,\n type SyntheticEvent,\n} from \"react\";\n\nimport useGlobalListeners from \"./useGlobalListeners\";\n\nimport type { EventBase, MoveData, PointerCoordinates, PointerType, UseMoveParams } from \"./useMove.types\";\n\nexport default function useMove<Element extends HTMLElement = HTMLElement>(params: UseMoveParams) {\n const [{ state }] = useState<{ state: MoveData }>(() => ({\n state: {\n activePointId: null,\n clientX: 0,\n clientY: 0,\n initialClientX: 0,\n initialClientY: 0,\n isDistanceReached: false,\n holdTimer: null,\n isTouchActive: false,\n },\n }));\n\n const paramsRef = useRef(params);\n paramsRef.current = params;\n\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n\n useEffect(() => () => clearHold(state), [state]);\n\n const { listeners, ref } = useMemo(() => {\n const attr: DOMAttributes<Element> = {};\n\n const stopEvent = (e: SyntheticEvent) => {\n if (\"stopPropagation\" in e && \"preventDefault\" in e) {\n e.stopPropagation();\n e.preventDefault();\n }\n };\n\n const update = (coordinates: PointerCoordinates, pointerId?: number | null) => {\n const {\n current: { distance = 0, ...handlers },\n } = paramsRef;\n\n const { clientX, clientY } = coordinates;\n const { clientX: prevClientX, clientY: prevClientY } = state;\n\n // oxlint-disable-next-line react-hooks/immutability\n state.clientX = clientX;\n state.clientY = clientY;\n\n if (pointerId !== undefined) {\n state.activePointId = pointerId;\n }\n\n const getCommonEventData = (event: EventBase) => ({\n shiftKey: event.shiftKey,\n metaKey: event.metaKey,\n ctrlKey: event.ctrlKey,\n altKey: event.altKey,\n clientX,\n clientY,\n });\n\n return {\n start(pointerType: PointerType, event: EventBase): boolean | void {\n state.initialClientX = clientX;\n state.initialClientY = clientY;\n state.isDistanceReached = distance === 0;\n\n return handlers.onMoveStart({\n type: \"movestart\",\n pointerType,\n ...getCommonEventData(event),\n });\n },\n move(pointerType: PointerType, event: EventBase, deltaX?: number, deltaY?: number) {\n const initialDeltaX = clientX - state.initialClientX;\n const initialDeltaY = clientY - state.initialClientY;\n\n if (!state.isDistanceReached && initialDeltaX ** 2 + initialDeltaY ** 2 >= distance ** 2) {\n state.isDistanceReached = true;\n }\n\n if (state.isDistanceReached) {\n handlers.onMove({\n type: \"move\",\n pointerType,\n deltaX: deltaX ?? clientX - prevClientX,\n deltaY: deltaY ?? clientY - prevClientY,\n initialDeltaX,\n initialDeltaY,\n ...getCommonEventData(event),\n });\n }\n },\n end(pointerType: PointerType, event: EventBase) {\n handlers.onMoveEnd({\n type: \"moveend\",\n pointerType,\n ...getCommonEventData(event),\n });\n },\n };\n };\n\n if (typeof PointerEvent === \"undefined\") {\n const onMouseMove = (e: MouseEvent) => {\n if (e.button === 0) {\n update(e).move(\"mouse\", e);\n }\n };\n const onMouseUp = (e: MouseEvent) => {\n if (e.button === 0) {\n update(e).end(\"mouse\", e);\n }\n };\n\n attr.onMouseDown = (e: ReactMouseEvent) => {\n if (e.button === 0) {\n if (update(e).start(\"mouse\", e) !== false) {\n addGlobalListener(window, \"mousemove\", onMouseMove, false);\n addGlobalListener(window, \"mouseup\", onMouseUp, false);\n\n stopEvent(e);\n } else update(e, null);\n }\n };\n\n const onTouchMove = (e: TouchEvent) => {\n const touch = [...e.changedTouches].findIndex(({ identifier }) => identifier === state.activePointId);\n if (touch >= 0) {\n const trouchEvent = e.changedTouches[touch];\n // move\n update(trouchEvent).move(\"touch\", e);\n }\n };\n const onTouchEnd = (e: TouchEvent) => {\n const touch = [...e.changedTouches].findIndex(({ identifier }) => identifier === state.activePointId);\n if (touch >= 0) {\n // end\n update(e.changedTouches[touch], null).end(\"touch\", e);\n\n removeGlobalListener(window, \"touchmove\", onTouchMove, false);\n removeGlobalListener(window, \"touchend\", onTouchEnd);\n removeGlobalListener(window, \"touchcancel\", onTouchEnd);\n }\n };\n attr.onTouchStart = (e: ReactTouchEvent) => {\n if (e.changedTouches.length === 0 || state.activePointId !== null) {\n return;\n }\n\n const touch = e.changedTouches[0];\n\n if (update(touch, touch.identifier).start(\"touch\", e) !== false) {\n addGlobalListener(window, \"touchmove\", onTouchMove, false);\n addGlobalListener(window, \"touchend\", onTouchEnd, false);\n addGlobalListener(window, \"touchcancel\", onTouchEnd, false);\n\n stopEvent(e);\n } else update(touch, null);\n };\n } else {\n const removePointerListeners = () => {\n removeGlobalListener(window, \"pointermove\", onPointerMove, false);\n removeGlobalListener(window, \"pointerup\", onPointerUp, false);\n removeGlobalListener(window, \"pointercancel\", onPointerUp, false);\n };\n\n // a touch that has not held still for `touchDelay` yet: drop it and let the page scroll\n const releaseHold = () => {\n clearHold(state);\n removePointerListeners();\n update(state, null);\n };\n\n const onPointerMove = (e: PointerEvent) => {\n if (e.pointerId !== state.activePointId) {\n return;\n }\n\n if (state.holdTimer !== null) {\n const deltaX = e.clientX - state.initialClientX;\n const deltaY = e.clientY - state.initialClientY;\n\n if (deltaX ** 2 + deltaY ** 2 > TOUCH_HOLD_TOLERANCE ** 2) {\n releaseHold();\n } else {\n update(e);\n }\n return;\n }\n\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n update(e).move(pointerType, e);\n };\n\n const onPointerUp = (e: PointerEvent) => {\n if (e.pointerId !== state.activePointId) {\n return;\n }\n\n // lifted, or taken by the browser to scroll, before the hold: no gesture\n if (state.holdTimer !== null) {\n releaseHold();\n return;\n }\n\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n\n // oxlint-disable-next-line react-hooks/immutability\n state.isTouchActive = false;\n update(e, null).end(pointerType, e);\n removePointerListeners();\n };\n\n const startPointer = (pointerType: PointerType, event: EventBase) => {\n if (update(state).start(pointerType, event) === false) {\n return false;\n }\n\n // oxlint-disable-next-line react-hooks/immutability\n state.isTouchActive = pointerType === \"touch\";\n return true;\n };\n\n attr.onPointerDown = (e: ReactPointerEvent) => {\n if (e.button !== 0 || state.activePointId !== null) {\n return;\n }\n\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n const { touchDelay = 0 } = paramsRef.current;\n\n update(e, e.pointerId);\n\n if (pointerType === \"touch\" && touchDelay > 0) {\n // until the hold the touch may still be a scroll: the gesture starts after `touchDelay`\n // oxlint-disable-next-line react-hooks/immutability\n state.initialClientX = e.clientX;\n state.initialClientY = e.clientY;\n\n const event = e.nativeEvent;\n state.holdTimer = setTimeout(() => {\n state.holdTimer = null;\n\n if (!startPointer(pointerType, event)) {\n releaseHold();\n return;\n }\n\n // the hold has taken: a short buzz where it is supported (not iOS Safari)\n if (\"vibrate\" in navigator) {\n navigator.vibrate(HOLD_VIBRATION);\n }\n }, touchDelay);\n } else if (!startPointer(pointerType, e)) {\n update(e, null);\n return;\n }\n\n addGlobalListener(window, \"pointermove\", onPointerMove, false);\n addGlobalListener(window, \"pointerup\", onPointerUp, false);\n addGlobalListener(window, \"pointercancel\", onPointerUp, false);\n\n stopEvent(e);\n };\n\n // a long press opens the context menu on Android: not during a touch gesture\n attr.onContextMenu = (e: ReactMouseEvent) => {\n if (state.holdTimer !== null || state.isTouchActive) {\n e.preventDefault();\n }\n };\n }\n\n const triggerKeyboardMove = (e: ReactKeyboardEvent, deltaX: number, deltaY: number) => {\n const { start, move, end } = update({ clientX: 0, clientY: 0 });\n if (start(\"keyboard\", e)) {\n move(\"keyboard\", e, deltaX, deltaY);\n end(\"keyboard\", e);\n } else {\n update({ clientX: 0, clientY: 0 }, null);\n }\n };\n\n attr.onKeyDown = (e) => {\n switch (e.key) {\n case \"Left\":\n case \"ArrowLeft\":\n stopEvent(e);\n triggerKeyboardMove(e, -1, 0);\n break;\n case \"Right\":\n case \"ArrowRight\":\n stopEvent(e);\n triggerKeyboardMove(e, 1, 0);\n break;\n case \"Up\":\n case \"ArrowUp\":\n stopEvent(e);\n triggerKeyboardMove(e, 0, -1);\n break;\n case \"Down\":\n case \"ArrowDown\":\n stopEvent(e);\n triggerKeyboardMove(e, 0, 1);\n break;\n }\n };\n\n // a touch gesture follows the finger instead of scrolling: the listener has to be on the\n // element before the touch starts, else iOS sends its moves as not cancelable\n const preventTouchScroll = (e: Event) => {\n if (state.isTouchActive && e.cancelable) {\n e.preventDefault();\n }\n };\n\n const touch: { target: Element | null } = { target: null };\n const ref = (node: Element | null) => {\n if (touch.target) {\n removeGlobalListener(touch.target, \"touchmove\", preventTouchScroll);\n }\n\n touch.target = node;\n\n if (node) {\n addGlobalListener(node, \"touchmove\", preventTouchScroll, { passive: false });\n }\n };\n\n return { listeners: attr, ref };\n }, [addGlobalListener, removeGlobalListener, state]);\n\n return { listeners, ref };\n}\n\n/** Buzz when a touch hold starts a gesture, in milliseconds. */\nconst HOLD_VIBRATION = 10;\n\n/** How far a touch may drift while it holds for `touchDelay`, in pixels. */\nconst TOUCH_HOLD_TOLERANCE = 10;\n\nfunction clearHold(state: MoveData) {\n if (state.holdTimer !== null) {\n clearTimeout(state.holdTimer);\n state.holdTimer = null;\n }\n}\n","import { useEffect, useRef } from \"react\";\n\nexport default function usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T>(undefined);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n\nexport function usePreviousWithInitial<T>(value: T): T {\n const ref = useRef<T>(value);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n","import useRefWithInit from \"./useRefWithInit\";\n\nexport interface RefList<T> {\n /** The mounted elements by index; an unmounted one is `null`. Read it in handlers, not in render. */\n readonly elements: { readonly current: readonly (T | null)[] };\n /** A callback ref that keeps the element at `index`, the same function for an index every render. */\n refAt: (index: number) => (node: T | null) => void;\n}\n\n/**\n * Refs to the elements of a rendered list: `<div ref={refAt(index)} />` for each item, then\n * `elements.current[index]` in an event handler.\n */\nexport default function useRefList<T extends Element>(): RefList<T> {\n return useRefWithInit(createRefList<T>).current;\n}\n\nfunction createRefList<T>(): RefList<T> {\n const elements: (T | null)[] = [];\n const refs = new Map<number, (node: T | null) => void>();\n\n return {\n elements: { current: elements },\n refAt(index) {\n let ref = refs.get(index);\n\n if (!ref) {\n ref = (node) => {\n elements[index] = node;\n };\n refs.set(index, ref);\n }\n\n return ref;\n },\n };\n}\n","import { startTransition, useState } from \"react\";\n\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\nimport type { ScrollbarMeasurements } from \"./useScrollBarSize.types\";\n\nfunction buildUseScrollbarSizeHook() {\n let element: HTMLElement | null = null;\n let count = 0;\n\n const elementFabric = (resizeCallback: () => void) => {\n count += 1;\n if (element === null) {\n // element was not created yet -- initialize\n element = document.createElement(\"div\");\n element.style.width = \"99px\";\n element.style.height = \"99px\";\n element.style.overflow = \"scroll\";\n element.style.position = \"absolute\";\n element.style.top = \"-9999px\";\n element.setAttribute(\"aria-hidden\", \"true\");\n element.setAttribute(\"role\", \"presentation\");\n\n document.body.appendChild(element);\n window.addEventListener(\"resize\", resizeCallback);\n }\n return {\n element,\n cleanup: () => {\n if (element && --count <= 0) {\n document.body.removeChild(element);\n window.removeEventListener(\"resize\", resizeCallback);\n element = null;\n count = 0;\n }\n },\n };\n };\n\n return function (): ScrollbarMeasurements {\n const [dimensions, setDimensions] = useState({ height: 0, width: 0 });\n\n // initialize resize event handler and state when mounted\n useIsomorphicLayoutEffect(() => {\n const updateState = () => {\n const scrollbarHeight = element.offsetHeight - element.clientHeight;\n const scrollbarWidth = element.offsetWidth - element.clientWidth;\n\n startTransition(() => {\n setDimensions((currentDimensions) => {\n const { height, width } = currentDimensions;\n return height !== scrollbarHeight || width !== scrollbarWidth\n ? { height: scrollbarHeight, width: scrollbarWidth }\n : currentDimensions;\n });\n });\n };\n\n const { element, cleanup } = elementFabric(updateState);\n\n // initialize\n updateState();\n\n // cleanup\n return cleanup;\n }, []);\n\n return dimensions;\n };\n}\n\nexport const useScrollBarSize = buildUseScrollbarSizeHook();\n","import { useCallback, useRef, useState } from \"react\";\n\n/**\n * State for rendering plus a ref to the same value for event handlers: the ref changes\n * at once, so handlers that run before the next render (pointer moves during a drag)\n * see the latest value.\n */\nexport default function useStateRef<T>(\n initialValue: T\n): [value: T, setValue: (next: T) => void, ref: { readonly current: T }] {\n const [value, setState] = useState(initialValue);\n const ref = useRef(initialValue);\n\n const setValue = useCallback((next: T) => {\n ref.current = next;\n setState(next);\n }, []);\n\n return [value, setValue, ref];\n}\n","import { useEffect, useRef } from \"react\";\n\nimport useCurrentRef from \"./useCurrentRef\";\n\nexport default function useTimeInterval(callback: () => void, interval: number, isActive = true) {\n const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);\n const callbackRef = useCurrentRef(callback);\n\n useEffect(() => {\n if (isActive) {\n // Get the current time\n const now = new Date();\n // Calculate how many milliseconds have passed in the current hour\n const timePassed = (now.getMinutes() * 60 + now.getSeconds()) * 1000;\n\n // Calculate the delay until the next 'n' minute mark\n const delay = interval - (timePassed % interval);\n\n timerRef.current = setTimeout(() => {\n callbackRef.current();\n timerRef.current = setInterval(callbackRef.current, interval);\n }, delay);\n\n callbackRef.current();\n }\n return () => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n };\n }, [callbackRef, interval, isActive]);\n}\n","import { useEffect, useState } from \"react\";\n\nimport type { CalendarDate, DateAdapter } from \"@weekwise/core\";\n\nimport { useCalendarDateUtils } from \"../date-localization\";\n\nconst startOfToday = (dateUtils: DateAdapter<CalendarDate>) => dateUtils.toMillis(dateUtils.getToday());\n\n/**\n * Start of today as a timestamp. Changes at midnight, so components that\n * depend on it (today's column, the now line, past-day limits) re-render\n * when the date rolls over, and with the adapter: in another time zone\n * today may already be another day.\n */\nexport default function useToday(): number {\n const dateUtils = useCalendarDateUtils();\n const [state, setState] = useState(() => ({ dateUtils, today: startOfToday(dateUtils) }));\n\n // another adapter (time zone): its today at once, not at the old zone's midnight\n let current = state;\n if (state.dateUtils !== dateUtils) {\n current = { dateUtils, today: startOfToday(dateUtils) };\n setState(current);\n }\n const { today } = current;\n\n useEffect(() => {\n // the next midnight in the adapter's time zone\n const nextMidnight = dateUtils.toMillis(dateUtils.addDays(dateUtils.fromMillis(today), 1));\n const delay = Math.max(nextMidnight - Date.now(), 0) + 1000;\n const timer = setTimeout(() => setState({ dateUtils, today: startOfToday(dateUtils) }), delay);\n return () => clearTimeout(timer);\n }, [dateUtils, today]);\n\n return today;\n}\n","import { createContext, useContext } from \"react\";\n\nimport type { CalendarContextValue } from \"../Calendar.types\";\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/**\n * DatePicker context.\n */\nconst CalendarContext = createContext<CalendarContextValue | undefined>(undefined);\n\nif (isDevEnvironment) {\n CalendarContext.displayName = \"CalendarContext\";\n}\n\nexport default CalendarContext;\n\nexport function useCalendarContext() {\n const context = useContext(CalendarContext);\n\n if (!context) {\n throw new Error(\"CalendarContext is required\");\n }\n\n return context;\n}\n","import { createContext } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/** The calendar's root element: portals copy its theme variables and font. */\nconst ThemeSourceContext = createContext<RefObject<HTMLElement | null> | null>(null);\n\nif (isDevEnvironment) {\n ThemeSourceContext.displayName = \"ThemeSourceContext\";\n}\n\nexport default ThemeSourceContext;\n","import { useCallback, useEffect, useRef } from \"react\";\n\nimport { useControlled, useCurrentRef, useEventCallback } from \"../hooks\";\nimport { getViewChangeTarget, mergeCallbacks, normalizeViewValue, transferDay } from \"@weekwise/core\";\n\nimport type { CalendarView, UseCalendarValueParams } from \"../Calendar.types\";\n\nexport default function useCalendarValue<TDate>(params: UseCalendarValueParams<TDate>) {\n const { view, defaultView, startWeek, viewValue, defaultViewValue, dateUtils, onChangeView, onChangeViewValue } =\n params;\n\n const [controlledView, setControlledView] = useControlled<CalendarView>({\n controlled: view,\n default: defaultView,\n initialState: \"week\",\n });\n\n const calculateViewValue = useCallback(\n (view: CalendarView, viewValue?: TDate) => normalizeViewValue(dateUtils, view, viewValue, startWeek),\n [dateUtils, startWeek]\n );\n\n const [controlledViewValue, setControlledViewValue] = useControlled({\n controlled: viewValue,\n default: defaultViewValue,\n initialState: calculateViewValue(controlledView),\n });\n\n const changeViewValue = useEventCallback((newValue: TDate, view: CalendarView) => {\n setControlledViewValue(newValue);\n onChangeViewValue?.(newValue, view);\n });\n\n const changeView = useEventCallback(\n mergeCallbacks((newView: CalendarView) => {\n setControlledView(newView);\n }, onChangeView)\n );\n\n const currentViewValueRef = useCurrentRef(controlledViewValue);\n const previousViewRef = useRef(controlledView);\n const previousStartWeekRef = useRef(startWeek);\n const previousDateUtilsRef = useRef(dateUtils);\n useEffect(() => {\n const fromView = previousViewRef.current;\n const startWeekChanged = previousStartWeekRef.current !== startWeek;\n // another adapter (e.g. another time zone): keep the day the user saw\n const previousDateUtils = previousDateUtilsRef.current;\n const viewValue =\n previousDateUtils === dateUtils\n ? currentViewValueRef.current\n : transferDay(previousDateUtils, dateUtils, currentViewValueRef.current);\n previousViewRef.current = controlledView;\n previousStartWeekRef.current = startWeek;\n previousDateUtilsRef.current = dateUtils;\n // On a view switch, anchor on today / the middle of the week instead of the\n // first visible day, so week → month does not jump to the previous month.\n // A new first day of the week (e.g. another locale) re-anchors the same way:\n // the old first day may belong to the previous week under the new one.\n const nextValue =\n fromView === controlledView && !startWeekChanged\n ? calculateViewValue(controlledView, viewValue)\n : getViewChangeTarget(dateUtils, fromView, controlledView, viewValue, startWeek);\n changeViewValue(nextValue, controlledView);\n }, [calculateViewValue, changeViewValue, controlledView, currentViewValueRef, dateUtils, startWeek]);\n\n return {\n view: controlledView,\n viewValue: controlledViewValue,\n changeViewValue,\n changeView,\n };\n}\n","import { getNavigationTarget } from \"@weekwise/core\";\n\nimport { useEventCallback } from \"../hooks\";\n\nimport type { UseNavigationParams } from \"../Calendar.types\";\n\nexport default function useNavigation<TDate>(params: UseNavigationParams<TDate>) {\n const { dateUtils, view, viewValue, changeViewValue, startWeek } = params;\n\n const navigate = (from: TDate, direction: 1 | 0 | -1) => () =>\n changeViewValue(getNavigationTarget(dateUtils, view, from, direction, startWeek), view);\n\n return {\n goForward: useEventCallback(navigate(viewValue, 1)),\n goBackward: useEventCallback(navigate(viewValue, -1)),\n goToday: useEventCallback(navigate(dateUtils.getToday(), 0)),\n };\n}\n","import type { SVGProps } from \"react\";\n\nexport default function ChevronIcon(props: SVGProps<SVGSVGElement>) {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" height=\"12\" viewBox=\"0 0 13 12\" width=\"13\" {...props}>\n <path\n d=\"M1.77498 2.29504L6.35498 6.87504L10.945 2.29504L12.355 3.70504L6.35498 9.70504L0.35498 3.70504L1.77498 2.29504Z\"\n fill=\"currentColor\"\n />\n </svg>\n );\n}\n","import { useContext, useSyncExternalStore } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { CSSProperties, ReactNode } from \"react\";\n\nimport { THEME_PROPERTIES } from \"@weekwise/core\";\n\nimport ThemeSourceContext from \"../contexts/ThemeSourceContext\";\n\nexport type PortalProps = {\n children?: ReactNode;\n container?: Element | DocumentFragment | null;\n};\n\nconst subscribe = () => () => {};\nconst getClientSnapshot = () => true;\nconst getServerSnapshot = () => false;\n\n/**\n * True only after hydration. During SSR and the hydrating render it is false,\n * so client-only output (portals) matches the server HTML.\n */\nexport function useIsHydrated() {\n return useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot);\n}\n\n/** The theme variables and font of `source`, for content rendered outside it. */\nfunction readTheme(source: Element | null | undefined): CSSProperties {\n const theme: Record<string, string> = { display: \"contents\" };\n if (!source) {\n return theme;\n }\n\n const computed = getComputedStyle(source);\n for (const name of THEME_PROPERTIES) {\n const value = computed.getPropertyValue(name).trim();\n if (value) {\n theme[name === \"font-family\" ? \"fontFamily\" : name] = value;\n }\n }\n return theme;\n}\n\n/**\n * Renders into `container`, or into `document.body`. Content in the body does not\n * inherit the calendar's theme variables and font, so a `display: contents` wrapper\n * carries copies of them.\n */\nexport default function Portal({ children, container }: PortalProps) {\n const hydrated = useIsHydrated();\n const themeSource = useContext(ThemeSourceContext);\n\n if (!hydrated) {\n return null;\n }\n\n if (container) {\n return createPortal(children, container);\n }\n\n return createPortal(<div style={readTheme(themeSource?.current)}>{children}</div>, document.body);\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { autoUpdate, flip, offset, shift, useFloating } from \"@floating-ui/react-dom\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ButtonHTMLAttributes, ReactNode } from \"react\";\n\nimport { useCalendarDateUtils, useMessages } from \"../../date-localization\";\nimport { useGlobalListeners } from \"../../hooks\";\nimport ChevronIcon from \"../../icons/chevron\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport type { CalendarView } from \"../../Calendar.types\";\nimport Portal from \"../../portal\";\nimport { cx, formatMonthYear, getMonthGrid, getViewHeading, isInViewPeriod } from \"@weekwise/core\";\n\nimport styles from \"./DateNavigator.module.css\";\n\nexport type DateNavigatorProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n renderHeading?: (date: CalendarDate, view: CalendarView) => ReactNode;\n};\n\nexport default function DateNavigator({\n renderHeading,\n type = \"button\",\n onClick,\n onKeyDown,\n className,\n ...buttonProps\n}: DateNavigatorProps) {\n const { view, viewValue, changeViewValue, startWeek } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const messages = useMessages();\n const { getStartOfWeek, getStartOfMonth, addMonths } = dateUtils;\n\n const [open, setOpen] = useState(false);\n const [pickerMonth, setPickerMonth] = useState(() => getStartOfMonth(viewValue));\n const rootRef = useRef<HTMLDivElement | null>(null);\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n\n const { refs, floatingStyles } = useFloating({\n placement: \"bottom\",\n middleware: [offset(6), flip({ padding: 8 }), shift({ padding: 8 })],\n whileElementsMounted: autoUpdate,\n });\n\n useEffect(() => {\n if (open) {\n setPickerMonth(getStartOfMonth(viewValue));\n }\n }, [open, getStartOfMonth, viewValue]);\n\n useEffect(() => {\n if (!open) {\n return;\n }\n\n const handlePointerDown = (event: PointerEvent) => {\n const target = event.target as Node;\n const isInside = rootRef.current?.contains(target) || refs.floating.current?.contains(target);\n if (!isInside) {\n setOpen(false);\n }\n };\n\n addGlobalListener(document, \"pointerdown\", handlePointerDown);\n return () => removeGlobalListener(document, \"pointerdown\", handlePointerDown);\n }, [addGlobalListener, open, refs.floating, removeGlobalListener]);\n\n const heading = useMemo(\n () => (renderHeading ? renderHeading(viewValue, view) : getViewHeading(dateUtils, view, viewValue, startWeek)),\n [dateUtils, renderHeading, startWeek, view, viewValue]\n );\n\n const gridDays = useMemo(() => getMonthGrid(dateUtils, pickerMonth, startWeek), [dateUtils, pickerMonth, startWeek]);\n\n const handleToggleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n setOpen((prev) => !prev);\n };\n\n const handleToggleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.key === \"Escape\") {\n setOpen(false);\n }\n };\n\n const handleSelectDay = (day: CalendarDate) => {\n if (view === \"week\") {\n changeViewValue(getStartOfWeek(day, startWeek), view);\n } else {\n changeViewValue(day, view);\n }\n setOpen(false);\n };\n\n return (\n <div ref={rootRef} className={styles.root}>\n <button\n type={type}\n aria-label={messages.chooseDate}\n aria-expanded={open}\n aria-haspopup=\"dialog\"\n {...buttonProps}\n onClick={handleToggleClick}\n onKeyDown={handleToggleKeyDown}\n ref={refs.setReference}\n className={cx(className, styles.root__toggle)}\n >\n <span className={styles.root__toggleLabel}>{heading}</span>\n <ChevronIcon className={cx(styles.root__toggleIcon, { [styles.root__toggleIcon_open]: open })} />\n </button>\n\n {open && (\n <Portal>\n <div\n ref={refs.setFloating}\n style={floatingStyles}\n role=\"dialog\"\n aria-label={messages.chooseDate}\n className={styles.popover}\n >\n <div className={styles.popover__header}>\n <button\n type=\"button\"\n aria-label={messages.previousMonth}\n onClick={() => setPickerMonth((prev) => addMonths(prev, -1))}\n >\n <ChevronIcon className={styles.popover__navBackward} />\n </button>\n <div className={styles.popover__title}>{formatMonthYear(dateUtils, pickerMonth)}</div>\n <button\n type=\"button\"\n aria-label={messages.nextMonth}\n onClick={() => setPickerMonth((prev) => addMonths(prev, 1))}\n >\n <ChevronIcon className={styles.popover__navForward} />\n </button>\n </div>\n\n <div className={styles.popover__grid}>\n {gridDays.slice(0, 7).map((day) => (\n <div key={dateUtils.getWeekDay(day)} className={styles.popover__weekday}>\n {dateUtils.weekDayShortName(dateUtils.getWeekDay(day))}\n </div>\n ))}\n {gridDays.map((day, index) => {\n const isOutsideMonth = dateUtils.getMonths(day) !== dateUtils.getMonths(pickerMonth);\n const isToday = dateUtils.isToday(day);\n // Month view needs no band: the picker already shows that month.\n const isSelected = view !== \"month\" && isInViewPeriod(dateUtils, view, viewValue, day);\n const isRangeStart = isSelected && (view === \"day\" || index % 7 === 0);\n const isRangeEnd = isSelected && (view === \"day\" || index % 7 === 6);\n return (\n <button\n key={dateUtils.toMillis(day)}\n type=\"button\"\n onClick={() => handleSelectDay(day)}\n className={cx(styles.popover__day, {\n [styles.popover__day_outside]: isOutsideMonth,\n [styles.popover__day_today]: isToday,\n [styles.popover__day_selected]: isSelected,\n [styles.popover__day_rangeStart]: isRangeStart,\n [styles.popover__day_rangeEnd]: isRangeEnd,\n })}\n >\n {dateUtils.getMonthDay(day)}\n </button>\n );\n })}\n </div>\n </div>\n </Portal>\n )}\n </div>\n );\n}\n","import type { ButtonHTMLAttributes } from \"react\";\n\nimport ChevronIcon from \"../../icons/chevron\";\nimport { useEventCallback } from \"../../hooks\";\nimport { cx, mergeCallbacks } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useMessages } from \"../../date-localization\";\n\nimport styles from \"./NavBtn.module.css\";\n\nexport type NavBtnProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n direction?: \"forward\" | \"backward\";\n};\n\nexport default function NavBtn({\n direction = \"forward\",\n type = \"button\",\n onClick,\n className,\n children,\n ...props\n}: NavBtnProps) {\n const { goForward, goBackward } = useCalendarContext();\n const messages = useMessages();\n\n const handleClick = useEventCallback(\n mergeCallbacks(onClick, () => {\n if (direction === \"forward\") {\n goForward();\n } else if (direction === \"backward\") {\n goBackward();\n }\n })\n );\n\n return (\n <button\n type={type}\n aria-label={direction === \"forward\" ? messages.next : messages.previous}\n {...props}\n onClick={handleClick}\n className={cx(className, styles.root)}\n >\n {children ?? (\n <ChevronIcon\n className={cx(styles.root__icon, {\n [styles.root__icon_backward]: direction === \"backward\",\n [styles.root__icon_forward]: direction === \"forward\",\n })}\n />\n )}\n </button>\n );\n}\n","import { autoUpdate, flip, offset, shift, useFloating } from \"@floating-ui/react-dom\";\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport type { KeyboardEvent } from \"react\";\n\nimport { cx } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useMessages } from \"../../date-localization\";\nimport { useGlobalListeners } from \"../../hooks\";\nimport ChevronIcon from \"../../icons/chevron\";\nimport Portal from \"../../portal\";\nimport type { CalendarView } from \"../../Calendar.types\";\n\nimport styles from \"./ViewSelect.module.css\";\n\nconst VIEWS: readonly CalendarView[] = [\"day\", \"week\", \"month\"];\n\nexport type ViewSelectProps = { className?: string };\n\n/**\n * The view (day, week, month) as one button with a list: the view tabs of a calendar too\n * narrow for them.\n */\nexport default function ViewSelect({ className }: ViewSelectProps) {\n const { view, changeView } = useCalendarContext();\n const messages = useMessages();\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n const id = useId();\n\n const [open, setOpen] = useState(false);\n const [active, setActive] = useState(view);\n const optionRefs = useRef(new Map<CalendarView, HTMLDivElement>());\n\n const { refs, floatingStyles } = useFloating({\n placement: \"bottom-end\",\n middleware: [offset(6), flip({ padding: 8 }), shift({ padding: 8 })],\n whileElementsMounted: autoUpdate,\n });\n\n const close = (returnFocus: boolean) => {\n setOpen(false);\n const reference = refs.reference.current;\n if (returnFocus && reference instanceof HTMLElement) reference.focus();\n };\n\n const openList = (focused: CalendarView = view) => {\n setActive(focused);\n setOpen(true);\n };\n\n const select = (next: CalendarView) => {\n close(true);\n changeView(next);\n };\n\n // the active option has the focus while the list is open\n useEffect(() => {\n if (open) optionRefs.current.get(active)?.focus();\n }, [open, active]);\n\n useEffect(() => {\n if (!open) return;\n const handlePointerDown = (event: PointerEvent) => {\n const target = event.target as Node;\n const reference = refs.reference.current;\n const inside =\n (reference instanceof Node && reference.contains(target)) || refs.floating.current?.contains(target);\n if (!inside) setOpen(false);\n };\n addGlobalListener(document, \"pointerdown\", handlePointerDown);\n return () => removeGlobalListener(document, \"pointerdown\", handlePointerDown);\n }, [addGlobalListener, open, refs.floating, refs.reference, removeGlobalListener]);\n\n const handleToggleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n openList();\n }\n };\n\n const handleListKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const index = VIEWS.indexOf(active);\n const moveTo = (next: number) => {\n event.preventDefault();\n setActive(VIEWS[(next + VIEWS.length) % VIEWS.length] ?? active);\n };\n\n switch (event.key) {\n case \"ArrowDown\":\n return moveTo(index + 1);\n case \"ArrowUp\":\n return moveTo(index - 1);\n case \"Home\":\n return moveTo(0);\n case \"End\":\n return moveTo(VIEWS.length - 1);\n case \"Enter\":\n case \" \":\n event.preventDefault();\n return select(active);\n case \"Escape\":\n event.preventDefault();\n return close(true);\n case \"Tab\":\n return close(false);\n }\n };\n\n const listId = `${id}-list`;\n\n return (\n <>\n <button\n ref={refs.setReference}\n type=\"button\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listId : undefined}\n aria-label={`${messages.chooseView}: ${messages[view]}`}\n className={cx(className, styles.root)}\n onClick={() => (open ? close(false) : openList())}\n onKeyDown={handleToggleKeyDown}\n >\n {messages[view]}\n <ChevronIcon aria-hidden=\"true\" className={cx(styles.root__icon, { [styles.root__icon_open]: open })} />\n </button>\n\n {open && (\n <Portal>\n <div\n ref={refs.setFloating}\n id={listId}\n role=\"listbox\"\n aria-label={messages.chooseView}\n style={floatingStyles}\n className={styles.list}\n onKeyDown={handleListKeyDown}\n >\n {VIEWS.map((option) => (\n <div\n key={option}\n ref={(element) => {\n if (element) optionRefs.current.set(option, element);\n else optionRefs.current.delete(option);\n }}\n id={`${id}-${option}`}\n role=\"option\"\n tabIndex={-1}\n aria-selected={option === view}\n className={cx(styles.list__option, { [styles.list__option_active]: option === active })}\n onClick={() => select(option)}\n onPointerMove={() => setActive(option)}\n >\n {messages[option]}\n {option === view && (\n <svg aria-hidden=\"true\" className={styles.list__check} viewBox=\"0 0 16 16\" width=\"14\" height=\"14\">\n <path\n d=\"M3 8.5 6.5 12 13 4.5\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n )}\n </div>\n ))}\n </div>\n </Portal>\n )}\n </>\n );\n}\n","import type { ButtonHTMLAttributes, HTMLAttributes } from \"react\";\n\nimport { useEventCallback } from \"../../hooks\";\nimport { cx, mergeCallbacks } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useMessages } from \"../../date-localization\";\nimport type { CalendarView } from \"../../Calendar.types\";\n\nimport DateNavigator from \"../date-navigator\";\nimport NavBtn from \"../nav-btn\";\nimport ViewSelect from \"../view-select\";\n\nimport styles from \"./CalendarToolbar.module.css\";\n\nexport type CalendarToolbarProps = HTMLAttributes<HTMLDivElement>;\n\nexport default function CalendarToolbar(props: CalendarToolbarProps) {\n const { goToday, changeView, view } = useCalendarContext();\n const messages = useMessages();\n\n const rootProps = props;\n\n const viewTabProps: Record<CalendarView, ButtonHTMLAttributes<HTMLButtonElement>> = {\n day: {\n type: \"button\",\n [\"aria-selected\"]: view === \"day\",\n onClick: mergeCallbacks(undefined, () => changeView(\"day\")),\n className: cx(styles.root__viewTab, { [styles.root__viewTab_isActive]: view === \"day\" }),\n children: messages.day,\n },\n week: {\n type: \"button\",\n [\"aria-selected\"]: view === \"week\",\n onClick: mergeCallbacks(undefined, () => changeView(\"week\")),\n className: cx(styles.root__viewTab, { [styles.root__viewTab_isActive]: view === \"week\" }),\n children: messages.week,\n },\n month: {\n type: \"button\",\n [\"aria-selected\"]: view === \"month\",\n onClick: mergeCallbacks(undefined, () => changeView(\"month\")),\n className: cx(styles.root__viewTab, {\n [styles.root__viewTab_isActive]: view === \"month\",\n }),\n children: messages.month,\n },\n };\n\n const todayProps: ButtonHTMLAttributes<HTMLButtonElement> = {\n type: \"button\",\n onClick: useEventCallback(goToday),\n className: styles.root__today,\n children: messages.today,\n };\n\n return (\n <div {...rootProps} className={cx(rootProps.className, styles.root)}>\n <DateNavigator />\n\n <div className={styles.root__navigationPane} role=\"group\">\n <NavBtn direction=\"backward\" />\n <button {...todayProps} />\n <NavBtn direction=\"forward\" />\n </div>\n\n <div className={styles.root__viewList}>\n <button {...viewTabProps.day} />\n <button {...viewTabProps.week} />\n <button {...viewTabProps.month} />\n </div>\n\n {/* in place of the tabs in a narrow calendar */}\n <div className={styles.root__viewSelect}>\n <ViewSelect />\n </div>\n </div>\n );\n}\n","import { createContext, useContext } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/**\n * Provides the calendar viewport element used to portal\n * drag overlays and position absolute transforms relative to.\n */\nexport type CalendarViewportContextValue = {\n viewportRef: RefObject<HTMLDivElement | null>;\n};\n\nconst CalendarViewportContext = createContext<CalendarViewportContextValue | undefined>(undefined);\n\nif (isDevEnvironment) {\n CalendarViewportContext.displayName = \"CalendarViewportContext\";\n}\n\nexport default CalendarViewportContext;\n\nexport function useCalendarViewportContext() {\n const context = useContext(CalendarViewportContext);\n\n if (!context) {\n throw new Error(\"CalendarViewportContext is required\");\n }\n\n return context;\n}\n","import type { HTMLAttributes } from \"react\";\n\nimport { cx } from \"@weekwise/core\";\nimport type { Coordinates } from \"@weekwise/core\";\n\nimport styles from \"./PointerPopover.module.css\";\n\nexport type PointerPopoverProps = HTMLAttributes<HTMLSpanElement> & {\n coordinates?: Coordinates;\n};\n\nexport default function PointerPopover({ coordinates, className, style, ...props }: PointerPopoverProps) {\n return (\n <span\n tabIndex={-1}\n {...props}\n className={cx(className, styles.root)}\n style={{\n ...style,\n ...(coordinates\n ? {\n top: `calc(${coordinates.y}px + 20px)`,\n left: `calc(${coordinates.x}px + 20px)`,\n }\n : null),\n }}\n />\n );\n}\n","import { useMemo, useRef, useState } from \"react\";\nimport type { CSSProperties, HTMLAttributes } from \"react\";\n\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\nimport { cx } from \"@weekwise/core\";\n\nimport type { EventData, EventPart } from \"../../Calendar.types\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useCalendarViewportContext } from \"../../contexts/CalendarViewportContext\";\nimport { useDocumentCursor, useIsomorphicLayoutEffect } from \"../../hooks\";\nimport Portal from \"../../portal\";\n\nimport PointerPopover from \"../pointer-popover\";\n\nimport styles from \"./DragOverlay.module.css\";\n\n/** The dragged event is drawn whole, whichever of its parts was picked up. */\nconst WHOLE_EVENT: EventPart = { isStart: true, isEnd: true };\n\nexport type DragOverlayProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * Whether to render the pointer time preview popover while dragging.\n * Disabled in views where the overlay transform does not map to minutes.\n */\n showPreview?: boolean;\n /** Height of a minute in pixels, to read the overlay transform as minutes for the preview. */\n pxPerMinute?: number;\n};\n\nexport default function DragOverlay({ showPreview = true, pxPerMinute = 1, ...props }: DragOverlayProps) {\n const { eventMap, eventRenderer, pointerPreviewRenderer, view } = useCalendarContext();\n const { viewportRef } = useCalendarViewportContext();\n\n const { isDragging, canDrop, dropData, eventItem, source, x, y, ...transform } = useDragAndDrop(\n ({ draggable, overlay, droppable, canDrop }) => {\n const dropData = [...droppable.dropTargets.values()].shift();\n const items = [...draggable.dragTargets.values()].shift();\n\n return {\n ...overlay.transform,\n source: [...draggable.dragTargets.keys()].shift() ?? null,\n canDrop: canDrop(),\n dropData,\n eventItem: items ? items.filter((item) => item.event)[0] : null,\n isDragging: draggable.isDragging,\n x: draggable.x,\n y: draggable.y,\n };\n }\n );\n\n const eventValue = useMemo(() => {\n if (!eventItem) {\n return null;\n }\n\n // the drag payload is serialized, so render the original value instead of the parsed one\n const { key } = JSON.parse(eventItem.event) as EventData;\n return eventMap.get(key)?.value ?? null;\n }, [eventItem, eventMap]);\n\n // Released where the event cannot go, outside the calendar or by Escape: the overlay flies back\n // from where it was last over a day onto the event, which reappears under it.\n const lastRef = useRef<{ transform: typeof transform; source: HTMLElement; eventValue: unknown } | null>(null);\n const droppedRef = useRef(false);\n // the drag has been over a day: the overlay has a place to be drawn at\n const [isPlaced, setIsPlaced] = useState(false);\n const [returning, setReturning] = useState<{\n container: HTMLElement;\n style: CSSProperties;\n eventValue: unknown;\n } | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (isDragging) {\n droppedRef.current = canDrop;\n if (dropData && source) {\n lastRef.current = { transform, source, eventValue };\n setIsPlaced(true);\n setReturning(null);\n }\n return;\n }\n\n setIsPlaced(false);\n const last = lastRef.current;\n lastRef.current = null;\n const container = viewportRef.current;\n if (!last || droppedRef.current || !container || !last.source.isConnected) return;\n\n const { transform: from } = last;\n const sourceRect = last.source.getBoundingClientRect();\n const containerRect = container.getBoundingClientRect();\n setReturning({\n container,\n eventValue: last.eventValue,\n style: {\n left: sourceRect.left - containerRect.left,\n top: sourceRect.top - containerRect.top,\n width: sourceRect.width,\n height: sourceRect.height,\n \"--ww-return-left\": `${from.left}px`,\n \"--ww-return-top\": `${from.top}px`,\n \"--ww-return-width\": `${from.width}px`,\n \"--ww-return-height\": `${from.height}px`,\n } as CSSProperties,\n });\n });\n\n // The page shows the drag's cursor: grabbing, or \"not allowed\" where the event cannot go.\n useDocumentCursor(isDragging ? (canDrop ? \"grabbing\" : \"not-allowed\") : null);\n\n if (!isDragging) {\n return returning ? (\n <Portal container={returning.container}>\n <div\n {...props}\n className={cx(props.className, styles.root, styles.root_isReturning)}\n style={returning.style}\n onAnimationEnd={() => setReturning(null)}\n >\n {returning.eventValue != null ? eventRenderer.current?.(returning.eventValue, view, WHOLE_EVENT) : null}\n </div>\n </Portal>\n ) : null;\n }\n\n if (!isPlaced) {\n return null;\n }\n\n // Over a day or time the event cannot be dropped on, or outside the calendar, the overlay\n // stays where it was last placed, marked as blocked.\n const isBlocked = !canDrop;\n\n return (\n <Portal container={viewportRef.current}>\n <div\n {...props}\n className={cx(props.className, styles.root, {\n [styles.root_isDragging]: isDragging,\n [styles.root_isBlocked]: isBlocked,\n })}\n style={{ ...transform }}\n >\n {eventValue != null ? eventRenderer.current?.(eventValue, view, WHOLE_EVENT) : null}\n </div>\n {showPreview && !isBlocked && (\n <PointerPopover coordinates={{ x, y }}>\n {dropData\n ? pointerPreviewRenderer.current?.(\n dropData.date,\n Math.round(transform.top / pxPerMinute),\n Math.round(transform.height / pxPerMinute)\n )\n : null}\n </PointerPopover>\n )}\n </Portal>\n );\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport type { CSSProperties } from \"react\";\n\n/** Lanes of events under the day numbers; more events collapse into \"+N more\". */\nexport const MAX_LANES = 3;\n\ntype CSSVariables = Record<`--${string}`, number>;\n\n/** Inline style of CSS custom properties, which place cells and bars in the week grid. */\nexport function cssVariables(variables: CSSVariables, style?: CSSProperties): CSSProperties {\n return { ...style, ...variables };\n}\n\n/** Splits the month grid's days into weeks of 7. */\nexport function splitIntoWeeks(days: CalendarDate[]): CalendarDate[][] {\n return Array.from({ length: Math.ceil(days.length / 7) }, (_, week) => days.slice(week * 7, week * 7 + 7));\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useEffect, useRef } from \"react\";\nimport type { DetailedHTMLProps, HTMLAttributes, MouseEvent } from \"react\";\n\nimport { useCalendarDateUtils } from \"../../date-localization\";\nimport type { TextDropItem } from \"@weekwise/dnd\";\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\nimport { useEventCallback, useMergedRefs } from \"../../hooks\";\nimport { cx } from \"@weekwise/core\";\n\nimport { toDayMinutes } from \"@weekwise/core\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport type { MonthViewDragItem } from \"./MonthViewEvent\";\n\nimport styles from \"./MonthView.module.css\";\n\nexport type MonthViewDayProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {\n /**\n * Date associated to the day cell\n */\n targetDate: CalendarDate;\n};\n\nexport interface MonthViewDropTargetData {\n date: CalendarDate;\n}\n\nexport default function MonthViewDay(props: MonthViewDayProps) {\n const { ref: forwardedRef, targetDate, children, onDoubleClick, ...rootProps } = props;\n\n const { onEventChange, onEventCreate, getIsDayDisabled, disabled, eventMap } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const { getHours, getMinutes, getNow } = dateUtils;\n\n const rootRef = useRef<HTMLDivElement>(null);\n\n const { register, isOver } = useDragAndDrop(({ registerDropTarget, isOver }) => ({\n register: registerDropTarget,\n isOver: isOver(rootRef.current),\n }));\n\n useEffect(() => {\n const dropTargetElement = rootRef.current;\n\n if (!dropTargetElement) {\n return;\n }\n\n const dropTargetData: MonthViewDropTargetData = { date: targetDate };\n return register(dropTargetElement, {\n data: dropTargetData,\n onDrop: async (e) => {\n const [dragItem] = await Promise.all(\n e.items\n .filter(\n (item): item is TextDropItem => item.kind === \"text\" && item.types.has(\"event\") && \"getText\" in item\n )\n .map(async (item) => {\n const data = await item.getText(\"event\");\n return JSON.parse(data) as MonthViewDragItem;\n })\n );\n\n const eventData = dragItem && eventMap.get(dragItem.key);\n if (!eventData) {\n return;\n }\n\n // move by as many days as the event was dragged: a multi-day event can be\n // grabbed by any of its days. The time of the day stays.\n const sourceDay = dateUtils.fromMillis(dragItem.day ?? dragItem.date);\n const shift = toDayMinutes(dateUtils, sourceDay, targetDate) / (24 * 60);\n if (shift === 0) {\n return;\n }\n onEventChange(eventData.key, dateUtils.addDays(dateUtils.getStartOfDay(eventData.date), shift), {\n from: getHours(eventData.date) * 60 + getMinutes(eventData.date),\n duration: eventData.duration,\n });\n },\n getDropOperationForPoint: (types, allowedOperations) => {\n if (disabled || !types.has(\"event\")) return \"cancel\";\n\n if (getIsDayDisabled && getIsDayDisabled(targetDate)) {\n return \"cancel\";\n }\n\n return allowedOperations[0];\n },\n });\n }, [dateUtils, disabled, eventMap, getHours, getIsDayDisabled, getMinutes, onEventChange, register, targetDate]);\n\n const handleDoubleClick = useEventCallback((event: MouseEvent<HTMLDivElement>) => {\n onDoubleClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n\n if (disabled) {\n return;\n }\n\n if (getIsDayDisabled && getIsDayDisabled(targetDate)) {\n return;\n }\n\n const now = getNow();\n onEventCreate(targetDate, {\n from: getHours(now) * 60 + getMinutes(now),\n duration: 60,\n });\n });\n\n const handleRootRef = useMergedRefs(rootRef, forwardedRef);\n\n return (\n <div\n {...rootProps}\n ref={handleRootRef}\n onDoubleClick={handleDoubleClick}\n className={cx(rootProps.className, styles.root__day, {\n [styles.root__day_isOver]: isOver,\n })}\n >\n {children}\n </div>\n );\n}\n","import { useCallback, useRef } from \"react\";\n\nexport function useInterval() {\n const intervalRef = useRef<number | null>(null);\n\n const set = useCallback((listener: (...args: any[]) => any, duration: number) => {\n intervalRef.current = setInterval(listener, duration);\n }, []);\n\n const clear = useCallback(() => {\n if (intervalRef.current !== null) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n }, []);\n\n return [set, clear] as const;\n}\n","import { useComputed, usePrevious } from \"../hooks\";\nimport type { Coordinates } from \"@weekwise/core\";\n\nexport enum ScrollDirection {\n Forward = 1,\n Backward = -1,\n}\n\ninterface ScrollIntent {\n x: Record<ScrollDirection, boolean>;\n y: Record<ScrollDirection, boolean>;\n}\n\nconst defaultScrollIntent: ScrollIntent = {\n x: { [ScrollDirection.Backward]: false, [ScrollDirection.Forward]: false },\n y: { [ScrollDirection.Backward]: false, [ScrollDirection.Forward]: false },\n};\n\nexport default function useScrollIntent({ delta, disabled }: { delta: Coordinates; disabled: boolean }): ScrollIntent {\n const previousDelta = usePrevious(delta);\n\n return useComputed<ScrollIntent>(\n (previousIntent) => {\n if (disabled || !previousDelta || !previousIntent) {\n // Reset scroll intent tracking when auto-scrolling is disabled\n return defaultScrollIntent;\n }\n\n const direction = {\n x: Math.sign(delta.x - previousDelta.x),\n y: Math.sign(delta.y - previousDelta.y),\n };\n\n // Keep track of the user intent to scroll in each direction for both axis\n return {\n x: {\n [ScrollDirection.Backward]: previousIntent.x[ScrollDirection.Backward] || direction.x === -1,\n [ScrollDirection.Forward]: previousIntent.x[ScrollDirection.Forward] || direction.x === 1,\n },\n y: {\n [ScrollDirection.Backward]: previousIntent.y[ScrollDirection.Backward] || direction.y === -1,\n [ScrollDirection.Forward]: previousIntent.y[ScrollDirection.Forward] || direction.y === 1,\n },\n };\n },\n [disabled, delta, previousDelta]\n );\n}\n","/* oxlint-disable react-hooks/exhaustive-deps */\nimport { useCallback, useEffect, useMemo, useRef } from \"react\";\n\nimport type { ClientRect, Coordinates } from \"@weekwise/core\";\n\nimport { getScrollDirectionAndSpeed } from \"@weekwise/core\";\nimport { useInterval } from \"./useInterval\";\nimport useScrollIntent, { type ScrollDirection as Direction } from \"./useScrollIntent\";\n\nenum AutoScrollActivator {\n Pointer,\n DraggableRect,\n}\n\nenum TraversalOrder {\n TreeOrder,\n ReversedTreeOrder,\n}\n\nexport function useAutoScroller(args: UseAutoScrollerParams) {\n const {\n acceleration,\n activator = AutoScrollActivator.Pointer,\n canScroll,\n enabled,\n interval = 5,\n pointerCoordinates,\n order = TraversalOrder.TreeOrder,\n delta,\n threshold,\n activeNodeRect,\n scrollableAncestors,\n scrollableAncestorsRects,\n } = args;\n\n const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();\n\n const scrollIntent = useScrollIntent({ delta, disabled: !enabled });\n const scrollSpeed = useRef<Coordinates>({ x: 0, y: 0 });\n const scrollDirection = useRef<ScrollDirection>({ x: 0, y: 0 });\n const scrollContainerRef = useRef<Element | null>(null);\n const sortedScrollableAncestorsWithRects = useMemo<[Element[], ClientRect[]]>(\n () =>\n order === TraversalOrder.TreeOrder\n ? [[...scrollableAncestors].reverse(), [...scrollableAncestorsRects].reverse()]\n : [[...scrollableAncestors], [...scrollableAncestorsRects]],\n [order, scrollableAncestors, scrollableAncestorsRects]\n );\n\n const rect = useMemo(() => {\n switch (activator) {\n case AutoScrollActivator.Pointer:\n return pointerCoordinates\n ? {\n top: pointerCoordinates.y,\n bottom: pointerCoordinates.y,\n left: pointerCoordinates.x,\n right: pointerCoordinates.x,\n }\n : null;\n case AutoScrollActivator.DraggableRect:\n return activeNodeRect;\n }\n }, [activator, activeNodeRect, pointerCoordinates]);\n\n const autoScroll = useCallback(() => {\n const scrollContainer = scrollContainerRef.current;\n\n if (!scrollContainer) {\n return;\n }\n\n const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;\n const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;\n\n scrollContainer.scrollBy(scrollLeft, scrollTop);\n }, []);\n\n useEffect(() => {\n const [scrollableAncestors, scrollableAncestorsRects] = sortedScrollableAncestorsWithRects;\n\n if (!enabled || !scrollableAncestors.length || !rect) {\n clearAutoScrollInterval();\n return;\n }\n\n for (const [index, scrollContainer] of scrollableAncestors.entries()) {\n if (!scrollContainer || canScroll?.(scrollContainer) === false) {\n continue;\n }\n\n const scrollContainerRect = scrollableAncestorsRects[index];\n\n if (!scrollContainerRect) {\n continue;\n }\n\n const { direction, speed } = getScrollDirectionAndSpeed(\n scrollContainer,\n scrollContainerRect,\n rect,\n acceleration,\n threshold\n );\n\n for (const axis of [\"x\", \"y\"] as const) {\n if (!scrollIntent[axis][direction[axis] as Direction]) {\n speed[axis] = 0;\n direction[axis] = 0;\n }\n }\n\n if (speed.x > 0 || speed.y > 0) {\n clearAutoScrollInterval();\n setAutoScrollInterval(autoScroll, interval);\n\n scrollContainerRef.current = scrollContainer;\n scrollSpeed.current = speed;\n scrollDirection.current = direction;\n return;\n }\n }\n\n scrollSpeed.current = { x: 0, y: 0 };\n scrollDirection.current = { x: 0, y: 0 };\n\n clearAutoScrollInterval();\n }, [\n acceleration,\n autoScroll,\n canScroll,\n enabled,\n interval,\n rect,\n scrollableAncestors,\n sortedScrollableAncestorsWithRects,\n threshold,\n clearAutoScrollInterval,\n setAutoScrollInterval,\n\n ...Object.entries(rect || {}),\n ...Object.entries(scrollIntent),\n ...Object.entries(threshold || {}),\n ]);\n}\n\ninterface UseAutoScrollerParams {\n enabled: boolean;\n pointerCoordinates: Coordinates | null;\n delta: Coordinates;\n acceleration?: number;\n activator?: AutoScrollActivator;\n canScroll?: CanScroll;\n interval?: number;\n activeNodeRect: ClientRect | null;\n scrollableAncestors: Element[];\n scrollableAncestorsRects: ClientRect[];\n layoutShiftCompensation?:\n | boolean\n | {\n x: boolean;\n y: boolean;\n };\n order?: TraversalOrder;\n threshold?: {\n x: number;\n y: number;\n };\n}\n\ninterface ScrollDirection {\n x: 0 | Direction;\n y: 0 | Direction;\n}\n\ntype CanScroll = (element: Element) => boolean;\n","import { useEffect, useMemo, useRef } from \"react\";\n\n/**\n * Returns a new MutationObserver instance.\n * If `MutationObserver` is undefined in the execution environment, returns `undefined`.\n */\nexport function useMutationObserver(cb: MutationCallback, disabled = false) {\n const cbRef = useRef(cb);\n cbRef.current = cb;\n\n const mutationObserver = useMemo(() => {\n if (disabled || typeof window === \"undefined\" || typeof window.MutationObserver === \"undefined\") {\n return undefined;\n }\n\n const { MutationObserver } = window;\n const { current: cb } = cbRef;\n return new MutationObserver(cb);\n }, [disabled]);\n\n useEffect(() => {\n return () => mutationObserver?.disconnect();\n }, [mutationObserver]);\n\n return mutationObserver;\n}\n","import { useReducer } from \"react\";\n\nimport { useIsomorphicLayoutEffect, useResizeObserver } from \"../hooks\";\nimport type { ClientRect } from \"@weekwise/core\";\nimport { shallowEqual } from \"@weekwise/core\";\n\nimport { getClientRect, isHTMLElement } from \"@weekwise/core\";\nimport { useMutationObserver } from \"./useMutationObserver\";\n\nexport default function useRect(\n element: HTMLElement | null,\n measure: (element: HTMLElement) => ClientRect = getClientRect,\n fallbackRect?: ClientRect | null\n) {\n const [rect, measureRect] = useReducer(reducer, null);\n\n const mutationObserver = useMutationObserver((records) => {\n if (!element) {\n return;\n }\n\n for (const record of records) {\n const { type, target } = record;\n\n if (type === \"childList\" && isHTMLElement(target) && target.contains(element)) {\n measureRect();\n break;\n }\n }\n });\n\n const resizeObserver = useResizeObserver(measureRect);\n\n useIsomorphicLayoutEffect(() => {\n measureRect();\n\n if (element) {\n resizeObserver?.observe(element);\n mutationObserver?.observe(document.body, { childList: true, subtree: true });\n } else {\n resizeObserver?.disconnect();\n mutationObserver?.disconnect();\n }\n }, [element, mutationObserver, resizeObserver]);\n\n return rect;\n\n function reducer(currentRect: ClientRect | null) {\n if (!element) {\n return null;\n }\n\n if (!element.isConnected) {\n // Fallback to last rect we measured if the element is\n // no longer connected to the DOM.\n return currentRect ?? fallbackRect ?? null;\n }\n\n const newRect = measure(element);\n\n if (shallowEqual(newRect, currentRect)) {\n return currentRect;\n }\n\n return newRect;\n }\n}\n","import { useEffect, useMemo, useRef } from \"react\";\n\nimport { getScrollableAncestors } from \"@weekwise/core\";\n\nconst defaultValue: Element[] = [];\n\nexport function useScrollableAncestors(node: HTMLElement | null, limit?: number) {\n const previousNode = useRef(node);\n\n const ancestors = useMemo<Element[]>(\n () => {\n if (!node) {\n return defaultValue;\n }\n\n return getScrollableAncestors(node, limit);\n },\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n [node, limit]\n );\n\n useEffect(() => {\n previousNode.current = node;\n }, [node]);\n\n return ancestors;\n}\n","import { useReducer } from \"react\";\n\nimport { useIsomorphicLayoutEffect, useResizeObserver } from \"../hooks\";\nimport type { ClientRect } from \"@weekwise/core\";\n\nimport { getClientRect, Rect } from \"@weekwise/core\";\nimport { getWindow } from \"@weekwise/core\";\n\nconst defaultValue: ClientRect[] = [];\n\nexport default function useScrollableAncestorsRects(elements: Element[], measure = getClientRect): ClientRect[] {\n const [rects, measureRects] = useReducer(reducer, defaultValue);\n const resizeObserver = useResizeObserver(measureRects);\n\n if (elements.length > 0 && rects === defaultValue) {\n measureRects();\n }\n\n useIsomorphicLayoutEffect(() => {\n if (elements.length) {\n elements.forEach((element) => resizeObserver?.observe(element));\n } else {\n resizeObserver?.disconnect();\n measureRects();\n }\n }, [elements, resizeObserver]);\n\n return rects;\n\n function reducer(): ClientRect[] {\n if (!elements.length) {\n return defaultValue;\n }\n\n return elements.map((element) => {\n if (element === document.scrollingElement) {\n const window = getWindow(element);\n const width = window.innerWidth;\n const height = window.innerHeight;\n\n return {\n top: 0,\n left: 0,\n right: width,\n bottom: height,\n width,\n height,\n };\n }\n\n return new Rect(measure(element), element);\n });\n }\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { Coordinates } from \"@weekwise/core\";\nimport { isNotNull } from \"@weekwise/core\";\n\nimport { add, defaultCoordinates, getScrollableElement, getScrollCoordinates, getScrollOffsets } from \"@weekwise/core\";\n\ntype ScrollCoordinates = Map<HTMLElement | Window, Coordinates>;\n\nexport default function useScrollOffsets(elements: Element[]): Coordinates {\n const [scrollCoordinates, setScrollCoordinates] = useState<ScrollCoordinates | null>(null);\n const prevElements = useRef(elements);\n\n const handleScroll = useCallback((event: Event) => {\n const scrollingElement = getScrollableElement(event.target);\n\n if (!scrollingElement) {\n return;\n }\n\n setScrollCoordinates((scrollCoordinates) => {\n if (!scrollCoordinates) {\n return null;\n }\n\n scrollCoordinates.set(scrollingElement, getScrollCoordinates(scrollingElement));\n\n return new Map(scrollCoordinates);\n });\n }, []);\n\n useEffect(() => {\n const previousElements = prevElements.current;\n\n if (elements !== previousElements) {\n cleanup(previousElements);\n\n const entries = elements\n .map((element) => {\n const scrollableElement = getScrollableElement(element);\n\n if (scrollableElement) {\n scrollableElement.addEventListener(\"scroll\", handleScroll, {\n passive: true,\n });\n\n return [scrollableElement, getScrollCoordinates(scrollableElement)] as const;\n }\n\n return null;\n })\n .filter((entry): entry is [HTMLElement | (Window & typeof globalThis), Coordinates] => isNotNull(entry));\n\n setScrollCoordinates(entries.length ? new Map(entries) : null);\n\n prevElements.current = elements;\n }\n\n return () => {\n cleanup(elements);\n cleanup(previousElements);\n };\n\n function cleanup(elements: Element[]) {\n elements.forEach((element) => {\n const scrollableElement = getScrollableElement(element);\n if (scrollableElement) {\n scrollableElement.removeEventListener(\"scroll\", handleScroll);\n }\n });\n }\n }, [handleScroll, elements]);\n\n return useMemo(() => {\n if (elements.length) {\n return scrollCoordinates\n ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates)\n : getScrollOffsets(elements);\n }\n\n return defaultCoordinates;\n }, [elements, scrollCoordinates]);\n}\n","import { useEffect, useRef, type DependencyList } from \"react\";\n\nimport { emptyArray } from \"@weekwise/core\";\nimport type { Coordinates } from \"@weekwise/core\";\n\nimport { defaultCoordinates, subtract } from \"@weekwise/core\";\n\nexport function useScrollOffsetsDelta(scrollOffsets: Coordinates, dependencies: DependencyList = emptyArray) {\n const initialScrollOffsets = useRef<Coordinates | null>(null);\n\n useEffect(\n () => {\n initialScrollOffsets.current = null;\n },\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n dependencies\n );\n\n useEffect(() => {\n const hasScrollOffsets = scrollOffsets !== defaultCoordinates;\n\n if (hasScrollOffsets && !initialScrollOffsets.current) {\n initialScrollOffsets.current = scrollOffsets;\n }\n\n if (!hasScrollOffsets && initialScrollOffsets.current) {\n initialScrollOffsets.current = null;\n }\n }, [scrollOffsets]);\n\n return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;\n}\n","import { useMemo, useReducer } from \"react\";\n\nimport {\n add,\n adjustScrollRect,\n applyMoveTransformModifiers,\n match,\n type ClientRect,\n type Coordinates,\n type MoveTransform,\n type MoveTransformModifier,\n} from \"@weekwise/core\";\n\nimport { useAutoScroller } from \"./useAutoScroller\";\nimport useRect from \"./useRect\";\nimport { useScrollableAncestors } from \"./useScrollableAncestors\";\nimport useScrollableAncestorsRects from \"./useScrollableAncestorsRects\";\nimport useScrollOffsets from \"./useScrollOffsets\";\nimport { useScrollOffsetsDelta } from \"./useScrollOffsetsDelta\";\n\nexport type { MoveTransform, MoveTransformModifier };\n\nconst UseMoveTransformActionTypes = {\n Start: \"start\",\n Move: \"move\",\n Stop: \"stop\",\n} as const;\n\nconst defaultMoveTransformState: UseMoveTransformState = {\n isActive: false,\n initialTranslate: { x: 0, y: 0 },\n translate: { x: 0, y: 0 },\n delta: { x: 0, y: 0 },\n context: null,\n};\n\ntype UseMoveTransformActionTypes = (typeof UseMoveTransformActionTypes)[keyof typeof UseMoveTransformActionTypes];\n\nexport default function useMoveTransform<Context = unknown>({\n autoScrollEnabled = true,\n modifiers = [],\n activeNode = null,\n containerNode = null,\n}: UseMoveTranformParams<Context>): [\n UseMoveTransformResult<Context>,\n MoveActions<Context>,\n {\n pointerCoordinates: Coordinates;\n scrollAdjustmentActiveNodeRect: ClientRect | null;\n scrollAdjustmentContainerNodeRect: ClientRect | null;\n },\n] {\n const [state, dispatch] = useReducer(defaultMoveTransformReducer, defaultMoveTransformState);\n const resolvedActiveNode = typeof activeNode === \"function\" ? activeNode(state.context as Context) : activeNode;\n const resolvedContainerNode =\n typeof containerNode === \"function\" ? containerNode(state.context as Context) : containerNode;\n // to get valid initial rect pass active node only if moving started\n const activeNodeRect = useRect(state.isActive ? resolvedActiveNode : null);\n const containerNodeRect = useRect(state.isActive ? resolvedContainerNode : null);\n const scrollableAncestors = useScrollableAncestors(state.isActive ? resolvedActiveNode : null);\n\n const scrollableAncestorsRects = useScrollableAncestorsRects(scrollableAncestors);\n const scrollOffsets = useScrollOffsets(scrollableAncestors);\n // Represents the scroll delta since moving was initiated\n const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets);\n\n const actions = useMemo(() => {\n const buildAction = <T extends UseMoveTransformActionTypes>(type: T): ContextCallback<T, Context> => {\n return (coordinates: Coordinates, context?: Context) => {\n dispatch({ type: type, coordinates, context });\n };\n };\n\n return {\n start: buildAction(UseMoveTransformActionTypes.Start),\n move: buildAction(UseMoveTransformActionTypes.Move),\n stop: buildAction(UseMoveTransformActionTypes.Stop),\n };\n }, []);\n\n const pointerCoordinates = add(state.initialTranslate, state.translate);\n\n useAutoScroller({\n // the delta between initial translate coordinates\n delta: state.translate,\n enabled: autoScrollEnabled && state.isActive,\n activeNodeRect,\n pointerCoordinates,\n scrollableAncestors,\n scrollableAncestorsRects,\n });\n\n const scrollAdjustmentTranslate = add(state.translate, scrollAdjustment);\n const scrollAdjustmentActiveNodeRect = adjustScrollRect(activeNodeRect, scrollAdjustment);\n const scrollAdjustmentContainerNodeRect = adjustScrollRect(containerNodeRect, scrollAdjustment);\n\n const transform: MoveTransform = applyMoveTransformModifiers(modifiers, {\n // the delta between previous translate coordinates\n delta: state.delta,\n transform: {\n ...state.translate,\n left: state.translate.x,\n top: state.translate.y,\n height: activeNodeRect?.height || 0,\n width: activeNodeRect?.width || 0,\n },\n context: state.context as Context,\n activeNodeRect,\n containerNodeRect,\n translate: scrollAdjustmentTranslate,\n initialTranslate: state.initialTranslate,\n });\n\n return [\n {\n context: state.context as Context,\n // activate only on start moving\n isActive: state.currentAction === \"move\",\n transform,\n translate: state.translate,\n initialTranslate: state.initialTranslate,\n containerNodeRect,\n activeNodeRect,\n delta: state.delta,\n },\n actions,\n { pointerCoordinates, scrollAdjustmentActiveNodeRect, scrollAdjustmentContainerNodeRect },\n ];\n}\n\nfunction defaultMoveTransformReducer(state: UseMoveTransformState, action: UseMoveTransformActions) {\n const reducer: UseMoveTranformReducer = {\n [UseMoveTransformActionTypes.Start]: (state, { coordinates, context }) => {\n return {\n ...state,\n isActive: true,\n currentAction: UseMoveTransformActionTypes.Start,\n initialTranslate: { ...coordinates },\n context,\n };\n },\n [UseMoveTransformActionTypes.Move]: (state, { coordinates }) => {\n return {\n ...state,\n currentAction: UseMoveTransformActionTypes.Move,\n translate: {\n x: coordinates.x - state.initialTranslate.x,\n y: coordinates.y - state.initialTranslate.y,\n },\n delta: {\n x: coordinates.x - (state.translate.x + state.initialTranslate.x),\n y: coordinates.y - (state.translate.y + state.initialTranslate.y),\n },\n };\n },\n [UseMoveTransformActionTypes.Stop]: () => {\n return { ...defaultMoveTransformState, currentAction: UseMoveTransformActionTypes.Stop };\n },\n };\n\n return match(action.type, reducer, state, action);\n}\n\ntype ContextCallback<\n Type extends UseMoveTransformActionTypes,\n Context = unknown,\n> = Type extends typeof UseMoveTransformActionTypes.Start\n ? (newCoordinates: Coordinates, context?: Context) => void\n : (newCoordinates: Coordinates) => void;\n\ninterface UseMoveTranformParams<Context> {\n modifiers?: MoveTransformModifier<Context>[];\n activeNode?: ((context: Context | null) => HTMLElement | null) | HTMLElement | null;\n containerNode?: ((context: Context | null) => HTMLElement | null) | HTMLElement | null;\n autoScrollEnabled?: boolean;\n}\n\ninterface MoveActions<Context = unknown> {\n /**\n * Starts the move transform\n * @param newCoordinates The new coordinates\n * @param context The context of execution\n * @returns void\n */\n start: (newCoordinates: Coordinates, context?: Context) => void;\n /**\n * Moves the move transform\n * @param newCoordinates The new coordinates\n * @returns void\n */\n move: (newCoordinates: Coordinates) => void;\n /**\n * Stops the move transform\n * @param newCoordinates The new coordinates\n * @returns void\n */\n stop: (newCoordinates: Coordinates) => void;\n}\n\ninterface UseMoveTransformResult<Context = unknown> {\n /**\n * Whether the move transform is active\n */\n isActive: boolean;\n /**\n * The current move transform\n */\n transform: MoveTransform;\n /**\n * The context of the current move transform\n */\n context: Context;\n /**\n * The current translate coordinates\n */\n translate: Coordinates;\n /**\n * The initial translate coordinates\n */\n initialTranslate: Coordinates;\n /**\n * The delta between previous translate coordinates\n */\n delta: Coordinates;\n /**\n * The actions of the move transform\n */\n activeNodeRect: ClientRect | null;\n /**\n * The actions of the move transform\n */\n containerNodeRect: ClientRect | null;\n /**\n * The actions of the move transform\n */\n}\n\ninterface UseMoveTransformState<Context = unknown> {\n /**\n * Whether the move transform is active\n */\n isActive: boolean;\n /**\n * Current action\n */\n currentAction?: UseMoveTransformActionTypes;\n /**\n * Initial translate coordinates\n */\n initialTranslate: Coordinates;\n /**\n * Delta between initial translate coordinates\n */\n translate: Coordinates;\n /**\n * Delta between previous translate coordinates\n */\n delta: Coordinates;\n /**\n * Current context of the action\n */\n context: Context | null;\n}\n\ntype UseMoveTransformActions =\n | {\n type: typeof UseMoveTransformActionTypes.Start;\n coordinates: Coordinates;\n context?: unknown;\n }\n | {\n type: typeof UseMoveTransformActionTypes.Move;\n coordinates: Coordinates;\n }\n | {\n type: typeof UseMoveTransformActionTypes.Stop;\n coordinates: Coordinates;\n };\n\ntype UseMoveTranformReducer = {\n [P in UseMoveTransformActionTypes]: (\n state: UseMoveTransformState,\n action: Extract<UseMoveTransformActions, { type: P }>\n ) => UseMoveTransformState;\n};\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useEffect, useRef } from \"react\";\nimport type { DetailedHTMLProps, HTMLAttributes, PointerEvent, RefObject } from \"react\";\n\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\nimport { useEventCallback, useMergedRefs, useMove } from \"../../hooks\";\nimport type { MoveTransform } from \"../../hooks/useMoveTransform\";\nimport useMoveTransform from \"../../hooks/useMoveTransform\";\nimport useRect from \"../../hooks/useRect\";\nimport { cx, MONTH_WEEK_GEOMETRY, type MonthBar } from \"@weekwise/core\";\n\nimport type { EventData } from \"../../Calendar.types\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useCalendarDateUtils } from \"../../date-localization\";\nimport { useCalendarViewportContext } from \"../../contexts/CalendarViewportContext\";\n\nimport { cssVariables } from \"./MonthView.utils\";\nimport type { MonthResizeActions, MonthResizeEdge } from \"./useMonthResize\";\n\nimport styles from \"./MonthView.module.css\";\n\n/** Horizontal margin of a bar in its day (`.root__event`). */\nconst BAR_INSET = 6;\n\nexport type MonthViewEventProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {\n /** The event's bar in this week: its days and lane. */\n eventData: MonthBar<unknown, CalendarDate>;\n /** The days of the week row the bar is in. */\n weekDays: CalendarDate[];\n /** The week row the bar lies in: where it is grabbed picks the day the drag moves. */\n weekRef: RefObject<HTMLDivElement | null>;\n /** Whether the bar's edges stretch the event into other days. */\n resizable?: boolean;\n /** Resizing by the bar's edges, run by the view. */\n resize?: MonthResizeActions;\n /** The bar before the resize: hidden while the view shows the new range. */\n isResizeSource?: boolean;\n /** Some event is being resized: no bar is draggable meanwhile. */\n isAnyResizing?: boolean;\n};\n\n/**\n * What a month event carries while dragged: the event and the day it was grabbed by.\n * Dragged items travel as JSON, so dates are timestamps: not every date type survives JSON.\n */\nexport interface MonthViewDragItem extends Omit<EventData<unknown, CalendarDate>, \"date\"> {\n /** Time stamp of the event's start. */\n date: number;\n /** Time stamp of the day cell the event was grabbed in. */\n day?: number;\n}\n\nexport default function MonthViewEvent(props: MonthViewEventProps) {\n const {\n ref: forwardedRef,\n eventData,\n weekDays,\n weekRef,\n resizable = false,\n resize,\n isResizeSource = false,\n isAnyResizing = false,\n children,\n ...rootProps\n } = props;\n\n const { disabled } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const { viewportRef } = useCalendarViewportContext();\n\n const rootRef = useRef<HTMLDivElement | null>(null);\n // the day under the pointer when the bar was pressed: a multi-day event moves by the\n // days it is dragged, by whichever of its days it was grabbed\n const grabbedDayRef = useRef<CalendarDate | null>(null);\n\n const { attributes, isDragging, overElement, register, setOverlayTransform } = useDragAndDrop(\n ({ registerDragSource, draggable, droppable, setTransform, isActive }) => {\n const isDragging = isActive(rootRef.current);\n const [overElement] = isDragging ? ([...droppable.dropTargets].pop() ?? [null]) : [null];\n\n return {\n attributes: draggable.attributes,\n isDragging,\n overElement,\n register: registerDragSource,\n setOverlayTransform: setTransform,\n };\n }\n );\n\n const overDayRect = useRect(isDragging ? overElement : null);\n\n const [{ transform, context }, actions] = useMoveTransform({\n autoScrollEnabled: false,\n activeNode: () => rootRef.current,\n containerNode: () => viewportRef.current,\n modifiers: [\n function overlayTransformModifier({ activeNodeRect, containerNodeRect, transform, translate, initialTranslate }) {\n if (!containerNodeRect || !activeNodeRect || !overDayRect) {\n return transform;\n }\n\n transform.x = translate.x + initialTranslate.x - containerNodeRect.left;\n transform.y = translate.y + initialTranslate.y - containerNodeRect.top;\n\n // in the target day, inset like a bar; vertically it follows the pointer, kept\n // inside the day below its number, so it moves into other weeks too\n transform.left = overDayRect.left - containerNodeRect.left + BAR_INSET;\n transform.width = overDayRect.width - 2 * BAR_INSET;\n transform.height = activeNodeRect.height;\n const top = activeNodeRect.top + translate.y;\n const minTop = overDayRect.top + MONTH_WEEK_GEOMETRY.header;\n const maxTop = overDayRect.top + overDayRect.height - activeNodeRect.height;\n transform.top = Math.max(minTop, Math.min(top, maxTop)) - containerNodeRect.top;\n\n return transform;\n },\n ],\n });\n\n // Away from every day the overlay keeps its last place: the transform has no day to fit in.\n const syncTransform = useEventCallback((transform: MoveTransform) => {\n if (context === \"overlay\" && overElement) {\n setOverlayTransform(transform);\n }\n });\n\n useEffect(() => {\n syncTransform(transform);\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [syncTransform, ...Object.values(transform)]);\n\n const getDragItems = useEventCallback(() => {\n const day = grabbedDayRef.current ?? weekDays[eventData.column];\n const item: MonthViewDragItem = {\n ...eventData,\n date: dateUtils.toMillis(eventData.date),\n day: day && dateUtils.toMillis(day),\n };\n return [{ [\"event\"]: JSON.stringify(item) }];\n });\n\n useEffect(() => {\n if (!rootRef.current || disabled) {\n return;\n }\n\n return register(rootRef.current, {\n getItems: getDragItems,\n onDragStart(e) {\n actions.start({ x: e.x, y: e.y }, \"overlay\");\n },\n onDragMove(e) {\n actions.move({ x: e.x, y: e.y });\n },\n onDragEnd(e) {\n actions.stop({ x: e.x, y: e.y });\n },\n getAllowedDropOperations() {\n return [\"move\"];\n },\n });\n }, [actions, disabled, getDragItems, register]);\n\n const handlePointerDown = (e: PointerEvent<HTMLDivElement>) => {\n e.stopPropagation();\n const week = weekRef.current;\n if (!week) return;\n const rect = week.getBoundingClientRect();\n const column = Math.floor(((e.clientX - rect.left) / rect.width) * weekDays.length);\n const clamped = Math.min(Math.max(column, eventData.column), eventData.column + eventData.span - 1);\n grabbedDayRef.current = weekDays[clamped] ?? null;\n };\n\n const resizeListeners = (edge: MonthResizeEdge) => ({\n onMoveStart: () => {\n resize?.start(eventData.key, edge);\n return true;\n },\n onMove: (e: { clientX: number; clientY: number }) => resize?.move(e.clientX, e.clientY),\n onMoveEnd: () => resize?.end(),\n });\n const { listeners: resizeStartListeners } = useMove(resizeListeners(\"start\"));\n const { listeners: resizeEndListeners } = useMove(resizeListeners(\"end\"));\n\n const handleRootRef = useMergedRefs(rootRef, forwardedRef);\n\n const multiDay = eventData.span > 1 || !eventData.isStart || !eventData.isEnd;\n const style = cssVariables(\n { \"--ww-column\": eventData.column + 1, \"--ww-span\": eventData.span, \"--ww-row\": eventData.lane + 2 },\n rootProps.style\n );\n\n return (\n <div\n {...rootProps}\n {...(isAnyResizing ? null : attributes)}\n ref={handleRootRef}\n style={style}\n data-key={String(eventData.key)}\n data-continues-before={eventData.isStart ? undefined : \"\"}\n data-continues-after={eventData.isEnd ? undefined : \"\"}\n onPointerDown={handlePointerDown}\n onDoubleClick={(e) => e.stopPropagation()}\n className={cx(rootProps.className, styles.root__event, {\n [styles.root__event_span]: multiDay,\n [styles.root__event_continuesBefore]: !eventData.isStart,\n [styles.root__event_continuesAfter]: !eventData.isEnd,\n [styles.root__event_isDragging]: isDragging,\n [styles.root__event_isResizeSource]: isResizeSource,\n })}\n >\n {children}\n {resizable && eventData.isStart && (\n <div\n {...resizeStartListeners}\n data-edge=\"start\"\n className={cx(styles.root__resize, styles.root__resizeStart)}\n />\n )}\n {resizable && eventData.isEnd && (\n <div {...resizeEndListeners} data-edge=\"end\" className={cx(styles.root__resize, styles.root__resizeEnd)} />\n )}\n </div>\n );\n}\n","import type { ReactNode } from \"react\";\n\nimport { cx, type CalendarDate, type MonthBar } from \"@weekwise/core\";\n\nimport { cssVariables } from \"./MonthView.utils\";\n\nimport styles from \"./MonthView.module.css\";\n\nexport type MonthViewEventPreviewProps = {\n /** A bar of the event's new range. */\n bar: MonthBar<unknown, CalendarDate>;\n children?: ReactNode;\n};\n\n/** An event while it is resized: one bar per week its new range covers. */\nexport default function MonthViewEventPreview({ bar, children }: MonthViewEventPreviewProps) {\n return (\n <div\n aria-hidden=\"true\"\n data-key={String(bar.key)}\n data-continues-before={bar.isStart ? undefined : \"\"}\n data-continues-after={bar.isEnd ? undefined : \"\"}\n className={cx(styles.root__event, styles.root__event_isResizing, {\n [styles.root__event_span]: bar.span > 1 || !bar.isStart || !bar.isEnd,\n [styles.root__event_continuesBefore]: !bar.isStart,\n [styles.root__event_continuesAfter]: !bar.isEnd,\n })}\n style={cssVariables({ \"--ww-column\": bar.column + 1, \"--ww-span\": bar.span, \"--ww-row\": bar.lane + 2 })}\n >\n {children}\n </div>\n );\n}\n","import { useRef } from \"react\";\n\nimport type { EventKey, MonthBar, MonthWeekLayout, CalendarDate } from \"@weekwise/core\";\n\nimport { useCalendarDateUtils, useMessages } from \"../../date-localization\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\n\nimport { cssVariables } from \"./MonthView.utils\";\nimport MonthViewDay from \"./MonthViewDay\";\nimport MonthViewEvent from \"./MonthViewEvent\";\nimport MonthViewEventPreview from \"./MonthViewEventPreview\";\nimport type { MonthResizeActions } from \"./useMonthResize\";\n\nimport styles from \"./MonthView.module.css\";\n\nexport interface MonthViewWeekProps {\n days: CalendarDate[];\n /** Index of the week's first day in the month grid. */\n firstDayIndex: number;\n /** Ref for the cell of the day at an index in the month grid. */\n cellRef: (index: number) => (node: HTMLDivElement | null) => void;\n /** Bars to draw: with the resized event's new range while it changes. */\n layout: MonthWeekLayout<unknown, CalendarDate>;\n /**\n * The resized event's bars before the change. They stay mounted, hidden, while the\n * preview shows the new range: their edge handles the pointer until it is released.\n */\n sourceBars: MonthBar<unknown, CalendarDate>[];\n /** Lanes of bars that fit into the row; the \"+N more\" labels go below them. */\n lanes: number;\n resizingKey?: EventKey;\n resize: MonthResizeActions;\n}\n\n/** One week row: day cells, the bars of the events over them and \"+N more\" labels. */\nexport default function MonthViewWeek(props: MonthViewWeekProps) {\n const { days, firstDayIndex, cellRef, layout, sourceBars, lanes, resizingKey, resize } = props;\n const weekRef = useRef<HTMLDivElement>(null);\n\n const { viewValue, eventRenderer, view, disabled } = useCalendarContext();\n const { getMonthDay, isSameMonth, isToday, toMillis } = useCalendarDateUtils();\n const messages = useMessages();\n\n const isResizing = resizingKey !== undefined;\n const renderEvent = (bar: MonthBar<unknown, CalendarDate>) =>\n eventRenderer.current?.(bar.value, view, { isStart: bar.isStart, isEnd: bar.isEnd });\n\n const renderBar = (bar: MonthBar<unknown, CalendarDate>, isResizeSource = false) => (\n <MonthViewEvent\n key={bar.key}\n eventData={bar}\n weekDays={days}\n weekRef={weekRef}\n resizable={!disabled}\n resize={resize}\n isResizeSource={isResizeSource}\n isAnyResizing={isResizing}\n >\n {renderEvent(bar)}\n </MonthViewEvent>\n );\n\n return (\n <div ref={weekRef} className={styles.root__week}>\n {days.map((day, column) => (\n <MonthViewDay\n key={toMillis(day)}\n ref={cellRef(firstDayIndex + column)}\n targetDate={day}\n data-day-index={firstDayIndex + column}\n data-is-outside={isSameMonth(day, viewValue) ? undefined : true}\n data-is-today={isToday(day) ? true : undefined}\n style={cssVariables({ \"--ww-column\": column + 1 })}\n >\n <span className={styles.root__dayNumber}>{getMonthDay(day)}</span>\n </MonthViewDay>\n ))}\n {/*\n One list, so that a bar keeps its key among the same siblings when it becomes the\n hidden source of a resize: it stays mounted and its edge keeps the pointer.\n */}\n {[\n ...layout.bars.map((bar) =>\n bar.key === resizingKey ? (\n <MonthViewEventPreview key={`preview-${bar.key}`} bar={bar}>\n {renderEvent(bar)}\n </MonthViewEventPreview>\n ) : (\n renderBar(bar)\n )\n ),\n ...sourceBars.map((bar) => renderBar(bar, true)),\n ]}\n {days.map(\n (day, column) =>\n layout.hidden[column] > 0 && (\n <span\n key={`more-${toMillis(day)}`}\n className={styles.root__more}\n style={cssVariables({ \"--ww-column\": column + 1, \"--ww-row\": lanes + 2 })}\n >\n {messages.more(layout.hidden[column])}\n </span>\n )\n )}\n </div>\n );\n}\n","import { useState, type RefObject } from \"react\";\n\nimport { getMonthLaneCount } from \"@weekwise/core\";\n\nimport { useIsomorphicLayoutEffect, useResizeObserver } from \"../../hooks\";\n\n/**\n * Number of event lanes that fit into the month's week rows, at most `maxLanes`. Rows share\n * the grid's height, so a short calendar shows fewer lanes and more \"+N more\" instead of\n * cutting events off. `maxLanes` until the rows are measured.\n */\nexport default function useMonthLanes(viewportRef: RefObject<HTMLElement | null>, maxLanes: number) {\n const [lanes, setLanes] = useState(maxLanes);\n\n const measure = () => {\n const week = viewportRef.current?.firstElementChild;\n // 0 until the row is laid out (or while it is hidden): keep the lanes it had\n if (week?.clientHeight) setLanes(getMonthLaneCount(week.clientHeight, maxLanes));\n };\n\n const resizeObserver = useResizeObserver(measure);\n\n useIsomorphicLayoutEffect(() => {\n measure();\n const week = viewportRef.current?.firstElementChild;\n if (week) resizeObserver?.observe(week);\n return () => {\n if (week) resizeObserver?.unobserve(week);\n };\n }, [resizeObserver, maxLanes]);\n\n return lanes;\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useMemo } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport {\n getEventTimeFrameFromInfo,\n resizeEventDays,\n type DateAdapter,\n type EventChangeInfo,\n type EventKey,\n type EventMap,\n} from \"@weekwise/core\";\n\nimport { useEventCallback, useGlobalListeners, useItemsLayout, useStateRef } from \"../../hooks\";\n\nexport type MonthResizeEdge = \"start\" | \"end\";\n\ninterface ResizeSession {\n key: EventKey;\n edge: MonthResizeEdge;\n /** The change so far; `null` until the edge reaches another day. */\n result: ReturnType<typeof resizeEventDays<CalendarDate>>;\n}\n\n/** Driven by the `useMove` listeners of a bar's edge. */\nexport interface MonthResizeActions {\n start: (key: EventKey, edge: MonthResizeEdge) => void;\n move: (x: number, y: number) => void;\n /** Applies the change; `false` drops it. */\n end: (commit?: boolean) => void;\n}\n\ninterface UseMonthResizeParams<TValue> {\n /** Days of the month grid. */\n days: CalendarDate[];\n viewportRef: RefObject<HTMLElement | null>;\n /** The day cells, in the order of `days`: the edge goes into the one nearest the pointer. */\n cellsRef: { readonly current: readonly (HTMLElement | null)[] };\n dateUtils: DateAdapter<CalendarDate>;\n eventMap: EventMap<TValue, CalendarDate>;\n disabled: boolean;\n getIsDayDisabled?: (date: CalendarDate) => boolean;\n onEventChange: (key: EventKey, date: CalendarDate, info: EventChangeInfo) => void;\n}\n\n/**\n * Stretches an event into other days by the left or right edge of its month-view bar.\n * `eventMap` is the map to draw while it changes, with the event's new range.\n */\nexport default function useMonthResize<TValue>(params: UseMonthResizeParams<TValue>) {\n const { days, viewportRef, cellsRef, dateUtils, eventMap, disabled, getIsDayDisabled, onEventChange } = params;\n\n const [session, setSession, sessionRef] = useStateRef<ResizeSession | null>(null);\n // Escape drops the change\n const { addGlobalListener, removeAllGlobalListeners } = useGlobalListeners();\n // the grid and its day cells, measured once a resize starts\n const layout = useItemsLayout(viewportRef, cellsRef);\n\n const end = useEventCallback((commit: boolean = true) => {\n const current = sessionRef.current;\n if (!current) return;\n removeAllGlobalListeners();\n layout.release();\n setSession(null);\n if (commit && current.result) {\n onEventChange(current.key, current.result.date, current.result.info);\n }\n });\n\n const handleKeyDown = useEventCallback((e: KeyboardEvent) => {\n if (e.key === \"Escape\") end(false);\n });\n\n const start = useEventCallback((key: EventKey, edge: MonthResizeEdge) => {\n if (disabled || sessionRef.current) return;\n layout.measure();\n setSession({ key, edge, result: null });\n addGlobalListener(document, \"keydown\", handleKeyDown, true);\n });\n\n const move = useEventCallback((x: number, y: number) => {\n const current = sessionRef.current;\n const event = current && eventMap.get(current.key);\n const target = days[layout.nearestIndex(x, y)];\n // an edge does not go into a day that cannot be edited; the last valid range stays\n if (!current || !event || !target || getIsDayDisabled?.(target)) return;\n setSession({ ...current, result: resizeEventDays(dateUtils, event, current.edge, target) });\n });\n\n const actions = useMemo<MonthResizeActions>(() => ({ start, move, end }), [end, move, start]);\n\n const shownEventMap = useMemo(() => {\n const event = session?.result && eventMap.get(session.key);\n if (!session?.result || !event) return eventMap;\n const [date] = getEventTimeFrameFromInfo(dateUtils, session.result.date, session.result.info);\n return new Map(eventMap).set(session.key, { ...event, date, duration: session.result.info.duration });\n }, [dateUtils, eventMap, session]);\n\n return {\n /** Key of the event being resized, if any. */\n resizingKey: session?.key,\n actions,\n eventMap: shownEventMap,\n };\n}\n","import { useMemo, useRef } from \"react\";\nimport type { HTMLAttributes } from \"react\";\n\nimport { arrangeMonthWeek, cx, getMonthGrid, getWeekdayNames, type CalendarDate, type MonthBar } from \"@weekwise/core\";\n\nimport { useCalendarDateUtils } from \"../../date-localization\";\nimport { useRefList, useToday } from \"../../hooks\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport CalendarViewportContext from \"../../contexts/CalendarViewportContext\";\n\nimport DragOverlay from \"../drag-overlay\";\n\nimport { cssVariables, MAX_LANES, splitIntoWeeks } from \"./MonthView.utils\";\nimport MonthViewWeek from \"./MonthViewWeek\";\nimport useMonthLanes from \"./useMonthLanes\";\nimport useMonthResize from \"./useMonthResize\";\n\nimport styles from \"./MonthView.module.css\";\n\nexport type MonthViewProps = HTMLAttributes<HTMLDivElement>;\n\nconst NO_BARS: MonthBar<unknown, CalendarDate>[] = [];\n\n/**\n * Month grid: 6 weeks of day cells. An event is one bar across the days it covers in a\n * week; the bar's edges stretch it into other days.\n */\nexport default function MonthView(props: MonthViewProps) {\n const { className, style, ...rootProps } = props;\n\n const { viewValue, eventMap, startWeek, disabled, getIsDayDisabled, onEventChange } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n // re-render at midnight so the highlighted day follows the date\n useToday();\n\n const viewportRef = useRef<HTMLDivElement>(null);\n // the day cells by index in the grid: resizing an event picks its day among them\n const cells = useRefList<HTMLDivElement>();\n\n const days = useMemo(() => getMonthGrid(dateUtils, viewValue, startWeek), [dateUtils, startWeek, viewValue]);\n const weeks = useMemo(() => splitIntoWeeks(days), [days]);\n const weekdayNames = useMemo(() => getWeekdayNames(dateUtils, startWeek), [dateUtils, startWeek]);\n\n const resize = useMonthResize({\n days,\n viewportRef,\n cellsRef: cells.elements,\n dateUtils,\n eventMap,\n disabled,\n getIsDayDisabled,\n onEventChange,\n });\n\n const lanes = useMonthLanes(viewportRef, MAX_LANES);\n\n const layouts = useMemo(\n () => weeks.map((week) => arrangeMonthWeek(eventMap, dateUtils, week, lanes)),\n [dateUtils, eventMap, lanes, weeks]\n );\n // while an event is resized, the grid shows its new range\n const shownLayouts = useMemo(\n () =>\n resize.eventMap === eventMap\n ? layouts\n : weeks.map((week) => arrangeMonthWeek(resize.eventMap, dateUtils, week, lanes)),\n [dateUtils, eventMap, lanes, layouts, resize.eventMap, weeks]\n );\n\n const contextValue = useMemo(() => ({ viewportRef }), []);\n\n return (\n <CalendarViewportContext.Provider value={contextValue}>\n <div\n {...rootProps}\n className={cx(className, styles.root, {\n [styles.root_isResizing]: resize.resizingKey !== undefined,\n })}\n style={cssVariables({ \"--ww-month-lanes\": lanes }, style)}\n >\n <div className={styles.root__head}>\n {weekdayNames.map((weekdayName) => (\n <div key={weekdayName} className={styles.root__weekday}>\n {weekdayName}\n </div>\n ))}\n </div>\n <div className={styles.root__body}>\n <div ref={viewportRef} className={styles.root__viewport}>\n {weeks.map((week, weekIndex) => (\n <MonthViewWeek\n key={dateUtils.toMillis(week[0])}\n days={week}\n firstDayIndex={weekIndex * 7}\n cellRef={cells.refAt}\n layout={shownLayouts[weekIndex]}\n sourceBars={\n resize.resizingKey === undefined\n ? NO_BARS\n : layouts[weekIndex].bars.filter((bar) => bar.key === resize.resizingKey)\n }\n lanes={lanes}\n resizingKey={resize.resizingKey}\n resize={resize.actions}\n />\n ))}\n </div>\n </div>\n </div>\n <DragOverlay className={styles.root__dragOverlay} showPreview={false} />\n </CalendarViewportContext.Provider>\n );\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport {\n fromDayMinutes,\n getTimeFrame,\n isPastDay,\n resizeEventRange,\n toDayMinutes,\n type DateAdapter,\n type EventChangeInfo,\n type EventKey,\n type EventMap,\n type TimeBounds,\n} from \"@weekwise/core\";\n\nimport useDocumentCursor from \"./useDocumentCursor\";\nimport useEventCallback from \"./useEventCallback\";\nimport useGlobalListeners from \"./useGlobalListeners\";\nimport useItemsLayout from \"./useItemsLayout\";\n\nconst DAY = 24 * 60;\n\nexport type ResizeEdge = \"top\" | \"bottom\";\n\n/** An event being resized: its range in wall-clock minutes from the first visible day. */\nexport interface ResizeState {\n key: EventKey;\n range: [number, number];\n /** Pointer position, for the time preview. */\n x: number;\n y: number;\n /** The pointer is where the edge cannot go; the last valid range stays. */\n blocked: boolean;\n}\n\ninterface ResizeSession {\n key: EventKey;\n edge: ResizeEdge;\n original: [number, number];\n range: [number, number];\n x: number;\n y: number;\n}\n\nexport interface EventResizeActions {\n start: (key: EventKey, edge: ResizeEdge, x: number, y: number) => void;\n move: (x: number, y: number) => void;\n end: () => void;\n}\n\ninterface UseEventResizeParams {\n days: CalendarDate[];\n viewportRef: RefObject<HTMLElement | null>;\n /** The day columns by day index, where the pointer picks the day. */\n columnsRef: { readonly current: readonly (HTMLElement | null)[] };\n dateUtils: DateAdapter<CalendarDate>;\n bounds: TimeBounds;\n timeStep: number;\n preventOutBoundsChanges: boolean;\n disabled: boolean;\n getIsDayDisabled?: (date: CalendarDate) => boolean;\n eventMap: EventMap<unknown, CalendarDate>;\n onEventChange: (key: EventKey, date: CalendarDate, info: EventChangeInfo) => void;\n}\n\n/**\n * Resizes an event by its top or bottom edge, into other days too (like macOS Calendar):\n * dragging the bottom edge into a later day ends the event there, the first day filling\n * to midnight. The view draws the event from {@link ResizeState} while it changes.\n */\nexport default function useEventResize(params: UseEventResizeParams) {\n const { days, viewportRef, columnsRef, dateUtils, bounds, timeStep, preventOutBoundsChanges } = params;\n const [state, setState] = useState<ResizeState | null>(null);\n const session = useRef<ResizeSession | null>(null);\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n // the timeline and its day columns, measured once a resize starts\n const layout = useItemsLayout(viewportRef, columnsRef);\n\n const paramsRef = useRef(params);\n paramsRef.current = params;\n\n const offset = bounds.hideMinMaxTime ? bounds.hourMin * 60 : 0;\n const timelineMinutes = bounds.hideMinMaxTime ? (bounds.hourMax - bounds.hourMin) * 60 : DAY;\n\n const update = useCallback(\n (x: number, y: number) => {\n const current = session.current;\n const viewport = layout.container();\n if (!current || !viewport) return;\n current.x = x;\n current.y = y;\n\n const { disabled, getIsDayDisabled } = paramsRef.current;\n const snap = (minute: number) => Math.round(minute / timeStep) * timeStep;\n const minute = snap(\n Math.min(Math.max(((y - viewport.top) / viewport.height) * timelineMinutes, 0), timelineMinutes)\n );\n\n // The column under the pointer, or the nearest one.\n const dayIndex = Math.max(layout.nearestIndex(x, y, \"x\"), 0);\n\n const next = resizeEventRange(\n { start: current.original[0], end: current.original[1] },\n current.edge,\n dayIndex,\n minute,\n {\n dayCount: days.length,\n bounds,\n timeStep,\n // An event across midnight passes hours a time frame leaves out.\n crossDays: !preventOutBoundsChanges || (bounds.hourMin <= 0 && bounds.hourMax >= 24),\n getFrame: (idx) => {\n if (!preventOutBoundsChanges) return [0, timelineMinutes];\n const [top, bottom] = getTimeFrame(dateUtils, days[idx], bounds);\n return [\n Math.ceil(top / timeStep) * timeStep,\n Math.min(Math.ceil(bottom / timeStep) * timeStep, timelineMinutes),\n ];\n },\n canEditDay: (idx) =>\n !disabled &&\n !getIsDayDisabled?.(days[idx]) &&\n !(preventOutBoundsChanges && isPastDay(dateUtils, days[idx])),\n }\n );\n if (next) current.range = next;\n setState({ key: current.key, range: current.range, x, y, blocked: !next });\n },\n [bounds, dateUtils, days, layout, preventOutBoundsChanges, timeStep, timelineMinutes]\n );\n\n // Auto-scroll moves the timeline under a still pointer: the layout follows, the time under the\n // pointer changes. Stable, so `end` removes the listener `start` added.\n const handleScroll = useEventCallback(() => {\n const current = session.current;\n if (current) update(current.x, current.y);\n });\n\n const actions = useMemo<EventResizeActions>(\n () => ({\n start(key, edge, x, y) {\n const event = paramsRef.current.eventMap.get(key);\n if (!event || !days[0] || !layout.measure()) return;\n const start = toDayMinutes(dateUtils, days[0], event.date);\n const original: [number, number] = [start, start + event.duration];\n session.current = { key, edge, original, range: original, x, y };\n addGlobalListener(document, \"scroll\", handleScroll, true);\n setState({ key, range: original, x, y, blocked: false });\n },\n move: update,\n end() {\n const current = session.current;\n session.current = null;\n removeGlobalListener(document, \"scroll\", handleScroll, true);\n layout.release();\n setState(null);\n if (!current) return;\n const [start, end] = current.range;\n if (start === current.original[0] && end === current.original[1]) return;\n const dayIndex = Math.floor(start / DAY);\n paramsRef.current.onEventChange(current.key, fromDayMinutes(dateUtils, days[0], dayIndex * DAY), {\n from: start - dayIndex * DAY,\n duration: end - start,\n });\n },\n }),\n [addGlobalListener, dateUtils, days, handleScroll, layout, removeGlobalListener, update]\n );\n\n // Over a place the edge cannot go: \"not allowed\" cursor on the whole page.\n useDocumentCursor(state?.blocked ? \"not-allowed\" : null);\n\n /** Start of the range: its day and the timeline position in it, for the time preview. */\n const previewOf = (range: [number, number]) => {\n const dayIndex = Math.floor(range[0] / DAY);\n return {\n date: fromDayMinutes(dateUtils, days[0], dayIndex * DAY),\n top: range[0] - dayIndex * DAY - offset,\n duration: range[1] - range[0],\n };\n };\n\n return { state, actions, previewOf };\n}\n","import { createContext, useContext } from \"react\";\n\nimport type { DayWeekViewContextValue } from \"../Calendar.types\";\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/**\n * DropTarget context.\n */\nconst DayWeekViewContext = createContext<DayWeekViewContextValue | undefined>(undefined);\n\nif (isDevEnvironment) {\n DayWeekViewContext.displayName = \"DayWeekViewContext\";\n}\n\nexport default DayWeekViewContext;\n\nexport function useDayWeekViewContext() {\n const context = useContext(DayWeekViewContext);\n\n if (!context) {\n throw new Error(\"DayWeekViewContext is required\");\n }\n\n return context;\n}\n","import { createContext, useContext } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/** The day column an event of the day/week view is drawn in. */\nexport type DayWeekDrawerContextValue = {\n /** The whole column: what an event resized in it is bounded by. */\n drawerRef: RefObject<HTMLDivElement | null>;\n /** The events' container, which their positions are relative to. */\n containerRef: RefObject<HTMLDivElement | null>;\n};\n\nconst DayWeekDrawerContext = createContext<DayWeekDrawerContextValue | undefined>(undefined);\n\nif (isDevEnvironment) {\n DayWeekDrawerContext.displayName = \"DayWeekDrawerContext\";\n}\n\nexport default DayWeekDrawerContext;\n\nexport function useDayWeekDrawerContext() {\n const context = useContext(DayWeekDrawerContext);\n\n if (!context) {\n throw new Error(\"DayWeekDrawerContext is required: render the event inside a DayWeekDrawer\");\n }\n\n return context;\n}\n","import { useMemo, useState } from \"react\";\n\nimport { getNowOffset } from \"@weekwise/core\";\n\nimport { useCalendarDateUtils } from \"../date-localization\";\nimport { useTimeInterval } from \"../hooks\";\n\nimport { useCalendarContext } from \"../contexts/CalendarContext\";\n\n/** Minutes from the timeline's start to now, and whether now is outside it. */\nexport default function useTimeOffset(isActive = true, interval = 1000 * 60): [number, boolean] {\n const { hideMinMaxTime, hourMin, hourMax } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n\n // Starts unset and ticks after mount: the server (or a static prerender) ran at a\n // different time, so computing it during the first render would make the hydrating\n // render differ from the server HTML.\n const [tick, setTick] = useState<number | null>(null);\n\n useTimeInterval(() => setTick(Date.now()), interval, isActive);\n\n // every minute, and at once for another adapter (time zone) or other hours\n return useMemo<[number, boolean]>(\n () => (tick === null ? [0, true] : getNowOffset(dateUtils, { hourMin, hourMax, hideMinMaxTime })),\n [tick, dateUtils, hourMin, hourMax, hideMinMaxTime]\n );\n}\n","import { useEffect, useMemo, useRef } from \"react\";\nimport type { DetailedHTMLProps, HTMLAttributes } from \"react\";\n\nimport { useCalendarDateUtils } from \"../../date-localization\";\nimport { useMergedRefs, useMove, useToday } from \"../../hooks\";\nimport type { TextDropItem } from \"@weekwise/dnd\";\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\n\nimport type { CalendarDate } from \"@weekwise/core\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport DayWeekDrawerContext from \"../../contexts/DayWeekDrawerContext\";\nimport { useDayWeekViewContext } from \"../../contexts/DayWeekViewContext\";\nimport useMoveTransform from \"../../hooks/useMoveTransform\";\nimport useTimeOffset from \"../../hooks/useTimeOffset\";\nimport Portal from \"../../portal\";\nimport {\n boundingResizableContainerModifier,\n cx,\n formatNowOffset,\n getTimeStepEqualizerModifier,\n toDayMinutes,\n TOUCH_HOLD_DELAY,\n} from \"@weekwise/core\";\n\nimport PointerPopover from \"../pointer-popover\";\nimport type { DayWeekDragItem, DayWeekViewDropTargetData } from \"../day-week-view\";\nimport type { CSSVarStyle } from \"../../utils/css\";\n\nimport styles from \"./DayWeekDrawer.module.css\";\n\nexport type DayWeekDrawerProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {\n /**\n * Associated to the drawer date\n */\n targetDate: CalendarDate;\n};\n\nexport default function DayWeekDrawer(props: DayWeekDrawerProps) {\n const { ref: forwardedRef, targetDate, children, ...rootProps } = props;\n\n const { onEventChange, onEventCreate, getIsDayDisabled, pointerPreviewRenderer, eventMap, ...options } =\n useCalendarContext();\n const { viewportRef, getTimeFrame, pxPerMinute } = useDayWeekViewContext();\n const { hideMinMaxTime, preventOutBoundsChanges, timeStep, hourMin, hourMax, disabled } = options;\n const dateUtils = useCalendarDateUtils();\n const { isBefore, isToday } = dateUtils;\n // Transforms are in pixels and an hour row is shorter than 60px in a compact calendar:\n // snap to a time step on screen, read pixels as minutes only for times.\n const stepPx = timeStep * pxPerMinute;\n const toMinutes = (px: number) => toTimelineMinutes(px, pxPerMinute, timeStep);\n const getTimeFramePx = (date: CalendarDate) => getTimeFrame(date).map((x) => x * pxPerMinute) as [number, number];\n\n const rootRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n const { register, getTransform } = useDragAndDrop(({ registerDropTarget, getTransform }) => ({\n register: registerDropTarget,\n getTransform: getTransform,\n }));\n\n const today = useToday();\n const todayOrPast = useMemo(() => {\n const isTodayFlag = isToday(targetDate);\n\n return {\n isToday: isTodayFlag,\n isPast: isBefore(targetDate) && !isTodayFlag,\n };\n // `today` re-evaluates the flags when the date rolls over at midnight\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [isBefore, isToday, targetDate, today]);\n\n const [{ isActive, transform }, actions, { scrollAdjustmentActiveNodeRect: resizingActiveNodeRect }] =\n useMoveTransform({\n activeNode: rootRef.current,\n // the drawer fills its day column\n containerNode: rootRef.current,\n modifiers: [\n // here activeNodeRect is used as containerRect\n function resizeSpotlightModifier({ activeNodeRect, initialTranslate, translate, transform }) {\n if (!activeNodeRect) {\n return transform;\n }\n\n const offsetY = initialTranslate.y - activeNodeRect.top;\n transform.x = transform.left + initialTranslate.x;\n transform.y = transform.top + initialTranslate.y;\n transform.top = Math.floor(offsetY / stepPx) * stepPx;\n transform.height = stepPx;\n transform.left = 0;\n transform.width = activeNodeRect.width;\n\n let compensation: number;\n if (translate.y > 0) {\n compensation = stepPx - (offsetY % stepPx);\n transform.height = Math.ceil((transform.height + translate.y - compensation) / stepPx) * stepPx;\n } else {\n compensation = offsetY % stepPx;\n transform.height = Math.ceil((transform.height - translate.y - compensation) / stepPx) * stepPx;\n transform.top -= transform.height - stepPx;\n }\n\n transform.height = Math.max(transform.height, stepPx);\n\n return transform;\n },\n function resizeContainerModifier({ transform }) {\n if (!preventOutBoundsChanges) {\n return transform;\n }\n\n const [bottomEdge, topEdge] = getTimeFrame(targetDate).map((x) => Math.ceil(x / timeStep) * stepPx);\n\n // restrict top\n if (transform.top < bottomEdge) {\n transform.height = Math.max(transform.height - (bottomEdge - transform.top), stepPx);\n transform.top = bottomEdge;\n }\n\n // restrict bottom\n if (transform.height + transform.top >= topEdge) {\n transform.height = Math.max(topEdge - transform.top, stepPx);\n }\n\n return transform;\n },\n boundingResizableContainerModifier,\n getTimeStepEqualizerModifier(stepPx),\n ],\n });\n\n const [timeOffset, offLimits] = useTimeOffset(todayOrPast.isToday);\n\n useEffect(() => {\n const dropTargetElement = rootRef.current;\n\n if (!dropTargetElement) {\n return;\n }\n\n const dropTargetData: DayWeekViewDropTargetData = { date: targetDate };\n return register(dropTargetElement, {\n data: dropTargetData,\n onDrop: async (e) => {\n const [eventData] = await Promise.all(\n e.items\n .filter(\n (item): item is TextDropItem => item.kind === \"text\" && item.types.has(\"event\") && \"getText\" in item\n )\n .map(async (item) => {\n const data = await item.getText(\"event\");\n return JSON.parse(data) as DayWeekDragItem;\n })\n );\n\n const transform = getTransform();\n const top = toTimelineMinutes(transform.top, pxPerMinute, timeStep);\n const height = toTimelineMinutes(transform.height, pxPerMinute, timeStep);\n const offset = hideMinMaxTime ? hourMin * 60 : 0;\n const event = eventMap.get(eventData.key);\n\n // An event across midnight was dragged by one of its days: it keeps its length,\n // and its start lands where the grabbed part's start was dropped.\n const startOfEvent = event ? toDayMinutes(dateUtils, event.date, event.date) : 0;\n if (event && startOfEvent + event.duration > 24 * 60) {\n // It passes hours a time frame leaves out: only a frame of the whole day allows it.\n if (preventOutBoundsChanges && (hourMin > 0 || hourMax < 24)) {\n actions.stop({ x: e.x, y: e.y });\n return;\n }\n const partDay = dateUtils.getStartOfDay(dateUtils.fromMillis(eventData.date));\n const grabbedStart = toDayMinutes(dateUtils, event.date, partDay) + offset + eventData.start;\n const fromStart = grabbedStart - startOfEvent;\n const start = offset + top - fromStart;\n const dayShift = Math.floor(start / (24 * 60));\n onEventChange(eventData.key, dateUtils.addDays(targetDate, dayShift), {\n from: start - dayShift * 24 * 60,\n duration: event.duration,\n });\n } else if (hideMinMaxTime) {\n onEventChange(eventData.key, targetDate, {\n from: top + hourMin * 60,\n duration: height,\n });\n } else {\n onEventChange(eventData.key, targetDate, {\n from: top,\n duration: height,\n });\n }\n\n actions.stop({ x: e.x, y: e.y });\n },\n getDropOperationForPoint: (types, allowedOperations) => {\n if (disabled || !types.has(\"event\")) return \"cancel\";\n\n if (getIsDayDisabled && getIsDayDisabled(targetDate)) {\n return \"cancel\";\n }\n\n const { isPast, isToday } = todayOrPast;\n\n if (preventOutBoundsChanges) {\n if (!isToday && isPast) {\n return \"cancel\";\n }\n\n const [top, bottom] = getTimeFrame(targetDate).map((x) => x * pxPerMinute);\n\n const transform = getTransform();\n if (transform.y < top || transform.y > bottom || (isToday && transform.height > bottom - top)) {\n return \"cancel\";\n }\n }\n\n return allowedOperations[0];\n },\n });\n }, [\n actions,\n dateUtils,\n disabled,\n eventMap,\n getIsDayDisabled,\n getTimeFrame,\n getTransform,\n hideMinMaxTime,\n hourMax,\n hourMin,\n onEventChange,\n preventOutBoundsChanges,\n pxPerMinute,\n register,\n targetDate,\n timeStep,\n todayOrPast,\n ]);\n\n const { listeners: moveListeners, ref: moveRef } = useMove({\n distance: Math.max(Math.min(5, timeStep), 1),\n // a finger scrolls the calendar: a long press creates an event, as in mobile calendars\n touchDelay: TOUCH_HOLD_DELAY,\n onMoveStart: (e) => {\n if (disabled) {\n return;\n }\n\n if (preventOutBoundsChanges) {\n const { isToday, isPast } = todayOrPast;\n\n if (isPast && !isToday) {\n return false;\n }\n }\n\n actions.start({ x: e.clientX, y: e.clientY });\n\n // a long press has started: show the slot under the finger before it moves\n if (e.pointerType === \"touch\") {\n actions.move({ x: e.clientX, y: e.clientY });\n }\n },\n onMove: (e) => {\n if (isActive) {\n actions.move({ x: e.clientX, y: e.clientY });\n return;\n }\n\n if (!resizingActiveNodeRect) {\n return;\n }\n\n if (preventOutBoundsChanges) {\n const [bottomEdge, topEdge] = getTimeFramePx(targetDate);\n const currentTop = e.clientY - resizingActiveNodeRect.top;\n\n if (currentTop < bottomEdge || currentTop > topEdge) {\n actions.stop({ x: e.clientX, y: e.clientY });\n return;\n }\n }\n\n if (!isActive) {\n actions.move({ x: e.clientX, y: e.clientY });\n }\n },\n onMoveEnd: (e) => {\n actions.stop({ x: e.clientX, y: e.clientY });\n\n if (!isActive) {\n return;\n }\n\n if (hideMinMaxTime) {\n onEventCreate(targetDate, {\n from: toMinutes(transform.top) + hourMin * 60,\n duration: toMinutes(transform.height),\n });\n } else {\n onEventCreate(targetDate, {\n from: toMinutes(transform.top),\n duration: toMinutes(transform.height),\n });\n }\n },\n });\n\n const drawerContextValue = useMemo(() => ({ drawerRef: rootRef, containerRef }), []);\n\n const handleRootRef = useMergedRefs<HTMLDivElement>(rootRef, moveRef, forwardedRef);\n\n const timeOffsetTitle = formatNowOffset(dateUtils, timeOffset, { hourMin, hideMinMaxTime });\n\n const renderPreview = () => {\n return pointerPreviewRenderer.current?.(targetDate, toMinutes(transform.top), toMinutes(transform.height));\n };\n\n return (\n <div\n {...rootProps}\n {...moveListeners}\n ref={handleRootRef}\n className={cx(rootProps.className, styles.root, {\n [styles.root_timeLimit]: preventOutBoundsChanges,\n [styles.root_isToday]: todayOrPast.isToday,\n [styles.root_isPast]: todayOrPast.isPast,\n [styles.root_offLimits]: offLimits,\n })}\n style={\n {\n ...rootProps.style,\n // minutes on the timeline, in pixels: an hour row is shorter in a compact calendar\n [\"--offset\"]: timeOffset * pxPerMinute,\n } as CSSVarStyle\n }\n >\n {todayOrPast.isToday && !offLimits && (\n <Portal container={viewportRef.current}>\n <span\n tabIndex={-1}\n className={styles.root__timeLine}\n data-now={timeOffsetTitle}\n style={{ [\"--offset\"]: timeOffset * pxPerMinute } as CSSVarStyle}\n />\n </Portal>\n )}\n <div ref={containerRef} className={styles.root__container}>\n <DayWeekDrawerContext.Provider value={drawerContextValue}>{children}</DayWeekDrawerContext.Provider>\n </div>\n {isActive && (\n <>\n <div className={styles.root__spotlight} style={transform ? { ...transform } : undefined} />\n <PointerPopover coordinates={{ x: transform.x, y: transform.y }}>{renderPreview()}</PointerPopover>\n </>\n )}\n </div>\n );\n}\n\n/** Pixels of the timeline as minutes, on the time step. */\nfunction toTimelineMinutes(px: number, pxPerMinute: number, timeStep: number): number {\n return Math.round(px / pxPerMinute / timeStep) * timeStep;\n}\n","import { useState, type RefObject } from \"react\";\n\nimport type { MeasuredEventData } from \"../components/day-week-view\";\nimport { useIsomorphicLayoutEffect } from \"../hooks\";\nimport { getClientRect, round, subtract } from \"@weekwise/core\";\n\nexport default function useAbsEventRect(\n rootRef: RefObject<HTMLDivElement | null>,\n /** The element the event is positioned in. */\n containerRef: RefObject<HTMLElement | null>,\n relativeRect: MeasuredEventData[\"rect\"]\n) {\n const [absEventRect, setAbsEventRect] = useState<MeasuredEventData[\"rect\"] | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n const rootEl = rootRef.current,\n parentEl = containerRef.current;\n\n if (rootEl && parentEl) {\n const { height, width, ...positions } = getClientRect(rootEl);\n const { left: x, top: y } = subtract(positions, getClientRect(parentEl));\n\n setAbsEventRect(\n // sometimes the values can be floating, so we need to round them\n round(relativeRect, { height, width, x, y })\n );\n }\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [rootRef, containerRef, ...Object.values(relativeRect)]);\n\n return absEventRect;\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useState } from \"react\";\n\nimport { useCalendarDateUtils } from \"../date-localization\";\nimport { useIsomorphicLayoutEffect } from \"../hooks\";\n\nimport { useCalendarContext } from \"../contexts/CalendarContext\";\nimport { useDayWeekViewContext } from \"../contexts/DayWeekViewContext\";\nimport type { MeasuredEventData } from \"../components/day-week-view\";\n\nexport default function useCanResizeEvent(eventDate: CalendarDate, absRect: MeasuredEventData[\"rect\"] | null) {\n const [canResize, setCanResize] = useState(true);\n const { preventOutBoundsChanges } = useCalendarContext();\n const { isBefore, isToday } = useCalendarDateUtils();\n const { getTimeFrame } = useDayWeekViewContext();\n\n useIsomorphicLayoutEffect(() => {\n // if preventOutBoundsChanges false then we can resize every event\n if (!absRect || !preventOutBoundsChanges) {\n return;\n }\n\n // if event is before today and not today then we can't resize\n if (isBefore(eventDate) && !isToday(eventDate)) {\n // oxlint-disable-next-line react-hooks/set-state-in-effect\n setCanResize(false);\n } else if (isToday(eventDate)) {\n // if is today then check if event is in time frame,\n // between current time and and of the day\n const { height, y } = absRect;\n const bottomRect = height + y;\n const [bottomEdge, topEdge] = getTimeFrame(eventDate);\n setCanResize(bottomRect > bottomEdge && y < topEdge);\n }\n }, [eventDate, absRect, getTimeFrame, preventOutBoundsChanges, isBefore, isToday]);\n\n return canResize;\n}\n","import { useEffect, useRef } from \"react\";\nimport type { DetailedHTMLProps, HTMLAttributes } from \"react\";\n\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\nimport { useEventCallback, useMergedRefs, useMove } from \"../../hooks\";\nimport type { MoveEndEvent } from \"../../hooks/useMove.types\";\nimport { cx, mergeCallbacks, omit } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useDayWeekDrawerContext } from \"../../contexts/DayWeekDrawerContext\";\nimport { useDayWeekViewContext } from \"../../contexts/DayWeekViewContext\";\nimport useAbsEventRect from \"../../hooks/useAbsEventRect\";\nimport useCanResizeEvent from \"../../hooks/useCanResizeEvent\";\nimport useMoveTransform, { type MoveTransform, type MoveTransformModifier } from \"../../hooks/useMoveTransform\";\nimport useRect from \"../../hooks/useRect\";\nimport {\n applyMoveTransformModifiers,\n boundingDraggableContainerModifier,\n getTimeStepEqualizerModifier,\n} from \"@weekwise/core\";\n\nimport type { DayWeekDragItem, MeasuredEventData } from \"../day-week-view\";\nimport { useCalendarDateUtils } from \"../../date-localization\";\n\nimport styles from \"./DayWeekEvent.module.css\";\n\nexport type DayWeekEventProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {\n eventData: MeasuredEventData;\n};\n\nexport type DayWeekEventTransformContext = \"bottom\" | \"top\" | \"overlay\";\n\nexport default function DayWeekEvent(props: DayWeekEventProps) {\n const { ref: forwardedRef, eventData, children, ...rootProps } = props;\n\n const { eventMap, ...options } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const { timeStep, preventOutBoundsChanges, disabled } = options;\n const rootRef = useRef<HTMLDivElement | null>(null);\n const topBarRef = useRef<HTMLDivElement | null>(null);\n const bottomBarRef = useRef<HTMLDivElement | null>(null);\n const { viewportRef, getTimeFrame, pxPerMinute, resize, resizing } = useDayWeekViewContext();\n // a time step on screen: the rows are shorter than 60px an hour in a compact calendar\n const stepPx = timeStep * pxPerMinute;\n const { drawerRef, containerRef } = useDayWeekDrawerContext();\n const absEventRect = useAbsEventRect(rootRef, containerRef, eventData.rect);\n // The whole event's start: a part shown today may belong to an event from yesterday.\n const canResize = useCanResizeEvent(eventMap.get(eventData.key)?.date ?? eventData.date, absEventRect);\n\n const { attributes, isDragging, overElement, overData, register, setOverlayTransform } = useDragAndDrop(\n ({ registerDragSource, draggable, droppable, setTransform, isActive }) => {\n const isDragging = isActive(rootRef.current);\n const [overElement, overData] = isDragging ? ([...droppable.dropTargets].pop() ?? [null, null]) : [null, null];\n\n return {\n attributes: draggable.attributes,\n overElement,\n overData,\n isDragging,\n register: registerDragSource,\n setOverlayTransform: setTransform,\n };\n }\n );\n\n const activeDrawerRect = useRect(isDragging ? overElement : null);\n\n const activeNodeResolver = (ctx: DayWeekEventTransformContext | null) => {\n return ctx === \"overlay\" ? rootRef.current : ctx === \"top\" ? topBarRef.current : bottomBarRef.current;\n };\n\n const containerNodeResolver = (ctx: DayWeekEventTransformContext | null) => {\n // the drawer, not the events' container in it: that one leaves a gap on the right\n return ctx === \"overlay\" ? viewportRef.current : drawerRef.current;\n };\n\n const [{ isActive, transform, context }, actions] = useMoveTransform<DayWeekEventTransformContext>({\n activeNode: activeNodeResolver,\n containerNode: containerNodeResolver,\n modifiers: [\n function overlayTransformModifier({\n activeNodeRect,\n containerNodeRect,\n context,\n transform,\n translate,\n initialTranslate,\n }) {\n // if context is not overlay do nothing\n if (context !== \"overlay\") {\n return transform;\n }\n\n if (!containerNodeRect || !activeNodeRect || !activeDrawerRect) {\n return transform;\n }\n\n transform.x = translate.x + initialTranslate.x - containerNodeRect.left;\n transform.y = translate.y + initialTranslate.y - containerNodeRect.top;\n\n transform.left = activeDrawerRect.left - containerNodeRect.left;\n transform.width = activeDrawerRect.width;\n transform.top = activeNodeRect.top - containerNodeRect.top;\n transform.height = activeNodeRect.height;\n\n let compensation: number;\n if (translate.y > 0) {\n compensation = stepPx - ((initialTranslate.y - activeNodeRect.top) % stepPx);\n transform.top += Math.ceil((translate.y - compensation) / stepPx) * stepPx;\n } else {\n compensation = (initialTranslate.y - activeNodeRect.top) % stepPx;\n transform.top += Math.floor((translate.y + compensation) / stepPx) * stepPx;\n }\n\n return transform;\n },\n function boundingDragTimeFrameModifier({ transform, context }) {\n if (!preventOutBoundsChanges) {\n return transform;\n }\n\n if (context !== \"overlay\" || !overData) {\n return transform;\n }\n\n const [top, bottom] = getTimeFrame(overData.date).map((x) => Math.ceil(x / timeStep) * stepPx);\n // top edge\n if (transform.top < top) {\n transform.top = top;\n }\n\n // bottom edge\n if (transform.top + transform.height > bottom) {\n transform.top = bottom - transform.height;\n }\n\n return transform;\n },\n getEventTransformModifiers(stepPx),\n ],\n });\n\n // Resizing is computed by the view (it may reach into other days); the move transform\n // only keeps auto-scroll running while the pointer is near an edge.\n const moveEndHandler = mergeCallbacks<[MoveEndEvent]>(\n () => resize.end(),\n (e) => {\n actions.stop({ x: e.clientX, y: e.clientY });\n }\n );\n\n const resizeListeners = (edge: \"top\" | \"bottom\") => ({\n onMoveStart: (e: { clientX: number; clientY: number }) => {\n actions.start({ x: e.clientX, y: e.clientY }, edge);\n resize.start(eventData.key, edge, e.clientX, e.clientY);\n return true;\n },\n onMove: (e: { clientX: number; clientY: number }) => {\n actions.move({ x: e.clientX, y: e.clientY });\n resize.move(e.clientX, e.clientY);\n },\n onMoveEnd: moveEndHandler,\n });\n\n const { listeners: resizeBottomListeners } = useMove(resizeListeners(\"bottom\"));\n const { listeners: resizeTopListeners } = useMove(resizeListeners(\"top\"));\n\n const handleRootRef = useMergedRefs(rootRef, forwardedRef);\n const isDragginOverlay = isActive && isDragging && context === \"overlay\";\n // While resized, the view draws the event's new range; its own parts step aside.\n const isResizeSource = resizing?.key === eventData.key;\n\n // Away from every day the overlay keeps its last place: the transform has no day to fit in.\n const syncTransform = useEventCallback((transform: MoveTransform) => {\n if (context === \"overlay\" && overElement) {\n setOverlayTransform(transform);\n }\n });\n\n useEffect(() => {\n syncTransform(transform);\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [syncTransform, ...Object.values(transform)]);\n\n useEffect(() => {\n if (!rootRef.current) {\n return;\n }\n\n const item: DayWeekDragItem = { ...omit(eventData, \"rect\"), date: dateUtils.toMillis(eventData.date) };\n const items = [{ [\"event\"]: JSON.stringify(item) }];\n\n return register(rootRef.current, {\n getItems() {\n return items;\n },\n onDragStart(e) {\n actions.start({ x: e.x, y: e.y }, \"overlay\");\n },\n onDragMove(e) {\n actions.move({ x: e.x, y: e.y });\n },\n onDragEnd(e) {\n actions.stop({ x: e.x, y: e.y });\n },\n getAllowedDropOperations() {\n return [\"move\"];\n },\n });\n }, [actions, eventData, register]);\n\n const rootClassName = cx(rootProps.className, styles.root, {\n [styles.root_isDragging]: isDragginOverlay,\n [styles.root_isResizeSource]: isResizeSource,\n [styles.root_isDisabled]: disabled,\n });\n\n const rootStyle = {\n ...rootProps.style,\n top: `${eventData.rect.y}%`,\n left: `${eventData.rect.x}%`,\n width: `${eventData.rect.width}%`,\n height: `${eventData.rect.height}%`,\n };\n\n const handlePointerDown = useEventCallback(mergeCallbacks(rootProps.onPointerDown, (e) => e.stopPropagation()));\n\n return (\n <>\n <div\n {...rootProps}\n {...attributes}\n ref={handleRootRef}\n className={rootClassName}\n style={rootStyle}\n onPointerDown={handlePointerDown}\n data-continues-before={eventData.isStart ? undefined : \"\"}\n data-continues-after={eventData.isEnd ? undefined : \"\"}\n >\n {/* Edges only where the event starts and ends, not at midnight between its days. */}\n {canResize && eventData.isStart && (\n <div {...resizeTopListeners} ref={topBarRef} className={styles.root__resizeTop} />\n )}\n <div role=\"button\" tabIndex={0} className={styles.root__container}>\n {children}\n </div>\n {canResize && eventData.isEnd && (\n <div {...resizeBottomListeners} ref={bottomBarRef} className={styles.root__resizeBottom} />\n )}\n </div>\n </>\n );\n}\n\nfunction getEventTransformModifiers(timeStep: number): MoveTransformModifier<DayWeekEventTransformContext> {\n return (args) => {\n const modifiers: MoveTransformModifier<DayWeekEventTransformContext>[] = [getTimeStepEqualizerModifier(timeStep)];\n\n if (args.context === \"overlay\") {\n modifiers.push(boundingDraggableContainerModifier);\n }\n\n return applyMoveTransformModifiers(modifiers, args);\n };\n}\n","import type { ReactNode } from \"react\";\n\nimport type { EventSegment } from \"@weekwise/core\";\n\nimport styles from \"./DayWeekEvent.module.css\";\n\nexport type DayWeekEventPreviewProps = {\n /** The day's part of the event's new range. */\n part: EventSegment;\n /** Length of the timeline in minutes: the part is placed in percent of it. */\n timelineMinutes: number;\n children?: ReactNode;\n};\n\n/** An event while it is resized: one per day its new range covers, across the full width. */\nexport default function DayWeekEventPreview({ part, timelineMinutes, children }: DayWeekEventPreviewProps) {\n const percent = (minutes: number) => `${(minutes / timelineMinutes) * 100}%`;\n return (\n <div\n aria-hidden=\"true\"\n className={`${styles.root} ${styles.root_isResizing} ${styles.root_isPreview}`}\n data-continues-before={part.isStart ? undefined : \"\"}\n data-continues-after={part.isEnd ? undefined : \"\"}\n style={{ top: percent(part.start), height: percent(part.duration), left: 0, width: \"100%\" }}\n >\n <div className={styles.root__container}>{children}</div>\n </div>\n );\n}\n","import { useEffect, useMemo, useState, type RefObject } from \"react\";\n\nimport { formatNowOffset, getHiddenEvents, getRevealScrollTop } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useCalendarDateUtils, useMessages } from \"../../date-localization\";\nimport { useEventCallback, useGlobalListeners, useResizeObserver } from \"../../hooks\";\nimport ChevronIcon from \"../../icons/chevron\";\n\nimport type { MeasuredEventData } from \"./DayWeekView\";\nimport styles from \"./DayWeekView.module.css\";\n\nexport type HiddenEventsProps = {\n /** The scrolled timeline. */\n scrollerRef: RefObject<HTMLDivElement | null>;\n /** Events of each day column. */\n columns: readonly MeasuredEventData[][];\n rowHeight: number;\n};\n\ntype ScrollState = { top: number; height: number };\n\n/**\n * Buttons at the top and bottom of each day column of a scrolled timeline, to the events\n * above or below what is in view.\n */\nexport default function HiddenEvents({ scrollerRef, columns, rowHeight }: HiddenEventsProps) {\n const { hourMin, hideMinMaxTime, size } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const messages = useMessages();\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n const [scroll, setScroll] = useState<ScrollState | null>(null);\n const pxPerMinute = rowHeight / 60;\n\n const measure = useEventCallback(() => {\n const scroller = scrollerRef.current;\n if (!scroller) return;\n const next = { top: scroller.scrollTop, height: scroller.clientHeight };\n setScroll((prev) => (prev?.top === next.top && prev.height === next.height ? prev : next));\n });\n\n const resizeObserver = useResizeObserver(measure);\n\n useEffect(() => {\n const scroller = scrollerRef.current;\n if (!scroller) return;\n measure();\n addGlobalListener(scroller, \"scroll\", measure, { passive: true });\n resizeObserver?.observe(scroller);\n return () => {\n removeGlobalListener(scroller, \"scroll\", measure);\n resizeObserver?.unobserve(scroller);\n };\n }, [addGlobalListener, measure, removeGlobalListener, resizeObserver, scrollerRef]);\n\n // the timeline's height changes with the rows: what is out of view changes too\n useEffect(measure, [measure, rowHeight, columns]);\n\n const hidden = useMemo(\n () =>\n // no layout to measure (jsdom, the server)\n scroll && scroll.height > 0\n ? columns.map((events) => getHiddenEvents(events, pxPerMinute, scroll.top, scroll.height))\n : null,\n [columns, pxPerMinute, scroll]\n );\n\n if (!hidden || !scroll) return null;\n\n const reveal = (event: MeasuredEventData) =>\n scrollerRef.current?.scrollTo({\n top: getRevealScrollTop(event, pxPerMinute, scroll.top, scroll.height),\n behavior: \"smooth\",\n });\n\n const renderButton = (events: MeasuredEventData[], direction: \"above\" | \"below\") => {\n const [nearest] = events;\n if (!nearest) return null;\n // a narrow column has room for a count only\n const label =\n events.length === 1 && size !== \"narrow\"\n ? formatNowOffset(dateUtils, nearest.start, { hourMin, hideMinMaxTime })\n : events.length;\n return (\n <button\n type=\"button\"\n className={styles.root__hiddenEvents}\n data-direction={direction}\n aria-label={direction === \"above\" ? messages.earlier(events.length) : messages.later(events.length)}\n onClick={() => reveal(nearest)}\n >\n <ChevronIcon aria-hidden=\"true\" className={styles.root__hiddenEventsIcon} />\n {label}\n </button>\n );\n };\n\n return (\n <div className={styles.root__hiddenEventsLayer}>\n <div />\n {hidden.map(({ above, below }, idx) => (\n <div key={idx} className={styles.root__hiddenEventsColumn}>\n {renderButton(above, \"above\")}\n {renderButton(below, \"below\")}\n </div>\n ))}\n </div>\n );\n}\n","import { useState, type RefObject } from \"react\";\n\nimport { useIsomorphicLayoutEffect } from \"../../hooks\";\n\n/**\n * Width the time column needs for its labels (\"10:00 PM\", \"下午10:00\"…) on one line, or\n * `undefined` while the theme's `--ww-time-column` holds them. Measured again when the\n * labels change and once the fonts have loaded.\n */\nexport default function useTimeColumnWidth(\n /** The view's root, which sets `--ww-time-column` for its own content. */\n rootRef: RefObject<HTMLElement | null>,\n /** The `<time>` label elements, e.g. from `useRefList`. */\n labelsRef: { readonly current: readonly (HTMLElement | null)[] },\n labels: readonly string[],\n /** Width of the time column when `--ww-time-column` is not set. */\n defaultWidth: number\n): number | undefined {\n const [width, setWidth] = useState<number>();\n // measured again only when the text of the labels changes\n const labelsKey = labels.join(\"|\");\n\n useIsomorphicLayoutEffect(() => {\n let cancelled = false;\n\n const measure = () => {\n const root = rootRef.current;\n if (cancelled || !root) return;\n\n let needed = 0;\n const range = document.createRange();\n // no layout to measure (jsdom)\n if (typeof range.getBoundingClientRect !== \"function\") return;\n for (const label of labelsRef.current) {\n if (!label) continue;\n range.selectNodeContents(label);\n const style = getComputedStyle(label);\n const text = range.getBoundingClientRect().width;\n needed = Math.max(needed, text + parseFloat(style.paddingLeft) + parseFloat(style.paddingRight));\n }\n\n // the theme's width, from outside the view: the view's root overrides the variable\n const outside = root.parentElement ?? document.body;\n const themed = parseFloat(getComputedStyle(outside).getPropertyValue(\"--ww-time-column\"));\n const base = Number.isNaN(themed) ? defaultWidth : themed;\n\n setWidth(needed > base ? Math.ceil(needed) : undefined);\n };\n\n measure();\n void document.fonts?.ready.then(measure);\n return () => {\n cancelled = true;\n };\n }, [defaultWidth, labelsKey, labelsRef, rootRef]);\n\n return width;\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport type { HTMLAttributes } from \"react\";\n\nimport { useCalendarDateUtils, useMessages } from \"../../date-localization\";\nimport { useMergedRefs, useRefList, useScrollBarSize, useToday } from \"../../hooks\";\nimport useEventResize from \"../../hooks/useEventResize\";\n\nimport type { EventData } from \"../../Calendar.types\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport CalendarViewportContext from \"../../contexts/CalendarViewportContext\";\nimport DayWeekViewContext from \"../../contexts/DayWeekViewContext\";\nimport {\n arrangeEventsByDay,\n buildTimeRows,\n cx,\n getTimeFrame as getDayTimeFrame,\n getVisibleDays,\n ROW_HEIGHTS,\n splitIntoDays,\n type MeasuredEventData as CoreMeasuredEventData,\n type TimeRowData,\n} from \"@weekwise/core\";\n\nimport DayWeekDrawer from \"../day-week-drawer\";\nimport DayWeekEvent from \"../day-week-event\";\nimport DragOverlay from \"../drag-overlay\";\nimport PointerPopover from \"../pointer-popover\";\nimport { DayWeekEventPreview } from \"../day-week-event\";\nimport type { CSSVarStyle } from \"../../utils/css\";\n\nimport HiddenEvents from \"./HiddenEvents\";\nimport useTimeColumnWidth from \"./useTimeColumnWidth\";\n\nimport styles from \"./DayWeekView.module.css\";\n\nexport type DayWeekViewProps = HTMLAttributes<HTMLDivElement> & {\n /** Height of an hour, in pixels. Defaults to the one of the calendar's size. */\n rowHeight?: number;\n};\n\nexport interface DayWeekHeaderCellData {\n day: number;\n events: MeasuredEventData[];\n weekDayName: string;\n weekDayNumber: number;\n isToday: boolean;\n attributes?: Record<string, string | number | boolean>;\n targetDate: CalendarDate;\n}\n\n/** A laid-out event in a day column; its dates are the adapter's, only the adapter reads them. */\nexport type MeasuredEventData = CoreMeasuredEventData<unknown, CalendarDate>;\n\n/**\n * What a day/week event carries while dragged. Dragged items travel as JSON, so the date\n * is a timestamp: not every date type survives JSON.\n */\nexport type DayWeekDragItem = Omit<MeasuredEventData, \"rect\" | \"date\"> & { date: number };\n\nexport type { TimeRowData };\n\nexport interface EventGroup {\n date: CalendarDate;\n events: EventData[];\n}\n\nexport interface EventArrangedGroup {\n date: CalendarDate;\n events: MeasuredEventData[];\n}\n\nexport interface DayWeekViewDropTargetData {\n date: CalendarDate;\n}\n\n/** Width of the time column when `--ww-time-column` is not set, per calendar size. */\nconst TIME_COLUMN_WIDTH = { regular: 64, compact: 44, narrow: 40 } as const;\n\nexport default function DayWeekView({ rowHeight: rowHeightProp, ...props }: DayWeekViewProps) {\n const {\n viewValue,\n hourMin,\n hourMax,\n view,\n eventMap,\n preventOutBoundsChanges,\n eventRenderer,\n timeStep,\n scrollable,\n size,\n hideMinMaxTime,\n disabled,\n getIsDayDisabled,\n onEventChange,\n pointerPreviewRenderer,\n } = useCalendarContext();\n\n const dateUtils = useCalendarDateUtils();\n const messages = useMessages();\n const { getMonthDay, getWeekDay, isToday, weekDayShortName } = dateUtils;\n const today = useToday();\n\n const rowHeight = rowHeightProp ?? ROW_HEIGHTS[size];\n const rootRef = useRef<HTMLDivElement>(null);\n const viewportRef = useRef<HTMLDivElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n // the day columns by day index: resizing an event picks its day among them\n const columns = useRefList<HTMLDivElement>();\n\n const timeRows = useMemo(\n () => buildTimeRows(dateUtils, timeStep, { hourMin, hourMax, hideMinMaxTime }, preventOutBoundsChanges),\n [dateUtils, timeStep, hourMin, hourMax, hideMinMaxTime, preventOutBoundsChanges]\n );\n\n const timeLabels = useMemo(() => timeRows.map(({ time }) => time), [timeRows]);\n // the time labels by row: the time column is as wide as the longest of them needs\n const timeLabelElements = useRefList<HTMLTimeElement>();\n const timeColumnWidth = useTimeColumnWidth(rootRef, timeLabelElements.elements, timeLabels, TIME_COLUMN_WIDTH[size]);\n\n const days = useMemo(() => getVisibleDays(dateUtils, view, viewValue), [dateUtils, view, viewValue]);\n const bounds = useMemo(() => ({ hourMin, hourMax, hideMinMaxTime }), [hourMin, hourMax, hideMinMaxTime]);\n\n // Laid out in minutes (rects are percentages of the timeline).\n const eventGroups = useMemo<EventArrangedGroup[]>(\n () => arrangeEventsByDay(eventMap, dateUtils, timeRows.length * 60, days, bounds),\n [eventMap, dateUtils, timeRows.length, days, bounds]\n );\n\n const eventColumns = useMemo(() => eventGroups.map(({ events }) => events), [eventGroups]);\n\n const {\n state: resizing,\n actions: resize,\n previewOf,\n } = useEventResize({\n days,\n viewportRef,\n columnsRef: columns.elements,\n dateUtils,\n bounds,\n timeStep,\n preventOutBoundsChanges,\n disabled,\n getIsDayDisabled,\n eventMap: eventMap,\n onEventChange,\n });\n\n // The resized event, one part per day its new range covers.\n const resizeParts = useMemo(\n () => (resizing ? splitIntoDays(resizing.range[0], resizing.range[1], days.length, bounds) : []),\n [resizing, days.length, bounds]\n );\n const resizingValue = resizing ? eventMap.get(resizing.key)?.value : undefined;\n\n const getTimeFrame = useCallback<(date: CalendarDate) => [number, number]>(\n (targetDate: CalendarDate) => getDayTimeFrame(dateUtils, targetDate, { hourMin, hourMax, hideMinMaxTime }),\n [dateUtils, hideMinMaxTime, hourMax, hourMin]\n );\n\n const weekDays = useMemo(\n () =>\n days.map<DayWeekHeaderCellData>((date, idx) => {\n const weekDayNumber = getWeekDay(date);\n const today = isToday(date);\n const eventsByDay = eventGroups[idx]?.events ?? [];\n return {\n attributes: today ? { [\"data-is-today\"]: true } : undefined,\n events: eventsByDay,\n day: getMonthDay(date),\n isToday: today,\n targetDate: date,\n weekDayName: weekDayShortName(weekDayNumber),\n weekDayNumber,\n };\n }),\n [today, dateUtils, days, eventGroups, getMonthDay, getWeekDay, isToday, weekDayShortName]\n );\n\n const scrollbarSize = useScrollBarSize();\n\n const rootProps = props;\n\n const headClassName = styles.root__head;\n const bodyClassName = styles.root__body;\n const viewportClassName = styles.root__viewport;\n const columnClassName = styles.root__column;\n const headerCellClassName = styles.root__headerCell;\n const headerCellDayClassName = styles.root__headerCellDay;\n const rowClassName = styles.root__row;\n const timeClassName = styles.root__rowHeadTime;\n const timeStepClassName = styles.root__timeStep;\n\n const handleViewportRef = useMergedRefs(viewportRef);\n\n const contextValue = useMemo(\n () => ({ viewportRef, getTimeFrame, pxPerMinute: rowHeight / 60, resize, resizing }),\n [viewportRef, getTimeFrame, rowHeight, resize, resizing]\n );\n\n const viewportContextValue = useMemo(() => ({ viewportRef }), [viewportRef]);\n\n const renderEvent = (eventData: MeasuredEventData, idx: number) => {\n return (\n <DayWeekEvent key={eventData.key} data-idx={idx} eventData={eventData}>\n {eventRenderer.current?.(eventData.value, view, { isStart: eventData.isStart, isEnd: eventData.isEnd })}\n </DayWeekEvent>\n );\n };\n\n return (\n <DayWeekViewContext.Provider value={contextValue}>\n <CalendarViewportContext.Provider value={viewportContextValue}>\n <>\n <div\n {...rootProps}\n ref={rootRef}\n className={cx(rootProps.className, styles.root, {\n [styles.root_scrollable]: scrollable,\n })}\n style={\n {\n ...rootProps.style,\n [\"--calendar-column-count\"]: weekDays.length,\n [\"--scrollbar-width\"]: scrollbarSize.width,\n [\"--scrollbar-height\"]: scrollbarSize.height,\n ...(timeColumnWidth !== undefined && { [\"--ww-time-column\"]: `${timeColumnWidth}px` }),\n } as CSSVarStyle\n }\n >\n <div className={headClassName}>\n <div className={headerCellClassName} />\n {weekDays.map((weekDay) => (\n <div key={weekDay.weekDayNumber} className={headerCellClassName} {...weekDay.attributes}>\n <span className={headerCellDayClassName}>{weekDay.day}</span>\n <span className={styles.root__headerCellLabel}>\n <span className={styles.root__headerCellName}>{weekDay.weekDayName}</span>\n {weekDay.isToday && <span className={styles.root__headerCellToday}>{messages.today}</span>}\n </span>\n </div>\n ))}\n </div>\n <div className={styles.root__main}>\n <div ref={bodyRef} className={bodyClassName}>\n <div\n ref={handleViewportRef}\n className={viewportClassName}\n style={{ height: timeRows.length * rowHeight }}\n >\n <div className={columnClassName}>\n {timeRows.map(({ time, value, steps }, idx) => (\n <div\n key={value}\n className={rowClassName}\n style={\n {\n height: rowHeight,\n [\"--translateY\"]: idx * rowHeight,\n [\"--calendar-rows-count\"]: steps.length,\n } as CSSVarStyle\n }\n >\n <time ref={timeLabelElements.refAt(idx)} className={timeClassName}>\n {time}\n </time>\n {steps.map(([step, , overTime]) => (\n <div\n key={step}\n className={cx(timeStepClassName, {\n [styles.root__timeStep_overTime]: overTime,\n })}\n />\n ))}\n </div>\n ))}\n </div>\n {weekDays.map((weekDay, dayIndex) => (\n <div\n key={weekDay.weekDayNumber}\n ref={columns.refAt(dayIndex)}\n className={columnClassName}\n data-day-index={dayIndex}\n {...weekDay.attributes}\n >\n <DayWeekDrawer id={`${weekDay.weekDayNumber}`} targetDate={weekDay.targetDate}>\n {weekDay.events.map((eventData, idx) => renderEvent(eventData, idx))}\n {resizeParts\n .filter((part) => part.dayIndex === dayIndex)\n .map((part) => (\n <DayWeekEventPreview key=\"resize\" part={part} timelineMinutes={timeRows.length * 60}>\n {resizingValue !== undefined\n ? eventRenderer.current?.(resizingValue, view, {\n isStart: part.isStart,\n isEnd: part.isEnd,\n })\n : null}\n </DayWeekEventPreview>\n ))}\n </DayWeekDrawer>\n </div>\n ))}\n </div>\n </div>\n {scrollable && <HiddenEvents scrollerRef={bodyRef} columns={eventColumns} rowHeight={rowHeight} />}\n </div>\n </div>\n\n <DragOverlay pxPerMinute={rowHeight / 60} />\n {resizing && !resizing.blocked && (\n <PointerPopover coordinates={{ x: resizing.x, y: resizing.y }}>\n {(() => {\n const { date, top, duration } = previewOf(resizing.range);\n return pointerPreviewRenderer.current?.(date, top, duration);\n })()}\n </PointerPopover>\n )}\n </>\n </CalendarViewportContext.Provider>\n </DayWeekViewContext.Provider>\n );\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useEffect, useMemo, useRef } from \"react\";\n\nimport { useCalendarDateUtils } from \"./date-localization\";\nimport {\n buildEventMap,\n cx,\n formatTimelineRange,\n getEventTimeFrameFromInfo,\n getTimelineRange,\n TOUCH_HOLD_DELAY,\n} from \"@weekwise/core\";\nimport { useCalendarSize, useCurrentRef, useEventCallback, useMergedRefs } from \"./hooks\";\n\nimport CalendarContext from \"./contexts/CalendarContext\";\nimport ThemeSourceContext from \"./contexts/ThemeSourceContext\";\nimport { createDragAndDropApi } from \"@weekwise/dnd\";\nimport { DragAndDropContext } from \"@weekwise/dnd/react\";\nimport useRefWithInit from \"./hooks/useRefWithInit\";\nimport useCalendarValue from \"./hooks/useCalendarValue\";\nimport useNavigation from \"./hooks/useNavigation\";\nimport { CalendarToolbar, DayWeekView, MonthView } from \"./components\";\n\nimport type { CalendarContextValue, CalendarProps, EventChangeInfo, EventKey, EventMap } from \"./Calendar.types\";\n\nimport styles from \"./Calendar.module.css\";\n\n/**\n * The calendar. Dates in its props and callbacks are of the adapter's type (`TDate`); inside,\n * they are opaque {@link CalendarDate}s that only the adapter reads or changes.\n */\nexport default function Calendar<TValue, TDate = Date>(publicProps: CalendarProps<TValue, TDate>) {\n const props = publicProps as unknown as CalendarProps<TValue, CalendarDate>;\n const {\n ref: forwardedRef,\n disabled = false,\n children: eventRenderer,\n hideMinMaxTime = false,\n timeFrame,\n startWeek: startWeekProp,\n timeStep = 15,\n items,\n onEventCreate,\n onEventChange,\n onEventDelete,\n onEventEdit,\n eventTimeFrameResolver,\n eventKeyResolver,\n getIsDayDisabled,\n pointerPreviewFormat,\n scrollable = false,\n view: viewProp,\n defaultView: defaultViewProp,\n viewValue: viewValueProp,\n defaultViewValue: defaultViewValueProp,\n onChangeView: onChangeViewProp,\n onChangeViewValue: onChangeViewValueProp,\n ...restProps\n } = props;\n\n const { hourMax, hourMin } = { hourMin: 0, hourMax: 24, ...timeFrame };\n const resolversRef = useCurrentRef({\n eventTimeFrameResolver,\n eventKeyResolver,\n });\n const dateUtils = useCalendarDateUtils();\n const startWeek = startWeekProp ?? dateUtils.weekStartsOn;\n const rootRef = useRef<HTMLDivElement | null>(null);\n const handleRootRef = useMergedRefs(rootRef, forwardedRef);\n const { viewValue, changeViewValue, view, changeView } = useCalendarValue({\n view: viewProp,\n defaultView: defaultViewProp,\n viewValue: viewValueProp,\n defaultViewValue: defaultViewValueProp,\n onChangeView: onChangeViewProp,\n onChangeViewValue: onChangeViewValueProp,\n dateUtils,\n startWeek,\n });\n\n const size = useCalendarSize(rootRef);\n\n // pointer input: the page's cursors show while dragging, and every browser auto-scrolls alike;\n // and a touch drags an event after a long press, so a swipe still scrolls the calendar\n const dragAndDropApi = useRefWithInit(() =>\n createDragAndDropApi({ input: \"pointer\", touchDelay: TOUCH_HOLD_DELAY })\n ).current;\n\n const eventMap = useMemo<EventMap<TValue, CalendarDate>>(\n () => buildEventMap(items, resolversRef.current, dateUtils, { hourMin, hideMinMaxTime }),\n [dateUtils, hideMinMaxTime, hourMin, items, resolversRef]\n );\n\n const { goBackward, goForward, goToday } = useNavigation({\n changeViewValue,\n dateUtils,\n startWeek,\n view,\n viewValue,\n });\n\n const handleOnEventChange = useEventCallback((eventKey: EventKey, date: CalendarDate, info: EventChangeInfo) => {\n const item = eventMap.get(eventKey);\n if (item) {\n onEventChange?.(item.value, ...getEventTimeFrameFromInfo(dateUtils, date, info));\n }\n });\n\n const handleOnEventCreate = useEventCallback((date: CalendarDate, info: EventChangeInfo) => {\n onEventCreate?.(...getEventTimeFrameFromInfo(dateUtils, date, info));\n });\n\n const handleOnEventEdit = useEventCallback((eventKey: EventKey) => {\n const item = eventMap.get(eventKey);\n if (item) {\n onEventEdit?.(item.value);\n }\n });\n\n const handleOnEventDelete = useEventCallback((eventKey: EventKey) => {\n const item = eventMap.get(eventKey);\n if (item) {\n onEventDelete?.(item.value);\n }\n });\n\n const pointerPreviewRendererRef = useCurrentRef((date: CalendarDate, start: number, duration: number) => {\n const [from, to] = getTimelineRange(dateUtils, date, start, duration, {\n hourMin,\n hideMinMaxTime,\n });\n return pointerPreviewFormat ? pointerPreviewFormat(from, to) : formatTimelineRange(dateUtils, from, to);\n });\n\n const eventRendererRef = useCurrentRef(eventRenderer);\n\n useEffect(() => {\n if (rootRef.current) {\n return dragAndDropApi.getState().registerRootElement(rootRef.current);\n }\n }, [dragAndDropApi]);\n\n const rootProps = { ...restProps, ref: handleRootRef };\n\n const contextValue = useMemo(\n () =>\n ({\n disabled,\n getIsDayDisabled,\n preventOutBoundsChanges: Boolean(timeFrame),\n changeView,\n changeViewValue,\n eventMap,\n goBackward,\n goForward,\n goToday,\n hideMinMaxTime,\n hourMax,\n hourMin,\n timeStep,\n scrollable,\n size,\n startWeek,\n view,\n viewValue,\n onEventCreate: handleOnEventCreate,\n onEventChange: handleOnEventChange,\n onEventDelete: handleOnEventDelete,\n onEventEdit: handleOnEventEdit,\n eventRenderer: eventRendererRef,\n pointerPreviewRenderer: pointerPreviewRendererRef,\n }) satisfies CalendarContextValue<TValue>,\n [\n disabled,\n pointerPreviewRendererRef,\n getIsDayDisabled,\n changeView,\n changeViewValue,\n eventMap,\n goBackward,\n goForward,\n goToday,\n hideMinMaxTime,\n hourMax,\n hourMin,\n scrollable,\n size,\n startWeek,\n timeStep,\n view,\n viewValue,\n handleOnEventCreate,\n handleOnEventChange,\n handleOnEventDelete,\n handleOnEventEdit,\n eventRendererRef,\n ]\n );\n\n return (\n <div\n {...rootProps}\n className={cx(rootProps.className, styles.root)}\n data-ww-size={size === \"regular\" ? undefined : size}\n >\n <CalendarContext.Provider value={contextValue as CalendarContextValue}>\n <DragAndDropContext.Provider value={dragAndDropApi}>\n <ThemeSourceContext.Provider value={rootRef}>\n <div className={styles.root__head}>\n <CalendarToolbar />\n </div>\n <div className={styles.root__body}>{view === \"month\" ? <MonthView /> : <DayWeekView />}</div>\n </ThemeSourceContext.Provider>\n </DragAndDropContext.Provider>\n </CalendarContext.Provider>\n </div>\n );\n}\n"],"mappings":"A,qTASA,IAAMgT,GAAA,EAA0BhT,EAAAA,cAAAA,CAAqD,IAAA,EAAS,EAE1FC,EAAAA,mBACF+S,EAAwB,YAAc,2BCFxC,SAAwBC,GAAiD,CACvE,IAAMC,GAAA,EAAUhT,EAAAA,WAAAA,CAAW8S,CAAuB,EAElD,GAAI,CAACE,EACH,MAAU,MAAM,qCAAqC,EAGvD,OAAOA,CACT,CAGA,SAAgBC,GAAkD,CAChE,OAAOF,EAA2B,CACpC,CChBA,IAAMG,GAAA,EAAkBjT,EAAAA,cAAAA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AY,IAAA,GAAYA,EAE/C,UAAA7B,EAAAA,EAAAA,IAAAA,CAACwL,GAAgB,SAAjB,CAA0B,MAAO2T,EAC/B,UAAAnf,EAAAA,EAAAA,IAAAA,CAACG,EAAAA,mBAAmB,SAApB,CAA6B,MAAO0pB,GAClC,UAAAzpB,EAAAA,EAAAA,KAAAA,CAACsL,EAAmB,SAApB,CAA6B,MAAOyD,EAApC,SAAA,EACEnP,EAAAA,EAAAA,IAAAA,CAAC,MAAD,CAAK,UAAWE,GAAO,WACrB,UAAAF,EAAAA,EAAAA,IAAAA,CAACyR,GAAD,CAAkB,CAAA,CACf,CAAA,GACLzR,EAAAA,EAAAA,IAAAA,CAAC,MAAD,CAAK,UAAWE,GAAO,WAAa,SAAA0L,IAAS,SAAU5L,EAAAA,EAAAA,IAAAA,CAAC6e,GAAD,CAAY,CAAA,GAAI7e,EAAAA,EAAAA,IAAAA,CAACymB,GAAD,CAAc,CAAA,CAAO,CAAA,CACjE,C,EACF,CAAA,CACL,CAAA,CACvB,CAAA,CAET,C,0GnElMA,SAA+DjZ,EAA6C,CAC1G,GAAM,CAAE+c,UAASrpB,WAAUiN,YAAaX,EAElCrM,GAAA,EAAYlT,EAAAA,QAAAA,KACT,OAAOs8B,GAAY,WAAa,IAAIA,EAAYA,EACvD,CAACA,CAAO,CACV,EAEMC,GAAA,EAAmBv8B,EAAAA,QAAAA,MAAAA,EAAcC,EAAAA,gBAAAA,CAAgBiT,EAAU,OAAQD,CAAQ,EAAG,CAACC,EAAU,OAAQD,CAAQ,CAAC,EAEhH,OACE/S,EAAAA,EAAAA,IAAAA,CAACyS,EAAwB,SAAzB,CAAkC,MAAOO,EACvC,UAAAhT,EAAAA,EAAAA,IAAAA,CAAC6S,EAAgB,SAAjB,CAA0B,MAAOwpB,EAAmBrc,UAAmC,CAAA,CACvD,CAAA,CAEtC,E"}
1
+ {"version":3,"file":"index.cjs","names":["createContext","isDevEnvironment","useContext","createContext","isDevEnvironment","useMemo","resolveMessages","_jsx","useContext","resolveMessages","useLayoutEffect","useEffect","useRef","useMemo","useEffect","useState","getCalendarSize","useRef","useRef","useMemo","useState","useRef","useEffect","useState","isDevEnvironment","useCallback","useEffect","useRef","isDevEnvironment","useInsertionEffect","useState","useMemo","useEffect","useEffect","Rect","getClientRect","useMemo","useState","useRef","useEffect","useMemo","useRef","useEffect","useState","startTransition","useState","useRef","useCallback","useRef","useEffect","useState","useEffect","createContext","isDevEnvironment","useContext","createContext","isDevEnvironment","resolveView","useEffect","isDevEnvironment","useCallback","normalizeViewValue","useRef","transferDay","getViewChangeTarget","getNavigationTarget","_jsx","useSyncExternalStore","THEME_PROPERTIES","useContext","createPortal","_jsx","useState","useRef","useFloating","offset","flip","shift","autoUpdate","useEffect","useMemo","getViewHeading","getMonthGrid","_jsxs","styles","cx","_jsx","formatMonthYear","isInViewPeriod","mergeCallbacks","_jsx","cx","styles","useId","useState","useRef","useFloating","offset","flip","shift","autoUpdate","useEffect","_jsxs","_Fragment","cx","styles","_jsx","cx","styles","_jsxs","_jsx","_Fragment","props","useRef","getViewList","getViewTimeStep","createDragAndDropApi","TOUCH_HOLD_DELAY","useMemo","buildEventMap","getEventTimeFrameFromInfo","getTimelineRange","formatTimelineRange","useEffect","_jsx","cx","styles","DragAndDropContext","_jsxs","useState","useRef","useCallback","resizeEventRange","getTimeFrame","isPastDay","useMemo","toDayMinutes","fromDayMinutes","createContext","isDevEnvironment","useContext","createContext","isDevEnvironment","useContext","createContext","isDevEnvironment","useContext","useRef","useCallback","useRef","useMemo","useCallback","useEffect","getScrollDirectionAndSpeed","useRef","useMemo","useEffect","getClientRect","useReducer","isHTMLElement","shallowEqual","defaultValue","useRef","useMemo","getScrollableAncestors","useEffect","getClientRect","useReducer","getWindow","Rect","useState","useRef","useCallback","getScrollableElement","getScrollCoordinates","useEffect","isNotNull","useMemo","add","defaultCoordinates","getScrollOffsets","emptyArray","useRef","useEffect","defaultCoordinates","subtract","useReducer","useMemo","add","adjustScrollRect","applyMoveTransformModifiers","match","useState","useMemo","getNowOffset","_jsx","cx","styles","useRef","useDragAndDrop","useMemo","boundingResizableContainerModifier","getTimeStepEqualizerModifier","useEffect","toDayMinutes","TOUCH_HOLD_DELAY","formatNowOffset","_jsxs","cx","styles","_jsx","_Fragment","useState","getClientRect","subtract","round","useState","useRef","useDragAndDrop","mergeCallbacks","useEffect","omit","cx","styles","_jsx","_Fragment","_jsxs","getTimeStepEqualizerModifier","boundingDraggableContainerModifier","applyMoveTransformModifiers","_jsx","styles","useDragAndDrop","useMemo","useRef","useState","_jsx","cx","styles","_jsxs","useState","useEffect","useMemo","getHiddenEvents","getRevealScrollTop","formatNowOffset","_jsxs","styles","_jsx","useState","ROW_HEIGHTS","useRef","useMemo","buildTimeRows","getVisibleDays","arrangeEventsByDay","splitIntoDays","useCallback","getDayTimeFrame","styles","_jsx","_jsxs","_Fragment","cx","_jsx","useRef","useDragAndDrop","useEffect","toDayMinutes","_jsx","cx","styles","useRef","useDragAndDrop","MONTH_WEEK_GEOMETRY","useEffect","_jsxs","cx","styles","_jsx","_jsx","cx","styles","_jsx","styles","useRef","_jsxs","useState","getMonthLaneCount","resizeEventDays","useMemo","getEventTimeFrameFromInfo","useRef","useMemo","getMonthGrid","getWeekdayNames","arrangeMonthWeek","groupEventsByDay","getDayKey","_jsxs","cx","styles","_jsx","_jsx","_jsx","react","_weekwise_core","_weekwise_dnd","_weekwise_dnd_react","_floating_ui_react_dom","react_jsx_runtime","react_dom","DateLocalizationContext","useDateUtils","context","useCalendarDateUtils","MessagesContext","useMessages","messages","dateUtils","useIsomorphicLayoutEffect","useResizeObserver","cb","disabled","cbRef","resizeObserver","ResizeObserver","useCalendarSize","ref","size","setSize","observer","entry","width","element","useCurrentRef","value","currentRef","useComputed","deps","valueRef","newValue","useIsControlled","controlledValue","isControlled","useAssert","defaultValue","defaultValueProp","error","useControlled","params","controlled","valueState","setValueState","setValueIfUncontrolled","useDocumentCursor","cursor","className","root","UNINITIALIZED","useRefWithInit","init","initArg","assertNotCalled","createStableCallback","stable","args","useEventCallback","callback","useGlobalListeners","globalListeners","addGlobalListener","removeGlobalListener","removeAllGlobalListeners","target","type","listener","options","fn","event","useItemsLayout","containerRef","itemsRef","layout","createItemsLayout","container","items","take","rect","item","left","top","right","bottom","x","y","axis","best","bestDistance","box","index","dx","dy","distance","toFnRef","mergeRefs","refs","useMergedRefs","useMove","state","paramsRef","clearHold","listeners","attr","stopEvent","update","coordinates","pointerId","handlers","clientX","clientY","prevClientX","prevClientY","getCommonEventData","pointerType","deltaX","deltaY","initialDeltaX","initialDeltaY","onMouseMove","onMouseUp","onTouchMove","touch","identifier","trouchEvent","onTouchEnd","removePointerListeners","onPointerMove","onPointerUp","releaseHold","TOUCH_HOLD_TOLERANCE","startPointer","touchDelay","HOLD_VIBRATION","triggerKeyboardMove","start","move","end","preventTouchScroll","node","usePrevious","useRefList","createRefList","elements","buildUseScrollbarSizeHook","count","elementFabric","resizeCallback","dimensions","setDimensions","updateState","scrollbarHeight","scrollbarWidth","currentDimensions","height","cleanup","useScrollBarSize","useStateRef","initialValue","setState","next","useTimeInterval","interval","isActive","timerRef","callbackRef","now","delay","startOfToday","useToday","current","today","nextMidnight","timer","CalendarContext","useCalendarContext","ThemeSourceContext","useCalendarValue","views","view","defaultView","startWeek","viewValue","defaultViewValue","onChangeView","onChangeViewValue","requestedView","setControlledView","controlledView","isViewOffered","calculateViewValue","controlledViewValue","setControlledViewValue","changeViewValue","changeView","newView","currentViewValueRef","previousViewRef","previousStartWeekRef","previousDateUtilsRef","fromView","startWeekChanged","previousDateUtils","nextValue","useNavigation","navigate","from","direction","ChevronIcon","props","subscribe","getClientSnapshot","getServerSnapshot","useIsHydrated","readTheme","source","theme","computed","name","Portal","children","hydrated","themeSource","DateNavigator_module_default","DateNavigator","renderHeading","onClick","onKeyDown","buttonProps","getStartOfWeek","getStartOfMonth","addMonths","open","setOpen","pickerMonth","setPickerMonth","rootRef","floatingStyles","handlePointerDown","heading","gridDays","handleToggleClick","prev","handleToggleKeyDown","handleSelectDay","day","isOutsideMonth","isToday","isSelected","isRangeStart","isRangeEnd","NavBtn_module_default","NavBtn","goForward","goBackward","handleClick","ViewSelect_module_default","ViewSelect","id","active","setActive","optionRefs","close","returnFocus","reference","openList","focused","select","handleListKeyDown","moveTo","listId","option","CalendarToolbar_module_default","CalendarToolbar","goToday","rootProps","viewTabProps","tab","todayProps","Calendar_module_default","CalendarBase","publicProps","forwardedRef","eventRenderer","viewsProp","hideMinMaxTime","timeFrame","startWeekProp","timeStepProp","onEventCreate","onEventChange","onEventDelete","onEventEdit","eventTimeFrameResolver","eventKeyResolver","getIsDayDisabled","pointerPreviewFormat","scrollable","viewProp","defaultViewProp","viewValueProp","defaultViewValueProp","onChangeViewProp","onChangeViewValueProp","restProps","hourMax","hourMin","resolversRef","handleRootRef","timeStep","dragAndDropApi","eventMap","handleOnEventChange","eventKey","date","info","handleOnEventCreate","handleOnEventEdit","handleOnEventDelete","pointerPreviewRendererRef","duration","to","eventRendererRef","activeView","ActiveView","contextValue","DAY","useEventResize","days","viewportRef","columnsRef","bounds","preventOutBoundsChanges","session","offset","timelineMinutes","viewport","minute","dayIndex","idx","handleScroll","actions","key","edge","original","range","CalendarViewportContext","useCalendarViewportContext","DayWeekViewContext","useDayWeekViewContext","DayWeekDrawerContext","useDayWeekDrawerContext","useInterval","intervalRef","defaultScrollIntent","useScrollIntent","delta","previousDelta","previousIntent","useAutoScroller","acceleration","activator","canScroll","enabled","pointerCoordinates","order","threshold","activeNodeRect","scrollableAncestors","scrollableAncestorsRects","setAutoScrollInterval","clearAutoScrollInterval","scrollIntent","scrollSpeed","scrollDirection","scrollContainerRef","sortedScrollableAncestorsWithRects","autoScroll","scrollContainer","scrollLeft","scrollTop","scrollContainerRect","speed","useMutationObserver","mutationObserver","MutationObserver","useRect","measure","fallbackRect","measureRect","reducer","records","record","currentRect","newRect","defaultValue$1","useScrollableAncestors","limit","previousNode","ancestors","useScrollableAncestorsRects","rects","measureRects","window","useScrollOffsets","scrollCoordinates","setScrollCoordinates","prevElements","scrollingElement","previousElements","entries","scrollableElement","acc","useScrollOffsetsDelta","scrollOffsets","dependencies","initialScrollOffsets","hasScrollOffsets","UseMoveTransformActionTypes","defaultMoveTransformState","useMoveTransform","autoScrollEnabled","modifiers","activeNode","containerNode","dispatch","defaultMoveTransformReducer","resolvedActiveNode","resolvedContainerNode","containerNodeRect","scrollAdjustment","buildAction","scrollAdjustmentTranslate","scrollAdjustmentActiveNodeRect","scrollAdjustmentContainerNodeRect","transform","action","useTimeOffset","tick","setTick","PointerPopover_module_default","PointerPopover","style","DayWeekDrawer_module_default","DayWeekDrawer","targetDate","pointerPreviewRenderer","getTimeFrame","pxPerMinute","isBefore","stepPx","toMinutes","px","toTimelineMinutes","getTimeFramePx","register","getTransform","registerDropTarget","todayOrPast","isTodayFlag","resizingActiveNodeRect","initialTranslate","translate","offsetY","compensation","bottomEdge","topEdge","timeOffset","offLimits","dropTargetElement","eventData","data","startOfEvent","partDay","fromStart","dayShift","types","allowedOperations","isPast","moveListeners","moveRef","currentTop","drawerContextValue","timeOffsetTitle","renderPreview","useAbsEventRect","relativeRect","absEventRect","setAbsEventRect","rootEl","parentEl","positions","useCanResizeEvent","eventDate","absRect","canResize","setCanResize","bottomRect","DayWeekEvent_module_default","DayWeekEvent","topBarRef","bottomBarRef","resize","resizing","drawerRef","attributes","isDragging","overElement","overData","setOverlayTransform","registerDragSource","draggable","droppable","setTransform","activeDrawerRect","ctx","getEventTransformModifiers","moveEndHandler","resizeListeners","e","resizeBottomListeners","resizeTopListeners","isDragginOverlay","isResizeSource","syncTransform","\"event\"","rootClassName","rootStyle","DayWeekEventPreview","part","percent","minutes","DragOverlay_module_default","WHOLE_EVENT","DragOverlay","showPreview","canDrop","dropData","eventItem","overlay","eventValue","lastRef","droppedRef","isPlaced","setIsPlaced","returning","setReturning","last","sourceRect","containerRect","isBlocked","DayWeekView_module_default","HiddenEvents","scrollerRef","columns","rowHeight","scroll","setScroll","scroller","hidden","events","reveal","renderButton","nearest","label","above","below","useTimeColumnWidth","labelsRef","labels","defaultWidth","setWidth","cancelled","needed","text","outside","themed","TIME_COLUMN_WIDTH","DayWeekView","rowHeightProp","getMonthDay","getWeekDay","weekDayShortName","bodyRef","timeRows","timeLabels","time","timeLabelElements","timeColumnWidth","eventGroups","eventColumns","previewOf","resizeParts","resizingValue","weekDays","weekDayNumber","eventsByDay","scrollbarSize","headClassName","bodyClassName","viewportClassName","columnClassName","headerCellClassName","headerCellDayClassName","rowClassName","timeClassName","timeStepClassName","handleViewportRef","viewportContextValue","renderEvent","weekDay","steps","step","overTime","TimelineView","dayView","weekView","cssVariables","variables","splitIntoWeeks","_","week","MonthView_module_default","MonthViewDay","onDayClick","onDoubleClick","getHours","getMinutes","getNow","isOver","dragItem","sourceDay","shift","handleDoubleClick","handleKeyDown","BAR_INSET","MonthViewEvent","weekRef","resizable","isAnyResizing","grabbedDayRef","overDayRect","minTop","maxTop","getDragItems","column","clamped","resizeStartListeners","resizeEndListeners","multiDay","MonthViewEventPreview","bar","MonthViewDayContent","MonthViewWeek","firstDayIndex","cellRef","sourceBars","lanes","resizingKey","renderDayContent","isSameMonth","toMillis","isResizing","renderBar","useMonthLanes","maxLanes","setLanes","useMonthResize","cellsRef","setSession","sessionRef","commit","shownEventMap","NO_BARS","NO_LAYOUT","MonthView","renderDay","cells","weeks","weekdayNames","dayRendererRef","hasDayRenderer","handleDayClick","layouts","dayEvents","shownLayouts","weekdayName","weekIndex","MonthViewOfOptions","monthView","Calendar","adapter","resolvedMessages"],"sources":["../src/date-localization/DateLocalizationContext.ts","../src/date-localization/useDateUtils.ts","../src/date-localization/MessagesContext.ts","../src/date-localization/DateLocalizationProvider.tsx","../src/date-localization/useMessages.ts","../src/hooks/useIsomorphicLayoutEffect.ts","../src/hooks/useResizeObserver.ts","../src/hooks/useCalendarSize.ts","../src/hooks/useCurrentRef.ts","../src/hooks/useComputed.ts","../src/hooks/useControlled.utils.ts","../src/hooks/useControlled.ts","../src/hooks/useDocumentCursor.ts","../src/hooks/useRefWithInit.ts","../src/hooks/useEventCallback.utils.ts","../src/hooks/useEventCallback.ts","../src/hooks/useGlobalListeners.ts","../src/hooks/useItemsLayout.ts","../src/utils/mergeRefs.ts","../src/hooks/useMergedRefs.ts","../src/hooks/useMove.ts","../src/hooks/usePrevious.ts","../src/hooks/useRefList.ts","../src/hooks/useScrollBarSize.ts","../src/hooks/useStateRef.ts","../src/hooks/useTimeInterval.ts","../src/hooks/useToday.ts","../src/contexts/CalendarContext.ts","../src/contexts/ThemeSourceContext.ts","../src/hooks/useCalendarValue.ts","../src/hooks/useNavigation.ts","../src/icons/chevron.tsx","../src/portal/Portal.tsx","../src/components/date-navigator/DateNavigator.tsx","../src/components/nav-btn/NavBtn.tsx","../src/components/view-select/ViewSelect.tsx","../src/components/calendar-toolbar/CalendarToolbar.tsx","../src/CalendarBase.tsx","../src/hooks/useEventResize.ts","../src/contexts/CalendarViewportContext.ts","../src/contexts/DayWeekViewContext.ts","../src/contexts/DayWeekDrawerContext.ts","../src/hooks/useInterval.ts","../src/hooks/useScrollIntent.ts","../src/hooks/useAutoScroller.ts","../src/hooks/useMutationObserver.ts","../src/hooks/useRect.ts","../src/hooks/useScrollableAncestors.ts","../src/hooks/useScrollableAncestorsRects.ts","../src/hooks/useScrollOffsets.ts","../src/hooks/useScrollOffsetsDelta.ts","../src/hooks/useMoveTransform.ts","../src/hooks/useTimeOffset.ts","../src/components/pointer-popover/PointerPopover.tsx","../src/components/day-week-drawer/DayWeekDrawer.tsx","../src/hooks/useAbsEventRect.ts","../src/hooks/useCanResizeEvent.ts","../src/components/day-week-event/DayWeekEvent.tsx","../src/components/day-week-event/DayWeekEventPreview.tsx","../src/components/drag-overlay/DragOverlay.tsx","../src/components/day-week-view/HiddenEvents.tsx","../src/components/day-week-view/useTimeColumnWidth.ts","../src/components/day-week-view/DayWeekView.tsx","../src/components/timeline-view/TimelineView.tsx","../src/views/dayView.ts","../src/views/weekView.ts","../src/components/month-view/MonthView.utils.ts","../src/components/month-view/MonthViewDay.tsx","../src/components/month-view/MonthViewEvent.tsx","../src/components/month-view/MonthViewEventPreview.tsx","../src/components/month-view/MonthViewWeek.tsx","../src/components/month-view/useMonthLanes.ts","../src/components/month-view/useMonthResize.ts","../src/components/month-view/MonthView.tsx","../src/views/monthView.tsx","../src/Calendar.tsx"],"sourcesContent":["import { createContext } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\nimport type { CalendarDate, DateAdapter } from \"@weekwise/core\";\n\n/**\n * DateLocalization context: the adapter, whatever its date type (read it with `useDateUtils<TDate>()`).\n */\nconst DateLocalizationContext = createContext<DateAdapter<CalendarDate> | undefined>(undefined);\n\nif (isDevEnvironment) {\n DateLocalizationContext.displayName = \"DateLocalizationContext\";\n}\n\nexport default DateLocalizationContext;\n","import { useContext } from \"react\";\n\nimport type { CalendarDate, DateAdapter } from \"@weekwise/core\";\n\nimport DateLocalizationContext from \"./DateLocalizationContext\";\n\n/**\n * The adapter given to `DateLocalizationProvider`. `TDate` is its date type: `Date` unless\n * the adapter works with another one, e.g. `useDateUtils<Temporal.ZonedDateTime>()`.\n */\nexport default function useDateUtils<TDate = Date>(): DateAdapter<TDate> {\n const context = useContext(DateLocalizationContext);\n\n if (!context) {\n throw new Error(\"DateLocalizationContext is required\");\n }\n\n return context as unknown as DateAdapter<TDate>;\n}\n\n/** The adapter for the calendar's own components, which never look inside a date. */\nexport function useCalendarDateUtils(): DateAdapter<CalendarDate> {\n return useDateUtils<CalendarDate>();\n}\n","import { createContext } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\nimport type { CalendarMessages } from \"@weekwise/core\";\n\n/** Interface strings, resolved by {@link DateLocalizationProvider} from the adapter's locale. */\nconst MessagesContext = createContext<CalendarMessages | undefined>(undefined);\n\nif (isDevEnvironment) {\n MessagesContext.displayName = \"MessagesContext\";\n}\n\nexport default MessagesContext;\n","import { useMemo, type PropsWithChildren } from \"react\";\n\nimport { resolveMessages } from \"@weekwise/core\";\nimport type { CalendarDate, CalendarMessages, DateAdapter } from \"@weekwise/core\";\n\nimport DateLocalizationContext from \"./DateLocalizationContext\";\nimport MessagesContext from \"./MessagesContext\";\n\nexport type DateLocalizationProviderProps<TDate = Date> = PropsWithChildren<{\n /**\n * Date adapter: an instance (`new DateFnsAdapter({ locale: ru })`) or a class\n * with a no-argument constructor (`DateFnsAdapter`). Its `locale` also selects\n * the interface language, so switching the adapter switches the whole calendar.\n * Its date type (`Date`, `Temporal.ZonedDateTime`…) is the one the calendar takes and gives.\n */\n adapter: DateAdapter<TDate> | (new () => DateAdapter<TDate>);\n /**\n * Interface strings on top of the built-in translation for the adapter's locale:\n * a few words to change, or every string for a language without a translation.\n */\n messages?: Partial<CalendarMessages>;\n}>;\n\nexport default function DateLocalizationProvider<TDate = Date>(props: DateLocalizationProviderProps<TDate>) {\n const { adapter, messages, children } = props;\n\n const dateUtils = useMemo<DateAdapter<TDate>>(\n () => (typeof adapter === \"function\" ? new adapter() : adapter),\n [adapter]\n );\n\n const resolvedMessages = useMemo(() => resolveMessages(dateUtils.locale, messages), [dateUtils.locale, messages]);\n\n return (\n <DateLocalizationContext.Provider value={dateUtils as unknown as DateAdapter<CalendarDate>}>\n <MessagesContext.Provider value={resolvedMessages}>{children}</MessagesContext.Provider>\n </DateLocalizationContext.Provider>\n );\n}\n","import { useContext } from \"react\";\n\nimport { resolveMessages } from \"@weekwise/core\";\n\nimport MessagesContext from \"./MessagesContext\";\nimport useDateUtils from \"./useDateUtils\";\n\n/** Interface strings in the language of the date adapter's locale. */\nexport default function useMessages() {\n const messages = useContext(MessagesContext);\n const dateUtils = useDateUtils();\n return messages ?? resolveMessages(dateUtils.locale);\n}\n","import { useEffect, useLayoutEffect } from \"react\";\n\nconst isBrowser = typeof window !== \"undefined\";\n\n/**\n * `useLayoutEffect` that falls back to `useEffect` during server-side\n * rendering to avoid the React SSR warning.\n */\nexport const useIsomorphicLayoutEffect = isBrowser ? useLayoutEffect : useEffect;\n\nexport default useIsomorphicLayoutEffect;\n","import { useEffect, useMemo, useRef } from \"react\";\n\n/**\n * Returns a new ResizeObserver instance bound to the `onResize` callback.\n * If `ResizeObserver` is undefined in the execution environment, returns `undefined`.\n */\nexport default function useResizeObserver(cb: ResizeObserverCallback, disabled = false) {\n const cbRef = useRef(cb);\n cbRef.current = cb;\n const resizeObserver = useMemo(() => {\n if (disabled || typeof window === \"undefined\" || typeof window.ResizeObserver === \"undefined\") {\n return undefined;\n }\n const { current: cb } = cbRef;\n const { ResizeObserver } = window;\n\n return new ResizeObserver(cb);\n }, [disabled]);\n\n useEffect(() => {\n return () => resizeObserver?.disconnect();\n }, [resizeObserver]);\n\n return resizeObserver;\n}\n","import { useState, type RefObject } from \"react\";\n\nimport { getCalendarSize, type CalendarSize } from \"@weekwise/core\";\n\nimport useIsomorphicLayoutEffect from \"./useIsomorphicLayoutEffect\";\nimport useResizeObserver from \"./useResizeObserver\";\n\n/**\n * Layout for the width of `ref`'s element, kept up to date as it is resized. `regular` on\n * the server and until the element is measured.\n */\nexport default function useCalendarSize(ref: RefObject<HTMLElement | null>): CalendarSize {\n const [size, setSize] = useState<CalendarSize>(\"regular\");\n\n const observer = useResizeObserver(([entry]) => {\n if (!entry) return;\n const width = entry.borderBoxSize?.[0]?.inlineSize ?? entry.contentRect.width;\n setSize(getCalendarSize(width));\n });\n\n useIsomorphicLayoutEffect(() => {\n const element = ref.current;\n if (!element) return;\n // before the first paint, so the regular layout does not flash\n setSize(getCalendarSize(element.getBoundingClientRect().width));\n observer?.observe(element);\n return () => observer?.unobserve(element);\n }, [observer, ref]);\n\n return size;\n}\n","import { useRef } from \"react\";\n\nexport default function useCurrentRef<T>(value: T): { readonly current: T } {\n const currentRef = useRef(value);\n currentRef.current = value;\n\n return currentRef;\n}\n","import { useMemo, useRef, type DependencyList } from \"react\";\n\nimport useCurrentRef from \"./useCurrentRef\";\n\nexport default function useComputed<T>(cb: (prevValue: T | undefined) => T, deps: DependencyList) {\n const valueRef = useRef<T>(undefined);\n const cbRef = useCurrentRef(cb);\n\n return useMemo(\n () => {\n const newValue = cbRef.current(valueRef.current);\n valueRef.current = newValue;\n\n return newValue;\n },\n // cbRef can be ignored because it will never change\n // oxlint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo\n deps\n );\n}\n","import { useEffect, useRef, useState } from \"react\";\n\n/**\n * Helper hook to handle previous comparison of controlled/uncontrolled\n * Prints an error when isControlled value switches between subsequent renders\n * @returns - whether the value is controlled\n */\nexport function useIsControlled<T>(controlledValue: T | undefined): controlledValue is T {\n const [isControlled] = useState<boolean>(() => controlledValue !== undefined);\n return isControlled;\n}\n\nexport function useAssert<T>(\n isControlled: boolean,\n controlledValue: T | undefined,\n defaultValue: T | undefined,\n defaultValueProp: T | undefined\n) {\n const error = useRef(new Error());\n // We don't want these warnings in production even though it is against native behaviour\n\n useEffect(() => {\n if (isControlled !== (controlledValue !== undefined)) {\n const controlWarning = isControlled\n ? \"a controlled value to be uncontrolled\"\n : \"an uncontrolled value to be controlled\";\n\n const undefinedWarning = isControlled ? \"defined to an undefined\" : \"undefined to a defined\";\n\n throw new Error(`\n [useControlled]:\n A component is changing ${controlWarning}. This is likely caused by the value changing from ${undefinedWarning} value, which should not happen.\n Decide between using a controlled or uncontrolled input element for the lifetime of the component.\n More info: https://reactjs.org/link/controlled-components\n ${error.current.stack}\n `);\n }\n }, [isControlled, controlledValue]);\n\n useEffect(() => {\n if (!isControlled && defaultValue !== defaultValueProp) {\n throw new Error(`\n [useControlled]:\n A component is changing the default state of an uncontrolled value after being initialized.\n To suppress this warning opt to use a controlled value.\n More info: https://reactjs.org/link/controlled-components\n ${error.current.stack}`);\n }\n }, [defaultValueProp, defaultValue, isControlled]);\n}\n","import { isDevEnvironment } from \"@weekwise/core\";\nimport { useCallback, useState, type Dispatch, type SetStateAction } from \"react\";\n\nimport type { UseControlledParams, UseControlledWithInitialParams } from \"./useControlled.types\";\nimport { useAssert, useIsControlled } from \"./useControlled.utils\";\n\n/**\n * Creates a controlled state with an uncontrolled fallback.\n *\n * If `controlled` is defined, `useControlled` will return the controlled value and an\n * identity function as the update function. If `controlled` is `undefined`, `useControlled`\n * will return the `defaultValue` and a state update function.\n *\n * This hook is useful when you want to make a component that can be either controlled or\n * uncontrolled, depending on whether the user provides a `value` or `defaultValue` prop.\n *\n * @param params - The parameters of the hook.\n * @param params.controlled - The controlled value.\n * @param params.default - The default value.\n * @returns A tuple of the value and the update function.\n */\nexport default function useControlled<T>(\n params: UseControlledParams<T>\n): [T | undefined, Dispatch<SetStateAction<T | undefined>>, boolean];\n/**\n * Creates a controlled state with an uncontrolled fallback and an `initialState`.\n *\n * This hook is useful when you want to make a component that can be either controlled or\n * uncontrolled, depending on whether the user provides a `value` or `defaultValue` prop. The\n * `initialState` is used as the initial value of the state, if the component is uncontrolled.\n *\n * The third element of the returned tuple is a boolean indicating whether the component is\n * controlled or uncontrolled.\n *\n * @param params - The parameters of the hook.\n * @param params.controlled - The controlled value.\n * @param params.default - The default value.\n * @param params.initialState - The initial state.\n * @returns A tuple of the value, the update function and a boolean indicating whether the\n * component is controlled or uncontrolled.\n */\nexport default function useControlled<T>(\n params: UseControlledWithInitialParams<T>\n): [T, Dispatch<SetStateAction<T>>, boolean];\nexport default function useControlled<T>(params: UseControlledParams<T> | UseControlledWithInitialParams<T>) {\n const { controlled, default: defaultValueProp } = params;\n const [valueState, setValueState] = useState(() => {\n if (defaultValueProp === undefined && \"initialState\" in params && params.initialState !== undefined) {\n return params.initialState;\n }\n return defaultValueProp;\n });\n const [defaultValue] = useState<T | undefined>(defaultValueProp);\n\n const isControlled = useIsControlled(controlled);\n\n if (isDevEnvironment) {\n // oxlint-disable-next-line react-hooks/rules-of-hooks\n useAssert(isControlled, controlled, defaultValue, defaultValueProp);\n }\n\n const setValueIfUncontrolled: Dispatch<SetStateAction<T | undefined>> = useCallback(\n (newValue) => {\n if (!isControlled) {\n setValueState(newValue);\n }\n },\n [isControlled]\n );\n return [isControlled ? controlled : valueState, setValueIfUncontrolled, isControlled];\n}\n","import { useEffect } from \"react\";\n\n/** Cursors set on the whole page while a gesture runs: see the `ww-cursor-*` classes in Calendar.module.css. */\nexport type DocumentCursor = \"grabbing\" | \"not-allowed\";\n\n/**\n * Shows `cursor` over the whole page, the calendar, its overlays and outside it, until it is\n * `null` or the component unmounts. The page's elements keep their own cursors otherwise.\n */\nexport default function useDocumentCursor(cursor: DocumentCursor | null) {\n useEffect(() => {\n if (!cursor) return;\n\n const className = `ww-cursor-${cursor}`;\n const root = document.documentElement;\n root.classList.add(className);\n return () => root.classList.remove(className);\n }, [cursor]);\n}\n","import { useRef } from \"react\";\n\nconst UNINITIALIZED: unknown = {};\n\n/**\n * A React.useRef() that is initialized with a function. Note that it accepts an optional\n * initialization argument, so the initialization function doesn't need to be an inline closure.\n *\n * @usage\n * const ref = useRefWithInit(sortColumns, columns)\n */\nexport default function useRefWithInit<T>(init: () => T): { readonly current: T };\nexport default function useRefWithInit<T, U>(init: (arg: U) => T, initArg: U): { readonly current: T };\nexport default function useRefWithInit<T>(\n init: (arg?: unknown) => unknown,\n initArg?: unknown\n): { readonly current: T } {\n const ref = useRef<unknown>(UNINITIALIZED);\n\n if (ref.current === UNINITIALIZED) {\n ref.current = init(initArg);\n }\n\n return ref as { readonly current: T };\n}\n","import { isDevEnvironment } from \"@weekwise/core\";\nimport type { Stable } from \"./useEventCallback.types\";\n\nfunction assertNotCalled() {\n if (isDevEnvironment) {\n throw new Error(\"useEventCallback: Cannot call an event handler while rendering.\");\n }\n}\n\nexport function createStableCallback() {\n const stable: Stable<any> = {\n next: undefined,\n callback: assertNotCalled,\n trampoline: (...args: []) => stable.callback?.(...args),\n effect: () => {\n stable.callback = stable.next;\n },\n };\n return stable;\n}\n","import { useInsertionEffect } from \"react\";\n\nimport useRefWithInit from \"./useRefWithInit\";\nimport { createStableCallback } from \"./useEventCallback.utils\";\n\nexport default function useEventCallback<T extends (...args: any[]) => any>(callback: T | undefined): T {\n const stable = useRefWithInit(createStableCallback).current;\n // oxlint-disable-next-line react-hooks/immutability\n stable.next = callback;\n useInsertionEffect(stable.effect);\n return stable.trampoline;\n}\n","import { useEffect, useMemo, useState } from \"react\";\n\nexport default function useGlobalListeners(): GlobalListeners {\n const [globalListeners] = useState(() => ({\n current: new Map<GeneralEventListener, ListenerMetadata>(),\n }));\n\n const { addGlobalListener, removeGlobalListener, removeAllGlobalListeners } = useMemo(() => {\n function addGlobalListener(\n target: EventTarget,\n type: string,\n listener: GeneralEventListener,\n options?: boolean | AddEventListenerOptions\n ) {\n const fn =\n typeof options !== \"boolean\" && options?.once\n ? (event: Event) => {\n globalListeners.current.delete(listener);\n if (target instanceof Document) listener.call(target, event);\n else (listener as EventListener)(event);\n }\n : listener;\n\n target.addEventListener(type, listener, options);\n globalListeners.current.set(listener, { type, target, fn, options });\n }\n function removeGlobalListener(\n target: EventTarget,\n type: string,\n listener: GeneralEventListener,\n options?: boolean | EventListenerOptions\n ) {\n const fn = globalListeners.current.get(listener)?.fn || listener;\n target.removeEventListener(type, fn, options);\n globalListeners.current.delete(listener);\n }\n\n function removeAllGlobalListeners() {\n globalListeners.current.forEach(({ target, type, options }, listener) => {\n removeGlobalListener(target, type, listener, options);\n });\n }\n\n return { addGlobalListener, removeGlobalListener, removeAllGlobalListeners };\n }, [globalListeners]);\n\n useEffect(() => {\n return removeAllGlobalListeners;\n }, [removeAllGlobalListeners]);\n\n return {\n addGlobalListener,\n removeGlobalListener,\n removeAllGlobalListeners,\n };\n}\n\ninterface GlobalListeners {\n addGlobalListener<K extends keyof DocumentEventMap>(\n el: EventTarget,\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | AddEventListenerOptions\n ): void;\n addGlobalListener(\n el: EventTarget,\n type: string,\n listener: EventListener,\n options?: boolean | AddEventListenerOptions\n ): void;\n removeGlobalListener<K extends keyof DocumentEventMap>(\n el: EventTarget,\n type: K,\n listener: (this: Document, ev: DocumentEventMap[K]) => any,\n options?: boolean | EventListenerOptions\n ): void;\n removeGlobalListener(\n el: EventTarget,\n type: string,\n listener: EventListener,\n options?: boolean | EventListenerOptions\n ): void;\n removeAllGlobalListeners(): void;\n}\n\ntype ListenerMetadata = {\n type: string;\n target: EventTarget;\n options: boolean | AddEventListenerOptions | undefined;\n fn: GeneralEventListener;\n};\n\ntype GeneralEventListener =\n EventListener | (<K extends keyof DocumentEventMap>(this: Document, ev: DocumentEventMap[K]) => any);\n","import { useEffect, type RefObject } from \"react\";\n\nimport { getClientRect, Rect } from \"@weekwise/core\";\n\nimport useRefWithInit from \"./useRefWithInit\";\n\n/** An item's box from the container's top left corner: it scrolls with the container. */\ninterface ItemBox {\n left: number;\n top: number;\n right: number;\n bottom: number;\n}\n\nexport interface ItemsLayout {\n /**\n * Measures the container and its items for a gesture, and again whenever the container\n * changes size, until {@link ItemsLayout.release}. `false` without a container.\n */\n measure: () => boolean;\n /** Ends the gesture: the measurements stop following the container's size. */\n release: () => void;\n /**\n * The container's box where it is now: it follows the scroll of the container's scrollable\n * ancestors without measuring again. `null` before {@link ItemsLayout.measure}.\n */\n container: () => Rect | null;\n /**\n * Index of the item under the point, or of the nearest one; `-1` without items. With\n * `axis: \"x\"` only the horizontal distance counts (columns as tall as the container).\n */\n nearestIndex: (x: number, y: number, axis?: \"x\" | \"xy\") => number;\n}\n\n/**\n * Where a container and the items in it (day columns, day cells) are during a pointer gesture,\n * measured once at its start instead of on every move. The items scroll with the container, so\n * their boxes are kept from its corner and only the container follows the scroll.\n */\nexport default function useItemsLayout(\n containerRef: RefObject<HTMLElement | null>,\n /** The items by index, e.g. from `useRefList`; an unmounted one is `null`. */\n itemsRef: ItemsRef\n): ItemsLayout {\n const layout = useRefWithInit(createItemsLayout, { containerRef, itemsRef }).current;\n // a gesture cut short by unmounting stops observing the container\n useEffect(() => layout.release, [layout]);\n return layout;\n}\n\ntype ItemsRef = { readonly current: readonly (HTMLElement | null)[] };\n\ninterface ItemsLayoutSources {\n containerRef: RefObject<HTMLElement | null>;\n itemsRef: ItemsRef;\n}\n\nfunction createItemsLayout({ containerRef, itemsRef }: ItemsLayoutSources): ItemsLayout {\n let container: Rect | null = null;\n let items: (ItemBox | null)[] = [];\n // a container that changes size (a window resized, a phone turned) moves its items: measure again\n let resizeObserver: ResizeObserver | null = null;\n\n function take() {\n const element = containerRef.current;\n if (!element) return false;\n\n const rect = new Rect(getClientRect(element), element);\n container = rect;\n items = itemsRef.current.map((item) => {\n if (!item) return null;\n const { left, top, right, bottom } = item.getBoundingClientRect();\n return { left: left - rect.left, top: top - rect.top, right: right - rect.left, bottom: bottom - rect.top };\n });\n return true;\n }\n\n return {\n measure() {\n if (!take()) return false;\n if (typeof ResizeObserver !== \"undefined\" && containerRef.current) {\n resizeObserver ??= new ResizeObserver(() => {\n if (container) take();\n });\n resizeObserver.observe(containerRef.current);\n }\n return true;\n },\n release() {\n resizeObserver?.disconnect();\n container = null;\n items = [];\n },\n container: () => container,\n nearestIndex(x, y, axis = \"xy\") {\n if (!container) return -1;\n\n const left = x - container.left;\n const top = y - container.top;\n let best = -1;\n let bestDistance = Infinity;\n\n items.forEach((box, index) => {\n if (!box) return;\n const dx = left < box.left ? box.left - left : left >= box.right ? left - box.right : 0;\n const dy = axis === \"x\" ? 0 : top < box.top ? box.top - top : top >= box.bottom ? top - box.bottom : 0;\n const distance = Math.hypot(dx, dy);\n if (distance < bestDistance) {\n bestDistance = distance;\n best = index;\n }\n });\n\n return best;\n },\n };\n}\n","import type { Ref } from \"react\";\n\nconst toFnRef = <T>(ref?: Ref<T | null> | null) =>\n !ref || typeof ref === \"function\"\n ? ref\n : (value: T | null) => {\n (ref as { current: T | null }).current = value;\n };\n\nexport default function mergeRefs<T>(...refs: (Ref<T | null> | null | undefined)[]): Ref<T> {\n return (value: T | null) => {\n refs.forEach((ref) => {\n toFnRef(ref)?.(value);\n });\n };\n}\n","import { useMemo, type Ref } from \"react\";\n\nimport mergeRefs from \"../utils/mergeRefs\";\n\nfunction useMergedRefs<T>(...refs: (Ref<T> | undefined)[]) {\n // oxlint-disable-next-line react-hooks/exhaustive-deps, react-hooks/use-memo\n return useMemo(() => mergeRefs(...refs), refs);\n}\n\nexport default useMergedRefs;\n","import {\n useEffect,\n useMemo,\n useRef,\n useState,\n type DOMAttributes,\n type KeyboardEvent as ReactKeyboardEvent,\n type MouseEvent as ReactMouseEvent,\n type PointerEvent as ReactPointerEvent,\n type TouchEvent as ReactTouchEvent,\n type SyntheticEvent,\n} from \"react\";\n\nimport useGlobalListeners from \"./useGlobalListeners\";\n\nimport type { EventBase, MoveData, PointerCoordinates, PointerType, UseMoveParams } from \"./useMove.types\";\n\nexport default function useMove<Element extends HTMLElement = HTMLElement>(params: UseMoveParams) {\n const [{ state }] = useState<{ state: MoveData }>(() => ({\n state: {\n activePointId: null,\n clientX: 0,\n clientY: 0,\n initialClientX: 0,\n initialClientY: 0,\n isDistanceReached: false,\n holdTimer: null,\n isTouchActive: false,\n },\n }));\n\n const paramsRef = useRef(params);\n paramsRef.current = params;\n\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n\n useEffect(() => () => clearHold(state), [state]);\n\n const { listeners, ref } = useMemo(() => {\n const attr: DOMAttributes<Element> = {};\n\n const stopEvent = (e: SyntheticEvent) => {\n if (\"stopPropagation\" in e && \"preventDefault\" in e) {\n e.stopPropagation();\n e.preventDefault();\n }\n };\n\n const update = (coordinates: PointerCoordinates, pointerId?: number | null) => {\n const {\n current: { distance = 0, ...handlers },\n } = paramsRef;\n\n const { clientX, clientY } = coordinates;\n const { clientX: prevClientX, clientY: prevClientY } = state;\n\n // oxlint-disable-next-line react-hooks/immutability\n state.clientX = clientX;\n state.clientY = clientY;\n\n if (pointerId !== undefined) {\n state.activePointId = pointerId;\n }\n\n const getCommonEventData = (event: EventBase) => ({\n shiftKey: event.shiftKey,\n metaKey: event.metaKey,\n ctrlKey: event.ctrlKey,\n altKey: event.altKey,\n clientX,\n clientY,\n });\n\n return {\n start(pointerType: PointerType, event: EventBase): boolean | void {\n state.initialClientX = clientX;\n state.initialClientY = clientY;\n state.isDistanceReached = distance === 0;\n\n return handlers.onMoveStart({\n type: \"movestart\",\n pointerType,\n ...getCommonEventData(event),\n });\n },\n move(pointerType: PointerType, event: EventBase, deltaX?: number, deltaY?: number) {\n const initialDeltaX = clientX - state.initialClientX;\n const initialDeltaY = clientY - state.initialClientY;\n\n if (!state.isDistanceReached && initialDeltaX ** 2 + initialDeltaY ** 2 >= distance ** 2) {\n state.isDistanceReached = true;\n }\n\n if (state.isDistanceReached) {\n handlers.onMove({\n type: \"move\",\n pointerType,\n deltaX: deltaX ?? clientX - prevClientX,\n deltaY: deltaY ?? clientY - prevClientY,\n initialDeltaX,\n initialDeltaY,\n ...getCommonEventData(event),\n });\n }\n },\n end(pointerType: PointerType, event: EventBase) {\n handlers.onMoveEnd({\n type: \"moveend\",\n pointerType,\n ...getCommonEventData(event),\n });\n },\n };\n };\n\n if (typeof PointerEvent === \"undefined\") {\n const onMouseMove = (e: MouseEvent) => {\n if (e.button === 0) {\n update(e).move(\"mouse\", e);\n }\n };\n const onMouseUp = (e: MouseEvent) => {\n if (e.button === 0) {\n update(e).end(\"mouse\", e);\n }\n };\n\n attr.onMouseDown = (e: ReactMouseEvent) => {\n if (e.button === 0) {\n if (update(e).start(\"mouse\", e) !== false) {\n addGlobalListener(window, \"mousemove\", onMouseMove, false);\n addGlobalListener(window, \"mouseup\", onMouseUp, false);\n\n stopEvent(e);\n } else update(e, null);\n }\n };\n\n const onTouchMove = (e: TouchEvent) => {\n const touch = [...e.changedTouches].findIndex(({ identifier }) => identifier === state.activePointId);\n if (touch >= 0) {\n const trouchEvent = e.changedTouches[touch];\n // move\n update(trouchEvent).move(\"touch\", e);\n }\n };\n const onTouchEnd = (e: TouchEvent) => {\n const touch = [...e.changedTouches].findIndex(({ identifier }) => identifier === state.activePointId);\n if (touch >= 0) {\n // end\n update(e.changedTouches[touch], null).end(\"touch\", e);\n\n removeGlobalListener(window, \"touchmove\", onTouchMove, false);\n removeGlobalListener(window, \"touchend\", onTouchEnd);\n removeGlobalListener(window, \"touchcancel\", onTouchEnd);\n }\n };\n attr.onTouchStart = (e: ReactTouchEvent) => {\n if (e.changedTouches.length === 0 || state.activePointId !== null) {\n return;\n }\n\n const touch = e.changedTouches[0];\n\n if (update(touch, touch.identifier).start(\"touch\", e) !== false) {\n addGlobalListener(window, \"touchmove\", onTouchMove, false);\n addGlobalListener(window, \"touchend\", onTouchEnd, false);\n addGlobalListener(window, \"touchcancel\", onTouchEnd, false);\n\n stopEvent(e);\n } else update(touch, null);\n };\n } else {\n const removePointerListeners = () => {\n removeGlobalListener(window, \"pointermove\", onPointerMove, false);\n removeGlobalListener(window, \"pointerup\", onPointerUp, false);\n removeGlobalListener(window, \"pointercancel\", onPointerUp, false);\n };\n\n // a touch that has not held still for `touchDelay` yet: drop it and let the page scroll\n const releaseHold = () => {\n clearHold(state);\n removePointerListeners();\n update(state, null);\n };\n\n const onPointerMove = (e: PointerEvent) => {\n if (e.pointerId !== state.activePointId) {\n return;\n }\n\n if (state.holdTimer !== null) {\n const deltaX = e.clientX - state.initialClientX;\n const deltaY = e.clientY - state.initialClientY;\n\n if (deltaX ** 2 + deltaY ** 2 > TOUCH_HOLD_TOLERANCE ** 2) {\n releaseHold();\n } else {\n update(e);\n }\n return;\n }\n\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n update(e).move(pointerType, e);\n };\n\n const onPointerUp = (e: PointerEvent) => {\n if (e.pointerId !== state.activePointId) {\n return;\n }\n\n // lifted, or taken by the browser to scroll, before the hold: no gesture\n if (state.holdTimer !== null) {\n releaseHold();\n return;\n }\n\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n\n // oxlint-disable-next-line react-hooks/immutability\n state.isTouchActive = false;\n update(e, null).end(pointerType, e);\n removePointerListeners();\n };\n\n const startPointer = (pointerType: PointerType, event: EventBase) => {\n if (update(state).start(pointerType, event) === false) {\n return false;\n }\n\n // oxlint-disable-next-line react-hooks/immutability\n state.isTouchActive = pointerType === \"touch\";\n return true;\n };\n\n attr.onPointerDown = (e: ReactPointerEvent) => {\n if (e.button !== 0 || state.activePointId !== null) {\n return;\n }\n\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n const { touchDelay = 0 } = paramsRef.current;\n\n update(e, e.pointerId);\n\n if (pointerType === \"touch\" && touchDelay > 0) {\n // until the hold the touch may still be a scroll: the gesture starts after `touchDelay`\n // oxlint-disable-next-line react-hooks/immutability\n state.initialClientX = e.clientX;\n state.initialClientY = e.clientY;\n\n const event = e.nativeEvent;\n state.holdTimer = setTimeout(() => {\n state.holdTimer = null;\n\n if (!startPointer(pointerType, event)) {\n releaseHold();\n return;\n }\n\n // the hold has taken: a short buzz where it is supported (not iOS Safari)\n if (\"vibrate\" in navigator) {\n navigator.vibrate(HOLD_VIBRATION);\n }\n }, touchDelay);\n } else if (!startPointer(pointerType, e)) {\n update(e, null);\n return;\n }\n\n addGlobalListener(window, \"pointermove\", onPointerMove, false);\n addGlobalListener(window, \"pointerup\", onPointerUp, false);\n addGlobalListener(window, \"pointercancel\", onPointerUp, false);\n\n stopEvent(e);\n };\n\n // a long press opens the context menu on Android: not during a touch gesture\n attr.onContextMenu = (e: ReactMouseEvent) => {\n if (state.holdTimer !== null || state.isTouchActive) {\n e.preventDefault();\n }\n };\n }\n\n const triggerKeyboardMove = (e: ReactKeyboardEvent, deltaX: number, deltaY: number) => {\n const { start, move, end } = update({ clientX: 0, clientY: 0 });\n if (start(\"keyboard\", e)) {\n move(\"keyboard\", e, deltaX, deltaY);\n end(\"keyboard\", e);\n } else {\n update({ clientX: 0, clientY: 0 }, null);\n }\n };\n\n attr.onKeyDown = (e) => {\n switch (e.key) {\n case \"Left\":\n case \"ArrowLeft\":\n stopEvent(e);\n triggerKeyboardMove(e, -1, 0);\n break;\n case \"Right\":\n case \"ArrowRight\":\n stopEvent(e);\n triggerKeyboardMove(e, 1, 0);\n break;\n case \"Up\":\n case \"ArrowUp\":\n stopEvent(e);\n triggerKeyboardMove(e, 0, -1);\n break;\n case \"Down\":\n case \"ArrowDown\":\n stopEvent(e);\n triggerKeyboardMove(e, 0, 1);\n break;\n }\n };\n\n // a touch gesture follows the finger instead of scrolling: the listener has to be on the\n // element before the touch starts, else iOS sends its moves as not cancelable\n const preventTouchScroll = (e: Event) => {\n if (state.isTouchActive && e.cancelable) {\n e.preventDefault();\n }\n };\n\n const touch: { target: Element | null } = { target: null };\n const ref = (node: Element | null) => {\n if (touch.target) {\n removeGlobalListener(touch.target, \"touchmove\", preventTouchScroll);\n }\n\n touch.target = node;\n\n if (node) {\n addGlobalListener(node, \"touchmove\", preventTouchScroll, { passive: false });\n }\n };\n\n return { listeners: attr, ref };\n }, [addGlobalListener, removeGlobalListener, state]);\n\n return { listeners, ref };\n}\n\n/** Buzz when a touch hold starts a gesture, in milliseconds. */\nconst HOLD_VIBRATION = 10;\n\n/** How far a touch may drift while it holds for `touchDelay`, in pixels. */\nconst TOUCH_HOLD_TOLERANCE = 10;\n\nfunction clearHold(state: MoveData) {\n if (state.holdTimer !== null) {\n clearTimeout(state.holdTimer);\n state.holdTimer = null;\n }\n}\n","import { useEffect, useRef } from \"react\";\n\nexport default function usePrevious<T>(value: T): T | undefined {\n const ref = useRef<T>(undefined);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n\nexport function usePreviousWithInitial<T>(value: T): T {\n const ref = useRef<T>(value);\n\n useEffect(() => {\n ref.current = value;\n }, [value]);\n\n return ref.current;\n}\n","import useRefWithInit from \"./useRefWithInit\";\n\nexport interface RefList<T> {\n /** The mounted elements by index; an unmounted one is `null`. Read it in handlers, not in render. */\n readonly elements: { readonly current: readonly (T | null)[] };\n /** A callback ref that keeps the element at `index`, the same function for an index every render. */\n refAt: (index: number) => (node: T | null) => void;\n}\n\n/**\n * Refs to the elements of a rendered list: `<div ref={refAt(index)} />` for each item, then\n * `elements.current[index]` in an event handler.\n */\nexport default function useRefList<T extends Element>(): RefList<T> {\n return useRefWithInit(createRefList<T>).current;\n}\n\nfunction createRefList<T>(): RefList<T> {\n const elements: (T | null)[] = [];\n const refs = new Map<number, (node: T | null) => void>();\n\n return {\n elements: { current: elements },\n refAt(index) {\n let ref = refs.get(index);\n\n if (!ref) {\n ref = (node) => {\n elements[index] = node;\n };\n refs.set(index, ref);\n }\n\n return ref;\n },\n };\n}\n","import { startTransition, useState } from \"react\";\n\nimport { useIsomorphicLayoutEffect } from \"./useIsomorphicLayoutEffect\";\n\nimport type { ScrollbarMeasurements } from \"./useScrollBarSize.types\";\n\nfunction buildUseScrollbarSizeHook() {\n let element: HTMLElement | null = null;\n let count = 0;\n\n const elementFabric = (resizeCallback: () => void) => {\n count += 1;\n if (element === null) {\n // element was not created yet -- initialize\n element = document.createElement(\"div\");\n element.style.width = \"99px\";\n element.style.height = \"99px\";\n element.style.overflow = \"scroll\";\n element.style.position = \"absolute\";\n element.style.top = \"-9999px\";\n element.setAttribute(\"aria-hidden\", \"true\");\n element.setAttribute(\"role\", \"presentation\");\n\n document.body.appendChild(element);\n window.addEventListener(\"resize\", resizeCallback);\n }\n return {\n element,\n cleanup: () => {\n if (element && --count <= 0) {\n document.body.removeChild(element);\n window.removeEventListener(\"resize\", resizeCallback);\n element = null;\n count = 0;\n }\n },\n };\n };\n\n return function (): ScrollbarMeasurements {\n const [dimensions, setDimensions] = useState({ height: 0, width: 0 });\n\n // initialize resize event handler and state when mounted\n useIsomorphicLayoutEffect(() => {\n const updateState = () => {\n const scrollbarHeight = element.offsetHeight - element.clientHeight;\n const scrollbarWidth = element.offsetWidth - element.clientWidth;\n\n startTransition(() => {\n setDimensions((currentDimensions) => {\n const { height, width } = currentDimensions;\n return height !== scrollbarHeight || width !== scrollbarWidth\n ? { height: scrollbarHeight, width: scrollbarWidth }\n : currentDimensions;\n });\n });\n };\n\n const { element, cleanup } = elementFabric(updateState);\n\n // initialize\n updateState();\n\n // cleanup\n return cleanup;\n }, []);\n\n return dimensions;\n };\n}\n\nexport const useScrollBarSize = buildUseScrollbarSizeHook();\n","import { useCallback, useRef, useState } from \"react\";\n\n/**\n * State for rendering plus a ref to the same value for event handlers: the ref changes\n * at once, so handlers that run before the next render (pointer moves during a drag)\n * see the latest value.\n */\nexport default function useStateRef<T>(\n initialValue: T\n): [value: T, setValue: (next: T) => void, ref: { readonly current: T }] {\n const [value, setState] = useState(initialValue);\n const ref = useRef(initialValue);\n\n const setValue = useCallback((next: T) => {\n ref.current = next;\n setState(next);\n }, []);\n\n return [value, setValue, ref];\n}\n","import { useEffect, useRef } from \"react\";\n\nimport useCurrentRef from \"./useCurrentRef\";\n\nexport default function useTimeInterval(callback: () => void, interval: number, isActive = true) {\n const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);\n const callbackRef = useCurrentRef(callback);\n\n useEffect(() => {\n if (isActive) {\n // Get the current time\n const now = new Date();\n // Calculate how many milliseconds have passed in the current hour\n const timePassed = (now.getMinutes() * 60 + now.getSeconds()) * 1000;\n\n // Calculate the delay until the next 'n' minute mark\n const delay = interval - (timePassed % interval);\n\n timerRef.current = setTimeout(() => {\n callbackRef.current();\n timerRef.current = setInterval(callbackRef.current, interval);\n }, delay);\n\n callbackRef.current();\n }\n return () => {\n if (timerRef.current) {\n clearTimeout(timerRef.current);\n }\n };\n }, [callbackRef, interval, isActive]);\n}\n","import { useEffect, useState } from \"react\";\n\nimport type { CalendarDate, DateAdapter } from \"@weekwise/core\";\n\nimport { useCalendarDateUtils } from \"../date-localization\";\n\nconst startOfToday = (dateUtils: DateAdapter<CalendarDate>) => dateUtils.toMillis(dateUtils.getToday());\n\n/**\n * Start of today as a timestamp. Changes at midnight, so components that\n * depend on it (today's column, the now line, past-day limits) re-render\n * when the date rolls over, and with the adapter: in another time zone\n * today may already be another day.\n */\nexport default function useToday(): number {\n const dateUtils = useCalendarDateUtils();\n const [state, setState] = useState(() => ({ dateUtils, today: startOfToday(dateUtils) }));\n\n // another adapter (time zone): its today at once, not at the old zone's midnight\n let current = state;\n if (state.dateUtils !== dateUtils) {\n current = { dateUtils, today: startOfToday(dateUtils) };\n setState(current);\n }\n const { today } = current;\n\n useEffect(() => {\n // the next midnight in the adapter's time zone\n const nextMidnight = dateUtils.toMillis(dateUtils.addDays(dateUtils.fromMillis(today), 1));\n const delay = Math.max(nextMidnight - Date.now(), 0) + 1000;\n const timer = setTimeout(() => setState({ dateUtils, today: startOfToday(dateUtils) }), delay);\n return () => clearTimeout(timer);\n }, [dateUtils, today]);\n\n return today;\n}\n","import { createContext, useContext } from \"react\";\n\nimport type { CalendarContextValue } from \"../Calendar.types\";\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/**\n * DatePicker context.\n */\nconst CalendarContext = createContext<CalendarContextValue | undefined>(undefined);\n\nif (isDevEnvironment) {\n CalendarContext.displayName = \"CalendarContext\";\n}\n\nexport default CalendarContext;\n\nexport function useCalendarContext() {\n const context = useContext(CalendarContext);\n\n if (!context) {\n throw new Error(\"CalendarContext is required\");\n }\n\n return context;\n}\n","import { createContext } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/** The calendar's root element: portals copy its theme variables and font. */\nconst ThemeSourceContext = createContext<RefObject<HTMLElement | null> | null>(null);\n\nif (isDevEnvironment) {\n ThemeSourceContext.displayName = \"ThemeSourceContext\";\n}\n\nexport default ThemeSourceContext;\n","import { useCallback, useEffect, useRef } from \"react\";\n\nimport { useControlled, useCurrentRef, useEventCallback } from \"../hooks\";\nimport { getViewChangeTarget, isDevEnvironment, normalizeViewValue, resolveView, transferDay } from \"@weekwise/core\";\n\nimport type { CalendarView, UseCalendarValueParams } from \"../Calendar.types\";\n\nexport default function useCalendarValue<TDate>(params: UseCalendarValueParams<TDate>) {\n const {\n views,\n view,\n defaultView,\n startWeek,\n viewValue,\n defaultViewValue,\n dateUtils,\n onChangeView,\n onChangeViewValue,\n } = params;\n\n const [requestedView, setControlledView] = useControlled<CalendarView>({\n controlled: view,\n default: defaultView,\n initialState: \"week\",\n });\n // a view that is not offered shows as week, or the first view offered\n const controlledView = resolveView(views, requestedView);\n\n const isViewOffered = view === undefined || views.includes(view);\n useEffect(() => {\n if (isDevEnvironment && !isViewOffered) {\n console.warn(`Calendar: the ${view} view is not among the calendar's views; ${controlledView} is shown.`);\n }\n }, [controlledView, isViewOffered, view]);\n\n const calculateViewValue = useCallback(\n (view: CalendarView, viewValue?: TDate) => normalizeViewValue(dateUtils, view, viewValue, startWeek),\n [dateUtils, startWeek]\n );\n\n const [controlledViewValue, setControlledViewValue] = useControlled({\n controlled: viewValue,\n default: defaultViewValue,\n initialState: calculateViewValue(controlledView),\n });\n\n const changeViewValue = useEventCallback((newValue: TDate, view: CalendarView) => {\n setControlledViewValue(newValue);\n onChangeViewValue?.(newValue, view);\n });\n\n const changeView = useEventCallback((newView: CalendarView) => {\n if (!views.includes(newView)) return;\n setControlledView(newView);\n onChangeView?.(newView);\n });\n\n const currentViewValueRef = useCurrentRef(controlledViewValue);\n const previousViewRef = useRef(controlledView);\n const previousStartWeekRef = useRef(startWeek);\n const previousDateUtilsRef = useRef(dateUtils);\n useEffect(() => {\n const fromView = previousViewRef.current;\n const startWeekChanged = previousStartWeekRef.current !== startWeek;\n // another adapter (e.g. another time zone): keep the day the user saw\n const previousDateUtils = previousDateUtilsRef.current;\n const viewValue =\n previousDateUtils === dateUtils\n ? currentViewValueRef.current\n : transferDay(previousDateUtils, dateUtils, currentViewValueRef.current);\n previousViewRef.current = controlledView;\n previousStartWeekRef.current = startWeek;\n previousDateUtilsRef.current = dateUtils;\n // On a view switch, anchor on today / the middle of the week instead of the\n // first visible day, so week → month does not jump to the previous month.\n // A new first day of the week (e.g. another locale) re-anchors the same way:\n // the old first day may belong to the previous week under the new one.\n const nextValue =\n fromView === controlledView && !startWeekChanged\n ? calculateViewValue(controlledView, viewValue)\n : getViewChangeTarget(dateUtils, fromView, controlledView, viewValue, startWeek);\n changeViewValue(nextValue, controlledView);\n }, [calculateViewValue, changeViewValue, controlledView, currentViewValueRef, dateUtils, startWeek]);\n\n return {\n view: controlledView,\n viewValue: controlledViewValue,\n changeViewValue,\n changeView,\n };\n}\n","import { getNavigationTarget } from \"@weekwise/core\";\n\nimport { useEventCallback } from \"../hooks\";\n\nimport type { UseNavigationParams } from \"../Calendar.types\";\n\nexport default function useNavigation<TDate>(params: UseNavigationParams<TDate>) {\n const { dateUtils, view, viewValue, changeViewValue, startWeek } = params;\n\n const navigate = (from: TDate, direction: 1 | 0 | -1) => () =>\n changeViewValue(getNavigationTarget(dateUtils, view, from, direction, startWeek), view);\n\n return {\n goForward: useEventCallback(navigate(viewValue, 1)),\n goBackward: useEventCallback(navigate(viewValue, -1)),\n goToday: useEventCallback(navigate(dateUtils.getToday(), 0)),\n };\n}\n","import type { SVGProps } from \"react\";\n\nexport default function ChevronIcon(props: SVGProps<SVGSVGElement>) {\n return (\n <svg xmlns=\"http://www.w3.org/2000/svg\" fill=\"none\" height=\"12\" viewBox=\"0 0 13 12\" width=\"13\" {...props}>\n <path\n d=\"M1.77498 2.29504L6.35498 6.87504L10.945 2.29504L12.355 3.70504L6.35498 9.70504L0.35498 3.70504L1.77498 2.29504Z\"\n fill=\"currentColor\"\n />\n </svg>\n );\n}\n","import { useContext, useSyncExternalStore } from \"react\";\nimport { createPortal } from \"react-dom\";\nimport type { CSSProperties, ReactNode } from \"react\";\n\nimport { THEME_PROPERTIES } from \"@weekwise/core\";\n\nimport ThemeSourceContext from \"../contexts/ThemeSourceContext\";\n\nexport type PortalProps = {\n children?: ReactNode;\n container?: Element | DocumentFragment | null;\n};\n\nconst subscribe = () => () => {};\nconst getClientSnapshot = () => true;\nconst getServerSnapshot = () => false;\n\n/**\n * True only after hydration. During SSR and the hydrating render it is false,\n * so client-only output (portals) matches the server HTML.\n */\nexport function useIsHydrated() {\n return useSyncExternalStore(subscribe, getClientSnapshot, getServerSnapshot);\n}\n\n/** The theme variables and font of `source`, for content rendered outside it. */\nfunction readTheme(source: Element | null | undefined): CSSProperties {\n const theme: Record<string, string> = { display: \"contents\" };\n if (!source) {\n return theme;\n }\n\n const computed = getComputedStyle(source);\n for (const name of THEME_PROPERTIES) {\n const value = computed.getPropertyValue(name).trim();\n if (value) {\n theme[name === \"font-family\" ? \"fontFamily\" : name] = value;\n }\n }\n return theme;\n}\n\n/**\n * Renders into `container`, or into `document.body`. Content in the body does not\n * inherit the calendar's theme variables and font, so a `display: contents` wrapper\n * carries copies of them.\n */\nexport default function Portal({ children, container }: PortalProps) {\n const hydrated = useIsHydrated();\n const themeSource = useContext(ThemeSourceContext);\n\n if (!hydrated) {\n return null;\n }\n\n if (container) {\n return createPortal(children, container);\n }\n\n return createPortal(<div style={readTheme(themeSource?.current)}>{children}</div>, document.body);\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { autoUpdate, flip, offset, shift, useFloating } from \"@floating-ui/react-dom\";\nimport { useEffect, useMemo, useRef, useState } from \"react\";\nimport type { ButtonHTMLAttributes, ReactNode } from \"react\";\n\nimport { useCalendarDateUtils, useMessages } from \"../../date-localization\";\nimport { useGlobalListeners } from \"../../hooks\";\nimport ChevronIcon from \"../../icons/chevron\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport type { CalendarView } from \"../../Calendar.types\";\nimport Portal from \"../../portal\";\nimport { cx, formatMonthYear, getMonthGrid, getViewHeading, isInViewPeriod } from \"@weekwise/core\";\n\nimport styles from \"./DateNavigator.module.css\";\n\nexport type DateNavigatorProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n renderHeading?: (date: CalendarDate, view: CalendarView) => ReactNode;\n};\n\nexport default function DateNavigator({\n renderHeading,\n type = \"button\",\n onClick,\n onKeyDown,\n className,\n ...buttonProps\n}: DateNavigatorProps) {\n const { view, viewValue, changeViewValue, startWeek } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const messages = useMessages();\n const { getStartOfWeek, getStartOfMonth, addMonths } = dateUtils;\n\n const [open, setOpen] = useState(false);\n const [pickerMonth, setPickerMonth] = useState(() => getStartOfMonth(viewValue));\n const rootRef = useRef<HTMLDivElement | null>(null);\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n\n const { refs, floatingStyles } = useFloating({\n placement: \"bottom\",\n middleware: [offset(6), flip({ padding: 8 }), shift({ padding: 8 })],\n whileElementsMounted: autoUpdate,\n });\n\n useEffect(() => {\n if (open) {\n setPickerMonth(getStartOfMonth(viewValue));\n }\n }, [open, getStartOfMonth, viewValue]);\n\n useEffect(() => {\n if (!open) {\n return;\n }\n\n const handlePointerDown = (event: PointerEvent) => {\n const target = event.target as Node;\n const isInside = rootRef.current?.contains(target) || refs.floating.current?.contains(target);\n if (!isInside) {\n setOpen(false);\n }\n };\n\n addGlobalListener(document, \"pointerdown\", handlePointerDown);\n return () => removeGlobalListener(document, \"pointerdown\", handlePointerDown);\n }, [addGlobalListener, open, refs.floating, removeGlobalListener]);\n\n const heading = useMemo(\n () => (renderHeading ? renderHeading(viewValue, view) : getViewHeading(dateUtils, view, viewValue, startWeek)),\n [dateUtils, renderHeading, startWeek, view, viewValue]\n );\n\n const gridDays = useMemo(() => getMonthGrid(dateUtils, pickerMonth, startWeek), [dateUtils, pickerMonth, startWeek]);\n\n const handleToggleClick = (event: React.MouseEvent<HTMLButtonElement>) => {\n onClick?.(event);\n setOpen((prev) => !prev);\n };\n\n const handleToggleKeyDown = (event: React.KeyboardEvent<HTMLButtonElement>) => {\n onKeyDown?.(event);\n if (event.key === \"Escape\") {\n setOpen(false);\n }\n };\n\n const handleSelectDay = (day: CalendarDate) => {\n if (view === \"week\") {\n changeViewValue(getStartOfWeek(day, startWeek), view);\n } else {\n changeViewValue(day, view);\n }\n setOpen(false);\n };\n\n return (\n <div ref={rootRef} className={styles.root}>\n <button\n type={type}\n aria-label={messages.chooseDate}\n aria-expanded={open}\n aria-haspopup=\"dialog\"\n {...buttonProps}\n onClick={handleToggleClick}\n onKeyDown={handleToggleKeyDown}\n ref={refs.setReference}\n className={cx(className, styles.root__toggle)}\n >\n <span className={styles.root__toggleLabel}>{heading}</span>\n <ChevronIcon className={cx(styles.root__toggleIcon, { [styles.root__toggleIcon_open]: open })} />\n </button>\n\n {open && (\n <Portal>\n <div\n ref={refs.setFloating}\n style={floatingStyles}\n role=\"dialog\"\n aria-label={messages.chooseDate}\n className={styles.popover}\n >\n <div className={styles.popover__header}>\n <button\n type=\"button\"\n aria-label={messages.previousMonth}\n onClick={() => setPickerMonth((prev) => addMonths(prev, -1))}\n >\n <ChevronIcon className={styles.popover__navBackward} />\n </button>\n <div className={styles.popover__title}>{formatMonthYear(dateUtils, pickerMonth)}</div>\n <button\n type=\"button\"\n aria-label={messages.nextMonth}\n onClick={() => setPickerMonth((prev) => addMonths(prev, 1))}\n >\n <ChevronIcon className={styles.popover__navForward} />\n </button>\n </div>\n\n <div className={styles.popover__grid}>\n {gridDays.slice(0, 7).map((day) => (\n <div key={dateUtils.getWeekDay(day)} className={styles.popover__weekday}>\n {dateUtils.weekDayShortName(dateUtils.getWeekDay(day))}\n </div>\n ))}\n {gridDays.map((day, index) => {\n const isOutsideMonth = dateUtils.getMonths(day) !== dateUtils.getMonths(pickerMonth);\n const isToday = dateUtils.isToday(day);\n // Month view needs no band: the picker already shows that month.\n const isSelected = view !== \"month\" && isInViewPeriod(dateUtils, view, viewValue, day);\n const isRangeStart = isSelected && (view === \"day\" || index % 7 === 0);\n const isRangeEnd = isSelected && (view === \"day\" || index % 7 === 6);\n return (\n <button\n key={dateUtils.toMillis(day)}\n type=\"button\"\n onClick={() => handleSelectDay(day)}\n className={cx(styles.popover__day, {\n [styles.popover__day_outside]: isOutsideMonth,\n [styles.popover__day_today]: isToday,\n [styles.popover__day_selected]: isSelected,\n [styles.popover__day_rangeStart]: isRangeStart,\n [styles.popover__day_rangeEnd]: isRangeEnd,\n })}\n >\n {dateUtils.getMonthDay(day)}\n </button>\n );\n })}\n </div>\n </div>\n </Portal>\n )}\n </div>\n );\n}\n","import type { ButtonHTMLAttributes } from \"react\";\n\nimport ChevronIcon from \"../../icons/chevron\";\nimport { useEventCallback } from \"../../hooks\";\nimport { cx, mergeCallbacks } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useMessages } from \"../../date-localization\";\n\nimport styles from \"./NavBtn.module.css\";\n\nexport type NavBtnProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n direction?: \"forward\" | \"backward\";\n};\n\nexport default function NavBtn({\n direction = \"forward\",\n type = \"button\",\n onClick,\n className,\n children,\n ...props\n}: NavBtnProps) {\n const { goForward, goBackward } = useCalendarContext();\n const messages = useMessages();\n\n const handleClick = useEventCallback(\n mergeCallbacks(onClick, () => {\n if (direction === \"forward\") {\n goForward();\n } else if (direction === \"backward\") {\n goBackward();\n }\n })\n );\n\n return (\n <button\n type={type}\n aria-label={direction === \"forward\" ? messages.next : messages.previous}\n {...props}\n onClick={handleClick}\n className={cx(className, styles.root)}\n >\n {children ?? (\n <ChevronIcon\n className={cx(styles.root__icon, {\n [styles.root__icon_backward]: direction === \"backward\",\n [styles.root__icon_forward]: direction === \"forward\",\n })}\n />\n )}\n </button>\n );\n}\n","import { autoUpdate, flip, offset, shift, useFloating } from \"@floating-ui/react-dom\";\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport type { KeyboardEvent } from \"react\";\n\nimport { cx } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useMessages } from \"../../date-localization\";\nimport { useGlobalListeners } from \"../../hooks\";\nimport ChevronIcon from \"../../icons/chevron\";\nimport Portal from \"../../portal\";\nimport type { CalendarView } from \"../../Calendar.types\";\n\nimport styles from \"./ViewSelect.module.css\";\n\nexport type ViewSelectProps = { className?: string };\n\n/**\n * The view (among the calendar's views) as one button with a list: the view tabs of a calendar too\n * narrow for them.\n */\nexport default function ViewSelect({ className }: ViewSelectProps) {\n const { view, views, changeView } = useCalendarContext();\n const messages = useMessages();\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n const id = useId();\n\n const [open, setOpen] = useState(false);\n const [active, setActive] = useState(view);\n const optionRefs = useRef(new Map<CalendarView, HTMLDivElement>());\n\n const { refs, floatingStyles } = useFloating({\n placement: \"bottom-end\",\n middleware: [offset(6), flip({ padding: 8 }), shift({ padding: 8 })],\n whileElementsMounted: autoUpdate,\n });\n\n const close = (returnFocus: boolean) => {\n setOpen(false);\n const reference = refs.reference.current;\n if (returnFocus && reference instanceof HTMLElement) reference.focus();\n };\n\n const openList = (focused: CalendarView = view) => {\n setActive(focused);\n setOpen(true);\n };\n\n const select = (next: CalendarView) => {\n close(true);\n changeView(next);\n };\n\n // the active option has the focus while the list is open\n useEffect(() => {\n if (open) optionRefs.current.get(active)?.focus();\n }, [open, active]);\n\n useEffect(() => {\n if (!open) return;\n const handlePointerDown = (event: PointerEvent) => {\n const target = event.target as Node;\n const reference = refs.reference.current;\n const inside =\n (reference instanceof Node && reference.contains(target)) || refs.floating.current?.contains(target);\n if (!inside) setOpen(false);\n };\n addGlobalListener(document, \"pointerdown\", handlePointerDown);\n return () => removeGlobalListener(document, \"pointerdown\", handlePointerDown);\n }, [addGlobalListener, open, refs.floating, refs.reference, removeGlobalListener]);\n\n const handleToggleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n openList();\n }\n };\n\n const handleListKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const index = views.indexOf(active);\n const moveTo = (next: number) => {\n event.preventDefault();\n setActive(views[(next + views.length) % views.length] ?? active);\n };\n\n switch (event.key) {\n case \"ArrowDown\":\n return moveTo(index + 1);\n case \"ArrowUp\":\n return moveTo(index - 1);\n case \"Home\":\n return moveTo(0);\n case \"End\":\n return moveTo(views.length - 1);\n case \"Enter\":\n case \" \":\n event.preventDefault();\n return select(active);\n case \"Escape\":\n event.preventDefault();\n return close(true);\n case \"Tab\":\n return close(false);\n }\n };\n\n const listId = `${id}-list`;\n\n return (\n <>\n <button\n ref={refs.setReference}\n type=\"button\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listId : undefined}\n aria-label={`${messages.chooseView}: ${messages[view]}`}\n className={cx(className, styles.root)}\n onClick={() => (open ? close(false) : openList())}\n onKeyDown={handleToggleKeyDown}\n >\n {messages[view]}\n <ChevronIcon aria-hidden=\"true\" className={cx(styles.root__icon, { [styles.root__icon_open]: open })} />\n </button>\n\n {open && (\n <Portal>\n <div\n ref={refs.setFloating}\n id={listId}\n role=\"listbox\"\n aria-label={messages.chooseView}\n style={floatingStyles}\n className={styles.list}\n onKeyDown={handleListKeyDown}\n >\n {views.map((option) => (\n <div\n key={option}\n ref={(element) => {\n if (element) optionRefs.current.set(option, element);\n else optionRefs.current.delete(option);\n }}\n id={`${id}-${option}`}\n role=\"option\"\n tabIndex={-1}\n aria-selected={option === view}\n className={cx(styles.list__option, { [styles.list__option_active]: option === active })}\n onClick={() => select(option)}\n onPointerMove={() => setActive(option)}\n >\n {messages[option]}\n {option === view && (\n <svg aria-hidden=\"true\" className={styles.list__check} viewBox=\"0 0 16 16\" width=\"14\" height=\"14\">\n <path\n d=\"M3 8.5 6.5 12 13 4.5\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n )}\n </div>\n ))}\n </div>\n </Portal>\n )}\n </>\n );\n}\n","import type { ButtonHTMLAttributes, HTMLAttributes } from \"react\";\n\nimport { useEventCallback } from \"../../hooks\";\nimport { cx } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useMessages } from \"../../date-localization\";\nimport type { CalendarView } from \"../../Calendar.types\";\n\nimport DateNavigator from \"../date-navigator\";\nimport NavBtn from \"../nav-btn\";\nimport ViewSelect from \"../view-select\";\n\nimport styles from \"./CalendarToolbar.module.css\";\n\nexport type CalendarToolbarProps = HTMLAttributes<HTMLDivElement>;\n\nexport default function CalendarToolbar(props: CalendarToolbarProps) {\n const { goToday, changeView, view, views } = useCalendarContext();\n const messages = useMessages();\n\n const rootProps = props;\n\n const viewTabProps = (tab: CalendarView): ButtonHTMLAttributes<HTMLButtonElement> => ({\n type: \"button\",\n [\"aria-selected\"]: view === tab,\n onClick: () => changeView(tab),\n className: cx(styles.root__viewTab, { [styles.root__viewTab_isActive]: view === tab }),\n children: messages[tab],\n });\n\n const todayProps: ButtonHTMLAttributes<HTMLButtonElement> = {\n type: \"button\",\n onClick: useEventCallback(goToday),\n className: styles.root__today,\n children: messages.today,\n };\n\n return (\n <div {...rootProps} className={cx(rootProps.className, styles.root)}>\n <DateNavigator />\n\n <div className={styles.root__navigationPane} role=\"group\">\n <NavBtn direction=\"backward\" />\n <button {...todayProps} />\n <NavBtn direction=\"forward\" />\n </div>\n\n {/* a single view needs no switch */}\n {views.length > 1 && (\n <>\n <div className={styles.root__viewList}>\n {views.map((tab) => (\n <button key={tab} {...viewTabProps(tab)} />\n ))}\n </div>\n\n {/* in place of the tabs in a narrow calendar */}\n <div className={styles.root__viewSelect}>\n <ViewSelect />\n </div>\n </>\n )}\n </div>\n );\n}\n","import type { CalendarDate, CalendarView } from \"@weekwise/core\";\nimport { useEffect, useMemo, useRef } from \"react\";\nimport type { ComponentType } from \"react\";\n\nimport { useCalendarDateUtils } from \"./date-localization\";\nimport {\n buildEventMap,\n getViewList,\n getViewTimeStep,\n cx,\n formatTimelineRange,\n getEventTimeFrameFromInfo,\n getTimelineRange,\n TOUCH_HOLD_DELAY,\n} from \"@weekwise/core\";\nimport { useCalendarSize, useCurrentRef, useEventCallback, useMergedRefs } from \"./hooks\";\n\nimport CalendarContext from \"./contexts/CalendarContext\";\nimport ThemeSourceContext from \"./contexts/ThemeSourceContext\";\nimport { createDragAndDropApi } from \"@weekwise/dnd\";\nimport { DragAndDropContext } from \"@weekwise/dnd/react\";\nimport useRefWithInit from \"./hooks/useRefWithInit\";\nimport useCalendarValue from \"./hooks/useCalendarValue\";\nimport useNavigation from \"./hooks/useNavigation\";\n// the toolbar only: the views come from `views`, so that a bundle has only those given\nimport CalendarToolbar from \"./components/calendar-toolbar\";\n\nimport type { CalendarBaseProps, CalendarContextValue, EventChangeInfo, EventKey, EventMap } from \"./Calendar.types\";\n\nimport type { ViewDefinition } from \"./views/types\";\n\nimport styles from \"./Calendar.module.css\";\n\n/**\n * The calendar with the views you import: `views={{ week: weekView(), month: monthView() }}`.\n * Only the views given are offered, and only their code is in your bundle; `Calendar` is this\n * calendar with all three. Dates in its props and callbacks are of the adapter's type\n * (`TDate`); inside, they are opaque {@link CalendarDate}s that only the adapter reads or changes.\n */\nexport default function CalendarBase<TValue, TDate = Date>(publicProps: CalendarBaseProps<TValue, TDate>) {\n const props = publicProps as CalendarBaseProps<TValue, CalendarDate>;\n const {\n ref: forwardedRef,\n disabled = false,\n renderEvent: eventRenderer,\n views: viewsProp,\n hideMinMaxTime = false,\n timeFrame,\n startWeek: startWeekProp,\n timeStep: timeStepProp = 15,\n items,\n onEventCreate,\n onEventChange,\n onEventDelete,\n onEventEdit,\n eventTimeFrameResolver,\n eventKeyResolver,\n getIsDayDisabled,\n pointerPreviewFormat,\n scrollable = false,\n view: viewProp,\n defaultView: defaultViewProp,\n viewValue: viewValueProp,\n defaultViewValue: defaultViewValueProp,\n onChangeView: onChangeViewProp,\n onChangeViewValue: onChangeViewValueProp,\n ...restProps\n } = props;\n\n const { hourMax, hourMin } = { hourMin: 0, hourMax: 24, ...timeFrame };\n const resolversRef = useCurrentRef({\n eventTimeFrameResolver,\n eventKeyResolver,\n });\n const dateUtils = useCalendarDateUtils();\n const startWeek = startWeekProp ?? dateUtils.weekStartsOn;\n const rootRef = useRef<HTMLDivElement | null>(null);\n const handleRootRef = useMergedRefs(rootRef, forwardedRef);\n // the same list for the same views, though `views` is a new object each render\n const views = getViewList((name) => viewsProp[name] !== undefined);\n\n const { viewValue, changeViewValue, view, changeView } = useCalendarValue({\n views,\n view: viewProp,\n defaultView: defaultViewProp,\n viewValue: viewValueProp,\n defaultViewValue: defaultViewValueProp,\n onChangeView: onChangeViewProp,\n onChangeViewValue: onChangeViewValueProp,\n dateUtils,\n startWeek,\n });\n\n const timeStep = getViewTimeStep({ day: viewsProp.day?.options, week: viewsProp.week?.options }, view, timeStepProp);\n\n const size = useCalendarSize(rootRef);\n\n // pointer input: the page's cursors show while dragging, and every browser auto-scrolls alike;\n // and a touch drags an event after a long press, so a swipe still scrolls the calendar\n const dragAndDropApi = useRefWithInit(() =>\n createDragAndDropApi({ input: \"pointer\", touchDelay: TOUCH_HOLD_DELAY })\n ).current;\n\n const eventMap = useMemo<EventMap<TValue, CalendarDate>>(\n () => buildEventMap(items, resolversRef.current, dateUtils, { hourMin, hideMinMaxTime }),\n [dateUtils, hideMinMaxTime, hourMin, items, resolversRef]\n );\n\n const { goBackward, goForward, goToday } = useNavigation({\n changeViewValue,\n dateUtils,\n startWeek,\n view,\n viewValue,\n });\n\n const handleOnEventChange = useEventCallback((eventKey: EventKey, date: CalendarDate, info: EventChangeInfo) => {\n const item = eventMap.get(eventKey);\n if (item) {\n onEventChange?.(item.value, ...getEventTimeFrameFromInfo(dateUtils, date, info));\n }\n });\n\n const handleOnEventCreate = useEventCallback((date: CalendarDate, info: EventChangeInfo) => {\n onEventCreate?.(...getEventTimeFrameFromInfo(dateUtils, date, info));\n });\n\n const handleOnEventEdit = useEventCallback((eventKey: EventKey) => {\n const item = eventMap.get(eventKey);\n if (item) {\n onEventEdit?.(item.value);\n }\n });\n\n const handleOnEventDelete = useEventCallback((eventKey: EventKey) => {\n const item = eventMap.get(eventKey);\n if (item) {\n onEventDelete?.(item.value);\n }\n });\n\n const pointerPreviewRendererRef = useCurrentRef((date: CalendarDate, start: number, duration: number) => {\n const [from, to] = getTimelineRange(dateUtils, date, start, duration, {\n hourMin,\n hideMinMaxTime,\n });\n return pointerPreviewFormat ? pointerPreviewFormat(from, to) : formatTimelineRange(dateUtils, from, to);\n });\n\n const eventRendererRef = useCurrentRef(eventRenderer);\n\n useEffect(() => {\n if (rootRef.current) {\n return dragAndDropApi.getState().registerRootElement(rootRef.current);\n }\n }, [dragAndDropApi]);\n\n const rootProps = { ...restProps, ref: handleRootRef };\n\n // offered, as the view is among `views`; day and week share a component, so it stays mounted\n const activeView = viewsProp[view] as ViewDefinition<CalendarView, unknown> | undefined;\n if (!activeView) throw new Error(`CalendarBase: no ${view} view in views`);\n // its options are the ones it was made with\n const ActiveView = activeView.component as ComponentType<{ options: unknown }>;\n\n const contextValue = useMemo(\n () =>\n ({\n disabled,\n getIsDayDisabled,\n preventOutBoundsChanges: Boolean(timeFrame),\n changeView,\n changeViewValue,\n eventMap,\n goBackward,\n goForward,\n goToday,\n hideMinMaxTime,\n hourMax,\n hourMin,\n timeStep,\n scrollable,\n size,\n startWeek,\n view,\n views,\n viewValue,\n onEventCreate: handleOnEventCreate,\n onEventChange: handleOnEventChange,\n onEventDelete: handleOnEventDelete,\n onEventEdit: handleOnEventEdit,\n eventRenderer: eventRendererRef,\n pointerPreviewRenderer: pointerPreviewRendererRef,\n }) satisfies CalendarContextValue<TValue>,\n [\n disabled,\n pointerPreviewRendererRef,\n getIsDayDisabled,\n changeView,\n changeViewValue,\n eventMap,\n goBackward,\n goForward,\n goToday,\n hideMinMaxTime,\n hourMax,\n hourMin,\n scrollable,\n size,\n startWeek,\n timeStep,\n view,\n viewValue,\n handleOnEventCreate,\n handleOnEventChange,\n handleOnEventDelete,\n handleOnEventEdit,\n eventRendererRef,\n views,\n ]\n );\n\n return (\n <div\n {...rootProps}\n className={cx(rootProps.className, styles.root)}\n data-ww-size={size === \"regular\" ? undefined : size}\n >\n <CalendarContext.Provider value={contextValue as CalendarContextValue}>\n <DragAndDropContext.Provider value={dragAndDropApi}>\n <ThemeSourceContext.Provider value={rootRef}>\n <div className={styles.root__head}>\n <CalendarToolbar />\n </div>\n <div className={styles.root__body}>\n <ActiveView options={activeView.options} />\n </div>\n </ThemeSourceContext.Provider>\n </DragAndDropContext.Provider>\n </CalendarContext.Provider>\n </div>\n );\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport {\n fromDayMinutes,\n getTimeFrame,\n isPastDay,\n resizeEventRange,\n toDayMinutes,\n type DateAdapter,\n type EventChangeInfo,\n type EventKey,\n type EventMap,\n type TimeBounds,\n} from \"@weekwise/core\";\n\nimport useDocumentCursor from \"./useDocumentCursor\";\nimport useEventCallback from \"./useEventCallback\";\nimport useGlobalListeners from \"./useGlobalListeners\";\nimport useItemsLayout from \"./useItemsLayout\";\n\nconst DAY = 24 * 60;\n\nexport type ResizeEdge = \"top\" | \"bottom\";\n\n/** An event being resized: its range in wall-clock minutes from the first visible day. */\nexport interface ResizeState {\n key: EventKey;\n range: [number, number];\n /** Pointer position, for the time preview. */\n x: number;\n y: number;\n /** The pointer is where the edge cannot go; the last valid range stays. */\n blocked: boolean;\n}\n\ninterface ResizeSession {\n key: EventKey;\n edge: ResizeEdge;\n original: [number, number];\n range: [number, number];\n x: number;\n y: number;\n}\n\nexport interface EventResizeActions {\n start: (key: EventKey, edge: ResizeEdge, x: number, y: number) => void;\n move: (x: number, y: number) => void;\n end: () => void;\n}\n\ninterface UseEventResizeParams {\n days: CalendarDate[];\n viewportRef: RefObject<HTMLElement | null>;\n /** The day columns by day index, where the pointer picks the day. */\n columnsRef: { readonly current: readonly (HTMLElement | null)[] };\n dateUtils: DateAdapter<CalendarDate>;\n bounds: TimeBounds;\n timeStep: number;\n preventOutBoundsChanges: boolean;\n disabled: boolean;\n getIsDayDisabled?: (date: CalendarDate) => boolean;\n eventMap: EventMap<unknown, CalendarDate>;\n onEventChange: (key: EventKey, date: CalendarDate, info: EventChangeInfo) => void;\n}\n\n/**\n * Resizes an event by its top or bottom edge, into other days too (like macOS Calendar):\n * dragging the bottom edge into a later day ends the event there, the first day filling\n * to midnight. The view draws the event from {@link ResizeState} while it changes.\n */\nexport default function useEventResize(params: UseEventResizeParams) {\n const { days, viewportRef, columnsRef, dateUtils, bounds, timeStep, preventOutBoundsChanges } = params;\n const [state, setState] = useState<ResizeState | null>(null);\n const session = useRef<ResizeSession | null>(null);\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n // the timeline and its day columns, measured once a resize starts\n const layout = useItemsLayout(viewportRef, columnsRef);\n\n const paramsRef = useRef(params);\n paramsRef.current = params;\n\n const offset = bounds.hideMinMaxTime ? bounds.hourMin * 60 : 0;\n const timelineMinutes = bounds.hideMinMaxTime ? (bounds.hourMax - bounds.hourMin) * 60 : DAY;\n\n const update = useCallback(\n (x: number, y: number) => {\n const current = session.current;\n const viewport = layout.container();\n if (!current || !viewport) return;\n current.x = x;\n current.y = y;\n\n const { disabled, getIsDayDisabled } = paramsRef.current;\n const snap = (minute: number) => Math.round(minute / timeStep) * timeStep;\n const minute = snap(\n Math.min(Math.max(((y - viewport.top) / viewport.height) * timelineMinutes, 0), timelineMinutes)\n );\n\n // The column under the pointer, or the nearest one.\n const dayIndex = Math.max(layout.nearestIndex(x, y, \"x\"), 0);\n\n const next = resizeEventRange(\n { start: current.original[0], end: current.original[1] },\n current.edge,\n dayIndex,\n minute,\n {\n dayCount: days.length,\n bounds,\n timeStep,\n // An event across midnight passes hours a time frame leaves out.\n crossDays: !preventOutBoundsChanges || (bounds.hourMin <= 0 && bounds.hourMax >= 24),\n getFrame: (idx) => {\n if (!preventOutBoundsChanges) return [0, timelineMinutes];\n const [top, bottom] = getTimeFrame(dateUtils, days[idx], bounds);\n return [\n Math.ceil(top / timeStep) * timeStep,\n Math.min(Math.ceil(bottom / timeStep) * timeStep, timelineMinutes),\n ];\n },\n canEditDay: (idx) =>\n !disabled &&\n !getIsDayDisabled?.(days[idx]) &&\n !(preventOutBoundsChanges && isPastDay(dateUtils, days[idx])),\n }\n );\n if (next) current.range = next;\n setState({ key: current.key, range: current.range, x, y, blocked: !next });\n },\n [bounds, dateUtils, days, layout, preventOutBoundsChanges, timeStep, timelineMinutes]\n );\n\n // Auto-scroll moves the timeline under a still pointer: the layout follows, the time under the\n // pointer changes. Stable, so `end` removes the listener `start` added.\n const handleScroll = useEventCallback(() => {\n const current = session.current;\n if (current) update(current.x, current.y);\n });\n\n const actions = useMemo<EventResizeActions>(\n () => ({\n start(key, edge, x, y) {\n const event = paramsRef.current.eventMap.get(key);\n if (!event || !days[0] || !layout.measure()) return;\n const start = toDayMinutes(dateUtils, days[0], event.date);\n const original: [number, number] = [start, start + event.duration];\n session.current = { key, edge, original, range: original, x, y };\n addGlobalListener(document, \"scroll\", handleScroll, true);\n setState({ key, range: original, x, y, blocked: false });\n },\n move: update,\n end() {\n const current = session.current;\n // Auto-scroll may have moved the timeline since the last scroll event (Safari sends them with\n // the next frame): the range is taken from where the timeline is now.\n if (current) update(current.x, current.y);\n session.current = null;\n removeGlobalListener(document, \"scroll\", handleScroll, true);\n layout.release();\n setState(null);\n if (!current) return;\n const [start, end] = current.range;\n if (start === current.original[0] && end === current.original[1]) return;\n const dayIndex = Math.floor(start / DAY);\n paramsRef.current.onEventChange(current.key, fromDayMinutes(dateUtils, days[0], dayIndex * DAY), {\n from: start - dayIndex * DAY,\n duration: end - start,\n });\n },\n }),\n [addGlobalListener, dateUtils, days, handleScroll, layout, removeGlobalListener, update]\n );\n\n // Over a place the edge cannot go: \"not allowed\" cursor on the whole page.\n useDocumentCursor(state?.blocked ? \"not-allowed\" : null);\n\n /** Start of the range: its day and the timeline position in it, for the time preview. */\n const previewOf = (range: [number, number]) => {\n const dayIndex = Math.floor(range[0] / DAY);\n return {\n date: fromDayMinutes(dateUtils, days[0], dayIndex * DAY),\n top: range[0] - dayIndex * DAY - offset,\n duration: range[1] - range[0],\n };\n };\n\n return { state, actions, previewOf };\n}\n","import { createContext, useContext } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/**\n * Provides the calendar viewport element used to portal\n * drag overlays and position absolute transforms relative to.\n */\nexport type CalendarViewportContextValue = {\n viewportRef: RefObject<HTMLDivElement | null>;\n};\n\nconst CalendarViewportContext = createContext<CalendarViewportContextValue | undefined>(undefined);\n\nif (isDevEnvironment) {\n CalendarViewportContext.displayName = \"CalendarViewportContext\";\n}\n\nexport default CalendarViewportContext;\n\nexport function useCalendarViewportContext() {\n const context = useContext(CalendarViewportContext);\n\n if (!context) {\n throw new Error(\"CalendarViewportContext is required\");\n }\n\n return context;\n}\n","import { createContext, useContext } from \"react\";\n\nimport type { DayWeekViewContextValue } from \"../Calendar.types\";\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/**\n * DropTarget context.\n */\nconst DayWeekViewContext = createContext<DayWeekViewContextValue | undefined>(undefined);\n\nif (isDevEnvironment) {\n DayWeekViewContext.displayName = \"DayWeekViewContext\";\n}\n\nexport default DayWeekViewContext;\n\nexport function useDayWeekViewContext() {\n const context = useContext(DayWeekViewContext);\n\n if (!context) {\n throw new Error(\"DayWeekViewContext is required\");\n }\n\n return context;\n}\n","import { createContext, useContext } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/** The day column an event of the day/week view is drawn in. */\nexport type DayWeekDrawerContextValue = {\n /** The whole column: what an event resized in it is bounded by. */\n drawerRef: RefObject<HTMLDivElement | null>;\n /** The events' container, which their positions are relative to. */\n containerRef: RefObject<HTMLDivElement | null>;\n};\n\nconst DayWeekDrawerContext = createContext<DayWeekDrawerContextValue | undefined>(undefined);\n\nif (isDevEnvironment) {\n DayWeekDrawerContext.displayName = \"DayWeekDrawerContext\";\n}\n\nexport default DayWeekDrawerContext;\n\nexport function useDayWeekDrawerContext() {\n const context = useContext(DayWeekDrawerContext);\n\n if (!context) {\n throw new Error(\"DayWeekDrawerContext is required: render the event inside a DayWeekDrawer\");\n }\n\n return context;\n}\n","import { useCallback, useRef } from \"react\";\n\nexport function useInterval() {\n const intervalRef = useRef<number | null>(null);\n\n const set = useCallback((listener: (...args: any[]) => any, duration: number) => {\n intervalRef.current = setInterval(listener, duration);\n }, []);\n\n const clear = useCallback(() => {\n if (intervalRef.current !== null) {\n clearInterval(intervalRef.current);\n intervalRef.current = null;\n }\n }, []);\n\n return [set, clear] as const;\n}\n","import { useComputed, usePrevious } from \"../hooks\";\nimport type { Coordinates } from \"@weekwise/core\";\n\nexport enum ScrollDirection {\n Forward = 1,\n Backward = -1,\n}\n\ninterface ScrollIntent {\n x: Record<ScrollDirection, boolean>;\n y: Record<ScrollDirection, boolean>;\n}\n\nconst defaultScrollIntent: ScrollIntent = {\n x: { [ScrollDirection.Backward]: false, [ScrollDirection.Forward]: false },\n y: { [ScrollDirection.Backward]: false, [ScrollDirection.Forward]: false },\n};\n\nexport default function useScrollIntent({ delta, disabled }: { delta: Coordinates; disabled: boolean }): ScrollIntent {\n const previousDelta = usePrevious(delta);\n\n return useComputed<ScrollIntent>(\n (previousIntent) => {\n if (disabled || !previousDelta || !previousIntent) {\n // Reset scroll intent tracking when auto-scrolling is disabled\n return defaultScrollIntent;\n }\n\n const direction = {\n x: Math.sign(delta.x - previousDelta.x),\n y: Math.sign(delta.y - previousDelta.y),\n };\n\n // Keep track of the user intent to scroll in each direction for both axis\n return {\n x: {\n [ScrollDirection.Backward]: previousIntent.x[ScrollDirection.Backward] || direction.x === -1,\n [ScrollDirection.Forward]: previousIntent.x[ScrollDirection.Forward] || direction.x === 1,\n },\n y: {\n [ScrollDirection.Backward]: previousIntent.y[ScrollDirection.Backward] || direction.y === -1,\n [ScrollDirection.Forward]: previousIntent.y[ScrollDirection.Forward] || direction.y === 1,\n },\n };\n },\n [disabled, delta, previousDelta]\n );\n}\n","/* oxlint-disable react-hooks/exhaustive-deps */\nimport { useCallback, useEffect, useMemo, useRef } from \"react\";\n\nimport type { ClientRect, Coordinates } from \"@weekwise/core\";\n\nimport { getScrollDirectionAndSpeed } from \"@weekwise/core\";\nimport { useInterval } from \"./useInterval\";\nimport useScrollIntent, { type ScrollDirection as Direction } from \"./useScrollIntent\";\n\nenum AutoScrollActivator {\n Pointer,\n DraggableRect,\n}\n\nenum TraversalOrder {\n TreeOrder,\n ReversedTreeOrder,\n}\n\nexport function useAutoScroller(args: UseAutoScrollerParams) {\n const {\n acceleration,\n activator = AutoScrollActivator.Pointer,\n canScroll,\n enabled,\n interval = 5,\n pointerCoordinates,\n order = TraversalOrder.TreeOrder,\n delta,\n threshold,\n activeNodeRect,\n scrollableAncestors,\n scrollableAncestorsRects,\n } = args;\n\n const [setAutoScrollInterval, clearAutoScrollInterval] = useInterval();\n\n const scrollIntent = useScrollIntent({ delta, disabled: !enabled });\n const scrollSpeed = useRef<Coordinates>({ x: 0, y: 0 });\n const scrollDirection = useRef<ScrollDirection>({ x: 0, y: 0 });\n const scrollContainerRef = useRef<Element | null>(null);\n const sortedScrollableAncestorsWithRects = useMemo<[Element[], ClientRect[]]>(\n () =>\n order === TraversalOrder.TreeOrder\n ? [[...scrollableAncestors].reverse(), [...scrollableAncestorsRects].reverse()]\n : [[...scrollableAncestors], [...scrollableAncestorsRects]],\n [order, scrollableAncestors, scrollableAncestorsRects]\n );\n\n const rect = useMemo(() => {\n switch (activator) {\n case AutoScrollActivator.Pointer:\n return pointerCoordinates\n ? {\n top: pointerCoordinates.y,\n bottom: pointerCoordinates.y,\n left: pointerCoordinates.x,\n right: pointerCoordinates.x,\n }\n : null;\n case AutoScrollActivator.DraggableRect:\n return activeNodeRect;\n }\n }, [activator, activeNodeRect, pointerCoordinates]);\n\n const autoScroll = useCallback(() => {\n const scrollContainer = scrollContainerRef.current;\n\n if (!scrollContainer) {\n return;\n }\n\n const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;\n const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;\n\n scrollContainer.scrollBy(scrollLeft, scrollTop);\n }, []);\n\n useEffect(() => {\n const [scrollableAncestors, scrollableAncestorsRects] = sortedScrollableAncestorsWithRects;\n\n if (!enabled || !scrollableAncestors.length || !rect) {\n clearAutoScrollInterval();\n return;\n }\n\n for (const [index, scrollContainer] of scrollableAncestors.entries()) {\n if (!scrollContainer || canScroll?.(scrollContainer) === false) {\n continue;\n }\n\n const scrollContainerRect = scrollableAncestorsRects[index];\n\n if (!scrollContainerRect) {\n continue;\n }\n\n const { direction, speed } = getScrollDirectionAndSpeed(\n scrollContainer,\n scrollContainerRect,\n rect,\n acceleration,\n threshold\n );\n\n for (const axis of [\"x\", \"y\"] as const) {\n if (!scrollIntent[axis][direction[axis] as Direction]) {\n speed[axis] = 0;\n direction[axis] = 0;\n }\n }\n\n if (speed.x > 0 || speed.y > 0) {\n clearAutoScrollInterval();\n setAutoScrollInterval(autoScroll, interval);\n\n scrollContainerRef.current = scrollContainer;\n scrollSpeed.current = speed;\n scrollDirection.current = direction;\n return;\n }\n }\n\n scrollSpeed.current = { x: 0, y: 0 };\n scrollDirection.current = { x: 0, y: 0 };\n\n clearAutoScrollInterval();\n }, [\n acceleration,\n autoScroll,\n canScroll,\n enabled,\n interval,\n rect,\n scrollableAncestors,\n sortedScrollableAncestorsWithRects,\n threshold,\n clearAutoScrollInterval,\n setAutoScrollInterval,\n\n ...Object.entries(rect || {}),\n ...Object.entries(scrollIntent),\n ...Object.entries(threshold || {}),\n ]);\n}\n\ninterface UseAutoScrollerParams {\n enabled: boolean;\n pointerCoordinates: Coordinates | null;\n delta: Coordinates;\n acceleration?: number;\n activator?: AutoScrollActivator;\n canScroll?: CanScroll;\n interval?: number;\n activeNodeRect: ClientRect | null;\n scrollableAncestors: Element[];\n scrollableAncestorsRects: ClientRect[];\n layoutShiftCompensation?:\n | boolean\n | {\n x: boolean;\n y: boolean;\n };\n order?: TraversalOrder;\n threshold?: {\n x: number;\n y: number;\n };\n}\n\ninterface ScrollDirection {\n x: 0 | Direction;\n y: 0 | Direction;\n}\n\ntype CanScroll = (element: Element) => boolean;\n","import { useEffect, useMemo, useRef } from \"react\";\n\n/**\n * Returns a new MutationObserver instance.\n * If `MutationObserver` is undefined in the execution environment, returns `undefined`.\n */\nexport function useMutationObserver(cb: MutationCallback, disabled = false) {\n const cbRef = useRef(cb);\n cbRef.current = cb;\n\n const mutationObserver = useMemo(() => {\n if (disabled || typeof window === \"undefined\" || typeof window.MutationObserver === \"undefined\") {\n return undefined;\n }\n\n const { MutationObserver } = window;\n const { current: cb } = cbRef;\n return new MutationObserver(cb);\n }, [disabled]);\n\n useEffect(() => {\n return () => mutationObserver?.disconnect();\n }, [mutationObserver]);\n\n return mutationObserver;\n}\n","import { useReducer } from \"react\";\n\nimport { useIsomorphicLayoutEffect, useResizeObserver } from \"../hooks\";\nimport type { ClientRect } from \"@weekwise/core\";\nimport { shallowEqual } from \"@weekwise/core\";\n\nimport { getClientRect, isHTMLElement } from \"@weekwise/core\";\nimport { useMutationObserver } from \"./useMutationObserver\";\n\nexport default function useRect(\n element: HTMLElement | null,\n measure: (element: HTMLElement) => ClientRect = getClientRect,\n fallbackRect?: ClientRect | null\n) {\n const [rect, measureRect] = useReducer(reducer, null);\n\n const mutationObserver = useMutationObserver((records) => {\n if (!element) {\n return;\n }\n\n for (const record of records) {\n const { type, target } = record;\n\n if (type === \"childList\" && isHTMLElement(target) && target.contains(element)) {\n measureRect();\n break;\n }\n }\n });\n\n const resizeObserver = useResizeObserver(measureRect);\n\n useIsomorphicLayoutEffect(() => {\n measureRect();\n\n if (element) {\n resizeObserver?.observe(element);\n mutationObserver?.observe(document.body, { childList: true, subtree: true });\n } else {\n resizeObserver?.disconnect();\n mutationObserver?.disconnect();\n }\n }, [element, mutationObserver, resizeObserver]);\n\n return rect;\n\n function reducer(currentRect: ClientRect | null) {\n if (!element) {\n return null;\n }\n\n if (!element.isConnected) {\n // Fallback to last rect we measured if the element is\n // no longer connected to the DOM.\n return currentRect ?? fallbackRect ?? null;\n }\n\n const newRect = measure(element);\n\n if (shallowEqual(newRect, currentRect)) {\n return currentRect;\n }\n\n return newRect;\n }\n}\n","import { useEffect, useMemo, useRef } from \"react\";\n\nimport { getScrollableAncestors } from \"@weekwise/core\";\n\nconst defaultValue: Element[] = [];\n\nexport function useScrollableAncestors(node: HTMLElement | null, limit?: number) {\n const previousNode = useRef(node);\n\n const ancestors = useMemo<Element[]>(\n () => {\n if (!node) {\n return defaultValue;\n }\n\n return getScrollableAncestors(node, limit);\n },\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n [node, limit]\n );\n\n useEffect(() => {\n previousNode.current = node;\n }, [node]);\n\n return ancestors;\n}\n","import { useReducer } from \"react\";\n\nimport { useIsomorphicLayoutEffect, useResizeObserver } from \"../hooks\";\nimport type { ClientRect } from \"@weekwise/core\";\n\nimport { getClientRect, Rect } from \"@weekwise/core\";\nimport { getWindow } from \"@weekwise/core\";\n\nconst defaultValue: ClientRect[] = [];\n\nexport default function useScrollableAncestorsRects(elements: Element[], measure = getClientRect): ClientRect[] {\n const [rects, measureRects] = useReducer(reducer, defaultValue);\n const resizeObserver = useResizeObserver(measureRects);\n\n if (elements.length > 0 && rects === defaultValue) {\n measureRects();\n }\n\n useIsomorphicLayoutEffect(() => {\n if (elements.length) {\n elements.forEach((element) => resizeObserver?.observe(element));\n } else {\n resizeObserver?.disconnect();\n measureRects();\n }\n }, [elements, resizeObserver]);\n\n return rects;\n\n function reducer(): ClientRect[] {\n if (!elements.length) {\n return defaultValue;\n }\n\n return elements.map((element) => {\n if (element === document.scrollingElement) {\n const window = getWindow(element);\n const width = window.innerWidth;\n const height = window.innerHeight;\n\n return {\n top: 0,\n left: 0,\n right: width,\n bottom: height,\n width,\n height,\n };\n }\n\n return new Rect(measure(element), element);\n });\n }\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\n\nimport type { Coordinates } from \"@weekwise/core\";\nimport { isNotNull } from \"@weekwise/core\";\n\nimport { add, defaultCoordinates, getScrollableElement, getScrollCoordinates, getScrollOffsets } from \"@weekwise/core\";\n\ntype ScrollCoordinates = Map<HTMLElement | Window, Coordinates>;\n\nexport default function useScrollOffsets(elements: Element[]): Coordinates {\n const [scrollCoordinates, setScrollCoordinates] = useState<ScrollCoordinates | null>(null);\n const prevElements = useRef(elements);\n\n const handleScroll = useCallback((event: Event) => {\n const scrollingElement = getScrollableElement(event.target);\n\n if (!scrollingElement) {\n return;\n }\n\n setScrollCoordinates((scrollCoordinates) => {\n if (!scrollCoordinates) {\n return null;\n }\n\n scrollCoordinates.set(scrollingElement, getScrollCoordinates(scrollingElement));\n\n return new Map(scrollCoordinates);\n });\n }, []);\n\n useEffect(() => {\n const previousElements = prevElements.current;\n\n if (elements !== previousElements) {\n cleanup(previousElements);\n\n const entries = elements\n .map((element) => {\n const scrollableElement = getScrollableElement(element);\n\n if (scrollableElement) {\n scrollableElement.addEventListener(\"scroll\", handleScroll, {\n passive: true,\n });\n\n return [scrollableElement, getScrollCoordinates(scrollableElement)] as const;\n }\n\n return null;\n })\n .filter((entry): entry is [HTMLElement | (Window & typeof globalThis), Coordinates] => isNotNull(entry));\n\n setScrollCoordinates(entries.length ? new Map(entries) : null);\n\n prevElements.current = elements;\n }\n\n return () => {\n cleanup(elements);\n cleanup(previousElements);\n };\n\n function cleanup(elements: Element[]) {\n elements.forEach((element) => {\n const scrollableElement = getScrollableElement(element);\n if (scrollableElement) {\n scrollableElement.removeEventListener(\"scroll\", handleScroll);\n }\n });\n }\n }, [handleScroll, elements]);\n\n return useMemo(() => {\n if (elements.length) {\n return scrollCoordinates\n ? Array.from(scrollCoordinates.values()).reduce((acc, coordinates) => add(acc, coordinates), defaultCoordinates)\n : getScrollOffsets(elements);\n }\n\n return defaultCoordinates;\n }, [elements, scrollCoordinates]);\n}\n","import { useEffect, useRef, type DependencyList } from \"react\";\n\nimport { emptyArray } from \"@weekwise/core\";\nimport type { Coordinates } from \"@weekwise/core\";\n\nimport { defaultCoordinates, subtract } from \"@weekwise/core\";\n\nexport function useScrollOffsetsDelta(scrollOffsets: Coordinates, dependencies: DependencyList = emptyArray) {\n const initialScrollOffsets = useRef<Coordinates | null>(null);\n\n useEffect(\n () => {\n initialScrollOffsets.current = null;\n },\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n dependencies\n );\n\n useEffect(() => {\n const hasScrollOffsets = scrollOffsets !== defaultCoordinates;\n\n if (hasScrollOffsets && !initialScrollOffsets.current) {\n initialScrollOffsets.current = scrollOffsets;\n }\n\n if (!hasScrollOffsets && initialScrollOffsets.current) {\n initialScrollOffsets.current = null;\n }\n }, [scrollOffsets]);\n\n return initialScrollOffsets.current ? subtract(scrollOffsets, initialScrollOffsets.current) : defaultCoordinates;\n}\n","import { useMemo, useReducer } from \"react\";\n\nimport {\n add,\n adjustScrollRect,\n applyMoveTransformModifiers,\n match,\n type ClientRect,\n type Coordinates,\n type MoveTransform,\n type MoveTransformModifier,\n} from \"@weekwise/core\";\n\nimport { useAutoScroller } from \"./useAutoScroller\";\nimport useRect from \"./useRect\";\nimport { useScrollableAncestors } from \"./useScrollableAncestors\";\nimport useScrollableAncestorsRects from \"./useScrollableAncestorsRects\";\nimport useScrollOffsets from \"./useScrollOffsets\";\nimport { useScrollOffsetsDelta } from \"./useScrollOffsetsDelta\";\n\nexport type { MoveTransform, MoveTransformModifier };\n\nconst UseMoveTransformActionTypes = {\n Start: \"start\",\n Move: \"move\",\n Stop: \"stop\",\n} as const;\n\nconst defaultMoveTransformState: UseMoveTransformState = {\n isActive: false,\n initialTranslate: { x: 0, y: 0 },\n translate: { x: 0, y: 0 },\n delta: { x: 0, y: 0 },\n context: null,\n};\n\ntype UseMoveTransformActionTypes = (typeof UseMoveTransformActionTypes)[keyof typeof UseMoveTransformActionTypes];\n\nexport default function useMoveTransform<Context = unknown>({\n autoScrollEnabled = true,\n modifiers = [],\n activeNode = null,\n containerNode = null,\n}: UseMoveTranformParams<Context>): [\n UseMoveTransformResult<Context>,\n MoveActions<Context>,\n {\n pointerCoordinates: Coordinates;\n scrollAdjustmentActiveNodeRect: ClientRect | null;\n scrollAdjustmentContainerNodeRect: ClientRect | null;\n },\n] {\n const [state, dispatch] = useReducer(defaultMoveTransformReducer, defaultMoveTransformState);\n const resolvedActiveNode = typeof activeNode === \"function\" ? activeNode(state.context as Context) : activeNode;\n const resolvedContainerNode =\n typeof containerNode === \"function\" ? containerNode(state.context as Context) : containerNode;\n // to get valid initial rect pass active node only if moving started\n const activeNodeRect = useRect(state.isActive ? resolvedActiveNode : null);\n const containerNodeRect = useRect(state.isActive ? resolvedContainerNode : null);\n const scrollableAncestors = useScrollableAncestors(state.isActive ? resolvedActiveNode : null);\n\n const scrollableAncestorsRects = useScrollableAncestorsRects(scrollableAncestors);\n const scrollOffsets = useScrollOffsets(scrollableAncestors);\n // Represents the scroll delta since moving was initiated\n const scrollAdjustment = useScrollOffsetsDelta(scrollOffsets);\n\n const actions = useMemo(() => {\n const buildAction = <T extends UseMoveTransformActionTypes>(type: T): ContextCallback<T, Context> => {\n return (coordinates: Coordinates, context?: Context) => {\n dispatch({ type: type, coordinates, context });\n };\n };\n\n return {\n start: buildAction(UseMoveTransformActionTypes.Start),\n move: buildAction(UseMoveTransformActionTypes.Move),\n stop: buildAction(UseMoveTransformActionTypes.Stop),\n };\n }, []);\n\n const pointerCoordinates = add(state.initialTranslate, state.translate);\n\n useAutoScroller({\n // the delta between initial translate coordinates\n delta: state.translate,\n enabled: autoScrollEnabled && state.isActive,\n activeNodeRect,\n pointerCoordinates,\n scrollableAncestors,\n scrollableAncestorsRects,\n });\n\n const scrollAdjustmentTranslate = add(state.translate, scrollAdjustment);\n const scrollAdjustmentActiveNodeRect = adjustScrollRect(activeNodeRect, scrollAdjustment);\n const scrollAdjustmentContainerNodeRect = adjustScrollRect(containerNodeRect, scrollAdjustment);\n\n const transform: MoveTransform = applyMoveTransformModifiers(modifiers, {\n // the delta between previous translate coordinates\n delta: state.delta,\n transform: {\n ...state.translate,\n left: state.translate.x,\n top: state.translate.y,\n height: activeNodeRect?.height || 0,\n width: activeNodeRect?.width || 0,\n },\n context: state.context as Context,\n activeNodeRect,\n containerNodeRect,\n translate: scrollAdjustmentTranslate,\n initialTranslate: state.initialTranslate,\n });\n\n return [\n {\n context: state.context as Context,\n // activate only on start moving\n isActive: state.currentAction === \"move\",\n transform,\n translate: state.translate,\n initialTranslate: state.initialTranslate,\n containerNodeRect,\n activeNodeRect,\n delta: state.delta,\n },\n actions,\n { pointerCoordinates, scrollAdjustmentActiveNodeRect, scrollAdjustmentContainerNodeRect },\n ];\n}\n\nfunction defaultMoveTransformReducer(state: UseMoveTransformState, action: UseMoveTransformActions) {\n const reducer: UseMoveTranformReducer = {\n [UseMoveTransformActionTypes.Start]: (state, { coordinates, context }) => {\n return {\n ...state,\n isActive: true,\n currentAction: UseMoveTransformActionTypes.Start,\n initialTranslate: { ...coordinates },\n context,\n };\n },\n [UseMoveTransformActionTypes.Move]: (state, { coordinates }) => {\n return {\n ...state,\n currentAction: UseMoveTransformActionTypes.Move,\n translate: {\n x: coordinates.x - state.initialTranslate.x,\n y: coordinates.y - state.initialTranslate.y,\n },\n delta: {\n x: coordinates.x - (state.translate.x + state.initialTranslate.x),\n y: coordinates.y - (state.translate.y + state.initialTranslate.y),\n },\n };\n },\n [UseMoveTransformActionTypes.Stop]: () => {\n return { ...defaultMoveTransformState, currentAction: UseMoveTransformActionTypes.Stop };\n },\n };\n\n return match(action.type, reducer, state, action);\n}\n\ntype ContextCallback<\n Type extends UseMoveTransformActionTypes,\n Context = unknown,\n> = Type extends typeof UseMoveTransformActionTypes.Start\n ? (newCoordinates: Coordinates, context?: Context) => void\n : (newCoordinates: Coordinates) => void;\n\ninterface UseMoveTranformParams<Context> {\n modifiers?: MoveTransformModifier<Context>[];\n activeNode?: ((context: Context | null) => HTMLElement | null) | HTMLElement | null;\n containerNode?: ((context: Context | null) => HTMLElement | null) | HTMLElement | null;\n autoScrollEnabled?: boolean;\n}\n\ninterface MoveActions<Context = unknown> {\n /**\n * Starts the move transform\n * @param newCoordinates The new coordinates\n * @param context The context of execution\n * @returns void\n */\n start: (newCoordinates: Coordinates, context?: Context) => void;\n /**\n * Moves the move transform\n * @param newCoordinates The new coordinates\n * @returns void\n */\n move: (newCoordinates: Coordinates) => void;\n /**\n * Stops the move transform\n * @param newCoordinates The new coordinates\n * @returns void\n */\n stop: (newCoordinates: Coordinates) => void;\n}\n\ninterface UseMoveTransformResult<Context = unknown> {\n /**\n * Whether the move transform is active\n */\n isActive: boolean;\n /**\n * The current move transform\n */\n transform: MoveTransform;\n /**\n * The context of the current move transform\n */\n context: Context;\n /**\n * The current translate coordinates\n */\n translate: Coordinates;\n /**\n * The initial translate coordinates\n */\n initialTranslate: Coordinates;\n /**\n * The delta between previous translate coordinates\n */\n delta: Coordinates;\n /**\n * The actions of the move transform\n */\n activeNodeRect: ClientRect | null;\n /**\n * The actions of the move transform\n */\n containerNodeRect: ClientRect | null;\n /**\n * The actions of the move transform\n */\n}\n\ninterface UseMoveTransformState<Context = unknown> {\n /**\n * Whether the move transform is active\n */\n isActive: boolean;\n /**\n * Current action\n */\n currentAction?: UseMoveTransformActionTypes;\n /**\n * Initial translate coordinates\n */\n initialTranslate: Coordinates;\n /**\n * Delta between initial translate coordinates\n */\n translate: Coordinates;\n /**\n * Delta between previous translate coordinates\n */\n delta: Coordinates;\n /**\n * Current context of the action\n */\n context: Context | null;\n}\n\ntype UseMoveTransformActions =\n | {\n type: typeof UseMoveTransformActionTypes.Start;\n coordinates: Coordinates;\n context?: unknown;\n }\n | {\n type: typeof UseMoveTransformActionTypes.Move;\n coordinates: Coordinates;\n }\n | {\n type: typeof UseMoveTransformActionTypes.Stop;\n coordinates: Coordinates;\n };\n\ntype UseMoveTranformReducer = {\n [P in UseMoveTransformActionTypes]: (\n state: UseMoveTransformState,\n action: Extract<UseMoveTransformActions, { type: P }>\n ) => UseMoveTransformState;\n};\n","import { useMemo, useState } from \"react\";\n\nimport { getNowOffset } from \"@weekwise/core\";\n\nimport { useCalendarDateUtils } from \"../date-localization\";\nimport { useTimeInterval } from \"../hooks\";\n\nimport { useCalendarContext } from \"../contexts/CalendarContext\";\n\n/** Minutes from the timeline's start to now, and whether now is outside it. */\nexport default function useTimeOffset(isActive = true, interval = 1000 * 60): [number, boolean] {\n const { hideMinMaxTime, hourMin, hourMax } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n\n // Starts unset and ticks after mount: the server (or a static prerender) ran at a\n // different time, so computing it during the first render would make the hydrating\n // render differ from the server HTML.\n const [tick, setTick] = useState<number | null>(null);\n\n useTimeInterval(() => setTick(Date.now()), interval, isActive);\n\n // every minute, and at once for another adapter (time zone) or other hours\n return useMemo<[number, boolean]>(\n () => (tick === null ? [0, true] : getNowOffset(dateUtils, { hourMin, hourMax, hideMinMaxTime })),\n [tick, dateUtils, hourMin, hourMax, hideMinMaxTime]\n );\n}\n","import type { HTMLAttributes } from \"react\";\n\nimport { cx } from \"@weekwise/core\";\nimport type { Coordinates } from \"@weekwise/core\";\n\nimport styles from \"./PointerPopover.module.css\";\n\nexport type PointerPopoverProps = HTMLAttributes<HTMLSpanElement> & {\n coordinates?: Coordinates;\n};\n\nexport default function PointerPopover({ coordinates, className, style, ...props }: PointerPopoverProps) {\n return (\n <span\n tabIndex={-1}\n {...props}\n className={cx(className, styles.root)}\n style={{\n ...style,\n ...(coordinates\n ? {\n top: `calc(${coordinates.y}px + 20px)`,\n left: `calc(${coordinates.x}px + 20px)`,\n }\n : null),\n }}\n />\n );\n}\n","import { useEffect, useMemo, useRef } from \"react\";\nimport type { DetailedHTMLProps, HTMLAttributes } from \"react\";\n\nimport { useCalendarDateUtils } from \"../../date-localization\";\nimport { useMergedRefs, useMove, useToday } from \"../../hooks\";\nimport type { TextDropItem } from \"@weekwise/dnd\";\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\n\nimport type { CalendarDate } from \"@weekwise/core\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport DayWeekDrawerContext from \"../../contexts/DayWeekDrawerContext\";\nimport { useDayWeekViewContext } from \"../../contexts/DayWeekViewContext\";\nimport useMoveTransform from \"../../hooks/useMoveTransform\";\nimport useTimeOffset from \"../../hooks/useTimeOffset\";\nimport Portal from \"../../portal\";\nimport {\n boundingResizableContainerModifier,\n cx,\n formatNowOffset,\n getTimeStepEqualizerModifier,\n toDayMinutes,\n TOUCH_HOLD_DELAY,\n} from \"@weekwise/core\";\n\nimport PointerPopover from \"../pointer-popover\";\nimport type { DayWeekDragItem, DayWeekViewDropTargetData } from \"../day-week-view\";\nimport type { CSSVarStyle } from \"../../utils/css\";\n\nimport styles from \"./DayWeekDrawer.module.css\";\n\nexport type DayWeekDrawerProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {\n /**\n * Associated to the drawer date\n */\n targetDate: CalendarDate;\n};\n\nexport default function DayWeekDrawer(props: DayWeekDrawerProps) {\n const { ref: forwardedRef, targetDate, children, ...rootProps } = props;\n\n const { onEventChange, onEventCreate, getIsDayDisabled, pointerPreviewRenderer, eventMap, ...options } =\n useCalendarContext();\n const { viewportRef, getTimeFrame, pxPerMinute } = useDayWeekViewContext();\n const { hideMinMaxTime, preventOutBoundsChanges, timeStep, hourMin, hourMax, disabled } = options;\n const dateUtils = useCalendarDateUtils();\n const { isBefore, isToday } = dateUtils;\n // Transforms are in pixels and an hour row is shorter than 60px in a compact calendar:\n // snap to a time step on screen, read pixels as minutes only for times.\n const stepPx = timeStep * pxPerMinute;\n const toMinutes = (px: number) => toTimelineMinutes(px, pxPerMinute, timeStep);\n const getTimeFramePx = (date: CalendarDate) => getTimeFrame(date).map((x) => x * pxPerMinute) as [number, number];\n\n const rootRef = useRef<HTMLDivElement>(null);\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n const { register, getTransform } = useDragAndDrop(({ registerDropTarget, getTransform }) => ({\n register: registerDropTarget,\n getTransform: getTransform,\n }));\n\n const today = useToday();\n const todayOrPast = useMemo(() => {\n const isTodayFlag = isToday(targetDate);\n\n return {\n isToday: isTodayFlag,\n isPast: isBefore(targetDate) && !isTodayFlag,\n };\n // `today` re-evaluates the flags when the date rolls over at midnight\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [isBefore, isToday, targetDate, today]);\n\n const [{ isActive, transform }, actions, { scrollAdjustmentActiveNodeRect: resizingActiveNodeRect }] =\n useMoveTransform({\n activeNode: rootRef.current,\n // the drawer fills its day column\n containerNode: rootRef.current,\n modifiers: [\n // here activeNodeRect is used as containerRect\n function resizeSpotlightModifier({ activeNodeRect, initialTranslate, translate, transform }) {\n if (!activeNodeRect) {\n return transform;\n }\n\n const offsetY = initialTranslate.y - activeNodeRect.top;\n transform.x = transform.left + initialTranslate.x;\n transform.y = transform.top + initialTranslate.y;\n transform.top = Math.floor(offsetY / stepPx) * stepPx;\n transform.height = stepPx;\n transform.left = 0;\n transform.width = activeNodeRect.width;\n\n let compensation: number;\n if (translate.y > 0) {\n compensation = stepPx - (offsetY % stepPx);\n transform.height = Math.ceil((transform.height + translate.y - compensation) / stepPx) * stepPx;\n } else {\n compensation = offsetY % stepPx;\n transform.height = Math.ceil((transform.height - translate.y - compensation) / stepPx) * stepPx;\n transform.top -= transform.height - stepPx;\n }\n\n transform.height = Math.max(transform.height, stepPx);\n\n return transform;\n },\n function resizeContainerModifier({ transform }) {\n if (!preventOutBoundsChanges) {\n return transform;\n }\n\n const [bottomEdge, topEdge] = getTimeFrame(targetDate).map((x) => Math.ceil(x / timeStep) * stepPx);\n\n // restrict top\n if (transform.top < bottomEdge) {\n transform.height = Math.max(transform.height - (bottomEdge - transform.top), stepPx);\n transform.top = bottomEdge;\n }\n\n // restrict bottom\n if (transform.height + transform.top >= topEdge) {\n transform.height = Math.max(topEdge - transform.top, stepPx);\n }\n\n return transform;\n },\n boundingResizableContainerModifier,\n getTimeStepEqualizerModifier(stepPx),\n ],\n });\n\n const [timeOffset, offLimits] = useTimeOffset(todayOrPast.isToday);\n\n useEffect(() => {\n const dropTargetElement = rootRef.current;\n\n if (!dropTargetElement) {\n return;\n }\n\n const dropTargetData: DayWeekViewDropTargetData = { date: targetDate };\n return register(dropTargetElement, {\n data: dropTargetData,\n onDrop: async (e) => {\n const [eventData] = await Promise.all(\n e.items\n .filter(\n (item): item is TextDropItem => item.kind === \"text\" && item.types.has(\"event\") && \"getText\" in item\n )\n .map(async (item) => {\n const data = await item.getText(\"event\");\n return JSON.parse(data) as DayWeekDragItem;\n })\n );\n\n const transform = getTransform();\n const top = toTimelineMinutes(transform.top, pxPerMinute, timeStep);\n const height = toTimelineMinutes(transform.height, pxPerMinute, timeStep);\n const offset = hideMinMaxTime ? hourMin * 60 : 0;\n const event = eventMap.get(eventData.key);\n\n // An event across midnight was dragged by one of its days: it keeps its length,\n // and its start lands where the grabbed part's start was dropped.\n const startOfEvent = event ? toDayMinutes(dateUtils, event.date, event.date) : 0;\n if (event && startOfEvent + event.duration > 24 * 60) {\n // It passes hours a time frame leaves out: only a frame of the whole day allows it.\n if (preventOutBoundsChanges && (hourMin > 0 || hourMax < 24)) {\n actions.stop({ x: e.x, y: e.y });\n return;\n }\n const partDay = dateUtils.getStartOfDay(dateUtils.fromMillis(eventData.date));\n const grabbedStart = toDayMinutes(dateUtils, event.date, partDay) + offset + eventData.start;\n const fromStart = grabbedStart - startOfEvent;\n const start = offset + top - fromStart;\n const dayShift = Math.floor(start / (24 * 60));\n onEventChange(eventData.key, dateUtils.addDays(targetDate, dayShift), {\n from: start - dayShift * 24 * 60,\n duration: event.duration,\n });\n } else if (hideMinMaxTime) {\n onEventChange(eventData.key, targetDate, {\n from: top + hourMin * 60,\n duration: height,\n });\n } else {\n onEventChange(eventData.key, targetDate, {\n from: top,\n duration: height,\n });\n }\n\n actions.stop({ x: e.x, y: e.y });\n },\n getDropOperationForPoint: (types, allowedOperations) => {\n if (disabled || !types.has(\"event\")) return \"cancel\";\n\n if (getIsDayDisabled && getIsDayDisabled(targetDate)) {\n return \"cancel\";\n }\n\n const { isPast, isToday } = todayOrPast;\n\n if (preventOutBoundsChanges) {\n if (!isToday && isPast) {\n return \"cancel\";\n }\n\n const [top, bottom] = getTimeFrame(targetDate).map((x) => x * pxPerMinute);\n\n const transform = getTransform();\n if (transform.y < top || transform.y > bottom || (isToday && transform.height > bottom - top)) {\n return \"cancel\";\n }\n }\n\n return allowedOperations[0];\n },\n });\n }, [\n actions,\n dateUtils,\n disabled,\n eventMap,\n getIsDayDisabled,\n getTimeFrame,\n getTransform,\n hideMinMaxTime,\n hourMax,\n hourMin,\n onEventChange,\n preventOutBoundsChanges,\n pxPerMinute,\n register,\n targetDate,\n timeStep,\n todayOrPast,\n ]);\n\n const { listeners: moveListeners, ref: moveRef } = useMove({\n distance: Math.max(Math.min(5, timeStep), 1),\n // a finger scrolls the calendar: a long press creates an event, as in mobile calendars\n touchDelay: TOUCH_HOLD_DELAY,\n onMoveStart: (e) => {\n if (disabled) {\n return;\n }\n\n if (preventOutBoundsChanges) {\n const { isToday, isPast } = todayOrPast;\n\n if (isPast && !isToday) {\n return false;\n }\n }\n\n actions.start({ x: e.clientX, y: e.clientY });\n\n // a long press has started: show the slot under the finger before it moves\n if (e.pointerType === \"touch\") {\n actions.move({ x: e.clientX, y: e.clientY });\n }\n },\n onMove: (e) => {\n if (isActive) {\n actions.move({ x: e.clientX, y: e.clientY });\n return;\n }\n\n if (!resizingActiveNodeRect) {\n return;\n }\n\n if (preventOutBoundsChanges) {\n const [bottomEdge, topEdge] = getTimeFramePx(targetDate);\n const currentTop = e.clientY - resizingActiveNodeRect.top;\n\n if (currentTop < bottomEdge || currentTop > topEdge) {\n actions.stop({ x: e.clientX, y: e.clientY });\n return;\n }\n }\n\n if (!isActive) {\n actions.move({ x: e.clientX, y: e.clientY });\n }\n },\n onMoveEnd: (e) => {\n actions.stop({ x: e.clientX, y: e.clientY });\n\n if (!isActive) {\n return;\n }\n\n if (hideMinMaxTime) {\n onEventCreate(targetDate, {\n from: toMinutes(transform.top) + hourMin * 60,\n duration: toMinutes(transform.height),\n });\n } else {\n onEventCreate(targetDate, {\n from: toMinutes(transform.top),\n duration: toMinutes(transform.height),\n });\n }\n },\n });\n\n const drawerContextValue = useMemo(() => ({ drawerRef: rootRef, containerRef }), []);\n\n const handleRootRef = useMergedRefs<HTMLDivElement>(rootRef, moveRef, forwardedRef);\n\n const timeOffsetTitle = formatNowOffset(dateUtils, timeOffset, { hourMin, hideMinMaxTime });\n\n const renderPreview = () => {\n return pointerPreviewRenderer.current?.(targetDate, toMinutes(transform.top), toMinutes(transform.height));\n };\n\n return (\n <div\n {...rootProps}\n {...moveListeners}\n ref={handleRootRef}\n className={cx(rootProps.className, styles.root, {\n [styles.root_timeLimit]: preventOutBoundsChanges,\n [styles.root_isToday]: todayOrPast.isToday,\n [styles.root_isPast]: todayOrPast.isPast,\n [styles.root_offLimits]: offLimits,\n })}\n style={\n {\n ...rootProps.style,\n // minutes on the timeline, in pixels: an hour row is shorter in a compact calendar\n [\"--offset\"]: timeOffset * pxPerMinute,\n } as CSSVarStyle\n }\n >\n {todayOrPast.isToday && !offLimits && (\n <Portal container={viewportRef.current}>\n <span\n tabIndex={-1}\n className={styles.root__timeLine}\n data-now={timeOffsetTitle}\n style={{ [\"--offset\"]: timeOffset * pxPerMinute } as CSSVarStyle}\n />\n </Portal>\n )}\n <div ref={containerRef} className={styles.root__container}>\n <DayWeekDrawerContext.Provider value={drawerContextValue}>{children}</DayWeekDrawerContext.Provider>\n </div>\n {isActive && (\n <>\n <div className={styles.root__spotlight} style={transform ? { ...transform } : undefined} />\n <PointerPopover coordinates={{ x: transform.x, y: transform.y }}>{renderPreview()}</PointerPopover>\n </>\n )}\n </div>\n );\n}\n\n/** Pixels of the timeline as minutes, on the time step. */\nfunction toTimelineMinutes(px: number, pxPerMinute: number, timeStep: number): number {\n return Math.round(px / pxPerMinute / timeStep) * timeStep;\n}\n","import { useState, type RefObject } from \"react\";\n\nimport type { MeasuredEventData } from \"../components/day-week-view\";\nimport { useIsomorphicLayoutEffect } from \"../hooks\";\nimport { getClientRect, round, subtract } from \"@weekwise/core\";\n\nexport default function useAbsEventRect(\n rootRef: RefObject<HTMLDivElement | null>,\n /** The element the event is positioned in. */\n containerRef: RefObject<HTMLElement | null>,\n relativeRect: MeasuredEventData[\"rect\"]\n) {\n const [absEventRect, setAbsEventRect] = useState<MeasuredEventData[\"rect\"] | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n const rootEl = rootRef.current,\n parentEl = containerRef.current;\n\n if (rootEl && parentEl) {\n const { height, width, ...positions } = getClientRect(rootEl);\n const { left: x, top: y } = subtract(positions, getClientRect(parentEl));\n\n setAbsEventRect(\n // sometimes the values can be floating, so we need to round them\n round(relativeRect, { height, width, x, y })\n );\n }\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [rootRef, containerRef, ...Object.values(relativeRect)]);\n\n return absEventRect;\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useState } from \"react\";\n\nimport { useCalendarDateUtils } from \"../date-localization\";\nimport { useIsomorphicLayoutEffect } from \"../hooks\";\n\nimport { useCalendarContext } from \"../contexts/CalendarContext\";\nimport { useDayWeekViewContext } from \"../contexts/DayWeekViewContext\";\nimport type { MeasuredEventData } from \"../components/day-week-view\";\n\nexport default function useCanResizeEvent(eventDate: CalendarDate, absRect: MeasuredEventData[\"rect\"] | null) {\n const [canResize, setCanResize] = useState(true);\n const { preventOutBoundsChanges } = useCalendarContext();\n const { isBefore, isToday } = useCalendarDateUtils();\n const { getTimeFrame } = useDayWeekViewContext();\n\n useIsomorphicLayoutEffect(() => {\n // if preventOutBoundsChanges false then we can resize every event\n if (!absRect || !preventOutBoundsChanges) {\n return;\n }\n\n // if event is before today and not today then we can't resize\n if (isBefore(eventDate) && !isToday(eventDate)) {\n // oxlint-disable-next-line react-hooks/set-state-in-effect\n setCanResize(false);\n } else if (isToday(eventDate)) {\n // if is today then check if event is in time frame,\n // between current time and and of the day\n const { height, y } = absRect;\n const bottomRect = height + y;\n const [bottomEdge, topEdge] = getTimeFrame(eventDate);\n setCanResize(bottomRect > bottomEdge && y < topEdge);\n }\n }, [eventDate, absRect, getTimeFrame, preventOutBoundsChanges, isBefore, isToday]);\n\n return canResize;\n}\n","import { useEffect, useRef } from \"react\";\nimport type { DetailedHTMLProps, HTMLAttributes } from \"react\";\n\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\nimport { useEventCallback, useMergedRefs, useMove } from \"../../hooks\";\nimport type { MoveEndEvent } from \"../../hooks/useMove.types\";\nimport { cx, mergeCallbacks, omit } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useDayWeekDrawerContext } from \"../../contexts/DayWeekDrawerContext\";\nimport { useDayWeekViewContext } from \"../../contexts/DayWeekViewContext\";\nimport useAbsEventRect from \"../../hooks/useAbsEventRect\";\nimport useCanResizeEvent from \"../../hooks/useCanResizeEvent\";\nimport useMoveTransform, { type MoveTransform, type MoveTransformModifier } from \"../../hooks/useMoveTransform\";\nimport useRect from \"../../hooks/useRect\";\nimport {\n applyMoveTransformModifiers,\n boundingDraggableContainerModifier,\n getTimeStepEqualizerModifier,\n} from \"@weekwise/core\";\n\nimport type { DayWeekDragItem, MeasuredEventData } from \"../day-week-view\";\nimport { useCalendarDateUtils } from \"../../date-localization\";\n\nimport styles from \"./DayWeekEvent.module.css\";\n\nexport type DayWeekEventProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {\n eventData: MeasuredEventData;\n};\n\nexport type DayWeekEventTransformContext = \"bottom\" | \"top\" | \"overlay\";\n\nexport default function DayWeekEvent(props: DayWeekEventProps) {\n const { ref: forwardedRef, eventData, children, ...rootProps } = props;\n\n const { eventMap, ...options } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const { timeStep, preventOutBoundsChanges, disabled } = options;\n const rootRef = useRef<HTMLDivElement | null>(null);\n const topBarRef = useRef<HTMLDivElement | null>(null);\n const bottomBarRef = useRef<HTMLDivElement | null>(null);\n const { viewportRef, getTimeFrame, pxPerMinute, resize, resizing } = useDayWeekViewContext();\n // a time step on screen: the rows are shorter than 60px an hour in a compact calendar\n const stepPx = timeStep * pxPerMinute;\n const { drawerRef, containerRef } = useDayWeekDrawerContext();\n const absEventRect = useAbsEventRect(rootRef, containerRef, eventData.rect);\n // The whole event's start: a part shown today may belong to an event from yesterday.\n const canResize = useCanResizeEvent(eventMap.get(eventData.key)?.date ?? eventData.date, absEventRect);\n\n const { attributes, isDragging, overElement, overData, register, setOverlayTransform } = useDragAndDrop(\n ({ registerDragSource, draggable, droppable, setTransform, isActive }) => {\n const isDragging = isActive(rootRef.current);\n const [overElement, overData] = isDragging ? ([...droppable.dropTargets].pop() ?? [null, null]) : [null, null];\n\n return {\n attributes: draggable.attributes,\n overElement,\n overData,\n isDragging,\n register: registerDragSource,\n setOverlayTransform: setTransform,\n };\n }\n );\n\n const activeDrawerRect = useRect(isDragging ? overElement : null);\n\n const activeNodeResolver = (ctx: DayWeekEventTransformContext | null) => {\n return ctx === \"overlay\" ? rootRef.current : ctx === \"top\" ? topBarRef.current : bottomBarRef.current;\n };\n\n const containerNodeResolver = (ctx: DayWeekEventTransformContext | null) => {\n // the drawer, not the events' container in it: that one leaves a gap on the right\n return ctx === \"overlay\" ? viewportRef.current : drawerRef.current;\n };\n\n const [{ isActive, transform, context }, actions] = useMoveTransform<DayWeekEventTransformContext>({\n activeNode: activeNodeResolver,\n containerNode: containerNodeResolver,\n modifiers: [\n function overlayTransformModifier({\n activeNodeRect,\n containerNodeRect,\n context,\n transform,\n translate,\n initialTranslate,\n }) {\n // if context is not overlay do nothing\n if (context !== \"overlay\") {\n return transform;\n }\n\n if (!containerNodeRect || !activeNodeRect || !activeDrawerRect) {\n return transform;\n }\n\n transform.x = translate.x + initialTranslate.x - containerNodeRect.left;\n transform.y = translate.y + initialTranslate.y - containerNodeRect.top;\n\n transform.left = activeDrawerRect.left - containerNodeRect.left;\n transform.width = activeDrawerRect.width;\n transform.top = activeNodeRect.top - containerNodeRect.top;\n transform.height = activeNodeRect.height;\n\n let compensation: number;\n if (translate.y > 0) {\n compensation = stepPx - ((initialTranslate.y - activeNodeRect.top) % stepPx);\n transform.top += Math.ceil((translate.y - compensation) / stepPx) * stepPx;\n } else {\n compensation = (initialTranslate.y - activeNodeRect.top) % stepPx;\n transform.top += Math.floor((translate.y + compensation) / stepPx) * stepPx;\n }\n\n return transform;\n },\n function boundingDragTimeFrameModifier({ transform, context }) {\n if (!preventOutBoundsChanges) {\n return transform;\n }\n\n if (context !== \"overlay\" || !overData) {\n return transform;\n }\n\n const [top, bottom] = getTimeFrame(overData.date).map((x) => Math.ceil(x / timeStep) * stepPx);\n // top edge\n if (transform.top < top) {\n transform.top = top;\n }\n\n // bottom edge\n if (transform.top + transform.height > bottom) {\n transform.top = bottom - transform.height;\n }\n\n return transform;\n },\n getEventTransformModifiers(stepPx),\n ],\n });\n\n // Resizing is computed by the view (it may reach into other days); the move transform\n // only keeps auto-scroll running while the pointer is near an edge.\n const moveEndHandler = mergeCallbacks<[MoveEndEvent]>(\n () => resize.end(),\n (e) => {\n actions.stop({ x: e.clientX, y: e.clientY });\n }\n );\n\n const resizeListeners = (edge: \"top\" | \"bottom\") => ({\n onMoveStart: (e: { clientX: number; clientY: number }) => {\n actions.start({ x: e.clientX, y: e.clientY }, edge);\n resize.start(eventData.key, edge, e.clientX, e.clientY);\n return true;\n },\n onMove: (e: { clientX: number; clientY: number }) => {\n actions.move({ x: e.clientX, y: e.clientY });\n resize.move(e.clientX, e.clientY);\n },\n onMoveEnd: moveEndHandler,\n });\n\n const { listeners: resizeBottomListeners } = useMove(resizeListeners(\"bottom\"));\n const { listeners: resizeTopListeners } = useMove(resizeListeners(\"top\"));\n\n const handleRootRef = useMergedRefs(rootRef, forwardedRef);\n const isDragginOverlay = isActive && isDragging && context === \"overlay\";\n // While resized, the view draws the event's new range; its own parts step aside.\n const isResizeSource = resizing?.key === eventData.key;\n\n // Away from every day the overlay keeps its last place: the transform has no day to fit in.\n const syncTransform = useEventCallback((transform: MoveTransform) => {\n if (context === \"overlay\" && overElement) {\n setOverlayTransform(transform);\n }\n });\n\n useEffect(() => {\n syncTransform(transform);\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [syncTransform, ...Object.values(transform)]);\n\n useEffect(() => {\n if (!rootRef.current) {\n return;\n }\n\n const item: DayWeekDragItem = { ...omit(eventData, \"rect\"), date: dateUtils.toMillis(eventData.date) };\n const items = [{ [\"event\"]: JSON.stringify(item) }];\n\n return register(rootRef.current, {\n getItems() {\n return items;\n },\n onDragStart(e) {\n actions.start({ x: e.x, y: e.y }, \"overlay\");\n },\n onDragMove(e) {\n actions.move({ x: e.x, y: e.y });\n },\n onDragEnd(e) {\n actions.stop({ x: e.x, y: e.y });\n },\n getAllowedDropOperations() {\n return [\"move\"];\n },\n });\n }, [actions, eventData, register]);\n\n const rootClassName = cx(rootProps.className, styles.root, {\n [styles.root_isDragging]: isDragginOverlay,\n [styles.root_isResizeSource]: isResizeSource,\n [styles.root_isDisabled]: disabled,\n });\n\n const rootStyle = {\n ...rootProps.style,\n top: `${eventData.rect.y}%`,\n left: `${eventData.rect.x}%`,\n width: `${eventData.rect.width}%`,\n height: `${eventData.rect.height}%`,\n };\n\n const handlePointerDown = useEventCallback(mergeCallbacks(rootProps.onPointerDown, (e) => e.stopPropagation()));\n\n return (\n <>\n <div\n {...rootProps}\n {...attributes}\n ref={handleRootRef}\n className={rootClassName}\n style={rootStyle}\n onPointerDown={handlePointerDown}\n data-continues-before={eventData.isStart ? undefined : \"\"}\n data-continues-after={eventData.isEnd ? undefined : \"\"}\n >\n {/* Edges only where the event starts and ends, not at midnight between its days. */}\n {canResize && eventData.isStart && (\n <div {...resizeTopListeners} ref={topBarRef} className={styles.root__resizeTop} />\n )}\n <div role=\"button\" tabIndex={0} className={styles.root__container}>\n {children}\n </div>\n {canResize && eventData.isEnd && (\n <div {...resizeBottomListeners} ref={bottomBarRef} className={styles.root__resizeBottom} />\n )}\n </div>\n </>\n );\n}\n\nfunction getEventTransformModifiers(timeStep: number): MoveTransformModifier<DayWeekEventTransformContext> {\n return (args) => {\n const modifiers: MoveTransformModifier<DayWeekEventTransformContext>[] = [getTimeStepEqualizerModifier(timeStep)];\n\n if (args.context === \"overlay\") {\n modifiers.push(boundingDraggableContainerModifier);\n }\n\n return applyMoveTransformModifiers(modifiers, args);\n };\n}\n","import type { ReactNode } from \"react\";\n\nimport type { EventSegment } from \"@weekwise/core\";\n\nimport styles from \"./DayWeekEvent.module.css\";\n\nexport type DayWeekEventPreviewProps = {\n /** The day's part of the event's new range. */\n part: EventSegment;\n /** Length of the timeline in minutes: the part is placed in percent of it. */\n timelineMinutes: number;\n children?: ReactNode;\n};\n\n/** An event while it is resized: one per day its new range covers, across the full width. */\nexport default function DayWeekEventPreview({ part, timelineMinutes, children }: DayWeekEventPreviewProps) {\n const percent = (minutes: number) => `${(minutes / timelineMinutes) * 100}%`;\n return (\n <div\n aria-hidden=\"true\"\n className={`${styles.root} ${styles.root_isResizing} ${styles.root_isPreview}`}\n data-continues-before={part.isStart ? undefined : \"\"}\n data-continues-after={part.isEnd ? undefined : \"\"}\n style={{ top: percent(part.start), height: percent(part.duration), left: 0, width: \"100%\" }}\n >\n <div className={styles.root__container}>{children}</div>\n </div>\n );\n}\n","import { useMemo, useRef, useState } from \"react\";\nimport type { CSSProperties, HTMLAttributes } from \"react\";\n\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\nimport { cx } from \"@weekwise/core\";\n\nimport type { EventData, EventPart } from \"../../Calendar.types\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useCalendarViewportContext } from \"../../contexts/CalendarViewportContext\";\nimport { useDocumentCursor, useIsomorphicLayoutEffect } from \"../../hooks\";\nimport Portal from \"../../portal\";\n\nimport PointerPopover from \"../pointer-popover\";\n\nimport styles from \"./DragOverlay.module.css\";\n\n/** The dragged event is drawn whole, whichever of its parts was picked up. */\nconst WHOLE_EVENT: EventPart = { isStart: true, isEnd: true };\n\nexport type DragOverlayProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * Whether to render the pointer time preview popover while dragging.\n * Disabled in views where the overlay transform does not map to minutes.\n */\n showPreview?: boolean;\n /** Height of a minute in pixels, to read the overlay transform as minutes for the preview. */\n pxPerMinute?: number;\n};\n\nexport default function DragOverlay({ showPreview = true, pxPerMinute = 1, ...props }: DragOverlayProps) {\n const { eventMap, eventRenderer, pointerPreviewRenderer, view } = useCalendarContext();\n const { viewportRef } = useCalendarViewportContext();\n\n const { isDragging, canDrop, dropData, eventItem, source, x, y, ...transform } = useDragAndDrop(\n ({ draggable, overlay, droppable, canDrop }) => {\n const dropData = [...droppable.dropTargets.values()].shift();\n const items = [...draggable.dragTargets.values()].shift();\n\n return {\n ...overlay.transform,\n source: [...draggable.dragTargets.keys()].shift() ?? null,\n canDrop: canDrop(),\n dropData,\n eventItem: items ? items.filter((item) => item.event)[0] : null,\n isDragging: draggable.isDragging,\n x: draggable.x,\n y: draggable.y,\n };\n }\n );\n\n const eventValue = useMemo(() => {\n if (!eventItem) {\n return null;\n }\n\n // the drag payload is serialized, so render the original value instead of the parsed one\n const { key } = JSON.parse(eventItem.event) as EventData;\n return eventMap.get(key)?.value ?? null;\n }, [eventItem, eventMap]);\n\n // Released where the event cannot go, outside the calendar or by Escape: the overlay flies back\n // from where it was last over a day onto the event, which reappears under it.\n const lastRef = useRef<{ transform: typeof transform; source: HTMLElement; eventValue: unknown } | null>(null);\n const droppedRef = useRef(false);\n // the drag has been over a day: the overlay has a place to be drawn at\n const [isPlaced, setIsPlaced] = useState(false);\n const [returning, setReturning] = useState<{\n container: HTMLElement;\n style: CSSProperties;\n eventValue: unknown;\n } | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (isDragging) {\n droppedRef.current = canDrop;\n if (dropData && source) {\n lastRef.current = { transform, source, eventValue };\n setIsPlaced(true);\n setReturning(null);\n }\n return;\n }\n\n setIsPlaced(false);\n const last = lastRef.current;\n lastRef.current = null;\n const container = viewportRef.current;\n if (!last || droppedRef.current || !container || !last.source.isConnected) return;\n\n const { transform: from } = last;\n const sourceRect = last.source.getBoundingClientRect();\n const containerRect = container.getBoundingClientRect();\n setReturning({\n container,\n eventValue: last.eventValue,\n style: {\n left: sourceRect.left - containerRect.left,\n top: sourceRect.top - containerRect.top,\n width: sourceRect.width,\n height: sourceRect.height,\n \"--ww-return-left\": `${from.left}px`,\n \"--ww-return-top\": `${from.top}px`,\n \"--ww-return-width\": `${from.width}px`,\n \"--ww-return-height\": `${from.height}px`,\n } as CSSProperties,\n });\n });\n\n // The page shows the drag's cursor: grabbing, or \"not allowed\" where the event cannot go.\n useDocumentCursor(isDragging ? (canDrop ? \"grabbing\" : \"not-allowed\") : null);\n\n if (!isDragging) {\n return returning ? (\n <Portal container={returning.container}>\n <div\n {...props}\n className={cx(props.className, styles.root, styles.root_isReturning)}\n style={returning.style}\n onAnimationEnd={() => setReturning(null)}\n >\n {returning.eventValue != null ? eventRenderer.current?.(returning.eventValue, view, WHOLE_EVENT) : null}\n </div>\n </Portal>\n ) : null;\n }\n\n if (!isPlaced) {\n return null;\n }\n\n // Over a day or time the event cannot be dropped on, or outside the calendar, the overlay\n // stays where it was last placed, marked as blocked.\n const isBlocked = !canDrop;\n\n return (\n <Portal container={viewportRef.current}>\n <div\n {...props}\n className={cx(props.className, styles.root, {\n [styles.root_isDragging]: isDragging,\n [styles.root_isBlocked]: isBlocked,\n })}\n style={{ ...transform }}\n >\n {eventValue != null ? eventRenderer.current?.(eventValue, view, WHOLE_EVENT) : null}\n </div>\n {showPreview && !isBlocked && (\n <PointerPopover coordinates={{ x, y }}>\n {dropData\n ? pointerPreviewRenderer.current?.(\n dropData.date,\n Math.round(transform.top / pxPerMinute),\n Math.round(transform.height / pxPerMinute)\n )\n : null}\n </PointerPopover>\n )}\n </Portal>\n );\n}\n","import { useEffect, useMemo, useState, type RefObject } from \"react\";\n\nimport { formatNowOffset, getHiddenEvents, getRevealScrollTop } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useCalendarDateUtils, useMessages } from \"../../date-localization\";\nimport { useEventCallback, useGlobalListeners, useResizeObserver } from \"../../hooks\";\nimport ChevronIcon from \"../../icons/chevron\";\n\nimport type { MeasuredEventData } from \"./DayWeekView\";\nimport styles from \"./DayWeekView.module.css\";\n\nexport type HiddenEventsProps = {\n /** The scrolled timeline. */\n scrollerRef: RefObject<HTMLDivElement | null>;\n /** Events of each day column. */\n columns: readonly MeasuredEventData[][];\n rowHeight: number;\n};\n\ntype ScrollState = { top: number; height: number };\n\n/**\n * Buttons at the top and bottom of each day column of a scrolled timeline, to the events\n * above or below what is in view.\n */\nexport default function HiddenEvents({ scrollerRef, columns, rowHeight }: HiddenEventsProps) {\n const { hourMin, hideMinMaxTime, size } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const messages = useMessages();\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n const [scroll, setScroll] = useState<ScrollState | null>(null);\n const pxPerMinute = rowHeight / 60;\n\n const measure = useEventCallback(() => {\n const scroller = scrollerRef.current;\n if (!scroller) return;\n const next = { top: scroller.scrollTop, height: scroller.clientHeight };\n setScroll((prev) => (prev?.top === next.top && prev.height === next.height ? prev : next));\n });\n\n const resizeObserver = useResizeObserver(measure);\n\n useEffect(() => {\n const scroller = scrollerRef.current;\n if (!scroller) return;\n measure();\n addGlobalListener(scroller, \"scroll\", measure, { passive: true });\n resizeObserver?.observe(scroller);\n return () => {\n removeGlobalListener(scroller, \"scroll\", measure);\n resizeObserver?.unobserve(scroller);\n };\n }, [addGlobalListener, measure, removeGlobalListener, resizeObserver, scrollerRef]);\n\n // the timeline's height changes with the rows: what is out of view changes too\n useEffect(measure, [measure, rowHeight, columns]);\n\n const hidden = useMemo(\n () =>\n // no layout to measure (jsdom, the server)\n scroll && scroll.height > 0\n ? columns.map((events) => getHiddenEvents(events, pxPerMinute, scroll.top, scroll.height))\n : null,\n [columns, pxPerMinute, scroll]\n );\n\n if (!hidden || !scroll) return null;\n\n const reveal = (event: MeasuredEventData) =>\n scrollerRef.current?.scrollTo({\n top: getRevealScrollTop(event, pxPerMinute, scroll.top, scroll.height),\n behavior: \"smooth\",\n });\n\n const renderButton = (events: MeasuredEventData[], direction: \"above\" | \"below\") => {\n const [nearest] = events;\n if (!nearest) return null;\n // a narrow column has room for a count only\n const label =\n events.length === 1 && size !== \"narrow\"\n ? formatNowOffset(dateUtils, nearest.start, { hourMin, hideMinMaxTime })\n : events.length;\n return (\n <button\n type=\"button\"\n className={styles.root__hiddenEvents}\n data-direction={direction}\n aria-label={direction === \"above\" ? messages.earlier(events.length) : messages.later(events.length)}\n onClick={() => reveal(nearest)}\n >\n <ChevronIcon aria-hidden=\"true\" className={styles.root__hiddenEventsIcon} />\n {label}\n </button>\n );\n };\n\n return (\n <div className={styles.root__hiddenEventsLayer}>\n <div />\n {hidden.map(({ above, below }, idx) => (\n <div key={idx} className={styles.root__hiddenEventsColumn}>\n {renderButton(above, \"above\")}\n {renderButton(below, \"below\")}\n </div>\n ))}\n </div>\n );\n}\n","import { useState, type RefObject } from \"react\";\n\nimport { useIsomorphicLayoutEffect } from \"../../hooks\";\n\n/**\n * Width the time column needs for its labels (\"10:00 PM\", \"下午10:00\"…) on one line, or\n * `undefined` while the theme's `--ww-time-column` holds them. Measured again when the\n * labels change and once the fonts have loaded.\n */\nexport default function useTimeColumnWidth(\n /** The view's root, which sets `--ww-time-column` for its own content. */\n rootRef: RefObject<HTMLElement | null>,\n /** The `<time>` label elements, e.g. from `useRefList`. */\n labelsRef: { readonly current: readonly (HTMLElement | null)[] },\n labels: readonly string[],\n /** Width of the time column when `--ww-time-column` is not set. */\n defaultWidth: number\n): number | undefined {\n const [width, setWidth] = useState<number>();\n // measured again only when the text of the labels changes\n const labelsKey = labels.join(\"|\");\n\n useIsomorphicLayoutEffect(() => {\n let cancelled = false;\n\n const measure = () => {\n const root = rootRef.current;\n if (cancelled || !root) return;\n\n let needed = 0;\n const range = document.createRange();\n // no layout to measure (jsdom)\n if (typeof range.getBoundingClientRect !== \"function\") return;\n for (const label of labelsRef.current) {\n if (!label) continue;\n range.selectNodeContents(label);\n const style = getComputedStyle(label);\n const text = range.getBoundingClientRect().width;\n needed = Math.max(needed, text + parseFloat(style.paddingLeft) + parseFloat(style.paddingRight));\n }\n\n // the theme's width, from outside the view: the view's root overrides the variable\n const outside = root.parentElement ?? document.body;\n const themed = parseFloat(getComputedStyle(outside).getPropertyValue(\"--ww-time-column\"));\n const base = Number.isNaN(themed) ? defaultWidth : themed;\n\n setWidth(needed > base ? Math.ceil(needed) : undefined);\n };\n\n measure();\n void document.fonts?.ready.then(measure);\n return () => {\n cancelled = true;\n };\n }, [defaultWidth, labelsKey, labelsRef, rootRef]);\n\n return width;\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useCallback, useMemo, useRef } from \"react\";\nimport type { HTMLAttributes } from \"react\";\n\nimport { useCalendarDateUtils, useMessages } from \"../../date-localization\";\nimport { useMergedRefs, useRefList, useScrollBarSize, useToday } from \"../../hooks\";\nimport useEventResize from \"../../hooks/useEventResize\";\n\nimport type { EventData } from \"../../Calendar.types\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport CalendarViewportContext from \"../../contexts/CalendarViewportContext\";\nimport DayWeekViewContext from \"../../contexts/DayWeekViewContext\";\nimport {\n arrangeEventsByDay,\n buildTimeRows,\n cx,\n getTimeFrame as getDayTimeFrame,\n getVisibleDays,\n ROW_HEIGHTS,\n splitIntoDays,\n type MeasuredEventData as CoreMeasuredEventData,\n type TimeRowData,\n} from \"@weekwise/core\";\n\nimport DayWeekDrawer from \"../day-week-drawer\";\nimport DayWeekEvent from \"../day-week-event\";\nimport DragOverlay from \"../drag-overlay\";\nimport PointerPopover from \"../pointer-popover\";\nimport { DayWeekEventPreview } from \"../day-week-event\";\nimport type { CSSVarStyle } from \"../../utils/css\";\n\nimport HiddenEvents from \"./HiddenEvents\";\nimport useTimeColumnWidth from \"./useTimeColumnWidth\";\n\nimport styles from \"./DayWeekView.module.css\";\n\nexport type DayWeekViewProps = HTMLAttributes<HTMLDivElement> & {\n /** Height of an hour, in pixels. Defaults to the one of the calendar's size. */\n rowHeight?: number;\n};\n\nexport interface DayWeekHeaderCellData {\n day: number;\n events: MeasuredEventData[];\n weekDayName: string;\n weekDayNumber: number;\n isToday: boolean;\n attributes?: Record<string, string | number | boolean>;\n targetDate: CalendarDate;\n}\n\n/** A laid-out event in a day column; its dates are the adapter's, only the adapter reads them. */\nexport type MeasuredEventData = CoreMeasuredEventData<unknown, CalendarDate>;\n\n/**\n * What a day/week event carries while dragged. Dragged items travel as JSON, so the date\n * is a timestamp: not every date type survives JSON.\n */\nexport type DayWeekDragItem = Omit<MeasuredEventData, \"rect\" | \"date\"> & { date: number };\n\nexport type { TimeRowData };\n\nexport interface EventGroup {\n date: CalendarDate;\n events: EventData[];\n}\n\nexport interface EventArrangedGroup {\n date: CalendarDate;\n events: MeasuredEventData[];\n}\n\nexport interface DayWeekViewDropTargetData {\n date: CalendarDate;\n}\n\n/** Width of the time column when `--ww-time-column` is not set, per calendar size. */\nconst TIME_COLUMN_WIDTH = { regular: 64, compact: 44, narrow: 40 } as const;\n\nexport default function DayWeekView({ rowHeight: rowHeightProp, ...props }: DayWeekViewProps) {\n const {\n viewValue,\n hourMin,\n hourMax,\n view,\n eventMap,\n preventOutBoundsChanges,\n eventRenderer,\n timeStep,\n scrollable,\n size,\n hideMinMaxTime,\n disabled,\n getIsDayDisabled,\n onEventChange,\n pointerPreviewRenderer,\n } = useCalendarContext();\n\n const dateUtils = useCalendarDateUtils();\n const messages = useMessages();\n const { getMonthDay, getWeekDay, isToday, weekDayShortName } = dateUtils;\n const today = useToday();\n\n const rowHeight = rowHeightProp ?? ROW_HEIGHTS[size];\n const rootRef = useRef<HTMLDivElement>(null);\n const viewportRef = useRef<HTMLDivElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\n // the day columns by day index: resizing an event picks its day among them\n const columns = useRefList<HTMLDivElement>();\n\n const timeRows = useMemo(\n () => buildTimeRows(dateUtils, timeStep, { hourMin, hourMax, hideMinMaxTime }, preventOutBoundsChanges),\n [dateUtils, timeStep, hourMin, hourMax, hideMinMaxTime, preventOutBoundsChanges]\n );\n\n const timeLabels = useMemo(() => timeRows.map(({ time }) => time), [timeRows]);\n // the time labels by row: the time column is as wide as the longest of them needs\n const timeLabelElements = useRefList<HTMLTimeElement>();\n const timeColumnWidth = useTimeColumnWidth(rootRef, timeLabelElements.elements, timeLabels, TIME_COLUMN_WIDTH[size]);\n\n const days = useMemo(() => getVisibleDays(dateUtils, view, viewValue), [dateUtils, view, viewValue]);\n const bounds = useMemo(() => ({ hourMin, hourMax, hideMinMaxTime }), [hourMin, hourMax, hideMinMaxTime]);\n\n // Laid out in minutes (rects are percentages of the timeline).\n const eventGroups = useMemo<EventArrangedGroup[]>(\n () => arrangeEventsByDay(eventMap, dateUtils, timeRows.length * 60, days, bounds),\n [eventMap, dateUtils, timeRows.length, days, bounds]\n );\n\n const eventColumns = useMemo(() => eventGroups.map(({ events }) => events), [eventGroups]);\n\n const {\n state: resizing,\n actions: resize,\n previewOf,\n } = useEventResize({\n days,\n viewportRef,\n columnsRef: columns.elements,\n dateUtils,\n bounds,\n timeStep,\n preventOutBoundsChanges,\n disabled,\n getIsDayDisabled,\n eventMap: eventMap,\n onEventChange,\n });\n\n // The resized event, one part per day its new range covers.\n const resizeParts = useMemo(\n () => (resizing ? splitIntoDays(resizing.range[0], resizing.range[1], days.length, bounds) : []),\n [resizing, days.length, bounds]\n );\n const resizingValue = resizing ? eventMap.get(resizing.key)?.value : undefined;\n\n const getTimeFrame = useCallback<(date: CalendarDate) => [number, number]>(\n (targetDate: CalendarDate) => getDayTimeFrame(dateUtils, targetDate, { hourMin, hourMax, hideMinMaxTime }),\n [dateUtils, hideMinMaxTime, hourMax, hourMin]\n );\n\n const weekDays = useMemo(\n () =>\n days.map<DayWeekHeaderCellData>((date, idx) => {\n const weekDayNumber = getWeekDay(date);\n const today = isToday(date);\n const eventsByDay = eventGroups[idx]?.events ?? [];\n return {\n attributes: today ? { [\"data-is-today\"]: true } : undefined,\n events: eventsByDay,\n day: getMonthDay(date),\n isToday: today,\n targetDate: date,\n weekDayName: weekDayShortName(weekDayNumber),\n weekDayNumber,\n };\n }),\n [today, dateUtils, days, eventGroups, getMonthDay, getWeekDay, isToday, weekDayShortName]\n );\n\n const scrollbarSize = useScrollBarSize();\n\n const rootProps = props;\n\n const headClassName = styles.root__head;\n const bodyClassName = styles.root__body;\n const viewportClassName = styles.root__viewport;\n const columnClassName = styles.root__column;\n const headerCellClassName = styles.root__headerCell;\n const headerCellDayClassName = styles.root__headerCellDay;\n const rowClassName = styles.root__row;\n const timeClassName = styles.root__rowHeadTime;\n const timeStepClassName = styles.root__timeStep;\n\n const handleViewportRef = useMergedRefs(viewportRef);\n\n const contextValue = useMemo(\n () => ({ viewportRef, getTimeFrame, pxPerMinute: rowHeight / 60, resize, resizing }),\n [viewportRef, getTimeFrame, rowHeight, resize, resizing]\n );\n\n const viewportContextValue = useMemo(() => ({ viewportRef }), [viewportRef]);\n\n const renderEvent = (eventData: MeasuredEventData, idx: number) => {\n return (\n <DayWeekEvent key={eventData.key} data-idx={idx} eventData={eventData}>\n {eventRenderer.current?.(eventData.value, view, { isStart: eventData.isStart, isEnd: eventData.isEnd })}\n </DayWeekEvent>\n );\n };\n\n return (\n <DayWeekViewContext.Provider value={contextValue}>\n <CalendarViewportContext.Provider value={viewportContextValue}>\n <>\n <div\n {...rootProps}\n ref={rootRef}\n className={cx(rootProps.className, styles.root, {\n [styles.root_scrollable]: scrollable,\n })}\n style={\n {\n ...rootProps.style,\n [\"--calendar-column-count\"]: weekDays.length,\n [\"--scrollbar-width\"]: scrollbarSize.width,\n [\"--scrollbar-height\"]: scrollbarSize.height,\n ...(timeColumnWidth !== undefined && { [\"--ww-time-column\"]: `${timeColumnWidth}px` }),\n } as CSSVarStyle\n }\n >\n <div className={headClassName}>\n <div className={headerCellClassName} />\n {weekDays.map((weekDay) => (\n <div key={weekDay.weekDayNumber} className={headerCellClassName} {...weekDay.attributes}>\n <span className={headerCellDayClassName}>{weekDay.day}</span>\n <span className={styles.root__headerCellLabel}>\n <span className={styles.root__headerCellName}>{weekDay.weekDayName}</span>\n {weekDay.isToday && <span className={styles.root__headerCellToday}>{messages.today}</span>}\n </span>\n </div>\n ))}\n </div>\n <div className={styles.root__main}>\n <div ref={bodyRef} className={bodyClassName}>\n <div\n ref={handleViewportRef}\n className={viewportClassName}\n style={{ height: timeRows.length * rowHeight }}\n >\n <div className={columnClassName}>\n {timeRows.map(({ time, value, steps }, idx) => (\n <div\n key={value}\n className={rowClassName}\n style={\n {\n height: rowHeight,\n [\"--translateY\"]: idx * rowHeight,\n [\"--calendar-rows-count\"]: steps.length,\n } as CSSVarStyle\n }\n >\n <time ref={timeLabelElements.refAt(idx)} className={timeClassName}>\n {time}\n </time>\n {steps.map(([step, , overTime]) => (\n <div\n key={step}\n className={cx(timeStepClassName, {\n [styles.root__timeStep_overTime]: overTime,\n })}\n />\n ))}\n </div>\n ))}\n </div>\n {weekDays.map((weekDay, dayIndex) => (\n <div\n key={weekDay.weekDayNumber}\n ref={columns.refAt(dayIndex)}\n className={columnClassName}\n data-day-index={dayIndex}\n {...weekDay.attributes}\n >\n <DayWeekDrawer id={`${weekDay.weekDayNumber}`} targetDate={weekDay.targetDate}>\n {weekDay.events.map((eventData, idx) => renderEvent(eventData, idx))}\n {resizeParts\n .filter((part) => part.dayIndex === dayIndex)\n .map((part) => (\n <DayWeekEventPreview key=\"resize\" part={part} timelineMinutes={timeRows.length * 60}>\n {resizingValue !== undefined\n ? eventRenderer.current?.(resizingValue, view, {\n isStart: part.isStart,\n isEnd: part.isEnd,\n })\n : null}\n </DayWeekEventPreview>\n ))}\n </DayWeekDrawer>\n </div>\n ))}\n </div>\n </div>\n {scrollable && <HiddenEvents scrollerRef={bodyRef} columns={eventColumns} rowHeight={rowHeight} />}\n </div>\n </div>\n\n <DragOverlay pxPerMinute={rowHeight / 60} />\n {resizing && !resizing.blocked && (\n <PointerPopover coordinates={{ x: resizing.x, y: resizing.y }}>\n {(() => {\n const { date, top, duration } = previewOf(resizing.range);\n return pointerPreviewRenderer.current?.(date, top, duration);\n })()}\n </PointerPopover>\n )}\n </>\n </CalendarViewportContext.Provider>\n </DayWeekViewContext.Provider>\n );\n}\n","import DayWeekView from \"../day-week-view\";\n\n/**\n * The day and the week view: one component for both, so that it stays mounted when the user\n * switches between them. It takes no options: their time step is read by the calendar and\n * reaches the timeline through the calendar context.\n */\nexport default function TimelineView() {\n return <DayWeekView />;\n}\n","import type { DayWeekViewOptions } from \"@weekwise/core\";\n\nimport TimelineView from \"../components/timeline-view\";\nimport type { DayViewDefinition } from \"./types\";\n\n/** The day view, for the `views` of `CalendarBase`. */\nexport function dayView(options: DayWeekViewOptions = {}): DayViewDefinition {\n return { name: \"day\", options, component: TimelineView };\n}\n","import type { DayWeekViewOptions } from \"@weekwise/core\";\n\nimport TimelineView from \"../components/timeline-view\";\nimport type { WeekViewDefinition } from \"./types\";\n\n/** The week view, for the `views` of `CalendarBase`. */\nexport function weekView(options: DayWeekViewOptions = {}): WeekViewDefinition {\n return { name: \"week\", options, component: TimelineView };\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport type { CSSProperties } from \"react\";\n\n/** Lanes of events under the day numbers; more events collapse into \"+N more\". */\nexport const MAX_LANES = 3;\n\ntype CSSVariables = Record<`--${string}`, number>;\n\n/** Inline style of CSS custom properties, which place cells and bars in the week grid. */\nexport function cssVariables(variables: CSSVariables, style?: CSSProperties): CSSProperties {\n return { ...style, ...variables };\n}\n\n/** Splits the month grid's days into weeks of 7. */\nexport function splitIntoWeeks(days: CalendarDate[]): CalendarDate[][] {\n return Array.from({ length: Math.ceil(days.length / 7) }, (_, week) => days.slice(week * 7, week * 7 + 7));\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useEffect, useRef } from \"react\";\nimport type { DetailedHTMLProps, HTMLAttributes, KeyboardEvent, MouseEvent } from \"react\";\n\nimport { useCalendarDateUtils } from \"../../date-localization\";\nimport type { TextDropItem } from \"@weekwise/dnd\";\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\nimport { useEventCallback, useMergedRefs } from \"../../hooks\";\nimport { cx } from \"@weekwise/core\";\n\nimport { toDayMinutes } from \"@weekwise/core\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport type { MonthViewDragItem } from \"./MonthViewEvent\";\n\nimport styles from \"./MonthView.module.css\";\n\nexport type MonthViewDayProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {\n /**\n * Date associated to the day cell\n */\n targetDate: CalendarDate;\n /** Reports a click on the day; with it the cell is a button. */\n onDayClick?: (date: CalendarDate) => void;\n};\n\nexport interface MonthViewDropTargetData {\n date: CalendarDate;\n}\n\nexport default function MonthViewDay(props: MonthViewDayProps) {\n const {\n ref: forwardedRef,\n targetDate,\n onDayClick,\n children,\n onDoubleClick,\n onClick,\n onKeyDown,\n ...rootProps\n } = props;\n\n const { onEventChange, onEventCreate, getIsDayDisabled, disabled, eventMap } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const { getHours, getMinutes, getNow } = dateUtils;\n\n const rootRef = useRef<HTMLDivElement>(null);\n\n const { register, isOver } = useDragAndDrop(({ registerDropTarget, isOver }) => ({\n register: registerDropTarget,\n isOver: isOver(rootRef.current),\n }));\n\n useEffect(() => {\n const dropTargetElement = rootRef.current;\n\n if (!dropTargetElement) {\n return;\n }\n\n const dropTargetData: MonthViewDropTargetData = { date: targetDate };\n return register(dropTargetElement, {\n data: dropTargetData,\n onDrop: async (e) => {\n const [dragItem] = await Promise.all(\n e.items\n .filter(\n (item): item is TextDropItem => item.kind === \"text\" && item.types.has(\"event\") && \"getText\" in item\n )\n .map(async (item) => {\n const data = await item.getText(\"event\");\n return JSON.parse(data) as MonthViewDragItem;\n })\n );\n\n const eventData = dragItem && eventMap.get(dragItem.key);\n if (!eventData) {\n return;\n }\n\n // move by as many days as the event was dragged: a multi-day event can be\n // grabbed by any of its days. The time of the day stays.\n const sourceDay = dateUtils.fromMillis(dragItem.day ?? dragItem.date);\n const shift = toDayMinutes(dateUtils, sourceDay, targetDate) / (24 * 60);\n if (shift === 0) {\n return;\n }\n onEventChange(eventData.key, dateUtils.addDays(dateUtils.getStartOfDay(eventData.date), shift), {\n from: getHours(eventData.date) * 60 + getMinutes(eventData.date),\n duration: eventData.duration,\n });\n },\n getDropOperationForPoint: (types, allowedOperations) => {\n if (disabled || !types.has(\"event\")) return \"cancel\";\n\n if (getIsDayDisabled && getIsDayDisabled(targetDate)) {\n return \"cancel\";\n }\n\n return allowedOperations[0];\n },\n });\n }, [dateUtils, disabled, eventMap, getHours, getIsDayDisabled, getMinutes, onEventChange, register, targetDate]);\n\n const handleDoubleClick = useEventCallback((event: MouseEvent<HTMLDivElement>) => {\n onDoubleClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n\n if (disabled) {\n return;\n }\n\n if (getIsDayDisabled && getIsDayDisabled(targetDate)) {\n return;\n }\n\n const now = getNow();\n onEventCreate(targetDate, {\n from: getHours(now) * 60 + getMinutes(now),\n duration: 60,\n });\n });\n\n const handleClick = useEventCallback((event: MouseEvent<HTMLDivElement>) => {\n onClick?.(event);\n if (!event.defaultPrevented) onDayClick?.(targetDate);\n });\n\n const handleKeyDown = useEventCallback((event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n // the cell itself, not something focusable inside it\n if (!onDayClick || event.defaultPrevented || event.target !== event.currentTarget) return;\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n onDayClick?.(targetDate);\n });\n\n const handleRootRef = useMergedRefs(rootRef, forwardedRef);\n\n return (\n <div\n {...rootProps}\n ref={handleRootRef}\n onDoubleClick={handleDoubleClick}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n // a day that opens on click is a button, for the keyboard too\n {...(onDayClick && { role: \"button\", tabIndex: 0, \"aria-label\": dateUtils.format(targetDate, \"dateLong\") })}\n className={cx(rootProps.className, styles.root__day, {\n [styles.root__day_isOver]: isOver,\n })}\n >\n {children}\n </div>\n );\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useEffect, useRef } from \"react\";\nimport type { DetailedHTMLProps, HTMLAttributes, PointerEvent, RefObject } from \"react\";\n\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\nimport { useEventCallback, useMergedRefs, useMove } from \"../../hooks\";\nimport type { MoveTransform } from \"../../hooks/useMoveTransform\";\nimport useMoveTransform from \"../../hooks/useMoveTransform\";\nimport useRect from \"../../hooks/useRect\";\nimport { cx, MONTH_WEEK_GEOMETRY, type MonthBar } from \"@weekwise/core\";\n\nimport type { EventData } from \"../../Calendar.types\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useCalendarDateUtils } from \"../../date-localization\";\nimport { useCalendarViewportContext } from \"../../contexts/CalendarViewportContext\";\n\nimport { cssVariables } from \"./MonthView.utils\";\nimport type { MonthResizeActions, MonthResizeEdge } from \"./useMonthResize\";\n\nimport styles from \"./MonthView.module.css\";\n\n/** Horizontal margin of a bar in its day (`.root__event`). */\nconst BAR_INSET = 6;\n\nexport type MonthViewEventProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {\n /** The event's bar in this week: its days and lane. */\n eventData: MonthBar<unknown, CalendarDate>;\n /** The days of the week row the bar is in. */\n weekDays: CalendarDate[];\n /** The week row the bar lies in: where it is grabbed picks the day the drag moves. */\n weekRef: RefObject<HTMLDivElement | null>;\n /** Whether the bar's edges stretch the event into other days. */\n resizable?: boolean;\n /** Resizing by the bar's edges, run by the view. */\n resize?: MonthResizeActions;\n /** The bar before the resize: hidden while the view shows the new range. */\n isResizeSource?: boolean;\n /** Some event is being resized: no bar is draggable meanwhile. */\n isAnyResizing?: boolean;\n};\n\n/**\n * What a month event carries while dragged: the event and the day it was grabbed by.\n * Dragged items travel as JSON, so dates are timestamps: not every date type survives JSON.\n */\nexport interface MonthViewDragItem extends Omit<EventData<unknown, CalendarDate>, \"date\"> {\n /** Time stamp of the event's start. */\n date: number;\n /** Time stamp of the day cell the event was grabbed in. */\n day?: number;\n}\n\nexport default function MonthViewEvent(props: MonthViewEventProps) {\n const {\n ref: forwardedRef,\n eventData,\n weekDays,\n weekRef,\n resizable = false,\n resize,\n isResizeSource = false,\n isAnyResizing = false,\n children,\n ...rootProps\n } = props;\n\n const { disabled } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const { viewportRef } = useCalendarViewportContext();\n\n const rootRef = useRef<HTMLDivElement | null>(null);\n // the day under the pointer when the bar was pressed: a multi-day event moves by the\n // days it is dragged, by whichever of its days it was grabbed\n const grabbedDayRef = useRef<CalendarDate | null>(null);\n\n const { attributes, isDragging, overElement, register, setOverlayTransform } = useDragAndDrop(\n ({ registerDragSource, draggable, droppable, setTransform, isActive }) => {\n const isDragging = isActive(rootRef.current);\n const [overElement] = isDragging ? ([...droppable.dropTargets].pop() ?? [null]) : [null];\n\n return {\n attributes: draggable.attributes,\n isDragging,\n overElement,\n register: registerDragSource,\n setOverlayTransform: setTransform,\n };\n }\n );\n\n const overDayRect = useRect(isDragging ? overElement : null);\n\n const [{ transform, context }, actions] = useMoveTransform({\n autoScrollEnabled: false,\n activeNode: () => rootRef.current,\n containerNode: () => viewportRef.current,\n modifiers: [\n function overlayTransformModifier({ activeNodeRect, containerNodeRect, transform, translate, initialTranslate }) {\n if (!containerNodeRect || !activeNodeRect || !overDayRect) {\n return transform;\n }\n\n transform.x = translate.x + initialTranslate.x - containerNodeRect.left;\n transform.y = translate.y + initialTranslate.y - containerNodeRect.top;\n\n // in the target day, inset like a bar; vertically it follows the pointer, kept\n // inside the day below its number, so it moves into other weeks too\n transform.left = overDayRect.left - containerNodeRect.left + BAR_INSET;\n transform.width = overDayRect.width - 2 * BAR_INSET;\n transform.height = activeNodeRect.height;\n const top = activeNodeRect.top + translate.y;\n const minTop = overDayRect.top + MONTH_WEEK_GEOMETRY.header;\n const maxTop = overDayRect.top + overDayRect.height - activeNodeRect.height;\n transform.top = Math.max(minTop, Math.min(top, maxTop)) - containerNodeRect.top;\n\n return transform;\n },\n ],\n });\n\n // Away from every day the overlay keeps its last place: the transform has no day to fit in.\n const syncTransform = useEventCallback((transform: MoveTransform) => {\n if (context === \"overlay\" && overElement) {\n setOverlayTransform(transform);\n }\n });\n\n useEffect(() => {\n syncTransform(transform);\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [syncTransform, ...Object.values(transform)]);\n\n const getDragItems = useEventCallback(() => {\n const day = grabbedDayRef.current ?? weekDays[eventData.column];\n const item: MonthViewDragItem = {\n ...eventData,\n date: dateUtils.toMillis(eventData.date),\n day: day && dateUtils.toMillis(day),\n };\n return [{ [\"event\"]: JSON.stringify(item) }];\n });\n\n useEffect(() => {\n if (!rootRef.current || disabled) {\n return;\n }\n\n return register(rootRef.current, {\n getItems: getDragItems,\n onDragStart(e) {\n actions.start({ x: e.x, y: e.y }, \"overlay\");\n },\n onDragMove(e) {\n actions.move({ x: e.x, y: e.y });\n },\n onDragEnd(e) {\n actions.stop({ x: e.x, y: e.y });\n },\n getAllowedDropOperations() {\n return [\"move\"];\n },\n });\n }, [actions, disabled, getDragItems, register]);\n\n const handlePointerDown = (e: PointerEvent<HTMLDivElement>) => {\n e.stopPropagation();\n const week = weekRef.current;\n if (!week) return;\n const rect = week.getBoundingClientRect();\n const column = Math.floor(((e.clientX - rect.left) / rect.width) * weekDays.length);\n const clamped = Math.min(Math.max(column, eventData.column), eventData.column + eventData.span - 1);\n grabbedDayRef.current = weekDays[clamped] ?? null;\n };\n\n const resizeListeners = (edge: MonthResizeEdge) => ({\n onMoveStart: () => {\n resize?.start(eventData.key, edge);\n return true;\n },\n onMove: (e: { clientX: number; clientY: number }) => resize?.move(e.clientX, e.clientY),\n onMoveEnd: () => resize?.end(),\n });\n const { listeners: resizeStartListeners } = useMove(resizeListeners(\"start\"));\n const { listeners: resizeEndListeners } = useMove(resizeListeners(\"end\"));\n\n const handleRootRef = useMergedRefs(rootRef, forwardedRef);\n\n const multiDay = eventData.span > 1 || !eventData.isStart || !eventData.isEnd;\n const style = cssVariables(\n { \"--ww-column\": eventData.column + 1, \"--ww-span\": eventData.span, \"--ww-row\": eventData.lane + 2 },\n rootProps.style\n );\n\n return (\n <div\n {...rootProps}\n {...(isAnyResizing ? null : attributes)}\n ref={handleRootRef}\n style={style}\n data-key={String(eventData.key)}\n data-continues-before={eventData.isStart ? undefined : \"\"}\n data-continues-after={eventData.isEnd ? undefined : \"\"}\n onPointerDown={handlePointerDown}\n onDoubleClick={(e) => e.stopPropagation()}\n className={cx(rootProps.className, styles.root__event, {\n [styles.root__event_span]: multiDay,\n [styles.root__event_continuesBefore]: !eventData.isStart,\n [styles.root__event_continuesAfter]: !eventData.isEnd,\n [styles.root__event_isDragging]: isDragging,\n [styles.root__event_isResizeSource]: isResizeSource,\n })}\n >\n {children}\n {resizable && eventData.isStart && (\n <div\n {...resizeStartListeners}\n data-edge=\"start\"\n className={cx(styles.root__resize, styles.root__resizeStart)}\n />\n )}\n {resizable && eventData.isEnd && (\n <div {...resizeEndListeners} data-edge=\"end\" className={cx(styles.root__resize, styles.root__resizeEnd)} />\n )}\n </div>\n );\n}\n","import type { ReactNode } from \"react\";\n\nimport { cx, type CalendarDate, type MonthBar } from \"@weekwise/core\";\n\nimport { cssVariables } from \"./MonthView.utils\";\n\nimport styles from \"./MonthView.module.css\";\n\nexport type MonthViewEventPreviewProps = {\n /** A bar of the event's new range. */\n bar: MonthBar<unknown, CalendarDate>;\n children?: ReactNode;\n};\n\n/** An event while it is resized: one bar per week its new range covers. */\nexport default function MonthViewEventPreview({ bar, children }: MonthViewEventPreviewProps) {\n return (\n <div\n aria-hidden=\"true\"\n data-key={String(bar.key)}\n data-continues-before={bar.isStart ? undefined : \"\"}\n data-continues-after={bar.isEnd ? undefined : \"\"}\n className={cx(styles.root__event, styles.root__event_isResizing, {\n [styles.root__event_span]: bar.span > 1 || !bar.isStart || !bar.isEnd,\n [styles.root__event_continuesBefore]: !bar.isStart,\n [styles.root__event_continuesAfter]: !bar.isEnd,\n })}\n style={cssVariables({ \"--ww-column\": bar.column + 1, \"--ww-span\": bar.span, \"--ww-row\": bar.lane + 2 })}\n >\n {children}\n </div>\n );\n}\n","import { useRef } from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport type { EventKey, MonthBar, MonthWeekLayout, CalendarDate } from \"@weekwise/core\";\n\nimport { useCalendarDateUtils, useMessages } from \"../../date-localization\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\n\nimport { cssVariables } from \"./MonthView.utils\";\nimport MonthViewDay from \"./MonthViewDay\";\nimport MonthViewEvent from \"./MonthViewEvent\";\nimport MonthViewEventPreview from \"./MonthViewEventPreview\";\nimport type { MonthResizeActions } from \"./useMonthResize\";\n\nimport styles from \"./MonthView.module.css\";\n\nexport interface MonthViewWeekProps {\n days: CalendarDate[];\n /** Index of the week's first day in the month grid. */\n firstDayIndex: number;\n /** Ref for the cell of the day at an index in the month grid. */\n cellRef: (index: number) => (node: HTMLDivElement | null) => void;\n /** Bars to draw: with the resized event's new range while it changes. */\n layout: MonthWeekLayout<unknown, CalendarDate>;\n /**\n * The resized event's bars before the change. They stay mounted, hidden, while the\n * preview shows the new range: their edge handles the pointer until it is released.\n */\n sourceBars: MonthBar<unknown, CalendarDate>[];\n /** Lanes of bars that fit into the row; the \"+N more\" labels go below them. */\n lanes: number;\n resizingKey?: EventKey;\n resize: MonthResizeActions;\n /** The user's content of a day, from `renderDay`, in place of the bars. */\n renderDayContent?: (day: CalendarDate) => ReactNode;\n /** Reports a click on a day; without it the day cells are not buttons. */\n onDayClick?: (date: CalendarDate) => void;\n}\n\n/** The user's content of a day, under its number; nothing when the content is empty. */\nfunction MonthViewDayContent({ children }: { children: ReactNode }) {\n if (children === null || children === undefined || children === false || children === \"\") return null;\n return <div className={styles.root__dayContent}>{children}</div>;\n}\n\n/** One week row: day cells, the bars of the events over them and \"+N more\" labels. */\nexport default function MonthViewWeek(props: MonthViewWeekProps) {\n const { days, firstDayIndex, cellRef, layout, sourceBars, lanes, resizingKey, resize, renderDayContent, onDayClick } =\n props;\n const weekRef = useRef<HTMLDivElement>(null);\n\n const { viewValue, eventRenderer, view, disabled } = useCalendarContext();\n const { getMonthDay, isSameMonth, isToday, toMillis } = useCalendarDateUtils();\n const messages = useMessages();\n\n const isResizing = resizingKey !== undefined;\n const renderEvent = (bar: MonthBar<unknown, CalendarDate>) =>\n eventRenderer.current?.(bar.value, view, { isStart: bar.isStart, isEnd: bar.isEnd });\n\n const renderBar = (bar: MonthBar<unknown, CalendarDate>, isResizeSource = false) => (\n <MonthViewEvent\n key={bar.key}\n eventData={bar}\n weekDays={days}\n weekRef={weekRef}\n resizable={!disabled}\n resize={resize}\n isResizeSource={isResizeSource}\n isAnyResizing={isResizing}\n >\n {renderEvent(bar)}\n </MonthViewEvent>\n );\n\n return (\n <div ref={weekRef} className={styles.root__week}>\n {days.map((day, column) => (\n <MonthViewDay\n key={toMillis(day)}\n ref={cellRef(firstDayIndex + column)}\n targetDate={day}\n onDayClick={onDayClick}\n data-day-index={firstDayIndex + column}\n data-is-outside={isSameMonth(day, viewValue) ? undefined : true}\n data-is-today={isToday(day) ? true : undefined}\n style={cssVariables({ \"--ww-column\": column + 1 })}\n >\n <span className={styles.root__dayNumber}>{getMonthDay(day)}</span>\n {renderDayContent && <MonthViewDayContent>{renderDayContent(day)}</MonthViewDayContent>}\n </MonthViewDay>\n ))}\n {/*\n One list, so that a bar keeps its key among the same siblings when it becomes the\n hidden source of a resize: it stays mounted and its edge keeps the pointer.\n */}\n {[\n ...layout.bars.map((bar) =>\n bar.key === resizingKey ? (\n <MonthViewEventPreview key={`preview-${bar.key}`} bar={bar}>\n {renderEvent(bar)}\n </MonthViewEventPreview>\n ) : (\n renderBar(bar)\n )\n ),\n ...sourceBars.map((bar) => renderBar(bar, true)),\n ]}\n {days.map(\n (day, column) =>\n layout.hidden[column] > 0 && (\n <span\n key={`more-${toMillis(day)}`}\n className={styles.root__more}\n style={cssVariables({ \"--ww-column\": column + 1, \"--ww-row\": lanes + 2 })}\n >\n {messages.more(layout.hidden[column])}\n </span>\n )\n )}\n </div>\n );\n}\n","import { useState, type RefObject } from \"react\";\n\nimport { getMonthLaneCount } from \"@weekwise/core\";\n\nimport { useIsomorphicLayoutEffect, useResizeObserver } from \"../../hooks\";\n\n/**\n * Number of event lanes that fit into the month's week rows, at most `maxLanes`. Rows share\n * the grid's height, so a short calendar shows fewer lanes and more \"+N more\" instead of\n * cutting events off. `maxLanes` until the rows are measured.\n */\nexport default function useMonthLanes(viewportRef: RefObject<HTMLElement | null>, maxLanes: number) {\n const [lanes, setLanes] = useState(maxLanes);\n\n const measure = () => {\n const week = viewportRef.current?.firstElementChild;\n // 0 until the row is laid out (or while it is hidden): keep the lanes it had\n if (week?.clientHeight) setLanes(getMonthLaneCount(week.clientHeight, maxLanes));\n };\n\n const resizeObserver = useResizeObserver(measure);\n\n useIsomorphicLayoutEffect(() => {\n measure();\n const week = viewportRef.current?.firstElementChild;\n if (week) resizeObserver?.observe(week);\n return () => {\n if (week) resizeObserver?.unobserve(week);\n };\n }, [resizeObserver, maxLanes]);\n\n return lanes;\n}\n","import type { CalendarDate } from \"@weekwise/core\";\nimport { useMemo } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport {\n getEventTimeFrameFromInfo,\n resizeEventDays,\n type DateAdapter,\n type EventChangeInfo,\n type EventKey,\n type EventMap,\n} from \"@weekwise/core\";\n\nimport { useEventCallback, useGlobalListeners, useItemsLayout, useStateRef } from \"../../hooks\";\n\nexport type MonthResizeEdge = \"start\" | \"end\";\n\ninterface ResizeSession {\n key: EventKey;\n edge: MonthResizeEdge;\n /** The change so far; `null` until the edge reaches another day. */\n result: ReturnType<typeof resizeEventDays<CalendarDate>>;\n}\n\n/** Driven by the `useMove` listeners of a bar's edge. */\nexport interface MonthResizeActions {\n start: (key: EventKey, edge: MonthResizeEdge) => void;\n move: (x: number, y: number) => void;\n /** Applies the change; `false` drops it. */\n end: (commit?: boolean) => void;\n}\n\ninterface UseMonthResizeParams<TValue> {\n /** Days of the month grid. */\n days: CalendarDate[];\n viewportRef: RefObject<HTMLElement | null>;\n /** The day cells, in the order of `days`: the edge goes into the one nearest the pointer. */\n cellsRef: { readonly current: readonly (HTMLElement | null)[] };\n dateUtils: DateAdapter<CalendarDate>;\n eventMap: EventMap<TValue, CalendarDate>;\n disabled: boolean;\n getIsDayDisabled?: (date: CalendarDate) => boolean;\n onEventChange: (key: EventKey, date: CalendarDate, info: EventChangeInfo) => void;\n}\n\n/**\n * Stretches an event into other days by the left or right edge of its month-view bar.\n * `eventMap` is the map to draw while it changes, with the event's new range.\n */\nexport default function useMonthResize<TValue>(params: UseMonthResizeParams<TValue>) {\n const { days, viewportRef, cellsRef, dateUtils, eventMap, disabled, getIsDayDisabled, onEventChange } = params;\n\n const [session, setSession, sessionRef] = useStateRef<ResizeSession | null>(null);\n // Escape drops the change\n const { addGlobalListener, removeAllGlobalListeners } = useGlobalListeners();\n // the grid and its day cells, measured once a resize starts\n const layout = useItemsLayout(viewportRef, cellsRef);\n\n const end = useEventCallback((commit: boolean = true) => {\n const current = sessionRef.current;\n if (!current) return;\n removeAllGlobalListeners();\n layout.release();\n setSession(null);\n if (commit && current.result) {\n onEventChange(current.key, current.result.date, current.result.info);\n }\n });\n\n const handleKeyDown = useEventCallback((e: KeyboardEvent) => {\n if (e.key === \"Escape\") end(false);\n });\n\n const start = useEventCallback((key: EventKey, edge: MonthResizeEdge) => {\n if (disabled || sessionRef.current) return;\n layout.measure();\n setSession({ key, edge, result: null });\n addGlobalListener(document, \"keydown\", handleKeyDown, true);\n });\n\n const move = useEventCallback((x: number, y: number) => {\n const current = sessionRef.current;\n const event = current && eventMap.get(current.key);\n const target = days[layout.nearestIndex(x, y)];\n // an edge does not go into a day that cannot be edited; the last valid range stays\n if (!current || !event || !target || getIsDayDisabled?.(target)) return;\n setSession({ ...current, result: resizeEventDays(dateUtils, event, current.edge, target) });\n });\n\n const actions = useMemo<MonthResizeActions>(() => ({ start, move, end }), [end, move, start]);\n\n const shownEventMap = useMemo(() => {\n const event = session?.result && eventMap.get(session.key);\n if (!session?.result || !event) return eventMap;\n const [date] = getEventTimeFrameFromInfo(dateUtils, session.result.date, session.result.info);\n return new Map(eventMap).set(session.key, { ...event, date, duration: session.result.info.duration });\n }, [dateUtils, eventMap, session]);\n\n return {\n /** Key of the event being resized, if any. */\n resizingKey: session?.key,\n actions,\n eventMap: shownEventMap,\n };\n}\n","import { useMemo, useRef } from \"react\";\nimport type { HTMLAttributes, ReactNode } from \"react\";\n\nimport {\n arrangeMonthWeek,\n cx,\n getDayKey,\n getMonthGrid,\n getWeekdayNames,\n groupEventsByDay,\n type CalendarDate,\n type MonthBar,\n type MonthWeekLayout,\n} from \"@weekwise/core\";\n\nimport { useCalendarDateUtils } from \"../../date-localization\";\nimport { useCurrentRef, useEventCallback, useRefList, useToday } from \"../../hooks\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport CalendarViewportContext from \"../../contexts/CalendarViewportContext\";\n\nimport DragOverlay from \"../drag-overlay\";\n\nimport { cssVariables, MAX_LANES, splitIntoWeeks } from \"./MonthView.utils\";\nimport MonthViewWeek from \"./MonthViewWeek\";\nimport useMonthLanes from \"./useMonthLanes\";\nimport useMonthResize from \"./useMonthResize\";\n\nimport styles from \"./MonthView.module.css\";\n\nexport type MonthViewProps = HTMLAttributes<HTMLDivElement> & {\n /** Content of a day in place of its event bars; without it the view draws a bar per event. */\n renderDay?: (date: CalendarDate, items: unknown[]) => ReactNode;\n /** A day was clicked, or Enter or Space was pressed on it, outside its events. */\n onDayClick?: (date: CalendarDate) => void;\n};\n\nconst NO_BARS: MonthBar<unknown, CalendarDate>[] = [];\nconst NO_LAYOUT: MonthWeekLayout<unknown, CalendarDate> = { bars: NO_BARS, hidden: [0, 0, 0, 0, 0, 0, 0] };\n\n/**\n * Month grid: 6 weeks of day cells. An event is one bar across the days it covers in a\n * week; the bar's edges stretch it into other days.\n */\nexport default function MonthView(props: MonthViewProps) {\n const { className, style, renderDay, onDayClick, ...rootProps } = props;\n\n const { viewValue, eventMap, startWeek, disabled, getIsDayDisabled, onEventChange } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n // re-render at midnight so the highlighted day follows the date\n useToday();\n\n const viewportRef = useRef<HTMLDivElement>(null);\n // the day cells by index in the grid: resizing an event picks its day among them\n const cells = useRefList<HTMLDivElement>();\n\n const days = useMemo(() => getMonthGrid(dateUtils, viewValue, startWeek), [dateUtils, startWeek, viewValue]);\n const weeks = useMemo(() => splitIntoWeeks(days), [days]);\n const weekdayNames = useMemo(() => getWeekdayNames(dateUtils, startWeek), [dateUtils, startWeek]);\n\n const resize = useMonthResize({\n days,\n viewportRef,\n cellsRef: cells.elements,\n dateUtils,\n eventMap,\n disabled,\n getIsDayDisabled,\n onEventChange,\n });\n\n const lanes = useMonthLanes(viewportRef, MAX_LANES);\n\n // the renderer is read when drawn: a new function each render does not rebuild the layout\n const dayRendererRef = useCurrentRef(renderDay);\n const hasDayRenderer = Boolean(renderDay);\n const handleDayClick = useEventCallback((date: CalendarDate) => onDayClick?.(date));\n\n // the user's day content takes the place of the bars\n const layouts = useMemo(\n () => weeks.map((week) => (hasDayRenderer ? NO_LAYOUT : arrangeMonthWeek(eventMap, dateUtils, week, lanes))),\n [dateUtils, eventMap, hasDayRenderer, lanes, weeks]\n );\n const dayEvents = useMemo(\n () => (hasDayRenderer ? groupEventsByDay(eventMap, dateUtils) : undefined),\n [dateUtils, eventMap, hasDayRenderer]\n );\n const renderDayContent = dayEvents\n ? (day: CalendarDate) =>\n dayRendererRef.current?.(\n day,\n (dayEvents.get(getDayKey(dateUtils, day)) ?? []).map((event) => event.value)\n )\n : undefined;\n // while an event is resized, the grid shows its new range\n const shownLayouts = useMemo(\n () =>\n resize.eventMap === eventMap || hasDayRenderer\n ? layouts\n : weeks.map((week) => arrangeMonthWeek(resize.eventMap, dateUtils, week, lanes)),\n [dateUtils, eventMap, hasDayRenderer, lanes, layouts, resize.eventMap, weeks]\n );\n\n const contextValue = useMemo(() => ({ viewportRef }), []);\n\n return (\n <CalendarViewportContext.Provider value={contextValue}>\n <div\n {...rootProps}\n className={cx(className, styles.root, {\n [styles.root_isResizing]: resize.resizingKey !== undefined,\n })}\n style={cssVariables({ \"--ww-month-lanes\": lanes }, style)}\n >\n <div className={styles.root__head}>\n {weekdayNames.map((weekdayName) => (\n <div key={weekdayName} className={styles.root__weekday}>\n {weekdayName}\n </div>\n ))}\n </div>\n <div className={styles.root__body}>\n <div ref={viewportRef} className={styles.root__viewport}>\n {weeks.map((week, weekIndex) => (\n <MonthViewWeek\n key={dateUtils.toMillis(week[0])}\n days={week}\n firstDayIndex={weekIndex * 7}\n cellRef={cells.refAt}\n layout={shownLayouts[weekIndex]}\n sourceBars={\n resize.resizingKey === undefined\n ? NO_BARS\n : layouts[weekIndex].bars.filter((bar) => bar.key === resize.resizingKey)\n }\n lanes={lanes}\n resizingKey={resize.resizingKey}\n resize={resize.actions}\n renderDayContent={renderDayContent}\n onDayClick={onDayClick ? handleDayClick : undefined}\n />\n ))}\n </div>\n </div>\n </div>\n <DragOverlay className={styles.root__dragOverlay} showPreview={false} />\n </CalendarViewportContext.Provider>\n );\n}\n","import type { MonthViewOptions } from \"../Calendar.types\";\nimport MonthView from \"../components/month-view\";\nimport type { MonthViewProps } from \"../components/month-view\";\n\nimport type { MonthViewDefinition } from \"./types\";\n\n/** The month view, from its options; its dates are opaque CalendarDates inside the calendar. */\nfunction MonthViewOfOptions({ options }: { options: Pick<MonthViewProps, \"renderDay\" | \"onDayClick\"> }) {\n return <MonthView renderDay={options.renderDay} onDayClick={options.onDayClick} />;\n}\n\n/**\n * The month view, for the `views` of `CalendarBase`. `renderDay` gets your event type when the\n * calendar is given it, `<CalendarBase<Event> …>`: TypeScript does not infer it from `items` there.\n * Views made apart from the calendar take it from `CalendarBaseViews<Event>` or\n * `monthView<Event>()`.\n */\nexport function monthView<TValue, TDate = Date>(\n options: MonthViewOptions<TValue, TDate> = {}\n): MonthViewDefinition<TValue, TDate> {\n return {\n name: \"month\",\n options,\n component: MonthViewOfOptions,\n };\n}\n","import CalendarBase from \"./CalendarBase\";\nimport type { CalendarProps } from \"./Calendar.types\";\nimport { dayView, monthView, weekView } from \"./views\";\n\n/**\n * The calendar, with the day, week and month views; `views` gives them options. To offer only\n * some views, and have only their code in your bundle, use `CalendarBase`.\n * Dates in its props and callbacks are of the adapter's type (`TDate`).\n */\nexport default function Calendar<TValue, TDate = Date>({ views, ...props }: CalendarProps<TValue, TDate>) {\n return (\n <CalendarBase<TValue, TDate>\n {...props}\n views={{\n day: dayView(views?.day),\n week: weekView(views?.week),\n month: monthView(views?.month),\n }}\n />\n );\n}\n"],"mappings":"A,qTASA,IAAMwT,GAAA,EAA0BxT,EAAAA,cAAAA,CAAqD,IAAA,EAAS,EAE1FC,EAAAA,mBACFuT,EAAwB,YAAc,2BCFxC,SAAwBC,GAAiD,CACvE,IAAMC,GAAA,EAAUxT,EAAAA,WAAAA,CAAWsT,CAAuB,EAElD,GAAI,CAACE,EACH,MAAU,MAAM,qCAAqC,EAGvD,OAAOA,CACT,CAGA,SAAgBC,GAAkD,CAChE,OAAOF,EAA2B,CACpC,CChBA,IAAMG,GAAA,EAAkBzT,EAAAA,cAAAA,CAA4C,IAAA,EAAS,EAEzEC,EAAAA,mBACFwT,EAAgB,YAAc,mBEFhC,SAAwBC,GAAc,CACpC,IAAMC,GAAA,EAAWtT,EAAAA,WAAAA,CAAWoT,CAAe,EACrCG,EAAYN,EAAa,EAC/B,OAAOK,IAAA,EAAYrT,EAAAA,gBAAAA,CAAgBsT,EAAU,MAAM,CACrD,CCJA,IAAaC,EANK,OAAO,OAAW,IAMiBtT,EAAAA,gBAAkBC,EAAAA,UCFvE,SAAwBsT,EAAkBC,EAA4BC,EAAW,GAAO,CACtF,IAAMC,GAAA,EAAQxT,EAAAA,OAAAA,CAAOsT,CAAE,EACvBE,EAAM,QAAUF,EAChB,IAAMG,GAAA,EAAiBxT,EAAAA,QAAAA,KAAc,CACnC,GAAIsT,GAAY,OAAO,OAAW,KAAsB,OAAO,iBAAmB,OAChF,OAEF,GAAM,CAAE,QAASD,GAAOE,EAClB,CAAEE,kBAAmB,OAE3B,OAAO,IAAIA,EAAeJ,CAAE,CAC9B,EAAG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