@weekwise/react 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/README.md +69 -9
  2. package/dist/Calendar.d.ts +4 -3
  3. package/dist/Calendar.js +20 -0
  4. package/dist/Calendar.js.map +1 -0
  5. package/dist/Calendar.module.css.js +11 -0
  6. package/dist/Calendar.module.css.js.map +1 -0
  7. package/dist/Calendar.types.d.ts +34 -6
  8. package/dist/CalendarBase.d.ts +8 -0
  9. package/dist/CalendarBase.js +161 -0
  10. package/dist/CalendarBase.js.map +1 -0
  11. package/dist/components/calendar-toolbar/CalendarToolbar.js +51 -0
  12. package/dist/components/calendar-toolbar/CalendarToolbar.js.map +1 -0
  13. package/dist/components/calendar-toolbar/CalendarToolbar.module.css.js +15 -0
  14. package/dist/components/calendar-toolbar/CalendarToolbar.module.css.js.map +1 -0
  15. package/dist/components/date-navigator/DateNavigator.js +129 -0
  16. package/dist/components/date-navigator/DateNavigator.js.map +1 -0
  17. package/dist/components/date-navigator/DateNavigator.module.css.js +25 -0
  18. package/dist/components/date-navigator/DateNavigator.module.css.js.map +1 -0
  19. package/dist/components/day-week-drawer/DayWeekDrawer.js +227 -0
  20. package/dist/components/day-week-drawer/DayWeekDrawer.js.map +1 -0
  21. package/dist/components/day-week-drawer/DayWeekDrawer.module.css.js +15 -0
  22. package/dist/components/day-week-drawer/DayWeekDrawer.module.css.js.map +1 -0
  23. package/dist/components/day-week-event/DayWeekEvent.js +154 -0
  24. package/dist/components/day-week-event/DayWeekEvent.js.map +1 -0
  25. package/dist/components/day-week-event/DayWeekEvent.module.css.js +17 -0
  26. package/dist/components/day-week-event/DayWeekEvent.module.css.js.map +1 -0
  27. package/dist/components/day-week-event/DayWeekEventPreview.js +26 -0
  28. package/dist/components/day-week-event/DayWeekEventPreview.js.map +1 -0
  29. package/dist/components/day-week-view/DayWeekView.js +226 -0
  30. package/dist/components/day-week-view/DayWeekView.js.map +1 -0
  31. package/dist/components/day-week-view/DayWeekView.module.css.js +27 -0
  32. package/dist/components/day-week-view/DayWeekView.module.css.js.map +1 -0
  33. package/dist/components/day-week-view/HiddenEvents.js +78 -0
  34. package/dist/components/day-week-view/HiddenEvents.js.map +1 -0
  35. package/dist/components/day-week-view/useTimeColumnWidth.js +34 -0
  36. package/dist/components/day-week-view/useTimeColumnWidth.js.map +1 -0
  37. package/dist/components/drag-overlay/DragOverlay.js +98 -0
  38. package/dist/components/drag-overlay/DragOverlay.js.map +1 -0
  39. package/dist/components/drag-overlay/DragOverlay.module.css.js +12 -0
  40. package/dist/components/drag-overlay/DragOverlay.module.css.js.map +1 -0
  41. package/dist/components/index.d.ts +1 -0
  42. package/dist/components/month-view/MonthView.d.ts +8 -2
  43. package/dist/components/month-view/MonthView.js +105 -0
  44. package/dist/components/month-view/MonthView.js.map +1 -0
  45. package/dist/components/month-view/MonthView.module.css.js +30 -0
  46. package/dist/components/month-view/MonthView.module.css.js.map +1 -0
  47. package/dist/components/month-view/MonthView.utils.js +14 -0
  48. package/dist/components/month-view/MonthView.utils.js.map +1 -0
  49. package/dist/components/month-view/MonthViewDay.d.ts +2 -0
  50. package/dist/components/month-view/MonthViewDay.js +75 -0
  51. package/dist/components/month-view/MonthViewDay.js.map +1 -0
  52. package/dist/components/month-view/MonthViewEvent.js +132 -0
  53. package/dist/components/month-view/MonthViewEvent.js.map +1 -0
  54. package/dist/components/month-view/MonthViewEventPreview.js +28 -0
  55. package/dist/components/month-view/MonthViewEventPreview.js.map +1 -0
  56. package/dist/components/month-view/MonthViewWeek.d.ts +5 -0
  57. package/dist/components/month-view/MonthViewWeek.js +67 -0
  58. package/dist/components/month-view/MonthViewWeek.js.map +1 -0
  59. package/dist/components/month-view/useMonthLanes.js +22 -0
  60. package/dist/components/month-view/useMonthLanes.js.map +1 -0
  61. package/dist/components/month-view/useMonthResize.js +57 -0
  62. package/dist/components/month-view/useMonthResize.js.map +1 -0
  63. package/dist/components/nav-btn/NavBtn.js +28 -0
  64. package/dist/components/nav-btn/NavBtn.js.map +1 -0
  65. package/dist/components/nav-btn/NavBtn.module.css.js +11 -0
  66. package/dist/components/nav-btn/NavBtn.module.css.js.map +1 -0
  67. package/dist/components/pointer-popover/PointerPopover.js +22 -0
  68. package/dist/components/pointer-popover/PointerPopover.js.map +1 -0
  69. package/dist/components/pointer-popover/PointerPopover.module.css.js +6 -0
  70. package/dist/components/pointer-popover/PointerPopover.module.css.js.map +1 -0
  71. package/dist/components/timeline-view/TimelineView.d.ts +6 -0
  72. package/dist/components/timeline-view/TimelineView.js +10 -0
  73. package/dist/components/timeline-view/TimelineView.js.map +1 -0
  74. package/dist/components/timeline-view/index.d.ts +1 -0
  75. package/dist/components/view-select/ViewSelect.d.ts +1 -1
  76. package/dist/components/view-select/ViewSelect.js +117 -0
  77. package/dist/components/view-select/ViewSelect.js.map +1 -0
  78. package/dist/components/view-select/ViewSelect.module.css.js +14 -0
  79. package/dist/components/view-select/ViewSelect.module.css.js.map +1 -0
  80. package/dist/contexts/CalendarContext.js +14 -0
  81. package/dist/contexts/CalendarContext.js.map +1 -0
  82. package/dist/contexts/CalendarViewportContext.js +14 -0
  83. package/dist/contexts/CalendarViewportContext.js.map +1 -0
  84. package/dist/contexts/DayWeekDrawerContext.js +14 -0
  85. package/dist/contexts/DayWeekDrawerContext.js.map +1 -0
  86. package/dist/contexts/DayWeekViewContext.js +14 -0
  87. package/dist/contexts/DayWeekViewContext.js.map +1 -0
  88. package/dist/contexts/ThemeSourceContext.js +9 -0
  89. package/dist/contexts/ThemeSourceContext.js.map +1 -0
  90. package/dist/date-localization/DateLocalizationContext.js +9 -0
  91. package/dist/date-localization/DateLocalizationContext.js.map +1 -0
  92. package/dist/date-localization/DateLocalizationProvider.js +20 -0
  93. package/dist/date-localization/DateLocalizationProvider.js.map +1 -0
  94. package/dist/date-localization/MessagesContext.js +9 -0
  95. package/dist/date-localization/MessagesContext.js.map +1 -0
  96. package/dist/date-localization/useDateUtils.js +15 -0
  97. package/dist/date-localization/useDateUtils.js.map +1 -0
  98. package/dist/date-localization/useMessages.js +13 -0
  99. package/dist/date-localization/useMessages.js.map +1 -0
  100. package/dist/hooks/useAbsEventRect.js +27 -0
  101. package/dist/hooks/useAbsEventRect.js.map +1 -0
  102. package/dist/hooks/useAutoScroller.js +83 -0
  103. package/dist/hooks/useAutoScroller.js.map +1 -0
  104. package/dist/hooks/useCalendarSize.js +20 -0
  105. package/dist/hooks/useCalendarSize.js.map +1 -0
  106. package/dist/hooks/useCalendarValue.d.ts +1 -1
  107. package/dist/hooks/useCalendarValue.js +51 -0
  108. package/dist/hooks/useCalendarValue.js.map +1 -0
  109. package/dist/hooks/useCanResizeEvent.js +29 -0
  110. package/dist/hooks/useCanResizeEvent.js.map +1 -0
  111. package/dist/hooks/useComputed.js +14 -0
  112. package/dist/hooks/useComputed.js.map +1 -0
  113. package/dist/hooks/useControlled.js +20 -0
  114. package/dist/hooks/useControlled.js.map +1 -0
  115. package/dist/hooks/useControlled.utils.js +33 -0
  116. package/dist/hooks/useControlled.utils.js.map +1 -0
  117. package/dist/hooks/useCurrentRef.js +10 -0
  118. package/dist/hooks/useCurrentRef.js.map +1 -0
  119. package/dist/hooks/useDocumentCursor.js +13 -0
  120. package/dist/hooks/useDocumentCursor.js.map +1 -0
  121. package/dist/hooks/useEventCallback.js +12 -0
  122. package/dist/hooks/useEventCallback.js.map +1 -0
  123. package/dist/hooks/useEventCallback.utils.js +20 -0
  124. package/dist/hooks/useEventCallback.utils.js.map +1 -0
  125. package/dist/hooks/useEventResize.js +106 -0
  126. package/dist/hooks/useEventResize.js.map +1 -0
  127. package/dist/hooks/useGlobalListeners.js +40 -0
  128. package/dist/hooks/useGlobalListeners.js.map +1 -0
  129. package/dist/hooks/useInterval.js +14 -0
  130. package/dist/hooks/useInterval.js.map +1 -0
  131. package/dist/hooks/useIsomorphicLayoutEffect.js +6 -0
  132. package/dist/hooks/useIsomorphicLayoutEffect.js.map +1 -0
  133. package/dist/hooks/useItemsLayout.js +53 -0
  134. package/dist/hooks/useItemsLayout.js.map +1 -0
  135. package/dist/hooks/useMergedRefs.js +10 -0
  136. package/dist/hooks/useMergedRefs.js.map +1 -0
  137. package/dist/hooks/useMove.js +180 -0
  138. package/dist/hooks/useMove.js.map +1 -0
  139. package/dist/hooks/useMoveTransform.js +118 -0
  140. package/dist/hooks/useMoveTransform.js.map +1 -0
  141. package/dist/hooks/useMutationObserver.js +16 -0
  142. package/dist/hooks/useMutationObserver.js.map +1 -0
  143. package/dist/hooks/useNavigation.js +15 -0
  144. package/dist/hooks/useNavigation.js.map +1 -0
  145. package/dist/hooks/usePrevious.js +12 -0
  146. package/dist/hooks/usePrevious.js.map +1 -0
  147. package/dist/hooks/useRect.js +37 -0
  148. package/dist/hooks/useRect.js.map +1 -0
  149. package/dist/hooks/useRefList.js +21 -0
  150. package/dist/hooks/useRefList.js.map +1 -0
  151. package/dist/hooks/useRefWithInit.js +11 -0
  152. package/dist/hooks/useRefWithInit.js.map +1 -0
  153. package/dist/hooks/useResizeObserver.js +16 -0
  154. package/dist/hooks/useResizeObserver.js.map +1 -0
  155. package/dist/hooks/useScrollBarSize.js +37 -0
  156. package/dist/hooks/useScrollBarSize.js.map +1 -0
  157. package/dist/hooks/useScrollIntent.js +41 -0
  158. package/dist/hooks/useScrollIntent.js.map +1 -0
  159. package/dist/hooks/useScrollOffsets.js +33 -0
  160. package/dist/hooks/useScrollOffsets.js.map +1 -0
  161. package/dist/hooks/useScrollOffsetsDelta.js +16 -0
  162. package/dist/hooks/useScrollOffsetsDelta.js.map +1 -0
  163. package/dist/hooks/useScrollableAncestors.js +14 -0
  164. package/dist/hooks/useScrollableAncestors.js.map +1 -0
  165. package/dist/hooks/useScrollableAncestorsRects.js +32 -0
  166. package/dist/hooks/useScrollableAncestorsRects.js.map +1 -0
  167. package/dist/hooks/useStateRef.js +16 -0
  168. package/dist/hooks/useStateRef.js.map +1 -0
  169. package/dist/hooks/useTimeInterval.js +25 -0
  170. package/dist/hooks/useTimeInterval.js.map +1 -0
  171. package/dist/hooks/useTimeOffset.js +24 -0
  172. package/dist/hooks/useTimeOffset.js.map +1 -0
  173. package/dist/hooks/useToday.js +26 -0
  174. package/dist/hooks/useToday.js.map +1 -0
  175. package/dist/icons/chevron.js +20 -0
  176. package/dist/icons/chevron.js.map +1 -0
  177. package/dist/index.cjs +1 -1
  178. package/dist/index.cjs.map +1 -1
  179. package/dist/index.d.ts +3 -0
  180. package/dist/index.js +12 -2798
  181. package/dist/portal/Portal.js +31 -0
  182. package/dist/portal/Portal.js.map +1 -0
  183. package/dist/style.css +1 -1
  184. package/dist/utils/mergeRefs.js +15 -0
  185. package/dist/utils/mergeRefs.js.map +1 -0
  186. package/dist/views/dayView.d.ts +4 -0
  187. package/dist/views/dayView.js +13 -0
  188. package/dist/views/dayView.js.map +1 -0
  189. package/dist/views/index.d.ts +4 -0
  190. package/dist/views/monthView.d.ts +9 -0
  191. package/dist/views/monthView.js +20 -0
  192. package/dist/views/monthView.js.map +1 -0
  193. package/dist/views/types.d.ts +30 -0
  194. package/dist/views/weekView.d.ts +4 -0
  195. package/dist/views/weekView.js +13 -0
  196. package/dist/views/weekView.js.map +1 -0
  197. package/package.json +7 -7
  198. package/dist/index.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DragOverlay.js","names":["_jsx","styles","_jsxs","useMemo","useRef","useState","useDragAndDrop","cx","useCalendarContext","useCalendarViewportContext","useDocumentCursor","useIsomorphicLayoutEffect","Portal","PointerPopover","DragOverlay_module_default","jsx","jsxs","WHOLE_EVENT","DragOverlay","showPreview","pxPerMinute","props","eventMap","eventRenderer","pointerPreviewRenderer","view","viewportRef","isDragging","canDrop","dropData","eventItem","source","x","y","transform","draggable","overlay","droppable","items","item","eventValue","key","lastRef","droppedRef","isPlaced","setIsPlaced","returning","setReturning","last","container","from","sourceRect","containerRect","isBlocked"],"sources":["../../../src/components/drag-overlay/DragOverlay.tsx"],"sourcesContent":["import { useMemo, useRef, useState } from \"react\";\nimport type { CSSProperties, HTMLAttributes } from \"react\";\n\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\nimport { cx } from \"@weekwise/core\";\n\nimport type { EventData, EventPart } from \"../../Calendar.types\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useCalendarViewportContext } from \"../../contexts/CalendarViewportContext\";\nimport { useDocumentCursor, useIsomorphicLayoutEffect } from \"../../hooks\";\nimport Portal from \"../../portal\";\n\nimport PointerPopover from \"../pointer-popover\";\n\nimport styles from \"./DragOverlay.module.css\";\n\n/** The dragged event is drawn whole, whichever of its parts was picked up. */\nconst WHOLE_EVENT: EventPart = { isStart: true, isEnd: true };\n\nexport type DragOverlayProps = HTMLAttributes<HTMLDivElement> & {\n /**\n * Whether to render the pointer time preview popover while dragging.\n * Disabled in views where the overlay transform does not map to minutes.\n */\n showPreview?: boolean;\n /** Height of a minute in pixels, to read the overlay transform as minutes for the preview. */\n pxPerMinute?: number;\n};\n\nexport default function DragOverlay({ showPreview = true, pxPerMinute = 1, ...props }: DragOverlayProps) {\n const { eventMap, eventRenderer, pointerPreviewRenderer, view } = useCalendarContext();\n const { viewportRef } = useCalendarViewportContext();\n\n const { isDragging, canDrop, dropData, eventItem, source, x, y, ...transform } = useDragAndDrop(\n ({ draggable, overlay, droppable, canDrop }) => {\n const dropData = [...droppable.dropTargets.values()].shift();\n const items = [...draggable.dragTargets.values()].shift();\n\n return {\n ...overlay.transform,\n source: [...draggable.dragTargets.keys()].shift() ?? null,\n canDrop: canDrop(),\n dropData,\n eventItem: items ? items.filter((item) => item.event)[0] : null,\n isDragging: draggable.isDragging,\n x: draggable.x,\n y: draggable.y,\n };\n }\n );\n\n const eventValue = useMemo(() => {\n if (!eventItem) {\n return null;\n }\n\n // the drag payload is serialized, so render the original value instead of the parsed one\n const { key } = JSON.parse(eventItem.event) as EventData;\n return eventMap.get(key)?.value ?? null;\n }, [eventItem, eventMap]);\n\n // Released where the event cannot go, outside the calendar or by Escape: the overlay flies back\n // from where it was last over a day onto the event, which reappears under it.\n const lastRef = useRef<{ transform: typeof transform; source: HTMLElement; eventValue: unknown } | null>(null);\n const droppedRef = useRef(false);\n // the drag has been over a day: the overlay has a place to be drawn at\n const [isPlaced, setIsPlaced] = useState(false);\n const [returning, setReturning] = useState<{\n container: HTMLElement;\n style: CSSProperties;\n eventValue: unknown;\n } | null>(null);\n\n useIsomorphicLayoutEffect(() => {\n if (isDragging) {\n droppedRef.current = canDrop;\n if (dropData && source) {\n lastRef.current = { transform, source, eventValue };\n setIsPlaced(true);\n setReturning(null);\n }\n return;\n }\n\n setIsPlaced(false);\n const last = lastRef.current;\n lastRef.current = null;\n const container = viewportRef.current;\n if (!last || droppedRef.current || !container || !last.source.isConnected) return;\n\n const { transform: from } = last;\n const sourceRect = last.source.getBoundingClientRect();\n const containerRect = container.getBoundingClientRect();\n setReturning({\n container,\n eventValue: last.eventValue,\n style: {\n left: sourceRect.left - containerRect.left,\n top: sourceRect.top - containerRect.top,\n width: sourceRect.width,\n height: sourceRect.height,\n \"--ww-return-left\": `${from.left}px`,\n \"--ww-return-top\": `${from.top}px`,\n \"--ww-return-width\": `${from.width}px`,\n \"--ww-return-height\": `${from.height}px`,\n } as CSSProperties,\n });\n });\n\n // The page shows the drag's cursor: grabbing, or \"not allowed\" where the event cannot go.\n useDocumentCursor(isDragging ? (canDrop ? \"grabbing\" : \"not-allowed\") : null);\n\n if (!isDragging) {\n return returning ? (\n <Portal container={returning.container}>\n <div\n {...props}\n className={cx(props.className, styles.root, styles.root_isReturning)}\n style={returning.style}\n onAnimationEnd={() => setReturning(null)}\n >\n {returning.eventValue != null ? eventRenderer.current?.(returning.eventValue, view, WHOLE_EVENT) : null}\n </div>\n </Portal>\n ) : null;\n }\n\n if (!isPlaced) {\n return null;\n }\n\n // Over a day or time the event cannot be dropped on, or outside the calendar, the overlay\n // stays where it was last placed, marked as blocked.\n const isBlocked = !canDrop;\n\n return (\n <Portal container={viewportRef.current}>\n <div\n {...props}\n className={cx(props.className, styles.root, {\n [styles.root_isDragging]: isDragging,\n [styles.root_isBlocked]: isBlocked,\n })}\n style={{ ...transform }}\n >\n {eventValue != null ? eventRenderer.current?.(eventValue, view, WHOLE_EVENT) : null}\n </div>\n {showPreview && !isBlocked && (\n <PointerPopover coordinates={{ x, y }}>\n {dropData\n ? pointerPreviewRenderer.current?.(\n dropData.date,\n Math.round(transform.top / pxPerMinute),\n Math.round(transform.height / pxPerMinute)\n )\n : null}\n </PointerPopover>\n )}\n </Portal>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,IAAMiB,IAAyB;CAAE,SAAS;CAAM,OAAO;AAAK;AAY5D,SAAwBC,EAAY,EAAEC,iBAAc,IAAMC,iBAAc,GAAG,GAAGC,KAA2B;CACvG,IAAM,EAAEC,aAAUC,kBAAeC,2BAAwBC,YAASjB,EAAmB,GAC/E,EAAEkB,mBAAgBjB,EAA2B,GAE7C,EAAEkB,eAAYC,YAASC,aAAUC,cAAWC,WAAQC,MAAGC,MAAG,GAAGC,MAAc5B,GAC9E,EAAE6B,cAAWC,YAASC,cAAWT,iBAAc;EAC9C,IAAMC,IAAW,CAAC,GAAGQ,EAAU,YAAY,OAAO,CAAC,CAAC,CAAC,MAAM,GACrDC,IAAQ,CAAC,GAAGH,EAAU,YAAY,OAAO,CAAC,CAAC,CAAC,MAAM;EAExD,OAAO;GACL,GAAGC,EAAQ;GACX,QAAQ,CAAC,GAAGD,EAAU,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,KAAK;GACrD,SAASP,EAAQ;GACjBC;GACA,WAAWS,IAAQA,EAAM,QAAQC,MAASA,EAAK,KAAK,CAAC,CAAC,KAAK;GAC3D,YAAYJ,EAAU;GACtB,GAAGA,EAAU;GACb,GAAGA,EAAU;EACf;CACF,CACF,GAEMK,IAAarC,QAAc;EAC/B,IAAI,CAAC2B,GACH,OAAO;EAIT,IAAM,EAAEW,WAAQ,KAAK,MAAMX,EAAU,KAAK;EAC1C,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jB,sBAAsBC,EAAa,IAAI;GAEtC,UAAAD,EAAU,cAAc,OAA0E,OAAnEvB,EAAc,UAAUuB,EAAU,YAAYrB,GAAMR,CAAW;EAC5F,CAAA;CACC,CAAA,IACN;CAGN,IAAI,CAAC2B,GACH,OAAO;CAKT,IAAMS,IAAY,CAACzB;CAEnB,OACE1B,kBAACU,GAAD;EAAQ,WAAWc,EAAY;EAA/B,UAAA,CACE1B,kBAAC,OAAD;GACE,GAAIqB;GACJ,WAAWd,EAAGc,EAAM,WAAWpB,EAAO,MAAM;KACzCA,EAAO,kBAAkB0B;KACzB1B,EAAO,iBAAiBoD;GAC3B,CAAC;GACD,OAAO,EAAE,GAAGnB,EAAU;GAErB,UAAAM,KAAc,OAAgE,OAAzDjB,EAAc,UAAUiB,GAAYf,GAAMR,CAAW;EACxE,CAAA,GACJE,KAAe,CAACkC,KACfrD,kBAACa,GAAD;GAAgB,aAAa;IAAEmB;IAAGC;GAAE;GACjC,UAAAJ,IACGL,EAAuB,UACrBK,EAAS,MACT,KAAK,MAAMK,EAAU,MAAMd,CAAW,GACtC,KAAK,MAAMc,EAAU,SAASd,CAAW,CAC3C,IACA;EACU,CAAA,CAEZ;;AAEZ"}
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ // src/components/drag-overlay/DragOverlay.module.css
3
+ var e = "_root_ssdmn_1", t = "_root_isDragging_ssdmn_14", n = "_root_isReturning_ssdmn_23", r = "_root_isBlocked_ssdmn_36", i = {
4
+ root: e,
5
+ root_isDragging: t,
6
+ root_isReturning: n,
7
+ "ww-drag-return": "_ww-drag-return_ssdmn_39",
8
+ root_isBlocked: r
9
+ };
10
+ export { i as default, e as root, r as root_isBlocked, t as root_isDragging, n as root_isReturning };
11
+
12
+ //# sourceMappingURL=DragOverlay.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DragOverlay.module.css.js","names":["root","root_isDragging","root_isReturning","root_isBlocked","DragOverlay_module_default"],"sources":[],"mappings":""}
@@ -1,3 +1,4 @@
1
1
  export { default as CalendarToolbar } from "./calendar-toolbar";
2
2
  export { default as MonthView } from "./month-view";
3
3
  export { default as DayWeekView } from "./day-week-view";
4
+ export { default as TimelineView } from "./timeline-view";
@@ -1,5 +1,11 @@
1
- import type { HTMLAttributes } from "react";
2
- export type MonthViewProps = HTMLAttributes<HTMLDivElement>;
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ import { type CalendarDate } from "@weekwise/core";
3
+ export type MonthViewProps = HTMLAttributes<HTMLDivElement> & {
4
+ /** Content of a day in place of its event bars; without it the view draws a bar per event. */
5
+ renderDay?: (date: CalendarDate, items: unknown[]) => ReactNode;
6
+ /** A day was clicked, or Enter or Space was pressed on it, outside its events. */
7
+ onDayClick?: (date: CalendarDate) => void;
8
+ };
3
9
  /**
4
10
  * Month grid: 6 weeks of day cells. An event is one bar across the days it covers in a
5
11
  * week; the bar's edges stretch it into other days.
@@ -0,0 +1,105 @@
1
+ "use client";
2
+ import { useMemo as e, useRef as t } from "react";
3
+ import { arrangeMonthWeek as n, cx as r, getDayKey as i, getMonthGrid as a, getWeekdayNames as o, groupEventsByDay as s } from "@weekwise/core";
4
+ import { useCalendarDateUtils as c } from "../../date-localization/useDateUtils.js";
5
+ import l from "../../hooks/useCurrentRef.js";
6
+ import u from "../../hooks/useEventCallback.js";
7
+ import d from "../../hooks/useRefList.js";
8
+ import f from "../../hooks/useToday.js";
9
+ import { useCalendarContext as p } from "../../contexts/CalendarContext.js";
10
+ import m from "../../contexts/CalendarViewportContext.js";
11
+ import h from "../drag-overlay/DragOverlay.js";
12
+ import { cssVariables as g, splitIntoWeeks as _ } from "./MonthView.utils.js";
13
+ import v from "./MonthViewWeek.js";
14
+ import y from "./useMonthLanes.js";
15
+ import b from "./useMonthResize.js";
16
+ import x from "./MonthView.module.css.js";
17
+ import { jsx as S, jsxs as C } from "react/jsx-runtime";
18
+ // src/components/month-view/MonthView.tsx
19
+ var w = [], T = {
20
+ bars: w,
21
+ hidden: [
22
+ 0,
23
+ 0,
24
+ 0,
25
+ 0,
26
+ 0,
27
+ 0,
28
+ 0
29
+ ]
30
+ };
31
+ function E(E) {
32
+ let { className: D, style: O, renderDay: k, onDayClick: A, ...j } = E, { viewValue: M, eventMap: N, startWeek: P, disabled: F, getIsDayDisabled: I, onEventChange: L } = p(), R = c();
33
+ f();
34
+ let z = t(null), B = d(), V = e(() => a(R, M, P), [
35
+ R,
36
+ P,
37
+ M
38
+ ]), H = e(() => _(V), [V]), U = e(() => o(R, P), [R, P]), W = b({
39
+ days: V,
40
+ viewportRef: z,
41
+ cellsRef: B.elements,
42
+ dateUtils: R,
43
+ eventMap: N,
44
+ disabled: F,
45
+ getIsDayDisabled: I,
46
+ onEventChange: L
47
+ }), G = y(z, 3), K = l(k), q = !!k, J = u((e) => A?.(e)), Y = e(() => H.map((e) => q ? T : n(N, R, e, G)), [
48
+ R,
49
+ N,
50
+ q,
51
+ G,
52
+ H
53
+ ]), X = e(() => q ? s(N, R) : void 0, [
54
+ R,
55
+ N,
56
+ q
57
+ ]), Z = X ? (e) => K.current?.(e, (X.get(i(R, e)) ?? []).map((e) => e.value)) : void 0, Q = e(() => W.eventMap === N || q ? Y : H.map((e) => n(W.eventMap, R, e, G)), [
58
+ R,
59
+ N,
60
+ q,
61
+ G,
62
+ Y,
63
+ W.eventMap,
64
+ H
65
+ ]), $ = e(() => ({ viewportRef: z }), []);
66
+ return /* @__PURE__ */ C(m.Provider, {
67
+ value: $,
68
+ children: [/* @__PURE__ */ C("div", {
69
+ ...j,
70
+ className: r(D, x.root, { [x.root_isResizing]: W.resizingKey !== void 0 }),
71
+ style: g({ "--ww-month-lanes": G }, O),
72
+ children: [/* @__PURE__ */ S("div", {
73
+ className: x.root__head,
74
+ children: U.map((e) => /* @__PURE__ */ S("div", {
75
+ className: x.root__weekday,
76
+ children: e
77
+ }, e))
78
+ }), /* @__PURE__ */ S("div", {
79
+ className: x.root__body,
80
+ children: /* @__PURE__ */ S("div", {
81
+ ref: z,
82
+ className: x.root__viewport,
83
+ children: H.map((e, t) => /* @__PURE__ */ S(v, {
84
+ days: e,
85
+ firstDayIndex: t * 7,
86
+ cellRef: B.refAt,
87
+ layout: Q[t],
88
+ sourceBars: W.resizingKey === void 0 ? w : Y[t].bars.filter((e) => e.key === W.resizingKey),
89
+ lanes: G,
90
+ resizingKey: W.resizingKey,
91
+ resize: W.actions,
92
+ renderDayContent: Z,
93
+ onDayClick: A ? J : void 0
94
+ }, R.toMillis(e[0])))
95
+ })
96
+ })]
97
+ }), /* @__PURE__ */ S(h, {
98
+ className: x.root__dragOverlay,
99
+ showPreview: !1
100
+ })]
101
+ });
102
+ }
103
+ export { E as default };
104
+
105
+ //# sourceMappingURL=MonthView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthView.js","names":["_jsxs","styles","_jsx","useMemo","useRef","arrangeMonthWeek","cx","getDayKey","getMonthGrid","getWeekdayNames","groupEventsByDay","useCalendarDateUtils","useCurrentRef","useEventCallback","useRefList","useToday","useCalendarContext","CalendarViewportContext","DragOverlay","cssVariables","splitIntoWeeks","MonthViewWeek","useMonthLanes","useMonthResize","MonthView_module_default","jsx","jsxs","NO_BARS","NO_LAYOUT","MonthView","props","className","style","renderDay","onDayClick","rootProps","viewValue","eventMap","startWeek","disabled","getIsDayDisabled","onEventChange","dateUtils","viewportRef","cells","days","weeks","weekdayNames","resize","lanes","dayRendererRef","hasDayRenderer","handleDayClick","date","layouts","week","dayEvents","renderDayContent","day","event","shownLayouts","contextValue","weekdayName","weekIndex","bar"],"sources":["../../../src/components/month-view/MonthView.tsx"],"sourcesContent":["import { useMemo, useRef } from \"react\";\nimport type { HTMLAttributes, ReactNode } from \"react\";\n\nimport {\n arrangeMonthWeek,\n cx,\n getDayKey,\n getMonthGrid,\n getWeekdayNames,\n groupEventsByDay,\n type CalendarDate,\n type MonthBar,\n type MonthWeekLayout,\n} from \"@weekwise/core\";\n\nimport { useCalendarDateUtils } from \"../../date-localization\";\nimport { useCurrentRef, useEventCallback, useRefList, useToday } from \"../../hooks\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport CalendarViewportContext from \"../../contexts/CalendarViewportContext\";\n\nimport DragOverlay from \"../drag-overlay\";\n\nimport { cssVariables, MAX_LANES, splitIntoWeeks } from \"./MonthView.utils\";\nimport MonthViewWeek from \"./MonthViewWeek\";\nimport useMonthLanes from \"./useMonthLanes\";\nimport useMonthResize from \"./useMonthResize\";\n\nimport styles from \"./MonthView.module.css\";\n\nexport type MonthViewProps = HTMLAttributes<HTMLDivElement> & {\n /** Content of a day in place of its event bars; without it the view draws a bar per event. */\n renderDay?: (date: CalendarDate, items: unknown[]) => ReactNode;\n /** A day was clicked, or Enter or Space was pressed on it, outside its events. */\n onDayClick?: (date: CalendarDate) => void;\n};\n\nconst NO_BARS: MonthBar<unknown, CalendarDate>[] = [];\nconst NO_LAYOUT: MonthWeekLayout<unknown, CalendarDate> = { bars: NO_BARS, hidden: [0, 0, 0, 0, 0, 0, 0] };\n\n/**\n * Month grid: 6 weeks of day cells. An event is one bar across the days it covers in a\n * week; the bar's edges stretch it into other days.\n */\nexport default function MonthView(props: MonthViewProps) {\n const { className, style, renderDay, onDayClick, ...rootProps } = props;\n\n const { viewValue, eventMap, startWeek, disabled, getIsDayDisabled, onEventChange } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n // re-render at midnight so the highlighted day follows the date\n useToday();\n\n const viewportRef = useRef<HTMLDivElement>(null);\n // the day cells by index in the grid: resizing an event picks its day among them\n const cells = useRefList<HTMLDivElement>();\n\n const days = useMemo(() => getMonthGrid(dateUtils, viewValue, startWeek), [dateUtils, startWeek, viewValue]);\n const weeks = useMemo(() => splitIntoWeeks(days), [days]);\n const weekdayNames = useMemo(() => getWeekdayNames(dateUtils, startWeek), [dateUtils, startWeek]);\n\n const resize = useMonthResize({\n days,\n viewportRef,\n cellsRef: cells.elements,\n dateUtils,\n eventMap,\n disabled,\n getIsDayDisabled,\n onEventChange,\n });\n\n const lanes = useMonthLanes(viewportRef, MAX_LANES);\n\n // the renderer is read when drawn: a new function each render does not rebuild the layout\n const dayRendererRef = useCurrentRef(renderDay);\n const hasDayRenderer = Boolean(renderDay);\n const handleDayClick = useEventCallback((date: CalendarDate) => onDayClick?.(date));\n\n // the user's day content takes the place of the bars\n const layouts = useMemo(\n () => weeks.map((week) => (hasDayRenderer ? NO_LAYOUT : arrangeMonthWeek(eventMap, dateUtils, week, lanes))),\n [dateUtils, eventMap, hasDayRenderer, lanes, weeks]\n );\n const dayEvents = useMemo(\n () => (hasDayRenderer ? groupEventsByDay(eventMap, dateUtils) : undefined),\n [dateUtils, eventMap, hasDayRenderer]\n );\n const renderDayContent = dayEvents\n ? (day: CalendarDate) =>\n dayRendererRef.current?.(\n day,\n (dayEvents.get(getDayKey(dateUtils, day)) ?? []).map((event) => event.value)\n )\n : undefined;\n // while an event is resized, the grid shows its new range\n const shownLayouts = useMemo(\n () =>\n resize.eventMap === eventMap || hasDayRenderer\n ? layouts\n : weeks.map((week) => arrangeMonthWeek(resize.eventMap, dateUtils, week, lanes)),\n [dateUtils, eventMap, hasDayRenderer, lanes, layouts, resize.eventMap, weeks]\n );\n\n const contextValue = useMemo(() => ({ viewportRef }), []);\n\n return (\n <CalendarViewportContext.Provider value={contextValue}>\n <div\n {...rootProps}\n className={cx(className, styles.root, {\n [styles.root_isResizing]: resize.resizingKey !== undefined,\n })}\n style={cssVariables({ \"--ww-month-lanes\": lanes }, style)}\n >\n <div className={styles.root__head}>\n {weekdayNames.map((weekdayName) => (\n <div key={weekdayName} className={styles.root__weekday}>\n {weekdayName}\n </div>\n ))}\n </div>\n <div className={styles.root__body}>\n <div ref={viewportRef} className={styles.root__viewport}>\n {weeks.map((week, weekIndex) => (\n <MonthViewWeek\n key={dateUtils.toMillis(week[0])}\n days={week}\n firstDayIndex={weekIndex * 7}\n cellRef={cells.refAt}\n layout={shownLayouts[weekIndex]}\n sourceBars={\n resize.resizingKey === undefined\n ? NO_BARS\n : layouts[weekIndex].bars.filter((bar) => bar.key === resize.resizingKey)\n }\n lanes={lanes}\n resizingKey={resize.resizingKey}\n resize={resize.actions}\n renderDayContent={renderDayContent}\n onDayClick={onDayClick ? handleDayClick : undefined}\n />\n ))}\n </div>\n </div>\n </div>\n <DragOverlay className={styles.root__dragOverlay} showPreview={false} />\n </CalendarViewportContext.Provider>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoCA,IAAM2B,IAA6C,CAAC,GAC9CC,IAAoD;CAAE,MAAMD;CAAS,QAAQ;EAAC;EAAG;EAAG;EAAG;EAAG;EAAG;EAAG;CAAC;AAAE;AAMzG,SAAwBE,EAAUC,GAAuB;CACvD,IAAM,EAAEC,cAAWC,UAAOC,cAAWC,eAAY,GAAGC,MAAcL,GAE5D,EAAEM,cAAWC,aAAUC,cAAWC,aAAUC,qBAAkBC,qBAAkBzB,EAAmB,GACnG0B,IAAY/B,EAAqB;CAEvCI,EAAS;CAET,IAAM4B,IAAcvC,EAAuB,IAAI,GAEzCwC,IAAQ9B,EAA2B,GAEnC+B,IAAO1C,QAAcK,EAAakC,GAAWN,GAAWE,CAAS,GAAG;EAACI;EAAWJ;EAAWF;CAAS,CAAC,GACrGU,IAAQ3C,QAAciB,EAAeyB,CAAI,GAAG,CAACA,CAAI,CAAC,GAClDE,IAAe5C,QAAcM,EAAgBiC,GAAWJ,CAAS,GAAG,CAACI,GAAWJ,CAAS,CAAC,GAE1FU,IAASzB,EAAe;EAC5BsB;EACAF;EACA,UAAUC,EAAM;EAChBF;EACAL;EACAE;EACAC;EACAC;CACF,CAAC,GAEKQ,IAAQ3B,EAAcqB,GAAA,CAAsB,GAG5CO,IAAiBtC,EAAcqB,CAAS,GACxCkB,IAAiB,EAAQlB,GACzBmB,IAAiBvC,GAAkBwC,MAAuBnB,IAAamB,CAAI,CAAC,GAG5EC,IAAUnD,QACR2C,EAAM,KAAKS,MAAUJ,IAAiBvB,IAAYvB,EAAiBgC,GAAUK,GAAWa,GAAMN,CAAK,CAAE,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AaG;MACrB,YACEf,EAAO,gBAAgB,KAAA,IACnBrB,IACA2B,EAAQS,EAAU,CAAC,KAAK,QAAQC,MAAQA,EAAI,QAAQhB,EAAO,WAAW;MAErEC;MACP,aAAaD,EAAO;MACpB,QAAQA,EAAO;MACGS;MAClB,YAAYvB,IAAakB,IAAiB,KAAA;KAC3C,GAfMV,EAAU,SAASa,EAAK,EAAE,CAehC,CACF;IACE,CAAA;GACF,CAAA,CACF;EACL,CAAA,GAAArD,kBAACgB,GAAD;GAAa,WAAWjB,EAAO;GAAmB,aAAa;EAAQ,CAAA,CACvC;;AAEtC"}
@@ -0,0 +1,30 @@
1
+ "use client";
2
+ // src/components/month-view/MonthView.module.css
3
+ var e = "_root_xj3te_1", t = "_root__head_xj3te_11", n = "_root__weekday_xj3te_21", r = "_root__body_xj3te_31", i = "_root__viewport_xj3te_37", a = "_root__week_xj3te_21", o = "_root__day_xj3te_62", s = "_root__day_isOver_xj3te_86", c = "_root__dayNumber_xj3te_100", l = "_root__dayContent_xj3te_113", u = "_root__event_xj3te_144", d = "_root__event_span_xj3te_177", f = "_root__event_continuesBefore_xj3te_183", p = "_root__event_continuesAfter_xj3te_189", m = "_root__event_isResizing_xj3te_195", h = "_root__event_isResizeSource_xj3te_199", g = "_root__resize_xj3te_204", _ = "_root__resizeStart_xj3te_214", v = "_root__resizeEnd_xj3te_218", y = "_root_isResizing_xj3te_222", b = "_root__event_isDragging_xj3te_227", x = "_root__dragOverlay_xj3te_232", S = "_root__more_xj3te_257", C = {
4
+ root: e,
5
+ root__head: t,
6
+ root__weekday: n,
7
+ root__body: r,
8
+ root__viewport: i,
9
+ root__week: a,
10
+ root__day: o,
11
+ root__day_isOver: s,
12
+ root__dayNumber: c,
13
+ root__dayContent: l,
14
+ root__event: u,
15
+ root__event_span: d,
16
+ root__event_continuesBefore: f,
17
+ root__event_continuesAfter: p,
18
+ root__event_isResizing: m,
19
+ root__event_isResizeSource: h,
20
+ root__resize: g,
21
+ root__resizeStart: _,
22
+ root__resizeEnd: v,
23
+ root_isResizing: y,
24
+ root__event_isDragging: b,
25
+ root__dragOverlay: x,
26
+ root__more: S
27
+ };
28
+ export { C as default, e as root, r as root__body, o as root__day, l as root__dayContent, c as root__dayNumber, s as root__day_isOver, x as root__dragOverlay, u as root__event, p as root__event_continuesAfter, f as root__event_continuesBefore, b as root__event_isDragging, h as root__event_isResizeSource, m as root__event_isResizing, d as root__event_span, t as root__head, S as root__more, g as root__resize, v as root__resizeEnd, _ as root__resizeStart, i as root__viewport, a as root__week, n as root__weekday, y as root_isResizing };
29
+
30
+ //# sourceMappingURL=MonthView.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthView.module.css.js","names":["root","root__head","root__weekday","root__body","root__viewport","root__week","root__day","root__day_isOver","root__dayNumber","root__dayContent","root__event","root__event_span","root__event_continuesBefore","root__event_continuesAfter","root__event_isResizing","root__event_isResizeSource","root__resize","root__resizeStart","root__resizeEnd","root_isResizing","root__event_isDragging","root__dragOverlay","root__more","MonthView_module_default"],"sources":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ // src/components/month-view/MonthView.utils.ts
3
+ function e(e, t) {
4
+ return {
5
+ ...t,
6
+ ...e
7
+ };
8
+ }
9
+ function t(e) {
10
+ return Array.from({ length: Math.ceil(e.length / 7) }, (t, n) => e.slice(n * 7, n * 7 + 7));
11
+ }
12
+ export { e as cssVariables, t as splitIntoWeeks };
13
+
14
+ //# sourceMappingURL=MonthView.utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthView.utils.js","names":["cssVariables","variables","style","splitIntoWeeks","days","_","week"],"sources":["../../../src/components/month-view/MonthView.utils.ts"],"sourcesContent":["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"],"mappings":";;AASA,SAAgBA,EAAaC,GAAyBC,GAAsC;CAC1F,OAAO;EAAE,GAAGA;EAAO,GAAGD;CAAU;AAClC;AAGA,SAAgBE,EAAeC,GAAwC;CACrE,OAAO,MAAM,KAAK,EAAE,QAAQ,KAAK,KAAKA,EAAK,SAAS,CAAC,EAAE,IAAIC,GAAGC,MAASF,EAAK,MAAME,IAAO,GAAGA,IAAO,IAAI,CAAC,CAAC;AAC3G"}
@@ -5,6 +5,8 @@ export type MonthViewDayProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>
5
5
  * Date associated to the day cell
6
6
  */
7
7
  targetDate: CalendarDate;
8
+ /** Reports a click on the day; with it the cell is a button. */
9
+ onDayClick?: (date: CalendarDate) => void;
8
10
  };
9
11
  export interface MonthViewDropTargetData {
10
12
  date: CalendarDate;
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ import { useEffect as e, useRef as t } from "react";
3
+ import { useCalendarDateUtils as n } from "../../date-localization/useDateUtils.js";
4
+ import { useDragAndDrop as r } from "@weekwise/dnd/react";
5
+ import i from "../../hooks/useEventCallback.js";
6
+ import a from "../../hooks/useMergedRefs.js";
7
+ import { cx as o, toDayMinutes as s } from "@weekwise/core";
8
+ import { useCalendarContext as c } from "../../contexts/CalendarContext.js";
9
+ import l from "./MonthView.module.css.js";
10
+ import { jsx as u } from "react/jsx-runtime";
11
+ // src/components/month-view/MonthViewDay.tsx
12
+ function d(d) {
13
+ let { ref: f, targetDate: p, onDayClick: m, children: h, onDoubleClick: g, onClick: _, onKeyDown: v, ...y } = d, { onEventChange: b, onEventCreate: x, getIsDayDisabled: S, disabled: C, eventMap: w } = c(), T = n(), { getHours: E, getMinutes: D, getNow: O } = T, k = t(null), { register: A, isOver: j } = r(({ registerDropTarget: e, isOver: t }) => ({
14
+ register: e,
15
+ isOver: t(k.current)
16
+ }));
17
+ e(() => {
18
+ let e = k.current;
19
+ if (e) return A(e, {
20
+ data: { date: p },
21
+ onDrop: async (e) => {
22
+ let [t] = await Promise.all(e.items.filter((e) => e.kind === "text" && e.types.has("event") && "getText" in e).map(async (e) => {
23
+ let t = await e.getText("event");
24
+ return JSON.parse(t);
25
+ })), n = t && w.get(t.key);
26
+ if (!n) return;
27
+ let r = T.fromMillis(t.day ?? t.date), i = s(T, r, p) / 1440;
28
+ i !== 0 && b(n.key, T.addDays(T.getStartOfDay(n.date), i), {
29
+ from: E(n.date) * 60 + D(n.date),
30
+ duration: n.duration
31
+ });
32
+ },
33
+ getDropOperationForPoint: (e, t) => C || !e.has("event") || S && S(p) ? "cancel" : t[0]
34
+ });
35
+ }, [
36
+ T,
37
+ C,
38
+ w,
39
+ E,
40
+ S,
41
+ D,
42
+ b,
43
+ A,
44
+ p
45
+ ]);
46
+ let M = i((e) => {
47
+ if (g?.(e), e.defaultPrevented || C || S && S(p)) return;
48
+ let t = O();
49
+ x(p, {
50
+ from: E(t) * 60 + D(t),
51
+ duration: 60
52
+ });
53
+ }), N = i((e) => {
54
+ _?.(e), e.defaultPrevented || m?.(p);
55
+ }), P = i((e) => {
56
+ v?.(e), m && !e.defaultPrevented && e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), m?.(p));
57
+ }), F = a(k, f);
58
+ return /* @__PURE__ */ u("div", {
59
+ ...y,
60
+ ref: F,
61
+ onDoubleClick: M,
62
+ onClick: N,
63
+ onKeyDown: P,
64
+ ...m && {
65
+ role: "button",
66
+ tabIndex: 0,
67
+ "aria-label": T.format(p, "dateLong")
68
+ },
69
+ className: o(y.className, l.root__day, { [l.root__day_isOver]: j }),
70
+ children: h
71
+ });
72
+ }
73
+ export { d as default };
74
+
75
+ //# sourceMappingURL=MonthViewDay.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthViewDay.js","names":["_jsx","styles","useEffect","useRef","useCalendarDateUtils","useDragAndDrop","useEventCallback","useMergedRefs","cx","toDayMinutes","useCalendarContext","MonthView_module_default","jsx","MonthViewDay","props","forwardedRef","targetDate","onDayClick","children","onDoubleClick","onClick","onKeyDown","rootProps","onEventChange","onEventCreate","getIsDayDisabled","disabled","eventMap","dateUtils","getHours","getMinutes","getNow","rootRef","register","isOver","registerDropTarget","dropTargetElement","dragItem","item","data","eventData","sourceDay","shift","types","allowedOperations","handleDoubleClick","event","now","handleClick","handleKeyDown","handleRootRef"],"sources":["../../../src/components/month-view/MonthViewDay.tsx"],"sourcesContent":["import type { CalendarDate } from \"@weekwise/core\";\nimport { useEffect, useRef } from \"react\";\nimport type { DetailedHTMLProps, HTMLAttributes, KeyboardEvent, MouseEvent } from \"react\";\n\nimport { useCalendarDateUtils } from \"../../date-localization\";\nimport type { TextDropItem } from \"@weekwise/dnd\";\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\nimport { useEventCallback, useMergedRefs } from \"../../hooks\";\nimport { cx } from \"@weekwise/core\";\n\nimport { toDayMinutes } from \"@weekwise/core\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport type { MonthViewDragItem } from \"./MonthViewEvent\";\n\nimport styles from \"./MonthView.module.css\";\n\nexport type MonthViewDayProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {\n /**\n * Date associated to the day cell\n */\n targetDate: CalendarDate;\n /** Reports a click on the day; with it the cell is a button. */\n onDayClick?: (date: CalendarDate) => void;\n};\n\nexport interface MonthViewDropTargetData {\n date: CalendarDate;\n}\n\nexport default function MonthViewDay(props: MonthViewDayProps) {\n const {\n ref: forwardedRef,\n targetDate,\n onDayClick,\n children,\n onDoubleClick,\n onClick,\n onKeyDown,\n ...rootProps\n } = props;\n\n const { onEventChange, onEventCreate, getIsDayDisabled, disabled, eventMap } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const { getHours, getMinutes, getNow } = dateUtils;\n\n const rootRef = useRef<HTMLDivElement>(null);\n\n const { register, isOver } = useDragAndDrop(({ registerDropTarget, isOver }) => ({\n register: registerDropTarget,\n isOver: isOver(rootRef.current),\n }));\n\n useEffect(() => {\n const dropTargetElement = rootRef.current;\n\n if (!dropTargetElement) {\n return;\n }\n\n const dropTargetData: MonthViewDropTargetData = { date: targetDate };\n return register(dropTargetElement, {\n data: dropTargetData,\n onDrop: async (e) => {\n const [dragItem] = await Promise.all(\n e.items\n .filter(\n (item): item is TextDropItem => item.kind === \"text\" && item.types.has(\"event\") && \"getText\" in item\n )\n .map(async (item) => {\n const data = await item.getText(\"event\");\n return JSON.parse(data) as MonthViewDragItem;\n })\n );\n\n const eventData = dragItem && eventMap.get(dragItem.key);\n if (!eventData) {\n return;\n }\n\n // move by as many days as the event was dragged: a multi-day event can be\n // grabbed by any of its days. The time of the day stays.\n const sourceDay = dateUtils.fromMillis(dragItem.day ?? dragItem.date);\n const shift = toDayMinutes(dateUtils, sourceDay, targetDate) / (24 * 60);\n if (shift === 0) {\n return;\n }\n onEventChange(eventData.key, dateUtils.addDays(dateUtils.getStartOfDay(eventData.date), shift), {\n from: getHours(eventData.date) * 60 + getMinutes(eventData.date),\n duration: eventData.duration,\n });\n },\n getDropOperationForPoint: (types, allowedOperations) => {\n if (disabled || !types.has(\"event\")) return \"cancel\";\n\n if (getIsDayDisabled && getIsDayDisabled(targetDate)) {\n return \"cancel\";\n }\n\n return allowedOperations[0];\n },\n });\n }, [dateUtils, disabled, eventMap, getHours, getIsDayDisabled, getMinutes, onEventChange, register, targetDate]);\n\n const handleDoubleClick = useEventCallback((event: MouseEvent<HTMLDivElement>) => {\n onDoubleClick?.(event);\n if (event.defaultPrevented) {\n return;\n }\n\n if (disabled) {\n return;\n }\n\n if (getIsDayDisabled && getIsDayDisabled(targetDate)) {\n return;\n }\n\n const now = getNow();\n onEventCreate(targetDate, {\n from: getHours(now) * 60 + getMinutes(now),\n duration: 60,\n });\n });\n\n const handleClick = useEventCallback((event: MouseEvent<HTMLDivElement>) => {\n onClick?.(event);\n if (!event.defaultPrevented) onDayClick?.(targetDate);\n });\n\n const handleKeyDown = useEventCallback((event: KeyboardEvent<HTMLDivElement>) => {\n onKeyDown?.(event);\n // the cell itself, not something focusable inside it\n if (!onDayClick || event.defaultPrevented || event.target !== event.currentTarget) return;\n if (event.key !== \"Enter\" && event.key !== \" \") return;\n event.preventDefault();\n onDayClick?.(targetDate);\n });\n\n const handleRootRef = useMergedRefs(rootRef, forwardedRef);\n\n return (\n <div\n {...rootProps}\n ref={handleRootRef}\n onDoubleClick={handleDoubleClick}\n onClick={handleClick}\n onKeyDown={handleKeyDown}\n // a day that opens on click is a button, for the keyboard too\n {...(onDayClick && { role: \"button\", tabIndex: 0, \"aria-label\": dateUtils.format(targetDate, \"dateLong\") })}\n className={cx(rootProps.className, styles.root__day, {\n [styles.root__day_isOver]: isOver,\n })}\n >\n {children}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AA6BA,SAAwBa,EAAaC,GAA0B;CAC7D,IAAM,EACJ,KAAKC,GACLC,eACAC,eACAC,aACAC,kBACAC,YACAC,cACA,GAAGC,MACDR,GAEE,EAAES,kBAAeC,kBAAeC,qBAAkBC,aAAUC,gBAAajB,EAAmB,GAC5FkB,IAAYxB,EAAqB,GACjC,EAAEyB,aAAUC,eAAYC,cAAWH,GAEnCI,IAAU7B,EAAuB,IAAI,GAErC,EAAE8B,aAAUC,cAAW7B,GAAgB,EAAE8B,uBAAoBD,iBAAc;EAC/E,UAAUC;EACV,QAAQD,EAAOF,EAAQ,OAAO;CAChC,EAAE;CAEF9B,QAAgB;EACd,IAAMkC,IAAoBJ,EAAQ;EAElC,IAAKI,GAKL,OAAOH,EAASG,GAAmB;GACjC,MAAM,EAF0C,MAAMpB,EAEhD;GACN,QAAQ,OAAO,MAAM;IACnB,IAAM,CAACqB,KAAY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C,GAAkBwC,MAAyC;EAC/EzB,IAAYyB,CAAK,GAEZ7B,KAAc6B,GAAM,oBAAoBA,EAAM,WAAWA,EAAM,kBAChEA,EAAM,QAAQ,WAAWA,EAAM,QAAQ,SAC3CA,EAAM,eAAe,GACrB7B,IAAaD,CAAU;CACzB,CAAC,GAEKkC,IAAgB3C,EAAcyB,GAASjB,CAAY;CAEzD,OACEf,kBAAC,OAAD;EACE,GAAIsB;EACJ,KAAK4B;EACL,eAAeL;EACf,SAASG;EACT,WAAWC;EAEX,GAAKhC,KAAc;GAAE,MAAM;GAAU,UAAU;GAAG,cAAcW,EAAU,OAAOZ,GAAY,UAAU;EAAE;EACzG,WAAWR,EAAGc,EAAU,WAAWrB,EAAO,WAAW,GAClDA,EAAO,mBAAmBiC,EAC7B,CAAC;EAEAhB;CACE,CAAA;AAET"}
@@ -0,0 +1,132 @@
1
+ "use client";
2
+ import { useEffect as e, useRef as t } from "react";
3
+ import { useDragAndDrop as n } from "@weekwise/dnd/react";
4
+ import r from "../../hooks/useEventCallback.js";
5
+ import i from "../../hooks/useMergedRefs.js";
6
+ import a from "../../hooks/useMove.js";
7
+ import o from "../../hooks/useMoveTransform.js";
8
+ import s from "../../hooks/useRect.js";
9
+ import { MONTH_WEEK_GEOMETRY as c, cx as l } from "@weekwise/core";
10
+ import { useCalendarContext as u } from "../../contexts/CalendarContext.js";
11
+ import { useCalendarDateUtils as d } from "../../date-localization/useDateUtils.js";
12
+ import { useCalendarViewportContext as f } from "../../contexts/CalendarViewportContext.js";
13
+ import { cssVariables as p } from "./MonthView.utils.js";
14
+ import m from "./MonthView.module.css.js";
15
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
16
+ // src/components/month-view/MonthViewEvent.tsx
17
+ var _ = 6;
18
+ function v(v) {
19
+ let { ref: y, eventData: b, weekDays: x, weekRef: S, resizable: C = !1, resize: w, isResizeSource: T = !1, isAnyResizing: E = !1, children: D, ...O } = v, { disabled: k } = u(), A = d(), { viewportRef: j } = f(), M = t(null), N = t(null), { attributes: P, isDragging: F, overElement: I, register: L, setOverlayTransform: R } = n(({ registerDragSource: e, draggable: t, droppable: n, setTransform: r, isActive: i }) => {
20
+ let a = i(M.current), [o] = a ? [...n.dropTargets].pop() ?? [null] : [null];
21
+ return {
22
+ attributes: t.attributes,
23
+ isDragging: a,
24
+ overElement: o,
25
+ register: e,
26
+ setOverlayTransform: r
27
+ };
28
+ }), z = s(F ? I : null), [{ transform: B, context: V }, H] = o({
29
+ autoScrollEnabled: !1,
30
+ activeNode: () => M.current,
31
+ containerNode: () => j.current,
32
+ modifiers: [function({ activeNodeRect: e, containerNodeRect: t, transform: n, translate: r, initialTranslate: i }) {
33
+ if (!t || !e || !z) return n;
34
+ n.x = r.x + i.x - t.left, n.y = r.y + i.y - t.top, n.left = z.left - t.left + _, n.width = z.width - 12, n.height = e.height;
35
+ let a = e.top + r.y, o = z.top + c.header, s = z.top + z.height - e.height;
36
+ return n.top = Math.max(o, Math.min(a, s)) - t.top, n;
37
+ }]
38
+ }), U = r((e) => {
39
+ V === "overlay" && I && R(e);
40
+ });
41
+ e(() => {
42
+ U(B);
43
+ }, [U, ...Object.values(B)]);
44
+ let W = r(() => {
45
+ let e = N.current ?? x[b.column], t = {
46
+ ...b,
47
+ date: A.toMillis(b.date),
48
+ day: e && A.toMillis(e)
49
+ };
50
+ return [{ event: JSON.stringify(t) }];
51
+ });
52
+ e(() => {
53
+ if (M.current && !k) return L(M.current, {
54
+ getItems: W,
55
+ onDragStart(e) {
56
+ H.start({
57
+ x: e.x,
58
+ y: e.y
59
+ }, "overlay");
60
+ },
61
+ onDragMove(e) {
62
+ H.move({
63
+ x: e.x,
64
+ y: e.y
65
+ });
66
+ },
67
+ onDragEnd(e) {
68
+ H.stop({
69
+ x: e.x,
70
+ y: e.y
71
+ });
72
+ },
73
+ getAllowedDropOperations() {
74
+ return ["move"];
75
+ }
76
+ });
77
+ }, [
78
+ H,
79
+ k,
80
+ W,
81
+ L
82
+ ]);
83
+ let G = (e) => {
84
+ e.stopPropagation();
85
+ let t = S.current;
86
+ if (!t) return;
87
+ let n = t.getBoundingClientRect(), r = Math.floor((e.clientX - n.left) / n.width * x.length), i = Math.min(Math.max(r, b.column), b.column + b.span - 1);
88
+ N.current = x[i] ?? null;
89
+ }, K = (e) => ({
90
+ onMoveStart: () => (w?.start(b.key, e), !0),
91
+ onMove: (e) => w?.move(e.clientX, e.clientY),
92
+ onMoveEnd: () => w?.end()
93
+ }), { listeners: q } = a(K("start")), { listeners: J } = a(K("end")), Y = i(M, y), X = b.span > 1 || !b.isStart || !b.isEnd, Z = p({
94
+ "--ww-column": b.column + 1,
95
+ "--ww-span": b.span,
96
+ "--ww-row": b.lane + 2
97
+ }, O.style);
98
+ return /* @__PURE__ */ g("div", {
99
+ ...O,
100
+ ...E ? null : P,
101
+ ref: Y,
102
+ style: Z,
103
+ "data-key": String(b.key),
104
+ "data-continues-before": b.isStart ? void 0 : "",
105
+ "data-continues-after": b.isEnd ? void 0 : "",
106
+ onPointerDown: G,
107
+ onDoubleClick: (e) => e.stopPropagation(),
108
+ className: l(O.className, m.root__event, {
109
+ [m.root__event_span]: X,
110
+ [m.root__event_continuesBefore]: !b.isStart,
111
+ [m.root__event_continuesAfter]: !b.isEnd,
112
+ [m.root__event_isDragging]: F,
113
+ [m.root__event_isResizeSource]: T
114
+ }),
115
+ children: [
116
+ D,
117
+ C && b.isStart && /* @__PURE__ */ h("div", {
118
+ ...q,
119
+ "data-edge": "start",
120
+ className: l(m.root__resize, m.root__resizeStart)
121
+ }),
122
+ C && b.isEnd && /* @__PURE__ */ h("div", {
123
+ ...J,
124
+ "data-edge": "end",
125
+ className: l(m.root__resize, m.root__resizeEnd)
126
+ })
127
+ ]
128
+ });
129
+ }
130
+ export { v as default };
131
+
132
+ //# sourceMappingURL=MonthViewEvent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthViewEvent.js","names":["_jsxs","styles","_jsx","useEffect","useRef","useDragAndDrop","useEventCallback","useMergedRefs","useMove","useMoveTransform","useRect","MONTH_WEEK_GEOMETRY","cx","useCalendarContext","useCalendarDateUtils","useCalendarViewportContext","cssVariables","MonthView_module_default","jsx","jsxs","BAR_INSET","MonthViewEvent","props","forwardedRef","eventData","weekDays","weekRef","resizable","resize","isResizeSource","isAnyResizing","children","rootProps","disabled","dateUtils","viewportRef","rootRef","grabbedDayRef","attributes","isDragging","overElement","register","setOverlayTransform","registerDragSource","draggable","droppable","setTransform","isActive","overDayRect","transform","context","actions","activeNodeRect","containerNodeRect","translate","initialTranslate","top","minTop","maxTop","syncTransform","getDragItems","day","item","\"event\"","handlePointerDown","week","rect","column","clamped","resizeListeners","edge","resizeStartListeners","resizeEndListeners","handleRootRef","multiDay","style"],"sources":["../../../src/components/month-view/MonthViewEvent.tsx"],"sourcesContent":["import type { CalendarDate } from \"@weekwise/core\";\nimport { useEffect, useRef } from \"react\";\nimport type { DetailedHTMLProps, HTMLAttributes, PointerEvent, RefObject } from \"react\";\n\nimport { useDragAndDrop } from \"@weekwise/dnd/react\";\nimport { useEventCallback, useMergedRefs, useMove } from \"../../hooks\";\nimport type { MoveTransform } from \"../../hooks/useMoveTransform\";\nimport useMoveTransform from \"../../hooks/useMoveTransform\";\nimport useRect from \"../../hooks/useRect\";\nimport { cx, MONTH_WEEK_GEOMETRY, type MonthBar } from \"@weekwise/core\";\n\nimport type { EventData } from \"../../Calendar.types\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useCalendarDateUtils } from \"../../date-localization\";\nimport { useCalendarViewportContext } from \"../../contexts/CalendarViewportContext\";\n\nimport { cssVariables } from \"./MonthView.utils\";\nimport type { MonthResizeActions, MonthResizeEdge } from \"./useMonthResize\";\n\nimport styles from \"./MonthView.module.css\";\n\n/** Horizontal margin of a bar in its day (`.root__event`). */\nconst BAR_INSET = 6;\n\nexport type MonthViewEventProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {\n /** The event's bar in this week: its days and lane. */\n eventData: MonthBar<unknown, CalendarDate>;\n /** The days of the week row the bar is in. */\n weekDays: CalendarDate[];\n /** The week row the bar lies in: where it is grabbed picks the day the drag moves. */\n weekRef: RefObject<HTMLDivElement | null>;\n /** Whether the bar's edges stretch the event into other days. */\n resizable?: boolean;\n /** Resizing by the bar's edges, run by the view. */\n resize?: MonthResizeActions;\n /** The bar before the resize: hidden while the view shows the new range. */\n isResizeSource?: boolean;\n /** Some event is being resized: no bar is draggable meanwhile. */\n isAnyResizing?: boolean;\n};\n\n/**\n * What a month event carries while dragged: the event and the day it was grabbed by.\n * Dragged items travel as JSON, so dates are timestamps: not every date type survives JSON.\n */\nexport interface MonthViewDragItem extends Omit<EventData<unknown, CalendarDate>, \"date\"> {\n /** Time stamp of the event's start. */\n date: number;\n /** Time stamp of the day cell the event was grabbed in. */\n day?: number;\n}\n\nexport default function MonthViewEvent(props: MonthViewEventProps) {\n const {\n ref: forwardedRef,\n eventData,\n weekDays,\n weekRef,\n resizable = false,\n resize,\n isResizeSource = false,\n isAnyResizing = false,\n children,\n ...rootProps\n } = props;\n\n const { disabled } = useCalendarContext();\n const dateUtils = useCalendarDateUtils();\n const { viewportRef } = useCalendarViewportContext();\n\n const rootRef = useRef<HTMLDivElement | null>(null);\n // the day under the pointer when the bar was pressed: a multi-day event moves by the\n // days it is dragged, by whichever of its days it was grabbed\n const grabbedDayRef = useRef<CalendarDate | null>(null);\n\n const { attributes, isDragging, overElement, register, setOverlayTransform } = useDragAndDrop(\n ({ registerDragSource, draggable, droppable, setTransform, isActive }) => {\n const isDragging = isActive(rootRef.current);\n const [overElement] = isDragging ? ([...droppable.dropTargets].pop() ?? [null]) : [null];\n\n return {\n attributes: draggable.attributes,\n isDragging,\n overElement,\n register: registerDragSource,\n setOverlayTransform: setTransform,\n };\n }\n );\n\n const overDayRect = useRect(isDragging ? overElement : null);\n\n const [{ transform, context }, actions] = useMoveTransform({\n autoScrollEnabled: false,\n activeNode: () => rootRef.current,\n containerNode: () => viewportRef.current,\n modifiers: [\n function overlayTransformModifier({ activeNodeRect, containerNodeRect, transform, translate, initialTranslate }) {\n if (!containerNodeRect || !activeNodeRect || !overDayRect) {\n return transform;\n }\n\n transform.x = translate.x + initialTranslate.x - containerNodeRect.left;\n transform.y = translate.y + initialTranslate.y - containerNodeRect.top;\n\n // in the target day, inset like a bar; vertically it follows the pointer, kept\n // inside the day below its number, so it moves into other weeks too\n transform.left = overDayRect.left - containerNodeRect.left + BAR_INSET;\n transform.width = overDayRect.width - 2 * BAR_INSET;\n transform.height = activeNodeRect.height;\n const top = activeNodeRect.top + translate.y;\n const minTop = overDayRect.top + MONTH_WEEK_GEOMETRY.header;\n const maxTop = overDayRect.top + overDayRect.height - activeNodeRect.height;\n transform.top = Math.max(minTop, Math.min(top, maxTop)) - containerNodeRect.top;\n\n return transform;\n },\n ],\n });\n\n // Away from every day the overlay keeps its last place: the transform has no day to fit in.\n const syncTransform = useEventCallback((transform: MoveTransform) => {\n if (context === \"overlay\" && overElement) {\n setOverlayTransform(transform);\n }\n });\n\n useEffect(() => {\n syncTransform(transform);\n // oxlint-disable-next-line react-hooks/exhaustive-deps\n }, [syncTransform, ...Object.values(transform)]);\n\n const getDragItems = useEventCallback(() => {\n const day = grabbedDayRef.current ?? weekDays[eventData.column];\n const item: MonthViewDragItem = {\n ...eventData,\n date: dateUtils.toMillis(eventData.date),\n day: day && dateUtils.toMillis(day),\n };\n return [{ [\"event\"]: JSON.stringify(item) }];\n });\n\n useEffect(() => {\n if (!rootRef.current || disabled) {\n return;\n }\n\n return register(rootRef.current, {\n getItems: getDragItems,\n onDragStart(e) {\n actions.start({ x: e.x, y: e.y }, \"overlay\");\n },\n onDragMove(e) {\n actions.move({ x: e.x, y: e.y });\n },\n onDragEnd(e) {\n actions.stop({ x: e.x, y: e.y });\n },\n getAllowedDropOperations() {\n return [\"move\"];\n },\n });\n }, [actions, disabled, getDragItems, register]);\n\n const handlePointerDown = (e: PointerEvent<HTMLDivElement>) => {\n e.stopPropagation();\n const week = weekRef.current;\n if (!week) return;\n const rect = week.getBoundingClientRect();\n const column = Math.floor(((e.clientX - rect.left) / rect.width) * weekDays.length);\n const clamped = Math.min(Math.max(column, eventData.column), eventData.column + eventData.span - 1);\n grabbedDayRef.current = weekDays[clamped] ?? null;\n };\n\n const resizeListeners = (edge: MonthResizeEdge) => ({\n onMoveStart: () => {\n resize?.start(eventData.key, edge);\n return true;\n },\n onMove: (e: { clientX: number; clientY: number }) => resize?.move(e.clientX, e.clientY),\n onMoveEnd: () => resize?.end(),\n });\n const { listeners: resizeStartListeners } = useMove(resizeListeners(\"start\"));\n const { listeners: resizeEndListeners } = useMove(resizeListeners(\"end\"));\n\n const handleRootRef = useMergedRefs(rootRef, forwardedRef);\n\n const multiDay = eventData.span > 1 || !eventData.isStart || !eventData.isEnd;\n const style = cssVariables(\n { \"--ww-column\": eventData.column + 1, \"--ww-span\": eventData.span, \"--ww-row\": eventData.lane + 2 },\n rootProps.style\n );\n\n return (\n <div\n {...rootProps}\n {...(isAnyResizing ? null : attributes)}\n ref={handleRootRef}\n style={style}\n data-key={String(eventData.key)}\n data-continues-before={eventData.isStart ? undefined : \"\"}\n data-continues-after={eventData.isEnd ? undefined : \"\"}\n onPointerDown={handlePointerDown}\n onDoubleClick={(e) => e.stopPropagation()}\n className={cx(rootProps.className, styles.root__event, {\n [styles.root__event_span]: multiDay,\n [styles.root__event_continuesBefore]: !eventData.isStart,\n [styles.root__event_continuesAfter]: !eventData.isEnd,\n [styles.root__event_isDragging]: isDragging,\n [styles.root__event_isResizeSource]: isResizeSource,\n })}\n >\n {children}\n {resizable && eventData.isStart && (\n <div\n {...resizeStartListeners}\n data-edge=\"start\"\n className={cx(styles.root__resize, styles.root__resizeStart)}\n />\n )}\n {resizable && eventData.isEnd && (\n <div {...resizeEndListeners} data-edge=\"end\" className={cx(styles.root__resize, styles.root__resizeEnd)} />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAsBA,IAAMoB,IAAY;AA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KAAaH,EAAU,WACtBtB,kBAAC,OAAD;IACE,GAAIqE;IACJ,aAAU;IACV,WAAW3D,EAAGX,EAAO,cAAcA,EAAO,iBAAiB;GAC5D,CAAA;GAEF0B,KAAaH,EAAU,SACtBtB,kBAAC,OAAD;IAAK,GAAIsE;IAAoB,aAAU;IAAM,WAAW5D,EAAGX,EAAO,cAAcA,EAAO,eAAe;GAAI,CAAA;EAEzG;;AAET"}
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import { cx as e } from "@weekwise/core";
3
+ import { cssVariables as t } from "./MonthView.utils.js";
4
+ import n from "./MonthView.module.css.js";
5
+ import { jsx as r } from "react/jsx-runtime";
6
+ // src/components/month-view/MonthViewEventPreview.tsx
7
+ function i({ bar: i, children: a }) {
8
+ return /* @__PURE__ */ r("div", {
9
+ "aria-hidden": "true",
10
+ "data-key": String(i.key),
11
+ "data-continues-before": i.isStart ? void 0 : "",
12
+ "data-continues-after": i.isEnd ? void 0 : "",
13
+ className: e(n.root__event, n.root__event_isResizing, {
14
+ [n.root__event_span]: i.span > 1 || !i.isStart || !i.isEnd,
15
+ [n.root__event_continuesBefore]: !i.isStart,
16
+ [n.root__event_continuesAfter]: !i.isEnd
17
+ }),
18
+ style: t({
19
+ "--ww-column": i.column + 1,
20
+ "--ww-span": i.span,
21
+ "--ww-row": i.lane + 2
22
+ }),
23
+ children: a
24
+ });
25
+ }
26
+ export { i as default };
27
+
28
+ //# sourceMappingURL=MonthViewEventPreview.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MonthViewEventPreview.js","names":["_jsx","styles","cx","cssVariables","MonthView_module_default","jsx","MonthViewEventPreview","bar","children"],"sources":["../../../src/components/month-view/MonthViewEventPreview.tsx"],"sourcesContent":["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"],"mappings":";;;;;;AAeA,SAAwBM,EAAsB,EAAEC,QAAKC,eAAwC;CAC3F,OACER,kBAAC,OAAD;EACE,eAAY;EACZ,YAAU,OAAOO,EAAI,GAAG;EACxB,yBAAuBA,EAAI,UAAU,KAAA,IAAY;EACjD,wBAAsBA,EAAI,QAAQ,KAAA,IAAY;EAC9C,WAAWL,EAAGD,EAAO,aAAaA,EAAO,wBAAwB;IAC9DA,EAAO,mBAAmBM,EAAI,OAAO,KAAK,CAACA,EAAI,WAAW,CAACA,EAAI;IAC/DN,EAAO,8BAA8B,CAACM,EAAI;IAC1CN,EAAO,6BAA6B,CAACM,EAAI;EAC5C,CAAC;EACD,OAAOJ,EAAa;GAAE,eAAeI,EAAI,SAAS;GAAG,aAAaA,EAAI;GAAM,YAAYA,EAAI,OAAO;EAAE,CAAC;EAErGC;CACE,CAAA;AAET"}
@@ -1,3 +1,4 @@
1
+ import type { ReactNode } from "react";
1
2
  import type { EventKey, MonthBar, MonthWeekLayout, CalendarDate } from "@weekwise/core";
2
3
  import type { MonthResizeActions } from "./useMonthResize";
3
4
  export interface MonthViewWeekProps {
@@ -17,6 +18,10 @@ export interface MonthViewWeekProps {
17
18
  lanes: number;
18
19
  resizingKey?: EventKey;
19
20
  resize: MonthResizeActions;
21
+ /** The user's content of a day, from `renderDay`, in place of the bars. */
22
+ renderDayContent?: (day: CalendarDate) => ReactNode;
23
+ /** Reports a click on a day; without it the day cells are not buttons. */
24
+ onDayClick?: (date: CalendarDate) => void;
20
25
  }
21
26
  /** One week row: day cells, the bars of the events over them and "+N more" labels. */
22
27
  export default function MonthViewWeek(props: MonthViewWeekProps): import("react").JSX.Element;
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ import { useRef as e } from "react";
3
+ import { useCalendarDateUtils as t } from "../../date-localization/useDateUtils.js";
4
+ import n from "../../date-localization/useMessages.js";
5
+ import { useCalendarContext as r } from "../../contexts/CalendarContext.js";
6
+ import { cssVariables as i } from "./MonthView.utils.js";
7
+ import a from "./MonthViewDay.js";
8
+ import o from "./MonthViewEvent.js";
9
+ import s from "./MonthViewEventPreview.js";
10
+ import c from "./MonthView.module.css.js";
11
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
12
+ // src/components/month-view/MonthViewWeek.tsx
13
+ function d({ children: e }) {
14
+ return e == null || e === !1 || e === "" ? null : /* @__PURE__ */ l("div", {
15
+ className: c.root__dayContent,
16
+ children: e
17
+ });
18
+ }
19
+ function f(f) {
20
+ let { days: p, firstDayIndex: m, cellRef: h, layout: g, sourceBars: _, lanes: v, resizingKey: y, resize: b, renderDayContent: x, onDayClick: S } = f, C = e(null), { viewValue: w, eventRenderer: T, view: E, disabled: D } = r(), { getMonthDay: O, isSameMonth: k, isToday: A, toMillis: j } = t(), M = n(), N = y !== void 0, P = (e) => T.current?.(e.value, E, {
21
+ isStart: e.isStart,
22
+ isEnd: e.isEnd
23
+ }), F = (e, t = !1) => /* @__PURE__ */ l(o, {
24
+ eventData: e,
25
+ weekDays: p,
26
+ weekRef: C,
27
+ resizable: !D,
28
+ resize: b,
29
+ isResizeSource: t,
30
+ isAnyResizing: N,
31
+ children: P(e)
32
+ }, e.key);
33
+ return /* @__PURE__ */ u("div", {
34
+ ref: C,
35
+ className: c.root__week,
36
+ children: [
37
+ p.map((e, t) => /* @__PURE__ */ u(a, {
38
+ ref: h(m + t),
39
+ targetDate: e,
40
+ onDayClick: S,
41
+ "data-day-index": m + t,
42
+ "data-is-outside": !k(e, w) || void 0,
43
+ "data-is-today": A(e) ? !0 : void 0,
44
+ style: i({ "--ww-column": t + 1 }),
45
+ children: [/* @__PURE__ */ l("span", {
46
+ className: c.root__dayNumber,
47
+ children: O(e)
48
+ }), x && /* @__PURE__ */ l(d, { children: x(e) })]
49
+ }, j(e))),
50
+ [...g.bars.map((e) => e.key === y ? /* @__PURE__ */ l(s, {
51
+ bar: e,
52
+ children: P(e)
53
+ }, `preview-${e.key}`) : F(e)), ..._.map((e) => F(e, !0))],
54
+ p.map((e, t) => g.hidden[t] > 0 && /* @__PURE__ */ l("span", {
55
+ className: c.root__more,
56
+ style: i({
57
+ "--ww-column": t + 1,
58
+ "--ww-row": v + 2
59
+ }),
60
+ children: M.more(g.hidden[t])
61
+ }, `more-${j(e)}`))
62
+ ]
63
+ });
64
+ }
65
+ export { f as default };
66
+
67
+ //# sourceMappingURL=MonthViewWeek.js.map