@dayflow/core 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.ja.md +9 -345
- package/README.md +7 -347
- package/README.zh.md +9 -345
- package/dist/components/calendarEvent/components/AllDayContent.d.ts +9 -0
- package/dist/components/calendarEvent/components/MonthAllDayContent.d.ts +8 -0
- package/dist/components/calendarEvent/components/MonthRegularContent.d.ts +11 -0
- package/dist/components/calendarEvent/components/RegularEventContent.d.ts +20 -0
- package/dist/components/calendarEvent/index.d.ts +4 -0
- package/dist/components/calendarEvent/types.d.ts +49 -0
- package/dist/components/dayView/DayContent.d.ts +55 -0
- package/dist/components/dayView/RightPanel.d.ts +16 -0
- package/dist/components/dayView/util.d.ts +8 -0
- package/dist/components/eventLayout/constants.d.ts +8 -0
- package/dist/components/eventLayout/index.d.ts +129 -0
- package/dist/components/eventLayout/types.d.ts +23 -0
- package/dist/components/eventLayout/utils.d.ts +5 -0
- package/dist/components/rangePicker/components/CalendarGrid.d.ts +13 -0
- package/dist/components/rangePicker/components/CalendarHeader.d.ts +11 -0
- package/dist/components/rangePicker/components/RangePickerPanel.d.ts +25 -0
- package/dist/components/rangePicker/components/TimeSelector.d.ts +21 -0
- package/dist/components/rangePicker/constants.d.ts +5 -0
- package/dist/components/rangePicker/index.d.ts +4 -0
- package/dist/components/rangePicker/types.d.ts +23 -0
- package/dist/components/rangePicker/utils.d.ts +2 -0
- package/dist/components/weekView/AllDayRow.d.ts +50 -0
- package/dist/components/weekView/TimeGrid.d.ts +52 -0
- package/dist/components/weekView/util.d.ts +9 -0
- package/dist/components/yearView/DefaultYearView.d.ts +11 -0
- package/dist/components/yearView/FixedWeekYearView.d.ts +14 -0
- package/dist/components/yearView/YearDayCell.d.ts +12 -0
- package/dist/components/yearView/YearMultiDayEvent.d.ts +23 -0
- package/dist/components/yearView/YearRowComponent.d.ts +27 -0
- package/dist/components/yearView/YearWeekComponent.d.ts +29 -0
- package/dist/components/yearView/utils.d.ts +19 -0
- package/dist/contexts/ThemeContext.d.ts +0 -21
- package/dist/factories/createDayView.d.ts +1 -9
- package/dist/factories/createMonthView.d.ts +1 -13
- package/dist/factories/createWeekView.d.ts +1 -12
- package/dist/factories/createYearView.d.ts +1 -7
- package/dist/factories/index.d.ts +0 -7
- package/dist/hooks/virtualScroll/useVirtualScroll.d.ts +9 -9
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/styles/classNames.d.ts +8 -8
- package/dist/styles.css +78 -140
- package/dist/types/dragIndicator.d.ts +2 -0
- package/dist/types/factory.d.ts +2 -0
- package/dist/types/plugin.d.ts +1 -1
- package/dist/views/YearView.d.ts +7 -2
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -10,369 +10,29 @@ views, and plugin architecture.
|
|
|
10
10
|
[](https://github.com/dayflow-js/dayflow/blob/main/LICENSE)
|
|
11
11
|
[](https://discord.gg/9vdFZKJqBb)
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Features
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### Monthly, Weekly, Daily and Various View Types
|
|
16
16
|
|
|
17
17
|
| Monthly | Weekly |
|
|
18
18
|
|------------------------------------------|----------------------------------------|
|
|
19
|
-
|  |  |
|
|
20
20
|
|
|
21
21
|
| Daily | Event Stack Level |
|
|
22
22
|
|---------------------------------------|------------------------------------------|
|
|
23
23
|
|  |  |
|
|
24
24
|
|
|
25
|
-
###
|
|
25
|
+
### Default Panel (with multiple Event Detail Panel options available)
|
|
26
26
|
|
|
27
27
|
| Detail Popup | Detail Dialog |
|
|
28
28
|
|-------------------------------------|--------------------------------------|
|
|
29
29
|
|  |  |
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
### Easy to resize and drag
|
|
32
|
+
https://github.com/user-attachments/assets/726a5232-35a8-4fe3-8e7b-4de07c455353
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
https://github.com/user-attachments/assets/957317e5-02d8-4419-a74b-62b7d191e347
|
|
34
35
|
|
|
35
|
-
https://dayflow-js.github.io/calendar/
|
|
36
|
-
|
|
37
|
-
### Installation
|
|
38
|
-
|
|
39
|
-
```tsx
|
|
40
|
-
npm
|
|
41
|
-
install
|
|
42
|
-
@dayflow/
|
|
43
|
-
core
|
|
44
|
-
lucide - react
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
The entire **DayFlow** app is created through the `useCalendarApp` hook, which returns a **`calendar`** object.
|
|
49
|
-
|
|
50
|
-
This object is then rendered using the `DayFlowCalendar` UI component.
|
|
51
|
-
|
|
52
|
-
```tsx
|
|
53
|
-
'use client';
|
|
54
|
-
|
|
55
|
-
import {
|
|
56
|
-
useCalendarApp,
|
|
57
|
-
DayFlowCalendar,
|
|
58
|
-
createMonthView,
|
|
59
|
-
createEvent,
|
|
60
|
-
createAllDayEvent,
|
|
61
|
-
createTimedEvent,
|
|
62
|
-
} from '@dayflow/core';
|
|
63
|
-
import '@dayflow/core/dist/styles.css';
|
|
64
|
-
|
|
65
|
-
// Local timed event (no timezone complexity)
|
|
66
|
-
const meeting = createEvent({
|
|
67
|
-
id: '1',
|
|
68
|
-
title: 'Team Meeting',
|
|
69
|
-
start: new Date(2024, 9, 15, 10, 0), // Oct 15, 2024 10:00
|
|
70
|
-
end: new Date(2024, 9, 15, 11, 0), // Oct 15, 2024 11:00
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
// All-day event
|
|
74
|
-
const holiday = createAllDayEvent(
|
|
75
|
-
'2',
|
|
76
|
-
'Tech Conference',
|
|
77
|
-
new Date(2024, 9, 20)
|
|
78
|
-
);
|
|
79
|
-
|
|
80
|
-
// Quick timed event creation
|
|
81
|
-
const lunch = createTimedEvent(
|
|
82
|
-
'3',
|
|
83
|
-
'Lunch Break',
|
|
84
|
-
new Date(2024, 9, 15, 12, 0), // 12:00
|
|
85
|
-
new Date(2024, 9, 15, 13, 0) // 13:00
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
export default function MyCalendar() {
|
|
89
|
-
const calendar = useCalendarApp({
|
|
90
|
-
views: [createMonthView()],
|
|
91
|
-
events: [],
|
|
92
|
-
calendars: [],
|
|
93
|
-
defaultView: 'month',
|
|
94
|
-
initialDate: new Date(),
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
return <DayFlowCalendar calendar={calendar} />;
|
|
98
|
-
}
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
- **views**: An array of calendar views. Currently, DayFlow provides four built-in factory functions:
|
|
102
|
-
`createMonthView`, `createWeekView`, `createDayView`, and `createYearView` (still in development).
|
|
103
|
-
The order of views determines the order of tabs (Year / Month / Week / Day).
|
|
104
|
-
- **events**: The core data of the calendar. Events can be created using the built-in helpers
|
|
105
|
-
`createEvent`, `createAllDayEvent`, and `createTimedEvent`, depending on the event type.
|
|
106
|
-
|
|
107
|
-
---
|
|
108
|
-
|
|
109
|
-
## `useCalendarApp` Configuration Options
|
|
110
|
-
|
|
111
|
-
| Option | Type | Default | Description | Required |
|
|
112
|
-
|------------------------|---------------------------|------------------------|----------------------------------------------------------------------------------------------------------------------|----------|
|
|
113
|
-
| `views` | `CalendarView[]` | — | Registered view definitions (e.g. `createMonthView()`). At least one view is required | ✅ |
|
|
114
|
-
| `plugins` | `CalendarPlugin[]` | `[]` | Optional plugins (drag support, keyboard shortcuts, etc.). Each plugin receives the app instance during installation | ❌ |
|
|
115
|
-
| `events` | `Event[]` | `[]` | Initial event data. Use `addEvent` / `updateEvent` to modify later | ❌ |
|
|
116
|
-
| `callbacks` | `CalendarCallbacks` | `{}` | Lifecycle hooks triggered on view, date, or event changes — ideal for API synchronization | ❌ |
|
|
117
|
-
| `defaultView` | `ViewType` | `ViewType.WEEK` | Initial view on load; must exist in `views` | ❌ |
|
|
118
|
-
| `initialDate` | `Date` | `new Date()` | Initial focused date (also initializes visible range calculation) | ❌ |
|
|
119
|
-
| `switcherMode` | `'buttons' | 'select'` | `'buttons'` | Controls how the built-in view switcher is rendered in the header | ❌ |
|
|
120
|
-
| `calendars` | `CalendarType[]` | `[]` | Register calendar categories (work, personal, etc.) with colors and visibility | ❌ |
|
|
121
|
-
| `defaultCalendar` | `string` | First visible calendar | Calendar ID used when creating new events | ❌ |
|
|
122
|
-
| `theme` | `ThemeConfig` | `{ mode: 'light' }` | Global theme mode and optional token overrides | ❌ |
|
|
123
|
-
| `locale` | `string | Locale` | `'en-US'` | Internationalization (i18n). Supports language codes (e.g. `'zh'`) or Locale objects | ❌ |
|
|
124
|
-
| `useSidebar` | `boolean | SidebarConfig` | `false` | Enable the built-in sidebar or customize width, collapse state, and renderer | ❌ |
|
|
125
|
-
| `useEventDetailDialog` | `boolean` | `false` | Use a modal dialog for event details instead of an inline panel | ❌ |
|
|
126
|
-
|
|
127
|
-
## Callback Functions
|
|
128
|
-
|
|
129
|
-
`callbacks` act as a bridge between DayFlow and your backend or external state management.
|
|
130
|
-
|
|
131
|
-
They are commonly used for CRUD operations with databases or APIs.
|
|
132
|
-
|
|
133
|
-
Examples include:
|
|
134
|
-
|
|
135
|
-
- `onViewChange(view)`: Triggered after view switching (useful for analytics or URL sync)
|
|
136
|
-
- `onDateChange(date)`: Fired when the focused date changes
|
|
137
|
-
- `onVisibleMonthChange(date)`: Triggered when the visible month changes (useful for preloading data)
|
|
138
|
-
- `onEventCreate / Update / Delete`: Connect event CRUD with your backend
|
|
139
|
-
- `onCalendarCreate / Update / Delete`: Sync calendar list changes
|
|
140
|
-
- `onCalendarMerge(sourceId, targetId)`: Triggered when merging two calendars
|
|
141
|
-
- `onRender`: Fired after a render cycle, suitable for performance monitoring
|
|
142
|
-
|
|
143
|
-
```tsx
|
|
144
|
-
const calendar = useCalendarApp({
|
|
145
|
-
views: [createDayView(), createWeekView(), createMonthView()],
|
|
146
|
-
events,
|
|
147
|
-
calendars: customCalendarTypes,
|
|
148
|
-
defaultCalendar: 'work',
|
|
149
|
-
plugins: [dragPlugin],
|
|
150
|
-
theme: { mode: 'auto' },
|
|
151
|
-
useSidebar: sidebarConfig,
|
|
152
|
-
callbacks: {
|
|
153
|
-
onCalendarUpdate: async calendar => {
|
|
154
|
-
console.log('update calendar:', calendar);
|
|
155
|
-
},
|
|
156
|
-
onCalendarDelete: async calendar => {
|
|
157
|
-
console.log('delete calendar:', calendar);
|
|
158
|
-
},
|
|
159
|
-
onCalendarCreate: async calendar => {
|
|
160
|
-
// await server API call
|
|
161
|
-
console.log('create calendar:', calendar);
|
|
162
|
-
},
|
|
163
|
-
onCalendarMerge: async (sourceId, targetId) => {
|
|
164
|
-
console.log('merge calendar:', sourceId, targetId);
|
|
165
|
-
},
|
|
166
|
-
},
|
|
167
|
-
});
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
## Event Detail Management
|
|
173
|
-
|
|
174
|
-
DayFlow includes a default event detail panel that supports editing:
|
|
175
|
-
|
|
176
|
-
- Title
|
|
177
|
-
- Time range
|
|
178
|
-
- Notes
|
|
179
|
-
|
|
180
|
-
You can also pass a `meta` object to store custom fields such as **meeting links**, **locations**, etc.
|
|
181
|
-
|
|
182
|
-
<img width="536" height="323" alt="image" src="https://github.com/user-attachments/assets/7a599105-460e-4f83-8418-92bcd0ff8c2a" />
|
|
183
|
-
|
|
184
|
-
You can enable the detail panel as a modal dialog by passing `useEventDetailDialog` to `DayFlowCalendar`:
|
|
185
|
-
|
|
186
|
-
```tsx
|
|
187
|
-
<DayFlowCalendar calendar={calendar} useEventDetailDialog={true} />
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
<img width="1476" height="1108" alt="image" src="https://github.com/user-attachments/assets/c9f1e231-f8d1-4006-8ff1-942bb7491934" />
|
|
191
|
-
|
|
192
|
-
---
|
|
193
|
-
|
|
194
|
-
### Custom Event Detail Panel / Dialog
|
|
195
|
-
|
|
196
|
-
For fully customized UIs, you can replace the default detail panel or dialog by providing your own components via:
|
|
197
|
-
|
|
198
|
-
- `customDetailPanelContent`
|
|
199
|
-
- `customEventDetailDialog`
|
|
200
|
-
|
|
201
|
-
```tsx
|
|
202
|
-
<DayFlowCalendar
|
|
203
|
-
calendar={calendar}
|
|
204
|
-
customEventDetailDialog={CustomDialog} // Modal dialog
|
|
205
|
-
customDetailPanelContent={CustomContent} // Floating panel
|
|
206
|
-
/>
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
See the documentation for details:
|
|
210
|
-
|
|
211
|
-
- **Custom Event Detail Dialog**
|
|
212
|
-
https://dayflow-js.github.io/calendar/docs/features/custom-detail-dialog
|
|
213
|
-
- **Custom Event Detail Panel**
|
|
214
|
-
https://dayflow-js.github.io/calendar/docs/features/custom-detail-panel
|
|
215
|
-
|
|
216
|
-
---
|
|
217
|
-
|
|
218
|
-
## Sidebar
|
|
219
|
-
|
|
220
|
-
DayFlow ships with a powerful built-in sidebar.
|
|
221
|
-
|
|
222
|
-
You can:
|
|
223
|
-
|
|
224
|
-
- Drag calendars from the sidebar to create events
|
|
225
|
-
|
|
226
|
-

|
|
227
|
-
|
|
228
|
-
- Merge, delete, and recolor calendars
|
|
229
|
-
|
|
230
|
-
<img width="540" height="423" alt="image" src="https://github.com/user-attachments/assets/257a8671-e645-43fe-861e-613030f6c46e" />
|
|
231
|
-
|
|
232
|
-
- Use preset colors or choose custom colors via a color picker
|
|
233
|
-
|
|
234
|
-
<img width="872" height="708" alt="image" src="https://github.com/user-attachments/assets/bfda7cde-281e-4c23-86d6-910b13e7bc63" />
|
|
235
|
-
|
|
236
|
-
```tsx
|
|
237
|
-
const calendar = useCalendarApp({
|
|
238
|
-
views: [createMonthView(), createWeekView(), createDayView()],
|
|
239
|
-
plugins: [createDragPlugin()],
|
|
240
|
-
events,
|
|
241
|
-
calendars,
|
|
242
|
-
defaultView: ViewType.WEEK,
|
|
243
|
-
useSidebar: {
|
|
244
|
-
enabled: true,
|
|
245
|
-
width: 280,
|
|
246
|
-
},
|
|
247
|
-
});
|
|
248
|
-
```
|
|
249
|
-
|
|
250
|
-
---
|
|
251
|
-
|
|
252
|
-
### `useSidebar` Configuration
|
|
253
|
-
|
|
254
|
-
| Property | Type | Description | Default |
|
|
255
|
-
|------------------------------|--------------------------------------------------------------------|---------------------------------------------------------------------------------------------|------------|
|
|
256
|
-
| `enabled` | `boolean` | Whether the sidebar is enabled. | `true` |
|
|
257
|
-
| `width` | `number \| string` | Width of the sidebar (e.g., `240` or `'20%'`). | `'240px'` |
|
|
258
|
-
| `initialCollapsed` | `boolean` | Whether the sidebar is collapsed by default. | `false` |
|
|
259
|
-
| `render` | `(props: CalendarSidebarRenderProps) => React.ReactNode` | Full override for the sidebar UI. | - |
|
|
260
|
-
| `createCalendarMode` | `'inline' \| 'modal'` | Mode for creating new calendars: `inline` (direct edit in list) or `modal` (pop-up dialog). | `'inline'` |
|
|
261
|
-
| `renderCalendarContextMenu` | `(calendar: CalendarType, onClose: () => void) => React.ReactNode` | Custom renderer for the right-click context menu on calendar items. | - |
|
|
262
|
-
| `renderCreateCalendarDialog` | `(props: CreateCalendarDialogProps) => React.ReactNode` | Custom renderer for the calendar creation dialog (used in `modal` mode). | - |
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
---
|
|
266
|
-
|
|
267
|
-
### Custom Sidebar
|
|
268
|
-
|
|
269
|
-
If your project already has its own sidebar design, you can fully customize it using `useSidebar.render`.
|
|
270
|
-
|
|
271
|
-
This render function receives real-time calendar state and helper methods to interact with DayFlow core.
|
|
272
|
-
|
|
273
|
-
**`CalendarSidebarRenderProps` enables communication between your custom sidebar and DayFlow core.**
|
|
274
|
-
|
|
275
|
-
```tsx
|
|
276
|
-
import type { CalendarSidebarRenderProps } from '@dayflow/core';
|
|
277
|
-
|
|
278
|
-
const CustomSidebar = ({
|
|
279
|
-
app,
|
|
280
|
-
calendars,
|
|
281
|
-
toggleCalendarVisibility,
|
|
282
|
-
toggleAll,
|
|
283
|
-
isCollapsed,
|
|
284
|
-
setCollapsed,
|
|
285
|
-
}: CalendarSidebarRenderProps) => {
|
|
286
|
-
if (isCollapsed) {
|
|
287
|
-
return <button onClick={() => setCollapsed(false)}>Expand Sidebar</button>;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
return (
|
|
291
|
-
<aside className="flex h-full flex-col gap-4 p-4">
|
|
292
|
-
<header className="flex items-center justify-between">
|
|
293
|
-
<h3 className="text-sm font-semibold">Calendars</h3>
|
|
294
|
-
<div className="space-x-2">
|
|
295
|
-
<button onClick={() => toggleAll(true)}>Show All</button>
|
|
296
|
-
<button onClick={() => toggleAll(false)}>Hide All</button>
|
|
297
|
-
</div>
|
|
298
|
-
</header>
|
|
299
|
-
<ul className="space-y-2">
|
|
300
|
-
{calendars.map(calendar => (
|
|
301
|
-
<li key={calendar.id} className="flex items-center gap-2 text-sm">
|
|
302
|
-
<input
|
|
303
|
-
type="checkbox"
|
|
304
|
-
checked={calendar.isVisible}
|
|
305
|
-
onChange={() =>
|
|
306
|
-
toggleCalendarVisibility(calendar.id, !calendar.isVisible)
|
|
307
|
-
}
|
|
308
|
-
/>
|
|
309
|
-
<span
|
|
310
|
-
className="h-2.5 w-2.5 rounded-full"
|
|
311
|
-
style={{ backgroundColor: calendar.colors.eventColor }}
|
|
312
|
-
/>
|
|
313
|
-
{calendar.name}
|
|
314
|
-
</li>
|
|
315
|
-
))}
|
|
316
|
-
</ul>
|
|
317
|
-
<section className="rounded-xl border border-slate-200 p-3 text-xs">
|
|
318
|
-
<p>Current date: {app.getCurrentDate().toDateString()}</p>
|
|
319
|
-
<p>Total events: {app.getEvents().length}</p>
|
|
320
|
-
</section>
|
|
321
|
-
</aside>
|
|
322
|
-
);
|
|
323
|
-
};
|
|
324
|
-
|
|
325
|
-
const calendar = useCalendarApp({
|
|
326
|
-
/* ... */
|
|
327
|
-
useSidebar: {
|
|
328
|
-
enabled: true,
|
|
329
|
-
width: 320,
|
|
330
|
-
render: props => <CustomSidebar {...props} />,
|
|
331
|
-
},
|
|
332
|
-
});
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
---
|
|
336
|
-
|
|
337
|
-
## Dark Mode
|
|
338
|
-
|
|
339
|
-
DayFlow Calendar natively supports full dark mode across views, sidebar, event cards, and dialogs.
|
|
340
|
-
|
|
341
|
-
<img width="1103" height="729" alt="image" src="https://github.com/user-attachments/assets/03c542d4-4b1b-4b99-9590-08c7be7f85df" />
|
|
342
|
-
|
|
343
|
-
You can switch between **light**, **dark**, or **auto** (follows system preference).
|
|
344
|
-
|
|
345
|
-
```tsx
|
|
346
|
-
import { DayFlowCalendar, useCalendarApp } from '@dayflow/core';
|
|
347
|
-
|
|
348
|
-
function MyCalendar() {
|
|
349
|
-
const calendar = useCalendarApp({
|
|
350
|
-
theme: {
|
|
351
|
-
mode: 'dark', // 'light' | 'dark' | 'auto'
|
|
352
|
-
},
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
return <DayFlowCalendar calendar={calendar} />;
|
|
356
|
-
}
|
|
357
|
-
```
|
|
358
|
-
|
|
359
|
-
---
|
|
360
|
-
|
|
361
|
-
## View Switcher Modes
|
|
362
|
-
|
|
363
|
-
The `switcherMode` option controls how the view switcher in the header is rendered.
|
|
364
|
-
|
|
365
|
-
DayFlow provides two built-in modes:
|
|
366
|
-
|
|
367
|
-
- **`buttons`**: Horizontal button tabs (default, ideal for desktop)
|
|
368
|
-
|
|
369
|
-
<img width="2190" height="406" alt="image" src="https://github.com/user-attachments/assets/a4be37bc-90ac-4872-afa0-589e3d1f7e9b" />
|
|
370
|
-
|
|
371
|
-
- **`select`**: Dropdown menu (space-saving, mobile-friendly)
|
|
372
|
-
|
|
373
|
-
<img width="2186" height="420" alt="image" src="https://github.com/user-attachments/assets/28e321ae-6c56-441a-a9fc-ddcfa504c920" />
|
|
374
|
-
|
|
375
|
-
---
|
|
376
36
|
|
|
377
37
|
## Contributing
|
|
378
38
|
|