cleanhaus-calendar 1.0.1 → 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 +2 -1
- 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/package.json +13 -20
- package/src/Calendar.tsx +0 -295
- 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 -385
- 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 -300
- package/src/MonthView/types.ts +0 -39
- package/src/MonthView/utils.ts +0 -260
- 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 -127
- 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/dayjs.d.ts +0 -25
- package/src/types/react-native.d.ts +0 -55
- 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 -30
- 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/validation.ts +0 -203
- package/src/utils/weekDayUtils.ts +0 -75
- package/src/web/index.ts +0 -28
- package/tsup.config.ts +0 -24
- /package/{src/shared/sparks.png → dist/sparks-EDXND3ZD.png} +0 -0
package/README.md
CHANGED
|
@@ -212,7 +212,7 @@ function transformApiEvents(apiData: ApiEvent[]): CalendarEvent[] {
|
|
|
212
212
|
- **Type-based Rendering**: Different styles for different event types
|
|
213
213
|
- **Theme Customization**: Customizable colors and styles
|
|
214
214
|
- **Cross-platform**: Works on React Native (iOS/Android) and Web (Next.js)
|
|
215
|
-
- **SSR-safe**:
|
|
215
|
+
- **SSR-safe**: Prevents hydration errors automatically
|
|
216
216
|
|
|
217
217
|
## Troubleshooting
|
|
218
218
|
|
|
@@ -225,6 +225,7 @@ function transformApiEvents(apiData: ApiEvent[]): CalendarEvent[] {
|
|
|
225
225
|
- Use `--webpack` flag for development: `npm run dev -- --webpack`
|
|
226
226
|
- Clear Next.js cache: `rm -rf .next`
|
|
227
227
|
- Ensure `react-native-web` is installed
|
|
228
|
+
|
|
228
229
|
- Verify the plugin is correctly applied in `next.config.ts`
|
|
229
230
|
|
|
230
231
|
**Module not found errors:**
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import * as react_native from 'react-native';
|
|
4
|
+
import { ViewStyle, PanResponderInstance } from 'react-native';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Calendar Theme Interface
|
|
8
|
+
* Scalable theme system for calendar component
|
|
9
|
+
*/
|
|
10
|
+
interface CalendarTheme {
|
|
11
|
+
primary: string;
|
|
12
|
+
secondary: string;
|
|
13
|
+
service: string;
|
|
14
|
+
alert: string;
|
|
15
|
+
today: string;
|
|
16
|
+
text: string;
|
|
17
|
+
textSecondary: string;
|
|
18
|
+
background: string;
|
|
19
|
+
border: string;
|
|
20
|
+
borderLight: string;
|
|
21
|
+
statusComplete: string;
|
|
22
|
+
statusInProgress: string;
|
|
23
|
+
statusScheduled: string;
|
|
24
|
+
statusIssue: string;
|
|
25
|
+
alertError: string;
|
|
26
|
+
alertWarning: string;
|
|
27
|
+
eventBookingBg: string;
|
|
28
|
+
eventServiceBg: string;
|
|
29
|
+
eventDefaultBg: string;
|
|
30
|
+
eventBorder: string;
|
|
31
|
+
errorBoundaryBg: string;
|
|
32
|
+
errorBoundaryText: string;
|
|
33
|
+
errorBoundaryError: string;
|
|
34
|
+
errorBoundaryButtonBg: string;
|
|
35
|
+
errorBoundaryButtonText: string;
|
|
36
|
+
[key: string]: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Default Calendar Theme
|
|
40
|
+
* Internal default theme that works out of the box
|
|
41
|
+
* Uses exact color codes from CleanHaus design system
|
|
42
|
+
*/
|
|
43
|
+
declare const DEFAULT_THEME: CalendarTheme;
|
|
44
|
+
/**
|
|
45
|
+
* Merge user theme with default theme
|
|
46
|
+
* @param userTheme - Partial theme override from props
|
|
47
|
+
* @returns Complete theme object
|
|
48
|
+
*/
|
|
49
|
+
declare function mergeTheme(userTheme?: Partial<CalendarTheme>): CalendarTheme;
|
|
50
|
+
/**
|
|
51
|
+
* Event Rendering Configuration
|
|
52
|
+
* Defines how different event types should be rendered in the calendar
|
|
53
|
+
* Based on event TYPE, not duration
|
|
54
|
+
*/
|
|
55
|
+
interface EventRenderConfig {
|
|
56
|
+
opacity: number;
|
|
57
|
+
showTitle: boolean;
|
|
58
|
+
showArrow: boolean;
|
|
59
|
+
showIcon: boolean;
|
|
60
|
+
showBorder: boolean;
|
|
61
|
+
titleOnFirstWeekOnly: boolean;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get rendering configuration for event based on its TYPE
|
|
65
|
+
* This determines opacity, title visibility, arrows, etc.
|
|
66
|
+
* @param event - The calendar event
|
|
67
|
+
* @returns EventRenderConfig object with rendering rules
|
|
68
|
+
*/
|
|
69
|
+
declare function getEventRenderingConfig(event: CalendarEvent): EventRenderConfig;
|
|
70
|
+
/**
|
|
71
|
+
* Get color for calendar event based on theme and event type
|
|
72
|
+
* @param event - The calendar event
|
|
73
|
+
* @param theme - The current theme
|
|
74
|
+
* @param availableProperties - Optional array of properties for consistent coloring
|
|
75
|
+
* @param propertyColors - Optional array of property colors to cycle through
|
|
76
|
+
* @returns Color string for the event
|
|
77
|
+
*/
|
|
78
|
+
declare function getCalendarEventColor(event: CalendarEvent, theme: CalendarTheme, availableProperties?: Array<{
|
|
79
|
+
id: number;
|
|
80
|
+
}>, propertyColors?: string[], propertyColorsDark?: string[]): string;
|
|
81
|
+
/**
|
|
82
|
+
* Check if event spans multiple days (date boundaries)
|
|
83
|
+
* NOTE: This is kept for backward compatibility but rendering logic
|
|
84
|
+
* now uses TYPE-based approach via getEventRenderingConfig()
|
|
85
|
+
*/
|
|
86
|
+
declare function isMultiDayEvent(event: CalendarEvent): boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Convert hex color to rgba with opacity
|
|
89
|
+
* @param hexColor - Hex color string (e.g., "#00BCD4")
|
|
90
|
+
* @param opacity - Opacity value (0-1)
|
|
91
|
+
*/
|
|
92
|
+
declare function hexToRgba(hexColor: string, opacity: number): string;
|
|
93
|
+
/**
|
|
94
|
+
* Get event background color with appropriate opacity
|
|
95
|
+
* @param event - The calendar event
|
|
96
|
+
* @param theme - The current theme
|
|
97
|
+
* @param availableProperties - Optional array of properties for consistent coloring
|
|
98
|
+
* @param propertyColors - Optional array of property colors to cycle through
|
|
99
|
+
* @returns Background color with opacity
|
|
100
|
+
*/
|
|
101
|
+
declare function getEventBackgroundColor(event: CalendarEvent, theme: CalendarTheme, availableProperties?: Array<{
|
|
102
|
+
id: number;
|
|
103
|
+
}>, propertyColors?: string[], propertyColorsDark?: string[]): string;
|
|
104
|
+
|
|
105
|
+
type ViewMode = "day" | "week" | "month";
|
|
106
|
+
interface CalendarEvent {
|
|
107
|
+
id: string;
|
|
108
|
+
eventId: string;
|
|
109
|
+
title: string;
|
|
110
|
+
start: Date;
|
|
111
|
+
end: Date;
|
|
112
|
+
meta?: {
|
|
113
|
+
type?: "property" | "cleaning" | "service" | "otherService" | "unassigned";
|
|
114
|
+
source?: string;
|
|
115
|
+
status?: string;
|
|
116
|
+
color?: string;
|
|
117
|
+
[key: string]: any;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
interface CalendarProps {
|
|
121
|
+
events: CalendarEvent[];
|
|
122
|
+
view?: ViewMode;
|
|
123
|
+
date: Date;
|
|
124
|
+
onDateChange: (date: Date) => void;
|
|
125
|
+
onEventPress: (event: CalendarEvent) => void;
|
|
126
|
+
onViewChange?: (view: ViewMode) => void;
|
|
127
|
+
onDateTimeChange?: (dateTime: Date) => void;
|
|
128
|
+
isLoading?: boolean;
|
|
129
|
+
availableProperties?: Array<{
|
|
130
|
+
id: number;
|
|
131
|
+
}>;
|
|
132
|
+
propertiesToShow?: Array<{
|
|
133
|
+
id: number;
|
|
134
|
+
name?: string;
|
|
135
|
+
}>;
|
|
136
|
+
theme?: Partial<CalendarTheme>;
|
|
137
|
+
autoScrollToNow?: boolean;
|
|
138
|
+
propertyColors?: string[];
|
|
139
|
+
propertyColorsDark?: string[];
|
|
140
|
+
showFAB?: boolean;
|
|
141
|
+
onFABPress?: () => void;
|
|
142
|
+
fabStyle?: react_native.ViewStyle;
|
|
143
|
+
renderFAB?: () => React.ReactElement | null;
|
|
144
|
+
cleaningIcon?: any;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
declare const CustomCalendar: React__default.FC<CalendarProps>;
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* MonthView-specific types
|
|
151
|
+
*/
|
|
152
|
+
interface MonthViewProps {
|
|
153
|
+
events: CalendarEvent[];
|
|
154
|
+
targetDate: Date;
|
|
155
|
+
containerHeight: number;
|
|
156
|
+
onPressEvent?: (event: CalendarEvent) => void;
|
|
157
|
+
onPressCell?: (date: Date) => void;
|
|
158
|
+
onShowMore?: (date: Date) => void;
|
|
159
|
+
onMonthChange?: (date: Date) => void;
|
|
160
|
+
maxVisibleRows?: number;
|
|
161
|
+
swipeEnabled?: boolean;
|
|
162
|
+
theme: CalendarTheme;
|
|
163
|
+
availableProperties?: Array<{
|
|
164
|
+
id: number;
|
|
165
|
+
}>;
|
|
166
|
+
propertyColors?: string[];
|
|
167
|
+
propertyColorsDark?: string[];
|
|
168
|
+
cleaningIcon?: any;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* MonthView Component
|
|
173
|
+
*
|
|
174
|
+
* A custom month calendar view with horizontal time-positioned events.
|
|
175
|
+
* Events are positioned based on their exact start/end times within each day cell.
|
|
176
|
+
* Events with the same eventId appear in the same row across all weeks.
|
|
177
|
+
*
|
|
178
|
+
* Features:
|
|
179
|
+
* - Horizontal time positioning (exact hour/minute)
|
|
180
|
+
* - Multi-day event spanning with fractional times
|
|
181
|
+
* - Global row assignment by eventId
|
|
182
|
+
* - Configurable max visible rows
|
|
183
|
+
* - Touch handlers for events and date cells
|
|
184
|
+
* - Swipe gestures for month navigation (left = next, right = previous)
|
|
185
|
+
*
|
|
186
|
+
* @example
|
|
187
|
+
* ```tsx
|
|
188
|
+
* const [currentDate, setCurrentDate] = useState(new Date());
|
|
189
|
+
*
|
|
190
|
+
* <MonthView
|
|
191
|
+
* events={events}
|
|
192
|
+
* targetDate={currentDate}
|
|
193
|
+
* containerHeight={600}
|
|
194
|
+
* onPressEvent={(event) => console.log(event)}
|
|
195
|
+
* onPressCell={(date) => console.log(date)}
|
|
196
|
+
* onMonthChange={(newDate) => setCurrentDate(newDate)}
|
|
197
|
+
* maxVisibleRows={3}
|
|
198
|
+
* swipeEnabled={true}
|
|
199
|
+
* />
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
declare const MonthView: React$1.FC<MonthViewProps>;
|
|
203
|
+
|
|
204
|
+
interface DayViewProps {
|
|
205
|
+
events: CalendarEvent[];
|
|
206
|
+
targetDate: Date;
|
|
207
|
+
onEventPress: (event: CalendarEvent) => void;
|
|
208
|
+
theme: CalendarTheme;
|
|
209
|
+
availableProperties?: Array<{
|
|
210
|
+
id: number;
|
|
211
|
+
name?: string;
|
|
212
|
+
}>;
|
|
213
|
+
propertiesToShow?: Array<{
|
|
214
|
+
id: number;
|
|
215
|
+
name?: string;
|
|
216
|
+
}>;
|
|
217
|
+
autoScrollToNow?: boolean;
|
|
218
|
+
propertyColors?: string[];
|
|
219
|
+
propertyColorsDark?: string[];
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* DayView Component
|
|
223
|
+
*
|
|
224
|
+
* A vertical time-based calendar view with:
|
|
225
|
+
* - Always-visible 24-hour timeline on the left
|
|
226
|
+
* - Data-dependent property swim lanes with horizontal scrolling
|
|
227
|
+
* - Synchronized header and content scrolling
|
|
228
|
+
* - Protected by error boundary for robust error handling
|
|
229
|
+
*/
|
|
230
|
+
declare const DayView: React__default.FC<DayViewProps>;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* WeekView-specific types
|
|
234
|
+
*/
|
|
235
|
+
interface WeekViewProps {
|
|
236
|
+
events: CalendarEvent[];
|
|
237
|
+
targetDate: Date;
|
|
238
|
+
onEventPress: (event: CalendarEvent) => void;
|
|
239
|
+
onShowMore?: (date: Date) => void;
|
|
240
|
+
onPressCell?: (date: Date, time: Date) => void;
|
|
241
|
+
theme: CalendarTheme;
|
|
242
|
+
availableProperties?: Array<{
|
|
243
|
+
id: number;
|
|
244
|
+
name?: string;
|
|
245
|
+
}>;
|
|
246
|
+
propertyColors?: string[];
|
|
247
|
+
propertyColorsDark?: string[];
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* WeekView Component
|
|
252
|
+
*
|
|
253
|
+
* A compact 7-day week view with:
|
|
254
|
+
* - Time column on the left (reused from DayView)
|
|
255
|
+
* - 7 day columns with time-based event positioning
|
|
256
|
+
* - Property indicator bars at the top
|
|
257
|
+
* - Max 2 events per time slot, with "+X more" overflow
|
|
258
|
+
* - Clicking "+X more" switches to day view
|
|
259
|
+
*/
|
|
260
|
+
declare const WeekView: React__default.FC<WeekViewProps>;
|
|
261
|
+
|
|
262
|
+
interface CalendarFABProps {
|
|
263
|
+
/**
|
|
264
|
+
* Whether the FAB should be visible
|
|
265
|
+
* @default true
|
|
266
|
+
*/
|
|
267
|
+
visible?: boolean;
|
|
268
|
+
/**
|
|
269
|
+
* Callback when FAB is pressed
|
|
270
|
+
*/
|
|
271
|
+
onPress: () => void;
|
|
272
|
+
/**
|
|
273
|
+
* Custom icon component (optional)
|
|
274
|
+
* @default Plus icon (+)
|
|
275
|
+
*/
|
|
276
|
+
icon?: React__default.ReactNode;
|
|
277
|
+
/**
|
|
278
|
+
* Theme object for colors (optional)
|
|
279
|
+
* Passed from Calendar component
|
|
280
|
+
*/
|
|
281
|
+
theme?: CalendarTheme;
|
|
282
|
+
/**
|
|
283
|
+
* Additional styles for the FAB container
|
|
284
|
+
* Use this to override size, colors, position, etc.
|
|
285
|
+
*/
|
|
286
|
+
style?: ViewStyle;
|
|
287
|
+
/**
|
|
288
|
+
* Test ID for testing purposes
|
|
289
|
+
*/
|
|
290
|
+
testID?: string;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Straightforward Floating Action Button for Calendar views
|
|
294
|
+
*
|
|
295
|
+
* Works out of the box with sensible defaults.
|
|
296
|
+
* Uses theme colors when available, falls back to defaults.
|
|
297
|
+
* Use the style prop to customize size, colors, position, etc.
|
|
298
|
+
*
|
|
299
|
+
* Features:
|
|
300
|
+
* - Fully independent (uses only React Native core)
|
|
301
|
+
* - Theme-aware (uses calendar theme colors when available)
|
|
302
|
+
* - Sensible defaults (works without any props except onPress)
|
|
303
|
+
* - Single style prop for all customization
|
|
304
|
+
* - Cross-platform shadow support (iOS & Android)
|
|
305
|
+
* - Follows React Native best practices
|
|
306
|
+
*/
|
|
307
|
+
declare const CalendarFAB: React__default.FC<CalendarFABProps>;
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Shared date utilities for calendar components
|
|
311
|
+
* Uses dayjs for consistent, reliable date operations across all views
|
|
312
|
+
*/
|
|
313
|
+
declare const MINUTES_IN_DAY = 1440;
|
|
314
|
+
declare const HOURS_IN_DAY = 24;
|
|
315
|
+
/**
|
|
316
|
+
* Format a date to a readable string
|
|
317
|
+
* @param date - The date to format
|
|
318
|
+
* @param options - Intl.DateTimeFormatOptions
|
|
319
|
+
* @returns Formatted date string
|
|
320
|
+
*/
|
|
321
|
+
declare function formatDate(date: Date, options?: Intl.DateTimeFormatOptions): string;
|
|
322
|
+
/**
|
|
323
|
+
* Navigate to previous/next period based on view mode
|
|
324
|
+
* Uses dayjs to avoid mutating the input date
|
|
325
|
+
* @param currentDate - Current date
|
|
326
|
+
* @param direction - Direction to navigate
|
|
327
|
+
* @param viewMode - Calendar view mode
|
|
328
|
+
* @returns New date (immutable)
|
|
329
|
+
*/
|
|
330
|
+
declare function navigateDate(currentDate: Date, direction: "prev" | "next", viewMode: "day" | "week" | "month"): Date;
|
|
331
|
+
/**
|
|
332
|
+
* Get date label for display based on view mode
|
|
333
|
+
* @param date - The date
|
|
334
|
+
* @param viewMode - Calendar view mode
|
|
335
|
+
* @returns Formatted label string
|
|
336
|
+
*/
|
|
337
|
+
declare function getDateLabel(date: Date, viewMode: "day" | "week" | "month"): string;
|
|
338
|
+
/**
|
|
339
|
+
* Get start of day (00:00:00.000) using dayjs
|
|
340
|
+
* @param date - The date
|
|
341
|
+
* @returns Date object at start of day
|
|
342
|
+
*/
|
|
343
|
+
declare function getDayStart(date: Date): Date;
|
|
344
|
+
/**
|
|
345
|
+
* Get end of day (23:59:59.999) using dayjs
|
|
346
|
+
* @param date - The date
|
|
347
|
+
* @returns Date object at end of day
|
|
348
|
+
*/
|
|
349
|
+
declare function getDayEnd(date: Date): Date;
|
|
350
|
+
/**
|
|
351
|
+
* Check if two dates are the same day
|
|
352
|
+
* @param date1 - First date
|
|
353
|
+
* @param date2 - Second date
|
|
354
|
+
* @returns True if same day
|
|
355
|
+
*/
|
|
356
|
+
declare function isSameDay(date1: Date, date2: Date): boolean;
|
|
357
|
+
/**
|
|
358
|
+
* Check if date is today
|
|
359
|
+
* @param date - The date to check
|
|
360
|
+
* @returns True if date is today
|
|
361
|
+
*/
|
|
362
|
+
declare function isToday(date: Date): boolean;
|
|
363
|
+
/**
|
|
364
|
+
* Format time in AM/PM or 24-hour format
|
|
365
|
+
* @param date - The date to format
|
|
366
|
+
* @param use24Hour - Use 24-hour format (default: false)
|
|
367
|
+
* @returns Formatted time string
|
|
368
|
+
*/
|
|
369
|
+
declare function formatTime(date: Date, use24Hour?: boolean): string;
|
|
370
|
+
/**
|
|
371
|
+
* Format an hour label without minutes, matching calendar rail (e.g., 12AM, 1PM)
|
|
372
|
+
* @param hour - 0..23
|
|
373
|
+
* @param use24Hour - Use 24-hour format (default: false)
|
|
374
|
+
*/
|
|
375
|
+
declare function formatHourLabel(hour: number, use24Hour?: boolean): string;
|
|
376
|
+
/**
|
|
377
|
+
* Format time range
|
|
378
|
+
* @param start - Start date
|
|
379
|
+
* @param end - End date
|
|
380
|
+
* @param use24Hour - Use 24-hour format (default: false)
|
|
381
|
+
* @returns Formatted time range string
|
|
382
|
+
*/
|
|
383
|
+
declare function formatTimeRange(start: Date, end: Date, use24Hour?: boolean): string;
|
|
384
|
+
/**
|
|
385
|
+
* Get duration in minutes between two dates
|
|
386
|
+
* @param start - Start date
|
|
387
|
+
* @param end - End date
|
|
388
|
+
* @returns Duration in minutes
|
|
389
|
+
*/
|
|
390
|
+
declare function getDurationMinutes(start: Date, end: Date): number;
|
|
391
|
+
/**
|
|
392
|
+
* Get duration in hours between two dates
|
|
393
|
+
* @param start - Start date
|
|
394
|
+
* @param end - End date
|
|
395
|
+
* @returns Duration in hours (decimal)
|
|
396
|
+
*/
|
|
397
|
+
declare function getDurationHours(start: Date, end: Date): number;
|
|
398
|
+
/**
|
|
399
|
+
* Clamp a date to be within day boundaries
|
|
400
|
+
* Returns new date if clamping occurred, original if within bounds
|
|
401
|
+
* @param date - Date to clamp
|
|
402
|
+
* @param dayStart - Start of day boundary
|
|
403
|
+
* @param dayEnd - End of day boundary
|
|
404
|
+
* @returns Clamped date
|
|
405
|
+
*/
|
|
406
|
+
declare function clampToDay(date: Date, dayStart: Date, dayEnd: Date): Date;
|
|
407
|
+
/**
|
|
408
|
+
* Check if an event overlaps with a specific day
|
|
409
|
+
* @param eventStart - Event start date
|
|
410
|
+
* @param eventEnd - Event end date
|
|
411
|
+
* @param targetDate - Target day to check
|
|
412
|
+
* @returns True if event overlaps with the day
|
|
413
|
+
*/
|
|
414
|
+
declare function eventOverlapsDay(eventStart: Date, eventEnd: Date, targetDate: Date): boolean;
|
|
415
|
+
/**
|
|
416
|
+
* Set time on a date without mutating the original
|
|
417
|
+
* @param date - Base date
|
|
418
|
+
* @param hours - Hours (0-23)
|
|
419
|
+
* @param minutes - Minutes (0-59), default: 0
|
|
420
|
+
* @param seconds - Seconds (0-59), default: 0
|
|
421
|
+
* @returns New Date with specified time
|
|
422
|
+
*/
|
|
423
|
+
declare function setTimeOnDate(date: Date, hours: number, minutes?: number, seconds?: number): Date;
|
|
424
|
+
/**
|
|
425
|
+
* Get date with time from click position in week view
|
|
426
|
+
* @param date - Base date
|
|
427
|
+
* @param yPosition - Y coordinate from touch event
|
|
428
|
+
* @returns Date with calculated time
|
|
429
|
+
*/
|
|
430
|
+
declare function getTimeFromPosition(date: Date, yPosition: number): Date;
|
|
431
|
+
/**
|
|
432
|
+
* Get date for cell press - current time if today, start of day otherwise
|
|
433
|
+
* @param pressedDate - The date that was pressed
|
|
434
|
+
* @returns Date with appropriate time
|
|
435
|
+
*/
|
|
436
|
+
declare function getCellPressDateTime(pressedDate: Date): Date;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* Week and Day View utilities
|
|
440
|
+
* These functions are used for customizing react-native-big-calendar Week/Day views
|
|
441
|
+
*/
|
|
442
|
+
/**
|
|
443
|
+
* Get color for event based on its type
|
|
444
|
+
* Used for Week/Day view event styling
|
|
445
|
+
*/
|
|
446
|
+
declare function getEventColor(event: CalendarEvent, propertyColors: string[], eventTypeColors: Record<string, string>, availableProperties?: Array<{
|
|
447
|
+
id: number;
|
|
448
|
+
}>): string;
|
|
449
|
+
/**
|
|
450
|
+
* Calculate time-based horizontal position for events in Week/Day views
|
|
451
|
+
* Returns position as percentage of day (0-100%)
|
|
452
|
+
*/
|
|
453
|
+
declare function getTimeBasedPosition(startTime: Date, endTime: Date): {
|
|
454
|
+
left: number;
|
|
455
|
+
width: number;
|
|
456
|
+
};
|
|
457
|
+
/**
|
|
458
|
+
* Normalize event data to CalendarEvent format
|
|
459
|
+
* Handles various input formats from react-native-big-calendar
|
|
460
|
+
*/
|
|
461
|
+
declare function normalizeCalendarEvent(event: any): CalendarEvent;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Property color palette - extracted for standalone package
|
|
465
|
+
* These colors cycle through properties for consistent coloring
|
|
466
|
+
* Property colors can be customized via Calendar props
|
|
467
|
+
*/
|
|
468
|
+
/**
|
|
469
|
+
* Default property color palette using all 7 secondary colors
|
|
470
|
+
* These colors cycle through properties: property 0 gets color 0, property 7 gets color 0 again
|
|
471
|
+
* Used consistently across calendar, filters, and headers
|
|
472
|
+
*/
|
|
473
|
+
declare const DEFAULT_PROPERTY_COLORS: string[];
|
|
474
|
+
/**
|
|
475
|
+
* Default darker property colors for other services (Landscaper, Pool/Spa Tech, Contractors)
|
|
476
|
+
* Uses 700 shade from each color palette for darker appearance
|
|
477
|
+
* These colors correspond to DEFAULT_PROPERTY_COLORS by index
|
|
478
|
+
*/
|
|
479
|
+
declare const DEFAULT_PROPERTY_COLORS_DARK: string[];
|
|
480
|
+
/**
|
|
481
|
+
* Legacy exports for backward compatibility
|
|
482
|
+
* @deprecated Use DEFAULT_PROPERTY_COLORS instead
|
|
483
|
+
*/
|
|
484
|
+
declare const PROPERTY_COLORS: string[];
|
|
485
|
+
declare const PROPERTY_COLORS_DARK: string[];
|
|
486
|
+
/**
|
|
487
|
+
* Get property color by index with fallback
|
|
488
|
+
* @param index - The index of the property
|
|
489
|
+
* @param colors - Optional custom color array, defaults to DEFAULT_PROPERTY_COLORS
|
|
490
|
+
* @returns The color for the property
|
|
491
|
+
*/
|
|
492
|
+
declare function getPropertyColor(index: number, colors?: string[]): string;
|
|
493
|
+
/**
|
|
494
|
+
* Get property color by property ID from available properties list
|
|
495
|
+
* @param propertyId - The ID of the property
|
|
496
|
+
* @param availableProperties - Array of available properties
|
|
497
|
+
* @param colors - Optional custom color array, defaults to DEFAULT_PROPERTY_COLORS
|
|
498
|
+
* @returns The color for the property
|
|
499
|
+
*/
|
|
500
|
+
declare function getPropertyColorById(propertyId: number, availableProperties: Array<{
|
|
501
|
+
id?: number;
|
|
502
|
+
entityId?: number;
|
|
503
|
+
}>, colors?: string[]): string;
|
|
504
|
+
|
|
505
|
+
/**
|
|
506
|
+
* Configuration options for swipe gesture detection
|
|
507
|
+
*/
|
|
508
|
+
interface SwipeGestureConfig {
|
|
509
|
+
/** Minimum horizontal distance (in pixels) to trigger a swipe. Default: 50 */
|
|
510
|
+
threshold?: number;
|
|
511
|
+
/** Callback triggered when user swipes left (dx < -threshold) */
|
|
512
|
+
onSwipeLeft?: () => void;
|
|
513
|
+
/** Callback triggered when user swipes right (dx > threshold) */
|
|
514
|
+
onSwipeRight?: () => void;
|
|
515
|
+
/** Enable/disable swipe gesture detection. Default: true */
|
|
516
|
+
enabled?: boolean;
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Custom hook for detecting horizontal swipe gestures using React Native's PanResponder.
|
|
520
|
+
*
|
|
521
|
+
* Based on react-native-big-calendar's implementation, this hook provides
|
|
522
|
+
* a simple way to add swipe-to-navigate functionality to calendar views.
|
|
523
|
+
*
|
|
524
|
+
* **Web Compatibility**: Swipe gestures are automatically disabled on web platform.
|
|
525
|
+
* Use navigation buttons or other UI controls for web users.
|
|
526
|
+
*
|
|
527
|
+
* @param config - Configuration object with swipe callbacks and options
|
|
528
|
+
* @returns PanResponderInstance to be spread onto a View component
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```tsx
|
|
532
|
+
* const panResponder = useSwipeGesture({
|
|
533
|
+
* onSwipeLeft: () => goToNextMonth(),
|
|
534
|
+
* onSwipeRight: () => goToPrevMonth(),
|
|
535
|
+
* threshold: 50,
|
|
536
|
+
* });
|
|
537
|
+
*
|
|
538
|
+
* return (
|
|
539
|
+
* <View {...panResponder.panHandlers}>
|
|
540
|
+
* {/* Calendar content *\/}
|
|
541
|
+
* </View>
|
|
542
|
+
* );
|
|
543
|
+
* ```
|
|
544
|
+
*/
|
|
545
|
+
declare function useSwipeGesture(config: SwipeGestureConfig): PanResponderInstance;
|
|
546
|
+
|
|
547
|
+
export { CustomCalendar as Calendar, type CalendarEvent, CalendarFAB, type CalendarFABProps, type CalendarProps, type CalendarTheme, DEFAULT_PROPERTY_COLORS, DEFAULT_PROPERTY_COLORS_DARK, DEFAULT_THEME, DayView, type DayViewProps, type EventRenderConfig, HOURS_IN_DAY, MINUTES_IN_DAY, MonthView, type MonthViewProps, PROPERTY_COLORS, PROPERTY_COLORS_DARK, type SwipeGestureConfig, type ViewMode, WeekView, type WeekViewProps, clampToDay, eventOverlapsDay, formatDate, formatHourLabel, formatTime, formatTimeRange, getCalendarEventColor, getCellPressDateTime, getDateLabel, getDayEnd, getDayStart, getDurationHours, getDurationMinutes, getEventBackgroundColor, getEventColor, getEventRenderingConfig, getPropertyColor, getPropertyColorById, getTimeBasedPosition, getTimeFromPosition, hexToRgba, isMultiDayEvent, isSameDay, isToday, mergeTheme, navigateDate, normalizeCalendarEvent, setTimeOnDate, useSwipeGesture };
|