regular-calendar 0.0.1

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 regular-calendar 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 ADDED
@@ -0,0 +1,337 @@
1
+ # regular-calendar 📅
2
+
3
+ A generic, high-performance facility schedule management component for React.
4
+ Designed to be domain-agnostic, customizable, and easy to integrate with any backend.
5
+
6
+ ![License](https://img.shields.io/badge/license-MIT-blue.svg)
7
+ ![TypeScript](https://img.shields.io/badge/TypeScript-Ready-blue)
8
+
9
+ ## Screenshots 📸
10
+
11
+ | Facility Schedule | Regular Calendar |
12
+ |-------------------|------------------|
13
+ | ![Facility Schedule](./assets/facilitySchyedule.png) | ![Regular Calendar](./assets/regularCalendar.png) |
14
+
15
+ ## Features 🚀
16
+
17
+ - **Generic & Domain-Agnostic**: Manage generic "Resources" (beds, rooms, machines) and "Events". No baked-in business logic.
18
+ - **Multiple Views**: Seamlessly switch between **Day**, **Week**, and **Month** views.
19
+ - **Interactive Scheduling**:
20
+ - Drag & Drop support (powered by `@dnd-kit`).
21
+ - Resizable events.
22
+ - One-click slot creation.
23
+ - **Performance**: Virtualized rendering for handling large numbers of resources.
24
+ - **Customizable**: Inject your own Event Modal or use the built-in simplified form.
25
+ - **Zero External Styles**: Uses locally scoped generic UI components for maximum portability.
26
+
27
+ ## Installation 📦
28
+
29
+ ```bash
30
+ pnpm install regular-calendar
31
+ ```
32
+
33
+ ### Peer Dependencies
34
+ Ensure you have the following installed:
35
+
36
+ ```bash
37
+ pnpm install react react-dom date-fns
38
+ ```
39
+
40
+ ## Quick Start 🏃‍♂️
41
+
42
+ 1. **Import the component and styles**:
43
+
44
+ ```tsx
45
+ import { FacilitySchedule } from 'regular-calendar';
46
+ import 'regular-calendar/styles';
47
+ ```
48
+
49
+ 2. **Render the schedule**:
50
+
51
+ ```tsx
52
+ import { useState } from 'react';
53
+ import { FacilitySchedule } from 'regular-calendar';
54
+ import 'regular-calendar/styles';
55
+
56
+ function App() {
57
+ const [events, setEvents] = useState([
58
+ {
59
+ id: 'e1',
60
+ resourceId: 'r1',
61
+ title: 'Meeting',
62
+ startDate: new Date('2024-01-01T09:00:00'),
63
+ endDate: new Date('2024-01-01T10:00:00'),
64
+ color: '#3b82f6'
65
+ }
66
+ ]);
67
+
68
+ const resources = [
69
+ { id: 'r1', name: 'Room A', groupId: 'g1', order: 1 }
70
+ ];
71
+
72
+ const groups = [
73
+ { id: 'g1', name: 'Conference Center' }
74
+ ];
75
+
76
+ return (
77
+ <div style={{ height: '100vh' }}>
78
+ <FacilitySchedule
79
+ events={events}
80
+ resources={resources}
81
+ groups={groups}
82
+ settings={{
83
+ weekStartsOn: 1, // Monday
84
+ startTime: '08:00',
85
+ endTime: '18:00',
86
+ defaultDuration: 60,
87
+ closedDays: [0], // Sunday
88
+ }}
89
+ onEventCreate={(data) => console.log('Create:', data)}
90
+ onEventUpdate={(id, data) => console.log('Update:', id, data)}
91
+ />
92
+ </div>
93
+ );
94
+ }
95
+ ```
96
+
97
+ ## API Reference 📚
98
+
99
+ ### `FacilitySchedule` Props
100
+
101
+ | Prop | Type | Description |
102
+ |------|------|-------------|
103
+ | `events` | `ScheduleEvent[]` | Array of event objects to display. |
104
+ | `resources` | `Resource[]` | Array of resources (rows/columns). |
105
+ | `groups` | `ResourceGroup[]` | Optional grouping for resources. |
106
+ | `settings` | `FacilityScheduleSettings` | Configuration for time ranges, grid size, etc. |
107
+ | `isLoading` | `boolean` | Shows a loading state if true. |
108
+ | `className` | `string` | Additional CSS classes for the container. |
109
+ | `components` | `{ EventModal?: React.ComponentType }` | Inject custom components (e.g. your own Event creation modal). |
110
+
111
+ ### Callbacks
112
+
113
+ | Callback | Signature | Description |
114
+ |----------|-----------|-------------|
115
+ | `onEventCreate` | `(data: EventFormData) => void` | Called when a new event is saved. |
116
+ | `onEventUpdate` | `(id: string, data: EventFormData) => void` | Called when an existing event is edited. |
117
+ | `onEventDelete` | `(id: string) => void` | Called when an event is deleted. |
118
+ | `onEventClick` | `(event: ScheduleEvent) => void` | Called when an event bar is clicked. |
119
+ | `onDateChange` | `(date: Date) => void` | Called when the current view date changes. |
120
+
121
+ ### Data Types
122
+
123
+ **ScheduleEvent**
124
+ ```typescript
125
+ interface ScheduleEvent {
126
+ id: string;
127
+ resourceId: string;
128
+ title: string;
129
+ startDate: Date;
130
+ endDate: Date;
131
+ color?: string;
132
+ // ... other optional fields
133
+ }
134
+ ```
135
+
136
+ **Resource**
137
+ ```typescript
138
+ interface Resource {
139
+ id: string;
140
+ name: string;
141
+ groupId: string;
142
+ order: number;
143
+ }
144
+ ```
145
+
146
+ ### Configuration (Settings)
147
+
148
+ The `settings` prop controls the calendar's behavior and constraints.
149
+
150
+ ```typescript
151
+ type FacilityScheduleSettings = {
152
+ // Business Hours
153
+ startTime: string; // e.g. "09:00"
154
+ endTime: string; // e.g. "18:00"
155
+
156
+ // Grid Configuration
157
+ defaultDuration: number; // Default event duration in minutes (e.g., 60)
158
+
159
+ // Holidays / Closed Days
160
+ closedDays: number[]; // 0=Sunday, 1=Monday, etc.
161
+
162
+ // Display
163
+ weekStartsOn: 0 | 1; // 0=Sunday, 1=Monday
164
+ timeZone?: string; // e.g. "Asia/Tokyo"
165
+
166
+ // Custom Time Slots (optional override)
167
+ timeSlots?: Array<{
168
+ id: string | number;
169
+ label: string;
170
+ startTime: string;
171
+ endTime: string;
172
+ }>;
173
+ };
174
+ ```
175
+
176
+ ### Internationalization (i18n) 🌍
177
+
178
+ This library uses `react-i18next` for translations. You must provide translations for the following keys in your i18n configuration:
179
+
180
+ ```json
181
+ {
182
+ "loading": "Loading...",
183
+ "today_button": "Today",
184
+ "view_day": "Day",
185
+ "view_week": "Week",
186
+ "view_month": "Month",
187
+ "event_modal_title_create": "New Schedule",
188
+ "event_modal_title_edit": "Edit Schedule",
189
+ "title_label": "Title",
190
+ "attendee_label": "Attendee",
191
+ "resource_label": "Resource",
192
+ "date_label": "Date",
193
+ "time_label": "Time",
194
+ "save_button": "Save",
195
+ "delete_button": "Delete",
196
+ "cancel_button": "Cancel",
197
+ "confirm_delete_title": "Delete Schedule",
198
+ "confirm_delete_message": "Are you sure you want to delete this schedule?"
199
+ }
200
+ ```
201
+
202
+ Ensure your `i18n` instance is initialized before rendering the component.
203
+
204
+ ## Full Stack Example 🏗️
205
+
206
+ Check out the `examples/` directory for a complete Full-Stack implementation using **Bun**, **Hono**, **SQLite**, and **React**.
207
+
208
+ - **Backend**: `examples/backend` (Bun + Hono + SQLite + Drizzle ORM)
209
+ - **Frontend**: `examples/frontend` (React Component with data fetching)
210
+
211
+ See [Walkthrough](./examples/README.md) (or simply explore the folder) for details on how to run it.
212
+
213
+ ## Customization 🎨
214
+
215
+ ### Tailwind Integration 🌬️
216
+
217
+ If you are using Tailwind CSS, you can use our preset to inherit all theme variables and utility classes.
218
+
219
+ 1. **Update `tailwind.config.js`**:
220
+
221
+ ```javascript
222
+ import regularCalendarPreset from 'regular-calendar/tailwind-preset';
223
+
224
+ export default {
225
+ presets: [regularCalendarPreset],
226
+ content: [
227
+ // ... your app content
228
+ './node_modules/regular-calendar/dist/**/*.{js,ts,jsx,tsx}'
229
+ ],
230
+ // ...
231
+ };
232
+ ```
233
+
234
+ This makes all `regular-calendar` utility classes (like `bg-primary`, `text-foreground`) available in your app, ensuring perfect visual consistency.
235
+
236
+ ### Theme Configuration
237
+
238
+ `regular-calendar` uses CSS variables for all styling. You can customize the look and feel by overriding these variables in your CSS.
239
+
240
+ #### 1. Setup Theme Provider
241
+
242
+ Use the `ThemeProvider` to control high-level settings like density and border radius.
243
+
244
+ ```tsx
245
+ import { FacilitySchedule, ThemeProvider } from 'regular-calendar';
246
+ import 'regular-calendar/styles';
247
+
248
+ function App() {
249
+ return (
250
+ <ThemeProvider config={{
251
+ density: 'compact', // 'compact' | 'normal' | 'spacious'
252
+ radius: 0.5, // Border radius in rem
253
+ tabletMode: false, // Enable touch-optimized UI
254
+ }}>
255
+ <FacilitySchedule ... />
256
+ </ThemeProvider>
257
+ );
258
+ }
259
+ ```
260
+
261
+ #### 2. CSS Variables (Theming)
262
+
263
+ You can globally override colors and layout metrics in your main CSS file. We support **Dark Mode** out of the box via the `.dark` class.
264
+
265
+ ```css
266
+ :root {
267
+ /* --- Layout Metrics --- */
268
+ --radius: 0.5rem;
269
+ --ui-font-size-base: 0.875rem;
270
+ --ui-component-height: 2.5rem; /* Height of inputs, buttons */
271
+
272
+ /* --- Colors (HSL values) --- */
273
+ --primary: 221 83% 53%; /* Main Brand Color */
274
+ --primary-foreground: 210 40% 98%;
275
+
276
+ --background: 0 0% 100%; /* Page Background */
277
+ --foreground: 222 47% 11%; /* Main Text */
278
+
279
+ --muted: 210 40% 96.1%; /* Secondary Backgrounds */
280
+ --muted-foreground: 215 16% 47%;
281
+
282
+ --border: 214 32% 91%; /* Borders */
283
+ --input: 214 32% 91%; /* Input Borders */
284
+
285
+ --accent: 210 40% 96.1%; /* Hover/Active States */
286
+ --accent-foreground: 222 47% 11%;
287
+ }
288
+
289
+ /* Dark Mode Overrides */
290
+ .dark {
291
+ --background: 222 47% 11%;
292
+ --foreground: 210 40% 98%;
293
+
294
+ --primary: 217 91% 60%;
295
+ --primary-foreground: 222 47% 11%;
296
+
297
+ --muted: 217 33% 17%;
298
+ --muted-foreground: 215 20% 65%;
299
+
300
+ --border: 217 33% 17%;
301
+ --input: 217 33% 17%;
302
+ }
303
+ ```
304
+
305
+ ### Custom Modal
306
+ You can replace the default event creation modal with your own by passing a component to the `components` prop.
307
+
308
+ ```tsx
309
+ <FacilitySchedule
310
+ // ...
311
+ components={{
312
+ EventModal: MyCustomModal
313
+ }}
314
+ />
315
+ ```
316
+
317
+ ## Development & Contributing 🛠️
318
+
319
+ Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests.
320
+
321
+ ```bash
322
+ # Install dependencies
323
+ pnpm install
324
+
325
+ # Run tests (Vitest)
326
+ pnpm test
327
+
328
+ # Build the library
329
+ pnpm run build
330
+
331
+ # Type Checking
332
+ pnpm run type-check
333
+ ```
334
+
335
+ ## License
336
+
337
+ MIT