cleanhaus-calendar 1.0.0 → 1.0.2
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 +118 -151
- package/dist/index.d.mts +547 -0
- package/dist/index.d.ts +547 -0
- package/dist/index.js +4481 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +4414 -0
- package/dist/index.mjs.map +1 -0
- package/dist/sparks-EDXND3ZD.png +0 -0
- package/package.json +13 -20
- package/src/Calendar.tsx +0 -279
- package/src/CalendarFAB.tsx +0 -116
- package/src/DayView/components/EventBlock.tsx +0 -306
- package/src/DayView/components/PropertyHeader.tsx +0 -62
- package/src/DayView/components/PropertyLane.tsx +0 -150
- package/src/DayView/config/EventBlockConfig.tsx +0 -603
- package/src/DayView/constants.ts +0 -39
- package/src/DayView/hooks/useScrollSynchronization.ts +0 -103
- package/src/DayView/index.tsx +0 -382
- package/src/DayView/styles/EventBlockStyles.ts +0 -274
- package/src/DayView/types.ts +0 -15
- package/src/DayView/utils.ts +0 -412
- package/src/MonthView/EventBar.tsx +0 -254
- package/src/MonthView/OverflowIndicator.tsx +0 -52
- package/src/MonthView/index.tsx +0 -299
- package/src/MonthView/types.ts +0 -39
- package/src/MonthView/utils.ts +0 -259
- package/src/WeekView/OverflowIndicator.tsx +0 -93
- package/src/WeekView/components/DayColumn.tsx +0 -236
- package/src/WeekView/components/PropertyBar.tsx +0 -108
- package/src/WeekView/components/PropertyIndicator.tsx +0 -62
- package/src/WeekView/components/WeekHeader.tsx +0 -142
- package/src/WeekView/constants.ts +0 -53
- package/src/WeekView/index.tsx +0 -403
- package/src/WeekView/types.ts +0 -38
- package/src/WeekView/utils/indicators.ts +0 -82
- package/src/WeekView/utils.ts +0 -314
- package/src/hooks/index.ts +0 -6
- package/src/hooks/useSwipeGesture.ts +0 -135
- package/src/index.ts +0 -21
- package/src/shared/ErrorBoundary.tsx +0 -130
- package/src/shared/HourGrid.tsx +0 -52
- package/src/shared/NowIndicator.tsx +0 -92
- package/src/shared/TimeColumn.tsx +0 -92
- package/src/shared/TimeRail.tsx +0 -63
- package/src/shared/VerticalDividers.tsx +0 -55
- package/src/shared/index.ts +0 -19
- package/src/shared/useNowIndicator.ts +0 -83
- package/src/types/react-native.d.ts +0 -33
- package/src/types.ts +0 -45
- package/src/utils/dateUtils.ts +0 -268
- package/src/utils/eventHelpers.ts +0 -425
- package/src/utils/index.ts +0 -27
- package/src/utils/platform.ts +0 -49
- package/src/utils/propertyColors.ts +0 -74
- package/src/utils/reanimated.ts +0 -127
- package/src/utils/theme.ts +0 -315
- package/src/utils/weekDayUtils.ts +0 -75
- package/src/web/index.ts +0 -28
- package/tsup.config.ts +0 -24
package/README.md
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
# cleanhaus-calendar
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Cross-platform calendar component for React Native and Next.js with Month, Week, and Day views. Features horizontal time positioning, multi-day event spanning, and type-based event rendering.
|
|
4
4
|
|
|
5
|
-
##
|
|
6
|
-
|
|
7
|
-
- ✅ **React Native** (iOS/Android)
|
|
8
|
-
- ✅ **Next.js** (Web with react-native-web)
|
|
9
|
-
|
|
10
|
-
## 📦 Installation
|
|
5
|
+
## Installation
|
|
11
6
|
|
|
12
7
|
```bash
|
|
13
8
|
npm install cleanhaus-calendar
|
|
@@ -19,23 +14,24 @@ npm install cleanhaus-calendar
|
|
|
19
14
|
npm install react react-native react-native-web react-native-reanimated dayjs calendarize
|
|
20
15
|
```
|
|
21
16
|
|
|
22
|
-
**
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
17
|
+
**Compatibility:**
|
|
18
|
+
- React >=18.0.0
|
|
19
|
+
- React Native >=0.70.0
|
|
20
|
+
- react-native-web >=0.19.0 (optional, for web)
|
|
21
|
+
- react-native-reanimated >=3.0.0
|
|
22
|
+
- dayjs ^1.11.0
|
|
23
|
+
- calendarize ^1.1.0
|
|
24
|
+
- Node >=18.0.0
|
|
30
25
|
|
|
31
|
-
##
|
|
26
|
+
## Quick Start
|
|
32
27
|
|
|
33
|
-
### React Native
|
|
28
|
+
### React Native
|
|
34
29
|
|
|
35
|
-
No additional configuration needed
|
|
30
|
+
No additional configuration needed. Install and use:
|
|
36
31
|
|
|
37
32
|
```tsx
|
|
38
33
|
import { Calendar, CalendarEvent } from "cleanhaus-calendar";
|
|
34
|
+
import { useState } from "react";
|
|
39
35
|
|
|
40
36
|
const events: CalendarEvent[] = [
|
|
41
37
|
{
|
|
@@ -48,24 +44,29 @@ const events: CalendarEvent[] = [
|
|
|
48
44
|
},
|
|
49
45
|
];
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
47
|
+
function App() {
|
|
48
|
+
const [date, setDate] = useState(new Date());
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Calendar
|
|
52
|
+
events={events}
|
|
53
|
+
view="month"
|
|
54
|
+
date={date}
|
|
55
|
+
onDateChange={setDate}
|
|
56
|
+
onEventPress={(event) => {
|
|
57
|
+
// Handle event press
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
58
62
|
```
|
|
59
63
|
|
|
60
|
-
### Next.js
|
|
64
|
+
### Next.js
|
|
61
65
|
|
|
62
|
-
**1.
|
|
63
|
-
```bash
|
|
64
|
-
npm install cleanhaus-calendar react react-native react-native-web react-native-reanimated dayjs calendarize
|
|
65
|
-
```
|
|
66
|
+
**1. Configure Next.js:**
|
|
66
67
|
|
|
67
|
-
**2. Update `next.config.ts`:**
|
|
68
68
|
```typescript
|
|
69
|
+
// next.config.ts
|
|
69
70
|
import type { NextConfig } from "next";
|
|
70
71
|
|
|
71
72
|
const withCalendar = require("cleanhaus-calendar/next-plugin");
|
|
@@ -77,7 +78,10 @@ const nextConfig: NextConfig = {
|
|
|
77
78
|
export default withCalendar(nextConfig);
|
|
78
79
|
```
|
|
79
80
|
|
|
80
|
-
**
|
|
81
|
+
**2. Development (Next.js 16+):**
|
|
82
|
+
|
|
83
|
+
Next.js 16+ uses Turbopack by default for development, but this package requires webpack configuration. Use the `--webpack` flag during development:
|
|
84
|
+
|
|
81
85
|
```json
|
|
82
86
|
{
|
|
83
87
|
"scripts": {
|
|
@@ -86,105 +90,69 @@ export default withCalendar(nextConfig);
|
|
|
86
90
|
}
|
|
87
91
|
```
|
|
88
92
|
|
|
89
|
-
**
|
|
90
|
-
```tsx
|
|
91
|
-
"use client"; // Required for App Router
|
|
92
|
-
|
|
93
|
-
import { Calendar, CalendarEvent } from "cleanhaus-calendar";
|
|
94
|
-
import { useState } from "react";
|
|
95
|
-
|
|
96
|
-
export default function MyPage() {
|
|
97
|
-
const [view, setView] = useState<ViewMode>("month");
|
|
98
|
-
const [date, setDate] = useState(new Date());
|
|
99
|
-
|
|
100
|
-
return (
|
|
101
|
-
<Calendar
|
|
102
|
-
events={events}
|
|
103
|
-
view={view}
|
|
104
|
-
date={date}
|
|
105
|
-
onDateChange={setDate}
|
|
106
|
-
onEventPress={(event) => console.log(event)}
|
|
107
|
-
onViewChange={setView}
|
|
108
|
-
/>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
**Note:** Next.js 16+ uses Turbopack by default. The plugin requires webpack, so use `--webpack` flag.
|
|
114
|
-
|
|
115
|
-
## 📖 Usage
|
|
93
|
+
**Note:** Production builds automatically use webpack, so no additional configuration is needed for deployment.
|
|
116
94
|
|
|
117
|
-
|
|
95
|
+
**3. Use the component:**
|
|
118
96
|
|
|
119
97
|
```tsx
|
|
98
|
+
"use client";
|
|
99
|
+
|
|
120
100
|
import { Calendar, CalendarEvent, ViewMode } from "cleanhaus-calendar";
|
|
121
101
|
import { useState } from "react";
|
|
122
102
|
|
|
123
|
-
|
|
124
|
-
{
|
|
125
|
-
id: "1",
|
|
126
|
-
eventId: "property-1",
|
|
127
|
-
title: "Booking",
|
|
128
|
-
start: new Date(2025, 0, 15, 10, 0),
|
|
129
|
-
end: new Date(2025, 0, 20, 14, 0),
|
|
130
|
-
meta: { type: "property" },
|
|
131
|
-
},
|
|
132
|
-
];
|
|
133
|
-
|
|
134
|
-
function MyCalendar() {
|
|
103
|
+
export default function CalendarPage() {
|
|
135
104
|
const [view, setView] = useState<ViewMode>("month");
|
|
136
105
|
const [date, setDate] = useState(new Date());
|
|
137
106
|
|
|
107
|
+
const events: CalendarEvent[] = [
|
|
108
|
+
{
|
|
109
|
+
id: "1",
|
|
110
|
+
eventId: "property-1",
|
|
111
|
+
title: "Booking",
|
|
112
|
+
start: new Date(2025, 0, 15, 10, 0),
|
|
113
|
+
end: new Date(2025, 0, 20, 14, 0),
|
|
114
|
+
meta: { type: "property" },
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
|
|
138
118
|
return (
|
|
139
119
|
<Calendar
|
|
140
120
|
events={events}
|
|
141
121
|
view={view}
|
|
142
122
|
date={date}
|
|
143
123
|
onDateChange={setDate}
|
|
144
|
-
onEventPress={(event) => console.log(event)}
|
|
145
124
|
onViewChange={setView}
|
|
125
|
+
onEventPress={(event) => {
|
|
126
|
+
// Handle event press
|
|
127
|
+
}}
|
|
146
128
|
/>
|
|
147
129
|
);
|
|
148
130
|
}
|
|
149
131
|
```
|
|
150
132
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
The package includes a default sparkle icon (✨) for cleaning events. Override it:
|
|
154
|
-
|
|
155
|
-
```tsx
|
|
156
|
-
import sparksIcon from "./assets/sparks.png";
|
|
157
|
-
|
|
158
|
-
<Calendar
|
|
159
|
-
events={events}
|
|
160
|
-
cleaningIcon={sparksIcon} // Optional: custom icon
|
|
161
|
-
// ... other props
|
|
162
|
-
/>
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
## 🔄 Data Format
|
|
133
|
+
## Data Format
|
|
166
134
|
|
|
167
135
|
Events must follow this structure:
|
|
168
136
|
|
|
169
137
|
```typescript
|
|
170
138
|
interface CalendarEvent {
|
|
171
|
-
id: string; //
|
|
172
|
-
eventId: string; //
|
|
173
|
-
title: string; //
|
|
174
|
-
start: Date; //
|
|
175
|
-
end: Date; //
|
|
139
|
+
id: string; // Unique identifier
|
|
140
|
+
eventId: string; // Group identifier (e.g., "property-1")
|
|
141
|
+
title: string; // Event title
|
|
142
|
+
start: Date; // Start date/time (must be Date object)
|
|
143
|
+
end: Date; // End date/time (must be Date object)
|
|
176
144
|
meta?: {
|
|
177
145
|
type?: "property" | "cleaning" | "service" | "otherService" | "unassigned";
|
|
178
|
-
jobTypeId?: number; // For cleaning: 1 = cleaning, 2-4 = service types
|
|
179
146
|
[key: string]: any;
|
|
180
147
|
};
|
|
181
148
|
}
|
|
182
149
|
```
|
|
183
150
|
|
|
184
|
-
|
|
151
|
+
**Important:** Always convert date strings to `Date` objects. The component does not accept string dates.
|
|
152
|
+
|
|
153
|
+
### Transforming API Data
|
|
185
154
|
|
|
186
155
|
```typescript
|
|
187
|
-
// Transform API response to CalendarEvent format
|
|
188
156
|
function transformApiEvents(apiData: ApiEvent[]): CalendarEvent[] {
|
|
189
157
|
return apiData.map((item) => ({
|
|
190
158
|
id: item.id.toString(),
|
|
@@ -199,77 +167,76 @@ function transformApiEvents(apiData: ApiEvent[]): CalendarEvent[] {
|
|
|
199
167
|
}
|
|
200
168
|
```
|
|
201
169
|
|
|
202
|
-
|
|
170
|
+
## API Reference
|
|
171
|
+
|
|
172
|
+
### Calendar Props
|
|
203
173
|
|
|
204
|
-
|
|
174
|
+
| Prop | Type | Required | Default | Description |
|
|
175
|
+
|------|------|----------|---------|-------------|
|
|
176
|
+
| `events` | `CalendarEvent[]` | Yes | - | Array of events to display |
|
|
177
|
+
| `date` | `Date` | Yes | - | Current date/month |
|
|
178
|
+
| `onDateChange` | `(date: Date) => void` | Yes | - | Called when date changes |
|
|
179
|
+
| `onEventPress` | `(event: CalendarEvent) => void` | Yes | - | Called when event is pressed |
|
|
180
|
+
| `view` | `"month" \| "week" \| "day"` | No | `"month"` | View mode |
|
|
181
|
+
| `onViewChange` | `(view: ViewMode) => void` | No | - | Called when view mode changes |
|
|
182
|
+
| `onDateTimeChange` | `(dateTime: Date) => void` | No | - | Unified handler for date+time changes (navigates to day view) |
|
|
183
|
+
| `isLoading` | `boolean` | No | `false` | Show loading spinner |
|
|
184
|
+
| `theme` | `Partial<CalendarTheme>` | No | - | Custom theme override |
|
|
185
|
+
| `availableProperties` | `Array<{ id: number }>` | No | - | Properties for consistent color assignment |
|
|
186
|
+
| `propertiesToShow` | `Array<{ id: number; name?: string }>` | No | - | Properties to show in DayView lanes |
|
|
187
|
+
| `propertyColors` | `string[]` | No | - | Custom property colors array |
|
|
188
|
+
| `propertyColorsDark` | `string[]` | No | - | Custom dark property colors array |
|
|
189
|
+
| `cleaningIcon` | `any` | No | - | Custom icon for cleaning events |
|
|
190
|
+
| `showFAB` | `boolean` | No | `false` | Show floating action button |
|
|
191
|
+
| `onFABPress` | `() => void` | No | - | FAB press handler |
|
|
192
|
+
| `fabStyle` | `ViewStyle` | No | - | Custom FAB styles |
|
|
193
|
+
| `renderFAB` | `() => React.ReactElement \| null` | No | - | Custom FAB component renderer |
|
|
194
|
+
| `autoScrollToNow` | `boolean` | No | `false` | Auto-scroll to current time in day view |
|
|
205
195
|
|
|
206
|
-
|
|
207
|
-
|------|------|----------|-------------|
|
|
208
|
-
| `events` | `CalendarEvent[]` | Yes | Array of events |
|
|
209
|
-
| `view` | `"month" \| "week" \| "day"` | No | View mode (default: `"month"`) |
|
|
210
|
-
| `date` | `Date` | Yes | Current date/month |
|
|
211
|
-
| `onDateChange` | `(date: Date) => void` | Yes | Date navigation handler |
|
|
212
|
-
| `onEventPress` | `(event: CalendarEvent) => void` | Yes | Event press handler |
|
|
213
|
-
| `onViewChange` | `(view: ViewMode) => void` | No | View mode change handler |
|
|
214
|
-
| `cleaningIcon` | `any` | No | Custom icon for cleaning events |
|
|
215
|
-
| `theme` | `CalendarTheme` | No | Custom theme |
|
|
216
|
-
| `availableProperties` | `Property[]` | No | Properties for color assignment |
|
|
196
|
+
### Exports
|
|
217
197
|
|
|
218
|
-
|
|
198
|
+
- `Calendar` - Main calendar component
|
|
199
|
+
- `CalendarEvent` - Event type
|
|
200
|
+
- `ViewMode` - View mode type (`"day" | "week" | "month"`)
|
|
201
|
+
- `MonthView`, `WeekView`, `DayView` - Individual view components
|
|
202
|
+
- `CalendarFAB` - Floating action button component
|
|
203
|
+
- Utilities: `dateUtils`, `weekDayUtils`, `theme`, `propertyColors`
|
|
204
|
+
- Hooks: `useSwipeGesture`
|
|
219
205
|
|
|
220
|
-
##
|
|
206
|
+
## Features
|
|
221
207
|
|
|
222
208
|
- **Month View**: Calendar grid with event bars and swipe navigation
|
|
223
209
|
- **Week View**: 7-day view with time-based positioning
|
|
224
210
|
- **Day View**: Single-day view with property lanes
|
|
225
211
|
- **Multi-day Events**: Continuous bars across day cells
|
|
226
|
-
- **Type-based Rendering**: Different styles for
|
|
227
|
-
- **
|
|
212
|
+
- **Type-based Rendering**: Different styles for different event types
|
|
213
|
+
- **Theme Customization**: Customizable colors and styles
|
|
214
|
+
- **Cross-platform**: Works on React Native (iOS/Android) and Web (Next.js)
|
|
215
|
+
- **SSR-safe**: Prevents hydration errors automatically
|
|
228
216
|
|
|
229
|
-
##
|
|
217
|
+
## Troubleshooting
|
|
230
218
|
|
|
231
|
-
|
|
232
|
-
-
|
|
233
|
-
-
|
|
234
|
-
-
|
|
219
|
+
**Events not appearing:**
|
|
220
|
+
- Ensure `start` and `end` are `Date` objects (not strings)
|
|
221
|
+
- Verify `eventId` is set correctly
|
|
222
|
+
- Check that events fall within the visible date range
|
|
235
223
|
|
|
236
|
-
|
|
224
|
+
**Next.js issues:**
|
|
225
|
+
- Use `--webpack` flag for development: `npm run dev -- --webpack`
|
|
226
|
+
- Clear Next.js cache: `rm -rf .next`
|
|
227
|
+
- Ensure `react-native-web` is installed
|
|
237
228
|
|
|
238
|
-
|
|
239
|
-
- ✅ Restart dev server: `npm run dev -- --webpack`
|
|
240
|
-
- ✅ Clear cache: `rm -rf .next`
|
|
229
|
+
- Verify the plugin is correctly applied in `next.config.ts`
|
|
241
230
|
|
|
242
|
-
**
|
|
243
|
-
-
|
|
244
|
-
-
|
|
245
|
-
|
|
246
|
-
**Turbopack error:**
|
|
247
|
-
- ✅ Use `npm run dev -- --webpack`
|
|
248
|
-
- ✅ Or add `turbopack: {}` to `next.config.ts`
|
|
249
|
-
|
|
250
|
-
## 📚 Props Reference
|
|
251
|
-
|
|
252
|
-
### Calendar Props
|
|
253
|
-
|
|
254
|
-
| Prop | Type | Required | Default | Description |
|
|
255
|
-
|------|------|----------|---------|-------------|
|
|
256
|
-
| `events` | `CalendarEvent[]` | Yes | - | Array of events |
|
|
257
|
-
| `view` | `ViewMode` | No | `"month"` | View mode |
|
|
258
|
-
| `date` | `Date` | Yes | - | Current date |
|
|
259
|
-
| `onDateChange` | `(date: Date) => void` | Yes | - | Date change handler |
|
|
260
|
-
| `onEventPress` | `(event: CalendarEvent) => void` | Yes | - | Event press handler |
|
|
261
|
-
| `onViewChange` | `(view: ViewMode) => void` | No | - | View change handler |
|
|
262
|
-
| `isLoading` | `boolean` | No | `false` | Show loading spinner |
|
|
263
|
-
| `theme` | `CalendarTheme` | No | - | Custom theme |
|
|
264
|
-
| `availableProperties` | `Property[]` | No | - | Properties for colors |
|
|
265
|
-
| `cleaningIcon` | `any` | No | - | Custom cleaning icon |
|
|
266
|
-
| `showFAB` | `boolean` | No | `false` | Show floating action button |
|
|
267
|
-
| `autoScrollToNow` | `boolean` | No | `false` | Auto-scroll to current time |
|
|
231
|
+
**Module not found errors:**
|
|
232
|
+
- Restart the development server
|
|
233
|
+
- Clear node_modules and reinstall: `rm -rf node_modules && npm install`
|
|
268
234
|
|
|
269
|
-
##
|
|
235
|
+
## License
|
|
270
236
|
|
|
271
237
|
MIT
|
|
272
238
|
|
|
273
|
-
|
|
239
|
+
## Links
|
|
274
240
|
|
|
275
|
-
|
|
241
|
+
- [Repository](https://github.com/cleanhaus/calendar-component)
|
|
242
|
+
- [Issues](https://github.com/cleanhaus/calendar-component/issues)
|