@weekwise/react 0.0.0-stage → 0.1.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 (96) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +227 -2
  3. package/dist/Calendar.d.ts +6 -0
  4. package/dist/Calendar.types.d.ts +118 -0
  5. package/dist/components/calendar-toolbar/CalendarToolbar.d.ts +3 -0
  6. package/dist/components/calendar-toolbar/index.d.ts +2 -0
  7. package/dist/components/date-navigator/DateNavigator.d.ts +7 -0
  8. package/dist/components/date-navigator/index.d.ts +2 -0
  9. package/dist/components/day-week-drawer/DayWeekDrawer.d.ts +9 -0
  10. package/dist/components/day-week-drawer/index.d.ts +2 -0
  11. package/dist/components/day-week-event/DayWeekEvent.d.ts +7 -0
  12. package/dist/components/day-week-event/DayWeekEventPreview.d.ts +11 -0
  13. package/dist/components/day-week-event/index.d.ts +3 -0
  14. package/dist/components/day-week-view/DayWeekView.d.ts +39 -0
  15. package/dist/components/day-week-view/HiddenEvents.d.ts +14 -0
  16. package/dist/components/day-week-view/index.d.ts +2 -0
  17. package/dist/components/day-week-view/useTimeColumnWidth.d.ts +9 -0
  18. package/dist/components/drag-overlay/DragOverlay.d.ts +9 -0
  19. package/dist/components/drag-overlay/index.d.ts +2 -0
  20. package/dist/components/index.d.ts +3 -0
  21. package/dist/components/month-view/MonthView.d.ts +7 -0
  22. package/dist/components/month-view/MonthView.utils.d.ts +12 -0
  23. package/dist/components/month-view/MonthViewDay.d.ts +12 -0
  24. package/dist/components/month-view/MonthViewEvent.d.ts +30 -0
  25. package/dist/components/month-view/MonthViewEventPreview.d.ts +9 -0
  26. package/dist/components/month-view/MonthViewWeek.d.ts +20 -0
  27. package/dist/components/month-view/index.d.ts +2 -0
  28. package/dist/components/month-view/useMonthLanes.d.ts +7 -0
  29. package/dist/components/month-view/useMonthResize.d.ts +32 -0
  30. package/dist/components/nav-btn/NavBtn.d.ts +5 -0
  31. package/dist/components/nav-btn/index.d.ts +2 -0
  32. package/dist/components/pointer-popover/PointerPopover.d.ts +6 -0
  33. package/dist/components/pointer-popover/index.d.ts +2 -0
  34. package/dist/components/view-select/ViewSelect.d.ts +8 -0
  35. package/dist/components/view-select/index.d.ts +2 -0
  36. package/dist/contexts/CalendarContext.d.ts +7 -0
  37. package/dist/contexts/CalendarViewportContext.d.ts +11 -0
  38. package/dist/contexts/DayWeekViewContext.d.ts +7 -0
  39. package/dist/contexts/ThemeSourceContext.d.ts +4 -0
  40. package/dist/date-localization/DateLocalizationContext.d.ts +6 -0
  41. package/dist/date-localization/DateLocalizationProvider.d.ts +17 -0
  42. package/dist/date-localization/MessagesContext.d.ts +4 -0
  43. package/dist/date-localization/index.d.ts +6 -0
  44. package/dist/date-localization/useDateUtils.d.ts +8 -0
  45. package/dist/date-localization/useMessages.d.ts +2 -0
  46. package/dist/hooks/index.d.ts +15 -0
  47. package/dist/hooks/useAbsEventRect.d.ts +3 -0
  48. package/dist/hooks/useAutoScroller.d.ts +33 -0
  49. package/dist/hooks/useCalendarSize.d.ts +7 -0
  50. package/dist/hooks/useCalendarValue.d.ts +7 -0
  51. package/dist/hooks/useCanResizeEvent.d.ts +3 -0
  52. package/dist/hooks/useComputed.d.ts +2 -0
  53. package/dist/hooks/useControlled.d.ts +36 -0
  54. package/dist/hooks/useControlled.types.d.ts +16 -0
  55. package/dist/hooks/useControlled.utils.d.ts +7 -0
  56. package/dist/hooks/useCurrentRef.d.ts +3 -0
  57. package/dist/hooks/useEventCallback.d.ts +1 -0
  58. package/dist/hooks/useEventCallback.types.d.ts +8 -0
  59. package/dist/hooks/useEventCallback.utils.d.ts +2 -0
  60. package/dist/hooks/useEventResize.d.ts +46 -0
  61. package/dist/hooks/useGlobalListeners.d.ts +9 -0
  62. package/dist/hooks/useInterval.d.ts +1 -0
  63. package/dist/hooks/useIsomorphicLayoutEffect.d.ts +7 -0
  64. package/dist/hooks/useMergedRefs.d.ts +3 -0
  65. package/dist/hooks/useMove.d.ts +5 -0
  66. package/dist/hooks/useMove.types.d.ts +56 -0
  67. package/dist/hooks/useMoveTransform.d.ts +72 -0
  68. package/dist/hooks/useMutationObserver.d.ts +5 -0
  69. package/dist/hooks/useNavigation.d.ts +6 -0
  70. package/dist/hooks/usePrevious.d.ts +2 -0
  71. package/dist/hooks/useRect.d.ts +2 -0
  72. package/dist/hooks/useRefWithInit.d.ts +13 -0
  73. package/dist/hooks/useResizeObserver.d.ts +5 -0
  74. package/dist/hooks/useScrollBarSize.d.ts +2 -0
  75. package/dist/hooks/useScrollBarSize.types.d.ts +6 -0
  76. package/dist/hooks/useScrollIntent.d.ts +14 -0
  77. package/dist/hooks/useScrollOffsets.d.ts +2 -0
  78. package/dist/hooks/useScrollOffsetsDelta.d.ts +3 -0
  79. package/dist/hooks/useScrollableAncestors.d.ts +1 -0
  80. package/dist/hooks/useScrollableAncestorsRects.d.ts +3 -0
  81. package/dist/hooks/useStateRef.d.ts +8 -0
  82. package/dist/hooks/useTimeInterval.d.ts +1 -0
  83. package/dist/hooks/useTimeOffset.d.ts +1 -0
  84. package/dist/hooks/useToday.d.ts +6 -0
  85. package/dist/icons/chevron.d.ts +2 -0
  86. package/dist/index.cjs +13 -0
  87. package/dist/index.cjs.map +1 -0
  88. package/dist/index.d.ts +7 -0
  89. package/dist/index.js +2633 -0
  90. package/dist/index.js.map +1 -0
  91. package/dist/portal/Portal.d.ts +16 -0
  92. package/dist/portal/index.d.ts +2 -0
  93. package/dist/style.css +2 -0
  94. package/dist/utils/css.d.ts +3 -0
  95. package/dist/utils/mergeRefs.d.ts +2 -0
  96. package/package.json +89 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 weekwise contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,228 @@
1
- # Temporary Holding Version
1
+ # @weekwise/react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ 📖 **[Documentation and live examples](https://weekwise.dev/reference/react/)** on [weekwise.dev](https://weekwise.dev)
4
+
5
+ Day, week and month calendar for React with drag-and-drop event management.
6
+
7
+ ## Features
8
+
9
+ - **Day / Week / Month views** with a toolbar for navigation and view switching
10
+ - **Drag and drop** events between days with auto-scroll
11
+ - **Resize events** to change their duration, into other days too: dragging the bottom edge
12
+ into a later day makes the event run until then, like in macOS Calendar
13
+ - **Events across midnight** are drawn in every day they cover
14
+ - **Click and drag on the timeline** to create new events
15
+ - **Date navigator popover** for jumping to a specific day/week (built with floating-ui)
16
+ - **Pluggable date library**: the calendar talks to dates only through an adapter
17
+ - **React 18+** support, written in TypeScript
18
+
19
+ ## Installation
20
+
21
+ The calendar needs a date adapter. The official one is built on date-fns:
22
+
23
+ ```bash
24
+ npm install @weekwise/react @weekwise/adapter-date-fns date-fns
25
+ ```
26
+
27
+ Import the stylesheet in your app:
28
+
29
+ ```tsx
30
+ import "@weekwise/react/styles.css";
31
+ ```
32
+
33
+ ## Usage
34
+
35
+ Wrap your app (or the calendar) in a `DateLocalizationProvider` and give it an adapter:
36
+
37
+ ```tsx
38
+ import { useState } from "react";
39
+ import Calendar, { DateLocalizationProvider } from "@weekwise/react";
40
+ import { DateFnsAdapter } from "@weekwise/adapter-date-fns";
41
+ import "@weekwise/react/styles.css";
42
+
43
+ type Event = {
44
+ id: string;
45
+ title: string;
46
+ start: Date;
47
+ end: Date;
48
+ };
49
+
50
+ const events: Event[] = [
51
+ {
52
+ id: "1",
53
+ title: "Standup",
54
+ start: new Date(2024, 4, 13, 9, 0),
55
+ end: new Date(2024, 4, 13, 9, 30),
56
+ },
57
+ ];
58
+
59
+ function App() {
60
+ const [items, setItems] = useState(events);
61
+
62
+ return (
63
+ <DateLocalizationProvider adapter={DateFnsAdapter}>
64
+ <Calendar
65
+ items={items}
66
+ eventTimeFrameResolver={(event) => ({ start: event.start, end: event.end })}
67
+ eventKeyResolver={(event) => event.id}
68
+ onEventChange={(event, start, end) => {
69
+ setItems((prev) =>
70
+ prev.map((item) =>
71
+ item.id === event.id ? { ...item, start, end } : item
72
+ )
73
+ );
74
+ }}
75
+ >
76
+ {(event) => <div>{event.title}</div>}
77
+ </Calendar>
78
+ </DateLocalizationProvider>
79
+ );
80
+ }
81
+ ```
82
+
83
+ `adapter` accepts either a class (`DateFnsAdapter`) or a ready instance
84
+ (`new DateFnsAdapter({ locale: fr })`). Create the instance outside the component, or memoize it,
85
+ so the context value stays stable.
86
+
87
+ ## Localization
88
+
89
+ One setting localizes everything: the adapter's locale. It drives month and weekday names,
90
+ date/time formats, the first day of the week and the interface text (buttons, labels).
91
+ The visible words ("Today", "Day", "Week", "Month") come from the browser's `Intl` data,
92
+ so every locale gets them. The screen-reader labels of the navigation buttons and the "+3 more"
93
+ label have built-in translations for English, Russian, Ukrainian, German, French, Spanish,
94
+ Portuguese, Italian, Dutch, Polish, Turkish, Chinese, Japanese and Korean; other languages get `Intl` wording for the month arrows and "+3", and English for
95
+ the rest.
96
+
97
+ ```tsx
98
+ import { de } from "date-fns/locale/de";
99
+ import { enUS } from "date-fns/locale/en-US";
100
+ import { ru } from "date-fns/locale/ru";
101
+
102
+ const adapters = {
103
+ en: new DateFnsAdapter({ locale: enUS }),
104
+ ru: new DateFnsAdapter({ locale: ru }),
105
+ de: new DateFnsAdapter({ locale: de }),
106
+ };
107
+
108
+ function App() {
109
+ const [language, setLanguage] = useState<keyof typeof adapters>("ru");
110
+ return (
111
+ <DateLocalizationProvider adapter={adapters[language]}>
112
+ <Calendar>{…}</Calendar>
113
+ </DateLocalizationProvider>
114
+ );
115
+ }
116
+ ```
117
+
118
+ Switching the adapter re-renders the calendar in the new language and keeps the visible
119
+ period (the week is re-aligned if the new locale starts it on another day).
120
+
121
+ Change single strings, or polish a language without a built-in translation, with `messages`:
122
+
123
+ ```tsx
124
+ <DateLocalizationProvider adapter={ptAdapter} messages={{
125
+ today: "Hoje", day: "Dia", week: "Semana", month: "Mês",
126
+ previous: "Anterior", next: "Próximo", chooseDate: "Escolher data",
127
+ previousMonth: "Mês anterior", nextMonth: "Próximo mês", chooseView: "Visualização",
128
+ more: (count) => `+${count} mais`,
129
+ earlier: (count) => `Eventos anteriores: ${count}`,
130
+ later: (count) => `Eventos posteriores: ${count}`,
131
+ }}>
132
+ ```
133
+
134
+ `useMessages()` returns the resolved strings for your own components, e.g. an event editor.
135
+ The hour column is 64px wide, enough for 12-hour locales (`en-US`, `zh-CN`); change it with `--ww-time-column`.
136
+ Colors, the surface around the card and the "now" line use the same `--ww-*` theme variables as
137
+ `@weekwise/dom` (listed in its README). Event content is yours: style it in the render function.
138
+ The part of an event that continues from or into another day has `data-continues-before` /
139
+ `data-continues-after` on its element, e.g. to square its corners there.
140
+
141
+ ## Props
142
+
143
+ | Prop | Type | Description |
144
+ | --------------------------- | --------------------------------------------- | ------------------------------------------------------------------ |
145
+ | `view` | `"day" \| "week" \| "month"` | Controlled current view. |
146
+ | `defaultView` | `"day" \| "week" \| "month"` | Initial view (defaults to `"week"`). |
147
+ | `viewValue` | `Date` | Controlled visible date. |
148
+ | `defaultViewValue` | `Date` | Initial visible date (defaults to today). |
149
+ | `startWeek` | `0 \| 1 \| ... \| 6` | First day of the week (defaults to the adapter's locale). |
150
+ | `timeStep` | `number` | Minutes per timeline step (defaults to `15`). |
151
+ | `timeFrame` | `{ hourMin?: number; hourMax?: number }` | Visible hour range. When set, changes are constrained to the range. |
152
+ | `hideMinMaxTime` | `boolean` | Hides time outside the `timeFrame`. |
153
+ | `items` | `TValue[]` | Event data. |
154
+ | `eventTimeFrameResolver` | `(item) => { start: Date; end: Date }` | Resolves an item to its time span. |
155
+ | `eventKeyResolver` | `(item) => string \| number` | Resolves an item to a unique key. |
156
+ | `disabled` | `boolean` | Disables interactions. |
157
+ | `scrollable` | `boolean` | Makes the timeline scrollable. |
158
+ | `getIsDayDisabled` | `(date: Date) => boolean` | Disables a day for event creation/drop. |
159
+ | `onEventChange` | `(item, start, end) => void` | Called when an event is moved or resized. |
160
+ | `onEventCreate` | `(start, end) => void` | Called when a new event is created on the timeline. |
161
+ | `onEventDelete` | `(item) => void` | Called when an event is deleted. |
162
+ | `onEventEdit` | `(item) => void` | Called when an event is edited. |
163
+ | `onChangeView` | `(view) => void` | Called when the view changes. |
164
+ | `onChangeViewValue` | `(viewValue, currentView) => void` | Called when the visible date changes. |
165
+ | `pointerPreviewFormat` | `(from, to) => ReactNode` | Customizes the drag/resize preview label. |
166
+ | `children` | `(item, view, part) => ReactNode` | Renders an event item. `part` (`{ isStart, isEnd }`) says whether the card continues from / into another day, to flatten its edges there. |
167
+
168
+ Any other props are spread onto the root `div`.
169
+
170
+ ## Next.js
171
+
172
+ Works with the App Router (tested with Next.js 16 and React 19, including static
173
+ prerendering). The package ships with a `"use client"` directive.
174
+
175
+ Render the calendar from a **Client Component**: its `children` is a render
176
+ function and the `adapter` is a class, and neither can be passed from a Server
177
+ Component.
178
+
179
+ ```tsx
180
+ // app/schedule/Schedule.tsx
181
+ "use client";
182
+
183
+ import Calendar, { DateLocalizationProvider } from "@weekwise/react";
184
+ import { DateFnsAdapter } from "@weekwise/adapter-date-fns";
185
+
186
+ export default function Schedule() {
187
+ return (
188
+ <DateLocalizationProvider adapter={DateFnsAdapter}>
189
+ <Calendar>{(event) => <div>{event.title}</div>}</Calendar>
190
+ </DateLocalizationProvider>
191
+ );
192
+ }
193
+ ```
194
+
195
+ ```tsx
196
+ // app/schedule/page.tsx (a Server Component)
197
+ import Schedule from "./Schedule";
198
+ import "@weekwise/react/styles.css";
199
+
200
+ export default function Page() {
201
+ return <Schedule />;
202
+ }
203
+ ```
204
+
205
+ The calendar renders on the server and hydrates without mismatches: browser-only
206
+ parts (drag and drop, popovers, the "now" line) appear after hydration.
207
+
208
+ Note that a statically prerendered page is rendered at build time, when "today"
209
+ may be a different day than when it is viewed. If you show the current week
210
+ without a fixed `viewValue`, render the page dynamically
211
+ (`export const dynamic = "force-dynamic"`) so the server and the browser agree
212
+ on the date.
213
+
214
+ ## Custom date library
215
+
216
+ Any object implementing the `DateAdapter` interface from `@weekwise/core` works as
217
+ an adapter. Adapters for date-fns, Day.js, Luxon and Temporal are ready; see
218
+ [`@weekwise/core`](../core/README.md) to write your own.
219
+
220
+ The calendar's date type follows the adapter: with `@weekwise/adapter-temporal`, `viewValue`,
221
+ `eventTimeFrameResolver`, `onEventChange` and the other date props are
222
+ `Temporal.ZonedDateTime`s. TypeScript infers it from the props; give it explicitly when it
223
+ cannot: `<Calendar<Meeting, Temporal.ZonedDateTime> …>`. Read the adapter in your own
224
+ components with `useDateUtils<Temporal.ZonedDateTime>()`.
225
+
226
+ ## License
227
+
228
+ MIT
@@ -0,0 +1,6 @@
1
+ import type { CalendarProps } from "./Calendar.types";
2
+ /**
3
+ * The calendar. Dates in its props and callbacks are of the adapter's type (`TDate`); inside,
4
+ * they are opaque {@link CalendarDate}s that only the adapter reads or changes.
5
+ */
6
+ export default function Calendar<TValue, TDate = Date>(publicProps: CalendarProps<TValue, TDate>): import("react").JSX.Element;
@@ -0,0 +1,118 @@
1
+ import type { HTMLAttributes, ReactNode, RefAttributes, RefObject } from "react";
2
+ import type { CalendarDate, CalendarSize, CalendarView, DateUtils, EventChangeInfo, EventKey, EventMap, WeekDay } from "@weekwise/core";
3
+ import type { EventResizeActions, ResizeState } from "./hooks/useEventResize";
4
+ export type { CalendarView, EventChangeInfo, EventData, EventKey, EventMap } from "@weekwise/core";
5
+ /**
6
+ * Which part of an event a card shows. An event across midnight is drawn as one card per
7
+ * day (one bar per week in the month view): `isStart` is false on the parts that continue
8
+ * from an earlier one, `isEnd` on the parts that continue into a later one. Use it to
9
+ * flatten the card's edges there.
10
+ */
11
+ export type EventPart = {
12
+ isStart: boolean;
13
+ isEnd: boolean;
14
+ };
15
+ export type EventRenderer<TValue> = (data: TValue, view: CalendarView, part: EventPart) => ReactNode;
16
+ type PointerPreviewRenderer = (date: CalendarDate, start: number, duration: number) => ReactNode;
17
+ /**
18
+ * Props of {@link Calendar}. `TDate` is the date type of the adapter given to
19
+ * `DateLocalizationProvider`: `Date` for the date-fns, Day.js and Luxon adapters,
20
+ * `Temporal.ZonedDateTime` for the Temporal one. It is inferred from the props
21
+ * (`viewValue`, `eventTimeFrameResolver`…) or can be given: `<Calendar<Event, Temporal.ZonedDateTime>>`.
22
+ */
23
+ export type CalendarProps<TValue, TDate = Date> = Omit<HTMLAttributes<HTMLDivElement>, "children"> & RefAttributes<HTMLDivElement> & {
24
+ disabled?: boolean;
25
+ hideMinMaxTime?: boolean;
26
+ timeFrame?: {
27
+ hourMin?: number;
28
+ hourMax?: number;
29
+ };
30
+ defaultView?: CalendarView;
31
+ view?: CalendarView;
32
+ viewValue?: TDate;
33
+ defaultViewValue?: TDate;
34
+ /** First day of the week. Defaults to the date adapter's locale (`weekStartsOn`). */
35
+ startWeek?: WeekDay;
36
+ timeStep?: number;
37
+ items?: TValue[];
38
+ scrollable?: boolean;
39
+ getIsDayDisabled?: (date: TDate) => boolean;
40
+ eventTimeFrameResolver?: (item: TValue) => {
41
+ start: TDate;
42
+ end: TDate;
43
+ };
44
+ eventKeyResolver?: (item: TValue) => EventKey;
45
+ onEventChange?: (item: TValue, start: TDate, end: TDate) => void;
46
+ onEventCreate?: (start: TDate, end: TDate) => void;
47
+ onEventDelete?: (item: TValue) => void;
48
+ onEventEdit?: (item: TValue) => void;
49
+ children: EventRenderer<TValue>;
50
+ pointerPreviewFormat?: (from: TDate, to: TDate) => ReactNode;
51
+ onChangeView?: (view: CalendarView) => void;
52
+ onChangeViewValue?: (viewValue: TDate, currentView: CalendarView) => void;
53
+ };
54
+ export type CalendarState<TValue> = {
55
+ rootProps: HTMLAttributes<HTMLDivElement>;
56
+ disabled: boolean;
57
+ view: CalendarView;
58
+ timeStep: number;
59
+ hideMinMaxTime: boolean;
60
+ scrollable: boolean;
61
+ /** Layout for the width of the calendar's container. */
62
+ size: CalendarSize;
63
+ startWeek: WeekDay;
64
+ viewValue: CalendarDate;
65
+ changeViewValue: (newValue: CalendarDate, currentView: CalendarView) => void;
66
+ changeView: (newView: CalendarView) => void;
67
+ goBackward: () => void;
68
+ goForward: () => void;
69
+ goToday: () => void;
70
+ hourMin: number;
71
+ hourMax: number;
72
+ eventMap: EventMap<TValue, CalendarDate>;
73
+ preventOutBoundsChanges: boolean;
74
+ onEventCreate: (date: CalendarDate, info: EventChangeInfo) => void;
75
+ onEventChange: (key: EventKey, date: CalendarDate, info: EventChangeInfo) => void;
76
+ onEventEdit: (key: EventKey) => void;
77
+ onEventDelete: (key: EventKey) => void;
78
+ eventRenderer: RefObject<EventRenderer<TValue>>;
79
+ getIsDayDisabled?: (date: CalendarDate) => boolean;
80
+ pointerPreviewRenderer: RefObject<PointerPreviewRenderer>;
81
+ };
82
+ export type DayWeekViewContextValue = {
83
+ viewportRef: RefObject<HTMLDivElement | null>;
84
+ /**
85
+ * Calculate available range in minutes for the given date.
86
+ * By default it returns hourMins and hourMaxs in minutes.
87
+ * If the given date is today bottom edge is current time.
88
+ * If hideMinMaxTime is true bottom edge will be zero and
89
+ * top edge will be difference between hourMax and hourMin
90
+ * in minutes.
91
+ */
92
+ getTimeFrame: (date: CalendarDate) => [number, number];
93
+ /** Resizes events by their edges, into other days too. */
94
+ resize: EventResizeActions;
95
+ /** The event being resized, if any. */
96
+ resizing: ResizeState | null;
97
+ };
98
+ export type CalendarContextValue<TValue = unknown> = Pick<CalendarState<TValue>, "disabled" | "eventMap" | "viewValue" | "changeViewValue" | "view" | "hourMin" | "hourMax" | "goBackward" | "goForward" | "goToday" | "changeView" | "timeStep" | "scrollable" | "size" | "startWeek" | "onEventCreate" | "onEventChange" | "onEventDelete" | "onEventEdit" | "eventRenderer" | "hideMinMaxTime" | "preventOutBoundsChanges" | "getIsDayDisabled" | "pointerPreviewRenderer">;
99
+ export type CalendarContextValues = {
100
+ calendarContextValue: CalendarContextValue;
101
+ };
102
+ export interface UseCalendarValueParams<TDate = CalendarDate> {
103
+ view?: CalendarView;
104
+ defaultView?: CalendarView;
105
+ viewValue?: TDate;
106
+ defaultViewValue?: TDate;
107
+ dateUtils: DateUtils<TDate>;
108
+ startWeek: WeekDay;
109
+ onChangeView?: (view: CalendarView) => void;
110
+ onChangeViewValue?: (viewValue: TDate, view: CalendarView) => void;
111
+ }
112
+ export interface UseNavigationParams<TDate = CalendarDate> {
113
+ view: CalendarView;
114
+ dateUtils: DateUtils<TDate>;
115
+ viewValue: TDate;
116
+ startWeek: WeekDay;
117
+ changeViewValue: (newValue: TDate, currentView: CalendarView) => void;
118
+ }
@@ -0,0 +1,3 @@
1
+ import type { HTMLAttributes } from "react";
2
+ export type CalendarToolbarProps = HTMLAttributes<HTMLDivElement>;
3
+ export default function CalendarToolbar(props: CalendarToolbarProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from "./CalendarToolbar";
2
+ export type { CalendarToolbarProps } from "./CalendarToolbar";
@@ -0,0 +1,7 @@
1
+ import type { CalendarDate } from "@weekwise/core";
2
+ import type { ButtonHTMLAttributes, ReactNode } from "react";
3
+ import type { CalendarView } from "../../Calendar.types";
4
+ export type DateNavigatorProps = ButtonHTMLAttributes<HTMLButtonElement> & {
5
+ renderHeading?: (date: CalendarDate, view: CalendarView) => ReactNode;
6
+ };
7
+ export default function DateNavigator({ renderHeading, type, onClick, onKeyDown, className, ...buttonProps }: DateNavigatorProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from "./DateNavigator";
2
+ export type { DateNavigatorProps } from "./DateNavigator";
@@ -0,0 +1,9 @@
1
+ import type { DetailedHTMLProps, HTMLAttributes } from "react";
2
+ import type { CalendarDate } from "@weekwise/core";
3
+ export type DayWeekDrawerProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
4
+ /**
5
+ * Associated to the drawer date
6
+ */
7
+ targetDate: CalendarDate;
8
+ };
9
+ export default function DayWeekDrawer(props: DayWeekDrawerProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from "./DayWeekDrawer";
2
+ export type { DayWeekDrawerProps } from "./DayWeekDrawer";
@@ -0,0 +1,7 @@
1
+ import type { DetailedHTMLProps, HTMLAttributes } from "react";
2
+ import type { MeasuredEventData } from "../day-week-view";
3
+ export type DayWeekEventProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
4
+ eventData: MeasuredEventData;
5
+ };
6
+ export type DayWeekEventTransformContext = "bottom" | "top" | "overlay";
7
+ export default function DayWeekEvent(props: DayWeekEventProps): import("react").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import type { ReactNode } from "react";
2
+ import type { EventSegment } from "@weekwise/core";
3
+ export type DayWeekEventPreviewProps = {
4
+ /** The day's part of the event's new range. */
5
+ part: EventSegment;
6
+ /** Length of the timeline in minutes: the part is placed in percent of it. */
7
+ timelineMinutes: number;
8
+ children?: ReactNode;
9
+ };
10
+ /** An event while it is resized: one per day its new range covers, across the full width. */
11
+ export default function DayWeekEventPreview({ part, timelineMinutes, children }: DayWeekEventPreviewProps): import("react").JSX.Element;
@@ -0,0 +1,3 @@
1
+ export { default } from "./DayWeekEvent";
2
+ export type { DayWeekEventProps, DayWeekEventTransformContext } from "./DayWeekEvent";
3
+ export { default as DayWeekEventPreview } from "./DayWeekEventPreview";
@@ -0,0 +1,39 @@
1
+ import type { CalendarDate } from "@weekwise/core";
2
+ import type { HTMLAttributes } from "react";
3
+ import type { EventData } from "../../Calendar.types";
4
+ import { type MeasuredEventData as CoreMeasuredEventData, type TimeRowData } from "@weekwise/core";
5
+ export type DayWeekViewProps = HTMLAttributes<HTMLDivElement> & {
6
+ /** Height of an hour, in pixels. Defaults to the one of the calendar's size. */
7
+ rowHeight?: number;
8
+ };
9
+ export interface DayWeekHeaderCellData {
10
+ day: number;
11
+ events: MeasuredEventData[];
12
+ weekDayName: string;
13
+ weekDayNumber: number;
14
+ isToday: boolean;
15
+ attributes?: Record<string, string | number | boolean>;
16
+ targetDate: CalendarDate;
17
+ }
18
+ /** A laid-out event in a day column; its dates are the adapter's, only the adapter reads them. */
19
+ export type MeasuredEventData = CoreMeasuredEventData<unknown, CalendarDate>;
20
+ /**
21
+ * What a day/week event carries while dragged. Dragged items travel as JSON, so the date
22
+ * is a timestamp: not every date type survives JSON.
23
+ */
24
+ export type DayWeekDragItem = Omit<MeasuredEventData, "rect" | "date"> & {
25
+ date: number;
26
+ };
27
+ export type { TimeRowData };
28
+ export interface EventGroup {
29
+ date: CalendarDate;
30
+ events: EventData[];
31
+ }
32
+ export interface EventArrangedGroup {
33
+ date: CalendarDate;
34
+ events: MeasuredEventData[];
35
+ }
36
+ export interface DayWeekViewDropTargetData {
37
+ date: CalendarDate;
38
+ }
39
+ export default function DayWeekView({ rowHeight: rowHeightProp, ...props }: DayWeekViewProps): import("react").JSX.Element;
@@ -0,0 +1,14 @@
1
+ import { type RefObject } from "react";
2
+ import type { MeasuredEventData } from "./DayWeekView";
3
+ export type HiddenEventsProps = {
4
+ /** The scrolled timeline. */
5
+ scrollerRef: RefObject<HTMLDivElement | null>;
6
+ /** Events of each day column. */
7
+ columns: readonly MeasuredEventData[][];
8
+ rowHeight: number;
9
+ };
10
+ /**
11
+ * Buttons at the top and bottom of each day column of a scrolled timeline, to the events
12
+ * above or below what is in view.
13
+ */
14
+ export default function HiddenEvents({ scrollerRef, columns, rowHeight }: HiddenEventsProps): import("react").JSX.Element | null;
@@ -0,0 +1,2 @@
1
+ export { default } from "./DayWeekView";
2
+ export type { DayWeekViewProps, DayWeekHeaderCellData, TimeRowData, EventGroup, EventArrangedGroup, MeasuredEventData, DayWeekViewDropTargetData, DayWeekDragItem, } from "./DayWeekView";
@@ -0,0 +1,9 @@
1
+ import { type RefObject } from "react";
2
+ /**
3
+ * Width the time column needs for its labels ("10:00 PM", "下午10:00"…) on one line, or
4
+ * `undefined` while the theme's `--ww-time-column` holds them. Measured again when the
5
+ * labels change and once the fonts have loaded.
6
+ */
7
+ export default function useTimeColumnWidth(viewportRef: RefObject<HTMLElement | null>, labels: readonly string[],
8
+ /** Width of the time column when `--ww-time-column` is not set. */
9
+ defaultWidth: number): number | undefined;
@@ -0,0 +1,9 @@
1
+ import type { HTMLAttributes } from "react";
2
+ export type DragOverlayProps = HTMLAttributes<HTMLDivElement> & {
3
+ /**
4
+ * Whether to render the pointer time preview popover while dragging.
5
+ * Disabled in views where the overlay transform does not map to minutes.
6
+ */
7
+ showPreview?: boolean;
8
+ };
9
+ export default function DragOverlay({ showPreview, ...props }: DragOverlayProps): import("react").JSX.Element | null;
@@ -0,0 +1,2 @@
1
+ export { default } from "./DragOverlay";
2
+ export type { DragOverlayProps } from "./DragOverlay";
@@ -0,0 +1,3 @@
1
+ export { default as CalendarToolbar } from "./calendar-toolbar";
2
+ export { default as MonthView } from "./month-view";
3
+ export { default as DayWeekView } from "./day-week-view";
@@ -0,0 +1,7 @@
1
+ import type { HTMLAttributes } from "react";
2
+ export type MonthViewProps = HTMLAttributes<HTMLDivElement>;
3
+ /**
4
+ * Month grid: 6 weeks of day cells. An event is one bar across the days it covers in a
5
+ * week; the bar's edges stretch it into other days.
6
+ */
7
+ export default function MonthView(props: MonthViewProps): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import type { CalendarDate } from "@weekwise/core";
2
+ import type { CSSProperties } from "react";
3
+ /** Lanes of events under the day numbers; more events collapse into "+N more". */
4
+ export declare const MAX_LANES = 3;
5
+ type CSSVariables = Record<`--${string}`, number>;
6
+ /** Inline style of CSS custom properties, which place cells and bars in the week grid. */
7
+ export declare function cssVariables(variables: CSSVariables, style?: CSSProperties): CSSProperties;
8
+ /** Splits the month grid's days into weeks of 7. */
9
+ export declare function splitIntoWeeks(days: CalendarDate[]): CalendarDate[][];
10
+ /** Index (`data-day-index`) of the day cell in `container` under the point, or of the nearest one; -1 without cells. */
11
+ export declare function getNearestDayIndex(container: HTMLElement | null, x: number, y: number): number;
12
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { CalendarDate } from "@weekwise/core";
2
+ import type { DetailedHTMLProps, HTMLAttributes } from "react";
3
+ export type MonthViewDayProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
4
+ /**
5
+ * Date associated to the day cell
6
+ */
7
+ targetDate: CalendarDate;
8
+ };
9
+ export interface MonthViewDropTargetData {
10
+ date: CalendarDate;
11
+ }
12
+ export default function MonthViewDay(props: MonthViewDayProps): import("react").JSX.Element;
@@ -0,0 +1,30 @@
1
+ import type { CalendarDate } from "@weekwise/core";
2
+ import type { DetailedHTMLProps, HTMLAttributes } from "react";
3
+ import { type MonthBar } from "@weekwise/core";
4
+ import type { EventData } from "../../Calendar.types";
5
+ import type { MonthResizeActions } from "./useMonthResize";
6
+ export type MonthViewEventProps = DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement> & {
7
+ /** The event's bar in this week: its days and lane. */
8
+ eventData: MonthBar<unknown, CalendarDate>;
9
+ /** The days of the week row the bar is in. */
10
+ weekDays: CalendarDate[];
11
+ /** Whether the bar's edges stretch the event into other days. */
12
+ resizable?: boolean;
13
+ /** Resizing by the bar's edges, run by the view. */
14
+ resize?: MonthResizeActions;
15
+ /** The bar before the resize: hidden while the view shows the new range. */
16
+ isResizeSource?: boolean;
17
+ /** Some event is being resized: no bar is draggable meanwhile. */
18
+ isAnyResizing?: boolean;
19
+ };
20
+ /**
21
+ * What a month event carries while dragged: the event and the day it was grabbed by.
22
+ * Dragged items travel as JSON, so dates are timestamps: not every date type survives JSON.
23
+ */
24
+ export interface MonthViewDragItem extends Omit<EventData<unknown, CalendarDate>, "date"> {
25
+ /** Time stamp of the event's start. */
26
+ date: number;
27
+ /** Time stamp of the day cell the event was grabbed in. */
28
+ day?: number;
29
+ }
30
+ export default function MonthViewEvent(props: MonthViewEventProps): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import type { ReactNode } from "react";
2
+ import { type CalendarDate, type MonthBar } from "@weekwise/core";
3
+ export type MonthViewEventPreviewProps = {
4
+ /** A bar of the event's new range. */
5
+ bar: MonthBar<unknown, CalendarDate>;
6
+ children?: ReactNode;
7
+ };
8
+ /** An event while it is resized: one bar per week its new range covers. */
9
+ export default function MonthViewEventPreview({ bar, children }: MonthViewEventPreviewProps): import("react").JSX.Element;
@@ -0,0 +1,20 @@
1
+ import type { EventKey, MonthBar, MonthWeekLayout, CalendarDate } from "@weekwise/core";
2
+ import type { MonthResizeActions } from "./useMonthResize";
3
+ export interface MonthViewWeekProps {
4
+ days: CalendarDate[];
5
+ /** Index of the week's first day in the month grid. */
6
+ firstDayIndex: number;
7
+ /** Bars to draw: with the resized event's new range while it changes. */
8
+ layout: MonthWeekLayout<unknown, CalendarDate>;
9
+ /**
10
+ * The resized event's bars before the change. They stay mounted, hidden, while the
11
+ * preview shows the new range: their edge handles the pointer until it is released.
12
+ */
13
+ sourceBars: MonthBar<unknown, CalendarDate>[];
14
+ /** Lanes of bars that fit into the row; the "+N more" labels go below them. */
15
+ lanes: number;
16
+ resizingKey?: EventKey;
17
+ resize: MonthResizeActions;
18
+ }
19
+ /** One week row: day cells, the bars of the events over them and "+N more" labels. */
20
+ export default function MonthViewWeek(props: MonthViewWeekProps): import("react").JSX.Element;
@@ -0,0 +1,2 @@
1
+ export { default } from "./MonthView";
2
+ export type { MonthViewProps } from "./MonthView";
@@ -0,0 +1,7 @@
1
+ import { type RefObject } from "react";
2
+ /**
3
+ * Number of event lanes that fit into the month's week rows, at most `maxLanes`. Rows share
4
+ * the grid's height, so a short calendar shows fewer lanes and more "+N more" instead of
5
+ * cutting events off. `maxLanes` until the rows are measured.
6
+ */
7
+ export default function useMonthLanes(viewportRef: RefObject<HTMLElement | null>, maxLanes: number): number;