@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@industream/timeline",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "type": "module",
5
5
  "description": "The @industream timeline as a framework-agnostic Web Component (<industream-timeline>). Self-contained bundle (React + styles inside a Shadow DOM). Works in Angular, Vue, vanilla — no React or Tailwind setup required.",
6
6
  "license": "ISC",
@@ -19,14 +19,20 @@
19
19
  "sideEffects": true,
20
20
  "main": "./dist/industream-timeline.js",
21
21
  "module": "./dist/industream-timeline.js",
22
+ "types": "./types/index.d.ts",
22
23
  "exports": {
23
- ".": "./dist/industream-timeline.js"
24
+ ".": {
25
+ "types": "./types/index.d.ts",
26
+ "default": "./dist/industream-timeline.js"
27
+ }
24
28
  },
25
29
  "files": [
26
- "dist"
30
+ "dist",
31
+ "types"
27
32
  ],
28
33
  "publishConfig": {
29
- "access": "public"
34
+ "access": "public",
35
+ "registry": "https://registry.npmjs.org/"
30
36
  },
31
37
  "devDependencies": {
32
38
  "@base-ui/react": "^1.3.0",
@@ -38,6 +44,7 @@
38
44
  "class-variance-authority": "^0.7.1",
39
45
  "clsx": "^2.1.1",
40
46
  "date-fns": "^4.1.0",
47
+ "jsdom": "^29.1.1",
41
48
  "react": "^19.2.4",
42
49
  "react-dom": "^19.2.4",
43
50
  "shadcn": "^4.2.0",
@@ -46,10 +53,12 @@
46
53
  "tw-animate-css": "^1.4.0",
47
54
  "typescript": "~5.9.3",
48
55
  "vite": "^8.0.1",
56
+ "vitest": "^4.1.10",
49
57
  "@industream/timeline-react": "0.1.0"
50
58
  },
51
59
  "scripts": {
52
60
  "build": "vite build",
53
- "typecheck": "tsc --noEmit"
61
+ "typecheck": "tsc --noEmit",
62
+ "test": "vitest run"
54
63
  }
55
64
  }
@@ -0,0 +1,82 @@
1
+ // Type declarations of @industream/timeline. Written by hand, as the bundle's sources depend on an unpublished
2
+ // package; the typecheck verifies them against the element (src/type-declarations.test.ts).
3
+
4
+ export type TimelineLanguage = "en" | "fr" | "de";
5
+ export type TimelineTheme = "light" | "dark";
6
+ export type TimelineMode = "historic" | "live" | "timelapse";
7
+
8
+ /**
9
+ * The element's attributes, for typing a framework's templates (e.g. a JSX `IntrinsicElements` entry). Boolean
10
+ * attributes (`instant`, `window`, `step-loading`) are on when present: give them `""`.
11
+ */
12
+ export interface IndustreamTimelineAttributes {
13
+ language?: TimelineLanguage;
14
+ /** Show the snapshot instant T. */
15
+ instant?: string;
16
+ /** Show the `[from, to]` window. */
17
+ window?: string;
18
+ /** Space-separated animated modes on top of Historic: `"live"`, `"timelapse"`; `""` for Historic only. */
19
+ modes?: string;
20
+ theme?: TimelineTheme;
21
+ "step-loading"?: string;
22
+ /** Window start: epoch ms or ISO 8601. Goes with `to`. */
23
+ from?: string | number;
24
+ /** Window end: epoch ms or ISO 8601. Goes with `from`. */
25
+ to?: string | number;
26
+ /** The window as the last duration: `30m`, `1h`, `2d`, `1w`, `3M`, `1y`. */
27
+ timespan?: string;
28
+ /** How much time the band spans, same syntax as `timespan`. */
29
+ extent?: string;
30
+ /** The mode to start in. */
31
+ mode?: "historic" | "live";
32
+ }
33
+
34
+ /** An overlay series drawn faintly across the band. */
35
+ export type BandPreview = {
36
+ points: readonly { time: number; value: number }[];
37
+ min: number;
38
+ max: number;
39
+ color?: string;
40
+ };
41
+
42
+ /** Times are epoch milliseconds. */
43
+ export type TimelineSnapshotChangeDetail = { snapshot: number };
44
+ export type TimelineWindowChangeDetail = { from: number; to: number };
45
+ export type TimelineExtentChangeDetail = { from: number; to: number };
46
+ export type TimelineModeChangeDetail = { mode: TimelineMode };
47
+
48
+ export interface IndustreamTimelineEventMap {
49
+ snapshotchange: CustomEvent<TimelineSnapshotChangeDetail>;
50
+ windowchange: CustomEvent<TimelineWindowChangeDetail>;
51
+ extentchange: CustomEvent<TimelineExtentChangeDetail>;
52
+ modechange: CustomEvent<TimelineModeChangeDetail>;
53
+ }
54
+
55
+ type TimelineListener<K extends keyof IndustreamTimelineEventMap> =
56
+ (this: IndustreamTimelineElement, event: IndustreamTimelineEventMap[K]) => unknown;
57
+ type ElementListener<K extends keyof HTMLElementEventMap> =
58
+ (this: IndustreamTimelineElement, event: HTMLElementEventMap[K]) => unknown;
59
+
60
+ /** `<industream-timeline>`. */
61
+ export declare class IndustreamTimelineElement extends HTMLElement {
62
+ static readonly observedAttributes: readonly string[];
63
+ /** Optional band overlay — an object, so set as a property, not an attribute. */
64
+ get preview(): BandPreview | null;
65
+ set preview(value: BandPreview | null);
66
+
67
+ addEventListener<K extends keyof IndustreamTimelineEventMap>(type: K, listener: TimelineListener<K>, options?: boolean | AddEventListenerOptions): void;
68
+ addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: ElementListener<K>, options?: boolean | AddEventListenerOptions): void;
69
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
70
+ removeEventListener<K extends keyof IndustreamTimelineEventMap>(type: K, listener: TimelineListener<K>, options?: boolean | EventListenerOptions): void;
71
+ removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: ElementListener<K>, options?: boolean | EventListenerOptions): void;
72
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
73
+ }
74
+
75
+ /** Registers `<industream-timeline>`, or the element under another tag name. Importing the package already does it. */
76
+ export declare function defineTimelineElement(tagName?: string): void;
77
+
78
+ declare global {
79
+ interface HTMLElementTagNameMap {
80
+ "industream-timeline": IndustreamTimelineElement;
81
+ }
82
+ }