@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":"MonthViewWeek.js","names":["_jsx","styles","_jsxs","useRef","useCalendarDateUtils","useMessages","useCalendarContext","cssVariables","MonthViewDay","MonthViewEvent","MonthViewEventPreview","MonthView_module_default","jsx","jsxs","MonthViewDayContent","children","MonthViewWeek","props","days","firstDayIndex","cellRef","layout","sourceBars","lanes","resizingKey","resize","renderDayContent","onDayClick","weekRef","viewValue","eventRenderer","view","disabled","getMonthDay","isSameMonth","isToday","toMillis","messages","isResizing","renderEvent","bar","renderBar","isResizeSource","day","column"],"sources":["../../../src/components/month-view/MonthViewWeek.tsx"],"sourcesContent":["import { useRef } from \"react\";\nimport type { ReactNode } from \"react\";\n\nimport type { EventKey, MonthBar, MonthWeekLayout, CalendarDate } from \"@weekwise/core\";\n\nimport { useCalendarDateUtils, useMessages } from \"../../date-localization\";\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\n\nimport { cssVariables } from \"./MonthView.utils\";\nimport MonthViewDay from \"./MonthViewDay\";\nimport MonthViewEvent from \"./MonthViewEvent\";\nimport MonthViewEventPreview from \"./MonthViewEventPreview\";\nimport type { MonthResizeActions } from \"./useMonthResize\";\n\nimport styles from \"./MonthView.module.css\";\n\nexport interface MonthViewWeekProps {\n days: CalendarDate[];\n /** Index of the week's first day in the month grid. */\n firstDayIndex: number;\n /** Ref for the cell of the day at an index in the month grid. */\n cellRef: (index: number) => (node: HTMLDivElement | null) => void;\n /** Bars to draw: with the resized event's new range while it changes. */\n layout: MonthWeekLayout<unknown, CalendarDate>;\n /**\n * The resized event's bars before the change. They stay mounted, hidden, while the\n * preview shows the new range: their edge handles the pointer until it is released.\n */\n sourceBars: MonthBar<unknown, CalendarDate>[];\n /** Lanes of bars that fit into the row; the \"+N more\" labels go below them. */\n lanes: number;\n resizingKey?: EventKey;\n resize: MonthResizeActions;\n /** The user's content of a day, from `renderDay`, in place of the bars. */\n renderDayContent?: (day: CalendarDate) => ReactNode;\n /** Reports a click on a day; without it the day cells are not buttons. */\n onDayClick?: (date: CalendarDate) => void;\n}\n\n/** The user's content of a day, under its number; nothing when the content is empty. */\nfunction MonthViewDayContent({ children }: { children: ReactNode }) {\n if (children === null || children === undefined || children === false || children === \"\") return null;\n return <div className={styles.root__dayContent}>{children}</div>;\n}\n\n/** One week row: day cells, the bars of the events over them and \"+N more\" labels. */\nexport default function MonthViewWeek(props: MonthViewWeekProps) {\n const { days, firstDayIndex, cellRef, layout, sourceBars, lanes, resizingKey, resize, renderDayContent, onDayClick } =\n props;\n const weekRef = useRef<HTMLDivElement>(null);\n\n const { viewValue, eventRenderer, view, disabled } = useCalendarContext();\n const { getMonthDay, isSameMonth, isToday, toMillis } = useCalendarDateUtils();\n const messages = useMessages();\n\n const isResizing = resizingKey !== undefined;\n const renderEvent = (bar: MonthBar<unknown, CalendarDate>) =>\n eventRenderer.current?.(bar.value, view, { isStart: bar.isStart, isEnd: bar.isEnd });\n\n const renderBar = (bar: MonthBar<unknown, CalendarDate>, isResizeSource = false) => (\n <MonthViewEvent\n key={bar.key}\n eventData={bar}\n weekDays={days}\n weekRef={weekRef}\n resizable={!disabled}\n resize={resize}\n isResizeSource={isResizeSource}\n isAnyResizing={isResizing}\n >\n {renderEvent(bar)}\n </MonthViewEvent>\n );\n\n return (\n <div ref={weekRef} className={styles.root__week}>\n {days.map((day, column) => (\n <MonthViewDay\n key={toMillis(day)}\n ref={cellRef(firstDayIndex + column)}\n targetDate={day}\n onDayClick={onDayClick}\n data-day-index={firstDayIndex + column}\n data-is-outside={isSameMonth(day, viewValue) ? undefined : true}\n data-is-today={isToday(day) ? true : undefined}\n style={cssVariables({ \"--ww-column\": column + 1 })}\n >\n <span className={styles.root__dayNumber}>{getMonthDay(day)}</span>\n {renderDayContent && <MonthViewDayContent>{renderDayContent(day)}</MonthViewDayContent>}\n </MonthViewDay>\n ))}\n {/*\n One list, so that a bar keeps its key among the same siblings when it becomes the\n hidden source of a resize: it stays mounted and its edge keeps the pointer.\n */}\n {[\n ...layout.bars.map((bar) =>\n bar.key === resizingKey ? (\n <MonthViewEventPreview key={`preview-${bar.key}`} bar={bar}>\n {renderEvent(bar)}\n </MonthViewEventPreview>\n ) : (\n renderBar(bar)\n )\n ),\n ...sourceBars.map((bar) => renderBar(bar, true)),\n ]}\n {days.map(\n (day, column) =>\n layout.hidden[column] > 0 && (\n <span\n key={`more-${toMillis(day)}`}\n className={styles.root__more}\n style={cssVariables({ \"--ww-column\": column + 1, \"--ww-row\": lanes + 2 })}\n >\n {messages.more(layout.hidden[column])}\n </span>\n )\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAwCA,SAASc,EAAoB,EAAEC,eAAqC;CAElE,OADIA,KAAa,QAAkCA,MAAa,M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,CAAG,CAWL,CACf;GAKA,CACC,GAAGtB,EAAO,KAAK,KAAKmB,MAClBA,EAAI,QAAQhB,IACVxB,kBAACU,GAAD;IAAuD8B;IACpD,UAAAD,EAAYC,CAAG;GACK,GAFK,WAAWA,EAAI,KAEpB,IAEvBC,EAAUD,CAAG,CAEjB,GACA,GAAGlB,EAAW,KAAKkB,MAAQC,EAAUD,GAAK,EAAI,CAAC,CACjD;GACCtB,EAAK,KACHyB,GAAKC,MACJvB,EAAO,OAAOuB,KAAU,KACtB5C,kBAAC,QAAD;IAEE,WAAWC,EAAO;IAClB,OAAOM,EAAa;KAAE,eAAeqC,IAAS;KAAG,YAAYrB,IAAQ;IAAE,CAAC;IAEvE,UAAAc,EAAS,KAAKhB,EAAO,OAAOuB,EAAO;GAChC,GALC,QAAQR,EAASO,CAAG,GAKrB,CAEZ;EACG;;AAET"}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { useState as e } from "react";
3
+ import { getMonthLaneCount as t } from "@weekwise/core";
4
+ import n from "../../hooks/useIsomorphicLayoutEffect.js";
5
+ import r from "../../hooks/useResizeObserver.js";
6
+ // src/components/month-view/useMonthLanes.ts
7
+ function i(i, a) {
8
+ let [o, s] = e(a), c = () => {
9
+ let e = i.current?.firstElementChild;
10
+ e?.clientHeight && s(t(e.clientHeight, a));
11
+ }, l = r(c);
12
+ return n(() => {
13
+ c();
14
+ let e = i.current?.firstElementChild;
15
+ return e && l?.observe(e), () => {
16
+ e && l?.unobserve(e);
17
+ };
18
+ }, [l, a]), o;
19
+ }
20
+ export { i as default };
21
+
22
+ //# sourceMappingURL=useMonthLanes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMonthLanes.js","names":["useState","getMonthLaneCount","useIsomorphicLayoutEffect","useResizeObserver","useMonthLanes","viewportRef","maxLanes","lanes","setLanes","measure","week","resizeObserver"],"sources":["../../../src/components/month-view/useMonthLanes.ts"],"sourcesContent":["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"],"mappings":";;;;;;AAWA,SAAwBI,EAAcC,GAA4CC,GAAkB;CAClG,IAAM,CAACC,GAAOC,KAAYR,EAASM,CAAQ,GAErCG,UAAgB;EACpB,IAAMC,IAAOL,EAAY,SAAS;EAE9BK,GAAM,gBAAcF,EAASP,EAAkBS,EAAK,cAAcJ,CAAQ,CAAC;CACjF,GAEMK,IAAiBR,EAAkBM,CAAO;CAWhD,OATAP,QAAgC;EAC9BO,EAAQ;EACR,IAAMC,IAAOL,EAAY,SAAS;EAElC,OADIK,KAAMC,GAAgB,QAAQD,CAAI,SACzB;GACPA,KAAMC,GAAgB,UAAUD,CAAI;EAC1C;CACF,GAAG,CAACC,GAAgBL,CAAQ,CAAC,GAEtBC;AACT"}
@@ -0,0 +1,57 @@
1
+ "use client";
2
+ import { useMemo as e } from "react";
3
+ import { getEventTimeFrameFromInfo as t, resizeEventDays as n } from "@weekwise/core";
4
+ import r from "../../hooks/useEventCallback.js";
5
+ import i from "../../hooks/useGlobalListeners.js";
6
+ import a from "../../hooks/useItemsLayout.js";
7
+ import o from "../../hooks/useStateRef.js";
8
+ // src/components/month-view/useMonthResize.ts
9
+ function s(s) {
10
+ let { days: c, viewportRef: l, cellsRef: u, dateUtils: d, eventMap: f, disabled: p, getIsDayDisabled: m, onEventChange: h } = s, [g, _, v] = o(null), { addGlobalListener: y, removeAllGlobalListeners: b } = i(), x = a(l, u), S = r((e = !0) => {
11
+ let t = v.current;
12
+ t && (b(), x.release(), _(null), e && t.result && h(t.key, t.result.date, t.result.info));
13
+ }), C = r((e) => {
14
+ e.key === "Escape" && S(!1);
15
+ }), w = r((e, t) => {
16
+ p || v.current || (x.measure(), _({
17
+ key: e,
18
+ edge: t,
19
+ result: null
20
+ }), y(document, "keydown", C, !0));
21
+ }), T = r((e, t) => {
22
+ let r = v.current, i = r && f.get(r.key), a = c[x.nearestIndex(e, t)];
23
+ r && i && a && !m?.(a) && _({
24
+ ...r,
25
+ result: n(d, i, r.edge, a)
26
+ });
27
+ }), E = e(() => ({
28
+ start: w,
29
+ move: T,
30
+ end: S
31
+ }), [
32
+ S,
33
+ T,
34
+ w
35
+ ]), D = e(() => {
36
+ let e = g?.result && f.get(g.key);
37
+ if (!g?.result || !e) return f;
38
+ let [n] = t(d, g.result.date, g.result.info);
39
+ return new Map(f).set(g.key, {
40
+ ...e,
41
+ date: n,
42
+ duration: g.result.info.duration
43
+ });
44
+ }, [
45
+ d,
46
+ f,
47
+ g
48
+ ]);
49
+ return {
50
+ resizingKey: g?.key,
51
+ actions: E,
52
+ eventMap: D
53
+ };
54
+ }
55
+ export { s as default };
56
+
57
+ //# sourceMappingURL=useMonthResize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMonthResize.js","names":["useMemo","getEventTimeFrameFromInfo","resizeEventDays","useEventCallback","useGlobalListeners","useItemsLayout","useStateRef","useMonthResize","params","days","viewportRef","cellsRef","dateUtils","eventMap","disabled","getIsDayDisabled","onEventChange","session","setSession","sessionRef","addGlobalListener","removeAllGlobalListeners","layout","end","commit","current","handleKeyDown","start","key","edge","move","x","y","event","target","actions","shownEventMap","date"],"sources":["../../../src/components/month-view/useMonthResize.ts"],"sourcesContent":["import type { CalendarDate } from \"@weekwise/core\";\nimport { useMemo } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport {\n getEventTimeFrameFromInfo,\n resizeEventDays,\n type DateAdapter,\n type EventChangeInfo,\n type EventKey,\n type EventMap,\n} from \"@weekwise/core\";\n\nimport { useEventCallback, useGlobalListeners, useItemsLayout, useStateRef } from \"../../hooks\";\n\nexport type MonthResizeEdge = \"start\" | \"end\";\n\ninterface ResizeSession {\n key: EventKey;\n edge: MonthResizeEdge;\n /** The change so far; `null` until the edge reaches another day. */\n result: ReturnType<typeof resizeEventDays<CalendarDate>>;\n}\n\n/** Driven by the `useMove` listeners of a bar's edge. */\nexport interface MonthResizeActions {\n start: (key: EventKey, edge: MonthResizeEdge) => void;\n move: (x: number, y: number) => void;\n /** Applies the change; `false` drops it. */\n end: (commit?: boolean) => void;\n}\n\ninterface UseMonthResizeParams<TValue> {\n /** Days of the month grid. */\n days: CalendarDate[];\n viewportRef: RefObject<HTMLElement | null>;\n /** The day cells, in the order of `days`: the edge goes into the one nearest the pointer. */\n cellsRef: { readonly current: readonly (HTMLElement | null)[] };\n dateUtils: DateAdapter<CalendarDate>;\n eventMap: EventMap<TValue, CalendarDate>;\n disabled: boolean;\n getIsDayDisabled?: (date: CalendarDate) => boolean;\n onEventChange: (key: EventKey, date: CalendarDate, info: EventChangeInfo) => void;\n}\n\n/**\n * Stretches an event into other days by the left or right edge of its month-view bar.\n * `eventMap` is the map to draw while it changes, with the event's new range.\n */\nexport default function useMonthResize<TValue>(params: UseMonthResizeParams<TValue>) {\n const { days, viewportRef, cellsRef, dateUtils, eventMap, disabled, getIsDayDisabled, onEventChange } = params;\n\n const [session, setSession, sessionRef] = useStateRef<ResizeSession | null>(null);\n // Escape drops the change\n const { addGlobalListener, removeAllGlobalListeners } = useGlobalListeners();\n // the grid and its day cells, measured once a resize starts\n const layout = useItemsLayout(viewportRef, cellsRef);\n\n const end = useEventCallback((commit: boolean = true) => {\n const current = sessionRef.current;\n if (!current) return;\n removeAllGlobalListeners();\n layout.release();\n setSession(null);\n if (commit && current.result) {\n onEventChange(current.key, current.result.date, current.result.info);\n }\n });\n\n const handleKeyDown = useEventCallback((e: KeyboardEvent) => {\n if (e.key === \"Escape\") end(false);\n });\n\n const start = useEventCallback((key: EventKey, edge: MonthResizeEdge) => {\n if (disabled || sessionRef.current) return;\n layout.measure();\n setSession({ key, edge, result: null });\n addGlobalListener(document, \"keydown\", handleKeyDown, true);\n });\n\n const move = useEventCallback((x: number, y: number) => {\n const current = sessionRef.current;\n const event = current && eventMap.get(current.key);\n const target = days[layout.nearestIndex(x, y)];\n // an edge does not go into a day that cannot be edited; the last valid range stays\n if (!current || !event || !target || getIsDayDisabled?.(target)) return;\n setSession({ ...current, result: resizeEventDays(dateUtils, event, current.edge, target) });\n });\n\n const actions = useMemo<MonthResizeActions>(() => ({ start, move, end }), [end, move, start]);\n\n const shownEventMap = useMemo(() => {\n const event = session?.result && eventMap.get(session.key);\n if (!session?.result || !event) return eventMap;\n const [date] = getEventTimeFrameFromInfo(dateUtils, session.result.date, session.result.info);\n return new Map(eventMap).set(session.key, { ...event, date, duration: session.result.info.duration });\n }, [dateUtils, eventMap, session]);\n\n return {\n /** Key of the event being resized, if any. */\n resizingKey: session?.key,\n actions,\n eventMap: shownEventMap,\n };\n}\n"],"mappings":";;;;;;;;AAiDA,SAAwBO,EAAuBC,GAAsC;CACnF,IAAM,EAAEC,SAAMC,gBAAaC,aAAUC,cAAWC,aAAUC,aAAUC,qBAAkBC,qBAAkBR,GAElG,CAACS,GAASC,GAAYC,KAAcb,EAAkC,IAAI,GAE1E,EAAEc,sBAAmBC,gCAA6BjB,EAAmB,GAErEkB,IAASjB,EAAeK,GAAaC,CAAQ,GAE7CY,IAAMpB,GAAkBqB,IAAkB,OAAS;EACvD,IAAMC,IAAUN,EAAW;EACtBM,MACLJ,EAAyB,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,OAAO;EAEL,aAAaA,GAAS;EACtBkB;EACA,UAAUC;CACZ;AACF"}
@@ -0,0 +1,28 @@
1
+ "use client";
2
+ import e from "../../icons/chevron.js";
3
+ import t from "../../hooks/useEventCallback.js";
4
+ import { cx as n, mergeCallbacks as r } from "@weekwise/core";
5
+ import { useCalendarContext as i } from "../../contexts/CalendarContext.js";
6
+ import a from "../../date-localization/useMessages.js";
7
+ import o from "./NavBtn.module.css.js";
8
+ import { jsx as s } from "react/jsx-runtime";
9
+ // src/components/nav-btn/NavBtn.tsx
10
+ function c({ direction: c = "forward", type: l = "button", onClick: u, className: d, children: f, ...p }) {
11
+ let { goForward: m, goBackward: h } = i(), g = a(), _ = t(r(u, () => {
12
+ c === "forward" ? m() : c === "backward" && h();
13
+ }));
14
+ return /* @__PURE__ */ s("button", {
15
+ type: l,
16
+ "aria-label": c === "forward" ? g.next : g.previous,
17
+ ...p,
18
+ onClick: _,
19
+ className: n(d, o.root),
20
+ children: f ?? /* @__PURE__ */ s(e, { className: n(o.root__icon, {
21
+ [o.root__icon_backward]: c === "backward",
22
+ [o.root__icon_forward]: c === "forward"
23
+ }) })
24
+ });
25
+ }
26
+ export { c as default };
27
+
28
+ //# sourceMappingURL=NavBtn.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavBtn.js","names":["_jsx","styles","ChevronIcon","useEventCallback","cx","mergeCallbacks","useCalendarContext","useMessages","NavBtn_module_default","jsx","NavBtn","direction","type","onClick","className","children","props","goForward","goBackward","messages","handleClick"],"sources":["../../../src/components/nav-btn/NavBtn.tsx"],"sourcesContent":["import type { ButtonHTMLAttributes } from \"react\";\n\nimport ChevronIcon from \"../../icons/chevron\";\nimport { useEventCallback } from \"../../hooks\";\nimport { cx, mergeCallbacks } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useMessages } from \"../../date-localization\";\n\nimport styles from \"./NavBtn.module.css\";\n\nexport type NavBtnProps = ButtonHTMLAttributes<HTMLButtonElement> & {\n direction?: \"forward\" | \"backward\";\n};\n\nexport default function NavBtn({\n direction = \"forward\",\n type = \"button\",\n onClick,\n className,\n children,\n ...props\n}: NavBtnProps) {\n const { goForward, goBackward } = useCalendarContext();\n const messages = useMessages();\n\n const handleClick = useEventCallback(\n mergeCallbacks(onClick, () => {\n if (direction === \"forward\") {\n goForward();\n } else if (direction === \"backward\") {\n goBackward();\n }\n })\n );\n\n return (\n <button\n type={type}\n aria-label={direction === \"forward\" ? messages.next : messages.previous}\n {...props}\n onClick={handleClick}\n className={cx(className, styles.root)}\n >\n {children ?? (\n <ChevronIcon\n className={cx(styles.root__icon, {\n [styles.root__icon_backward]: direction === \"backward\",\n [styles.root__icon_forward]: direction === \"forward\",\n })}\n />\n )}\n </button>\n );\n}\n"],"mappings":";;;;;;;;;AAeA,SAAwBU,EAAO,EAC7BC,eAAY,WACZC,UAAO,UACPC,YACAC,cACAC,aACA,GAAGC,KACW;CACd,IAAM,EAAEC,cAAWC,kBAAeZ,EAAmB,GAC/Ca,IAAWZ,EAAY,GAEvBa,IAAcjB,EAClBE,EAAeQ,SAAe;EACxBF,MAAc,YAChBM,EAAU,IACDN,MAAc,cACvBO,EAAW;CAEf,CAAC,CACH;CAEA,OACElB,kBAAC,UAAD;EACQY;EACN,cAAYD,MAAc,YAAYQ,EAAS,OAAOA,EAAS;EAC/D,GAAIH;EACJ,SAASI;EACT,WAAWhB,EAAGU,GAAWb,EAAO,IAAI;EAEnC,UAAAc,KACCf,kBAACE,GAAD,EACE,WAAWE,EAAGH,EAAO,YAAY;IAC9BA,EAAO,sBAAsBU,MAAc;IAC3CV,EAAO,qBAAqBU,MAAc;EAC7C,CAAC,EACF,CAAA;CAEG,CAAA;AAEZ"}
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ // src/components/nav-btn/NavBtn.module.css
3
+ var e = "_root_uo171_1", t = "_root__icon_uo171_23", n = "_root__icon_forward_uo171_27", r = "_root__icon_backward_uo171_31", i = {
4
+ root: e,
5
+ root__icon: t,
6
+ root__icon_forward: n,
7
+ root__icon_backward: r
8
+ };
9
+ export { i as default, e as root, t as root__icon, r as root__icon_backward, n as root__icon_forward };
10
+
11
+ //# sourceMappingURL=NavBtn.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NavBtn.module.css.js","names":["root","root__icon","root__icon_forward","root__icon_backward","NavBtn_module_default"],"sources":[],"mappings":""}
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { cx as e } from "@weekwise/core";
3
+ import t from "./PointerPopover.module.css.js";
4
+ import { jsx as n } from "react/jsx-runtime";
5
+ // src/components/pointer-popover/PointerPopover.tsx
6
+ function r({ coordinates: r, className: i, style: a, ...o }) {
7
+ return /* @__PURE__ */ n("span", {
8
+ tabIndex: -1,
9
+ ...o,
10
+ className: e(i, t.root),
11
+ style: {
12
+ ...a,
13
+ ...r ? {
14
+ top: `calc(${r.y}px + 20px)`,
15
+ left: `calc(${r.x}px + 20px)`
16
+ } : null
17
+ }
18
+ });
19
+ }
20
+ export { r as default };
21
+
22
+ //# sourceMappingURL=PointerPopover.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PointerPopover.js","names":["_jsx","styles","cx","PointerPopover_module_default","jsx","PointerPopover","coordinates","className","style","props"],"sources":["../../../src/components/pointer-popover/PointerPopover.tsx"],"sourcesContent":["import type { HTMLAttributes } from \"react\";\n\nimport { cx } from \"@weekwise/core\";\nimport type { Coordinates } from \"@weekwise/core\";\n\nimport styles from \"./PointerPopover.module.css\";\n\nexport type PointerPopoverProps = HTMLAttributes<HTMLSpanElement> & {\n coordinates?: Coordinates;\n};\n\nexport default function PointerPopover({ coordinates, className, style, ...props }: PointerPopoverProps) {\n return (\n <span\n tabIndex={-1}\n {...props}\n className={cx(className, styles.root)}\n style={{\n ...style,\n ...(coordinates\n ? {\n top: `calc(${coordinates.y}px + 20px)`,\n left: `calc(${coordinates.x}px + 20px)`,\n }\n : null),\n }}\n />\n );\n}\n"],"mappings":";;;;;AAWA,SAAwBK,EAAe,EAAEC,gBAAaC,cAAWC,UAAO,GAAGC,KAA8B;CACvG,OACET,kBAAC,QAAD;EACE,UAAU;EACV,GAAIS;EACJ,WAAWP,EAAGK,GAAWN,EAAO,IAAI;EACpC,OAAO;GACL,GAAGO;GACH,GAAIF,IACA;IACE,KAAK,QAAQA,EAAY,EAAE;IAC3B,MAAM,QAAQA,EAAY,EAAE;GAC9B,IACA;EACN;CACD,CAAA;AAEL"}
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ // src/components/pointer-popover/PointerPopover.module.css
3
+ var e = "_root_1pvvm_1", t = { root: e };
4
+ export { t as default, e as root };
5
+
6
+ //# sourceMappingURL=PointerPopover.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PointerPopover.module.css.js","names":["root","PointerPopover_module_default"],"sources":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The day and the week view: one component for both, so that it stays mounted when the user
3
+ * switches between them. It takes no options: their time step is read by the calendar and
4
+ * reaches the timeline through the calendar context.
5
+ */
6
+ export default function TimelineView(): import("react").JSX.Element;
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import e from "../day-week-view/DayWeekView.js";
3
+ import { jsx as t } from "react/jsx-runtime";
4
+ // src/components/timeline-view/TimelineView.tsx
5
+ function n() {
6
+ return /* @__PURE__ */ t(e, {});
7
+ }
8
+ export { n as default };
9
+
10
+ //# sourceMappingURL=TimelineView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimelineView.js","names":["_jsx","DayWeekView","jsx","TimelineView"],"sources":["../../../src/components/timeline-view/TimelineView.tsx"],"sourcesContent":["import DayWeekView from \"../day-week-view\";\n\n/**\n * The day and the week view: one component for both, so that it stays mounted when the user\n * switches between them. It takes no options: their time step is read by the calendar and\n * reaches the timeline through the calendar context.\n */\nexport default function TimelineView() {\n return <DayWeekView />;\n}\n"],"mappings":";;;;AAOA,SAAwBG,IAAe;CACrC,OAAOH,kBAACC,GAAD,CAAc,CAAA;AACvB"}
@@ -0,0 +1 @@
1
+ export { default } from "./TimelineView";
@@ -2,7 +2,7 @@ export type ViewSelectProps = {
2
2
  className?: string;
3
3
  };
4
4
  /**
5
- * The view (day, week, month) as one button with a list: the view tabs of a calendar too
5
+ * The view (among the calendar's views) as one button with a list: the view tabs of a calendar too
6
6
  * narrow for them.
7
7
  */
8
8
  export default function ViewSelect({ className }: ViewSelectProps): import("react").JSX.Element;
@@ -0,0 +1,117 @@
1
+ "use client";
2
+ import { autoUpdate as e, flip as t, offset as n, shift as r, useFloating as i } from "@floating-ui/react-dom";
3
+ import { useEffect as a, useId as o, useRef as s, useState as c } from "react";
4
+ import { cx as l } from "@weekwise/core";
5
+ import { useCalendarContext as u } from "../../contexts/CalendarContext.js";
6
+ import d from "../../date-localization/useMessages.js";
7
+ import f from "../../hooks/useGlobalListeners.js";
8
+ import p from "../../icons/chevron.js";
9
+ import m from "../../portal/Portal.js";
10
+ import h from "./ViewSelect.module.css.js";
11
+ import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
12
+ // src/components/view-select/ViewSelect.tsx
13
+ function y({ className: y }) {
14
+ let { view: b, views: x, changeView: S } = u(), C = d(), { addGlobalListener: w, removeGlobalListener: T } = f(), E = o(), [D, O] = c(!1), [k, A] = c(b), j = s(/* @__PURE__ */ new Map()), { refs: M, floatingStyles: N } = i({
15
+ placement: "bottom-end",
16
+ middleware: [
17
+ n(6),
18
+ t({ padding: 8 }),
19
+ r({ padding: 8 })
20
+ ],
21
+ whileElementsMounted: e
22
+ }), P = (e) => {
23
+ O(!1);
24
+ let t = M.reference.current;
25
+ e && t instanceof HTMLElement && t.focus();
26
+ }, F = (e = b) => {
27
+ A(e), O(!0);
28
+ }, I = (e) => {
29
+ P(!0), S(e);
30
+ };
31
+ a(() => {
32
+ D && j.current.get(k)?.focus();
33
+ }, [D, k]), a(() => {
34
+ if (!D) return;
35
+ let e = (e) => {
36
+ let t = e.target, n = M.reference.current;
37
+ n instanceof Node && n.contains(t) || M.floating.current?.contains(t) || O(!1);
38
+ };
39
+ return w(document, "pointerdown", e), () => T(document, "pointerdown", e);
40
+ }, [
41
+ w,
42
+ D,
43
+ M.floating,
44
+ M.reference,
45
+ T
46
+ ]);
47
+ let L = (e) => {
48
+ (e.key === "ArrowDown" || e.key === "ArrowUp") && (e.preventDefault(), F());
49
+ }, R = (e) => {
50
+ let t = x.indexOf(k), n = (t) => {
51
+ e.preventDefault(), A(x[(t + x.length) % x.length] ?? k);
52
+ };
53
+ switch (e.key) {
54
+ case "ArrowDown": return n(t + 1);
55
+ case "ArrowUp": return n(t - 1);
56
+ case "Home": return n(0);
57
+ case "End": return n(x.length - 1);
58
+ case "Enter":
59
+ case " ": return e.preventDefault(), I(k);
60
+ case "Escape": return e.preventDefault(), P(!0);
61
+ case "Tab": return P(!1);
62
+ }
63
+ }, z = `${E}-list`;
64
+ return /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ v("button", {
65
+ ref: M.setReference,
66
+ type: "button",
67
+ "aria-haspopup": "listbox",
68
+ "aria-expanded": D,
69
+ "aria-controls": D ? z : void 0,
70
+ "aria-label": `${C.chooseView}: ${C[b]}`,
71
+ className: l(y, h.root),
72
+ onClick: () => D ? P(!1) : F(),
73
+ onKeyDown: L,
74
+ children: [C[b], /* @__PURE__ */ _(p, {
75
+ "aria-hidden": "true",
76
+ className: l(h.root__icon, { [h.root__icon_open]: D })
77
+ })]
78
+ }), D && /* @__PURE__ */ _(m, { children: /* @__PURE__ */ _("div", {
79
+ ref: M.setFloating,
80
+ id: z,
81
+ role: "listbox",
82
+ "aria-label": C.chooseView,
83
+ style: N,
84
+ className: h.list,
85
+ onKeyDown: R,
86
+ children: x.map((e) => /* @__PURE__ */ v("div", {
87
+ ref: (t) => {
88
+ t ? j.current.set(e, t) : j.current.delete(e);
89
+ },
90
+ id: `${E}-${e}`,
91
+ role: "option",
92
+ tabIndex: -1,
93
+ "aria-selected": e === b,
94
+ className: l(h.list__option, { [h.list__option_active]: e === k }),
95
+ onClick: () => I(e),
96
+ onPointerMove: () => A(e),
97
+ children: [C[e], e === b && /* @__PURE__ */ _("svg", {
98
+ "aria-hidden": "true",
99
+ className: h.list__check,
100
+ viewBox: "0 0 16 16",
101
+ width: "14",
102
+ height: "14",
103
+ children: /* @__PURE__ */ _("path", {
104
+ d: "M3 8.5 6.5 12 13 4.5",
105
+ fill: "none",
106
+ stroke: "currentColor",
107
+ strokeWidth: "2",
108
+ strokeLinecap: "round",
109
+ strokeLinejoin: "round"
110
+ })
111
+ })]
112
+ }, e))
113
+ }) })] });
114
+ }
115
+ export { y as default };
116
+
117
+ //# sourceMappingURL=ViewSelect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewSelect.js","names":["_jsxs","_Fragment","styles","_jsx","autoUpdate","flip","offset","shift","useFloating","useEffect","useId","useRef","useState","cx","useCalendarContext","useMessages","useGlobalListeners","ChevronIcon","Portal","ViewSelect_module_default","Fragment","jsx","jsxs","ViewSelect","className","view","views","changeView","messages","addGlobalListener","removeGlobalListener","id","open","setOpen","active","setActive","optionRefs","refs","floatingStyles","close","returnFocus","reference","openList","focused","select","next","handlePointerDown","event","target","handleToggleKeyDown","handleListKeyDown","index","moveTo","listId","option","element"],"sources":["../../../src/components/view-select/ViewSelect.tsx"],"sourcesContent":["import { autoUpdate, flip, offset, shift, useFloating } from \"@floating-ui/react-dom\";\nimport { useEffect, useId, useRef, useState } from \"react\";\nimport type { KeyboardEvent } from \"react\";\n\nimport { cx } from \"@weekwise/core\";\n\nimport { useCalendarContext } from \"../../contexts/CalendarContext\";\nimport { useMessages } from \"../../date-localization\";\nimport { useGlobalListeners } from \"../../hooks\";\nimport ChevronIcon from \"../../icons/chevron\";\nimport Portal from \"../../portal\";\nimport type { CalendarView } from \"../../Calendar.types\";\n\nimport styles from \"./ViewSelect.module.css\";\n\nexport type ViewSelectProps = { className?: string };\n\n/**\n * The view (among the calendar's views) as one button with a list: the view tabs of a calendar too\n * narrow for them.\n */\nexport default function ViewSelect({ className }: ViewSelectProps) {\n const { view, views, changeView } = useCalendarContext();\n const messages = useMessages();\n const { addGlobalListener, removeGlobalListener } = useGlobalListeners();\n const id = useId();\n\n const [open, setOpen] = useState(false);\n const [active, setActive] = useState(view);\n const optionRefs = useRef(new Map<CalendarView, HTMLDivElement>());\n\n const { refs, floatingStyles } = useFloating({\n placement: \"bottom-end\",\n middleware: [offset(6), flip({ padding: 8 }), shift({ padding: 8 })],\n whileElementsMounted: autoUpdate,\n });\n\n const close = (returnFocus: boolean) => {\n setOpen(false);\n const reference = refs.reference.current;\n if (returnFocus && reference instanceof HTMLElement) reference.focus();\n };\n\n const openList = (focused: CalendarView = view) => {\n setActive(focused);\n setOpen(true);\n };\n\n const select = (next: CalendarView) => {\n close(true);\n changeView(next);\n };\n\n // the active option has the focus while the list is open\n useEffect(() => {\n if (open) optionRefs.current.get(active)?.focus();\n }, [open, active]);\n\n useEffect(() => {\n if (!open) return;\n const handlePointerDown = (event: PointerEvent) => {\n const target = event.target as Node;\n const reference = refs.reference.current;\n const inside =\n (reference instanceof Node && reference.contains(target)) || refs.floating.current?.contains(target);\n if (!inside) setOpen(false);\n };\n addGlobalListener(document, \"pointerdown\", handlePointerDown);\n return () => removeGlobalListener(document, \"pointerdown\", handlePointerDown);\n }, [addGlobalListener, open, refs.floating, refs.reference, removeGlobalListener]);\n\n const handleToggleKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"ArrowDown\" || event.key === \"ArrowUp\") {\n event.preventDefault();\n openList();\n }\n };\n\n const handleListKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {\n const index = views.indexOf(active);\n const moveTo = (next: number) => {\n event.preventDefault();\n setActive(views[(next + views.length) % views.length] ?? active);\n };\n\n switch (event.key) {\n case \"ArrowDown\":\n return moveTo(index + 1);\n case \"ArrowUp\":\n return moveTo(index - 1);\n case \"Home\":\n return moveTo(0);\n case \"End\":\n return moveTo(views.length - 1);\n case \"Enter\":\n case \" \":\n event.preventDefault();\n return select(active);\n case \"Escape\":\n event.preventDefault();\n return close(true);\n case \"Tab\":\n return close(false);\n }\n };\n\n const listId = `${id}-list`;\n\n return (\n <>\n <button\n ref={refs.setReference}\n type=\"button\"\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-controls={open ? listId : undefined}\n aria-label={`${messages.chooseView}: ${messages[view]}`}\n className={cx(className, styles.root)}\n onClick={() => (open ? close(false) : openList())}\n onKeyDown={handleToggleKeyDown}\n >\n {messages[view]}\n <ChevronIcon aria-hidden=\"true\" className={cx(styles.root__icon, { [styles.root__icon_open]: open })} />\n </button>\n\n {open && (\n <Portal>\n <div\n ref={refs.setFloating}\n id={listId}\n role=\"listbox\"\n aria-label={messages.chooseView}\n style={floatingStyles}\n className={styles.list}\n onKeyDown={handleListKeyDown}\n >\n {views.map((option) => (\n <div\n key={option}\n ref={(element) => {\n if (element) optionRefs.current.set(option, element);\n else optionRefs.current.delete(option);\n }}\n id={`${id}-${option}`}\n role=\"option\"\n tabIndex={-1}\n aria-selected={option === view}\n className={cx(styles.list__option, { [styles.list__option_active]: option === active })}\n onClick={() => select(option)}\n onPointerMove={() => setActive(option)}\n >\n {messages[option]}\n {option === view && (\n <svg aria-hidden=\"true\" className={styles.list__check} viewBox=\"0 0 16 16\" width=\"14\" height=\"14\">\n <path\n d=\"M3 8.5 6.5 12 13 4.5\"\n fill=\"none\"\n stroke=\"currentColor\"\n strokeWidth=\"2\"\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n </svg>\n )}\n </div>\n ))}\n </div>\n </Portal>\n )}\n </>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAqBA,SAAwBuB,EAAW,EAAEC,gBAA8B;CACjE,IAAM,EAAEC,SAAMC,UAAOC,kBAAeb,EAAmB,GACjDc,IAAWb,EAAY,GACvB,EAAEc,sBAAmBC,4BAAyBd,EAAmB,GACjEe,IAAKrB,EAAM,GAEX,CAACsB,GAAMC,KAAWrB,EAAS,EAAK,GA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AC9CnB,EAAW,QAAQ,OAAOkB,CAAM;GACvC;GACA,IAAI,GAAGvB,EAAG,GAAGuB;GACb,MAAK;GACL,UAAU;GACV,iBAAeA,MAAW7B;GAC1B,WAAWZ,EAAGX,EAAO,cAAc,GAAGA,EAAO,sBAAsBoD,MAAWpB,EAAO,CAAC;GACtF,eAAeU,EAAOU,CAAM;GAC5B,qBAAqBnB,EAAUmB,CAAM;GAZvC,UAAA,CAcG1B,EAAS0B,IACTA,MAAW7B,KACVtB,kBAAC,OAAD;IAAK,eAAY;IAAO,WAAWD,EAAO;IAAa,SAAQ;IAAY,OAAM;IAAK,QAAO;IAC3F,UAAAC,kBAAC,QAAD;KACE,GAAE;KACF,MAAK;KACL,QAAO;KACP,aAAY;KACZ,eAAc;KACd,gBAAe;IAChB,CAAA;GACE,CAAA,CAEJ;EA1BE,GAAAmD,CA0BF,CACN;CACE,CAAA,EACC,CAAA,CAEV,EAAA,CAAA;AAEN"}
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ // src/components/view-select/ViewSelect.module.css
3
+ var e = "_root_5dy7b_1", t = "_root__icon_5dy7b_27", n = "_root__icon_open_5dy7b_34", r = "_list_5dy7b_38", i = "_list__option_5dy7b_52", a = "_list__option_active_5dy7b_72", o = "_list__check_5dy7b_80", s = {
4
+ root: e,
5
+ root__icon: t,
6
+ root__icon_open: n,
7
+ list: r,
8
+ list__option: i,
9
+ list__option_active: a,
10
+ list__check: o
11
+ };
12
+ export { s as default, r as list, o as list__check, i as list__option, a as list__option_active, e as root, t as root__icon, n as root__icon_open };
13
+
14
+ //# sourceMappingURL=ViewSelect.module.css.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ViewSelect.module.css.js","names":["root","root__icon","root__icon_open","list","list__option","list__option_active","list__check","ViewSelect_module_default"],"sources":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { createContext as e, useContext as t } from "react";
3
+ import { isDevEnvironment as n } from "@weekwise/core";
4
+ // src/contexts/CalendarContext.ts
5
+ var r = e(void 0);
6
+ n && (r.displayName = "CalendarContext");
7
+ function i() {
8
+ let e = t(r);
9
+ if (!e) throw Error("CalendarContext is required");
10
+ return e;
11
+ }
12
+ export { r as default, i as useCalendarContext };
13
+
14
+ //# sourceMappingURL=CalendarContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CalendarContext.js","names":["createContext","useContext","isDevEnvironment","CalendarContext","useCalendarContext","context"],"sources":["../../src/contexts/CalendarContext.ts"],"sourcesContent":["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"],"mappings":";;;;AAQA,IAAMG,IAAkBH,EAAgD,KAAA,CAAS;AAE7EE,MACFC,EAAgB,cAAc;AAKhC,SAAgBC,IAAqB;CACnC,IAAMC,IAAUJ,EAAWE,CAAe;CAE1C,IAAI,CAACE,GACH,MAAU,MAAM,6BAA6B;CAG/C,OAAOA;AACT"}
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { createContext as e, useContext as t } from "react";
3
+ import { isDevEnvironment as n } from "@weekwise/core";
4
+ // src/contexts/CalendarViewportContext.ts
5
+ var r = e(void 0);
6
+ n && (r.displayName = "CalendarViewportContext");
7
+ function i() {
8
+ let e = t(r);
9
+ if (!e) throw Error("CalendarViewportContext is required");
10
+ return e;
11
+ }
12
+ export { r as default, i as useCalendarViewportContext };
13
+
14
+ //# sourceMappingURL=CalendarViewportContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CalendarViewportContext.js","names":["createContext","useContext","isDevEnvironment","CalendarViewportContext","useCalendarViewportContext","context"],"sources":["../../src/contexts/CalendarViewportContext.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/**\n * Provides the calendar viewport element used to portal\n * drag overlays and position absolute transforms relative to.\n */\nexport type CalendarViewportContextValue = {\n viewportRef: RefObject<HTMLDivElement | null>;\n};\n\nconst CalendarViewportContext = createContext<CalendarViewportContextValue | undefined>(undefined);\n\nif (isDevEnvironment) {\n CalendarViewportContext.displayName = \"CalendarViewportContext\";\n}\n\nexport default CalendarViewportContext;\n\nexport function useCalendarViewportContext() {\n const context = useContext(CalendarViewportContext);\n\n if (!context) {\n throw new Error(\"CalendarViewportContext is required\");\n }\n\n return context;\n}\n"],"mappings":";;;;AAaA,IAAMG,IAA0BH,EAAwD,KAAA,CAAS;AAE7FE,MACFC,EAAwB,cAAc;AAKxC,SAAgBC,IAA6B;CAC3C,IAAMC,IAAUJ,EAAWE,CAAuB;CAElD,IAAI,CAACE,GACH,MAAU,MAAM,qCAAqC;CAGvD,OAAOA;AACT"}
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { createContext as e, useContext as t } from "react";
3
+ import { isDevEnvironment as n } from "@weekwise/core";
4
+ // src/contexts/DayWeekDrawerContext.ts
5
+ var r = e(void 0);
6
+ n && (r.displayName = "DayWeekDrawerContext");
7
+ function i() {
8
+ let e = t(r);
9
+ if (!e) throw Error("DayWeekDrawerContext is required: render the event inside a DayWeekDrawer");
10
+ return e;
11
+ }
12
+ export { r as default, i as useDayWeekDrawerContext };
13
+
14
+ //# sourceMappingURL=DayWeekDrawerContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DayWeekDrawerContext.js","names":["createContext","useContext","isDevEnvironment","DayWeekDrawerContext","useDayWeekDrawerContext","context"],"sources":["../../src/contexts/DayWeekDrawerContext.ts"],"sourcesContent":["import { createContext, useContext } from \"react\";\nimport type { RefObject } from \"react\";\n\nimport { isDevEnvironment } from \"@weekwise/core\";\n\n/** The day column an event of the day/week view is drawn in. */\nexport type DayWeekDrawerContextValue = {\n /** The whole column: what an event resized in it is bounded by. */\n drawerRef: RefObject<HTMLDivElement | null>;\n /** The events' container, which their positions are relative to. */\n containerRef: RefObject<HTMLDivElement | null>;\n};\n\nconst DayWeekDrawerContext = createContext<DayWeekDrawerContextValue | undefined>(undefined);\n\nif (isDevEnvironment) {\n DayWeekDrawerContext.displayName = \"DayWeekDrawerContext\";\n}\n\nexport default DayWeekDrawerContext;\n\nexport function useDayWeekDrawerContext() {\n const context = useContext(DayWeekDrawerContext);\n\n if (!context) {\n throw new Error(\"DayWeekDrawerContext is required: render the event inside a DayWeekDrawer\");\n }\n\n return context;\n}\n"],"mappings":";;;;AAaA,IAAMG,IAAuBH,EAAqD,KAAA,CAAS;AAEvFE,MACFC,EAAqB,cAAc;AAKrC,SAAgBC,IAA0B;CACxC,IAAMC,IAAUJ,EAAWE,CAAoB;CAE/C,IAAI,CAACE,GACH,MAAU,MAAM,2EAA2E;CAG7F,OAAOA;AACT"}
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ import { createContext as e, useContext as t } from "react";
3
+ import { isDevEnvironment as n } from "@weekwise/core";
4
+ // src/contexts/DayWeekViewContext.ts
5
+ var r = e(void 0);
6
+ n && (r.displayName = "DayWeekViewContext");
7
+ function i() {
8
+ let e = t(r);
9
+ if (!e) throw Error("DayWeekViewContext is required");
10
+ return e;
11
+ }
12
+ export { r as default, i as useDayWeekViewContext };
13
+
14
+ //# sourceMappingURL=DayWeekViewContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DayWeekViewContext.js","names":["createContext","useContext","isDevEnvironment","DayWeekViewContext","useDayWeekViewContext","context"],"sources":["../../src/contexts/DayWeekViewContext.ts"],"sourcesContent":["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"],"mappings":";;;;AAQA,IAAMG,IAAqBH,EAAmD,KAAA,CAAS;AAEnFE,MACFC,EAAmB,cAAc;AAKnC,SAAgBC,IAAwB;CACtC,IAAMC,IAAUJ,EAAWE,CAAkB;CAE7C,IAAI,CAACE,GACH,MAAU,MAAM,gCAAgC;CAGlD,OAAOA;AACT"}
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { createContext as e } from "react";
3
+ import { isDevEnvironment as t } from "@weekwise/core";
4
+ // src/contexts/ThemeSourceContext.ts
5
+ var n = e(null);
6
+ t && (n.displayName = "ThemeSourceContext");
7
+ export { n as default };
8
+
9
+ //# sourceMappingURL=ThemeSourceContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ThemeSourceContext.js","names":["createContext","isDevEnvironment","ThemeSourceContext"],"sources":["../../src/contexts/ThemeSourceContext.ts"],"sourcesContent":["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"],"mappings":";;;;AAMA,IAAME,IAAqBF,EAAoD,IAAI;AAE/EC,MACFC,EAAmB,cAAc"}
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { createContext as e } from "react";
3
+ import { isDevEnvironment as t } from "@weekwise/core";
4
+ // src/date-localization/DateLocalizationContext.ts
5
+ var n = e(void 0);
6
+ t && (n.displayName = "DateLocalizationContext");
7
+ export { n as default };
8
+
9
+ //# sourceMappingURL=DateLocalizationContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateLocalizationContext.js","names":["createContext","isDevEnvironment","DateLocalizationContext"],"sources":["../../src/date-localization/DateLocalizationContext.ts"],"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"],"mappings":";;;;AASA,IAAME,IAA0BF,EAAqD,KAAA,CAAS;AAE1FC,MACFC,EAAwB,cAAc"}
@@ -0,0 +1,20 @@
1
+ "use client";
2
+ import { useMemo as e } from "react";
3
+ import { resolveMessages as t } from "@weekwise/core";
4
+ import n from "./DateLocalizationContext.js";
5
+ import r from "./MessagesContext.js";
6
+ import { jsx as i } from "react/jsx-runtime";
7
+ // src/date-localization/DateLocalizationProvider.tsx
8
+ function a(a) {
9
+ let { adapter: o, messages: s, children: c } = a, l = e(() => typeof o == "function" ? new o() : o, [o]), u = e(() => t(l.locale, s), [l.locale, s]);
10
+ return /* @__PURE__ */ i(n.Provider, {
11
+ value: l,
12
+ children: /* @__PURE__ */ i(r.Provider, {
13
+ value: u,
14
+ children: c
15
+ })
16
+ });
17
+ }
18
+ export { a as default };
19
+
20
+ //# sourceMappingURL=DateLocalizationProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DateLocalizationProvider.js","names":["_jsx","useMemo","resolveMessages","DateLocalizationContext","MessagesContext","jsx","DateLocalizationProvider","props","adapter","messages","children","dateUtils","resolvedMessages"],"sources":["../../src/date-localization/DateLocalizationProvider.tsx"],"sourcesContent":["import { useMemo, type PropsWithChildren } from \"react\";\n\nimport { resolveMessages } from \"@weekwise/core\";\nimport type { CalendarDate, CalendarMessages, DateAdapter } from \"@weekwise/core\";\n\nimport DateLocalizationContext from \"./DateLocalizationContext\";\nimport MessagesContext from \"./MessagesContext\";\n\nexport type DateLocalizationProviderProps<TDate = Date> = PropsWithChildren<{\n /**\n * Date adapter: an instance (`new DateFnsAdapter({ locale: ru })`) or a class\n * with a no-argument constructor (`DateFnsAdapter`). Its `locale` also selects\n * the interface language, so switching the adapter switches the whole calendar.\n * Its date type (`Date`, `Temporal.ZonedDateTime`…) is the one the calendar takes and gives.\n */\n adapter: DateAdapter<TDate> | (new () => DateAdapter<TDate>);\n /**\n * Interface strings on top of the built-in translation for the adapter's locale:\n * a few words to change, or every string for a language without a translation.\n */\n messages?: Partial<CalendarMessages>;\n}>;\n\nexport default function DateLocalizationProvider<TDate = Date>(props: DateLocalizationProviderProps<TDate>) {\n const { adapter, messages, children } = props;\n\n const dateUtils = useMemo<DateAdapter<TDate>>(\n () => (typeof adapter === \"function\" ? new adapter() : adapter),\n [adapter]\n );\n\n const resolvedMessages = useMemo(() => resolveMessages(dateUtils.locale, messages), [dateUtils.locale, messages]);\n\n return (\n <DateLocalizationContext.Provider value={dateUtils as unknown as DateAdapter<CalendarDate>}>\n <MessagesContext.Provider value={resolvedMessages}>{children}</MessagesContext.Provider>\n </DateLocalizationContext.Provider>\n );\n}\n"],"mappings":";;;;;;;AAuBA,SAAwBM,EAAuCC,GAA6C;CAC1G,IAAM,EAAEC,YAASC,aAAUC,gBAAaH,GAElCI,IAAYV,QACT,OAAOO,KAAY,aAAa,IAAIA,EAAQ,IAAIA,GACvD,CAACA,CAAO,CACV,GAEMI,IAAmBX,QAAcC,EAAgBS,EAAU,QAAQF,CAAQ,GAAG,CAACE,EAAU,QAAQF,CAAQ,CAAC;CAEhH,OACET,kBAACG,EAAwB,UAAzB;EAAkC,OAAOQ;EACvC,UAAAX,kBAACI,EAAgB,UAAjB;GAA0B,OAAOQ;GAAmBF;EAAmC,CAAA;CACvD,CAAA;AAEtC"}
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import { createContext as e } from "react";
3
+ import { isDevEnvironment as t } from "@weekwise/core";
4
+ // src/date-localization/MessagesContext.ts
5
+ var n = e(void 0);
6
+ t && (n.displayName = "MessagesContext");
7
+ export { n as default };
8
+
9
+ //# sourceMappingURL=MessagesContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessagesContext.js","names":["createContext","isDevEnvironment","MessagesContext"],"sources":["../../src/date-localization/MessagesContext.ts"],"sourcesContent":["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"],"mappings":";;;;AAOA,IAAME,IAAkBF,EAA4C,KAAA,CAAS;AAEzEC,MACFC,EAAgB,cAAc"}
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { useContext as e } from "react";
3
+ import t from "./DateLocalizationContext.js";
4
+ // src/date-localization/useDateUtils.ts
5
+ function n() {
6
+ let n = e(t);
7
+ if (!n) throw Error("DateLocalizationContext is required");
8
+ return n;
9
+ }
10
+ function r() {
11
+ return n();
12
+ }
13
+ export { n as default, r as useCalendarDateUtils };
14
+
15
+ //# sourceMappingURL=useDateUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDateUtils.js","names":["useContext","DateLocalizationContext","useDateUtils","context","useCalendarDateUtils"],"sources":["../../src/date-localization/useDateUtils.ts"],"sourcesContent":["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"],"mappings":";;;;AAUA,SAAwBE,IAAiD;CACvE,IAAMC,IAAUH,EAAWC,CAAuB;CAElD,IAAI,CAACE,GACH,MAAU,MAAM,qCAAqC;CAGvD,OAAOA;AACT;AAGA,SAAgBC,IAAkD;CAChE,OAAOF,EAA2B;AACpC"}
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { useContext as e } from "react";
3
+ import { resolveMessages as t } from "@weekwise/core";
4
+ import n from "./MessagesContext.js";
5
+ import r from "./useDateUtils.js";
6
+ // src/date-localization/useMessages.ts
7
+ function i() {
8
+ let i = e(n), a = r();
9
+ return i ?? t(a.locale);
10
+ }
11
+ export { i as default };
12
+
13
+ //# sourceMappingURL=useMessages.js.map