@industream/timeline 1.0.1 → 1.2.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/README.md CHANGED
@@ -33,25 +33,68 @@ Then drop it anywhere. Drive it with **attributes**, read it back through **even
33
33
  | `language` | `en` \| `fr` \| `de` | `en` | UI language. |
34
34
  | `instant` | boolean (presence) | — | Show the snapshot instant T (playhead + value bubble). |
35
35
  | `window` | boolean (presence) | — | Show the `[from,to]` window and its start/end fields. |
36
- | `modes` | space-separated `live` `timelapse` | all compatible | Animated modes on top of Historic (always on). `timelapse` needs `instant`+`window`. |
36
+ | `modes` | space-separated `live` `timelapse` (absent = all; `""` = Historic only) | all compatible | Animated modes on top of Historic (always on). `timelapse` auto-adds `instant`+`window` while it runs. |
37
37
  | `theme` | `light` \| `dark` | `light` | Built-in colour theme. |
38
38
  | `step-loading` | boolean | off | Tells timelapse a snapshot is still loading, so playback waits for your data. |
39
+ | `from`, `to` | epoch ms (digits only) or ISO 8601 | — | The window `[from, to]`. Give both, or neither. |
40
+ | `timespan` | duration: `30m`, `1h`, `2d`, `1w`, `3M`, `1y` | `2d` | The window as the last *duration* (ends now). `from` / `to` win over it. |
41
+ | `extent` | duration, same syntax | `7d` | How much time the band spans. |
42
+ | `mode` | `live` \| `historic` | Live when offered, else Historic | The mode to start in. `live` needs Live in `modes`. |
43
+
44
+ If **neither** `instant` nor `window` is present, both default on (bare `<industream-timeline>` = full timeline). Historic is always on; `modes` lists only `live` / `timelapse` (**omit** the attribute for the default, `""` for Historic only). Listing `historic` or an unknown mode throws; `timelapse` never throws — it auto-adds any missing content while it runs. See the [full guide](../docs/web-component.md#every-combination) for every combination.
45
+
46
+ **Position** (`from` / `to` / `timespan`, `extent`, `mode`): the timeline starts on these attributes, and
47
+ **changing one later moves it** — so a page can give its window back to a timeline it mounts again. Changing
48
+ `modes`, `language` or `theme` keeps the window and mode (a mode no longer offered falls back to Historic). Durations
49
+ use `m` for minutes and `M` for months. A window is always shown whole: the extent widens or moves to contain
50
+ it, and a window ending in the future ends now. In Live, the window keeps its duration but ends now. Changing
51
+ `from` / `to` leaves Live; changing `timespan` keeps the current mode. Setting `from` / `to` to the window the
52
+ timeline has just emitted does nothing, so a page may store the window it receives and hand it back. An
53
+ invalid value throws. See the [full guide](../docs/web-component.md#position).
39
54
 
40
- If **neither** `instant` nor `window` is present, both default on (bare `<industream-timeline>` = full timeline). Historic is always on; `modes` lists only `live` / `timelapse`. An invalid `modes` (listing `historic`, or `timelapse` without both `instant` and `window`) throws.
55
+ ```html
56
+ <!-- Live on the last hour, Historic available -->
57
+ <industream-timeline window modes="live" timespan="1h"></industream-timeline>
58
+ <!-- Historic only, on a window the user chose -->
59
+ <industream-timeline window modes="" from="2026-10-01T00:00:00Z" to="2026-10-03T00:00:00Z"></industream-timeline>
60
+ ```
41
61
 
42
62
  One **property** (an object, so set it in JS, not as an attribute): `el.preview = { points, min, max }` — an
43
63
  optional series drawn faintly across the band.
44
64
 
45
65
  ### Events
46
66
 
47
- All fire as `CustomEvent`s (they `bubble` and cross shadow boundaries). Times are **epoch milliseconds** in
48
- `event.detail`.
67
+ All fire as `CustomEvent`s (they `bubble` and cross shadow boundaries), once on start and then on every
68
+ change. Times are **epoch milliseconds** in `event.detail`.
49
69
 
50
70
  | Event | `detail` | Fires when |
51
71
  | --- | --- | --- |
52
72
  | `snapshotchange` | `{ snapshot }` | the "as of" instant changes (debounced). |
53
73
  | `windowchange` | `{ from, to }` | the window bounds change (debounced). |
54
74
  | `extentchange` | `{ from, to }` | the full navigable extent changes. |
75
+ | `modechange` | `{ mode }` — `"historic"` \| `"live"` \| `"timelapse"` | the mode changes. |
76
+
77
+ ## TypeScript
78
+
79
+ The package ships its type declarations: the element class, `IndustreamTimelineAttributes`, the event details
80
+ (`TimelineWindowChangeDetail`…) and the `HTMLElementTagNameMap` entry. So
81
+ `document.createElement("industream-timeline")` is typed, and so is `event.detail` in its listeners.
82
+
83
+ React's JSX has no entry for custom tags. Add it once in your app, from the shipped attributes:
84
+
85
+ ```ts
86
+ // industream-timeline-jsx.d.ts
87
+ import type { DetailedHTMLProps, HTMLAttributes } from "react";
88
+ import type { IndustreamTimelineAttributes, IndustreamTimelineElement } from "@industream/timeline";
89
+
90
+ declare module "react" {
91
+ namespace JSX {
92
+ interface IntrinsicElements {
93
+ "industream-timeline": DetailedHTMLProps<HTMLAttributes<IndustreamTimelineElement>, IndustreamTimelineElement> & IndustreamTimelineAttributes;
94
+ }
95
+ }
96
+ }
97
+ ```
55
98
 
56
99
  ## Angular
57
100