react-smart-scheduler 0.1.3 → 0.1.5

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 CHANGED
@@ -106,6 +106,93 @@ export default function App() {
106
106
 
107
107
  ---
108
108
 
109
+ ## 🎨 Styling options
110
+
111
+ react-smart-scheduler ships with a zero-dependency default theme and two optional CSS adapters. All three are drop-in replacements for `<Scheduler />` — just swap the import.
112
+
113
+ | Adapter | Import | Accent | Font |
114
+ |---|---|---|---|
115
+ | **Default** | `import { Scheduler }` | Blue `#3b82f6` | System UI |
116
+ | **Tailwind** | `import { TailwindScheduler }` | Indigo `#6366f1` | Inter |
117
+ | **MUI** | `import { MuiScheduler }` | MUI Blue `#1976d2` | Roboto |
118
+
119
+ ### Default (built-in)
120
+
121
+ ```tsx
122
+ import { Scheduler } from 'react-smart-scheduler';
123
+ import 'react-smart-scheduler/dist/scheduler.css';
124
+
125
+ <Scheduler events={events} onEventAdd={...} onEventChange={...} onEventDelete={...} />
126
+ ```
127
+
128
+ ### Tailwind-inspired adapter
129
+
130
+ No Tailwind installation required — this is CSS-only styling inspired by the Tailwind design system.
131
+
132
+ ```tsx
133
+ import { TailwindScheduler } from 'react-smart-scheduler';
134
+ import 'react-smart-scheduler/dist/scheduler.css';
135
+
136
+ <TailwindScheduler events={events} onEventAdd={...} onEventChange={...} onEventDelete={...} />
137
+ ```
138
+
139
+ ### MUI-inspired adapter
140
+
141
+ No `@mui/material` installation required — pure CSS that mirrors Material Design aesthetics.
142
+
143
+ ```tsx
144
+ import { MuiScheduler } from 'react-smart-scheduler';
145
+ import 'react-smart-scheduler/dist/scheduler.css';
146
+
147
+ <MuiScheduler events={events} onEventAdd={...} onEventChange={...} onEventDelete={...} />
148
+ ```
149
+
150
+ ### Headless (bring your own styles)
151
+
152
+ Use `HeadlessScheduler` when you want the scheduler's logic with a completely custom CSS layer.
153
+
154
+ ```tsx
155
+ import { HeadlessScheduler } from 'react-smart-scheduler';
156
+ import 'react-smart-scheduler/dist/scheduler.css'; // structural styles only
157
+
158
+ <HeadlessScheduler events={events} className="my-custom-theme" ... />
159
+ ```
160
+
161
+ ### Custom CSS tokens
162
+
163
+ All adapters expose the same CSS custom properties. Override any token on a parent element:
164
+
165
+ ```css
166
+ /* your-theme.css */
167
+ .rss-root {
168
+ --rss-primary: #0ea5e9; /* sky-500 */
169
+ --rss-primary-light: #f0f9ff;
170
+ --rss-today-bg: #f0f9ff;
171
+ --rss-radius: 10px;
172
+ --rss-event-radius: 8px;
173
+ }
174
+ ```
175
+
176
+ ### Slots — swap built-in sub-components
177
+
178
+ For deeper customisation, swap the `Header` or `EventModal` with your own components:
179
+
180
+ ```tsx
181
+ import { Scheduler, HeaderSlotProps, EventModalSlotProps } from 'react-smart-scheduler';
182
+
183
+ const MyHeader: React.FC<HeaderSlotProps> = ({ view, date, onViewChange, onDateChange }) => (
184
+ // your custom header JSX
185
+ );
186
+
187
+ <Scheduler
188
+ events={events}
189
+ slots={{ Header: MyHeader }}
190
+ ...
191
+ />
192
+ ```
193
+
194
+ ---
195
+
109
196
  ## 📖 API
110
197
 
111
198
  ### `<Scheduler />` Props
@@ -124,6 +211,7 @@ export default function App() {
124
211
  | `startHour` | `number` | `0` | First visible hour (0–23) |
125
212
  | `endHour` | `number` | `24` | Last visible hour (1–24) |
126
213
  | `className` | `string` | `''` | Extra CSS class on the root element |
214
+ | `slots` | `SchedulerSlots` | — | Swap `Header` or `EventModal` with custom components |
127
215
 
128
216
  ### `CalendarEvent` type
129
217
 
package/dist/index.d.ts CHANGED
@@ -20,40 +20,41 @@ export declare interface CalendarEvent {
20
20
  /** A small palette of default event colours. */
21
21
  export declare const EVENT_COLORS: readonly string[];
22
22
 
23
+ /** Props passed to a custom EventModal slot component. */
24
+ export declare interface EventModalSlotProps {
25
+ event: CalendarEvent | null;
26
+ initialStart?: Date;
27
+ initialEnd?: Date;
28
+ onSave: (data: {
29
+ title: string;
30
+ start: Date;
31
+ end: Date;
32
+ color?: string;
33
+ }) => void;
34
+ onDelete?: () => void;
35
+ onClose: () => void;
36
+ }
37
+
23
38
  /** Generate a stable unique id for a new event. */
24
39
  export declare function generateId(): string;
25
40
 
41
+ /** Props passed to a custom Header slot component. */
42
+ export declare interface HeaderSlotProps {
43
+ view: ViewType;
44
+ date: Date;
45
+ isMobile?: boolean;
46
+ onViewChange: (view: ViewType) => void;
47
+ onDateChange: (date: Date) => void;
48
+ }
49
+
50
+ export declare const MuiScheduler: default_2.FC<SchedulerProps>;
51
+
26
52
  /** Pick a colour from the palette, cycling based on a hash of the id. */
27
53
  export declare function pickColor(id: string): string;
28
54
 
29
- /**
30
- * <Scheduler /> the root component.
31
- *
32
- * Architecture decisions:
33
- *
34
- * 1. Fully controlled: events, view, and date are all owned by the parent.
35
- * The Scheduler only owns transient UI state (drag preview, modal open).
36
- *
37
- * 2. Single DndContext: wraps all views so dnd-kit's sensors work across
38
- * view transitions without needing multiple contexts.
39
- *
40
- * 3. Drag math uses delta (pixels moved from drag start) rather than
41
- * absolute drop coordinates. This avoids needing per-cell droppables
42
- * and gives sub-cell precision. Column width is measured via
43
- * ResizeObserver and stored in a mutable ref (not state) to avoid
44
- * re-renders on window resize.
45
- *
46
- * 4. Resize is handled entirely in EventItem via Pointer Capture API,
47
- * completely independent of dnd-kit. EventItem calls onEventResizeEnd
48
- * after commit; Scheduler forwards to onEventChange.
49
- *
50
- * 5. Responsive: uses useBreakpoint() to set the initial default view
51
- * when no `view` prop is provided (uncontrolled mode).
52
- * mobile → 'day', tablet/desktop → 'week'.
53
- * Both PointerSensor and TouchSensor are active so drag & drop works
54
- * on touch devices out of the box.
55
- */
56
- export declare const Scheduler: default_2.FC<SchedulerProps>;
55
+ declare const Scheduler: default_2.FC<SchedulerProps>;
56
+ export { Scheduler as HeadlessScheduler }
57
+ export { Scheduler }
57
58
 
58
59
  /** Props accepted by the top-level <Scheduler /> component. */
59
60
  export declare interface SchedulerProps {
@@ -85,25 +86,27 @@ export declare interface SchedulerProps {
85
86
  endHour?: number;
86
87
  /** Extra CSS class applied to the root element. */
87
88
  className?: string;
89
+ /** Optional component overrides — swap the built-in Header or EventModal. */
90
+ slots?: SchedulerSlots;
88
91
  }
89
92
 
93
+ /** Map of swappable sub-components. */
94
+ export declare interface SchedulerSlots {
95
+ Header?: default_2.ComponentType<HeaderSlotProps>;
96
+ EventModal?: default_2.ComponentType<EventModalSlotProps>;
97
+ }
98
+
99
+ export declare const TailwindScheduler: default_2.FC<SchedulerProps>;
100
+
90
101
  /**
91
- * Returns the current responsive breakpoint and re-renders whenever the
92
- * window is resized across a threshold.
93
- *
94
- * Breakpoints:
95
- * mobile — < 640 px (phones, small screens)
96
- * tablet — 640–1023 px (tablets, small laptops)
97
- * desktop — ≥ 1024 px (standard laptop / desktop)
98
- *
99
- * Usage:
100
- * const bp = useBreakpoint();
101
- * const isMobile = bp === 'mobile';
102
+ * Returns the current responsive breakpoint, updating on window resize.
103
+ * mobile — < 640 px
104
+ * tablet — 640–1023 px
105
+ * desktop — ≥ 1024 px
102
106
  */
103
107
  export declare function useBreakpoint(): Breakpoint;
104
108
 
105
- /** Library version matches package.json version field. */
106
- export declare const VERSION: "0.1.3";
109
+ export declare const VERSION: "0.1.5";
107
110
 
108
111
  export declare type ViewType = 'day' | 'week' | 'month';
109
112