@nanahoshi/mona-ui 0.40.0 → 0.42.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/auto-complete.md +2 -0
- package/docs/api/combo-box.md +2 -0
- package/docs/api/common.md +1 -1
- package/docs/api/dropdowns.md +3 -1
- package/docs/api/i18n.md +54 -0
- package/docs/api/kanban.md +222 -0
- package/docs/api/locales.md +14 -14
- package/docs/api/sortable.md +189 -0
- package/docs/api/sparkline.md +85 -0
- package/docs/api/tabs.md +20 -0
- package/docs/auto-complete.md +64 -0
- package/docs/combo-box.md +65 -0
- package/docs/kanban.md +293 -0
- package/docs/sortable.md +320 -0
- package/docs/sparkline.md +303 -0
- package/docs/tabs.md +59 -10
- package/fesm2022/nanahoshi-mona-ui-auto-complete.mjs +95 -30
- package/fesm2022/nanahoshi-mona-ui-combo-box.mjs +58 -5
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +64 -29
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +87 -0
- package/fesm2022/nanahoshi-mona-ui-kanban.mjs +660 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +44 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +44 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +14 -0
- package/fesm2022/nanahoshi-mona-ui-sortable.mjs +733 -0
- package/fesm2022/nanahoshi-mona-ui-sparkline.mjs +573 -0
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +112 -5
- package/i18n/catalogs/en-US.messages.json +14 -0
- package/kanban/package.json +4 -0
- package/llms.txt +8 -2
- package/locales/ar-sa/ar-sa.messages.json +14 -0
- package/locales/de-de/de-de.messages.json +14 -0
- package/locales/es-es/es-es.messages.json +14 -0
- package/locales/fr-fr/fr-fr.messages.json +14 -0
- package/locales/id-id/id-id.messages.json +14 -0
- package/locales/it-it/it-it.messages.json +14 -0
- package/locales/ja-jp/ja-jp.messages.json +14 -0
- package/locales/ko-kr/ko-kr.messages.json +14 -0
- package/locales/pl-pl/pl-pl.messages.json +14 -0
- package/locales/pt-br/pt-br.messages.json +14 -0
- package/locales/ru-ru/ru-ru.messages.json +14 -0
- package/locales/tr-tr/tr-tr.messages.json +14 -0
- package/locales/zh-cn/zh-cn.messages.json +14 -0
- package/locales/zh-tw/zh-tw.messages.json +14 -0
- package/package.json +13 -1
- package/sortable/package.json +4 -0
- package/sparkline/package.json +4 -0
- package/types/nanahoshi-mona-ui-auto-complete.d.ts +42 -1
- package/types/nanahoshi-mona-ui-combo-box.d.ts +37 -1
- package/types/nanahoshi-mona-ui-dropdowns.d.ts +54 -4
- package/types/nanahoshi-mona-ui-i18n.d.ts +31 -0
- package/types/nanahoshi-mona-ui-kanban.d.ts +270 -0
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +14 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +14 -0
- package/types/nanahoshi-mona-ui-sortable.d.ts +245 -0
- package/types/nanahoshi-mona-ui-sparkline.d.ts +228 -0
- package/types/nanahoshi-mona-ui-tabs.d.ts +46 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
# Sparkline
|
|
2
|
+
|
|
3
|
+
> A word-sized line, area, column or win-loss chart, for a table cell or a line of text.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/sparkline`
|
|
6
|
+
|
|
7
|
+
**Selector:** `mona-sparkline`
|
|
8
|
+
|
|
9
|
+
`SparklineComponent` draws a series of values as a chart the size of a word, to sit on a line of text or in a table cell: a line, an area, columns or wins and losses. It has no axes, legend or tooltips; it shows a trend at a glance, next to the numbers that give it.
|
|
10
|
+
|
|
11
|
+
Screen readers read it as an image, with its name and a summary of its values: how many, the first, the last, the lowest and the highest.
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
Give the sparkline its values and a name. It draws them from left to right, scaled to fill its box, which is 6rem wide and 1.5rem tall unless a class sizes it.
|
|
16
|
+
|
|
17
|
+
**Use Sparkline when:**
|
|
18
|
+
|
|
19
|
+
- A trend matters more than its values: in a table row, a dashboard tile or a sentence.
|
|
20
|
+
- Many small charts should compare at a glance, on one scale.
|
|
21
|
+
|
|
22
|
+
To read values off axes, see a tooltip or interact with the data, use a [chart](chart.md).
|
|
23
|
+
|
|
24
|
+
## Import & Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { SparklineComponent } from "@nanahoshi/mona-ui/sparkline";
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<mona-sparkline aria-label="Visitors per day" [data]="visitors" />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
protected readonly visitors = [320, 410, 380, 520, 490, 610, 580, 720];
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Examples
|
|
39
|
+
|
|
40
|
+
### Line, area, column and win-loss
|
|
41
|
+
|
|
42
|
+
`type` sets how the values are drawn. A column sparkline stands its bars on zero, in the error color below it. A win-loss sparkline draws a bar up for each positive value, down for each negative one, and a short tick for each zero, all of one height.
|
|
43
|
+
|
|
44
|
+
`types-example.component.ts`
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { Component } from "@angular/core";
|
|
48
|
+
import { SparklineComponent } from "@nanahoshi/mona-ui/sparkline";
|
|
49
|
+
|
|
50
|
+
@Component({
|
|
51
|
+
selector: "app-sparkline-types-example",
|
|
52
|
+
imports: [SparklineComponent],
|
|
53
|
+
templateUrl: "./types-example.component.html"
|
|
54
|
+
})
|
|
55
|
+
export class SparklineTypesExampleComponent {
|
|
56
|
+
protected readonly results = [1, 1, -1, 0, 1, -1, -1, 1, 1, 0, 1, 1];
|
|
57
|
+
protected readonly revenueChange = [4, 7, -2, 5, 9, -6, 3, 8, -3, 6];
|
|
58
|
+
protected readonly signUps = [12, 15, 14, 22, 28, 24, 31, 36, 33, 41];
|
|
59
|
+
protected readonly visitors = [320, 410, 380, 520, 490, 610, 580, 720, 690, 840];
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
`types-example.component.html`
|
|
64
|
+
|
|
65
|
+
```html
|
|
66
|
+
<dl class="grid max-w-md grid-cols-[8rem_auto] items-center gap-x-6 gap-y-4 text-sm">
|
|
67
|
+
<dt class="text-muted-foreground">Line</dt>
|
|
68
|
+
<dd><mona-sparkline aria-label="Visitors per day" [data]="visitors" /></dd>
|
|
69
|
+
|
|
70
|
+
<dt class="text-muted-foreground">Area</dt>
|
|
71
|
+
<dd><mona-sparkline aria-label="Sign-ups per day" type="area" [data]="signUps" /></dd>
|
|
72
|
+
|
|
73
|
+
<dt class="text-muted-foreground">Column</dt>
|
|
74
|
+
<dd><mona-sparkline aria-label="Change in revenue per month" type="column" [data]="revenueChange" /></dd>
|
|
75
|
+
|
|
76
|
+
<dt class="text-muted-foreground">Win-loss</dt>
|
|
77
|
+
<dd><mona-sparkline aria-label="Results of the last 12 matches" type="win-loss" [data]="results" /></dd>
|
|
78
|
+
</dl>
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Smooth and stepped lines
|
|
82
|
+
|
|
83
|
+
`curve` sets how a line or an area joins its values, with the same choices as a chart's line series:
|
|
84
|
+
|
|
85
|
+
- `"linear"`, the default, joins them with straight segments.
|
|
86
|
+
- `"monotone-x"` draws a smooth curve that never swings past the values, so none looks higher or lower than it is.
|
|
87
|
+
- `"natural"` is smoother still, but it can overshoot where the values rise and fall sharply.
|
|
88
|
+
- `"step"` changes halfway between values.
|
|
89
|
+
- `"step-after"` holds each value until the next, for something that changes at a moment, such as a price, a plan or a stock level.
|
|
90
|
+
|
|
91
|
+
Columns and win-loss bars ignore it.
|
|
92
|
+
|
|
93
|
+
`curves-example.component.ts`
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { Component } from "@angular/core";
|
|
97
|
+
import { SparklineComponent } from "@nanahoshi/mona-ui/sparkline";
|
|
98
|
+
|
|
99
|
+
@Component({
|
|
100
|
+
selector: "app-sparkline-curves-example",
|
|
101
|
+
imports: [SparklineComponent],
|
|
102
|
+
templateUrl: "./curves-example.component.html"
|
|
103
|
+
})
|
|
104
|
+
export class SparklineCurvesExampleComponent {
|
|
105
|
+
protected readonly orders = [14, 22, 18, 30, 26, 41, 35, 38, 52, 47];
|
|
106
|
+
protected readonly plan = [10, 10, 10, 25, 25, 25, 25, 50, 50, 50];
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`curves-example.component.html`
|
|
111
|
+
|
|
112
|
+
```html
|
|
113
|
+
<dl class="grid max-w-md grid-cols-[8rem_auto] items-center gap-x-6 gap-y-4 text-sm">
|
|
114
|
+
<dt class="text-muted-foreground">Linear</dt>
|
|
115
|
+
<dd><mona-sparkline aria-label="Orders per day" [data]="orders" /></dd>
|
|
116
|
+
|
|
117
|
+
<dt class="text-muted-foreground">Monotone</dt>
|
|
118
|
+
<dd><mona-sparkline aria-label="Orders per day" curve="monotone-x" [data]="orders" /></dd>
|
|
119
|
+
|
|
120
|
+
<dt class="text-muted-foreground">Natural</dt>
|
|
121
|
+
<dd><mona-sparkline aria-label="Orders per day" curve="natural" [data]="orders" /></dd>
|
|
122
|
+
|
|
123
|
+
<dt class="text-muted-foreground">Step</dt>
|
|
124
|
+
<dd><mona-sparkline aria-label="Orders per day" curve="step" type="area" [data]="orders" /></dd>
|
|
125
|
+
|
|
126
|
+
<dt class="text-muted-foreground">Step after</dt>
|
|
127
|
+
<dd><mona-sparkline aria-label="Plan limit per month" curve="step-after" type="area" [data]="plan" /></dd>
|
|
128
|
+
</dl>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### In a table
|
|
132
|
+
|
|
133
|
+
Give every row's sparkline the same `min` and `max`, and they share a scale, so their heights compare. `markers` puts a dot on the latest week.
|
|
134
|
+
|
|
135
|
+
`table-example.component.ts`
|
|
136
|
+
|
|
137
|
+
```typescript
|
|
138
|
+
import { Component } from "@angular/core";
|
|
139
|
+
import { SparklineComponent } from "@nanahoshi/mona-ui/sparkline";
|
|
140
|
+
|
|
141
|
+
interface Product {
|
|
142
|
+
readonly name: string;
|
|
143
|
+
readonly total: number;
|
|
144
|
+
readonly weeks: readonly number[];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
function product(name: string, weeks: readonly number[]): Product {
|
|
148
|
+
return { name, total: weeks.reduce((sum, units) => sum + units, 0), weeks };
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
@Component({
|
|
152
|
+
selector: "app-sparkline-table-example",
|
|
153
|
+
imports: [SparklineComponent],
|
|
154
|
+
templateUrl: "./table-example.component.html"
|
|
155
|
+
})
|
|
156
|
+
export class SparklineTableExampleComponent {
|
|
157
|
+
protected readonly products: readonly Product[] = [
|
|
158
|
+
product("Desk lamp", [42, 38, 45, 51, 48, 56, 61, 58, 66, 72, 69, 78]),
|
|
159
|
+
product("Notebook", [80, 76, 71, 74, 68, 65, 62, 66, 59, 55, 57, 52]),
|
|
160
|
+
product("Water bottle", [20, 24, 31, 45, 62, 70, 74, 69, 51, 38, 29, 24]),
|
|
161
|
+
product("Headphones", [33, 35, 34, 36, 35, 37, 36, 38, 37, 39, 38, 40])
|
|
162
|
+
];
|
|
163
|
+
/** One scale for every row, so the sparklines compare. */
|
|
164
|
+
protected readonly highest = Math.max(...this.products.flatMap(item => item.weeks));
|
|
165
|
+
}
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`table-example.component.html`
|
|
169
|
+
|
|
170
|
+
```html
|
|
171
|
+
<table class="w-full max-w-lg text-sm">
|
|
172
|
+
<thead class="text-muted-foreground">
|
|
173
|
+
<tr>
|
|
174
|
+
<th scope="col" class="pb-2 text-start font-medium">Product</th>
|
|
175
|
+
<th scope="col" class="pb-2 text-start font-medium">Last 12 weeks</th>
|
|
176
|
+
<th scope="col" class="pb-2 text-end font-medium">Units</th>
|
|
177
|
+
</tr>
|
|
178
|
+
</thead>
|
|
179
|
+
<tbody>
|
|
180
|
+
@for (product of products; track product.name) {
|
|
181
|
+
<tr class="border-t border-border">
|
|
182
|
+
<th scope="row" class="py-2 text-start font-medium">{{ product.name }}</th>
|
|
183
|
+
<td class="py-2">
|
|
184
|
+
<mona-sparkline
|
|
185
|
+
class="w-32"
|
|
186
|
+
[aria-label]="'Weekly units of ' + product.name"
|
|
187
|
+
[data]="product.weeks"
|
|
188
|
+
[markers]="['last']"
|
|
189
|
+
[max]="highest"
|
|
190
|
+
[min]="0" />
|
|
191
|
+
</td>
|
|
192
|
+
<td class="py-2 text-end tabular-nums">{{ product.total }}</td>
|
|
193
|
+
</tr>
|
|
194
|
+
}
|
|
195
|
+
</tbody>
|
|
196
|
+
</table>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### Markers and a reference line
|
|
200
|
+
|
|
201
|
+
`markers` marks the first, the last, the lowest and the highest values with dots. `referenceValue` draws a dashed line at a target or an average, and the range widens to show it. `color` sets the sparkline's color, and `format` how the summary reads its values.
|
|
202
|
+
|
|
203
|
+
`reference-example.component.ts`
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
import { Component } from "@angular/core";
|
|
207
|
+
import { SparklineComponent } from "@nanahoshi/mona-ui/sparkline";
|
|
208
|
+
|
|
209
|
+
@Component({
|
|
210
|
+
selector: "app-sparkline-reference-example",
|
|
211
|
+
imports: [SparklineComponent],
|
|
212
|
+
templateUrl: "./reference-example.component.html"
|
|
213
|
+
})
|
|
214
|
+
export class SparklineReferenceExampleComponent {
|
|
215
|
+
protected readonly milliseconds: Intl.NumberFormatOptions = { style: "unit", unit: "millisecond" };
|
|
216
|
+
protected readonly responseTimes = [172, 168, 181, 195, 214, 231, 208, 193, 188, 179, 191, 186];
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`reference-example.component.html`
|
|
221
|
+
|
|
222
|
+
```html
|
|
223
|
+
<div class="flex max-w-md flex-col gap-1 rounded-lg border border-border p-4">
|
|
224
|
+
<span class="text-sm text-muted-foreground">Response time, target 200 ms</span>
|
|
225
|
+
<div class="flex items-center gap-4">
|
|
226
|
+
<span class="text-2xl font-semibold tabular-nums">186 ms</span>
|
|
227
|
+
<mona-sparkline
|
|
228
|
+
aria-label="Response time per hour, against a target of 200 ms"
|
|
229
|
+
class="h-10 w-48"
|
|
230
|
+
color="var(--color-chart-3)"
|
|
231
|
+
type="area"
|
|
232
|
+
[data]="responseTimes"
|
|
233
|
+
[format]="milliseconds"
|
|
234
|
+
[markers]="['min', 'max', 'last']"
|
|
235
|
+
[referenceValue]="200" />
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
## Appearance & Styling
|
|
241
|
+
|
|
242
|
+
The sparkline is an inline block, aligned to the middle of the text around it. Size it with a class, such as `class="h-8 w-40"`.
|
|
243
|
+
|
|
244
|
+
Its colors are custom properties, so a class or a style sheet can set them too:
|
|
245
|
+
|
|
246
|
+
| Custom property | Input | Default | Colors |
|
|
247
|
+
| --- | --- | --- | --- |
|
|
248
|
+
| `--mona-sparkline-color` | `color` | The first chart color, `--color-chart-1` | The line, the area, columns above zero and wins |
|
|
249
|
+
| `--mona-sparkline-negative-color` | `negativeColor` | The error color, `--color-error` | Columns below zero and losses |
|
|
250
|
+
|
|
251
|
+
The line is 1.5 pixels wide and markers are 5 pixels across, whatever the sparkline's size. An area under the line is a wash of its color, with the line carrying the shape. Keep a color you choose at 3:1 against the background, as the default chart colors are. In forced colors, the sparkline is drawn in the system's text color.
|
|
252
|
+
|
|
253
|
+
## Behavior
|
|
254
|
+
|
|
255
|
+
### Values and gaps
|
|
256
|
+
|
|
257
|
+
`data` takes the values in order. A `null`, or anything that isn't a finite number, leaves a gap: the line breaks there, and a value alone between gaps shows as a dot. Gaps keep their place, so the values on either side stay where they'd be. A curve joins each run of values between gaps on its own.
|
|
258
|
+
|
|
259
|
+
### The range
|
|
260
|
+
|
|
261
|
+
Without `min` and `max`, the lowest value is at the bottom and the highest at the top. Columns always take zero into the range, as they stand on it, and so does a reference value. Values outside a range you set are drawn at its edge. When all the values are the same, the line runs across the middle. A `"natural"` curve can swing a little past the lowest and highest values, and out of the box; `"monotone-x"` stays inside it.
|
|
262
|
+
|
|
263
|
+
An area fills down to zero when the values cross it, and to the bottom edge when they're all above it.
|
|
264
|
+
|
|
265
|
+
### Direction
|
|
266
|
+
|
|
267
|
+
Values run from left to right in right-to-left layouts too, as on a chart's axis.
|
|
268
|
+
|
|
269
|
+
## Accessibility
|
|
270
|
+
|
|
271
|
+
The sparkline is an image (`role="img"`) to assistive technology. `aria-label` names it, and a summary of its values describes it: "12 values, first 6, last 15, lowest 4, highest 18", or for a win-loss sparkline, "7 wins, 3 losses, 1 draw". Without a name, the summary is its name. `format` sets how the summary formats values, such as a currency, in the locale's number format.
|
|
272
|
+
|
|
273
|
+
When the text beside a sparkline already gives its values, set `decorative` to hide it from assistive technology.
|
|
274
|
+
|
|
275
|
+
The sparkline isn't focusable and has no keyboard interaction.
|
|
276
|
+
|
|
277
|
+
### ARIA
|
|
278
|
+
|
|
279
|
+
| Attribute | When present | Value |
|
|
280
|
+
| --- | --- | --- |
|
|
281
|
+
| `role` | Unless `decorative` | `"img"` |
|
|
282
|
+
| `aria-label` | Unless `decorative` | The `aria-label` input, or the summary without one |
|
|
283
|
+
| `aria-describedby` | With a name, or `aria-describedby` given | The ids given, then the summary's |
|
|
284
|
+
| `aria-hidden` | `decorative` is set | `"true"` |
|
|
285
|
+
|
|
286
|
+
## API
|
|
287
|
+
|
|
288
|
+
Everything below is imported from `@nanahoshi/mona-ui/sparkline`. Each name links to its reference page, with every input, output, property and method.
|
|
289
|
+
|
|
290
|
+
| Name | Kind | Description |
|
|
291
|
+
| --- | --- | --- |
|
|
292
|
+
| [`SparklineComponent`](api/sparkline.md#sparklinecomponent) | Component | A word-sized chart of a series of values, to sit on a line of text or in a table cell: a line, an area, columns or wins and losses. |
|
|
293
|
+
|
|
294
|
+
### Types
|
|
295
|
+
|
|
296
|
+
| Type | Kind | Description |
|
|
297
|
+
| --- | --- | --- |
|
|
298
|
+
| [`SPARKLINE_DEFAULT_MESSAGES`](api/sparkline.md#sparkline-default-messages) | Constant | |
|
|
299
|
+
| [`SparklineCurve`](api/sparkline.md#sparklinecurve) | Type alias | How a line or an area sparkline joins its values, as a chart's line series does: `"linear"` with straight segments, `"monotone-x"` with a smooth curve that never swings past the values, `"natural"` with a smoother curve that can, `"step"` in steps that change halfway between values, and `"step-after"` in steps that hold each value until the next one. |
|
|
300
|
+
| [`SparklineMarker`](api/sparkline.md#sparklinemarker) | Type alias | A value a line or area sparkline marks with a dot: its first, its last, its lowest or its highest. |
|
|
301
|
+
| [`SparklineType`](api/sparkline.md#sparklinetype) | Type alias | How a sparkline draws its values: `"line"` joins them, `"area"` fills under the line, `"column"` draws a bar for each from zero, and `"win-loss"` draws a bar up for each positive value, down for each negative one and a short tick for each zero, all of one height. |
|
|
302
|
+
|
|
303
|
+
**Related types:** [`MonaSparklineMessages`](api/i18n.md#monasparklinemessages)
|
package/docs/tabs.md
CHANGED
|
@@ -182,6 +182,53 @@ export class TabsClosableExampleComponent {
|
|
|
182
182
|
|
|
183
183
|
Closing a tab is entirely the consumer's responsibility — see [Tabs are removed by the consumer](#tabs-are-removed-by-the-consumer).
|
|
184
184
|
|
|
185
|
+
### Reordering tabs
|
|
186
|
+
|
|
187
|
+
`sortable` lets the user reorder the tabs: by dragging one along the strip, or with `Control+Shift` and the arrow keys along it, `Home` or `End` (`Command+Shift` on macOS). As with closing, the component only reports the move: `tabReorder` carries the tab's `previousIndex` and `currentIndex`, and moving it in whatever renders the `mona-tab` elements is what moves it. `moveItem` from `@nanahoshi/mona-ui/sortable` returns the reordered copy of an array.
|
|
188
|
+
|
|
189
|
+
`sortable-example.component.ts`
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
import { Component, signal } from "@angular/core";
|
|
193
|
+
import { moveItem } from "@nanahoshi/mona-ui/sortable";
|
|
194
|
+
import {
|
|
195
|
+
type TabReorderEvent,
|
|
196
|
+
TabComponent,
|
|
197
|
+
TabContentTemplateDirective,
|
|
198
|
+
TabsComponent
|
|
199
|
+
} from "@nanahoshi/mona-ui/tabs";
|
|
200
|
+
|
|
201
|
+
@Component({
|
|
202
|
+
selector: "app-tabs-sortable-example",
|
|
203
|
+
imports: [TabComponent, TabContentTemplateDirective, TabsComponent],
|
|
204
|
+
templateUrl: "./sortable-example.component.html"
|
|
205
|
+
})
|
|
206
|
+
export class TabsSortableExampleComponent {
|
|
207
|
+
protected readonly files = signal(["index.html", "styles.css", "main.ts", "README.md"]);
|
|
208
|
+
|
|
209
|
+
/** The tabs only report the move; reordering the data is what moves the tab. */
|
|
210
|
+
protected reorder(event: TabReorderEvent): void {
|
|
211
|
+
this.files.update(files => moveItem(files, event.previousIndex, event.currentIndex));
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
`sortable-example.component.html`
|
|
217
|
+
|
|
218
|
+
```html
|
|
219
|
+
<mona-tabs aria-label="Open files" class="w-[28rem] max-w-full" sortable (tabReorder)="reorder($event)">
|
|
220
|
+
@for (file of files(); track file) {
|
|
221
|
+
<mona-tab [title]="file">
|
|
222
|
+
<ng-template monaTabContentTemplate>
|
|
223
|
+
<p class="p-4 text-sm">The contents of {{ file }}.</p>
|
|
224
|
+
</ng-template>
|
|
225
|
+
</mona-tab>
|
|
226
|
+
}
|
|
227
|
+
</mona-tabs>
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
The selected tab stays selected wherever it moves, and `selectedIndex` follows it. A disabled tab can't be dragged or moved, but other tabs move past it. Each move is announced: "main.ts moved to position 1 of 4". On a touch screen, press and hold a tab to pick it up, so a swipe still scrolls the strip.
|
|
231
|
+
|
|
185
232
|
### Disabled tabs
|
|
186
233
|
|
|
187
234
|
`disabled` on `mona-tabs` disables every tab. `disabled` on an individual `mona-tab` disables only that tab, even if the parent's `disabled` is `false`. A disabled tab cannot be selected or closed by pointer or keyboard. A tab that becomes disabled while it's selected stays selected until something else is chosen, so its panel doesn't disappear from under the user.
|
|
@@ -385,12 +432,13 @@ Not applicable. `TabsComponent` and `TabComponent` are not form controls and do
|
|
|
385
432
|
| `ArrowUp` / `ArrowDown` (left/right) | Select the previous/next enabled tab, wrapping around at the ends. Disabled tabs are skipped. |
|
|
386
433
|
| `Home` / `End` | Select the first/last enabled tab. |
|
|
387
434
|
| `Delete` / `Backspace` | Close the tab that has focus, if it is closable and not disabled. |
|
|
435
|
+
| `Control+Shift` with the strip's arrow keys, `Home` or `End` (`Command+Shift` on macOS) | With `sortable`: move the focused tab one place, or to the start or end of the strip. |
|
|
388
436
|
| `Tab` | Moves focus from the tab strip into the selected tab's panel. |
|
|
389
437
|
| `Shift+Tab` (while the panel itself has focus) | Moves focus back to the selected tab. |
|
|
390
438
|
|
|
391
439
|
In a right-to-left layout, `ArrowLeft` and `ArrowRight` swap, so they still follow the strip.
|
|
392
440
|
|
|
393
|
-
These keys are left to the browser when `Alt`, `Ctrl` or `Meta` is held, so `Alt+ArrowLeft` still goes back, and when `Shift` is held on the arrows.
|
|
441
|
+
These keys are left to the browser when `Alt`, `Ctrl` or `Meta` is held, so `Alt+ArrowLeft` still goes back, and when `Shift` is held on the arrows, except for the moves of a `sortable` strip.
|
|
394
442
|
|
|
395
443
|
The close button on each tab is not a Tab stop; keyboard users close a tab with `Delete`/`Backspace` instead of activating the close button directly.
|
|
396
444
|
|
|
@@ -412,7 +460,7 @@ The selected tab is the only tab in the Tab order (`tabindex="0"`); all other ta
|
|
|
412
460
|
| Tab | `aria-selected` | Always | Reflects whether the tab is the active tab |
|
|
413
461
|
| Tab | `aria-disabled` | Always | Reflects the tab's effective disabled state (own `disabled`, or the parent's `disabled`) |
|
|
414
462
|
| Tab | `aria-controls` | Always | The corresponding panel's element id |
|
|
415
|
-
| Tab | `aria-keyshortcuts` | The tab can close and isn't disabled
|
|
463
|
+
| Tab | `aria-keyshortcuts` | The tab can close, or the strip is `sortable`, and the tab isn't disabled | `"Delete Backspace"` when it can close, then the moves, such as `"Control+Shift+ArrowLeft Control+Shift+ArrowRight Control+Shift+Home Control+Shift+End"` |
|
|
416
464
|
| Panel | `role` | Always | `"tabpanel"` |
|
|
417
465
|
| Panel | `aria-hidden` | Always | `"true"` on a kept panel that isn't the active one, otherwise `"false"` |
|
|
418
466
|
| Panel | `aria-labelledby` | Always | The corresponding tab's element id |
|
|
@@ -425,14 +473,15 @@ A tab list may only contain tabs, and a tab's content is presentational, so a cl
|
|
|
425
473
|
|
|
426
474
|
Everything below is imported from `@nanahoshi/mona-ui/tabs`. Each name links to its reference page, with every input, output, property and method.
|
|
427
475
|
|
|
428
|
-
| Name | Kind |
|
|
429
|
-
| --- | --- |
|
|
430
|
-
| [`TabsComponent`](api/tabs.md#tabscomponent) | Component |
|
|
431
|
-
| [`TabComponent`](api/tabs.md#tabcomponent) | Component |
|
|
432
|
-
| [`TabContentTemplateDirective`](api/tabs.md#tabcontenttemplatedirective) | Directive |
|
|
433
|
-
| [`TabTitleTemplateDirective`](api/tabs.md#tabtitletemplatedirective) | Directive |
|
|
434
|
-
| [`TabCloseEvent`](api/tabs.md#tabcloseevent) | Class |
|
|
435
|
-
| [`
|
|
476
|
+
| Name | Kind | Description |
|
|
477
|
+
| --- | --- | --- |
|
|
478
|
+
| [`TabsComponent`](api/tabs.md#tabscomponent) | Component | |
|
|
479
|
+
| [`TabComponent`](api/tabs.md#tabcomponent) | Component | |
|
|
480
|
+
| [`TabContentTemplateDirective`](api/tabs.md#tabcontenttemplatedirective) | Directive | |
|
|
481
|
+
| [`TabTitleTemplateDirective`](api/tabs.md#tabtitletemplatedirective) | Directive | |
|
|
482
|
+
| [`TabCloseEvent`](api/tabs.md#tabcloseevent) | Class | |
|
|
483
|
+
| [`TabReorderEvent`](api/tabs.md#tabreorderevent) | Class | A tab dragged, or moved with Control+Shift and an arrow key, Home or End, to a new place in a sortable tab strip. |
|
|
484
|
+
| [`TabSelectEvent`](api/tabs.md#tabselectevent) | Class | |
|
|
436
485
|
|
|
437
486
|
### Types
|
|
438
487
|
|