@weekwise/react 0.1.0 → 0.1.2
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.
- package/dist/Calendar.types.d.ts +2 -0
- package/dist/components/drag-overlay/DragOverlay.d.ts +3 -1
- package/dist/hooks/useTimeOffset.d.ts +1 -0
- package/dist/hooks/useToday.d.ts +2 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +710 -691
- package/dist/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +7 -7
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["resolveMessages","_jsx","resolveMessages","_jsx","_jsx","_jsxs","styles","_jsx","_jsx","styles","_jsxs","_Fragment","styles","_jsx","styles","_jsxs","_jsx","_jsx","styles","_jsx","styles","_jsxs","_jsx","styles","defaultValue","_jsxs","styles","_jsx","_jsx","styles","_jsx","_jsxs","styles","_jsxs","styles","_jsx","_jsxs","styles","_jsx","_Fragment","styles","_jsx","_Fragment","_jsxs","_jsx","styles","_jsxs","styles","_jsx","styles","getTimeFrame","getDayTimeFrame","styles","_jsx","_jsxs","_Fragment","props","_jsx","styles","_jsxs","createContext","startTransition","useCallback","useContext","useEffect","useId","useInsertionEffect","useLayoutEffect","useMemo","useReducer","useRef","useState","useSyncExternalStore","MONTH_WEEK_GEOMETRY","ROW_HEIGHTS","Rect","THEME_PROPERTIES","add","adjustScrollRect","applyMoveTransformModifiers","arrangeEventsByDay","arrangeMonthWeek","boundingDraggableContainerModifier","boundingResizableContainerModifier","buildEventMap","buildTimeRows","builtInMessages","cx","defaultCoordinates","emptyArray","formatMonthYear","formatNowOffset","formatTimelineRange","fromDayMinutes","getCalendarSize","getClientRect","getEventTimeFrameFromInfo","getHiddenEvents","getMonthGrid","getMonthLaneCount","getNavigationTarget","getNowOffset","getRevealScrollTop","getScrollCoordinates","getScrollDirectionAndSpeed","getScrollOffsets","getScrollableAncestors","getScrollableElement","getTimeFrame","getTimeStepEqualizerModifier","getTimelineRange","getViewChangeTarget","getViewHeading","getVisibleDays","getWeekdayNames","getWindow","isDevEnvironment","isHTMLElement","isInViewPeriod","isNotNull","isPastDay","match","mergeCallbacks","normalizeViewValue","omit","resizeEventDays","resizeEventRange","resolveMessages","resolveMessages$1","round","shallowEqual","splitIntoDays","subtract","toDayMinutes","transferDay","createDragAndDropApi","DragAndDropContext","useDragAndDrop","autoUpdate","flip","offset","shift","useFloating","Fragment","jsx","jsxs","createPortal","DateLocalizationContext","useDateUtils","context","useCalendarDateUtils","MessagesContext","DateLocalizationProvider","props","adapter","messages","children","dateUtils","resolvedMessages","useMessages","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","UNINITIALIZED","useRefWithInit","init","initArg","assertNotCalled","createStableCallback","stable","args","useEventCallback","callback","useGlobalListeners","globalListeners","addGlobalListener","removeGlobalListener","removeAllGlobalListeners","target","type","listener","options","fn","event","toFnRef","mergeRefs","refs","useMergedRefs","useMove","state","paramsRef","attr","stopEvent","update","coordinates","pointerId","distance","handlers","clientX","clientY","prevClientX","prevClientY","getCommonEventData","pointerType","deltaX","deltaY","initialDeltaX","initialDeltaY","onMouseMove","onMouseUp","onTouchMove","touch","identifier","trouchEvent","onTouchEnd","onPointerMove","onPointerUp","triggerKeyboardMove","start","move","end","usePrevious","buildUseScrollbarSizeHook","count","elementFabric","resizeCallback","dimensions","setDimensions","updateState","scrollbarHeight","scrollbarWidth","currentDimensions","height","cleanup","useScrollBarSize","useStateRef","initialValue","setState","next","useTimeInterval","interval","isActive","timerRef","callbackRef","now","delay","useToday","getToday","addDays","toMillis","fromMillis","today","setToday","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","subscribe","getClientSnapshot","getServerSnapshot","useIsHydrated","readTheme","source","theme","computed","name","Portal","container","hydrated","themeSource","DateNavigator_module_default","DateNavigator","renderHeading","onClick","onKeyDown","className","buttonProps","getStartOfWeek","getStartOfMonth","addMonths","open","setOpen","pickerMonth","setPickerMonth","rootRef","floatingStyles","handlePointerDown","heading","gridDays","handleToggleClick","prev","handleToggleKeyDown","handleSelectDay","day","index","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","eventMap","eventRenderer","pointerPreviewRenderer","viewportRef","isDragging","canDrop","dropData","eventItem","x","y","transform","draggable","overlay","droppable","items","item","eventValue","key","lastTransformRef","returning","setReturning","sourceRect","containerRect","isBlocked","cssVariables","variables","splitIntoWeeks","days","_","week","getNearestDayIndex","cells","best","bestDistance","cell","rect","dx","dy","MonthView_module_default","MonthViewDay","forwardedRef","targetDate","onDoubleClick","onEventChange","onEventCreate","getIsDayDisabled","getHours","getMinutes","getNow","register","isOver","registerDropTarget","dropTargetElement","dragItem","data","eventData","sourceDay","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","axis","useMutationObserver","mutationObserver","MutationObserver","useRect","measure","fallbackRect","measureRect","reducer","records","record","currentRect","newRect","defaultValue$1","useScrollableAncestors","node","limit","previousNode","ancestors","useScrollableAncestorsRects","elements","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","resizable","resize","isResizeSource","isAnyResizing","grabbedDayRef","attributes","overElement","setOverlayTransform","registerDragSource","setTransform","overDayRect","translate","initialTranslate","top","minTop","maxTop","syncTransform","getDragItems","\"event\"","column","clamped","resizeListeners","edge","resizeStartListeners","resizeEndListeners","multiDay","MonthViewEventPreview","bar","MonthViewWeek","firstDayIndex","layout","sourceBars","lanes","resizingKey","getMonthDay","isSameMonth","isResizing","renderEvent","renderBar","useMonthLanes","maxLanes","setLanes","useMonthResize","session","setSession","sessionRef","commit","current","handleKeyDown","shownEventMap","date","NO_BARS","MonthView","weeks","weekdayNames","layouts","shownLayouts","contextValue","weekdayName","weekIndex","DAY","useEventResize","bounds","timeStep","preventOutBoundsChanges","timelineMinutes","viewport","columns","minute","dayIndex","box","idx","bottom","original","blocked","range","DayWeekViewContext","useDayWeekViewContext","useTimeOffset","hideMinMaxTime","hourMin","hourMax","calculateOffset","updateOffset","DayWeekDrawer_module_default","DayWeekDrawer","isBefore","containerRef","getTransform","todayOrPast","isTodayFlag","resizingActiveNodeRect","offsetY","compensation","bottomEdge","topEdge","timeOffset","offLimits","startOfEvent","partDay","fromStart","dayShift","isPast","moveListeners","currentTop","timeOffsetTitle","renderPreview","useAbsEventRect","relativeRect","absEventRect","setAbsEventRect","rootEl","parentEl","positions","useCanResizeEvent","eventDate","absRect","canResize","setCanResize","bottomRect","DayWeekEvent_module_default","DayWeekEvent","topBarRef","bottomBarRef","resizing","overData","activeDrawerRect","ctx","getEventTransformModifiers","moveEndHandler","e","resizeBottomListeners","resizeTopListeners","isDragginOverlay","rootClassName","rootStyle","DayWeekEventPreview","part","percent","minutes","DayWeekView_module_default","HiddenEvents","scrollerRef","rowHeight","scroll","setScroll","pxPerMinute","scroller","hidden","events","reveal","renderButton","nearest","label","above","below","useTimeColumnWidth","labels","defaultWidth","setWidth","cancelled","needed","text","outside","themed","TIME_COLUMN_WIDTH","DayWeekView","rowHeightProp","scrollable","getWeekDay","weekDayShortName","bodyRef","timeRows","timeColumnWidth","time","eventGroups","eventColumns","previewOf","resizeParts","resizingValue","getTimeFrame$1","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"],"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/useRefWithInit.ts","../src/hooks/useEventCallback.utils.ts","../src/hooks/useEventCallback.ts","../src/hooks/useGlobalListeners.ts","../src/utils/mergeRefs.ts","../src/hooks/useMergedRefs.ts","../src/hooks/useMove.ts","../src/hooks/usePrevious.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/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>(\n props: DateLocalizationProviderProps<TDate>\n) {\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(\n () => resolveMessages(dateUtils.locale, messages),\n [dateUtils.locale, messages]\n );\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;","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}","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 // eslint-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/**\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>(\n params: UseControlledParams<T> | UseControlledWithInitialParams<T>\n) {\n const { controlled, default: defaultValueProp } = params;\n const [valueState, setValueState] = useState(() => {\n if (\n defaultValueProp === undefined &&\n \"initialState\" in params &&\n params.initialState !== undefined\n ) {\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 // eslint-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 { 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}","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 // eslint-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\n | (<K extends keyof DocumentEventMap>(this: Document, ev: DocumentEventMap[K]) => any);\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}","import { useMemo, type Ref } from \"react\";\n\nimport mergeRefs from \"../utils/mergeRefs\";\n\nfunction useMergedRefs<T>(...refs: (Ref<T> | undefined)[]) {\n // eslint-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 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 {\n EventBase,\n MoveData,\n PointerCoordinates,\n PointerType,\n UseMoveParams,\n} 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 },\n }));\n\n const paramsRef = useRef(params);\n paramsRef.current = params;\n\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n\n const listeners = useMemo<DOMAttributes<Element>>(() => {\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 // eslint-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 (\n !state.isDistanceReached &&\n initialDeltaX ** 2 + initialDeltaY ** 2 >= distance ** 2\n ) {\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(\n ({ identifier }) => identifier === state.activePointId\n );\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(\n ({ identifier }) => identifier === state.activePointId\n );\n if (touch >= 0) {\n // end\n update(e.changedTouches[touch], null).end(\"touch\", e);\n\n addGlobalListener(window, \"touchmove\", onTouchMove);\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 onPointerMove = (e: PointerEvent) => {\n if (e.pointerId === state.activePointId) {\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n update(e).move(pointerType, e);\n }\n };\n\n const onPointerUp = (e: PointerEvent) => {\n if (e.pointerId === state.activePointId) {\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n\n update(e, null).end(pointerType, e);\n\n removeGlobalListener(window, \"pointermove\", onPointerMove, false);\n removeGlobalListener(window, \"pointerup\", onPointerUp, false);\n removeGlobalListener(window, \"pointercancel\", onPointerUp, false);\n }\n };\n\n attr.onPointerDown = (e: ReactPointerEvent) => {\n if (e.button === 0 && state.activePointId === null) {\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n\n if (update(e, e.pointerId).start(pointerType, e) !== false) {\n addGlobalListener(window, \"pointermove\", onPointerMove, false);\n addGlobalListener(window, \"pointerup\", onPointerUp, false);\n addGlobalListener(window, \"pointercancel\", onPointerUp, false);\n\n stopEvent(e);\n } else update(e, null);\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 return attr;\n }, [addGlobalListener, removeGlobalListener, state]);\n\n return { listeners };\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 { 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 { useCalendarDateUtils } from \"../date-localization\";\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.\n */\nexport default function useToday(): number {\n const { getToday, addDays, toMillis, fromMillis } = useCalendarDateUtils();\n const [today, setToday] = useState(() => toMillis(getToday()));\n\n useEffect(() => {\n // the next midnight in the adapter's time zone\n const nextMidnight = toMillis(addDays(fromMillis(today), 1));\n const delay = Math.max(nextMidnight - Date.now(), 0) + 1000;\n const timer = setTimeout(() => setToday(toMillis(getToday())), delay);\n return () => clearTimeout(timer);\n }, [addDays, fromMillis, getToday, toMillis, 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 {\n view,\n defaultView,\n startWeek,\n viewValue,\n defaultViewValue,\n dateUtils,\n onChangeView,\n 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) =>\n 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\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n height=\"12\"\n viewBox=\"0 0 13 12\"\n width=\"13\"\n {...props}\n >\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}","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 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\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 document.addEventListener(\"pointerdown\", handlePointerDown);\n return () => document.removeEventListener(\"pointerdown\", handlePointerDown);\n }, [open, refs.floating]);\n\n const heading = useMemo(\n () =>\n renderHeading\n ? renderHeading(viewValue, view)\n : getViewHeading(dateUtils, view, viewValue, startWeek),\n [dateUtils, renderHeading, startWeek, view, viewValue]\n );\n\n const gridDays = useMemo(\n () => getMonthGrid(dateUtils, pickerMonth, startWeek),\n [dateUtils, pickerMonth, startWeek]\n );\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\n className={cx(styles.root__toggleIcon, { [styles.root__toggleIcon_open]: open })}\n />\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}>\n {formatMonthYear(dateUtils, pickerMonth)}\n </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}","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}","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 d=\"M3 8.5 6.5 12 13 4.5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\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}","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}","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({\n coordinates,\n className,\n style,\n ...props\n}: 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}","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 { 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};\n\nexport default function DragOverlay({ showPreview = true, ...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 (or the pointer left the calendar): the browser\n // plays its own \"return\" animation of the (invisible) drag image before it ends the drag,\n // and the event stays faded until then. The overlay flies back onto the event meanwhile.\n const lastTransformRef = useRef<typeof transform | null>(null);\n const [returning, setReturning] = useState<{ container: HTMLElement; style: CSSProperties } | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (!isDragging || dropData) {\n lastTransformRef.current = isDragging ? transform : null;\n setReturning(null);\n return;\n }\n const from = lastTransformRef.current;\n const container = viewportRef.current;\n if (returning || !from || !source || !container) return;\n\n const sourceRect = source.getBoundingClientRect();\n const containerRect = container.getBoundingClientRect();\n setReturning({\n container,\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 if (!isDragging) {\n return null;\n }\n\n if (!dropData) {\n return returning ? (\n <Portal container={returning.container}>\n <div {...props} className={cx(props.className, styles.root, styles.root_isReturning)} style={returning.style}>\n {eventValue != null ? eventRenderer.current?.(eventValue, view, WHOLE_EVENT) : null}\n </div>\n </Portal>\n ) : null;\n }\n\n // Native drag and drop ignores CSS cursors, and macOS shows no \"not allowed\" cursor\n // for `dropEffect = \"none\"`: over a day or time the event cannot be dropped on, the\n // overlay stays, 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?.(dropData.date, transform.top, transform.height)\n : null}\n </PointerPopover>\n )}\n </Portal>\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\n/** Index (`data-day-index`) of the day cell in `container` under the point, or of the nearest one; -1 without cells. */\nexport function getNearestDayIndex(container: HTMLElement | null, x: number, y: number): number {\n const cells = container?.querySelectorAll<HTMLElement>(\"[data-day-index]\") ?? [];\n let best = -1;\n let bestDistance = Infinity;\n for (const cell of cells) {\n const rect = cell.getBoundingClientRect();\n const dx = x < rect.left ? rect.left - x : x >= rect.right ? x - rect.right : 0;\n const dy = y < rect.top ? rect.top - y : y >= rect.bottom ? y - rect.bottom : 0;\n const distance = Math.hypot(dx, dy);\n if (distance < bestDistance) {\n bestDistance = distance;\n best = Number(cell.dataset.dayIndex);\n }\n }\n return best;\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 =>\n 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 }, [\n dateUtils,\n disabled,\n eventMap,\n getHours,\n getIsDayDisabled,\n getMinutes,\n onEventChange,\n register,\n targetDate,\n ]);\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(\n rootRef,\n forwardedRef\n );\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}","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({\n delta,\n disabled,\n}: {\n delta: Coordinates;\n disabled: boolean;\n}): 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]:\n previousIntent.x[ScrollDirection.Backward] || direction.x === -1,\n [ScrollDirection.Forward]: previousIntent.x[ScrollDirection.Forward] || direction.x === 1,\n },\n y: {\n [ScrollDirection.Backward]:\n 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","/* eslint-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 (\n disabled ||\n typeof window === \"undefined\" ||\n typeof window.MutationObserver === \"undefined\"\n ) {\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 === false) {\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 // eslint-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}","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(\n elements: Element[],\n measure = getClientRect\n): 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 {\n add,\n defaultCoordinates,\n getScrollableElement,\n getScrollCoordinates,\n getScrollOffsets,\n} 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] =>\n isNotNull(entry)\n );\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(\n (acc, coordinates) => add(acc, coordinates),\n defaultCoordinates\n )\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(\n scrollOffsets: Coordinates,\n dependencies: DependencyList = emptyArray\n) {\n const initialScrollOffsets = useRef<Coordinates | null>(null);\n\n useEffect(\n () => {\n initialScrollOffsets.current = null;\n },\n // eslint-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\n ? subtract(scrollOffsets, initialScrollOffsets.current)\n : 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<unknown> = {\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 =\n (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 =\n 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>(\n type: T\n ): 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(\n state: UseMoveTransformState,\n action: UseMoveTransformActions\n) {\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\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\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 } 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\n\nexport type MonthViewEventProps = DetailedHTMLProps<\n HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n> & {\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 /** 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 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\n ? ([...droppable.dropTargets].pop() ?? [null])\n : [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({\n activeNodeRect,\n containerNodeRect,\n transform,\n translate,\n initialTranslate,\n }) {\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 const syncTransform = useEventCallback((transform: MoveTransform) => {\n if (context === \"overlay\") {\n setOverlayTransform(transform);\n }\n });\n\n useEffect(() => {\n syncTransform(transform);\n // eslint-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 = e.currentTarget.parentElement;\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\n {...resizeEndListeners}\n data-edge=\"end\"\n className={cx(styles.root__resize, styles.root__resizeEnd)}\n />\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 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 /** 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, layout, sourceBars, lanes, resizingKey, resize } = props;\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>) => 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 resizable={!disabled}\n resize={resize}\n isResizeSource={isResizeSource}\n isAnyResizing={isResizing}\n >\n {renderEvent(bar)}\n </MonthViewEvent>\n );\n\n return (\n <div className={styles.root__week}>\n {days.map((day, column) => (\n <MonthViewDay\n key={toMillis(day)}\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, useStateRef } from \"../../hooks\";\n\nimport { getNearestDayIndex } from \"./MonthView.utils\";\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, in the order of the cells' `data-day-index`. */\n days: CalendarDate[];\n viewportRef: RefObject<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, 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\n const end = useEventCallback((commit: boolean = true) => {\n const current = sessionRef.current;\n if (!current) return;\n removeAllGlobalListeners();\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 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[getNearestDayIndex(viewportRef.current, 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 { 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 } =\n 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\n const days = useMemo(\n () => getMonthGrid(dateUtils, viewValue, startWeek),\n [dateUtils, startWeek, viewValue]\n );\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 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 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, useEffect, 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\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\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 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, dateUtils, bounds, timeStep, preventOutBoundsChanges } = params;\n const [state, setState] = useState<ResizeState | null>(null);\n const session = useRef<{\n key: EventKey;\n edge: ResizeEdge;\n original: [number, number];\n range: [number, number];\n x: number;\n y: number;\n } | null>(null);\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 = viewportRef.current;\n if (!current || !viewport) return;\n current.x = x;\n current.y = y;\n\n const { disabled, getIsDayDisabled } = paramsRef.current;\n const columns = [...viewport.querySelectorAll<HTMLElement>(\"[data-day-index]\")];\n const rect = viewport.getBoundingClientRect();\n const snap = (minute: number) => Math.round(minute / timeStep) * timeStep;\n const minute = snap(Math.min(Math.max(((y - rect.top) / rect.height) * timelineMinutes, 0), timelineMinutes));\n\n // The column under the pointer, or the nearest one.\n let dayIndex = 0;\n let bestDistance = Infinity;\n columns.forEach((column) => {\n const box = column.getBoundingClientRect();\n const distance = x < box.left ? box.left - x : x > box.right ? x - box.right : 0;\n if (distance < bestDistance) {\n bestDistance = distance;\n dayIndex = Number(column.dataset.dayIndex);\n }\n });\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 [Math.ceil(top / timeStep) * timeStep, Math.min(Math.ceil(bottom / timeStep) * timeStep, timelineMinutes)];\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, preventOutBoundsChanges, timeStep, timelineMinutes, viewportRef]\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]) 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 setState({ key, range: original, x, y, blocked: false });\n },\n move: update,\n end() {\n const current = session.current;\n session.current = null;\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 [dateUtils, days, update]\n );\n\n // Auto-scroll moves the timeline under a still pointer: follow it.\n const isActive = state !== null;\n useEffect(() => {\n if (!isActive) return;\n const handleScroll = () => session.current && update(session.current.x, session.current.y);\n document.addEventListener(\"scroll\", handleScroll, true);\n return () => document.removeEventListener(\"scroll\", handleScroll, true);\n }, [isActive, update]);\n\n // Over a place the edge cannot go: \"not allowed\" cursor on the whole page.\n const blocked = state?.blocked ?? false;\n useEffect(() => {\n if (!blocked) return;\n document.documentElement.classList.add(\"ww-cursor-not-allowed\");\n return () => document.documentElement.classList.remove(\"ww-cursor-not-allowed\");\n }, [blocked]);\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 { 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\nexport default function useTimeOffset(isActive = true, interval = 1000 * 60): [number, boolean] {\n const { hideMinMaxTime, hourMin, hourMax } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n\n const calculateOffset = (): [number, boolean] =>\n getNowOffset(dateUtils, { hourMin, hourMax, hideMinMaxTime });\n\n // Starts hidden and is computed after mount: the server (or a static\n // prerender) ran at a different time, so computing it during render would\n // make the hydrating render differ from the server HTML.\n const [offset, updateOffset] = useState<[number, boolean]>([0, true]);\n\n useTimeInterval(() => updateOffset(calculateOffset()), interval, isActive);\n\n return offset;\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 { 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} 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<\n HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n> & {\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 } = useDayWeekViewContext();\n const { hideMinMaxTime, preventOutBoundsChanges, timeStep, hourMin, hourMax, disabled } = options;\n const dateUtils = useCalendarDateUtils();\n const { isBefore, isToday } = dateUtils;\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 // eslint-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 containerNode: rootRef.current?.parentElement,\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 / timeStep) * timeStep;\n transform.height = timeStep;\n transform.left = 0;\n transform.width = activeNodeRect.width;\n\n let compensation: number;\n if (translate.y > 0) {\n compensation = timeStep - (offsetY % timeStep);\n transform.height =\n Math.ceil((transform.height + translate.y - compensation) / timeStep) * timeStep;\n } else {\n compensation = offsetY % timeStep;\n transform.height =\n Math.ceil((transform.height - translate.y - compensation) / timeStep) * timeStep;\n transform.top -= transform.height - timeStep;\n }\n\n transform.height = Math.max(transform.height, timeStep);\n\n return transform;\n },\n function resizeContainerModifier({ transform }) {\n if (!preventOutBoundsChanges) {\n return transform;\n }\n\n const [bottomEdge, topEdge] = getTimeFrame(targetDate).map(\n (x) => Math.ceil(x / timeStep) * timeStep\n );\n\n // restrict top\n if (transform.top < bottomEdge) {\n transform.height = Math.max(transform.height - (bottomEdge - transform.top), timeStep);\n transform.top = bottomEdge;\n }\n\n // restrict bottom\n if (transform.height + transform.top >= topEdge) {\n transform.height = Math.max(topEdge - transform.top, timeStep);\n }\n\n return transform;\n },\n boundingResizableContainerModifier,\n getTimeStepEqualizerModifier(timeStep),\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 =>\n 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 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 + transform.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: transform.top + hourMin * 60,\n duration: transform.height,\n });\n } else {\n onEventChange(eventData.key, targetDate, {\n from: transform.top,\n duration: transform.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);\n\n const transform = getTransform();\n if (\n transform.y < top ||\n transform.y > bottom ||\n (isToday && transform.height > bottom - top)\n ) {\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 register,\n targetDate,\n todayOrPast,\n ]);\n\n const { listeners: moveListeners } = useMove({\n distance: Math.max(Math.min(5, timeStep), 1),\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 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] = getTimeFrame(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: transform.top + hourMin * 60,\n duration: transform.height,\n });\n } else {\n onEventCreate(targetDate, {\n from: transform.top,\n duration: transform.height,\n });\n }\n },\n });\n\n const handleRootRef = useMergedRefs(\n rootRef,\n forwardedRef\n );\n\n const timeOffsetTitle = formatNowOffset(dateUtils, timeOffset, { hourMin, hideMinMaxTime });\n\n const renderPreview = () => {\n return pointerPreviewRenderer.current?.(targetDate, transform.top, 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 ...rootProps.style,\n [\"--offset\"]: timeOffset,\n } as CSSVarStyle}\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 } as CSSVarStyle}\n />\n </Portal>\n )}\n <div ref={containerRef} className={styles.root__container}>\n {children}\n </div>\n {isActive && (\n <>\n <div className={styles.root__spotlight} style={transform ? { ...transform } : undefined} />\n <PointerPopover coordinates={{ x: transform.x, y: transform.y }}>\n {renderPreview()}\n </PointerPopover>\n </>\n )}\n </div>\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 relativeRect: MeasuredEventData[\"rect\"]\n) {\n const [absEventRect, setAbsEventRect] = useState<MeasuredEventData[\"rect\"] | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n const rootEl = rootRef.current,\n parentEl = rootRef.current?.parentElement;\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [rootRef, ...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(\n eventDate: CalendarDate,\n absRect: MeasuredEventData[\"rect\"] | null\n) {\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 // eslint-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 { useDayWeekViewContext } from \"../../contexts/DayWeekViewContext\";\nimport useAbsEventRect from \"../../hooks/useAbsEventRect\";\nimport useCanResizeEvent from \"../../hooks/useCanResizeEvent\";\nimport useMoveTransform, {\n type MoveTransform,\n type MoveTransformModifier,\n} 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<\n HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n> & {\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, resize, resizing } = useDayWeekViewContext();\n const absEventRect = useAbsEventRect(rootRef, 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 } =\n useDragAndDrop(({ registerDragSource, draggable, droppable, setTransform, isActive }) => {\n const isDragging = isActive(rootRef.current);\n const [overElement, overData] = isDragging\n ? ([...droppable.dropTargets].pop() ?? [null, null])\n : [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 const activeDrawerRect = useRect(isDragging ? overElement : null);\n\n const activeNodeResolver = (ctx: DayWeekEventTransformContext | null) => {\n return ctx === \"overlay\"\n ? rootRef.current\n : ctx === \"top\"\n ? topBarRef.current\n : bottomBarRef.current;\n };\n\n const containerNodeResolver = (ctx: DayWeekEventTransformContext | null) => {\n return ctx === \"overlay\"\n ? viewportRef.current\n : // parent element is the drawer that has right padding\n // so we need to take next the parent of the drawer to\n // get full container width\n (rootRef.current?.parentElement?.parentElement ?? null);\n };\n\n const [{ isActive, transform, context }, actions] =\n useMoveTransform<DayWeekEventTransformContext>({\n autoScrollEnabled: !isDragging,\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 = timeStep - ((initialTranslate.y - activeNodeRect.top) % timeStep);\n transform.top += Math.ceil((translate.y - compensation) / timeStep) * timeStep;\n } else {\n compensation = (initialTranslate.y - activeNodeRect.top) % timeStep;\n transform.top += Math.floor((translate.y + compensation) / timeStep) * timeStep;\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(\n (x) => Math.ceil(x / timeStep) * timeStep\n );\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(timeStep),\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(\n rootRef,\n forwardedRef\n );\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 const syncTransform = useEventCallback((transform: MoveTransform) => {\n if (context === \"overlay\") {\n setOverlayTransform(transform);\n }\n });\n\n useEffect(() => {\n syncTransform(transform);\n // eslint-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(\n mergeCallbacks(rootProps.onPointerDown, (e) => e.stopPropagation())\n );\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(\n timeStep: number\n): MoveTransformModifier<DayWeekEventTransformContext> {\n return (args) => {\n const modifiers: MoveTransformModifier<DayWeekEventTransformContext>[] = [\n getTimeStepEqualizerModifier(timeStep),\n ];\n\n if (args.context === \"overlay\") {\n modifiers.push(boundingDraggableContainerModifier);\n }\n\n return applyMoveTransformModifiers(modifiers, args);\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\nimport styles from \"./DayWeekView.module.css\";\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 viewportRef: RefObject<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 viewport = viewportRef.current;\n if (cancelled || !viewport) 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 viewport.querySelectorAll(\"time\")) {\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 = viewport.closest(`.${styles.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, viewportRef]);\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, 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 viewportRef = useRef<HTMLDivElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\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 const timeColumnWidth = useTimeColumnWidth(viewportRef, 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 { state: resizing, actions: resize, previewOf } = useEventResize({\n days,\n viewportRef,\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 [\n today,\n dateUtils,\n days,\n eventGroups,\n getMonthDay,\n getWeekDay,\n isToday,\n weekDayShortName,\n ]\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, resize, resizing }),\n [viewportRef, getTimeFrame, 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 className={cx(rootProps.className, styles.root, {\n [styles.root_scrollable]: scrollable,\n })}\n style={{\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 <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 height: rowHeight,\n [\"--translateY\"]: idx * rowHeight,\n [\"--calendar-rows-count\"]: steps.length,\n } as CSSVarStyle}\n >\n <time className={timeClassName}>{time}</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 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 ? eventRenderer.current?.(resizingValue, view, { isStart: part.isStart, isEnd: part.isEnd }) : null}\n </DayWeekEventPreview>\n ))}\n </DayWeekDrawer>\n </div>\n ))}\n </div>\n </div>\n {scrollable && (\n <HiddenEvents scrollerRef={bodyRef} columns={eventColumns} rowHeight={rowHeight} />\n )}\n </div>\n </div>\n\n <DragOverlay />\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}","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} from \"@weekwise/core\";\nimport {\n useCalendarSize,\n useCurrentRef,\n useEventCallback,\n useMergedRefs,\n} 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 {\n CalendarContextValue,\n CalendarProps,\n EventChangeInfo,\n EventKey,\n EventMap,\n} 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(\n rootRef,\n forwardedRef,\n );\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 const dragAndDropApi = useRefWithInit(createDragAndDropApi).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(\n (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\n const handleOnEventCreate = useEventCallback(\n (date: CalendarDate, info: EventChangeInfo) => {\n onEventCreate?.(...getEventTimeFrameFromInfo(dateUtils, date, info));\n },\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(\n (date: CalendarDate, start: number, duration: number) => {\n const [from, to] = getTimelineRange(dateUtils, date, start, duration, {\n hourMin,\n hideMinMaxTime,\n });\n return pointerPreviewFormat\n ? pointerPreviewFormat(from, to)\n : formatTimelineRange(dateUtils, from, to);\n },\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 unknown 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 {view === \"month\" ? <MonthView /> : <DayWeekView />}\n </div>\n </ThemeSourceContext.Provider>\n </DragAndDropContext.Provider>\n </CalendarContext.Provider>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AASA,IAAMmJ,KAA0BvF,EAAqD,KAAA,CAAS;AAE1FwD,MACF+B,GAAwB,cAAc;;ACFxC,SAAwBC,KAAiD;CACvE,IAAMC,IAAUtF,EAAWoF,EAAuB;CAElD,IAAI,CAACE,GACH,MAAU,MAAM,qCAAqC;CAGvD,OAAOA;AACT;AAGA,SAAgBC,IAAkD;CAChE,OAAOF,GAA2B;AACpC;;AChBA,IAAMG,KAAkB3F,EAA4C,KAAA,CAAS;AAEzEwD,MACFmC,GAAgB,cAAc;;ACahC,SAAwBC,GACtBC,GACA;CACA,IAAM,EAAEC,YAASC,aAAUC,gBAAaH,GAElCI,IAAYzF,QACT,OAAOsF,KAAY,aAAa,IAAIA,EAAQ,IAAIA,GACvD,CAACA,CAAO,CACV,GAEMI,IAAmB1F,QACjBpE,GAAgB6J,EA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EACEtmB;EACAsmB;EACA7U;EACA5I;EACAD;EACAgG;EACAlC;EACAD;EACAsB;EACAsP;EACAE;EACAD;EACAwF;EACAxiB;EACA4H;EACAmU;EACArU;EACAG;EACAge;EACAH;EACAK;EACAD;EACAI;CACF,CACF;CAEA,OACEltB,kBAAC,OAAD;EACE,GAAI0U;EACJ,WAAW5S,EAAG4S,EAAU,WAAWzU,GAAO,IAAI;EAC9C,gBAAc+G,OAAS,YAAY,KAAA,IAAYA;EAE/C,UAAAhH,kBAACsO,GAAgB,UAAjB;GAA0B,OAAOmU;GAC/B,UAAAziB,kBAAC+E,GAAmB,UAApB;IAA6B,OAAO0nB;IAClC,UAAAvsB,kBAACsO,GAAmB,UAApB;KAA6B,OAAOyD;KAApC,UAAA,CACEjS,kBAAC,OAAD;MAAK,WAAWC,GAAO;MACrB,UAAAD,kBAACwU,IAAD,CAAkB,CAAA;KACf,CAAA,GACLxU,kBAAC,OAAD;MAAK,WAAWC,GAAO;MACpB,UAAmBD,EAAnB0O,MAAS,UAAW0T,KAAgBkH,IAAjB,CAAY,CAAkB;KAC/C,CAAA,CACsB;;GACF,CAAA;EACL,CAAA;CACvB,CAAA;AAET"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["resolveMessages","_jsx","resolveMessages","_jsx","_jsx","_jsxs","styles","_jsx","_jsx","styles","_jsxs","_Fragment","styles","_jsx","styles","_jsxs","_jsx","_jsx","styles","_jsx","styles","_jsxs","_jsx","styles","defaultValue","_jsxs","styles","_jsx","_jsx","styles","_jsx","_jsxs","styles","_jsxs","styles","_jsx","_jsxs","styles","_jsx","_Fragment","styles","_jsx","_Fragment","_jsxs","_jsx","styles","_jsxs","styles","_jsx","styles","getTimeFrame","getDayTimeFrame","styles","_jsx","_jsxs","_Fragment","props","_jsx","styles","_jsxs","createContext","startTransition","useCallback","useContext","useEffect","useId","useInsertionEffect","useLayoutEffect","useMemo","useReducer","useRef","useState","useSyncExternalStore","MONTH_WEEK_GEOMETRY","ROW_HEIGHTS","Rect","THEME_PROPERTIES","add","adjustScrollRect","applyMoveTransformModifiers","arrangeEventsByDay","arrangeMonthWeek","boundingDraggableContainerModifier","boundingResizableContainerModifier","buildEventMap","buildTimeRows","builtInMessages","cx","defaultCoordinates","emptyArray","formatMonthYear","formatNowOffset","formatTimelineRange","fromDayMinutes","getCalendarSize","getClientRect","getEventTimeFrameFromInfo","getHiddenEvents","getMonthGrid","getMonthLaneCount","getNavigationTarget","getNowOffset","getRevealScrollTop","getScrollCoordinates","getScrollDirectionAndSpeed","getScrollOffsets","getScrollableAncestors","getScrollableElement","getTimeFrame","getTimeStepEqualizerModifier","getTimelineRange","getViewChangeTarget","getViewHeading","getVisibleDays","getWeekdayNames","getWindow","isDevEnvironment","isHTMLElement","isInViewPeriod","isNotNull","isPastDay","match","mergeCallbacks","normalizeViewValue","omit","resizeEventDays","resizeEventRange","resolveMessages","resolveMessages$1","round","shallowEqual","splitIntoDays","subtract","toDayMinutes","transferDay","createDragAndDropApi","DragAndDropContext","useDragAndDrop","autoUpdate","flip","offset","shift","useFloating","Fragment","jsx","jsxs","createPortal","DateLocalizationContext","useDateUtils","context","useCalendarDateUtils","MessagesContext","DateLocalizationProvider","props","adapter","messages","children","dateUtils","resolvedMessages","useMessages","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","UNINITIALIZED","useRefWithInit","init","initArg","assertNotCalled","createStableCallback","stable","args","useEventCallback","callback","useGlobalListeners","globalListeners","addGlobalListener","removeGlobalListener","removeAllGlobalListeners","target","type","listener","options","fn","event","toFnRef","mergeRefs","refs","useMergedRefs","useMove","state","paramsRef","attr","stopEvent","update","coordinates","pointerId","distance","handlers","clientX","clientY","prevClientX","prevClientY","getCommonEventData","pointerType","deltaX","deltaY","initialDeltaX","initialDeltaY","onMouseMove","onMouseUp","onTouchMove","touch","identifier","trouchEvent","onTouchEnd","onPointerMove","onPointerUp","triggerKeyboardMove","start","move","end","usePrevious","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","subscribe","getClientSnapshot","getServerSnapshot","useIsHydrated","readTheme","source","theme","computed","name","Portal","container","hydrated","themeSource","DateNavigator_module_default","DateNavigator","renderHeading","onClick","onKeyDown","className","buttonProps","getStartOfWeek","getStartOfMonth","addMonths","open","setOpen","pickerMonth","setPickerMonth","rootRef","floatingStyles","handlePointerDown","heading","gridDays","handleToggleClick","prev","handleToggleKeyDown","handleSelectDay","day","index","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","x","y","transform","draggable","overlay","droppable","items","item","eventValue","key","lastTransformRef","returning","setReturning","sourceRect","containerRect","isBlocked","cssVariables","variables","splitIntoWeeks","days","_","week","getNearestDayIndex","cells","best","bestDistance","cell","rect","dx","dy","MonthView_module_default","MonthViewDay","forwardedRef","targetDate","onDoubleClick","onEventChange","onEventCreate","getIsDayDisabled","getHours","getMinutes","getNow","register","isOver","registerDropTarget","dropTargetElement","dragItem","data","eventData","sourceDay","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","axis","useMutationObserver","mutationObserver","MutationObserver","useRect","measure","fallbackRect","measureRect","reducer","records","record","currentRect","newRect","defaultValue$1","useScrollableAncestors","node","limit","previousNode","ancestors","useScrollableAncestorsRects","elements","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","resizable","resize","isResizeSource","isAnyResizing","grabbedDayRef","attributes","overElement","setOverlayTransform","registerDragSource","setTransform","overDayRect","translate","initialTranslate","top","minTop","maxTop","syncTransform","getDragItems","\"event\"","column","clamped","resizeListeners","edge","resizeStartListeners","resizeEndListeners","multiDay","MonthViewEventPreview","bar","MonthViewWeek","firstDayIndex","layout","sourceBars","lanes","resizingKey","getMonthDay","isSameMonth","toMillis","isResizing","renderEvent","renderBar","useMonthLanes","maxLanes","setLanes","useMonthResize","session","setSession","sessionRef","commit","handleKeyDown","shownEventMap","date","NO_BARS","MonthView","weeks","weekdayNames","layouts","shownLayouts","contextValue","weekdayName","weekIndex","DAY","useEventResize","bounds","timeStep","preventOutBoundsChanges","timelineMinutes","viewport","columns","minute","dayIndex","box","idx","bottom","original","blocked","range","DayWeekViewContext","useDayWeekViewContext","useTimeOffset","hideMinMaxTime","hourMin","hourMax","tick","setTick","DayWeekDrawer_module_default","DayWeekDrawer","isBefore","stepPx","toMinutes","px","toTimelineMinutes","getTimeFramePx","containerRef","getTransform","todayOrPast","isTodayFlag","resizingActiveNodeRect","offsetY","compensation","bottomEdge","topEdge","timeOffset","offLimits","startOfEvent","partDay","fromStart","dayShift","isPast","moveListeners","currentTop","timeOffsetTitle","renderPreview","useAbsEventRect","relativeRect","absEventRect","setAbsEventRect","rootEl","parentEl","positions","useCanResizeEvent","eventDate","absRect","canResize","setCanResize","bottomRect","DayWeekEvent_module_default","DayWeekEvent","topBarRef","bottomBarRef","resizing","overData","activeDrawerRect","ctx","getEventTransformModifiers","moveEndHandler","e","resizeBottomListeners","resizeTopListeners","isDragginOverlay","rootClassName","rootStyle","DayWeekEventPreview","part","percent","minutes","DayWeekView_module_default","HiddenEvents","scrollerRef","rowHeight","scroll","setScroll","scroller","hidden","events","reveal","renderButton","nearest","label","above","below","useTimeColumnWidth","labels","defaultWidth","setWidth","cancelled","needed","text","outside","themed","TIME_COLUMN_WIDTH","DayWeekView","rowHeightProp","scrollable","getWeekDay","weekDayShortName","bodyRef","timeRows","timeColumnWidth","time","eventGroups","eventColumns","previewOf","resizeParts","resizingValue","getTimeFrame$1","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"],"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/useRefWithInit.ts","../src/hooks/useEventCallback.utils.ts","../src/hooks/useEventCallback.ts","../src/hooks/useGlobalListeners.ts","../src/utils/mergeRefs.ts","../src/hooks/useMergedRefs.ts","../src/hooks/useMove.ts","../src/hooks/usePrevious.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/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>(\n props: DateLocalizationProviderProps<TDate>\n) {\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(\n () => resolveMessages(dateUtils.locale, messages),\n [dateUtils.locale, messages]\n );\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;","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}","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 // eslint-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/**\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>(\n params: UseControlledParams<T> | UseControlledWithInitialParams<T>\n) {\n const { controlled, default: defaultValueProp } = params;\n const [valueState, setValueState] = useState(() => {\n if (\n defaultValueProp === undefined &&\n \"initialState\" in params &&\n params.initialState !== undefined\n ) {\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 // eslint-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 { 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}","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 // eslint-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\n | (<K extends keyof DocumentEventMap>(this: Document, ev: DocumentEventMap[K]) => any);\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}","import { useMemo, type Ref } from \"react\";\n\nimport mergeRefs from \"../utils/mergeRefs\";\n\nfunction useMergedRefs<T>(...refs: (Ref<T> | undefined)[]) {\n // eslint-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 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 {\n EventBase,\n MoveData,\n PointerCoordinates,\n PointerType,\n UseMoveParams,\n} 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 },\n }));\n\n const paramsRef = useRef(params);\n paramsRef.current = params;\n\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n\n const listeners = useMemo<DOMAttributes<Element>>(() => {\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 // eslint-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 (\n !state.isDistanceReached &&\n initialDeltaX ** 2 + initialDeltaY ** 2 >= distance ** 2\n ) {\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(\n ({ identifier }) => identifier === state.activePointId\n );\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(\n ({ identifier }) => identifier === state.activePointId\n );\n if (touch >= 0) {\n // end\n update(e.changedTouches[touch], null).end(\"touch\", e);\n\n addGlobalListener(window, \"touchmove\", onTouchMove);\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 onPointerMove = (e: PointerEvent) => {\n if (e.pointerId === state.activePointId) {\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n update(e).move(pointerType, e);\n }\n };\n\n const onPointerUp = (e: PointerEvent) => {\n if (e.pointerId === state.activePointId) {\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n\n update(e, null).end(pointerType, e);\n\n removeGlobalListener(window, \"pointermove\", onPointerMove, false);\n removeGlobalListener(window, \"pointerup\", onPointerUp, false);\n removeGlobalListener(window, \"pointercancel\", onPointerUp, false);\n }\n };\n\n attr.onPointerDown = (e: ReactPointerEvent) => {\n if (e.button === 0 && state.activePointId === null) {\n const pointerType = (e.pointerType || \"mouse\") as PointerType;\n\n if (update(e, e.pointerId).start(pointerType, e) !== false) {\n addGlobalListener(window, \"pointermove\", onPointerMove, false);\n addGlobalListener(window, \"pointerup\", onPointerUp, false);\n addGlobalListener(window, \"pointercancel\", onPointerUp, false);\n\n stopEvent(e);\n } else update(e, null);\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 return attr;\n }, [addGlobalListener, removeGlobalListener, state]);\n\n return { listeners };\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 { 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 {\n view,\n defaultView,\n startWeek,\n viewValue,\n defaultViewValue,\n dateUtils,\n onChangeView,\n 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) =>\n 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\n xmlns=\"http://www.w3.org/2000/svg\"\n fill=\"none\"\n height=\"12\"\n viewBox=\"0 0 13 12\"\n width=\"13\"\n {...props}\n >\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}","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 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\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 document.addEventListener(\"pointerdown\", handlePointerDown);\n return () => document.removeEventListener(\"pointerdown\", handlePointerDown);\n }, [open, refs.floating]);\n\n const heading = useMemo(\n () =>\n renderHeading\n ? renderHeading(viewValue, view)\n : getViewHeading(dateUtils, view, viewValue, startWeek),\n [dateUtils, renderHeading, startWeek, view, viewValue]\n );\n\n const gridDays = useMemo(\n () => getMonthGrid(dateUtils, pickerMonth, startWeek),\n [dateUtils, pickerMonth, startWeek]\n );\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\n className={cx(styles.root__toggleIcon, { [styles.root__toggleIcon_open]: open })}\n />\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}>\n {formatMonthYear(dateUtils, pickerMonth)}\n </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}","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}","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 d=\"M3 8.5 6.5 12 13 4.5\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" />\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}","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}","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({\n coordinates,\n className,\n style,\n ...props\n}: 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}","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 { 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 (or the pointer left the calendar): the browser\n // plays its own \"return\" animation of the (invisible) drag image before it ends the drag,\n // and the event stays faded until then. The overlay flies back onto the event meanwhile.\n const lastTransformRef = useRef<typeof transform | null>(null);\n const [returning, setReturning] = useState<{ container: HTMLElement; style: CSSProperties } | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (!isDragging || dropData) {\n lastTransformRef.current = isDragging ? transform : null;\n setReturning(null);\n return;\n }\n const from = lastTransformRef.current;\n const container = viewportRef.current;\n if (returning || !from || !source || !container) return;\n\n const sourceRect = source.getBoundingClientRect();\n const containerRect = container.getBoundingClientRect();\n setReturning({\n container,\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 if (!isDragging) {\n return null;\n }\n\n if (!dropData) {\n return returning ? (\n <Portal container={returning.container}>\n <div {...props} className={cx(props.className, styles.root, styles.root_isReturning)} style={returning.style}>\n {eventValue != null ? eventRenderer.current?.(eventValue, view, WHOLE_EVENT) : null}\n </div>\n </Portal>\n ) : null;\n }\n\n // Native drag and drop ignores CSS cursors, and macOS shows no \"not allowed\" cursor\n // for `dropEffect = \"none\"`: over a day or time the event cannot be dropped on, the\n // overlay stays, 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}","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\n/** Index (`data-day-index`) of the day cell in `container` under the point, or of the nearest one; -1 without cells. */\nexport function getNearestDayIndex(container: HTMLElement | null, x: number, y: number): number {\n const cells = container?.querySelectorAll<HTMLElement>(\"[data-day-index]\") ?? [];\n let best = -1;\n let bestDistance = Infinity;\n for (const cell of cells) {\n const rect = cell.getBoundingClientRect();\n const dx = x < rect.left ? rect.left - x : x >= rect.right ? x - rect.right : 0;\n const dy = y < rect.top ? rect.top - y : y >= rect.bottom ? y - rect.bottom : 0;\n const distance = Math.hypot(dx, dy);\n if (distance < bestDistance) {\n bestDistance = distance;\n best = Number(cell.dataset.dayIndex);\n }\n }\n return best;\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 =>\n 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 }, [\n dateUtils,\n disabled,\n eventMap,\n getHours,\n getIsDayDisabled,\n getMinutes,\n onEventChange,\n register,\n targetDate,\n ]);\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(\n rootRef,\n forwardedRef\n );\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}","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({\n delta,\n disabled,\n}: {\n delta: Coordinates;\n disabled: boolean;\n}): 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]:\n previousIntent.x[ScrollDirection.Backward] || direction.x === -1,\n [ScrollDirection.Forward]: previousIntent.x[ScrollDirection.Forward] || direction.x === 1,\n },\n y: {\n [ScrollDirection.Backward]:\n 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","/* eslint-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 (\n disabled ||\n typeof window === \"undefined\" ||\n typeof window.MutationObserver === \"undefined\"\n ) {\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 === false) {\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 // eslint-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}","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(\n elements: Element[],\n measure = getClientRect\n): 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 {\n add,\n defaultCoordinates,\n getScrollableElement,\n getScrollCoordinates,\n getScrollOffsets,\n} 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] =>\n isNotNull(entry)\n );\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(\n (acc, coordinates) => add(acc, coordinates),\n defaultCoordinates\n )\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(\n scrollOffsets: Coordinates,\n dependencies: DependencyList = emptyArray\n) {\n const initialScrollOffsets = useRef<Coordinates | null>(null);\n\n useEffect(\n () => {\n initialScrollOffsets.current = null;\n },\n // eslint-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\n ? subtract(scrollOffsets, initialScrollOffsets.current)\n : 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<unknown> = {\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 =\n (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 =\n 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>(\n type: T\n ): 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(\n state: UseMoveTransformState,\n action: UseMoveTransformActions\n) {\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\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\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 } 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\n\nexport type MonthViewEventProps = DetailedHTMLProps<\n HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n> & {\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 /** 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 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\n ? ([...droppable.dropTargets].pop() ?? [null])\n : [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({\n activeNodeRect,\n containerNodeRect,\n transform,\n translate,\n initialTranslate,\n }) {\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 const syncTransform = useEventCallback((transform: MoveTransform) => {\n if (context === \"overlay\") {\n setOverlayTransform(transform);\n }\n });\n\n useEffect(() => {\n syncTransform(transform);\n // eslint-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 = e.currentTarget.parentElement;\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\n {...resizeEndListeners}\n data-edge=\"end\"\n className={cx(styles.root__resize, styles.root__resizeEnd)}\n />\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 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 /** 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, layout, sourceBars, lanes, resizingKey, resize } = props;\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>) => 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 resizable={!disabled}\n resize={resize}\n isResizeSource={isResizeSource}\n isAnyResizing={isResizing}\n >\n {renderEvent(bar)}\n </MonthViewEvent>\n );\n\n return (\n <div className={styles.root__week}>\n {days.map((day, column) => (\n <MonthViewDay\n key={toMillis(day)}\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, useStateRef } from \"../../hooks\";\n\nimport { getNearestDayIndex } from \"./MonthView.utils\";\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, in the order of the cells' `data-day-index`. */\n days: CalendarDate[];\n viewportRef: RefObject<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, 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\n const end = useEventCallback((commit: boolean = true) => {\n const current = sessionRef.current;\n if (!current) return;\n removeAllGlobalListeners();\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 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[getNearestDayIndex(viewportRef.current, 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 { 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 } =\n 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\n const days = useMemo(\n () => getMonthGrid(dateUtils, viewValue, startWeek),\n [dateUtils, startWeek, viewValue]\n );\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 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 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, useEffect, 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\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\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 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, dateUtils, bounds, timeStep, preventOutBoundsChanges } = params;\n const [state, setState] = useState<ResizeState | null>(null);\n const session = useRef<{\n key: EventKey;\n edge: ResizeEdge;\n original: [number, number];\n range: [number, number];\n x: number;\n y: number;\n } | null>(null);\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 = viewportRef.current;\n if (!current || !viewport) return;\n current.x = x;\n current.y = y;\n\n const { disabled, getIsDayDisabled } = paramsRef.current;\n const columns = [...viewport.querySelectorAll<HTMLElement>(\"[data-day-index]\")];\n const rect = viewport.getBoundingClientRect();\n const snap = (minute: number) => Math.round(minute / timeStep) * timeStep;\n const minute = snap(Math.min(Math.max(((y - rect.top) / rect.height) * timelineMinutes, 0), timelineMinutes));\n\n // The column under the pointer, or the nearest one.\n let dayIndex = 0;\n let bestDistance = Infinity;\n columns.forEach((column) => {\n const box = column.getBoundingClientRect();\n const distance = x < box.left ? box.left - x : x > box.right ? x - box.right : 0;\n if (distance < bestDistance) {\n bestDistance = distance;\n dayIndex = Number(column.dataset.dayIndex);\n }\n });\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 [Math.ceil(top / timeStep) * timeStep, Math.min(Math.ceil(bottom / timeStep) * timeStep, timelineMinutes)];\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, preventOutBoundsChanges, timeStep, timelineMinutes, viewportRef]\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]) 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 setState({ key, range: original, x, y, blocked: false });\n },\n move: update,\n end() {\n const current = session.current;\n session.current = null;\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 [dateUtils, days, update]\n );\n\n // Auto-scroll moves the timeline under a still pointer: follow it.\n const isActive = state !== null;\n useEffect(() => {\n if (!isActive) return;\n const handleScroll = () => session.current && update(session.current.x, session.current.y);\n document.addEventListener(\"scroll\", handleScroll, true);\n return () => document.removeEventListener(\"scroll\", handleScroll, true);\n }, [isActive, update]);\n\n // Over a place the edge cannot go: \"not allowed\" cursor on the whole page.\n const blocked = state?.blocked ?? false;\n useEffect(() => {\n if (!blocked) return;\n document.documentElement.classList.add(\"ww-cursor-not-allowed\");\n return () => document.documentElement.classList.remove(\"ww-cursor-not-allowed\");\n }, [blocked]);\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 { 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 { 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} 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<\n HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n> & {\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) =>\n 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 // eslint-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 containerNode: rootRef.current?.parentElement,\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(\n (x) => Math.ceil(x / timeStep) * stepPx\n );\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 =>\n 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 (\n transform.y < top ||\n transform.y > bottom ||\n (isToday && transform.height > bottom - top)\n ) {\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 } = useMove({\n distance: Math.max(Math.min(5, timeStep), 1),\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 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 handleRootRef = useMergedRefs(\n rootRef,\n forwardedRef\n );\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 ...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 {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 {children}\n </div>\n {isActive && (\n <>\n <div className={styles.root__spotlight} style={transform ? { ...transform } : undefined} />\n <PointerPopover coordinates={{ x: transform.x, y: transform.y }}>\n {renderPreview()}\n </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 relativeRect: MeasuredEventData[\"rect\"]\n) {\n const [absEventRect, setAbsEventRect] = useState<MeasuredEventData[\"rect\"] | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n const rootEl = rootRef.current,\n parentEl = rootRef.current?.parentElement;\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 // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [rootRef, ...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(\n eventDate: CalendarDate,\n absRect: MeasuredEventData[\"rect\"] | null\n) {\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 // eslint-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 { useDayWeekViewContext } from \"../../contexts/DayWeekViewContext\";\nimport useAbsEventRect from \"../../hooks/useAbsEventRect\";\nimport useCanResizeEvent from \"../../hooks/useCanResizeEvent\";\nimport useMoveTransform, {\n type MoveTransform,\n type MoveTransformModifier,\n} 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<\n HTMLAttributes<HTMLDivElement>,\n HTMLDivElement\n> & {\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 absEventRect = useAbsEventRect(rootRef, 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 } =\n useDragAndDrop(({ registerDragSource, draggable, droppable, setTransform, isActive }) => {\n const isDragging = isActive(rootRef.current);\n const [overElement, overData] = isDragging\n ? ([...droppable.dropTargets].pop() ?? [null, null])\n : [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 const activeDrawerRect = useRect(isDragging ? overElement : null);\n\n const activeNodeResolver = (ctx: DayWeekEventTransformContext | null) => {\n return ctx === \"overlay\"\n ? rootRef.current\n : ctx === \"top\"\n ? topBarRef.current\n : bottomBarRef.current;\n };\n\n const containerNodeResolver = (ctx: DayWeekEventTransformContext | null) => {\n return ctx === \"overlay\"\n ? viewportRef.current\n : // parent element is the drawer that has right padding\n // so we need to take next the parent of the drawer to\n // get full container width\n (rootRef.current?.parentElement?.parentElement ?? null);\n };\n\n const [{ isActive, transform, context }, actions] =\n useMoveTransform<DayWeekEventTransformContext>({\n autoScrollEnabled: !isDragging,\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(\n (x) => Math.ceil(x / timeStep) * stepPx\n );\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(\n rootRef,\n forwardedRef\n );\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 const syncTransform = useEventCallback((transform: MoveTransform) => {\n if (context === \"overlay\") {\n setOverlayTransform(transform);\n }\n });\n\n useEffect(() => {\n syncTransform(transform);\n // eslint-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(\n mergeCallbacks(rootProps.onPointerDown, (e) => e.stopPropagation())\n );\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(\n timeStep: number\n): MoveTransformModifier<DayWeekEventTransformContext> {\n return (args) => {\n const modifiers: MoveTransformModifier<DayWeekEventTransformContext>[] = [\n getTimeStepEqualizerModifier(timeStep),\n ];\n\n if (args.context === \"overlay\") {\n modifiers.push(boundingDraggableContainerModifier);\n }\n\n return applyMoveTransformModifiers(modifiers, args);\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\nimport styles from \"./DayWeekView.module.css\";\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 viewportRef: RefObject<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 viewport = viewportRef.current;\n if (cancelled || !viewport) 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 viewport.querySelectorAll(\"time\")) {\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 = viewport.closest(`.${styles.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, viewportRef]);\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, 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 viewportRef = useRef<HTMLDivElement>(null);\n const bodyRef = useRef<HTMLDivElement>(null);\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 const timeColumnWidth = useTimeColumnWidth(viewportRef, 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 { state: resizing, actions: resize, previewOf } = useEventResize({\n days,\n viewportRef,\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 [\n today,\n dateUtils,\n days,\n eventGroups,\n getMonthDay,\n getWeekDay,\n isToday,\n weekDayShortName,\n ]\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 className={cx(rootProps.className, styles.root, {\n [styles.root_scrollable]: scrollable,\n })}\n style={{\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 <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 height: rowHeight,\n [\"--translateY\"]: idx * rowHeight,\n [\"--calendar-rows-count\"]: steps.length,\n } as CSSVarStyle}\n >\n <time className={timeClassName}>{time}</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 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 ? eventRenderer.current?.(resizingValue, view, { isStart: part.isStart, isEnd: part.isEnd }) : null}\n </DayWeekEventPreview>\n ))}\n </DayWeekDrawer>\n </div>\n ))}\n </div>\n </div>\n {scrollable && (\n <HiddenEvents scrollerRef={bodyRef} columns={eventColumns} rowHeight={rowHeight} />\n )}\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}","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} from \"@weekwise/core\";\nimport {\n useCalendarSize,\n useCurrentRef,\n useEventCallback,\n useMergedRefs,\n} 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 {\n CalendarContextValue,\n CalendarProps,\n EventChangeInfo,\n EventKey,\n EventMap,\n} 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(\n rootRef,\n forwardedRef,\n );\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 const dragAndDropApi = useRefWithInit(createDragAndDropApi).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(\n (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\n const handleOnEventCreate = useEventCallback(\n (date: CalendarDate, info: EventChangeInfo) => {\n onEventCreate?.(...getEventTimeFrameFromInfo(dateUtils, date, info));\n },\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(\n (date: CalendarDate, start: number, duration: number) => {\n const [from, to] = getTimelineRange(dateUtils, date, start, duration, {\n hourMin,\n hideMinMaxTime,\n });\n return pointerPreviewFormat\n ? pointerPreviewFormat(from, to)\n : formatTimelineRange(dateUtils, from, to);\n },\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}>\n {view === \"month\" ? <MonthView /> : <DayWeekView />}\n </div>\n </ThemeSourceContext.Provider>\n </DragAndDropContext.Provider>\n </CalendarContext.Provider>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;AASA,IAAMmJ,KAA0BvF,EAAqD,KAAA,CAAS;AAE1FwD,MACF+B,GAAwB,cAAc;;ACFxC,SAAwBC,KAAiD;CACvE,IAAMC,IAAUtF,EAAWoF,EAAuB;CAElD,IAAI,CAACE,GACH,MAAU,MAAM,qCAAqC;CAGvD,OAAOA;AACT;AAGA,SAAgBC,IAAkD;CAChE,OAAOF,GAA2B;AACp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