@nomideusz/svelte-calendar 0.1.0 → 0.1.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/README.md +55 -30
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# @svelte-calendar
|
|
1
|
+
# @nomideusz/svelte-calendar
|
|
2
2
|
|
|
3
|
-
A themeable, pluggable **Svelte 5** calendar component library with **Day** and **Week** views
|
|
3
|
+
A themeable, pluggable **Svelte 5** calendar component library with **Day** and **Week** views — ready for yoga studios, tour bookings, concerts, language schools, and more.
|
|
4
4
|
|
|
5
5
|
## Views — Concept-Paired
|
|
6
6
|
|
|
@@ -9,14 +9,15 @@ Switching between Day and Week preserves the active concept.
|
|
|
9
9
|
|
|
10
10
|
| Concept | Day View | Week View | Description |
|
|
11
11
|
|---------|----------|-----------|-------------|
|
|
12
|
-
| **Grid** |
|
|
13
|
-
| **
|
|
12
|
+
| **Grid** | DayGrid | WeekGrid | The primary planner — time blocks on a scrollable grid. |
|
|
13
|
+
| **Timeline** | DayTimeline | — | Horizontal day timeline. Day-only. |
|
|
14
|
+
| **Agenda** | Agenda `mode="day"` | Agenda `mode="week"` | List / feed — Done, Now, Next (day) or grouped-by-day scroll (week). |
|
|
14
15
|
| **Heatmap** | — | WeekHeatmap | Density view — 24 cells per day showing busy/free intensity. Week-only. |
|
|
15
16
|
|
|
16
17
|
## Installation
|
|
17
18
|
|
|
18
19
|
```bash
|
|
19
|
-
|
|
20
|
+
pnpm add @nomideusz/svelte-calendar
|
|
20
21
|
```
|
|
21
22
|
|
|
22
23
|
> **Peer dependency:** Svelte 5 (`^5.0.0`)
|
|
@@ -27,15 +28,15 @@ npm install @svelte-calendar/core
|
|
|
27
28
|
<script lang="ts">
|
|
28
29
|
import {
|
|
29
30
|
Calendar,
|
|
31
|
+
DayGrid,
|
|
30
32
|
DayTimeline,
|
|
31
|
-
|
|
33
|
+
Agenda,
|
|
32
34
|
WeekGrid,
|
|
33
|
-
WeekAgenda,
|
|
34
35
|
WeekHeatmap,
|
|
35
36
|
createMemoryAdapter,
|
|
36
37
|
midnight,
|
|
37
|
-
} from '@svelte-calendar
|
|
38
|
-
import type { CalendarView, TimelineEvent } from '@svelte-calendar
|
|
38
|
+
} from '@nomideusz/svelte-calendar';
|
|
39
|
+
import type { CalendarView, TimelineEvent } from '@nomideusz/svelte-calendar';
|
|
39
40
|
|
|
40
41
|
const events: TimelineEvent[] = [
|
|
41
42
|
{ id: '1', title: 'Yoga Flow', start: new Date('2025-03-01T09:00'), end: new Date('2025-03-01T10:00'), color: '#818cf8' },
|
|
@@ -47,10 +48,10 @@ npm install @svelte-calendar/core
|
|
|
47
48
|
|
|
48
49
|
// Concepts are paired by label — switching Day↔Week preserves the concept
|
|
49
50
|
const views: CalendarView[] = [
|
|
50
|
-
{ id: 'day-grid', label: 'Grid', granularity: 'day', component:
|
|
51
|
+
{ id: 'day-grid', label: 'Grid', granularity: 'day', component: DayGrid },
|
|
51
52
|
{ id: 'week-grid', label: 'Grid', granularity: 'week', component: WeekGrid },
|
|
52
|
-
{ id: 'day-agenda', label: 'Agenda', granularity: 'day', component:
|
|
53
|
-
{ id: 'week-agenda', label: 'Agenda', granularity: 'week', component:
|
|
53
|
+
{ id: 'day-agenda', label: 'Agenda', granularity: 'day', component: Agenda, props: { mode: 'day' } },
|
|
54
|
+
{ id: 'week-agenda', label: 'Agenda', granularity: 'week', component: Agenda, props: { mode: 'week' } },
|
|
54
55
|
{ id: 'week-heatmap', label: 'Heatmap', granularity: 'week', component: WeekHeatmap },
|
|
55
56
|
];
|
|
56
57
|
</script>
|
|
@@ -66,6 +67,27 @@ npm install @svelte-calendar/core
|
|
|
66
67
|
/>
|
|
67
68
|
```
|
|
68
69
|
|
|
70
|
+
## Settings Panel
|
|
71
|
+
|
|
72
|
+
The `Settings` component provides a theme picker and dynamic fields for controlling view parameters:
|
|
73
|
+
|
|
74
|
+
```svelte
|
|
75
|
+
<script lang="ts">
|
|
76
|
+
import { Settings } from '@nomideusz/svelte-calendar';
|
|
77
|
+
import type { SettingsField, PresetName } from '@nomideusz/svelte-calendar';
|
|
78
|
+
|
|
79
|
+
let theme: PresetName = $state('midnight');
|
|
80
|
+
let values = $state({ hourHeight: 60, elastic: true });
|
|
81
|
+
|
|
82
|
+
const fields: SettingsField[] = [
|
|
83
|
+
{ key: 'hourHeight', label: 'Hour Height', type: 'range', min: 40, max: 120, step: 5 },
|
|
84
|
+
{ key: 'elastic', label: 'Elastic Compression', type: 'toggle' },
|
|
85
|
+
];
|
|
86
|
+
</script>
|
|
87
|
+
|
|
88
|
+
<Settings {fields} bind:values bind:theme />
|
|
89
|
+
```
|
|
90
|
+
|
|
69
91
|
## Themes
|
|
70
92
|
|
|
71
93
|
Three built-in presets each view reads from the same `--dt-*` CSS custom property contract:
|
|
@@ -78,7 +100,7 @@ Three built-in presets each view reads from the same `--dt-*` CSS custom proper
|
|
|
78
100
|
|
|
79
101
|
```svelte
|
|
80
102
|
<script>
|
|
81
|
-
import { midnight, parchment, indigo, presets } from '@svelte-calendar
|
|
103
|
+
import { midnight, parchment, indigo, presets } from '@nomideusz/svelte-calendar';
|
|
82
104
|
</script>
|
|
83
105
|
|
|
84
106
|
<!-- Apply directly -->
|
|
@@ -107,13 +129,13 @@ const custom = `
|
|
|
107
129
|
|
|
108
130
|
```
|
|
109
131
|
src/lib/
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
132
|
+
├── core/ # Clock, time utils, locale, types
|
|
133
|
+
├── engine/ # Reactive state: event-store, view-state, selection, drag
|
|
134
|
+
├── adapters/ # Data layer: memory adapter, REST adapter
|
|
135
|
+
├── primitives/ # Low-level UI atoms: NowIndicator, EventBlock, TimeGutter...
|
|
136
|
+
├── calendar/ # Calendar shell, Toolbar
|
|
137
|
+
├── views/ # View components (day/, week/, agenda/, settings/)
|
|
138
|
+
└── theme/ # Preset themes and token definitions
|
|
117
139
|
```
|
|
118
140
|
|
|
119
141
|
## Engine
|
|
@@ -124,19 +146,19 @@ import {
|
|
|
124
146
|
createViewState,
|
|
125
147
|
createSelection,
|
|
126
148
|
createDragState,
|
|
127
|
-
} from '@svelte-calendar
|
|
149
|
+
} from '@nomideusz/svelte-calendar';
|
|
128
150
|
```
|
|
129
151
|
|
|
130
|
-
- **`createEventStore(adapter)`**
|
|
131
|
-
- **`createViewState(options)`**
|
|
132
|
-
- **`createSelection()`**
|
|
133
|
-
- **`createDragState()`**
|
|
152
|
+
- **`createEventStore(adapter)`** — reactive event list with fetch/add/update/remove
|
|
153
|
+
- **`createViewState(options)`** — current view, date range, navigation (prev/next/today)
|
|
154
|
+
- **`createSelection()`** — selected event tracking
|
|
155
|
+
- **`createDragState()`** — drag-to-create and drag-to-move state machine
|
|
134
156
|
|
|
135
157
|
## Adapters
|
|
136
158
|
|
|
137
159
|
| Adapter | Use |
|
|
138
160
|
|---------|-----|
|
|
139
|
-
| `createMemoryAdapter(events)` | In-memory
|
|
161
|
+
| `createMemoryAdapter(events)` | In-memory — great for demos and prototyping |
|
|
140
162
|
| `createRestAdapter(options)` | Fetch from a REST API with configurable endpoints |
|
|
141
163
|
|
|
142
164
|
## Standalone Views
|
|
@@ -150,6 +172,9 @@ Each view works independently without the Calendar shell:
|
|
|
150
172
|
<!-- Vertical day grid with elastic night compression -->
|
|
151
173
|
<DayGrid style={midnight} events={events} height={600} elastic />
|
|
152
174
|
|
|
175
|
+
<!-- Agenda in day mode -->
|
|
176
|
+
<Agenda mode="day" events={events} height={520} />
|
|
177
|
+
|
|
153
178
|
<!-- Week density heatmap -->
|
|
154
179
|
<WeekHeatmap style={parchment} events={events} height={320} />
|
|
155
180
|
```
|
|
@@ -157,10 +182,10 @@ Each view works independently without the Calendar shell:
|
|
|
157
182
|
## Development
|
|
158
183
|
|
|
159
184
|
```bash
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
185
|
+
pnpm install
|
|
186
|
+
pnpm dev # SvelteKit dev server (demo app)
|
|
187
|
+
pnpm check # Type check
|
|
188
|
+
pnpm run package # Build the library into dist/
|
|
164
189
|
```
|
|
165
190
|
|
|
166
191
|
## License
|
package/package.json
CHANGED