@nickkupriyanov/slotline-react 0.0.0-stage → 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Nick Kupriyanov
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 CHANGED
@@ -1,3 +1,107 @@
1
- # Temporary Holding Version
1
+ # @nickkupriyanov/slotline-react
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A booking widget for React: **month calendar → time slots → details → confirmation** in one drop-in component.
4
+
5
+ Dark theme by default, plain-CSS theming, soft animations, `Intl`-correct time zones, and one small adapter that connects it to your backend.
6
+
7
+ ```bash
8
+ pnpm add @nickkupriyanov/slotline-react
9
+ ```
10
+
11
+ ```tsx
12
+ import { Slotline, createMockAdapter } from '@nickkupriyanov/slotline-react';
13
+ import '@nickkupriyanov/slotline-react/styles.css';
14
+
15
+ export const Booking = () => <Slotline adapter={createMockAdapter()} theme="dark" />;
16
+ ```
17
+
18
+ ## Highlights
19
+
20
+ - **No vendor, no iframe.** You implement `getAvailability`, `getSlots` and `createBooking`; the widget never talks to anyone else.
21
+ - **Dark and light themes by design**, built on CSS custom properties (`--sl-accent`, `--sl-surface`, …) — retheme it from your own stylesheet.
22
+ - **Soft animations with zero runtime**: direction-aware step transitions, animated height, staggered slot reveals, a self-drawing check mark. Optional `@nickkupriyanov/slotline-react/motion` entry for spring transitions.
23
+ - **Accessible**: ARIA grid with roving tabindex, keyboard navigation, live-region step announcements, focus management, labelled controls, `prefers-reduced-motion` support.
24
+ - **Correct dates**: day keys are time-zone aware, slots are instants, everything formats through `Intl`. `en` and `ru` copy included, any locale tag works.
25
+ - **Small**: ~14.5 kB gzip ESM + ~3.6 kB gzip CSS, no runtime dependencies.
26
+
27
+ ## Entries
28
+
29
+ | Import | What you get |
30
+ | --- | --- |
31
+ | `@nickkupriyanov/slotline-react` | `Slotline`, `SlotlineProvider`, `SlotlineView`, `useBookingFlow`, `useSlotlineContext`, `createMockAdapter`, types, date and i18n helpers. |
32
+ | `@nickkupriyanov/slotline-react/motion` | The same API with a spring-based animation kit. Requires the optional `motion` peer dependency. |
33
+ | `@nickkupriyanov/slotline-react/styles.css` | The stylesheet. Import it once. |
34
+
35
+ The state machine, the `Intl` date helpers, the copy, the class names and the stylesheet come from **`@nickkupriyanov/slotline-core`**, a dependency of this package. React users never import it directly — it exists so another binding can render the same widget against the same core.
36
+
37
+ ## Adapter
38
+
39
+ ```ts
40
+ import type { BookingAdapter } from '@nickkupriyanov/slotline-react';
41
+
42
+ export const adapter: BookingAdapter = {
43
+ async getAvailability({ from, to, duration, timeZone, signal }) {
44
+ const res = await fetch(`/api/availability?from=${from}&to=${to}&duration=${duration}&tz=${timeZone}`, { signal });
45
+ if (!res.ok) throw new Error('Could not load availability');
46
+ return res.json(); // [{ date: '2026-05-04', slotCount: 8 }, …]
47
+ },
48
+ async getSlots({ date, duration, timeZone, signal }) {
49
+ const res = await fetch(`/api/slots?date=${date}&duration=${duration}&tz=${timeZone}`, { signal });
50
+ if (!res.ok) throw new Error('Could not load times');
51
+ return res.json(); // [{ start: '2026-05-04T07:15:00Z' }, …]
52
+ },
53
+ async createBooking(request) {
54
+ const res = await fetch('/api/bookings', { method: 'POST', body: JSON.stringify(request) });
55
+ if (!res.ok) throw new Error('Booking failed');
56
+ return res.json(); // { id, inviteeEmail? }
57
+ },
58
+ };
59
+ ```
60
+
61
+ `request` is `{ slot, date, duration, timeZone, details }`. Every query receives an `AbortSignal` tied to the widget's lifetime.
62
+
63
+ ## Theming
64
+
65
+ ```css
66
+ .sl-root {
67
+ --sl-accent: #7c5cff;
68
+ --sl-accent-hover: #8f74ff;
69
+ --sl-accent-ink: #ab9dff;
70
+ --sl-accent-soft: rgba(124, 92, 255, 0.18);
71
+ --sl-radius-card: 18px;
72
+ --sl-width: 440px;
73
+ }
74
+ ```
75
+
76
+ Set `theme="light" | "dark" | "system"` on the component; the resolved theme lands on `.sl-root[data-sl-theme]`.
77
+
78
+ ## Custom UI
79
+
80
+ ```tsx
81
+ import { SlotlineProvider, useSlotlineContext } from '@nickkupriyanov/slotline-react';
82
+
83
+ const Panel = () => {
84
+ const { state, monthLabel, actions, isDayBookable, monthGrid } = useSlotlineContext();
85
+ return (
86
+ <>
87
+ <h2>{monthLabel}</h2>
88
+ {monthGrid.filter(isDayBookable).map((day) => (
89
+ <button key={day} onClick={() => actions.selectDate(day)}>{day}</button>
90
+ ))}
91
+ </>
92
+ );
93
+ };
94
+
95
+ export const Custom = () => (
96
+ <SlotlineProvider adapter={adapter} theme="dark"><Panel /></SlotlineProvider>
97
+ );
98
+ ```
99
+
100
+ ## Documentation
101
+
102
+ Full prop tables, the class-name reference, the animation matrix, accessibility notes and the scope/limits section live in the
103
+ [repository README](https://github.com/nickkupriyanov/slotline#readme).
104
+
105
+ ## License
106
+
107
+ MIT © Nick Kupriyanov