@nanahoshi/mona-ui 0.33.0 → 0.34.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/grid.md CHANGED
@@ -85,6 +85,21 @@ Component.
85
85
  | `title` | `string \| null` | `null` | The title displayed in the command column header. Without one, the localized `commandColumnTitle` message ("Commands"). |
86
86
  | `width` | `number \| null` | `160` | The fixed width of this command column in pixels. |
87
87
 
88
+ ## `GridColumnGroupComponent`
89
+
90
+ Component.
91
+
92
+ Puts a header over the `mona-grid-column`s and `mona-grid-command-column`s inside it. Groups nest: each level adds a
93
+ header row above the column headers.
94
+
95
+ **Selector:** `mona-grid-column-group`
96
+
97
+ ### Inputs
98
+
99
+ | Name | Type | Default | Description |
100
+ | --- | --- | --- | --- |
101
+ | `title` | `string` | `""` | The text shown in the group's header, which also names it for assistive technologies. |
102
+
88
103
  ## `GridEditableDirective`
89
104
 
90
105
  Directive.
@@ -223,6 +238,20 @@ Directive.
223
238
  | --- | --- | --- |
224
239
  | `scrollEnd` | `void` | Emitted when the scroll position reaches the configured threshold from the bottom of the virtualized list. |
225
240
 
241
+ ## `GridExportDirective`
242
+
243
+ Directive.
244
+
245
+ **Selector:** `mona-grid[monaGridExport]`
246
+ **Exported as:** `monaGridExport`
247
+
248
+ ### Methods
249
+
250
+ | Signature | Description |
251
+ | --- | --- |
252
+ | `exportCsv(filename?: string): void` | Exports the visible columns of the current view as CSV (only the loaded page with server binding). |
253
+ | `exportExcel(filename?: string): Promise<void>` | Exports the same rows and columns as `exportCsv` as an Excel workbook (`.xlsx`), with column groups as merged header cells and values that keep their types. Resolves once the download has started. |
254
+
226
255
  ## `GridFilterableDirective`
227
256
 
228
257
  Directive.
@@ -327,19 +356,6 @@ Directive.
327
356
  | --- | --- | --- | --- |
328
357
  | `monaGridEditCommand` | `Row \| null` | `null` | The row the button puts into row edit mode when clicked, usually the command template's `row`. Does nothing while `null` or when the grid isn't in row edit mode. |
329
358
 
330
- ## `GridExportDirective`
331
-
332
- Directive.
333
-
334
- **Selector:** `mona-grid[monaGridExport]`
335
- **Exported as:** `monaGridExport`
336
-
337
- ### Methods
338
-
339
- | Signature | Description |
340
- | --- | --- |
341
- | `exportCsv(filename?: string): void` | Exports the visible columns of the current view as CSV (only the loaded page with server binding). |
342
-
343
359
  ## `GridRemoveCommandDirective`
344
360
 
345
361
  Directive.
@@ -823,6 +839,7 @@ grid scrolls horizontally.
823
839
  | `footerTemplate` (read-only) | `TemplateRef<unknown> \| null` | The column's `monaGridFooterTemplate`, which renders its footer cell, or `null`. |
824
840
  | `format` (read-only) | `ColumnFormat \| null` | How cell values are formatted for display, or `null` to show them as they are. |
825
841
  | `groupFooterTemplate` (read-only) | `TemplateRef<unknown> \| null` | The column's `monaGridGroupFooterTemplate`, which renders its cell in group footer rows, or `null`. |
842
+ | `groups?` (read-only) | `readonly ColumnGroup[]` | The `mona-grid-column-group`s the column sits in, outermost first. Left out, or empty, when it isn't in a group. |
826
843
  | `headerTemplate` (read-only) | `TemplateRef<unknown> \| null` | The column's `monaGridHeaderTemplate`, which replaces the whole header content and receives the column, or `null`. |
827
844
  | `hidden` (read-only) | `boolean` | The column's `hidden` input as set. |
828
845
  | `id` (read-only) | `string` | A unique id generated for the column. |
@@ -861,6 +878,7 @@ Interface.
861
878
  | `footerTemplate` (read-only) | `TemplateRef<unknown> \| null` | The column's `monaGridFooterTemplate`, which renders its footer cell, or `null`. |
862
879
  | `format` (read-only) | `ColumnFormat \| null` | How cell values are formatted for display, or `null` to show them as they are. |
863
880
  | `groupFooterTemplate` (read-only) | `TemplateRef<unknown> \| null` | The column's `monaGridGroupFooterTemplate`, which renders its cell in group footer rows, or `null`. |
881
+ | `groups?` (read-only) | `readonly ColumnGroup[]` | The `mona-grid-column-group`s the column sits in, outermost first. Left out, or empty, when it isn't in a group. |
864
882
  | `headerTemplate` (read-only) | `TemplateRef<unknown> \| null` | The column's `monaGridHeaderTemplate`, which replaces the whole header content and receives the column, or `null`. |
865
883
  | `hidden` (read-only) | `boolean` | The column's `hidden` input as set. |
866
884
  | `id` (read-only) | `string` | A unique id generated for the column. |
@@ -879,6 +897,21 @@ Interface.
879
897
 
880
898
  **Used by:** [`Column`](grid.md#column)
881
899
 
900
+ ## `ColumnGroup`
901
+
902
+ Interface.
903
+
904
+ A `mona-grid-column-group`: a header over the columns inside it.
905
+
906
+ ### Properties
907
+
908
+ | Name | Type | Description |
909
+ | --- | --- | --- |
910
+ | `id` (read-only) | `string` | A unique id generated for the group. |
911
+ | `title` (read-only) | `string` | The text shown in the group's header. |
912
+
913
+ **Used by:** [`ColumnConfig`](grid.md#columnconfig)
914
+
882
915
  ## `ColumnResizeEvent`
883
916
 
884
917
  Interface.
@@ -1,12 +1,12 @@
1
1
  # Columns
2
2
 
3
- > Resize, reorder, lock and hide columns, by pointer, keyboard or the column chooser.
3
+ > Group, resize, reorder, lock and hide columns, by pointer, keyboard or the column chooser.
4
4
 
5
5
  Entry point: `@nanahoshi/mona-ui/grid`
6
6
 
7
7
  **Selectors:** `mona-grid[monaGridResizable]`, `mona-grid[monaGridReorderable]`
8
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.
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, `mona-grid-column-group` puts a header over a set of columns, and the toolbar's Columns button lets people choose which columns they see.
10
10
 
11
11
  ## Overview
12
12
 
@@ -17,6 +17,7 @@ Entry point: `@nanahoshi/mona-ui/grid`
17
17
  | Reordering | `monaGridReorderable` | `columnReorder` (cancelable) |
18
18
  | Locking | `locked` and `lockedPosition` on a column or the command column | — |
19
19
  | Hiding | `hidden` on a column; the Columns button in the toolbar | — |
20
+ | Grouping | `mona-grid-column-group` around columns, nested for more header rows | — |
20
21
 
21
22
  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
 
@@ -27,13 +28,23 @@ People's changes to widths, order and visibility live in the grid, not in your c
27
28
  ## Import & Quick Start
28
29
 
29
30
  ```typescript
30
- import { GridColumnComponent, GridComponent, GridReorderableDirective, GridResizableDirective } from "@nanahoshi/mona-ui/grid";
31
+ import {
32
+ GridColumnComponent,
33
+ GridColumnGroupComponent,
34
+ GridComponent,
35
+ GridReorderableDirective,
36
+ GridResizableDirective
37
+ } from "@nanahoshi/mona-ui/grid";
31
38
  ```
32
39
 
33
40
  ```html
34
41
  <mona-grid aria-label="Orders" [data]="orders()" monaGridResizable monaGridReorderable>
35
42
  <mona-grid-column field="orderId" title="Order ID" [locked]="true" [width]="110"></mona-grid-column>
36
43
  <mona-grid-column field="customer" title="Customer" [minWidth]="160"></mona-grid-column>
44
+ <mona-grid-column-group title="Shipping">
45
+ <mona-grid-column field="shipCity" title="City"></mona-grid-column>
46
+ <mona-grid-column field="shipCountry" title="Country"></mona-grid-column>
47
+ </mona-grid-column-group>
37
48
  </mona-grid>
38
49
  ```
39
50
 
@@ -125,6 +136,80 @@ export class GridLockedColumnsExampleComponent {
125
136
 
126
137
  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
138
 
139
+ ### Column Groups
140
+
141
+ `column-groups-example.component.ts`
142
+
143
+ ```typescript
144
+ import { Component } from "@angular/core";
145
+ import {
146
+ GridColumnComponent,
147
+ GridColumnGroupComponent,
148
+ GridComponent,
149
+ GridReorderableDirective,
150
+ GridResizableDirective,
151
+ GridToolbarTemplateDirective
152
+ } from "@nanahoshi/mona-ui/grid";
153
+
154
+ @Component({
155
+ selector: "app-grid-columns-column-groups-example",
156
+ imports: [
157
+ GridColumnComponent,
158
+ GridColumnGroupComponent,
159
+ GridComponent,
160
+ GridReorderableDirective,
161
+ GridResizableDirective,
162
+ GridToolbarTemplateDirective
163
+ ],
164
+ templateUrl: "./column-groups-example.component.html"
165
+ })
166
+ export class GridColumnGroupsExampleComponent {
167
+ protected readonly flights = Array.from({ length: 8 }, (_, index) => ({
168
+ aircraft: ["Airbus A320", "Boeing 737-800", "Embraer 190"][index % 3],
169
+ arrives: `${String(9 + index).padStart(2, "0")}:${index % 2 === 0 ? "10" : "40"}`,
170
+ departs: `${String(7 + index).padStart(2, "0")}:${index % 2 === 0 ? "05" : "35"}`,
171
+ flight: `MN ${410 + index * 7}`,
172
+ from: ["Oslo Gardermoen", "Lisbon Humberto Delgado", "Dublin", "Tallinn"][index % 4],
173
+ seats: [180, 189, 100][index % 3],
174
+ to: ["Rotterdam The Hague", "Hamburg", "Antwerp", "Gdańsk Lech Wałęsa"][(index + 1) % 4]
175
+ }));
176
+ }
177
+ ```
178
+
179
+ `column-groups-example.component.html`
180
+
181
+ ```html
182
+ <mona-grid
183
+ aria-label="Departures"
184
+ class="w-full"
185
+ rowKey="flight"
186
+ [data]="flights"
187
+ [pageSize]="5"
188
+ monaGridReorderable
189
+ monaGridResizable>
190
+ <ng-template monaGridToolbarTemplate>
191
+ <span class="text-sm font-medium">Departures</span>
192
+ </ng-template>
193
+ <mona-grid-column field="flight" title="Flight" [locked]="true" [width]="100" />
194
+ <mona-grid-column-group title="Route">
195
+ <mona-grid-column-group title="Departure">
196
+ <mona-grid-column field="from" title="Airport" [width]="190" />
197
+ <mona-grid-column field="departs" title="Time" [width]="90" />
198
+ </mona-grid-column-group>
199
+ <mona-grid-column-group title="Arrival">
200
+ <mona-grid-column field="to" title="Airport" [width]="190" />
201
+ <mona-grid-column field="arrives" title="Time" [width]="90" />
202
+ </mona-grid-column-group>
203
+ </mona-grid-column-group>
204
+ <mona-grid-column-group title="Aircraft">
205
+ <mona-grid-column field="aircraft" title="Type" [width]="150" />
206
+ <mona-grid-column field="seats" title="Seats" type="number" [width]="90" />
207
+ </mona-grid-column-group>
208
+ </mona-grid>
209
+ ```
210
+
211
+ Route holds two nested groups, so the header has two rows of group titles above the column titles. Move a column with its header or `Ctrl+Shift+ArrowRight`: a Time column only swaps with its Airport, and Departure and Arrival move past each other as wholes. The Columns button lists each column with its groups, such as `Route / Departure / Airport`.
212
+
128
213
  ### Column Widths
129
214
 
130
215
  `width` fixes a column's width in pixels. Columns without one get theirs from the grid's `resizeMethod`:
@@ -159,6 +244,16 @@ A drag stops at the column's `minWidth` and `maxWidth`, and `Escape` during a dr
159
244
 
160
245
  Dropping on the start half of a header puts the column before it, the end half after it; `Escape` cancels the drag.
161
246
 
247
+ ### Column groups
248
+
249
+ Each `mona-grid-column-group` adds a header over the columns inside it, and nested groups add a header row per level. A column outside a group at some level shows its title in the bottom row, with the space above it left empty.
250
+
251
+ - **Order.** A group's columns always sit together, where its first column is. A column moves only among its group's columns and nested groups, and a nested group moves past it as a whole; a column outside the group can't be dropped into it. A saved state that splits a group is put back together.
252
+ - **Width.** A group's header is as wide as its visible columns. Resizing a column widens or narrows its groups too; a group's header has no resize handle of its own.
253
+ - **Hiding.** Hiding a column narrows its groups, and a group with no visible column leaves the header. When the deepest group has no visible column left, its header row goes.
254
+ - **Locking.** A locked column moves to its side of the grid, so its group's header splits there, with the title over each part. Lock every column of a group to keep it whole. While the grid scrolls sideways, a group's title stays in view beside the locked columns as long as part of the group does.
255
+ - **Export.** `exportCsv` writes the column titles only, and `exportExcel` writes the groups as merged header cells, see [State & Export](grid-state-export.md).
256
+
162
257
  ### Locking
163
258
 
164
259
  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.
@@ -169,7 +264,9 @@ With a `monaGridToolbarTemplate`, the toolbar shows a Columns button (the `colum
169
264
 
170
265
  ## Accessibility
171
266
 
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).
267
+ Every column needs a `title`: it names the header, the resize handle and the Columns popup's checkbox. Give every `mona-grid-column-group` a `title` too: it names the group's header. Moving a column from the keyboard is announced through a polite live region (the `columnMoved` message).
268
+
269
+ Group headers are column headers that span their columns, so a screen reader can read a cell's group with its column. `ArrowUp` and `ArrowDown` reach a group's header from any column under it and come back to the same column.
173
270
 
174
271
  ### Keyboard
175
272
 
@@ -179,7 +276,8 @@ Every column needs a `title`: it names the header, the resize handle and the Col
179
276
  | `ArrowLeft` / `ArrowRight` | On a resize handle, narrows/widens the column by 10px (mirrored in right-to-left layouts). |
180
277
  | `Home` / `End` | On a resize handle, sets the column to its narrowest/widest width. |
181
278
  | `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. |
279
+ | `Ctrl+Shift+ArrowLeft` / `Ctrl+Shift+ArrowRight` | With `monaGridReorderable`, moves the focused header's column one place within its column group, past a nested group as a whole (mirrored in right-to-left layouts), and announces it. `Cmd` too. |
280
+ | `ArrowUp` / `ArrowDown` | Between a column's header and the headers of the groups over it. |
183
281
 
184
282
  The rest of the grid's keys are on [Grid Overview](grid.md#keyboard).
185
283
 
@@ -192,25 +290,31 @@ The rest of the grid's keys are on [Grid Overview](grid.md#keyboard).
192
290
  | `aria-label` | On the column resize handle | `"Resize {column}"` (`resizeColumn` message) |
193
291
  | `aria-valuenow` | On the column resize handle | The column width in pixels, with `aria-valuemin`/`aria-valuemax` |
194
292
  | `aria-keyshortcuts` | On a header of a reorderable grid | The keys that move it |
293
+ | `role` | On a column group's header | `"columnheader"`, with `scope="colgroup"` |
294
+ | `aria-colspan` | On a column group's header | The number of columns it spans |
295
+ | `aria-colindex` | On a column group's header | Its first column's position |
296
+ | `aria-hidden` | On the space over a column outside a group | `"true"` |
195
297
 
196
298
  ## API
197
299
 
198
300
  Everything below is imported from `@nanahoshi/mona-ui/grid`. Each name links to its reference page, with every input, output, property and method.
199
301
 
200
- | Name | Kind |
201
- | --- | --- |
202
- | [`GridReorderableDirective`](api/grid.md#gridreorderabledirective) | Directive |
203
- | [`GridResizableDirective`](api/grid.md#gridresizabledirective) | Directive |
204
- | [`ColumnReorderEvent`](api/grid.md#columnreorderevent) | Class |
302
+ | Name | Kind | Description |
303
+ | --- | --- | --- |
304
+ | [`GridColumnGroupComponent`](api/grid.md#gridcolumngroupcomponent) | Component | Puts a header over the `mona-grid-column`s and `mona-grid-command-column`s inside it. |
305
+ | [`GridReorderableDirective`](api/grid.md#gridreorderabledirective) | Directive | |
306
+ | [`GridResizableDirective`](api/grid.md#gridresizabledirective) | Directive | |
307
+ | [`ColumnReorderEvent`](api/grid.md#columnreorderevent) | Class | |
205
308
 
206
309
  ### Types
207
310
 
208
- | Type | Kind |
209
- | --- | --- |
210
- | [`ColumnResizeEvent`](api/grid.md#columnresizeevent) | Interface |
211
- | [`ReorderableOptions`](api/grid.md#reorderableoptions) | Interface |
212
- | [`ResizableOptions`](api/grid.md#resizableoptions) | Interface |
213
- | [`GridColumnLockedPosition`](api/grid.md#gridcolumnlockedposition) | Type alias |
214
- | [`ResizeMethod`](api/grid.md#resizemethod) | Type alias |
311
+ | Type | Kind | Description |
312
+ | --- | --- | --- |
313
+ | [`ColumnGroup`](api/grid.md#columngroup) | Interface | A `mona-grid-column-group`: a header over the columns inside it. |
314
+ | [`ColumnResizeEvent`](api/grid.md#columnresizeevent) | Interface | |
315
+ | [`ReorderableOptions`](api/grid.md#reorderableoptions) | Interface | |
316
+ | [`ResizableOptions`](api/grid.md#resizableoptions) | Interface | |
317
+ | [`GridColumnLockedPosition`](api/grid.md#gridcolumnlockedposition) | Type alias | |
318
+ | [`ResizeMethod`](api/grid.md#resizemethod) | Type alias | |
215
319
 
216
320
  **Related types:** [`Column`](api/grid.md#column), [`PreventableEvent`](api/common.md#preventableevent)
@@ -1,26 +1,26 @@
1
1
  # State & Export
2
2
 
3
- > Save and restore the grid's columns, sort, filter, groups and page size, and export rows as CSV.
3
+ > Save and restore the grid's columns, sort, filter, groups and page size, and export rows as CSV or Excel.
4
4
 
5
5
  Entry point: `@nanahoshi/mona-ui/grid`
6
6
 
7
7
  **Selectors:** `mona-grid[monaGridStatePersistence]`, `mona-grid[monaGridExport]`
8
8
 
9
- `monaGridStatePersistence` captures what people changed (column order, widths and visibility, sort, filter, groups and page size) as a plain `GridState` object you can store and give back later. `monaGridExport` writes the rows of the current view to a CSV file.
9
+ `monaGridStatePersistence` captures what people changed (column order, widths and visibility, sort, filter, groups and page size) as a plain `GridState` object you can store and give back later. `monaGridExport` writes the rows of the current view to a CSV file or an Excel workbook.
10
10
 
11
11
  ## Overview
12
12
 
13
13
  | Directive | State you bind | Methods |
14
14
  | :--- | :--- | :--- |
15
15
  | `monaGridStatePersistence` | `[(state)]`: `GridState \| null` | `captureState()`, `loadState(state)` |
16
- | `monaGridExport` | — | `exportCsv(filename?)` |
16
+ | `monaGridExport` | — | `exportCsv(filename?)`, `exportExcel(filename?)` |
17
17
 
18
18
  A `GridState` is JSON-safe, so it can go to `localStorage`, a user profile on your server, or a URL. The grid doesn't store it anywhere itself.
19
19
 
20
20
  **Use something else when:**
21
21
 
22
22
  - You need one value back, such as the sort. Bind that feature's own model (`[(sort)]`, `[(filter)]`, `[(group)]`, `[(pageSize)]`) instead.
23
- - The export needs every record from a server, or a format other than CSV. Produce it in your application from your data.
23
+ - The export needs every record from a server, or a format other than CSV and Excel, such as PDF. Produce it in your application from your data.
24
24
 
25
25
  ## Import & Quick Start
26
26
 
@@ -34,6 +34,7 @@ protected readonly state = signal<GridState | null>(null);
34
34
 
35
35
  ```html
36
36
  <button monaButton type="button" (click)="gridExport.exportCsv('orders.csv')">Export as CSV</button>
37
+ <button monaButton type="button" (click)="gridExport.exportExcel('orders.xlsx')">Export as Excel</button>
37
38
  <mona-grid
38
39
  #gridExport="monaGridExport"
39
40
  aria-label="Orders"
@@ -92,7 +93,8 @@ export class GridSavedStateExampleComponent {
92
93
  protected readonly orders = Array.from({ length: 24 }, (_, index) => ({
93
94
  orderId: 10248 + index,
94
95
  customer: ["Ernst Handel", "Hanari Carnes", "=Island Trading", "Folk och fä HB"][index % 4],
95
- freight: 12.5 + ((index * 17) % 60)
96
+ freight: 12.5 + ((index * 17) % 60),
97
+ orderDate: new Date(2024, 6, 4 + index * 3)
96
98
  }));
97
99
  /** Restored on the next visit: sort, column order, widths, visibility and page size. */
98
100
  protected readonly state = signal<GridState | null>(readSavedState());
@@ -128,14 +130,16 @@ export class GridSavedStateExampleComponent {
128
130
  [(state)]="state">
129
131
  <ng-template monaGridToolbarTemplate>
130
132
  <button monaButton type="button" (click)="gridExport.exportCsv('orders.csv')">Export as CSV</button>
133
+ <button monaButton type="button" (click)="gridExport.exportExcel('orders.xlsx')">Export as Excel</button>
131
134
  </ng-template>
132
135
  <mona-grid-column field="orderId" title="Order" type="number" />
133
136
  <mona-grid-column field="customer" title="Customer" />
134
137
  <mona-grid-column field="freight" title="Freight" type="number" />
138
+ <mona-grid-column field="orderDate" title="Order Date" type="date" />
135
139
  </mona-grid>
136
140
  ```
137
141
 
138
- The example reads a saved state when it starts and writes every new one to `localStorage`. Sort a column, change the page size or move a column, then reload the page: the grid comes back the same. The toolbar's Export button downloads the rows as `orders.csv`; the customer `=Island Trading` is written as `'=Island Trading`, so a spreadsheet doesn't run it as a formula.
142
+ The example reads a saved state when it starts and writes every new one to `localStorage`. Sort a column, change the page size or move a column, then reload the page: the grid comes back the same. The toolbar's buttons download the rows as `orders.csv` and `orders.xlsx`. In the CSV file the customer `=Island Trading` is written as `'=Island Trading`, so a spreadsheet doesn't run it as a formula; the workbook holds it as text, so it needs no quote. The Order Date column is a real date in the workbook, shown in your spreadsheet's date format.
139
143
 
140
144
  ### Applying a State from Code
141
145
 
@@ -176,9 +180,22 @@ The `state` model updates after each change people make, and a column resize is
176
180
 
177
181
  `exportCsv(filename?)` exports the visible columns of every row in the current view: filtered and sorted, all pages. With server binding it exports only the loaded page. Dates are written as the local calendar date (`YYYY-MM-DD`), and text starting with `=`, `+`, `-`, `@`, a tab or a carriage return is prefixed with `'` so spreadsheets don't run it as a formula. The column titles form the header row. Formatters and cell templates aren't used: the file has the raw values.
178
182
 
183
+ `exportExcel(filename?)` writes the same rows and columns to an `.xlsx` workbook with one sheet, named after the file (`export.xlsx` without a name), and returns a promise that resolves once the download starts.
184
+
185
+ | In the grid | In the workbook |
186
+ | :--- | :--- |
187
+ | A `number`, `boolean` or `date` column's values | Numbers, `TRUE`/`FALSE` and dates, which sort and add up there. Dates use the spreadsheet's short date format, by the local calendar day. A value of another type is written as text. |
188
+ | Text | Text, as it is: a cell's text is never run as a formula, so nothing is prefixed. Empty values leave the cell empty. |
189
+ | Column groups | Merged header cells above the column titles, in bold; a column outside a group has its title merged down to the titles' row. |
190
+ | The header and left-locked columns | Frozen, so they stay in view while the sheet scrolls. |
191
+ | Column widths | The columns' widths. |
192
+ | A right-to-left layout | A right-to-left sheet. |
193
+
194
+ Footers, aggregates and row groups aren't exported, in either format. The workbook is built in the browser, without a dependency, and compressed where the browser supports `CompressionStream`.
195
+
179
196
  ## Accessibility
180
197
 
181
- Neither directive adds roles or keys. Put the export command where people expect it, such as a button in the toolbar, and give it a visible label that says it downloads a file. A restored layout changes the column order and the sort that assistive technology reads, so restore it when the page loads rather than while someone is working in the grid.
198
+ Neither directive adds roles or keys. Put the export commands where people expect them, such as buttons in the toolbar, and give each a visible label that says what it downloads, such as "Export as Excel". A restored layout changes the column order and the sort that assistive technology reads, so restore it when the page loads rather than while someone is working in the grid.
182
199
 
183
200
  ### Keyboard
184
201
 
package/docs/grid.md CHANGED
@@ -310,4 +310,4 @@ Everything below is imported from `@nanahoshi/mona-ui/grid`. Each name links to
310
310
  | [`ColumnFormatFunction`](api/grid.md#columnformatfunction) | Type alias | Formats a cell's value for display. |
311
311
  | [`ColumnKind`](api/grid.md#columnkind) | Type alias | |
312
312
 
313
- **Related types:** [`AggregateFunction`](api/grid.md#aggregatefunction), [`ColumnSortComparator`](api/grid.md#columnsortcomparator), [`DataType`](api/common.md#datatype), [`GridColumnLockedPosition`](api/grid.md#gridcolumnlockedposition), [`GridDataState`](api/grid.md#griddatastate), [`GridEditSession`](api/grid.md#grideditsession), [`GridKeySelector`](api/grid.md#gridkeyselector), [`GridRowClass`](api/grid.md#gridrowclass), [`PageChangeEvent`](api/pager.md#pagechangeevent), [`ResizeMethod`](api/grid.md#resizemethod), [`SortDirection`](api/query.md#sortdirection)
313
+ **Related types:** [`AggregateFunction`](api/grid.md#aggregatefunction), [`ColumnGroup`](api/grid.md#columngroup), [`ColumnSortComparator`](api/grid.md#columnsortcomparator), [`DataType`](api/common.md#datatype), [`GridColumnLockedPosition`](api/grid.md#gridcolumnlockedposition), [`GridDataState`](api/grid.md#griddatastate), [`GridEditSession`](api/grid.md#grideditsession), [`GridKeySelector`](api/grid.md#gridkeyselector), [`GridRowClass`](api/grid.md#gridrowclass), [`PageChangeEvent`](api/pager.md#pagechangeevent), [`ResizeMethod`](api/grid.md#resizemethod), [`SortDirection`](api/query.md#sortdirection)
@@ -1,4 +1,4 @@
1
- import { V as GridService } from "./nanahoshi-mona-ui-grid-grid.styles-62LTuPhD.mjs";
1
+ import { G as GridService } from "./nanahoshi-mona-ui-grid-grid.styles-aPD3c2A6.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-C62HvK-w.mjs.map
77
+ //# sourceMappingURL=nanahoshi-mona-ui-grid-grid-colgroup.component-Lv3GunpV.mjs.map
@@ -1,4 +1,4 @@
1
- import { B as GridLockedCellDirective, I as GridLogicalCellDirective, V as GridService, h as gridFooterTableRowThemeVariants, m as gridFooterTableCellThemeVariants } from "./nanahoshi-mona-ui-grid-grid.styles-62LTuPhD.mjs";
1
+ import { B as GridLogicalCellDirective, G as GridService, W as GridLockedCellDirective, h as gridFooterTableRowThemeVariants, m as gridFooterTableCellThemeVariants } from "./nanahoshi-mona-ui-grid-grid.styles-aPD3c2A6.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";
@@ -376,7 +376,11 @@ var GridFooterRowComponent = class GridFooterRowComponent {
376
376
  kind: "directive",
377
377
  type: GridLockedCellDirective,
378
378
  selector: "td[monaGridLockedCell], th[monaGridLockedCell]",
379
- inputs: ["monaGridLockedCell", "lockedCellHeader"]
379
+ inputs: [
380
+ "monaGridLockedCell",
381
+ "lockedCellHeader",
382
+ "stickyState"
383
+ ]
380
384
  },
381
385
  {
382
386
  kind: "directive",
@@ -387,6 +391,7 @@ var GridFooterRowComponent = class GridFooterRowComponent {
387
391
  "cellKind",
388
392
  "colIndex",
389
393
  "columnId",
394
+ "columnSpan",
390
395
  "editable",
391
396
  "expanded",
392
397
  "firstInRow",
@@ -477,4 +482,4 @@ i0.ɵɵngDeclareClassMetadata({
477
482
  });
478
483
  export { GridFooterRowComponent };
479
484
 
480
- //# sourceMappingURL=nanahoshi-mona-ui-grid-grid-footer-row.component-BpsJwMkQ.mjs.map
485
+ //# sourceMappingURL=nanahoshi-mona-ui-grid-grid-footer-row.component-BYH9XbCV.mjs.map
@@ -1,7 +1,7 @@
1
- import { A as gridListTableThemeVariants, B as GridLockedCellDirective, D as gridListBaseThemeVariants, M as gridRowDragPreviewThemeVariants, V as GridService } from "./nanahoshi-mona-ui-grid-grid.styles-62LTuPhD.mjs";
2
- import { i as GridCellDirective, n as GridGroupRowComponent, r as GridAddRowComponent, t as GridRowComponent } from "./nanahoshi-mona-ui-grid-grid-row.component-D0T8kfdm.mjs";
3
- import { t as GridColgroupComponent } from "./nanahoshi-mona-ui-grid-grid-colgroup.component-C62HvK-w.mjs";
4
- import { GridFooterRowComponent } from "./nanahoshi-mona-ui-grid-grid-footer-row.component-BpsJwMkQ.mjs";
1
+ import { G as GridService, I as gridRowDragPreviewThemeVariants, P as gridListTableThemeVariants, W as GridLockedCellDirective, j as gridListBaseThemeVariants } from "./nanahoshi-mona-ui-grid-grid.styles-aPD3c2A6.mjs";
2
+ import { i as GridCellDirective, n as GridGroupRowComponent, r as GridAddRowComponent, t as GridRowComponent } from "./nanahoshi-mona-ui-grid-grid-row.component-BUJvgihp.mjs";
3
+ import { t as GridColgroupComponent } from "./nanahoshi-mona-ui-grid-grid-colgroup.component-Lv3GunpV.mjs";
4
+ import { GridFooterRowComponent } from "./nanahoshi-mona-ui-grid-grid-footer-row.component-BYH9XbCV.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";
@@ -77,7 +77,11 @@ var GridDetailRowComponent = class GridDetailRowComponent {
77
77
  kind: "directive",
78
78
  type: GridLockedCellDirective,
79
79
  selector: "td[monaGridLockedCell], th[monaGridLockedCell]",
80
- inputs: ["monaGridLockedCell", "lockedCellHeader"]
80
+ inputs: [
81
+ "monaGridLockedCell",
82
+ "lockedCellHeader",
83
+ "stickyState"
84
+ ]
81
85
  },
82
86
  {
83
87
  kind: "directive",
@@ -467,4 +471,4 @@ i0.ɵɵngDeclareClassMetadata({
467
471
  });
468
472
  export { GridListComponent };
469
473
 
470
- //# sourceMappingURL=nanahoshi-mona-ui-grid-grid-list.component-BVpGUjA7.mjs.map
474
+ //# sourceMappingURL=nanahoshi-mona-ui-grid-grid-list.component-S2iCn8TV.mjs.map
@@ -1,5 +1,5 @@
1
- import { B as GridLockedCellDirective, F as gridSelectionCellThemeVariants, I as GridLogicalCellDirective, L as GRID_CELL_FOCUSABLE_SELECTOR, N as gridRowReorderHandleThemeVariants, O as gridListTableCellThemeVariants, U as GridNavigationService, V as GridService, a as gridCellEditorBaseThemeVariants, b as gridGroupRowThemeVariants, i as gridCellDirtyIndicatorThemeVariants, k as gridListTableRowThemeVariants, n as gridCellBaseThemeVariants, o as gridCellEditorInputThemeVariants, r as gridCellContainerThemeVariants, s as gridCellTextThemeVariants } from "./nanahoshi-mona-ui-grid-grid.styles-62LTuPhD.mjs";
2
- import { n as removeGridRow } from "./nanahoshi-mona-ui-grid-grid-colgroup.component-C62HvK-w.mjs";
1
+ import { B as GridLogicalCellDirective, G as GridService, L as gridRowReorderHandleThemeVariants, M as gridListTableCellThemeVariants, N as gridListTableRowThemeVariants, V as GRID_CELL_FOCUSABLE_SELECTOR, W as GridLockedCellDirective, Z as GridNavigationService, a as gridCellEditorBaseThemeVariants, b as gridGroupRowThemeVariants, i as gridCellDirtyIndicatorThemeVariants, n as gridCellBaseThemeVariants, o as gridCellEditorInputThemeVariants, r as gridCellContainerThemeVariants, s as gridCellTextThemeVariants, z as gridSelectionCellThemeVariants } from "./nanahoshi-mona-ui-grid-grid.styles-aPD3c2A6.mjs";
2
+ import { n as removeGridRow } from "./nanahoshi-mona-ui-grid-grid-colgroup.component-Lv3GunpV.mjs";
3
3
  import * as i0 from "@angular/core";
4
4
  import { Component, Directive, ElementRef, Injector, LOCALE_ID, afterNextRender, computed, effect, inject, input, isDevMode, model, output, signal, untracked, viewChild } from "@angular/core";
5
5
  import { DialogService } from "@nanahoshi/mona-ui/dialog";
@@ -997,7 +997,11 @@ var GridAddRowComponent = class GridAddRowComponent {
997
997
  kind: "directive",
998
998
  type: GridLockedCellDirective,
999
999
  selector: "td[monaGridLockedCell], th[monaGridLockedCell]",
1000
- inputs: ["monaGridLockedCell", "lockedCellHeader"]
1000
+ inputs: [
1001
+ "monaGridLockedCell",
1002
+ "lockedCellHeader",
1003
+ "stickyState"
1004
+ ]
1001
1005
  },
1002
1006
  {
1003
1007
  kind: "directive",
@@ -1008,6 +1012,7 @@ var GridAddRowComponent = class GridAddRowComponent {
1008
1012
  "cellKind",
1009
1013
  "colIndex",
1010
1014
  "columnId",
1015
+ "columnSpan",
1011
1016
  "editable",
1012
1017
  "expanded",
1013
1018
  "firstInRow",
@@ -1264,7 +1269,11 @@ var GridGroupRowComponent = class GridGroupRowComponent {
1264
1269
  kind: "directive",
1265
1270
  type: GridLockedCellDirective,
1266
1271
  selector: "td[monaGridLockedCell], th[monaGridLockedCell]",
1267
- inputs: ["monaGridLockedCell", "lockedCellHeader"]
1272
+ inputs: [
1273
+ "monaGridLockedCell",
1274
+ "lockedCellHeader",
1275
+ "stickyState"
1276
+ ]
1268
1277
  },
1269
1278
  {
1270
1279
  kind: "directive",
@@ -1275,6 +1284,7 @@ var GridGroupRowComponent = class GridGroupRowComponent {
1275
1284
  "cellKind",
1276
1285
  "colIndex",
1277
1286
  "columnId",
1287
+ "columnSpan",
1278
1288
  "editable",
1279
1289
  "expanded",
1280
1290
  "firstInRow",
@@ -1995,7 +2005,11 @@ var GridRowComponent = class GridRowComponent {
1995
2005
  kind: "directive",
1996
2006
  type: GridLockedCellDirective,
1997
2007
  selector: "td[monaGridLockedCell], th[monaGridLockedCell]",
1998
- inputs: ["monaGridLockedCell", "lockedCellHeader"]
2008
+ inputs: [
2009
+ "monaGridLockedCell",
2010
+ "lockedCellHeader",
2011
+ "stickyState"
2012
+ ]
1999
2013
  },
2000
2014
  {
2001
2015
  kind: "directive",
@@ -2006,6 +2020,7 @@ var GridRowComponent = class GridRowComponent {
2006
2020
  "cellKind",
2007
2021
  "colIndex",
2008
2022
  "columnId",
2023
+ "columnSpan",
2009
2024
  "editable",
2010
2025
  "expanded",
2011
2026
  "firstInRow",
@@ -2112,4 +2127,4 @@ i0.ɵɵngDeclareClassMetadata({
2112
2127
  });
2113
2128
  export { GridCellDirective as i, GridGroupRowComponent as n, GridAddRowComponent as r, GridRowComponent as t };
2114
2129
 
2115
- //# sourceMappingURL=nanahoshi-mona-ui-grid-grid-row.component-D0T8kfdm.mjs.map
2130
+ //# sourceMappingURL=nanahoshi-mona-ui-grid-grid-row.component-BUJvgihp.mjs.map
@@ -1,7 +1,7 @@
1
- import { A as gridListTableThemeVariants, D as gridListBaseThemeVariants, U as GridNavigationService, V as GridService, _ as gridFooterThemeVariants, g as gridFooterTableThemeVariants } from "./nanahoshi-mona-ui-grid-grid.styles-62LTuPhD.mjs";
2
- import { n as GridGroupRowComponent, r as GridAddRowComponent, t as GridRowComponent } from "./nanahoshi-mona-ui-grid-grid-row.component-D0T8kfdm.mjs";
3
- import { t as GridColgroupComponent } from "./nanahoshi-mona-ui-grid-grid-colgroup.component-C62HvK-w.mjs";
4
- import { GridFooterRowComponent } from "./nanahoshi-mona-ui-grid-grid-footer-row.component-BpsJwMkQ.mjs";
1
+ import { G as GridService, P as gridListTableThemeVariants, Z as GridNavigationService, _ as gridFooterThemeVariants, g as gridFooterTableThemeVariants, j as gridListBaseThemeVariants } from "./nanahoshi-mona-ui-grid-grid.styles-aPD3c2A6.mjs";
2
+ import { n as GridGroupRowComponent, r as GridAddRowComponent, t as GridRowComponent } from "./nanahoshi-mona-ui-grid-grid-row.component-BUJvgihp.mjs";
3
+ import { t as GridColgroupComponent } from "./nanahoshi-mona-ui-grid-grid-colgroup.component-Lv3GunpV.mjs";
4
+ import { GridFooterRowComponent } from "./nanahoshi-mona-ui-grid-grid-footer-row.component-BYH9XbCV.mjs";
5
5
  import * as i0 from "@angular/core";
6
6
  import { Component, DestroyRef, ElementRef, Injector, afterNextRender, computed, effect, inject, input, untracked, viewChild } from "@angular/core";
7
7
  import { ImmutableList } from "@mirei/ts-collections";
@@ -327,4 +327,4 @@ i0.ɵɵngDeclareClassMetadata({
327
327
  });
328
328
  export { GridVirtualListComponent };
329
329
 
330
- //# sourceMappingURL=nanahoshi-mona-ui-grid-grid-virtual-list.component-5D2BjGx4.mjs.map
330
+ //# sourceMappingURL=nanahoshi-mona-ui-grid-grid-virtual-list.component-Wndy-_Bt.mjs.map