@synapxlab/ladder-timeline 0.0.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.fr.md +155 -0
  3. package/README.md +155 -0
  4. package/package.json +67 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Laurent
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.fr.md ADDED
@@ -0,0 +1,155 @@
1
+ # @synapxlab/ladder-timeline
2
+
3
+ > Carrousel temporel multi-échelles — glisser et zoomer sur 16 échelles,
4
+ > du milliard d'années à la milliseconde. Zéro dépendance runtime,
5
+ > TypeScript + SCSS.
6
+
7
+ 🇬🇧 [Read in English](./README.md)
8
+
9
+ LadderTimeline est un composant d'axe temporel horizontal organisé en
10
+ **échelle de 16 niveaux** (Ga, 100Ma, Ma, 100ka, 10ka, millénaire,
11
+ siècle, décennie, année, mois, semaine, jour, heure, minute, seconde,
12
+ ms). `↑`/`↓` (ou `setScale(id)`) bascule vers une échelle plus
13
+ fine / plus grossière ; glisser navigue dans l'échelle courante.
14
+
15
+ Conçu comme une brique de **ChronoMap** (timeline géospatiale) mais
16
+ utilisable de façon autonome pour toute UI de scrubber temporel.
17
+
18
+ ## Installation
19
+
20
+ ```bash
21
+ npm install @synapxlab/ladder-timeline
22
+ ```
23
+
24
+ ## Démarrage rapide
25
+
26
+ ```ts
27
+ import { LadderTimeline } from '@synapxlab/ladder-timeline';
28
+ import '@synapxlab/ladder-timeline/style';
29
+
30
+ const timeline = new LadderTimeline({
31
+ container: document.getElementById('timeline')!,
32
+ scale: 'week',
33
+ displayMode: 'expanded', // ou 'compact'
34
+ minScale: 'ms', // unité la plus fine autorisée
35
+ maxScale: 'millennium', // unité la plus grossière autorisée
36
+ minDate: new Date(1900, 0, 1),
37
+ maxDate: new Date(2100, 11, 31),
38
+ onItemChange: info => console.log('commit', info),
39
+ onItemPreview: info => console.log('preview', info),
40
+ });
41
+ ```
42
+
43
+ ## Fonctionnalités
44
+
45
+ ### 16 échelles (« l'échelle »)
46
+
47
+ | Macro | Calendaire | Sub-jour | Sub-seconde |
48
+ |-----------|-------------------|----------------|--------------|
49
+ | Ga | millénaire | heure | ms |
50
+ | 100Ma | siècle | minute | |
51
+ | Ma | décennie | seconde | |
52
+ | 100ka | année | | |
53
+ | 10ka | mois | | |
54
+ | | semaine | | |
55
+ | | jour | | |
56
+
57
+ Le curseur est stocké en interne comme une **année décimale** (`number`),
58
+ ce qui permet une navigation fluide à toutes les échelles. L'échelle `ms`
59
+ est décorative (float64 ne supporte pas de timestamp absolu plus fin
60
+ que ~1 ms — les labels sont relatifs `±N ms` autour du curseur).
61
+
62
+ ### Deux modes d'affichage
63
+
64
+ - **`expanded`** (défaut) — chaque item affiche label + sublabel complets.
65
+ - **`compact`** — les items aux frontières de l'**échelle supérieure**
66
+ gardent l'affichage complet ; les items intermédiaires sont minimisés
67
+ à un seul chiffre. Exemple à l'échelle décennie :
68
+ `1800` · 10 · 20 · 30 · 40 · 50 · 60 · 70 · 80 · 90 · `1900`
69
+
70
+ Bascule à l'exécution :
71
+
72
+ ```ts
73
+ timeline.setDisplayMode('compact');
74
+ ```
75
+
76
+ ### Bornes
77
+
78
+ ```ts
79
+ new LadderTimeline({
80
+ minYear, maxYear, // année décimale (couvre toute la plage Ga→ms)
81
+ minDate, maxDate, // confort Date (converti en minYear/maxYear)
82
+ minScale, maxScale, // clamp ScaleId sur setScale()
83
+ });
84
+
85
+ timeline.getBounds(); // { minYear, maxYear, minScale, maxScale }
86
+ ```
87
+
88
+ Le curseur reste dans `[minYear, maxYear]` (drag, clavier, `setDate`).
89
+ L'échelle reste dans `[maxScale, minScale]` (du plus grossier au plus fin).
90
+
91
+ ### Clavier
92
+
93
+ | Touche | Action |
94
+ |----------------------|-------------------------------------|
95
+ | `←` / `→` | Item précédent / suivant |
96
+ | `Home` | Aujourd'hui |
97
+ | `↑` / `+` | Zoom in (échelle plus fine) |
98
+ | `↓` / `-` | Zoom out (échelle plus grossière) |
99
+
100
+ Molette : scroll = précédent/suivant (debounced).
101
+
102
+ ### Callbacks
103
+
104
+ ```ts
105
+ new LadderTimeline({
106
+ onItemChange: info => {…}, // commit (après snap)
107
+ onItemPreview: info => {…}, // live (pendant drag/scroll)
108
+ });
109
+
110
+ // info: { scale, year, label, sublabel, header, date }
111
+ ```
112
+
113
+ `date` est `null` quand l'année de l'échelle est hors plage `Date` JS
114
+ (Ma, Ga, …).
115
+
116
+ ## API
117
+
118
+ ```ts
119
+ class LadderTimeline {
120
+ constructor(options: LadderTimelineOptions);
121
+
122
+ // Curseur
123
+ getDate(): Date;
124
+ setDate(date: Date): void;
125
+ goToToday(): void;
126
+ goToPrevious(): void;
127
+ goToNext(): void;
128
+
129
+ // Échelle
130
+ getScale(): ScaleId;
131
+ setScale(id: ScaleId): void;
132
+
133
+ // Affichage
134
+ getDisplayMode(): 'expanded' | 'compact';
135
+ setDisplayMode(mode: 'expanded' | 'compact'): void;
136
+
137
+ // Bornes
138
+ getBounds(): { minYear, maxYear, minScale, maxScale };
139
+
140
+ // Cycle de vie
141
+ render(): void;
142
+ destroy(): void;
143
+ on(event, handler): () => void;
144
+ getEventTarget(): EventTarget;
145
+ connectAdapter(adapter: CalendarAdapter): void;
146
+ }
147
+ ```
148
+
149
+ ## Statut
150
+
151
+ Squelette initial — l'API publique n'est pas encore stable.
152
+
153
+ ## Licence
154
+
155
+ MIT © synapxLab
package/README.md ADDED
@@ -0,0 +1,155 @@
1
+ # @synapxlab/ladder-timeline
2
+
3
+ > Multi-scale temporal carousel — drag and zoom across 16 scales,
4
+ > from billion-years to milliseconds. Zero runtime dependency,
5
+ > TypeScript + SCSS.
6
+
7
+ 🇫🇷 [Lire en français](./README.fr.md)
8
+
9
+ LadderTimeline is a horizontal time-axis component with a **ladder of
10
+ 16 scales** (Ga, 100Ma, Ma, 100ka, 10ka, millennium, century, decade,
11
+ year, month, week, day, hour, minute, second, ms). Press `↑`/`↓`
12
+ (or call `setScale(id)`) to jump to a finer/coarser scale; drag to
13
+ navigate within the current one.
14
+
15
+ Designed as a building block for **ChronoMap** (geospatial timeline)
16
+ but usable standalone for any timeline/scrubber UI.
17
+
18
+ ## Install
19
+
20
+ ```bash
21
+ npm install @synapxlab/ladder-timeline
22
+ ```
23
+
24
+ ## Quick start
25
+
26
+ ```ts
27
+ import { LadderTimeline } from '@synapxlab/ladder-timeline';
28
+ import '@synapxlab/ladder-timeline/style';
29
+
30
+ const timeline = new LadderTimeline({
31
+ container: document.getElementById('timeline')!,
32
+ scale: 'week',
33
+ displayMode: 'expanded', // or 'compact'
34
+ minScale: 'ms', // finest unit allowed
35
+ maxScale: 'millennium', // coarsest unit allowed
36
+ minDate: new Date(1900, 0, 1),
37
+ maxDate: new Date(2100, 11, 31),
38
+ onItemChange: info => console.log('committed', info),
39
+ onItemPreview: info => console.log('preview', info),
40
+ });
41
+ ```
42
+
43
+ ## Features
44
+
45
+ ### 16 scales (the "ladder")
46
+
47
+ | Macro | Calendar | Sub-day | Sub-second |
48
+ |-----------|------------------|----------------|--------------|
49
+ | Ga | millennium | hour | ms |
50
+ | 100Ma | century | minute | |
51
+ | Ma | decade | second | |
52
+ | 100ka | year | | |
53
+ | 10ka | month | | |
54
+ | | week | | |
55
+ | | day | | |
56
+
57
+ The cursor is stored as a **decimal year** (`number`) internally,
58
+ so navigation works seamlessly across all scales. The `ms` scale is
59
+ decorative (float64 doesn't support absolute timestamps finer than
60
+ ~1 ms, so labels are relative `±N ms` around the cursor).
61
+
62
+ ### Two display modes
63
+
64
+ - **`expanded`** (default) — every item shows full label + sublabel.
65
+ - **`compact`** — items at the *next-coarser scale* boundaries keep
66
+ the full display; intermediate items are minimised to a single
67
+ digit. Example at decade scale:
68
+ `1800` · 10 · 20 · 30 · 40 · 50 · 60 · 70 · 80 · 90 · `1900`
69
+
70
+ Switch at runtime:
71
+
72
+ ```ts
73
+ timeline.setDisplayMode('compact');
74
+ ```
75
+
76
+ ### Bounds
77
+
78
+ ```ts
79
+ new LadderTimeline({
80
+ minYear, maxYear, // decimal year (covers full Ga→ms range)
81
+ minDate, maxDate, // Date convenience (converted to minYear/maxYear)
82
+ minScale, maxScale, // ScaleId clamp on setScale()
83
+ });
84
+
85
+ timeline.getBounds(); // { minYear, maxYear, minScale, maxScale }
86
+ ```
87
+
88
+ Cursor stays inside `[minYear, maxYear]` (drag, keyboard, `setDate`).
89
+ Scale stays inside `[maxScale, minScale]` (coarsest → finest).
90
+
91
+ ### Keyboard
92
+
93
+ | Key | Action |
94
+ |----------------------|------------------------------|
95
+ | `←` / `→` | Previous / next item |
96
+ | `Home` | Today |
97
+ | `↑` / `+` | Zoom in (finer scale) |
98
+ | `↓` / `-` | Zoom out (coarser scale) |
99
+
100
+ Wheel : scroll = next/previous (debounced).
101
+
102
+ ### Callbacks
103
+
104
+ ```ts
105
+ new LadderTimeline({
106
+ onItemChange: info => {…}, // committed (after snap)
107
+ onItemPreview: info => {…}, // live (during drag/scroll)
108
+ });
109
+
110
+ // info: { scale, year, label, sublabel, header, date }
111
+ ```
112
+
113
+ `date` is `null` when the scale's year is outside the JS `Date`
114
+ range (Ma, Ga, …).
115
+
116
+ ## API
117
+
118
+ ```ts
119
+ class LadderTimeline {
120
+ constructor(options: LadderTimelineOptions);
121
+
122
+ // Cursor
123
+ getDate(): Date;
124
+ setDate(date: Date): void;
125
+ goToToday(): void;
126
+ goToPrevious(): void;
127
+ goToNext(): void;
128
+
129
+ // Scale
130
+ getScale(): ScaleId;
131
+ setScale(id: ScaleId): void;
132
+
133
+ // Display
134
+ getDisplayMode(): 'expanded' | 'compact';
135
+ setDisplayMode(mode: 'expanded' | 'compact'): void;
136
+
137
+ // Bounds
138
+ getBounds(): { minYear, maxYear, minScale, maxScale };
139
+
140
+ // Lifecycle
141
+ render(): void;
142
+ destroy(): void;
143
+ on(event, handler): () => void;
144
+ getEventTarget(): EventTarget;
145
+ connectAdapter(adapter: CalendarAdapter): void;
146
+ }
147
+ ```
148
+
149
+ ## Status
150
+
151
+ Early scaffold — public API not stable yet.
152
+
153
+ ## License
154
+
155
+ MIT © synapxLab
package/package.json ADDED
@@ -0,0 +1,67 @@
1
+ {
2
+ "name": "@synapxlab/ladder-timeline",
3
+ "version": "0.0.1",
4
+ "description": "Multi-scale temporal carousel — drag/zoom across 18 scales from billion-years to nanoseconds. Zero runtime dependency, TypeScript + SCSS.",
5
+ "type": "module",
6
+ "main": "./dist/ladder-timeline.umd.cjs",
7
+ "module": "./dist/ladder-timeline.es.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/ladder-timeline.es.js",
12
+ "require": "./dist/ladder-timeline.umd.cjs",
13
+ "types": "./dist/index.d.ts"
14
+ },
15
+ "./style": "./dist/style.css"
16
+ },
17
+ "files": [
18
+ "dist",
19
+ "README.md"
20
+ ],
21
+ "sideEffects": [
22
+ "**/*.css"
23
+ ],
24
+ "scripts": {
25
+ "dev": "vite",
26
+ "build": "vite build",
27
+ "build:lib": "tsc --noEmit && vite build --config vite.lib.config.ts && tsc --declaration --emitDeclarationOnly --outDir dist",
28
+ "preview": "vite preview",
29
+ "tsc": "tsc --noEmit",
30
+ "test": "vitest run",
31
+ "test:watch": "vitest",
32
+ "coverage": "vitest run --coverage"
33
+ },
34
+ "keywords": [
35
+ "timeline",
36
+ "carousel",
37
+ "scale",
38
+ "zoom",
39
+ "temporal",
40
+ "geological-time",
41
+ "logarithmic",
42
+ "drag",
43
+ "typescript",
44
+ "zero-dependency"
45
+ ],
46
+ "author": "synapxLab",
47
+ "license": "MIT",
48
+ "repository": {
49
+ "type": "git",
50
+ "url": "https://github.com/synapxLab/LadderTimeline"
51
+ },
52
+ "bugs": {
53
+ "url": "https://github.com/synapxLab/LadderTimeline/issues"
54
+ },
55
+ "homepage": "https://github.com/synapxLab/LadderTimeline#readme",
56
+ "engines": {
57
+ "node": ">=18"
58
+ },
59
+ "devDependencies": {
60
+ "@vitest/coverage-v8": "^4.1.6",
61
+ "jsdom": "^29.1.1",
62
+ "sass": "^1.77.0",
63
+ "typescript": "^5.4.5",
64
+ "vite": "^5.2.0",
65
+ "vitest": "^4.1.6"
66
+ }
67
+ }