@nanahoshi/mona-ui 0.26.2 → 0.27.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.
@@ -730,4 +730,4 @@ From `@nanahoshi/mona-ui/common`.
730
730
  | `isDefaultPrevented(): boolean` | Whether `preventDefault()` was called. |
731
731
  | `preventDefault(): void` | Cancels what the event announces, such as opening or closing a popup, or closing a dialog. |
732
732
 
733
- **Documented elsewhere:** [`FilterableOptions`](grid.md), [`GroupableOptions`](grid.md), [`PopupCloseEvent`](popup.md), [`VirtualScrollOptions`](list-view.md)
733
+ **Documented elsewhere:** [`FilterableOptions`](grid-sorting-filtering.md), [`GroupableOptions`](list-view.md), [`PopupCloseEvent`](popup.md), [`VirtualScrollOptions`](list-view.md)
@@ -71,6 +71,33 @@ export class CircularProgressBarSizesExampleComponent {
71
71
  </div>
72
72
  ```
73
73
 
74
+ ### Round and flat ends
75
+
76
+ The arc's ends are round by default. `lineCap="flat"` cuts them straight instead. Both cover the same part of the ring, so 72% reads the same either way.
77
+
78
+ `line-cap-example.component.ts`
79
+
80
+ ```typescript
81
+ import { Component } from "@angular/core";
82
+ import { CircularProgressBarComponent } from "@nanahoshi/mona-ui/circular-progress-bar";
83
+
84
+ @Component({
85
+ selector: "app-circular-progress-bar-line-cap-example",
86
+ imports: [CircularProgressBarComponent],
87
+ templateUrl: "./line-cap-example.component.html"
88
+ })
89
+ export class CircularProgressBarLineCapExampleComponent {}
90
+ ```
91
+
92
+ `line-cap-example.component.html`
93
+
94
+ ```html
95
+ <div class="flex flex-wrap items-center gap-6">
96
+ <mona-circular-progress-bar aria-label="Quiz score" [size]="120" [thickness]="12" [value]="72"></mona-circular-progress-bar>
97
+ <mona-circular-progress-bar aria-label="Course progress" lineCap="flat" [size]="120" [thickness]="12" [value]="72"></mona-circular-progress-bar>
98
+ </div>
99
+ ```
100
+
74
101
  ### Indeterminate
75
102
 
76
103
  Use it when the completion percentage is unknown. Set `aria-valuetext` so screen readers announce a state.
@@ -161,6 +188,10 @@ The `size` input controls the outer dimension of the SVG in pixels. Both width a
161
188
 
162
189
  `thickness` controls the stroke width of both the track and the progress arc in pixels. The stroke fits inside `size`, so increasing it reduces the effective radius. The default of `6` suits most sizes; reduce it for small sizes or increase it for bold indicators.
163
190
 
191
+ ### Line cap
192
+
193
+ `lineCap` sets the shape of the arc's ends: `"round"` (the default) rounds them, `"flat"` cuts them straight. A round end reaches half the `thickness` past where the arc ends, so the component shortens the arc by that much at each end to keep it within the value. An empty ring draws nothing either way, and a sliver of progress draws a dot as wide as the stroke.
194
+
164
195
  ### Color
165
196
 
166
197
  When `color` is empty the arc color falls back to `var(--color-primary)`. The track (the full circle behind the arc) always uses the `var(--color-surface-muted)` design token.
@@ -243,6 +274,7 @@ Everything below is imported from `@nanahoshi/mona-ui/circular-progress-bar`.
243
274
  | `disabled` | `boolean` | `false` | Renders the component with reduced visual emphasis and removes pointer interaction. |
244
275
  | `indeterminate` | `boolean` | `false` | Activates indeterminate mode when the completion value is unknown. ARIA value attributes are removed. |
245
276
  | `labelVisible` | `boolean` | `true` | Controls label visibility in determinate mode. Has no effect in indeterminate mode, where the label is always hidden. |
277
+ | `lineCap` | `CircularProgressBarLineCap` | `"round"` | Shape of the arc's two ends. `"round"` draws rounded ends that stay within the value's span, so the arc covers the same part of the ring as `"flat"`, which cuts them straight. An empty ring draws nothing either way. |
246
278
  | `max` | `number` | `100` | Upper bound of the value range. Must be greater than `min`; otherwise the bar reports no values and a warning is logged in development. |
247
279
  | `min` | `number` | `0` | Lower bound of the value range. |
248
280
  | `size` | `number` | `100` | Diameter of the indicator in pixels. Controls both width and height of the host element. |
@@ -276,6 +308,12 @@ when `indeterminate` is `true`.
276
308
  | `min` | `number` |
277
309
  | `percent` | `number` |
278
310
 
311
+ #### `CircularProgressBarLineCap`
312
+
313
+ ```typescript
314
+ type CircularProgressBarLineCap = "flat" | "round";
315
+ ```
316
+
279
317
  #### `Action`
280
318
 
281
319
  From `@nanahoshi/mona-ui/common`.
package/docs/combo-box.md CHANGED
@@ -761,4 +761,4 @@ From `@nanahoshi/mona-ui/common`.
761
761
  | `isDefaultPrevented(): boolean` | Whether `preventDefault()` was called. |
762
762
  | `preventDefault(): void` | Cancels what the event announces, such as opening or closing a popup, or closing a dialog. |
763
763
 
764
- **Documented elsewhere:** [`FilterableOptions`](grid.md), [`GroupableOptions`](grid.md), [`PopupCloseEvent`](popup.md), [`VirtualScrollOptions`](list-view.md)
764
+ **Documented elsewhere:** [`FilterableOptions`](grid-sorting-filtering.md), [`GroupableOptions`](list-view.md), [`PopupCloseEvent`](popup.md), [`VirtualScrollOptions`](list-view.md)
@@ -776,4 +776,4 @@ From `@nanahoshi/mona-ui/common`.
776
776
  | `isDefaultPrevented(): boolean` | Whether `preventDefault()` was called. |
777
777
  | `preventDefault(): void` | Cancels what the event announces, such as opening or closing a popup, or closing a dialog. |
778
778
 
779
- **Documented elsewhere:** [`FilterableOptions`](grid.md), [`GroupableOptions`](grid.md), [`PopupCloseEvent`](popup.md), [`VirtualScrollOptions`](list-view.md)
779
+ **Documented elsewhere:** [`FilterableOptions`](grid-sorting-filtering.md), [`GroupableOptions`](list-view.md), [`PopupCloseEvent`](popup.md), [`VirtualScrollOptions`](list-view.md)
@@ -0,0 +1,296 @@
1
+ # Columns
2
+
3
+ > Resize, reorder, lock and hide columns, by pointer, keyboard or the column chooser.
4
+
5
+ Entry point: `@nanahoshi/mona-ui/grid`
6
+
7
+ **Selectors:** `mona-grid[monaGridResizable]`, `mona-grid[monaGridReorderable]`
8
+
9
+ `monaGridResizable` adds a drag handle between column headers, and `monaGridReorderable` lets people drag headers into a new order. A column's own inputs set its width, lock it to one side while the grid scrolls sideways, or hide it, and the toolbar's Columns button lets people choose which columns they see.
10
+
11
+ ## Overview
12
+
13
+ | What | How | Event |
14
+ | :--- | :--- | :--- |
15
+ | Width | `width`, `minWidth`, `maxWidth` on a column; `resizeMethod` on the grid | — |
16
+ | Resizing | `monaGridResizable` | `columnResize` |
17
+ | Reordering | `monaGridReorderable` | `columnReorder` (cancelable) |
18
+ | Locking | `locked` and `lockedPosition` on a column or the command column | — |
19
+ | Hiding | `hidden` on a column; the Columns button in the toolbar | — |
20
+
21
+ People's changes to widths, order and visibility live in the grid, not in your column definitions. To keep them across visits, add `monaGridStatePersistence`, see [State & Export](grid-state-export.md).
22
+
23
+ **Use something else when:**
24
+
25
+ - Columns should change with the screen size. Bind `hidden` to your own breakpoint signal instead of relying on people to hide them.
26
+
27
+ ## Import & Quick Start
28
+
29
+ ```typescript
30
+ import { GridColumnComponent, GridComponent, GridReorderableDirective, GridResizableDirective } from "@nanahoshi/mona-ui/grid";
31
+ ```
32
+
33
+ ```html
34
+ <mona-grid aria-label="Orders" [data]="orders()" monaGridResizable monaGridReorderable>
35
+ <mona-grid-column field="orderId" title="Order ID" [locked]="true" [width]="110"></mona-grid-column>
36
+ <mona-grid-column field="customer" title="Customer" [minWidth]="160"></mona-grid-column>
37
+ </mona-grid>
38
+ ```
39
+
40
+ ## Examples
41
+
42
+ ### Locked, Resizable and Movable Columns
43
+
44
+ `locked-columns-example.component.ts`
45
+
46
+ ```typescript
47
+ import { Component, signal } from "@angular/core";
48
+ import {
49
+ type ColumnReorderEvent,
50
+ type ColumnResizeEvent,
51
+ GridColumnComponent,
52
+ GridComponent,
53
+ GridReorderableDirective,
54
+ GridResizableDirective,
55
+ GridToolbarTemplateDirective
56
+ } from "@nanahoshi/mona-ui/grid";
57
+
58
+ @Component({
59
+ selector: "app-grid-columns-locked-columns-example",
60
+ imports: [
61
+ GridColumnComponent,
62
+ GridComponent,
63
+ GridReorderableDirective,
64
+ GridResizableDirective,
65
+ GridToolbarTemplateDirective
66
+ ],
67
+ templateUrl: "./locked-columns-example.component.html"
68
+ })
69
+ export class GridLockedColumnsExampleComponent {
70
+ protected readonly lastChange = signal("Drag a header or the edge between two headers.");
71
+ protected readonly shipments = Array.from({ length: 8 }, (_, index) => ({
72
+ id: 7001 + index,
73
+ carrier: ["Northwind Freight", "Blue Anchor", "Polar Express"][index % 3],
74
+ origin: ["Rotterdam", "Hamburg", "Antwerp", "Gdańsk"][index % 4],
75
+ destination: ["Oslo", "Lisbon", "Dublin", "Tallinn"][(index + 1) % 4],
76
+ weight: 1200 + index * 340,
77
+ containers: 2 + (index % 5),
78
+ status: index % 3 === 0 ? "Delayed" : "On time"
79
+ }));
80
+
81
+ protected onColumnReorder(event: ColumnReorderEvent): void {
82
+ // The shipment number stays first; preventing the event leaves the columns as they were.
83
+ if (event.column.field === "id") {
84
+ event.preventDefault();
85
+ this.lastChange.set("The shipment column can't move.");
86
+ return;
87
+ }
88
+ this.lastChange.set(`Moved ${event.column.title} to position ${event.newIndex + 1}.`);
89
+ }
90
+
91
+ protected onColumnResize(event: ColumnResizeEvent): void {
92
+ this.lastChange.set(`Resized ${event.column.title} from ${event.oldWidth}px to ${event.newWidth}px.`);
93
+ }
94
+ }
95
+ ```
96
+
97
+ `locked-columns-example.component.html`
98
+
99
+ ```html
100
+ <div class="flex flex-col gap-2">
101
+ <mona-grid
102
+ aria-label="Shipments"
103
+ class="w-full"
104
+ rowKey="id"
105
+ [data]="shipments"
106
+ [pageSize]="5"
107
+ monaGridReorderable
108
+ monaGridResizable
109
+ (columnReorder)="onColumnReorder($event)"
110
+ (columnResize)="onColumnResize($event)">
111
+ <ng-template monaGridToolbarTemplate>
112
+ <span class="text-sm font-medium">Shipments</span>
113
+ </ng-template>
114
+ <mona-grid-column field="id" title="Shipment" type="number" [locked]="true" [width]="110" />
115
+ <mona-grid-column field="carrier" title="Carrier" [minWidth]="140" [width]="180" />
116
+ <mona-grid-column field="origin" title="Origin" [width]="160" />
117
+ <mona-grid-column field="destination" title="Destination" [width]="160" />
118
+ <mona-grid-column field="weight" title="Weight (kg)" type="number" [width]="140" />
119
+ <mona-grid-column field="containers" title="Containers" type="number" [hidden]="true" [width]="130" />
120
+ <mona-grid-column field="status" lockedPosition="right" title="Status" [locked]="true" [width]="120" />
121
+ </mona-grid>
122
+ <span aria-live="polite" class="text-sm">{{ lastChange() }}</span>
123
+ </div>
124
+ ```
125
+
126
+ The Shipment column is locked to the start and the Status column to the end, so both stay in view while the others scroll sideways. Containers starts hidden; the toolbar's Columns button shows it. `columnReorder` is prevented for the Shipment column, so it can't move.
127
+
128
+ ### Column Widths
129
+
130
+ `width` fixes a column's width in pixels. Columns without one get theirs from the grid's `resizeMethod`:
131
+
132
+ | `resizeMethod` | Columns without a `width` |
133
+ | :--- | :--- |
134
+ | `"fitView"` (default) | Share the width the fixed columns leave. |
135
+ | `"auto"` | Fit their rendered content. |
136
+ | A number | Get that many pixels each. |
137
+
138
+ `minWidth` (40 by default) and `maxWidth` bound a resize.
139
+
140
+ ### Canceling a Move
141
+
142
+ ```typescript
143
+ protected onColumnReorder(event: ColumnReorderEvent): void {
144
+ if (event.column.field === "orderId") {
145
+ event.preventDefault();
146
+ }
147
+ }
148
+ ```
149
+
150
+ `columnReorder` carries the `column`, its `oldIndex` and its `newIndex`. `columnResize` is a plain object with the `column`, `oldWidth` and `newWidth`, emitted once when a resize ends; it can't be prevented.
151
+
152
+ ## Behavior
153
+
154
+ ### Resizing
155
+
156
+ A drag stops at the column's `minWidth` and `maxWidth`, and `Escape` during a drag puts the width back. The handle is also a focusable `separator`, see [Keyboard](#keyboard).
157
+
158
+ ### Reordering
159
+
160
+ Dropping on the start half of a header puts the column before it, the end half after it; `Escape` cancels the drag.
161
+
162
+ ### Locking
163
+
164
+ A locked column stays on its `lockedPosition` side, `"left"` (default) or `"right"`, which are the start and end of the grid, so they swap in right-to-left layouts. The command column takes `locked` and `lockedPosition` too. The selection checkbox column is always locked at the start.
165
+
166
+ ### The Columns button
167
+
168
+ With a `monaGridToolbarTemplate`, the toolbar shows a Columns button (the `columns` message). Its popup lists every column, with a box to filter the list by title. Apply shows the checked columns and hides the others; Cancel drops the changes. A column's `hidden` input sets where it starts, and `monaGridStatePersistence` saves what the user chose. The popup's component is internal, so there is nothing to import.
169
+
170
+ ## Accessibility
171
+
172
+ Every column needs a `title`: it names the header, the resize handle and the Columns popup's checkbox. Moving a column from the keyboard is announced through a polite live region (the `columnMoved` message).
173
+
174
+ ### Keyboard
175
+
176
+ | Key | Action |
177
+ | --- | --- |
178
+ | `F2` | On a header, moves to its resize handle. |
179
+ | `ArrowLeft` / `ArrowRight` | On a resize handle, narrows/widens the column by 10px (mirrored in right-to-left layouts). |
180
+ | `Home` / `End` | On a resize handle, sets the column to its narrowest/widest width. |
181
+ | `Enter` | On a resize handle, fits the column to its content. |
182
+ | `Ctrl+Shift+ArrowLeft` / `Ctrl+Shift+ArrowRight` | With `monaGridReorderable`, moves the focused header's column one place (mirrored in right-to-left layouts) and announces it. `Cmd` too. |
183
+
184
+ The rest of the grid's keys are on [Grid Overview](grid.md#keyboard).
185
+
186
+ ### ARIA
187
+
188
+ | Attribute | When present | Value |
189
+ | --- | --- | --- |
190
+ | `role` | On the column resize handle | `"separator"` |
191
+ | `aria-orientation` | On the column resize handle | `"vertical"` |
192
+ | `aria-label` | On the column resize handle | `"Resize {column}"` (`resizeColumn` message) |
193
+ | `aria-valuenow` | On the column resize handle | The column width in pixels, with `aria-valuemin`/`aria-valuemax` |
194
+ | `aria-keyshortcuts` | On a header of a reorderable grid | The keys that move it |
195
+
196
+ ## API
197
+
198
+ Everything below is imported from `@nanahoshi/mona-ui/grid`.
199
+
200
+ ### `GridReorderableDirective`
201
+
202
+ **Selector:** `mona-grid[monaGridReorderable]`
203
+
204
+ #### Inputs
205
+
206
+ | Name | Type | Default | Description |
207
+ | --- | --- | --- | --- |
208
+ | `monaGridReorderable` | `ReorderableOptions \| ""` | `""` | Enables column reordering via drag and drop. Pass a `ReorderableOptions` object to configure it explicitly. |
209
+
210
+ #### Outputs
211
+
212
+ | Name | Type | Description |
213
+ | --- | --- | --- |
214
+ | `columnReorder` | `ColumnReorderEvent` | Emitted when a column is dropped into a new position. Call `preventDefault()` on the event to cancel the reorder. |
215
+
216
+ ### `GridResizableDirective`
217
+
218
+ **Selector:** `mona-grid[monaGridResizable]`
219
+
220
+ #### Inputs
221
+
222
+ | Name | Type | Default | Description |
223
+ | --- | --- | --- | --- |
224
+ | `monaGridResizable` | `ResizableOptions \| ""` | `""` | Enables column resizing on the grid. Pass a `ResizableOptions` object to configure it explicitly. |
225
+
226
+ #### Outputs
227
+
228
+ | Name | Type | Description |
229
+ | --- | --- | --- |
230
+ | `columnResize` | `ColumnResizeEvent` | Emitted when a column resize completes, with the column and its old and new widths. |
231
+
232
+ ### `ColumnReorderEvent`
233
+
234
+ **Extends:** `PreventableEvent`
235
+
236
+ #### Properties
237
+
238
+ | Name | Type |
239
+ | --- | --- |
240
+ | `column` (read-only) | `Column` |
241
+ | `newIndex` (read-only) | `number` |
242
+ | `oldIndex` (read-only) | `number` |
243
+
244
+ ### Types
245
+
246
+ #### `ColumnResizeEvent`
247
+
248
+ | Name | Type |
249
+ | --- | --- |
250
+ | `column` | `Column` |
251
+ | `newWidth` | `number` |
252
+ | `oldWidth` | `number` |
253
+
254
+ #### `ReorderableOptions`
255
+
256
+ | Name | Type | Description |
257
+ | --- | --- | --- |
258
+ | `enabled` | `boolean` | Whether column reordering is active. On unless set to `false`; options replace earlier ones. |
259
+
260
+ #### `ResizableOptions`
261
+
262
+ | Name | Type | Description |
263
+ | --- | --- | --- |
264
+ | `enabled` | `boolean` | Whether column resizing is active. On unless set to `false`; options replace earlier ones. |
265
+
266
+ #### `GridColumnLockedPosition`
267
+
268
+ ```typescript
269
+ type GridColumnLockedPosition = "left" | "right";
270
+ ```
271
+
272
+ #### `ResizeMethod`
273
+
274
+ ```typescript
275
+ type ResizeMethod = "auto" | "fitView" | number;
276
+ ```
277
+
278
+ #### `PreventableEvent`
279
+
280
+ From `@nanahoshi/mona-ui/common`.
281
+
282
+ **Type parameters:** `E extends Event = Event`
283
+
284
+ | Name | Type | Description |
285
+ | --- | --- | --- |
286
+ | `originalEvent` (read-only) | `E \| undefined` | The DOM event that caused this one, when there is one. |
287
+ | `type` (read-only) | `string \| undefined` | A name for the kind of event, when the component that emits it sets one. |
288
+
289
+ **Methods**
290
+
291
+ | Signature | Description |
292
+ | --- | --- |
293
+ | `isDefaultPrevented(): boolean` | Whether `preventDefault()` was called. |
294
+ | `preventDefault(): void` | Cancels what the event announces, such as opening or closing a popup, or closing a dialog. |
295
+
296
+ **Documented elsewhere:** [`Column`](grid.md)