timeline-scheduler 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.
@@ -0,0 +1,63 @@
1
+ export interface Resource {
2
+ id: string;
3
+ name: string;
4
+ /** Optional avatar image URL. Falls back to coloured initials. */
5
+ avatar?: string;
6
+ }
7
+ export interface TimelineItem {
8
+ id: string;
9
+ resourceId: string;
10
+ name: string;
11
+ /** Any valid CSS color string, e.g. "#3b82f6" or "rgb(59, 130, 246)" */
12
+ color: string;
13
+ start: Date;
14
+ end: Date;
15
+ /** Optional tooltip text shown on hover */
16
+ description?: string;
17
+ }
18
+ export interface ChangeDetail {
19
+ items: TimelineItem[];
20
+ }
21
+ export interface ItemClickDetail {
22
+ item: TimelineItem;
23
+ }
24
+ export interface ItemHoverDetail {
25
+ item: TimelineItem;
26
+ type: 'enter' | 'leave';
27
+ }
28
+ export interface ItemContextMenuDetail {
29
+ item: TimelineItem;
30
+ /** clientX of the pointer event */
31
+ x: number;
32
+ /** clientY of the pointer event */
33
+ y: number;
34
+ }
35
+ export interface ItemCreateDetail {
36
+ resourceId: string;
37
+ start: Date;
38
+ end: Date;
39
+ }
40
+ export interface DateChangeDetail {
41
+ date: Date;
42
+ }
43
+ export interface ItemDblClickDetail {
44
+ item: TimelineItem;
45
+ }
46
+ export interface ItemDragStartDetail {
47
+ item: TimelineItem;
48
+ }
49
+ export interface ItemDragEndDetail {
50
+ item: TimelineItem;
51
+ /** Resource the item was dropped on */
52
+ resourceId: string;
53
+ start: Date;
54
+ end: Date;
55
+ }
56
+ export interface ItemResizeStartDetail {
57
+ item: TimelineItem;
58
+ }
59
+ export interface ItemResizeEndDetail {
60
+ item: TimelineItem;
61
+ start: Date;
62
+ end: Date;
63
+ }
@@ -0,0 +1,7 @@
1
+ import type { TimelineItem } from '../types';
2
+ /**
3
+ * Assigns a sub-row index to each item using a greedy interval scheduling algorithm.
4
+ * Items are sorted by start time. Each item goes into the first sub-row where
5
+ * the last item's end time <= this item's start time.
6
+ */
7
+ export declare function assignSubRows(items: TimelineItem[]): Map<string, number>;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ export declare function clamp(value: number, min: number, max: number): number;
2
+ /**
3
+ * Converts a Date to a percentage position [0, 100] on the timeline.
4
+ * Clamps dates outside the startHour–endHour range.
5
+ * Note: sub-minute precision (seconds, milliseconds) is ignored intentionally —
6
+ * the timeline operates at minute granularity.
7
+ */
8
+ export declare function timeToPercent(date: Date, startHour: number, endHour: number): number;
9
+ /**
10
+ * Converts a percentage [0, 100] back to a Date, using baseDate for the date part.
11
+ */
12
+ export declare function percentToTime(percent: number, startHour: number, endHour: number, baseDate: Date): Date;
13
+ /**
14
+ * Snaps a Date to the nearest multiple of `minutes`.
15
+ */
16
+ export declare function snapToInterval(date: Date, minutes: number): Date;
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "timeline-scheduler",
3
+ "version": "0.1.0",
4
+ "description": "Framework-agnostic Web Component timeline scheduler with drag & drop",
5
+ "type": "module",
6
+ "main": "./dist/timeline-scheduler.cjs.js",
7
+ "module": "./dist/timeline-scheduler.es.js",
8
+ "types": "./dist/timeline-scheduler.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/timeline-scheduler.es.js",
12
+ "require": "./dist/timeline-scheduler.cjs.js"
13
+ }
14
+ },
15
+ "files": ["dist"],
16
+ "scripts": {
17
+ "build": "vite build && tsc",
18
+ "dev": "vite serve playground --open",
19
+ "test": "vitest run",
20
+ "test:watch": "vitest"
21
+ },
22
+ "keywords": ["timeline", "scheduler", "web-component", "drag-drop"],
23
+ "license": "MIT",
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://github.com/Sindreglo/timeline-scheduler"
27
+ },
28
+ "homepage": "https://github.com/Sindreglo/timeline-scheduler#readme",
29
+ "bugs": {
30
+ "url": "https://github.com/Sindreglo/timeline-scheduler/issues"
31
+ },
32
+ "dependencies": {
33
+ "lit": "^3.3.2"
34
+ },
35
+ "devDependencies": {
36
+ "@vitest/coverage-v8": "^4.1.4",
37
+ "jsdom": "^29.0.2",
38
+ "typescript": "^6.0.2",
39
+ "vite": "^8.0.8",
40
+ "vitest": "^4.1.4"
41
+ }
42
+ }