@dayflow/core 0.1.4 → 1.0.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.
- package/README.md +79 -382
- package/dist/contexts/ThemeContext.d.ts +59 -0
- package/dist/core/CalendarApp.d.ts +23 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/dist/styles/classNames.d.ts +33 -33
- package/dist/styles.css +1 -1
- package/dist/types/core.d.ts +5 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/styleUtils.d.ts +24 -0
- package/dist/utils/themeUtils.d.ts +85 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,12 +2,40 @@
|
|
|
2
2
|
|
|
3
3
|
A flexible and feature-rich calendar component library for React applications with drag-and-drop support, multiple views, and plugin architecture.
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@dayflow/core)
|
|
6
|
+
[](https://github.com/dayflow-js/dayflow/pulls)
|
|
7
|
+
[](https://github.com/dayflow-js/dayflow/blob/main/LICENSE)
|
|
8
|
+
[](https://discord.gg/jc37N4xw)
|
|
7
9
|
|
|
8
|
-
##
|
|
10
|
+
## 🗓️ Features
|
|
9
11
|
|
|
10
|
-
|
|
12
|
+
### ✨ Monthly, Weekly, Daily and Various View Types
|
|
13
|
+
|
|
14
|
+
| Monthly | Weekly |
|
|
15
|
+
| ---------------------------------------- | -------------------------------------- |
|
|
16
|
+
|  |  |
|
|
17
|
+
|
|
18
|
+
| Daily | Event Stack Level |
|
|
19
|
+
| ------------------------------------- | ---------------------------------------- |
|
|
20
|
+
|  |  |
|
|
21
|
+
|
|
22
|
+
### 🤩 Default Panel (with multiple Event Detail Panel options available)
|
|
23
|
+
|
|
24
|
+
| Detail Popup | Detail Dialog |
|
|
25
|
+
| ----------------------------------- | ------------------------------------ |
|
|
26
|
+
|  |  |
|
|
27
|
+
|
|
28
|
+
### 🎯 Easy to resize and drag
|
|
29
|
+
|
|
30
|
+
https://github.com/user-attachments/assets/726a5232-35a8-4fe3-8e7b-4de07c455353
|
|
31
|
+
|
|
32
|
+
https://github.com/user-attachments/assets/957317e5-02d8-4419-a74b-62b7d191e347
|
|
33
|
+
|
|
34
|
+
> ⚡ For more features and interactive experience, visit our [live demo](https://dayflow-js.github.io/dayflow/).
|
|
35
|
+
|
|
36
|
+
## ✨ Core Features
|
|
37
|
+
|
|
38
|
+
- 🗓️ **Multiple Views**: Day, Week, Month, and Year views
|
|
11
39
|
- 🎨 **Customizable Styling**: Built with Tailwind CSS for easy customization
|
|
12
40
|
- 📱 **Responsive Design**: Works seamlessly on desktop, tablet, and mobile
|
|
13
41
|
- 🔌 **Plugin Architecture**: Extensible plugin system for custom functionality
|
|
@@ -17,9 +45,38 @@ A flexible and feature-rich calendar component library for React applications wi
|
|
|
17
45
|
- 🔄 **Virtual Scrolling**: High performance with large datasets
|
|
18
46
|
- 🎭 **Custom Renderers**: Customize event appearance and behavior
|
|
19
47
|
|
|
20
|
-
##
|
|
48
|
+
## 🚀 Additional Features
|
|
49
|
+
|
|
50
|
+
### 📅 Advanced Calendar Capabilities
|
|
51
|
+
|
|
52
|
+
- **Multi-Day Events**: Seamlessly span events across multiple days with visual continuity
|
|
53
|
+
- **All-Day Events**: Support for full-day events with dedicated header section
|
|
54
|
+
- **Event Stacking**: Intelligent event overlap detection with customizable stack levels
|
|
55
|
+
- **Sidebar Support**: Built-in sidebar component for calendar management
|
|
56
|
+
|
|
57
|
+
### 🎨 Customization & Theming
|
|
58
|
+
|
|
59
|
+
- **Custom Event Renderers**: Full control over event appearance with custom components
|
|
60
|
+
- **Color Coding**: Multiple calendar types with color-coded events (`calendarId` support)
|
|
61
|
+
- **Custom Detail Panels**: Three display modes - Dialog, Popup, or custom panel
|
|
62
|
+
- **Custom Headers**: Fully customizable `ViewHeader` component with switcher modes
|
|
63
|
+
- **Drag Indicators**: Customizable drag indicator renderers for different event types
|
|
64
|
+
|
|
65
|
+
### 🎯 Event Interaction
|
|
66
|
+
|
|
67
|
+
- **Event Callbacks**: `onEventCreate`, `onEventUpdate`, `onEventDelete` lifecycle hooks
|
|
68
|
+
- **Click Events**: Handle event clicks with custom callbacks
|
|
69
|
+
- **Drag & Drop**: Resize and move events with visual feedback
|
|
70
|
+
- **Color Picker**: Built-in color selection component for calendar types
|
|
21
71
|
|
|
22
|
-
###
|
|
72
|
+
### ⚡ Performance & Developer Experience
|
|
73
|
+
|
|
74
|
+
- **Virtual Scrolling**: High-performance rendering for large datasets in Month and Year views
|
|
75
|
+
- **TypeScript First**: Complete type definitions for all APIs
|
|
76
|
+
- **Plugin System**: Extensible architecture with Events Plugin and Drag Plugin
|
|
77
|
+
- **Temporal API**: Modern date/time handling with Temporal polyfill
|
|
78
|
+
|
|
79
|
+
## 📦 Installation
|
|
23
80
|
|
|
24
81
|
```bash
|
|
25
82
|
npm install @dayflow/core lucide-react
|
|
@@ -31,62 +88,15 @@ pnpm add @dayflow/core lucide-react
|
|
|
31
88
|
|
|
32
89
|
### Peer Dependencies
|
|
33
90
|
|
|
34
|
-
DayFlow requires the following peer dependencies:
|
|
35
91
|
- `react` >= 18.0.0
|
|
36
92
|
- `react-dom` >= 18.0.0
|
|
37
93
|
- `lucide-react` >= 0.400.0
|
|
38
94
|
|
|
39
|
-
### Configure Tailwind CSS (Required)
|
|
40
|
-
|
|
41
|
-
DayFlow uses Tailwind CSS for styling. Set up Tailwind in your project:
|
|
42
|
-
|
|
43
|
-
**1. Install Tailwind CSS:**
|
|
44
|
-
|
|
45
|
-
```bash
|
|
46
|
-
npm install -D tailwindcss @tailwindcss/postcss autoprefixer
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
**2. Create `postcss.config.js`:**
|
|
50
|
-
|
|
51
|
-
```js
|
|
52
|
-
export default {
|
|
53
|
-
plugins: {
|
|
54
|
-
'@tailwindcss/postcss': {},
|
|
55
|
-
autoprefixer: {},
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
**3. Create `tailwind.config.js` with required spacing configuration:**
|
|
61
|
-
|
|
62
|
-
```js
|
|
63
|
-
/** @type {import('tailwindcss').Config} */
|
|
64
|
-
export default {
|
|
65
|
-
content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'],
|
|
66
|
-
theme: {
|
|
67
|
-
extend: {
|
|
68
|
-
spacing: {
|
|
69
|
-
18: '4.5rem', // Required for Week/Day view hour heights
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
plugins: [],
|
|
74
|
-
};
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
**4. Import Tailwind in your CSS:**
|
|
78
|
-
|
|
79
|
-
```css
|
|
80
|
-
/* src/index.css */
|
|
81
|
-
@import 'tailwindcss';
|
|
82
|
-
```
|
|
83
|
-
|
|
84
95
|
## 🚀 Quick Start
|
|
85
96
|
|
|
86
97
|
```tsx
|
|
87
98
|
import { useCalendarApp, DayFlowCalendar } from '@dayflow/core';
|
|
88
99
|
import { createMonthView, createWeekView, createDayView } from '@dayflow/core';
|
|
89
|
-
// Import styles
|
|
90
100
|
import '@dayflow/core/dist/styles.css';
|
|
91
101
|
|
|
92
102
|
function App() {
|
|
@@ -99,350 +109,37 @@ function App() {
|
|
|
99
109
|
}
|
|
100
110
|
```
|
|
101
111
|
|
|
102
|
-
> **
|
|
103
|
-
|
|
104
|
-
## 📖 Basic Usage
|
|
105
|
-
|
|
106
|
-
### Creating a Calendar with Events
|
|
107
|
-
|
|
108
|
-
```tsx
|
|
109
|
-
import {
|
|
110
|
-
useCalendarApp,
|
|
111
|
-
DayFlowCalendar,
|
|
112
|
-
createMonthView,
|
|
113
|
-
createEvent,
|
|
114
|
-
createAllDayEvent,
|
|
115
|
-
} from '@dayflow/core';
|
|
116
|
-
import '@dayflow/core/dist/styles.css';
|
|
117
|
-
|
|
118
|
-
function MyCalendar() {
|
|
119
|
-
const events = [
|
|
120
|
-
// Timed event
|
|
121
|
-
createEvent({
|
|
122
|
-
id: '1',
|
|
123
|
-
title: 'Team Meeting',
|
|
124
|
-
start: new Date(2025, 0, 15, 10, 0),
|
|
125
|
-
end: new Date(2025, 0, 15, 11, 0),
|
|
126
|
-
}),
|
|
127
|
-
// All-day event
|
|
128
|
-
createAllDayEvent(
|
|
129
|
-
'2',
|
|
130
|
-
'Conference',
|
|
131
|
-
new Date(2025, 0, 20)
|
|
132
|
-
),
|
|
133
|
-
];
|
|
134
|
-
|
|
135
|
-
const calendar = useCalendarApp({
|
|
136
|
-
views: [createMonthView()],
|
|
137
|
-
initialDate: new Date(),
|
|
138
|
-
events,
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
return <DayFlowCalendar calendar={calendar} />;
|
|
142
|
-
}
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
### Using Multiple Views
|
|
146
|
-
|
|
147
|
-
```tsx
|
|
148
|
-
import {
|
|
149
|
-
useCalendarApp,
|
|
150
|
-
DayFlowCalendar,
|
|
151
|
-
createDayView,
|
|
152
|
-
createWeekView,
|
|
153
|
-
createMonthView,
|
|
154
|
-
createYearView,
|
|
155
|
-
ViewType,
|
|
156
|
-
} from '@dayflow/core';
|
|
157
|
-
import '@dayflow/core/dist/styles.css';
|
|
158
|
-
|
|
159
|
-
function MultiViewCalendar() {
|
|
160
|
-
const calendar = useCalendarApp({
|
|
161
|
-
views: [
|
|
162
|
-
createDayView(),
|
|
163
|
-
createWeekView(),
|
|
164
|
-
createMonthView(),
|
|
165
|
-
createYearView(),
|
|
166
|
-
],
|
|
167
|
-
initialView: ViewType.MONTH,
|
|
168
|
-
initialDate: new Date(),
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<div>
|
|
173
|
-
<div className="view-switcher">
|
|
174
|
-
<button onClick={() => calendar.changeView(ViewType.DAY)}>Day</button>
|
|
175
|
-
<button onClick={() => calendar.changeView(ViewType.WEEK)}>Week</button>
|
|
176
|
-
<button onClick={() => calendar.changeView(ViewType.MONTH)}>
|
|
177
|
-
Month
|
|
178
|
-
</button>
|
|
179
|
-
<button onClick={() => calendar.changeView(ViewType.YEAR)}>Year</button>
|
|
180
|
-
</div>
|
|
181
|
-
<DayFlowCalendar calendar={calendar} />
|
|
182
|
-
</div>
|
|
183
|
-
);
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### Event Callbacks
|
|
188
|
-
|
|
189
|
-
```tsx
|
|
190
|
-
function CalendarWithCallbacks() {
|
|
191
|
-
const calendar = useCalendarApp({
|
|
192
|
-
views: [createMonthView()],
|
|
193
|
-
initialDate: new Date(),
|
|
194
|
-
callbacks: {
|
|
195
|
-
onEventCreate: event => {
|
|
196
|
-
console.log('Event created:', event);
|
|
197
|
-
// Save to database
|
|
198
|
-
},
|
|
199
|
-
onEventUpdate: event => {
|
|
200
|
-
console.log('Event updated:', event);
|
|
201
|
-
// Update in database
|
|
202
|
-
},
|
|
203
|
-
onEventDelete: eventId => {
|
|
204
|
-
console.log('Event deleted:', eventId);
|
|
205
|
-
// Delete from database
|
|
206
|
-
},
|
|
207
|
-
},
|
|
208
|
-
});
|
|
209
|
-
|
|
210
|
-
return <DayFlowCalendar calendar={calendar} />;
|
|
211
|
-
}
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
## 🎨 Customization
|
|
215
|
-
|
|
216
|
-
### Custom Event Styling
|
|
217
|
-
|
|
218
|
-
```tsx
|
|
219
|
-
import { createEvent } from '@dayflow/core';
|
|
220
|
-
|
|
221
|
-
const events = [
|
|
222
|
-
createEvent({
|
|
223
|
-
id: '1',
|
|
224
|
-
title: 'Important Meeting',
|
|
225
|
-
start: new Date(2025, 0, 15, 9, 0),
|
|
226
|
-
end: new Date(2025, 0, 15, 10, 0),
|
|
227
|
-
calendarId: 'work', // Use calendarId for color theming
|
|
228
|
-
}),
|
|
229
|
-
createEvent({
|
|
230
|
-
id: '2',
|
|
231
|
-
title: 'Workshop',
|
|
232
|
-
start: new Date(2025, 0, 15, 14, 0),
|
|
233
|
-
end: new Date(2025, 0, 15, 16, 0),
|
|
234
|
-
calendarId: 'personal',
|
|
235
|
-
}),
|
|
236
|
-
];
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### Custom Drag Indicator
|
|
240
|
-
|
|
241
|
-
```tsx
|
|
242
|
-
import { DragIndicatorRenderer } from '@dayflow/core';
|
|
243
|
-
|
|
244
|
-
const customRenderer: DragIndicatorRenderer = {
|
|
245
|
-
renderDefaultContent: props => (
|
|
246
|
-
<div className="custom-drag-indicator">{props.title}</div>
|
|
247
|
-
),
|
|
248
|
-
renderAllDayContent: props => (
|
|
249
|
-
<div className="custom-allday-indicator">All Day: {props.title}</div>
|
|
250
|
-
),
|
|
251
|
-
renderRegularContent: props => (
|
|
252
|
-
<div className="custom-regular-indicator">
|
|
253
|
-
{props.formatTime?.(props.drag.startHour)} - {props.title}
|
|
254
|
-
</div>
|
|
255
|
-
),
|
|
256
|
-
};
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
## 📚 API Reference
|
|
260
|
-
|
|
261
|
-
### Core Hooks
|
|
262
|
-
|
|
263
|
-
#### `useCalendarApp(config)`
|
|
264
|
-
|
|
265
|
-
Creates a calendar application instance.
|
|
266
|
-
|
|
267
|
-
**Parameters:**
|
|
268
|
-
|
|
269
|
-
- `config.views`: Array of view factories
|
|
270
|
-
- `config.initialDate`: Initial date to display
|
|
271
|
-
- `config.initialView`: Initial view type
|
|
272
|
-
- `config.events`: Initial events array
|
|
273
|
-
- `config.onEventCreate`: Callback when event is created
|
|
274
|
-
- `config.onEventUpdate`: Callback when event is updated
|
|
275
|
-
- `config.onEventDelete`: Callback when event is deleted
|
|
276
|
-
|
|
277
|
-
**Returns:**
|
|
278
|
-
|
|
279
|
-
- Calendar application instance
|
|
280
|
-
|
|
281
|
-
### View Factories
|
|
282
|
-
|
|
283
|
-
- `createDayView()` - Creates a day view
|
|
284
|
-
- `createWeekView()` - Creates a week view
|
|
285
|
-
- `createMonthView()` - Creates a month view
|
|
286
|
-
- `createYearView()` - Creates a year view
|
|
287
|
-
|
|
288
|
-
### Components
|
|
289
|
-
|
|
290
|
-
- `DayFlowCalendar` - Main calendar rendering component
|
|
291
|
-
- `Event` - Individual event component
|
|
292
|
-
|
|
293
|
-
### Types
|
|
294
|
-
|
|
295
|
-
#### `Event`
|
|
296
|
-
|
|
297
|
-
```typescript
|
|
298
|
-
interface Event {
|
|
299
|
-
id: number;
|
|
300
|
-
title: string;
|
|
301
|
-
date: Date;
|
|
302
|
-
startHour: number;
|
|
303
|
-
endHour: number;
|
|
304
|
-
color?: string;
|
|
305
|
-
isAllDay?: boolean;
|
|
306
|
-
startDate?: Date;
|
|
307
|
-
endDate?: Date;
|
|
308
|
-
day?: number;
|
|
309
|
-
}
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
#### `ViewType`
|
|
313
|
-
|
|
314
|
-
```typescript
|
|
315
|
-
enum ViewType {
|
|
316
|
-
DAY = 'day',
|
|
317
|
-
WEEK = 'week',
|
|
318
|
-
MONTH = 'month',
|
|
319
|
-
YEAR = 'year',
|
|
320
|
-
}
|
|
321
|
-
```
|
|
322
|
-
|
|
323
|
-
## 🔌 Plugins
|
|
324
|
-
|
|
325
|
-
The library includes built-in plugins:
|
|
326
|
-
|
|
327
|
-
- **Events Plugin**: Manages event state and operations
|
|
328
|
-
- **Drag Plugin**: Provides drag-and-drop functionality
|
|
329
|
-
|
|
330
|
-
You can create custom plugins by implementing the `CalendarPlugin` interface.
|
|
331
|
-
|
|
332
|
-
## 🎯 Advanced Usage
|
|
112
|
+
> 📖 **[View Full Documentation →](https://dayflow-js.github.io/dayflow/)**
|
|
333
113
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
```typescript
|
|
337
|
-
import { CalendarPlugin } from 'dayflow';
|
|
338
|
-
|
|
339
|
-
const myCustomPlugin: CalendarPlugin = {
|
|
340
|
-
name: 'myCustomPlugin',
|
|
341
|
-
initialize: context => {
|
|
342
|
-
// Plugin initialization
|
|
343
|
-
return {
|
|
344
|
-
// Plugin API
|
|
345
|
-
customMethod: () => {
|
|
346
|
-
console.log('Custom method called');
|
|
347
|
-
},
|
|
348
|
-
};
|
|
349
|
-
},
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
const calendar = useCalendarApp({
|
|
353
|
-
views: [createMonthView()],
|
|
354
|
-
plugins: [myCustomPlugin],
|
|
355
|
-
});
|
|
356
|
-
```
|
|
114
|
+
## 🎯 Use Cases
|
|
357
115
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
The calendar automatically uses virtual scrolling for better performance with large datasets, especially in Month and Year views.
|
|
361
|
-
|
|
362
|
-
## 🧪 Testing
|
|
363
|
-
|
|
364
|
-
DayFlow includes comprehensive testing support:
|
|
365
|
-
|
|
366
|
-
```bash
|
|
367
|
-
# Run all tests
|
|
368
|
-
npm test
|
|
369
|
-
|
|
370
|
-
# Run tests in watch mode
|
|
371
|
-
npm run test:watch
|
|
372
|
-
|
|
373
|
-
# Generate coverage report
|
|
374
|
-
npm run test:coverage
|
|
375
|
-
```
|
|
116
|
+
DayFlow is perfect for:
|
|
376
117
|
|
|
377
|
-
|
|
118
|
+
- 📅 **Scheduling Applications**: Employee scheduling, appointment booking, class timetables
|
|
119
|
+
- 🎫 **Event Management**: Conference schedules, event calendars, festival planners
|
|
120
|
+
- 🏢 **Project Management**: Timeline views, task scheduling
|
|
121
|
+
- 💼 **Business**: Meeting rooms, resource booking, availability management
|
|
378
122
|
|
|
379
|
-
|
|
380
|
-
import { CalendarApp } from 'dayflow';
|
|
381
|
-
import { ViewType } from 'dayflow/types';
|
|
123
|
+
## 🌟 Key Highlights
|
|
382
124
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
});
|
|
390
|
-
|
|
391
|
-
app.addEvent({
|
|
392
|
-
id: 'test-1',
|
|
393
|
-
title: 'Test Event',
|
|
394
|
-
start: new Date(),
|
|
395
|
-
end: new Date(),
|
|
396
|
-
});
|
|
397
|
-
|
|
398
|
-
expect(app.getAllEvents()).toHaveLength(1);
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
See the [Testing Guide](./docs/testing.md) for more information.
|
|
404
|
-
|
|
405
|
-
## ⚡ Performance
|
|
406
|
-
|
|
407
|
-
### Bundle Size
|
|
408
|
-
|
|
409
|
-
- ESM bundle: ~237KB (minified)
|
|
410
|
-
- Gzipped: ~65KB
|
|
411
|
-
- Tree-shakeable for optimal bundle size
|
|
412
|
-
|
|
413
|
-
### Optimization Tips
|
|
414
|
-
|
|
415
|
-
1. **Import only what you need**: Tree-shaking eliminates unused code
|
|
416
|
-
2. **Use virtual scrolling**: Automatically enabled for large datasets
|
|
417
|
-
3. **Lazy load views**: Use React.lazy() for code splitting
|
|
418
|
-
4. **Optimize events**: Filter events by visible date range
|
|
419
|
-
|
|
420
|
-
```typescript
|
|
421
|
-
// Good - Only import what you need
|
|
422
|
-
import { useCalendarApp } from 'dayflow';
|
|
423
|
-
import { createMonthView } from 'dayflow/factories';
|
|
424
|
-
|
|
425
|
-
// Analyze bundle size
|
|
426
|
-
npm run build // Generates bundle-analysis.html
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
See the [Performance Guide](./docs/optimization.md) for detailed optimization strategies.
|
|
125
|
+
- ✅ **TypeScript Support**: Full type definitions included
|
|
126
|
+
- ✅ **Drag & Drop**: Built-in drag and resize functionality
|
|
127
|
+
- ✅ **Virtual Scrolling**: Optimized rendering for large datasets
|
|
128
|
+
- ✅ **Plugin System**: Extensible with Events and Drag plugins
|
|
129
|
+
- ✅ **Modern React**: Hooks-based architecture (React 18+)
|
|
130
|
+
- ✅ **Tailwind CSS**: Easy styling customization
|
|
430
131
|
|
|
431
132
|
## 🤝 Contributing
|
|
432
133
|
|
|
433
134
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
434
135
|
|
|
435
|
-
## 📄 License
|
|
436
|
-
|
|
437
|
-
MIT © [Jayce Li](https://github.com/JayceV552)
|
|
438
|
-
|
|
439
136
|
## 🐛 Bug Reports
|
|
440
137
|
|
|
441
|
-
If you find a bug, please file an issue on [GitHub Issues](https://github.com/
|
|
138
|
+
If you find a bug, please file an issue on [GitHub Issues](https://github.com/dayflow-js/dayflow/issues).
|
|
442
139
|
|
|
443
140
|
## 📮 Support
|
|
444
141
|
|
|
445
|
-
For questions and support, please open an issue on GitHub.
|
|
142
|
+
For questions and support, please open an issue on GitHub or go to discord.
|
|
446
143
|
|
|
447
144
|
---
|
|
448
145
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ThemeMode } from '@/types/calendarTypes';
|
|
3
|
+
/**
|
|
4
|
+
* Theme Context Type
|
|
5
|
+
*/
|
|
6
|
+
export interface ThemeContextType {
|
|
7
|
+
/** Current theme mode (can be 'auto') */
|
|
8
|
+
theme: ThemeMode;
|
|
9
|
+
/** Effective theme (resolved, never 'auto') */
|
|
10
|
+
effectiveTheme: 'light' | 'dark';
|
|
11
|
+
/** Set theme mode */
|
|
12
|
+
setTheme: (mode: ThemeMode) => void;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Theme Provider Props
|
|
16
|
+
*/
|
|
17
|
+
export interface ThemeProviderProps {
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
/** Initial theme mode */
|
|
20
|
+
initialTheme?: ThemeMode;
|
|
21
|
+
/** Callback when theme changes */
|
|
22
|
+
onThemeChange?: (theme: ThemeMode, effectiveTheme: 'light' | 'dark') => void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Theme Provider Component
|
|
26
|
+
*
|
|
27
|
+
* Manages theme state and applies it to the document root.
|
|
28
|
+
* Supports 'light', 'dark', and 'auto' modes.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* <ThemeProvider initialTheme="auto">
|
|
33
|
+
* <App />
|
|
34
|
+
* </ThemeProvider>
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare const ThemeProvider: React.FC<ThemeProviderProps>;
|
|
38
|
+
/**
|
|
39
|
+
* Use Theme Hook
|
|
40
|
+
*
|
|
41
|
+
* Access current theme and theme control functions.
|
|
42
|
+
* Must be used within a ThemeProvider.
|
|
43
|
+
*
|
|
44
|
+
* @returns Theme context value
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```tsx
|
|
48
|
+
* function MyComponent() {
|
|
49
|
+
* const { theme, effectiveTheme, setTheme } = useTheme();
|
|
50
|
+
*
|
|
51
|
+
* return (
|
|
52
|
+
* <button onClick={() => setTheme(effectiveTheme === 'light' ? 'dark' : 'light')}>
|
|
53
|
+
* Toggle Theme
|
|
54
|
+
* </button>
|
|
55
|
+
* );
|
|
56
|
+
* }
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const useTheme: () => ThemeContextType;
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { CalendarApp as ICalendarApp, CalendarAppConfig, CalendarAppState, CalendarView, ViewType, SidebarConfig, CalendarType } from '@/types';
|
|
3
3
|
import { Event } from '@/types';
|
|
4
4
|
import { CalendarRegistry } from './calendarRegistry';
|
|
5
|
+
import { ThemeMode } from '@/types/calendarTypes';
|
|
5
6
|
export declare class CalendarApp implements ICalendarApp {
|
|
6
7
|
state: CalendarAppState;
|
|
7
8
|
private callbacks;
|
|
@@ -9,6 +10,7 @@ export declare class CalendarApp implements ICalendarApp {
|
|
|
9
10
|
private sidebarConfig;
|
|
10
11
|
private visibleMonth;
|
|
11
12
|
private useEventDetailDialog;
|
|
13
|
+
private themeChangeListeners;
|
|
12
14
|
constructor(config: CalendarAppConfig);
|
|
13
15
|
changeView: (view: ViewType) => void;
|
|
14
16
|
getCurrentView: () => CalendarView;
|
|
@@ -39,4 +41,25 @@ export declare class CalendarApp implements ICalendarApp {
|
|
|
39
41
|
triggerRender: () => void;
|
|
40
42
|
getCalendarRegistry: () => CalendarRegistry;
|
|
41
43
|
getUseEventDetailDialog: () => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Set theme mode
|
|
46
|
+
* @param mode - Theme mode ('light', 'dark', or 'auto')
|
|
47
|
+
*/
|
|
48
|
+
setTheme: (mode: ThemeMode) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Get current theme mode
|
|
51
|
+
* @returns Current theme mode
|
|
52
|
+
*/
|
|
53
|
+
getTheme: () => ThemeMode;
|
|
54
|
+
/**
|
|
55
|
+
* Subscribe to theme changes
|
|
56
|
+
* @param callback - Function to call when theme changes
|
|
57
|
+
* @returns Unsubscribe function
|
|
58
|
+
*/
|
|
59
|
+
subscribeThemeChange: (callback: (theme: ThemeMode) => void) => (() => void);
|
|
60
|
+
/**
|
|
61
|
+
* Unsubscribe from theme changes
|
|
62
|
+
* @param callback - Function to remove from listeners
|
|
63
|
+
*/
|
|
64
|
+
unsubscribeThemeChange: (callback: (theme: ThemeMode) => void) => void;
|
|
42
65
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,8 @@ export { CalendarApp } from './core/CalendarApp';
|
|
|
3
3
|
export { useCalendarApp } from './core/useCalendarApp';
|
|
4
4
|
export { DayFlowCalendar } from './core/DayFlowCalendar';
|
|
5
5
|
export { CalendarRegistry } from './core/calendarRegistry';
|
|
6
|
+
export { ThemeProvider, useTheme } from './contexts/ThemeContext';
|
|
7
|
+
export type { ThemeContextType, ThemeProviderProps } from './contexts/ThemeContext';
|
|
6
8
|
export { createDayView } from './factories/createDayView';
|
|
7
9
|
export { createWeekView } from './factories/createWeekView';
|
|
8
10
|
export { createMonthView } from './factories/createMonthView';
|