@nanahoshi/mona-ui 0.39.1 → 0.41.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/common.md +1 -1
- package/docs/api/grid.md +214 -17
- package/docs/api/i18n.md +36 -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/tabs.md +20 -0
- package/docs/grid-selection.md +134 -9
- package/docs/grid-state-export.md +56 -6
- package/docs/grid-tree.md +279 -0
- package/docs/kanban.md +293 -0
- package/docs/sortable.md +320 -0
- package/docs/tabs.md +59 -10
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-colgroup.component-Lv3GunpV.mjs → nanahoshi-mona-ui-grid-grid-colgroup.component-DpszxgFY.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-BYH9XbCV.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-CpvzAcX8.mjs} +4 -3
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-BoSXXLKQ.mjs → nanahoshi-mona-ui-grid-grid-list.component-tRmEWiQR.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-Df2gfS0X.mjs → nanahoshi-mona-ui-grid-grid-row.component-eET6dh2Q.mjs} +52 -35
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-xjrcCXXF.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-8h2EMexB.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid.styles-aPD3c2A6.mjs → nanahoshi-mona-ui-grid-grid.styles-wAf6jsT9.mjs} +646 -20
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +1663 -22
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +56 -0
- package/fesm2022/nanahoshi-mona-ui-kanban.mjs +660 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +17 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +17 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +17 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +17 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +21 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +17 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +21 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +11 -0
- package/fesm2022/nanahoshi-mona-ui-sortable.mjs +733 -0
- package/fesm2022/nanahoshi-mona-ui-tabs.mjs +112 -5
- package/i18n/catalogs/en-US.messages.json +11 -0
- package/kanban/package.json +4 -0
- package/llms.txt +10 -5
- package/locales/ar-sa/ar-sa.messages.json +11 -0
- package/locales/de-de/de-de.messages.json +11 -0
- package/locales/es-es/es-es.messages.json +11 -0
- package/locales/fr-fr/fr-fr.messages.json +11 -0
- package/locales/id-id/id-id.messages.json +11 -0
- package/locales/it-it/it-it.messages.json +11 -0
- package/locales/ja-jp/ja-jp.messages.json +11 -0
- package/locales/ko-kr/ko-kr.messages.json +11 -0
- package/locales/pl-pl/pl-pl.messages.json +11 -0
- package/locales/pt-br/pt-br.messages.json +11 -0
- package/locales/ru-ru/ru-ru.messages.json +11 -0
- package/locales/tr-tr/tr-tr.messages.json +11 -0
- package/locales/zh-cn/zh-cn.messages.json +11 -0
- package/locales/zh-tw/zh-tw.messages.json +11 -0
- package/package.json +9 -1
- package/sortable/package.json +4 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +305 -3
- package/types/nanahoshi-mona-ui-i18n.d.ts +23 -0
- package/types/nanahoshi-mona-ui-kanban.d.ts +270 -0
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +11 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +11 -0
- package/types/nanahoshi-mona-ui-sortable.d.ts +245 -0
- package/types/nanahoshi-mona-ui-tabs.d.ts +46 -0
package/docs/sortable.md
ADDED
|
@@ -0,0 +1,320 @@
|
|
|
1
|
+
# Sortable
|
|
2
|
+
|
|
3
|
+
> Lets users reorder any list by dragging or with the keyboard, and move items between connected lists.
|
|
4
|
+
|
|
5
|
+
Entry point: `@nanahoshi/mona-ui/sortable`
|
|
6
|
+
|
|
7
|
+
**Selectors:** `[monaSortable]`, `[monaSortableItem]`, `[monaSortableGroup]`, `[monaSortableHandle]`
|
|
8
|
+
|
|
9
|
+
`SortableDirective` lets users reorder the items of a list you render yourself, such as a list of priorities, a row of chips or a grid of dashboard tiles. They drag an item to its new place, or focus it and press Control+Shift with an arrow key, and each move is announced to screen readers. Lists inside a `monaSortableGroup` exchange items, as the columns of a board do.
|
|
10
|
+
|
|
11
|
+
The directive adds no markup or roles: your list keeps its own. To reorder tabs, use the `sortable` input of [Tabs](tabs.md); for a board of columns, use [Kanban](kanban.md), which is built on this directive.
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
Put `monaSortable` on a list element and `monaSortableItem` on each item, and give them your data: the array on the list, and each item's element of it. When the user moves an item, the list emits its new array; it doesn't reorder its elements itself. Bind the array two-way and the new order renders.
|
|
16
|
+
|
|
17
|
+
**Use Sortable when:**
|
|
18
|
+
|
|
19
|
+
- Users choose an order that matters to them: priorities, the columns a table shows, the widgets on a dashboard.
|
|
20
|
+
- Items move between a few lists, such as shown and hidden fields.
|
|
21
|
+
|
|
22
|
+
For a list with selection and a toolbar of move buttons, use [List Box](list-box.md). For a board of columns with counts and limits, use [Kanban](kanban.md).
|
|
23
|
+
|
|
24
|
+
## Import & Quick Start
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import { SortableDirective, SortableItemDirective } from "@nanahoshi/mona-ui/sortable";
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<ol aria-label="Priorities" [(monaSortable)]="priorities">
|
|
32
|
+
@for (priority of priorities(); track priority) {
|
|
33
|
+
<li tabindex="0" [monaSortableItem]="priority">{{ priority }}</li>
|
|
34
|
+
}
|
|
35
|
+
</ol>
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
protected readonly priorities = signal(["Fix the sign-in bug", "Write the release notes", "Plan the offsite"]);
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Render every element of the array as an item, in the array's order: the list maps the positions the user sees to the array's indexes. Track items by something stable, such as the item itself or its id, so a moved item keeps its element.
|
|
43
|
+
|
|
44
|
+
## Anatomy
|
|
45
|
+
|
|
46
|
+
| Directive | Selector | Goes on |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| `SortableDirective` | `[monaSortable]` | The element that holds the items |
|
|
49
|
+
| `SortableItemDirective` | `[monaSortableItem]` | Each item, given its element of the array |
|
|
50
|
+
| `SortableGroupDirective` | `[monaSortableGroup]` | An element around lists that exchange items |
|
|
51
|
+
| `SortableHandleDirective` | `[monaSortableHandle]` | The part of an item that starts a drag, when only part of it should |
|
|
52
|
+
|
|
53
|
+
## Examples
|
|
54
|
+
|
|
55
|
+
### A sortable list
|
|
56
|
+
|
|
57
|
+
`[(monaSortable)]` gives the list its array and takes each new order. `sortableLockAxis` keeps a dragged item on the list's axis, up and down here. The row numbers are hidden from screen readers, so the announcement names the item by its text alone.
|
|
58
|
+
|
|
59
|
+
`list-example.component.ts`
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { Component, signal } from "@angular/core";
|
|
63
|
+
import { SortableDirective, SortableItemDirective } from "@nanahoshi/mona-ui/sortable";
|
|
64
|
+
|
|
65
|
+
@Component({
|
|
66
|
+
selector: "app-sortable-list-example",
|
|
67
|
+
imports: [SortableDirective, SortableItemDirective],
|
|
68
|
+
templateUrl: "./list-example.component.html"
|
|
69
|
+
})
|
|
70
|
+
export class SortableListExampleComponent {
|
|
71
|
+
protected readonly priorities = signal([
|
|
72
|
+
"Fix the sign-in bug",
|
|
73
|
+
"Write the release notes",
|
|
74
|
+
"Review the onboarding design",
|
|
75
|
+
"Plan the team offsite"
|
|
76
|
+
]);
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`list-example.component.html`
|
|
81
|
+
|
|
82
|
+
```html
|
|
83
|
+
<div class="flex w-80 max-w-full flex-col gap-3">
|
|
84
|
+
<ol aria-label="Priorities" class="flex flex-col gap-1" [(monaSortable)]="priorities" sortableLockAxis>
|
|
85
|
+
@for (priority of priorities(); track priority; let index = $index) {
|
|
86
|
+
<li
|
|
87
|
+
tabindex="0"
|
|
88
|
+
class="flex cursor-grab items-center gap-3 rounded-md border border-border bg-card px-3 py-2 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-indicator"
|
|
89
|
+
[monaSortableItem]="priority">
|
|
90
|
+
<span aria-hidden="true" class="w-4 text-end text-muted-foreground tabular-nums">{{ index + 1 }}</span>
|
|
91
|
+
{{ priority }}
|
|
92
|
+
</li>
|
|
93
|
+
}
|
|
94
|
+
</ol>
|
|
95
|
+
<p class="text-sm text-muted-foreground">Up first: {{ priorities()[0] }}</p>
|
|
96
|
+
</div>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Moving items between lists
|
|
100
|
+
|
|
101
|
+
Lists inside a `monaSortableGroup` exchange items. Each list emits its own new array, so bind each one two-way. `sortableCanEnter` decides whether an item from another list may come in, here only while fewer than five columns are shown; the list's own items can always be reordered.
|
|
102
|
+
|
|
103
|
+
`connected-example.component.ts`
|
|
104
|
+
|
|
105
|
+
```typescript
|
|
106
|
+
import { Component, signal } from "@angular/core";
|
|
107
|
+
import { SortableDirective, SortableGroupDirective, SortableItemDirective } from "@nanahoshi/mona-ui/sortable";
|
|
108
|
+
|
|
109
|
+
/** The most columns the table shows. */
|
|
110
|
+
const MAX_SHOWN = 5;
|
|
111
|
+
|
|
112
|
+
@Component({
|
|
113
|
+
selector: "app-sortable-connected-example",
|
|
114
|
+
imports: [SortableDirective, SortableGroupDirective, SortableItemDirective],
|
|
115
|
+
templateUrl: "./connected-example.component.html"
|
|
116
|
+
})
|
|
117
|
+
export class SortableConnectedExampleComponent {
|
|
118
|
+
protected readonly hidden = signal(["Email", "Phone", "Country", "Start date"]);
|
|
119
|
+
protected readonly maxShown = MAX_SHOWN;
|
|
120
|
+
protected readonly shown = signal(["Name", "Role", "Team"]);
|
|
121
|
+
|
|
122
|
+
/** A column can join the shown ones while there's room; the shown ones can always be reordered. */
|
|
123
|
+
protected readonly canShow = (): boolean => this.shown().length < MAX_SHOWN;
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`connected-example.component.html`
|
|
128
|
+
|
|
129
|
+
```html
|
|
130
|
+
<div monaSortableGroup class="grid w-[32rem] max-w-full grid-cols-2 gap-4">
|
|
131
|
+
<section class="flex flex-col gap-2">
|
|
132
|
+
<h3 id="sortable-connected-hidden" class="text-sm font-semibold">Hidden columns</h3>
|
|
133
|
+
<ul
|
|
134
|
+
aria-labelledby="sortable-connected-hidden"
|
|
135
|
+
class="flex min-h-40 flex-col gap-1 rounded-md bg-surface-muted p-2"
|
|
136
|
+
[(monaSortable)]="hidden">
|
|
137
|
+
@for (column of hidden(); track column) {
|
|
138
|
+
<li
|
|
139
|
+
tabindex="0"
|
|
140
|
+
class="cursor-grab rounded-md border border-border bg-card px-3 py-1.5 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-indicator"
|
|
141
|
+
[monaSortableItem]="column">
|
|
142
|
+
{{ column }}
|
|
143
|
+
</li>
|
|
144
|
+
}
|
|
145
|
+
</ul>
|
|
146
|
+
</section>
|
|
147
|
+
<section class="flex flex-col gap-2">
|
|
148
|
+
<h3 id="sortable-connected-shown" class="text-sm font-semibold">Shown columns</h3>
|
|
149
|
+
<ul
|
|
150
|
+
aria-labelledby="sortable-connected-shown"
|
|
151
|
+
aria-describedby="sortable-connected-limit"
|
|
152
|
+
class="flex min-h-40 flex-col gap-1 rounded-md bg-surface-muted p-2"
|
|
153
|
+
[(monaSortable)]="shown"
|
|
154
|
+
[sortableCanEnter]="canShow">
|
|
155
|
+
@for (column of shown(); track column) {
|
|
156
|
+
<li
|
|
157
|
+
tabindex="0"
|
|
158
|
+
class="cursor-grab rounded-md border border-border bg-card px-3 py-1.5 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-indicator"
|
|
159
|
+
[monaSortableItem]="column">
|
|
160
|
+
{{ column }}
|
|
161
|
+
</li>
|
|
162
|
+
}
|
|
163
|
+
</ul>
|
|
164
|
+
<p id="sortable-connected-limit" class="text-sm text-muted-foreground">
|
|
165
|
+
{{ shown().length }} of {{ maxShown }} columns
|
|
166
|
+
</p>
|
|
167
|
+
</section>
|
|
168
|
+
</div>
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Rows that wrap, with handles
|
|
172
|
+
|
|
173
|
+
`sortableOrientation="mixed"` is for items laid out in rows that wrap, such as tiles. A `monaSortableHandle` makes only the grip start a drag, so the rest of the tile can hold text to select or controls to use. The keyboard moves the tile from anywhere in it. `sortableLabel` names each tile in announcements, where its text would also read the figure.
|
|
174
|
+
|
|
175
|
+
`tiles-example.component.ts`
|
|
176
|
+
|
|
177
|
+
```typescript
|
|
178
|
+
import { Component, signal } from "@angular/core";
|
|
179
|
+
import { LucideGripVertical } from "@lucide/angular";
|
|
180
|
+
import { SortableDirective, SortableHandleDirective, SortableItemDirective } from "@nanahoshi/mona-ui/sortable";
|
|
181
|
+
|
|
182
|
+
interface Widget {
|
|
183
|
+
readonly id: string;
|
|
184
|
+
readonly title: string;
|
|
185
|
+
readonly value: string;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@Component({
|
|
189
|
+
selector: "app-sortable-tiles-example",
|
|
190
|
+
imports: [LucideGripVertical, SortableDirective, SortableHandleDirective, SortableItemDirective],
|
|
191
|
+
templateUrl: "./tiles-example.component.html"
|
|
192
|
+
})
|
|
193
|
+
export class SortableTilesExampleComponent {
|
|
194
|
+
protected readonly widgets = signal<Widget[]>([
|
|
195
|
+
{ id: "visitors", title: "Visitors", value: "12,480" },
|
|
196
|
+
{ id: "signups", title: "Sign-ups", value: "312" },
|
|
197
|
+
{ id: "revenue", title: "Revenue", value: "$8,920" },
|
|
198
|
+
{ id: "churn", title: "Churn", value: "1.8%" },
|
|
199
|
+
{ id: "tickets", title: "Open tickets", value: "27" }
|
|
200
|
+
]);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
`tiles-example.component.html`
|
|
205
|
+
|
|
206
|
+
```html
|
|
207
|
+
<ul
|
|
208
|
+
aria-label="Dashboard widgets"
|
|
209
|
+
class="flex w-[30rem] max-w-full flex-wrap gap-3"
|
|
210
|
+
[(monaSortable)]="widgets"
|
|
211
|
+
sortableOrientation="mixed">
|
|
212
|
+
@for (widget of widgets(); track widget.id) {
|
|
213
|
+
<li
|
|
214
|
+
tabindex="0"
|
|
215
|
+
class="flex w-36 flex-col gap-2 rounded-lg border border-border bg-card p-3 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-focus-indicator"
|
|
216
|
+
[monaSortableItem]="widget"
|
|
217
|
+
[sortableLabel]="widget.title">
|
|
218
|
+
<div class="flex items-center justify-between gap-2">
|
|
219
|
+
<span class="text-sm text-muted-foreground">{{ widget.title }}</span>
|
|
220
|
+
<svg
|
|
221
|
+
monaSortableHandle
|
|
222
|
+
lucideGripVertical
|
|
223
|
+
aria-hidden="true"
|
|
224
|
+
class="text-muted-foreground"
|
|
225
|
+
[size]="16"></svg>
|
|
226
|
+
</div>
|
|
227
|
+
<span class="text-2xl font-semibold tabular-nums">{{ widget.value }}</span>
|
|
228
|
+
</li>
|
|
229
|
+
}
|
|
230
|
+
</ul>
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
## Behavior
|
|
234
|
+
|
|
235
|
+
### The list doesn't change your data
|
|
236
|
+
|
|
237
|
+
A move first emits `sortableMove` on the list the item lands in. It carries the item, its previous and new index, and both lists' arrays after the move: `previousItems` and `currentItems`, the same array for a move within one list. Call `preventDefault()` to refuse the move. Otherwise each list involved emits its new array through `monaSortableChange`, which `[(monaSortable)]` writes back.
|
|
238
|
+
|
|
239
|
+
```html
|
|
240
|
+
<ul [monaSortable]="tasks()" (sortableMove)="save($event)">…</ul>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
```typescript
|
|
244
|
+
protected save(event: SortableMoveEvent<Task>): void {
|
|
245
|
+
// Keep the new order only once the server has it.
|
|
246
|
+
event.preventDefault();
|
|
247
|
+
this.api.reorder(event.currentItems).subscribe(() => this.tasks.set([...event.currentItems]));
|
|
248
|
+
}
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
`moveItem(items, from, to)` returns a copy of an array with one item moved, for moves reported by index, such as [reordered tabs](tabs.md#reordering-tabs).
|
|
252
|
+
|
|
253
|
+
### Orientation
|
|
254
|
+
|
|
255
|
+
`sortableOrientation` says how the items are laid out, which sets the keys that move them:
|
|
256
|
+
|
|
257
|
+
| Value | Layout | Keys that move an item within the list | Keys that move it to another list of the group |
|
|
258
|
+
| --- | --- | --- | --- |
|
|
259
|
+
| `"vertical"` (default) | A column | `ArrowUp`, `ArrowDown` | `ArrowLeft`, `ArrowRight` |
|
|
260
|
+
| `"horizontal"` | A row | `ArrowLeft`, `ArrowRight` | `ArrowUp`, `ArrowDown` |
|
|
261
|
+
| `"mixed"` | Rows that wrap | All four: up and down to the item above or below | None |
|
|
262
|
+
|
|
263
|
+
In rows that wrap, the items must be the list element's own children.
|
|
264
|
+
|
|
265
|
+
### Disabling
|
|
266
|
+
|
|
267
|
+
`sortableDisabled` on the list stops its items from moving, and stops items from other lists coming in. On an item, it stops that item from moving; other items still move past it.
|
|
268
|
+
|
|
269
|
+
### Touch screens
|
|
270
|
+
|
|
271
|
+
On a touch screen, press and hold an item for a moment to pick it up. A quick swipe scrolls the page, or the list, as usual.
|
|
272
|
+
|
|
273
|
+
## Accessibility
|
|
274
|
+
|
|
275
|
+
Each item must take focus, or hold a control that does, for the keyboard to move it: give it `tabindex="0"`, or put the list's own focus management on it. The directive adds no roles, so keep the semantics of your markup: a `ul` or `ol` of `li` elements, or the roles of the pattern you build.
|
|
276
|
+
|
|
277
|
+
After every move, the list announces the item's name and its new position, "Write the release notes moved to position 1 of 3", and for a move into another list, that list's name too, "Email moved to Shown columns, position 4 of 4". The item's name is its `sortableLabel`, else its `aria-label` or `aria-labelledby` text, else its text without what's `aria-hidden`. The list's name is its `sortableLabel`, else its `aria-label` or `aria-labelledby` text.
|
|
278
|
+
|
|
279
|
+
### Keyboard
|
|
280
|
+
|
|
281
|
+
With focus on an item, or on an element in it that isn't a text field:
|
|
282
|
+
|
|
283
|
+
| Key | Action |
|
|
284
|
+
| --- | --- |
|
|
285
|
+
| `Control+Shift` with an arrow key (`Command+Shift` on macOS) | Moves the item one place, or to the next list of the group, as the [orientation](#orientation) sets |
|
|
286
|
+
| `Control+Shift+Home` / `Control+Shift+End` | Moves the item to the start or the end of its list |
|
|
287
|
+
|
|
288
|
+
`ArrowLeft` and `ArrowRight` swap in right-to-left layouts. A move into another list keeps the item's position, or puts it last when the list is shorter, and passes over a list that refuses it. Focus stays on the moved item, also when it lands in another list.
|
|
289
|
+
|
|
290
|
+
### ARIA
|
|
291
|
+
|
|
292
|
+
| Attribute | When present | Value |
|
|
293
|
+
| --- | --- | --- |
|
|
294
|
+
| `aria-keyshortcuts` | On each item that can move | The shortcuts that move it, such as `"Control+Shift+ArrowUp Control+Shift+ArrowDown Control+Shift+Home Control+Shift+End"` |
|
|
295
|
+
|
|
296
|
+
An item with `role="presentation"` or `role="none"` doesn't get `aria-keyshortcuts`, which would conflict with its role. Bind the item's `keyShortcuts()` on the element in it that takes focus instead: `#item="monaSortableItem"`, then `[attr.aria-keyshortcuts]="item.keyShortcuts()"`.
|
|
297
|
+
|
|
298
|
+
## API
|
|
299
|
+
|
|
300
|
+
Everything below is imported from `@nanahoshi/mona-ui/sortable`. Each name links to its reference page, with every input, output, property and method.
|
|
301
|
+
|
|
302
|
+
| Name | Kind | Description |
|
|
303
|
+
| --- | --- | --- |
|
|
304
|
+
| [`SortableDirective`](api/sortable.md#sortabledirective) | Directive | Lets the user reorder a list's items by dragging them, or with Control+Shift and the arrow keys (Command+Shift on macOS), and announces each move. |
|
|
305
|
+
| [`SortableItemDirective`](api/sortable.md#sortableitemdirective) | Directive | An item of a `monaSortable` list, given the array element it shows. |
|
|
306
|
+
| [`SortableGroupDirective`](api/sortable.md#sortablegroupdirective) | Directive | Connects the sortable lists inside it, so an item can move from one to another: dragged, or with Control+Shift and the arrow keys that cross the lists, such as Left and Right between columns. |
|
|
307
|
+
| [`SortableHandleDirective`](api/sortable.md#sortablehandledirective) | Directive | Marks the part of a sortable item that starts a drag, such as a grip icon. |
|
|
308
|
+
| [`SortableMoveEvent`](api/sortable.md#sortablemoveevent) | Class | A move of an item, by pointer or keyboard, within a sortable list or into another list of its group. |
|
|
309
|
+
| [`moveItem`](api/sortable.md#moveitem) | Function | A copy of `items` with the item at `from` moved to `to`, the index it has afterwards. |
|
|
310
|
+
|
|
311
|
+
### Types
|
|
312
|
+
|
|
313
|
+
| Type | Kind | Description |
|
|
314
|
+
| --- | --- | --- |
|
|
315
|
+
| [`SORTABLE_DEFAULT_MESSAGES`](api/sortable.md#sortable-default-messages) | Constant | |
|
|
316
|
+
| [`SortableMoveEventOptions`](api/sortable.md#sortablemoveeventoptions) | Interface | |
|
|
317
|
+
| [`SortableMoveKey`](api/sortable.md#sortablemovekey) | Type alias | The keys that move an item, held with Control and Shift (Command and Shift on macOS). |
|
|
318
|
+
| [`SortableOrientation`](api/sortable.md#sortableorientation) | Type alias | How a sortable list lays out its items: in a column (`vertical`), in a row (`horizontal`), or in rows that wrap (`mixed`), such as a grid of cards. |
|
|
319
|
+
|
|
320
|
+
**Related types:** [`MonaSortableMessages`](api/i18n.md#monasortablemessages), [`PreventableEvent`](api/common.md#preventableevent)
|
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
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { q as GridService } from "./nanahoshi-mona-ui-grid-grid.styles-wAf6jsT9.mjs";
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
3
|
import { Component, inject } from "@angular/core";
|
|
4
4
|
import { take } from "rxjs";
|
|
@@ -74,4 +74,4 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
74
74
|
});
|
|
75
75
|
export { removeGridRow as n, GridColgroupComponent as t };
|
|
76
76
|
|
|
77
|
-
//# sourceMappingURL=nanahoshi-mona-ui-grid-grid-colgroup.component-
|
|
77
|
+
//# sourceMappingURL=nanahoshi-mona-ui-grid-grid-colgroup.component-DpszxgFY.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { H as GridLogicalCellDirective, K as GridLockedCellDirective, h as gridFooterTableRowThemeVariants, m as gridFooterTableCellThemeVariants, q as GridService } from "./nanahoshi-mona-ui-grid-grid.styles-wAf6jsT9.mjs";
|
|
2
2
|
import * as i0 from "@angular/core";
|
|
3
3
|
import { Component, Directive, computed, inject, input } from "@angular/core";
|
|
4
4
|
import { NgTemplateOutlet } from "@angular/common";
|
|
@@ -401,7 +401,8 @@ var GridFooterRowComponent = class GridFooterRowComponent {
|
|
|
401
401
|
"readOnly",
|
|
402
402
|
"rowIndex",
|
|
403
403
|
"rowUid",
|
|
404
|
-
"section"
|
|
404
|
+
"section",
|
|
405
|
+
"treeCell"
|
|
405
406
|
],
|
|
406
407
|
outputs: [
|
|
407
408
|
"edit",
|
|
@@ -482,4 +483,4 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
482
483
|
});
|
|
483
484
|
export { GridFooterRowComponent };
|
|
484
485
|
|
|
485
|
-
//# sourceMappingURL=nanahoshi-mona-ui-grid-grid-footer-row.component-
|
|
486
|
+
//# sourceMappingURL=nanahoshi-mona-ui-grid-grid-footer-row.component-CpvzAcX8.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { i as GridCellDirective, n as GridGroupRowComponent, r as GridAddRowComponent, t as GridRowComponent } from "./nanahoshi-mona-ui-grid-grid-row.component-
|
|
3
|
-
import { t as GridColgroupComponent } from "./nanahoshi-mona-ui-grid-grid-colgroup.component-
|
|
4
|
-
import { GridFooterRowComponent } from "./nanahoshi-mona-ui-grid-grid-footer-row.component-
|
|
1
|
+
import { I as gridRowDragPreviewThemeVariants, K as GridLockedCellDirective, P as gridListTableThemeVariants, j as gridListBaseThemeVariants, q as GridService } from "./nanahoshi-mona-ui-grid-grid.styles-wAf6jsT9.mjs";
|
|
2
|
+
import { i as GridCellDirective, n as GridGroupRowComponent, r as GridAddRowComponent, t as GridRowComponent } from "./nanahoshi-mona-ui-grid-grid-row.component-eET6dh2Q.mjs";
|
|
3
|
+
import { t as GridColgroupComponent } from "./nanahoshi-mona-ui-grid-grid-colgroup.component-DpszxgFY.mjs";
|
|
4
|
+
import { GridFooterRowComponent } from "./nanahoshi-mona-ui-grid-grid-footer-row.component-CpvzAcX8.mjs";
|
|
5
5
|
import * as i0 from "@angular/core";
|
|
6
6
|
import { Component, DestroyRef, ElementRef, afterNextRender, afterRenderEffect, computed, effect, inject, input, untracked, viewChild } from "@angular/core";
|
|
7
7
|
import { NgTemplateOutlet } from "@angular/common";
|
|
@@ -471,4 +471,4 @@ i0.ɵɵngDeclareClassMetadata({
|
|
|
471
471
|
});
|
|
472
472
|
export { GridListComponent };
|
|
473
473
|
|
|
474
|
-
//# sourceMappingURL=nanahoshi-mona-ui-grid-grid-list.component-
|
|
474
|
+
//# sourceMappingURL=nanahoshi-mona-ui-grid-grid-list.component-tRmEWiQR.mjs.map
|