@nanahoshi/mona-ui 0.43.1 → 0.44.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/docs/api/index.json +1 -1
- package/docs/api/timeline.json +1 -0
- package/docs/api/timeline.md +188 -0
- package/docs/manifest.json +1 -1
- package/docs/timeline.md +482 -0
- package/fesm2022/nanahoshi-mona-ui-expansion-panel.mjs +1 -6
- package/fesm2022/nanahoshi-mona-ui-internal.mjs +6 -1
- package/fesm2022/nanahoshi-mona-ui-timeline.mjs +1028 -0
- package/llms.txt +2 -0
- package/package.json +5 -1
- package/timeline/package.json +4 -0
- package/types/nanahoshi-mona-ui-internal.d.ts +4 -0
- package/types/nanahoshi-mona-ui-timeline.d.ts +338 -0
package/docs/timeline.md
ADDED
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
# Timeline
|
|
2
|
+
|
|
3
|
+
> Dated events along a line, down the page or across it, with cards that can open and close.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/timeline`
|
|
6
|
+
|
|
7
|
+
**Selector:** `mona-timeline`
|
|
8
|
+
|
|
9
|
+
`TimelineComponent` shows events in order along a line: each event's date, a marker on the line, and a card with its title, subtitle and description. It runs down the page, with the cards on one side of the line or on alternating sides, or across it. On a collapsible timeline, each card's header opens and closes its details.
|
|
10
|
+
|
|
11
|
+
Screen readers read it as an ordered list. Each event's date comes first, then its title, which is a heading.
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
Give the timeline its events. It shows them in the order of the array, reading each event's date, title, subtitle and description from its fields: `date`, `title`, `subtitle` and `description` by default.
|
|
16
|
+
|
|
17
|
+
**Use Timeline when:**
|
|
18
|
+
|
|
19
|
+
- Things happened, or will happen, in an order that matters: a project's milestones, a company's history, a changelog, an order's progress.
|
|
20
|
+
- Each event needs a few lines of its own, more than a row of a table.
|
|
21
|
+
|
|
22
|
+
To guide users through the steps of a task they're doing, use a [stepper](stepper.md). For many events that people filter, sort or page through, use a [list view](list-view.md) or a [grid](grid.md).
|
|
23
|
+
|
|
24
|
+
## Import & Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { TimelineComponent } from "@nanahoshi/mona-ui/timeline";
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<mona-timeline aria-label="Project milestones" [data]="milestones" />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
protected readonly milestones = [
|
|
36
|
+
{ date: "2026-01-12", title: "Research", subtitle: "Discovery team", description: "Interviews with twelve customers." },
|
|
37
|
+
{ date: "2026-03-02", title: "Design", subtitle: "Product design", description: "A clickable prototype." }
|
|
38
|
+
];
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
`dateField`, `titleField`, `subtitleField` and `descriptionField` name the fields to read when yours are called something else. An event without a date, a subtitle or a description just leaves it out.
|
|
42
|
+
|
|
43
|
+
## Anatomy
|
|
44
|
+
|
|
45
|
+
| Directive | Selector | Replaces |
|
|
46
|
+
| --- | --- | --- |
|
|
47
|
+
| `TimelineHeaderTemplateDirective` | `ng-template[monaTimelineHeaderTemplate]` | The card's title and subtitle |
|
|
48
|
+
| `TimelineBodyTemplateDirective` | `ng-template[monaTimelineBodyTemplate]` | The card's description |
|
|
49
|
+
| `TimelineDateTemplateDirective` | `ng-template[monaTimelineDateTemplate]` | The date label |
|
|
50
|
+
| `TimelineMarkerTemplateDirective` | `ng-template[monaTimelineMarkerTemplate]` | The dot on the line |
|
|
51
|
+
|
|
52
|
+
Each template's context is the event (`let-event`), its `date` as a `Date` or `null`, whether its details are open (`expanded`), and its `index`. Bind the timeline's data to the directive's `Of` input, such as `[monaTimelineBodyTemplateOf]="steps"`, to type the event; without it, the event is `any`.
|
|
53
|
+
|
|
54
|
+
The header is the event's heading, and on a collapsible timeline the button that opens its details, so keep a header template to text and images: no links or controls. A body template can hold anything.
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
|
|
58
|
+
### Down the page
|
|
59
|
+
|
|
60
|
+
By default, the line runs down the start side, with each event's date above its card.
|
|
61
|
+
|
|
62
|
+
`basic-example.component.ts`
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { Component } from "@angular/core";
|
|
66
|
+
import { TimelineComponent } from "@nanahoshi/mona-ui/timeline";
|
|
67
|
+
|
|
68
|
+
interface Milestone {
|
|
69
|
+
readonly date: string;
|
|
70
|
+
readonly description: string;
|
|
71
|
+
readonly subtitle: string;
|
|
72
|
+
readonly title: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@Component({
|
|
76
|
+
selector: "app-timeline-basic-example",
|
|
77
|
+
imports: [TimelineComponent],
|
|
78
|
+
templateUrl: "./basic-example.component.html"
|
|
79
|
+
})
|
|
80
|
+
export class TimelineBasicExampleComponent {
|
|
81
|
+
protected readonly milestones: readonly Milestone[] = [
|
|
82
|
+
{
|
|
83
|
+
date: "2026-01-12",
|
|
84
|
+
description: "Interviews with twelve customers set the goals for the new app.",
|
|
85
|
+
subtitle: "Discovery team",
|
|
86
|
+
title: "Research"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
date: "2026-03-02",
|
|
90
|
+
description: "Wireframes and a clickable prototype, tested with five users.",
|
|
91
|
+
subtitle: "Product design",
|
|
92
|
+
title: "Design"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
date: "2026-06-15",
|
|
96
|
+
description: "The first build goes out to 200 testers.",
|
|
97
|
+
subtitle: "Engineering",
|
|
98
|
+
title: "Beta"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
date: "2026-09-01",
|
|
102
|
+
description: "The app ships to the App Store and Google Play.",
|
|
103
|
+
subtitle: "Everyone",
|
|
104
|
+
title: "Launch"
|
|
105
|
+
}
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`basic-example.component.html`
|
|
111
|
+
|
|
112
|
+
```html
|
|
113
|
+
<mona-timeline aria-label="Project milestones" class="max-w-md" [data]="milestones" />
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### Alternating sides
|
|
117
|
+
|
|
118
|
+
`alternate` puts the cards after the line and before it in turn, with each date across from its card. Below 32rem wide, the timeline goes back to one side, so it fits a phone. `dateFormat` shows the years alone here.
|
|
119
|
+
|
|
120
|
+
`alternate-example.component.ts`
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
import { Component } from "@angular/core";
|
|
124
|
+
import { TimelineComponent } from "@nanahoshi/mona-ui/timeline";
|
|
125
|
+
|
|
126
|
+
interface Chapter {
|
|
127
|
+
readonly description: string;
|
|
128
|
+
readonly title: string;
|
|
129
|
+
readonly year: string;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@Component({
|
|
133
|
+
selector: "app-timeline-alternate-example",
|
|
134
|
+
imports: [TimelineComponent],
|
|
135
|
+
templateUrl: "./alternate-example.component.html"
|
|
136
|
+
})
|
|
137
|
+
export class TimelineAlternateExampleComponent {
|
|
138
|
+
protected readonly history: readonly Chapter[] = [
|
|
139
|
+
{ description: "Two friends start the studio in a spare room in Lisbon.", title: "Founded", year: "2014" },
|
|
140
|
+
{
|
|
141
|
+
description: "Our first app, a recipe planner, reaches 100,000 users.",
|
|
142
|
+
title: "First product",
|
|
143
|
+
year: "2016"
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
description: "A second office opens in Osaka, and the team grows to 40.",
|
|
147
|
+
title: "Osaka office",
|
|
148
|
+
year: "2019"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
description: "Every product can now be used with a screen reader.",
|
|
152
|
+
title: "Accessible by default",
|
|
153
|
+
year: "2022"
|
|
154
|
+
},
|
|
155
|
+
{ description: "The design system goes open source.", title: "Open source", year: "2025" }
|
|
156
|
+
];
|
|
157
|
+
protected readonly yearOnly: Intl.DateTimeFormatOptions = { year: "numeric" };
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
`alternate-example.component.html`
|
|
162
|
+
|
|
163
|
+
```html
|
|
164
|
+
<mona-timeline aria-label="Our history" dateField="year" [alternate]="true" [data]="history" [dateFormat]="yearOnly" />
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Across the page
|
|
168
|
+
|
|
169
|
+
`orientation="horizontal"` runs the timeline across the page, with the dates above the line and the cards below it, scrolling sideways when they don't fit. With `alternate`, the cards go below the line and above it in turn. The `--mona-timeline-event-width` custom property sets how wide each event is, 16rem by default.
|
|
170
|
+
|
|
171
|
+
`horizontal-example.component.ts`
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
import { Component } from "@angular/core";
|
|
175
|
+
import { TimelineComponent } from "@nanahoshi/mona-ui/timeline";
|
|
176
|
+
|
|
177
|
+
interface Release {
|
|
178
|
+
readonly codename: string;
|
|
179
|
+
readonly date: string;
|
|
180
|
+
readonly highlights: string;
|
|
181
|
+
readonly version: string;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
@Component({
|
|
185
|
+
selector: "app-timeline-horizontal-example",
|
|
186
|
+
imports: [TimelineComponent],
|
|
187
|
+
templateUrl: "./horizontal-example.component.html"
|
|
188
|
+
})
|
|
189
|
+
export class TimelineHorizontalExampleComponent {
|
|
190
|
+
protected readonly monthAndYear: Intl.DateTimeFormatOptions = { month: "short", year: "numeric" };
|
|
191
|
+
protected readonly releases: readonly Release[] = [
|
|
192
|
+
{ codename: "Acorn", date: "2025-02-10", highlights: "Buttons, inputs and the theme.", version: "0.1" },
|
|
193
|
+
{ codename: "Birch", date: "2025-05-21", highlights: "The grid, with sorting and paging.", version: "0.5" },
|
|
194
|
+
{ codename: "Cedar", date: "2025-09-03", highlights: "Date pickers in 18 locales.", version: "0.9" },
|
|
195
|
+
{ codename: "Dogwood", date: "2026-01-14", highlights: "Charts, and right-to-left layouts.", version: "1.0" },
|
|
196
|
+
{ codename: "Elm", date: "2026-04-28", highlights: "The editor, with tables and images.", version: "1.2" },
|
|
197
|
+
{ codename: "Fir", date: "2026-08-19", highlights: "Kanban boards and drag to sort.", version: "1.4" }
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
`horizontal-example.component.html`
|
|
203
|
+
|
|
204
|
+
```html
|
|
205
|
+
<mona-timeline
|
|
206
|
+
aria-label="Releases"
|
|
207
|
+
descriptionField="highlights"
|
|
208
|
+
orientation="horizontal"
|
|
209
|
+
subtitleField="codename"
|
|
210
|
+
titleField="version"
|
|
211
|
+
class="[--mona-timeline-event-width:13rem]"
|
|
212
|
+
[data]="releases"
|
|
213
|
+
[dateFormat]="monthAndYear" />
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Collapsible details
|
|
217
|
+
|
|
218
|
+
With `collapsible`, each card's header is a button that opens and closes its details, all closed to start. `expandedKeys` holds the open events; bind it two-way to follow the user and to open or close events yourself. `keyField` names the field that identifies an event in it, so an open event stays open when the data is replaced with copies.
|
|
219
|
+
|
|
220
|
+
`collapsible-example.component.ts`
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
import { Component, computed, signal } from "@angular/core";
|
|
224
|
+
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
225
|
+
import { TimelineComponent } from "@nanahoshi/mona-ui/timeline";
|
|
226
|
+
|
|
227
|
+
interface Change {
|
|
228
|
+
readonly date: string;
|
|
229
|
+
readonly notes: string;
|
|
230
|
+
readonly summary: string;
|
|
231
|
+
readonly version: string;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
@Component({
|
|
235
|
+
selector: "app-timeline-collapsible-example",
|
|
236
|
+
imports: [ButtonDirective, TimelineComponent],
|
|
237
|
+
templateUrl: "./collapsible-example.component.html"
|
|
238
|
+
})
|
|
239
|
+
export class TimelineCollapsibleExampleComponent {
|
|
240
|
+
protected readonly changes: readonly Change[] = [
|
|
241
|
+
{
|
|
242
|
+
date: "2026-11-18",
|
|
243
|
+
notes: "Paste or drop an image into the editor to upload it.\nWord and character counts, with a soft limit.",
|
|
244
|
+
summary: "Editor uploads and counts",
|
|
245
|
+
version: "2.4.0"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
date: "2026-10-30",
|
|
249
|
+
notes: "The date picker no longer opens a second time after a quick Escape.",
|
|
250
|
+
summary: "Date picker fix",
|
|
251
|
+
version: "2.3.1"
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
date: "2026-10-02",
|
|
255
|
+
notes: "Bottom sheets for drop-downs on small screens.\nA tree in a drop-down, with multi-selection.",
|
|
256
|
+
summary: "Drop-down trees and sheets",
|
|
257
|
+
version: "2.3.0"
|
|
258
|
+
}
|
|
259
|
+
];
|
|
260
|
+
protected readonly openCount = computed(() => this.openVersions().length);
|
|
261
|
+
protected readonly openVersions = signal<readonly unknown[]>(["2.4.0"]);
|
|
262
|
+
|
|
263
|
+
protected collapseAll(): void {
|
|
264
|
+
this.openVersions.set([]);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
protected expandAll(): void {
|
|
268
|
+
this.openVersions.set(this.changes.map(change => change.version));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
`collapsible-example.component.html`
|
|
274
|
+
|
|
275
|
+
```html
|
|
276
|
+
<div class="flex max-w-md flex-col gap-3">
|
|
277
|
+
<div class="flex gap-2">
|
|
278
|
+
<button monaButton size="small" type="button" (click)="expandAll()">Open all</button>
|
|
279
|
+
<button monaButton size="small" type="button" (click)="collapseAll()">Close all</button>
|
|
280
|
+
</div>
|
|
281
|
+
<mona-timeline
|
|
282
|
+
aria-label="Changelog"
|
|
283
|
+
descriptionField="notes"
|
|
284
|
+
keyField="version"
|
|
285
|
+
subtitleField="summary"
|
|
286
|
+
titleField="version"
|
|
287
|
+
[collapsible]="true"
|
|
288
|
+
[data]="changes"
|
|
289
|
+
[(expandedKeys)]="openVersions" />
|
|
290
|
+
<p class="text-sm text-muted-foreground">{{ openCount() }} of {{ changes.length }} releases open.</p>
|
|
291
|
+
</div>
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Status markers and templates
|
|
295
|
+
|
|
296
|
+
The marker template shows each step's status as an icon, with its name for screen readers. The date template adds the time of day, or "Expected by" for the step still to come, and the body template adds the place.
|
|
297
|
+
|
|
298
|
+
`templates-example.component.ts`
|
|
299
|
+
|
|
300
|
+
```typescript
|
|
301
|
+
import { DatePipe } from "@angular/common";
|
|
302
|
+
import { Component } from "@angular/core";
|
|
303
|
+
import { LucideCheck, LucideTruck } from "@lucide/angular";
|
|
304
|
+
import {
|
|
305
|
+
TimelineBodyTemplateDirective,
|
|
306
|
+
TimelineComponent,
|
|
307
|
+
TimelineDateTemplateDirective,
|
|
308
|
+
TimelineMarkerTemplateDirective
|
|
309
|
+
} from "@nanahoshi/mona-ui/timeline";
|
|
310
|
+
|
|
311
|
+
interface OrderStep {
|
|
312
|
+
readonly detail: string;
|
|
313
|
+
readonly place?: string;
|
|
314
|
+
readonly status: "current" | "done" | "upcoming";
|
|
315
|
+
readonly time: Date;
|
|
316
|
+
readonly title: string;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
@Component({
|
|
320
|
+
selector: "app-timeline-templates-example",
|
|
321
|
+
imports: [
|
|
322
|
+
DatePipe,
|
|
323
|
+
LucideCheck,
|
|
324
|
+
LucideTruck,
|
|
325
|
+
TimelineBodyTemplateDirective,
|
|
326
|
+
TimelineComponent,
|
|
327
|
+
TimelineDateTemplateDirective,
|
|
328
|
+
TimelineMarkerTemplateDirective
|
|
329
|
+
],
|
|
330
|
+
templateUrl: "./templates-example.component.html"
|
|
331
|
+
})
|
|
332
|
+
export class TimelineTemplatesExampleComponent {
|
|
333
|
+
protected readonly statusText: Readonly<Record<OrderStep["status"], string>> = {
|
|
334
|
+
current: "In progress",
|
|
335
|
+
done: "Done",
|
|
336
|
+
upcoming: "Not yet"
|
|
337
|
+
};
|
|
338
|
+
protected readonly steps: readonly OrderStep[] = [
|
|
339
|
+
{
|
|
340
|
+
detail: "We've received your order and your payment.",
|
|
341
|
+
status: "done",
|
|
342
|
+
time: new Date(2026, 10, 16, 9, 12),
|
|
343
|
+
title: "Ordered"
|
|
344
|
+
},
|
|
345
|
+
{
|
|
346
|
+
detail: "Your order is packed and labeled.",
|
|
347
|
+
place: "Warehouse, Rotterdam",
|
|
348
|
+
status: "done",
|
|
349
|
+
time: new Date(2026, 10, 16, 15, 40),
|
|
350
|
+
title: "Packed"
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
detail: "On its way with the courier.",
|
|
354
|
+
place: "Antwerp sorting center",
|
|
355
|
+
status: "current",
|
|
356
|
+
time: new Date(2026, 10, 17, 7, 5),
|
|
357
|
+
title: "Shipped"
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
detail: "Handed to you, or left in a safe place.",
|
|
361
|
+
status: "upcoming",
|
|
362
|
+
time: new Date(2026, 10, 19),
|
|
363
|
+
title: "Delivered"
|
|
364
|
+
}
|
|
365
|
+
];
|
|
366
|
+
}
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
`templates-example.component.html`
|
|
370
|
+
|
|
371
|
+
```html
|
|
372
|
+
<mona-timeline aria-label="Order status" dateField="time" class="max-w-md" [data]="steps">
|
|
373
|
+
<ng-template monaTimelineDateTemplate [monaTimelineDateTemplateOf]="steps" let-step let-date="date">
|
|
374
|
+
@if (step.status === "upcoming") {
|
|
375
|
+
Expected by <time [attr.datetime]="date | date: 'yyyy-MM-dd'">{{ date | date: "EEE, MMM d" }}</time>
|
|
376
|
+
} @else {
|
|
377
|
+
<time [attr.datetime]="date | date: 'yyyy-MM-dd HH:mm'">{{ date | date: "EEE, MMM d, h:mm a" }}</time>
|
|
378
|
+
}
|
|
379
|
+
</ng-template>
|
|
380
|
+
<ng-template monaTimelineMarkerTemplate [monaTimelineMarkerTemplateOf]="steps" let-step>
|
|
381
|
+
@switch (step.status) {
|
|
382
|
+
@case ("done") {
|
|
383
|
+
<span
|
|
384
|
+
class="flex size-6 items-center justify-center rounded-full border-2 border-success bg-success text-success-foreground">
|
|
385
|
+
<svg lucideCheck [size]="14" aria-hidden="true"></svg>
|
|
386
|
+
</span>
|
|
387
|
+
}
|
|
388
|
+
@case ("current") {
|
|
389
|
+
<span
|
|
390
|
+
class="flex size-6 items-center justify-center rounded-full border-2 border-primary bg-background text-primary">
|
|
391
|
+
<svg lucideTruck [size]="14" aria-hidden="true"></svg>
|
|
392
|
+
</span>
|
|
393
|
+
}
|
|
394
|
+
@default {
|
|
395
|
+
<span class="block size-3 rounded-full border-2 border-border bg-background"></span>
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
<span class="sr-only">{{ statusText[step.status] }}</span>
|
|
399
|
+
</ng-template>
|
|
400
|
+
<ng-template monaTimelineBodyTemplate [monaTimelineBodyTemplateOf]="steps" let-step>
|
|
401
|
+
<p>{{ step.detail }}</p>
|
|
402
|
+
@if (step.place) {
|
|
403
|
+
<p class="mt-1 text-xs">{{ step.place }}</p>
|
|
404
|
+
}
|
|
405
|
+
</ng-template>
|
|
406
|
+
</mona-timeline>
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
## Appearance & Styling
|
|
410
|
+
|
|
411
|
+
Each card has the raised surface of a [card](card.md). The marker is a dot in the primary color, and the line is the border color. In forced colors, the dot, the line and the cards' borders are drawn in the system's text color.
|
|
412
|
+
|
|
413
|
+
A marker template sits centered on the line, beside the date or the card's title. It can be larger than the dot, such as an icon in a circle; on a horizontal timeline, the line's row grows to fit it.
|
|
414
|
+
|
|
415
|
+
| Custom property | Default | Sets |
|
|
416
|
+
| --- | --- | --- |
|
|
417
|
+
| `--mona-timeline-event-width` | `16rem` | The width of each event on a horizontal timeline |
|
|
418
|
+
|
|
419
|
+
Set it with a class on the timeline, such as `class="[--mona-timeline-event-width:20rem]"`.
|
|
420
|
+
|
|
421
|
+
## Behavior
|
|
422
|
+
|
|
423
|
+
### Order and dates
|
|
424
|
+
|
|
425
|
+
The events keep the order of `data`, so sort them the way they should read: oldest first, or newest first, as in a changelog.
|
|
426
|
+
|
|
427
|
+
An event's date can be a `Date`, a timestamp in milliseconds or an ISO 8601 string. A string is in local time unless it gives an offset, so `"2026-03-02"` is March 2 wherever it's read. `dateFormat` formats it in the locale, `{ dateStyle: "medium" }` by default, as in "Mar 2, 2026"; give it `{ year: "numeric" }` for years, or `{ dateStyle: "medium", timeStyle: "short" }` for a time of day too.
|
|
428
|
+
|
|
429
|
+
### Layout
|
|
430
|
+
|
|
431
|
+
A vertical timeline fills its container's width. An alternating one lays its events out by its own width, not the page's: at 32rem and wider, the cards take turns on either side of the line, and below that, they're all after it. A horizontal timeline gives each event the same width and scrolls sideways; the line runs straight through the middle of the markers, whatever the cards' heights.
|
|
432
|
+
|
|
433
|
+
The timeline follows the layout's direction: in a right-to-left layout, the line runs down the right side, and a horizontal timeline runs from right to left.
|
|
434
|
+
|
|
435
|
+
### Opening and closing
|
|
436
|
+
|
|
437
|
+
On a collapsible timeline, the details open and close with a short height animation, or at once when the user prefers reduced motion. An event without details, with no description and no body template, has a plain header. Closed details are inert, so their content can't be focused or found.
|
|
438
|
+
|
|
439
|
+
## Accessibility
|
|
440
|
+
|
|
441
|
+
The timeline is an ordered list, named by `aria-label` or `aria-labelledby`. Each event is an item that reads its date first, in a `<time>` element whose `datetime` holds the date in ISO 8601, then its card. The title is a heading, level 3 by default; set `headingLevel` to fit the page's outline, or to `null` for no headings.
|
|
442
|
+
|
|
443
|
+
The marker is read too, which a template can use: give an icon `aria-hidden="true"`, and add text that says what it means, as the status example does. The dot and the line aren't read.
|
|
444
|
+
|
|
445
|
+
### Keyboard
|
|
446
|
+
|
|
447
|
+
On a collapsible timeline, each header with details is a button, one Tab stop each. A horizontal timeline is a Tab stop too, so the arrow keys can scroll it.
|
|
448
|
+
|
|
449
|
+
| Key | Action |
|
|
450
|
+
| --- | --- |
|
|
451
|
+
| `Tab` / `Shift+Tab` | Moves focus through the headers' buttons, and to a horizontal timeline |
|
|
452
|
+
| `Enter` / `Space` | Opens or closes the details of the focused header |
|
|
453
|
+
| `ArrowLeft` / `ArrowRight` | Scrolls a focused horizontal timeline |
|
|
454
|
+
|
|
455
|
+
### ARIA
|
|
456
|
+
|
|
457
|
+
| Attribute | When present | Value |
|
|
458
|
+
| --- | --- | --- |
|
|
459
|
+
| `aria-label` / `aria-labelledby` | On the list, when given | The timeline's name |
|
|
460
|
+
| `tabindex` | On the list of a horizontal timeline | `"0"` |
|
|
461
|
+
| `role` / `aria-level` | On each title, unless `headingLevel` is `null` | `"heading"` and the level |
|
|
462
|
+
| `aria-expanded` | On each header's button, on a collapsible timeline | Whether the details are open |
|
|
463
|
+
| `aria-controls` | On each header's button, on a collapsible timeline | The id of its details |
|
|
464
|
+
|
|
465
|
+
## API
|
|
466
|
+
|
|
467
|
+
Everything below is imported from `@nanahoshi/mona-ui/timeline`. Each name links to its reference page, with every input, output, property and method.
|
|
468
|
+
|
|
469
|
+
| Name | Kind | Description |
|
|
470
|
+
| --- | --- | --- |
|
|
471
|
+
| [`TimelineComponent`](api/timeline.md#timelinecomponent) | Component | Events in order along a line: each one's date, a marker on the line, and a card with its title, subtitle and description. |
|
|
472
|
+
| [`TimelineBodyTemplateDirective`](api/timeline.md#timelinebodytemplatedirective) | Directive | Template for each event's details, in place of its description. |
|
|
473
|
+
| [`TimelineDateTemplateDirective`](api/timeline.md#timelinedatetemplatedirective) | Directive | Template for each event's date label, in place of its date formatted with `dateFormat`, such as a relative date. |
|
|
474
|
+
| [`TimelineHeaderTemplateDirective`](api/timeline.md#timelineheadertemplatedirective) | Directive | Template for each event's header, in place of its title and subtitle. |
|
|
475
|
+
| [`TimelineMarkerTemplateDirective`](api/timeline.md#timelinemarkertemplatedirective) | Directive | Template for each event's marker on the line, in place of its dot, such as an icon for its status. |
|
|
476
|
+
|
|
477
|
+
### Types
|
|
478
|
+
|
|
479
|
+
| Type | Kind | Description |
|
|
480
|
+
| --- | --- | --- |
|
|
481
|
+
| [`TimelineEventTemplateContext`](api/timeline.md#timelineeventtemplatecontext) | Interface | The context of a timeline's templates, `monaTimelineHeaderTemplate`, `monaTimelineBodyTemplate`, `monaTimelineDateTemplate` and `monaTimelineMarkerTemplate`: the event, as `let-event`. |
|
|
482
|
+
| [`TimelineOrientation`](api/timeline.md#timelineorientation) | Type alias | Which way a timeline runs: `"vertical"`, down the page, or `"horizontal"`, across it in the reading direction, which is right to left in a right-to-left layout. |
|
|
@@ -3,7 +3,7 @@ import { Component, DestroyRef, Directive, ElementRef, InjectionToken, TemplateR
|
|
|
3
3
|
import { NgTemplateOutlet } from "@angular/common";
|
|
4
4
|
import { LucideMinus, LucidePlus } from "@lucide/angular";
|
|
5
5
|
import { COLLAPSIBLE_CONFIG, CollapsibleTriggerDirective } from "@nanahoshi/mona-ui/collapsible";
|
|
6
|
-
import { createElementControlId } from "@nanahoshi/mona-ui/internal";
|
|
6
|
+
import { createElementControlId, toHeadingLevel } from "@nanahoshi/mona-ui/internal";
|
|
7
7
|
import { twMerge } from "tailwind-merge";
|
|
8
8
|
import { cva } from "class-variance-authority";
|
|
9
9
|
const EXPANSION_PANEL_ACCORDION = new InjectionToken("EXPANSION_PANEL_ACCORDION");
|
|
@@ -266,11 +266,6 @@ const expansionPanelContentThemeVariants = cva(`
|
|
|
266
266
|
true: "grid-rows-[1fr]",
|
|
267
267
|
false: "grid-rows-[0fr]"
|
|
268
268
|
} } });
|
|
269
|
-
function toHeadingLevel(value) {
|
|
270
|
-
if (value === null) return null;
|
|
271
|
-
const level = Number(value);
|
|
272
|
-
return Number.isInteger(level) && level >= 1 && level <= 6 ? level : 3;
|
|
273
|
-
}
|
|
274
269
|
const DOCUMENT_POSITION_FOLLOWING = 4;
|
|
275
270
|
var ExpansionPanelComponent = class ExpansionPanelComponent {
|
|
276
271
|
#host;
|
|
@@ -375,6 +375,11 @@ function focusElement(host, element) {
|
|
|
375
375
|
target?.focus();
|
|
376
376
|
return target;
|
|
377
377
|
}
|
|
378
|
+
function toHeadingLevel(value) {
|
|
379
|
+
if (value === null) return null;
|
|
380
|
+
const level = Number(value);
|
|
381
|
+
return Number.isInteger(level) && level >= 1 && level <= 6 ? level : 3;
|
|
382
|
+
}
|
|
378
383
|
const inertCounts = /* @__PURE__ */ new WeakMap();
|
|
379
384
|
const isExempt = (element) => element instanceof HTMLScriptElement || element instanceof HTMLStyleElement || element instanceof HTMLTemplateElement || element.hasAttribute("aria-live") || element.classList.contains("cdk-overlay-backdrop") || element.classList.contains("cdk-overlay-container");
|
|
380
385
|
const inertOutside = (element, options = {}) => {
|
|
@@ -955,6 +960,6 @@ const setupTypeahead = (typeaheadKey$) => {
|
|
|
955
960
|
})));
|
|
956
961
|
return merge(keypress$, resetTrigger$).pipe(scan((buffer, action) => action.type === "reset" ? "" : buffer + action.value.toLowerCase(), ""), filter((buffer) => buffer.length > 0));
|
|
957
962
|
};
|
|
958
|
-
export { AttributeBinderDirective, FIELD_ASSOCIATION_BOUNDARY, HOVER_GRACE, HoverIntent, MONA_FIELDSET_DISABLED, MONA_FORM_FIELD, MONA_LABEL, NavigationKeys, RovingToolbar, TYPEAHEAD_RESET_DELAY, addAriaReference, colorKey, createElementControlId, createPageScrollBlockStrategy, focusCanReturn, focusElement, formatAlpha, hex2rgba, hsla2hsva, hsva2rgba, inertOutside, injectEffectiveDisabled, injectLabelAssociation, injectLabelledByText, isNavigationKey, isTypeaheadKey, isValidHex, listenForHover, matchesAccept, navigationKeysList, onDisconnect, overlaySidePositions, parseAccept, parseColor, positionGlobalOverlay, removeAriaReference, resolveOverlaySide, restoreOverlayScroll, rgba2hex, rgba2hsla, rgba2hsva, runUpload, rxFromResize, rxTimeout, setupTypeahead, sideOfPosition, themeControlBackdropClasses, themeControlSurfaceClasses, themeOverlayBackdropClasses, themeOverlaySurfaceClasses, themeRaisedBackdropClasses, themeRaisedSurfaceClasses, themeSelectionBarClasses, themeSelectionBorderClasses, toCssValue };
|
|
963
|
+
export { AttributeBinderDirective, FIELD_ASSOCIATION_BOUNDARY, HOVER_GRACE, HoverIntent, MONA_FIELDSET_DISABLED, MONA_FORM_FIELD, MONA_LABEL, NavigationKeys, RovingToolbar, TYPEAHEAD_RESET_DELAY, addAriaReference, colorKey, createElementControlId, createPageScrollBlockStrategy, focusCanReturn, focusElement, formatAlpha, hex2rgba, hsla2hsva, hsva2rgba, inertOutside, injectEffectiveDisabled, injectLabelAssociation, injectLabelledByText, isNavigationKey, isTypeaheadKey, isValidHex, listenForHover, matchesAccept, navigationKeysList, onDisconnect, overlaySidePositions, parseAccept, parseColor, positionGlobalOverlay, removeAriaReference, resolveOverlaySide, restoreOverlayScroll, rgba2hex, rgba2hsla, rgba2hsva, runUpload, rxFromResize, rxTimeout, setupTypeahead, sideOfPosition, themeControlBackdropClasses, themeControlSurfaceClasses, themeOverlayBackdropClasses, themeOverlaySurfaceClasses, themeRaisedBackdropClasses, themeRaisedSurfaceClasses, themeSelectionBarClasses, themeSelectionBorderClasses, toCssValue, toHeadingLevel };
|
|
959
964
|
|
|
960
965
|
//# sourceMappingURL=nanahoshi-mona-ui-internal.mjs.map
|