@molecule/app-timeline 1.0.0 → 1.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.
- package/README.md +259 -0
- package/package.json +10 -4
package/README.md
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
AUTO-GENERATED — DO NOT EDIT THIS FILE.
|
|
3
|
+
Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
|
|
4
|
+
Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
|
|
5
|
+
To change this document, edit the module-level JSDoc in src/index.ts.
|
|
6
|
+
Generated: 2026-08-04T01:52:58.127Z
|
|
7
|
+
-->
|
|
8
|
+
|
|
9
|
+
# @molecule/app-timeline
|
|
10
|
+
|
|
11
|
+
> **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
|
|
12
|
+
> It is written to be read by coding agents as much as by people, and is generated from this
|
|
13
|
+
> package's source — edit `src/index.ts` JSDoc, not this file.
|
|
14
|
+
|
|
15
|
+
Timeline core interface for molecule.dev.
|
|
16
|
+
|
|
17
|
+
Provides a standardized API for rendering timeline and activity log
|
|
18
|
+
UI components. Bond a provider (e.g. `@molecule/app-timeline-default`)
|
|
19
|
+
to supply the concrete implementation.
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { requireProvider, setProvider } from '@molecule/app-timeline'
|
|
25
|
+
import { provider } from '@molecule/app-timeline-default'
|
|
26
|
+
|
|
27
|
+
setProvider(provider) // once, at startup (bonds.ts)
|
|
28
|
+
|
|
29
|
+
const timeline = requireProvider().createTimeline({
|
|
30
|
+
items: [{ id: '1', date: new Date(), title: 'Created project' }],
|
|
31
|
+
})
|
|
32
|
+
timeline.addItem({ id: '2', date: new Date(), title: 'Invited teammate' })
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Type
|
|
36
|
+
|
|
37
|
+
`core`
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @molecule/app-timeline @molecule/app-bond
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## API
|
|
46
|
+
|
|
47
|
+
### Interfaces
|
|
48
|
+
|
|
49
|
+
#### `TimelineInstance`
|
|
50
|
+
|
|
51
|
+
A live timeline instance returned by the provider.
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
interface TimelineInstance {
|
|
55
|
+
/**
|
|
56
|
+
* Updates the timeline items.
|
|
57
|
+
*
|
|
58
|
+
* @param items - The new set of timeline items.
|
|
59
|
+
*/
|
|
60
|
+
setItems(items: TimelineItem[]): void
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Appends a single item to the timeline.
|
|
64
|
+
*
|
|
65
|
+
* @param item - The item to add.
|
|
66
|
+
*/
|
|
67
|
+
addItem(item: TimelineItem): void
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Removes an item by its ID.
|
|
71
|
+
*
|
|
72
|
+
* @param id - The ID of the item to remove.
|
|
73
|
+
* @returns `true` if the item was found and removed.
|
|
74
|
+
*/
|
|
75
|
+
removeItem(id: string): boolean
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Returns all current timeline items.
|
|
79
|
+
*
|
|
80
|
+
* @returns Array of timeline items.
|
|
81
|
+
*/
|
|
82
|
+
getItems(): TimelineItem[]
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Destroys the timeline instance and cleans up resources.
|
|
86
|
+
*/
|
|
87
|
+
destroy(): void
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
#### `TimelineItem`
|
|
92
|
+
|
|
93
|
+
A single item in a timeline.
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
interface TimelineItem {
|
|
97
|
+
/** Unique identifier for the item. */
|
|
98
|
+
id: string
|
|
99
|
+
|
|
100
|
+
/** Date/time the event occurred. */
|
|
101
|
+
date: Date
|
|
102
|
+
|
|
103
|
+
/** Title of the timeline entry. */
|
|
104
|
+
title: string
|
|
105
|
+
|
|
106
|
+
/** Optional description or body text. */
|
|
107
|
+
description?: string
|
|
108
|
+
|
|
109
|
+
/** Optional icon identifier. */
|
|
110
|
+
icon?: string
|
|
111
|
+
|
|
112
|
+
/** Optional color for the timeline dot/marker. */
|
|
113
|
+
color?: string
|
|
114
|
+
|
|
115
|
+
/** Arbitrary metadata attached to the item. */
|
|
116
|
+
metadata?: Record<string, unknown>
|
|
117
|
+
}
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### `TimelineOptions`
|
|
121
|
+
|
|
122
|
+
Configuration options for creating a timeline.
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
interface TimelineOptions {
|
|
126
|
+
/** Items to display in the timeline. */
|
|
127
|
+
items: TimelineItem[]
|
|
128
|
+
|
|
129
|
+
/** Whether to alternate items on opposite sides. Defaults to `false`. */
|
|
130
|
+
alternate?: boolean
|
|
131
|
+
|
|
132
|
+
/** Callback when a timeline item is clicked. */
|
|
133
|
+
onItemClick?: (item: TimelineItem) => void
|
|
134
|
+
}
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
#### `TimelineProvider`
|
|
138
|
+
|
|
139
|
+
Timeline provider interface.
|
|
140
|
+
|
|
141
|
+
All timeline providers must implement this interface to create
|
|
142
|
+
and manage timeline / activity log UI.
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
interface TimelineProvider {
|
|
146
|
+
/** Provider name identifier. */
|
|
147
|
+
readonly name: string
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Creates a new timeline instance.
|
|
151
|
+
*
|
|
152
|
+
* @param options - Configuration for the timeline.
|
|
153
|
+
* @returns A timeline instance for managing the timeline.
|
|
154
|
+
*/
|
|
155
|
+
createTimeline(options: TimelineOptions): TimelineInstance
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Functions
|
|
160
|
+
|
|
161
|
+
#### `getProvider()`
|
|
162
|
+
|
|
163
|
+
Retrieves the bonded timeline provider, or `null` if none is bonded.
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
function getProvider(): TimelineProvider | null
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
**Returns:** The active timeline provider, or `null`.
|
|
170
|
+
|
|
171
|
+
#### `hasProvider()`
|
|
172
|
+
|
|
173
|
+
Checks whether a timeline provider has been bonded.
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
function hasProvider(): boolean
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Returns:** `true` if a timeline provider is available.
|
|
180
|
+
|
|
181
|
+
#### `requireProvider()`
|
|
182
|
+
|
|
183
|
+
Retrieves the bonded timeline provider, throwing if none is configured.
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
function requireProvider(): TimelineProvider
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
**Returns:** The active timeline provider.
|
|
190
|
+
|
|
191
|
+
#### `setProvider(provider)`
|
|
192
|
+
|
|
193
|
+
Registers a timeline provider as the active singleton.
|
|
194
|
+
|
|
195
|
+
```typescript
|
|
196
|
+
function setProvider(provider: TimelineProvider): void
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
- `provider` — The timeline provider implementation to bond.
|
|
200
|
+
|
|
201
|
+
## Available Providers
|
|
202
|
+
|
|
203
|
+
| Provider | Package |
|
|
204
|
+
| -------- | -------------------------------- |
|
|
205
|
+
| Timeline | `@molecule/app-timeline-default` |
|
|
206
|
+
|
|
207
|
+
## Injection Notes
|
|
208
|
+
|
|
209
|
+
### Requirements
|
|
210
|
+
|
|
211
|
+
Peer dependencies:
|
|
212
|
+
|
|
213
|
+
- `@molecule/app-bond` ^1.0.1
|
|
214
|
+
|
|
215
|
+
### Runtime Dependencies
|
|
216
|
+
|
|
217
|
+
- `@molecule/app-bond`
|
|
218
|
+
|
|
219
|
+
- **The instance is HEADLESS state, not UI.** `createTimeline` returns item
|
|
220
|
+
management (`setItems`/`addItem`/`removeItem`/`getItems`) — nothing appears
|
|
221
|
+
on screen. The app renders the entries itself, styling via `getClassMap()`
|
|
222
|
+
from `@molecule/app-ui` and putting every label through
|
|
223
|
+
`t('key', values, { defaultValue })`.
|
|
224
|
+
- **Wire it with THIS package's `setProvider()` or `bond('timeline', …)`.**
|
|
225
|
+
`setProvider()` delegates into the shared `@molecule/app-bond` registry, so
|
|
226
|
+
both write the same slot; {@link requireProvider} throws until one has run.
|
|
227
|
+
- `TimelineItem.date` is a `Date` — format it for display with the app's
|
|
228
|
+
locale-aware formatting, never a hardcoded locale string.
|
|
229
|
+
- Call `destroy()` when the owning screen unmounts.
|
|
230
|
+
|
|
231
|
+
## E2E Tests
|
|
232
|
+
|
|
233
|
+
Integration checklist — drive the real timeline UI (live preview, no mocks),
|
|
234
|
+
adapt each item to this app's actual timeline/activity screens, and check
|
|
235
|
+
every box off one by one. A box you can't check is an integration bug to fix
|
|
236
|
+
— not a skip:
|
|
237
|
+
|
|
238
|
+
- [ ] The timeline renders its entries in the correct chronological order per
|
|
239
|
+
the app's config (newest-first or oldest-first) — the on-screen order
|
|
240
|
+
matches the item `date` timestamps, NOT insertion order (`getItems()`
|
|
241
|
+
preserves insertion order; the app sorts by `date` for display).
|
|
242
|
+
- [ ] Each rendered entry shows its real data: the locale-formatted `date`
|
|
243
|
+
(never a raw `Date` string), the `title`, and — when set — the
|
|
244
|
+
`description`, `icon`, and dot/marker `color`.
|
|
245
|
+
- [ ] With `alternate` on, consecutive entries sit on opposite sides of the
|
|
246
|
+
rail; with it off, every entry sits on the same side.
|
|
247
|
+
- [ ] Clicking an entry fires `onItemClick` with THAT item — the wired action
|
|
248
|
+
(navigate/expand/select) happens for the clicked entry, not a neighbour.
|
|
249
|
+
- [ ] If the app groups entries (by day or type), each entry sits under the
|
|
250
|
+
correct group header, and an entry dated in a different bucket renders under
|
|
251
|
+
the right header.
|
|
252
|
+
- [ ] `addItem()` makes the new event appear in its correct position by `date`
|
|
253
|
+
timestamp (not merely appended last), and `removeItem(id)` removes exactly
|
|
254
|
+
that one entry.
|
|
255
|
+
- [ ] If the app loads older entries (load-more/pagination), they append via
|
|
256
|
+
`setItems` with no duplication — every rendered `id` stays unique.
|
|
257
|
+
- [ ] An empty timeline (no items) renders a defined empty state, not a
|
|
258
|
+
blank/broken layout; adding the first item replaces the empty state with the
|
|
259
|
+
entry.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/app-timeline",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,18 +17,24 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"files": [
|
|
20
|
-
"dist"
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
21
22
|
],
|
|
22
23
|
"keywords": [
|
|
23
24
|
"molecule",
|
|
24
25
|
"timeline"
|
|
25
26
|
],
|
|
26
27
|
"license": "Apache-2.0",
|
|
28
|
+
"repository": {
|
|
29
|
+
"type": "git",
|
|
30
|
+
"url": "https://github.com/molecule-dev/molecule.git",
|
|
31
|
+
"directory": "packages/app/core/timeline"
|
|
32
|
+
},
|
|
27
33
|
"peerDependencies": {
|
|
28
|
-
"@molecule/app-bond": "^1.0.
|
|
34
|
+
"@molecule/app-bond": "^1.0.1"
|
|
29
35
|
},
|
|
30
36
|
"devDependencies": {
|
|
31
|
-
"@molecule/app-bond": "1.0.
|
|
37
|
+
"@molecule/app-bond": "1.0.1",
|
|
32
38
|
"@types/node": "26.1.2",
|
|
33
39
|
"typescript": "6.0.3",
|
|
34
40
|
"vitest": "4.1.10"
|