trud-calendar-core 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 +52 -0
- package/package.json +3 -2
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# trud-calendar-core
|
|
2
|
+
|
|
3
|
+
Headless calendar engine — types, state, date utils, layout algorithms, recurrence. **Zero dependencies.**
|
|
4
|
+
|
|
5
|
+
This is the framework-agnostic core of [trud-calendar](https://www.npmjs.com/package/trud-calendar). Use it to build calendar UIs in any framework — React, Vue, Svelte, Angular, or vanilla JS.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install trud-calendar-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## What's included
|
|
14
|
+
|
|
15
|
+
- **Types** — `CalendarEvent`, `CalendarView`, `DateString`, `PositionedEvent`, `EventSegment`, `RecurrenceRule`, `UndoStack`, `VirtualRange`
|
|
16
|
+
- **Date utils** — `addDays`, `startOfWeek`, `startOfMonth`, `isSameDay`, `eachDayOfRange`, `getVisibleRange`, ...
|
|
17
|
+
- **Formatting** — `formatToolbarTitle`, `formatTime`, `formatTimeRange`, `formatAgendaDate` (all via `Intl`)
|
|
18
|
+
- **Event utils** — `sortEvents`, `filterEventsInRange`, `segmentMultiDayEvent`, `computeTimePositions`, `groupEventsByDate`
|
|
19
|
+
- **Recurrence** — `expandRecurringEvents`, `generateOccurrences` (RFC 5545 RRULE)
|
|
20
|
+
- **Undo/Redo** — `createUndoStack`, `pushState`, `undo`, `redo` (generic, framework-agnostic)
|
|
21
|
+
- **Virtualization** — `filterVisibleEvents`, `scrollToViewportRange`
|
|
22
|
+
- **Layout** — `buildOverlapGroups`, `assignColumns`, `computeTimePositions` (column-packing)
|
|
23
|
+
- **State** — `calendarReducer`, `createInitialState`
|
|
24
|
+
|
|
25
|
+
## Quick example
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import {
|
|
29
|
+
getVisibleRange,
|
|
30
|
+
filterEventsInRange,
|
|
31
|
+
computeTimePositions,
|
|
32
|
+
formatTime,
|
|
33
|
+
} from "trud-calendar-core";
|
|
34
|
+
|
|
35
|
+
const range = getVisibleRange("2026-03-13", "week", 1);
|
|
36
|
+
const visible = filterEventsInRange(events, range.start, range.end);
|
|
37
|
+
const positioned = computeTimePositions(timedEvents, 8, 20);
|
|
38
|
+
|
|
39
|
+
for (const { event, top, height, column, totalColumns } of positioned) {
|
|
40
|
+
console.log(`${formatTime(event.start, "en-US")} ${event.title}`);
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
All dates use **ISO 8601 strings** — no `Date` objects.
|
|
45
|
+
|
|
46
|
+
## Documentation
|
|
47
|
+
|
|
48
|
+
Full docs at [github.com/trudapp/trud-calendar](https://github.com/trudapp/trud-calendar)
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trud-calendar-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Headless calendar engine — types, state, date utils, layout algorithms. Zero dependencies.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -34,7 +34,8 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"files": [
|
|
37
|
-
"dist"
|
|
37
|
+
"dist",
|
|
38
|
+
"README.md"
|
|
38
39
|
],
|
|
39
40
|
"devDependencies": {
|
|
40
41
|
"tsup": "^8.0.0",
|