@nanahoshi/mona-ui 0.32.3 → 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/file-upload.md +174 -0
- package/docs/api/grid.md +46 -13
- package/docs/api/i18n.md +46 -0
- package/docs/api/locales.md +14 -14
- package/docs/file-upload.md +516 -0
- package/docs/forms.md +2 -0
- package/docs/grid-columns.md +121 -17
- package/docs/grid-state-export.md +24 -7
- package/docs/grid.md +1 -1
- package/fesm2022/nanahoshi-mona-ui-color-gradient.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-command.mjs +4 -3
- package/fesm2022/nanahoshi-mona-ui-dropdowns.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-file-upload.mjs +1137 -0
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-colgroup.component-NhONCVIX.mjs → nanahoshi-mona-ui-grid-grid-colgroup.component-Lv3GunpV.mjs} +2 -2
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-footer-row.component-Djv8ZnT5.mjs → nanahoshi-mona-ui-grid-grid-footer-row.component-BYH9XbCV.mjs} +8 -3
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-list.component-C1qjq2s7.mjs → nanahoshi-mona-ui-grid-grid-list.component-S2iCn8TV.mjs} +10 -6
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-row.component-CgOt2A6O.mjs → nanahoshi-mona-ui-grid-grid-row.component-BUJvgihp.mjs} +23 -8
- package/fesm2022/{nanahoshi-mona-ui-grid-grid-virtual-list.component-tguG2LpN.mjs → nanahoshi-mona-ui-grid-grid-virtual-list.component-Wndy-_Bt.mjs} +5 -5
- package/fesm2022/{nanahoshi-mona-ui-grid-grid.styles-BmLU-3zP.mjs → nanahoshi-mona-ui-grid-grid.styles-aPD3c2A6.mjs} +230 -18
- package/fesm2022/nanahoshi-mona-ui-grid.mjs +425 -31
- package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +74 -0
- package/fesm2022/nanahoshi-mona-ui-internal-live-announcer.mjs +10 -0
- package/fesm2022/nanahoshi-mona-ui-internal-tree.mjs +3 -2
- package/fesm2022/nanahoshi-mona-ui-list-box.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +50 -0
- package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +38 -0
- package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +38 -0
- package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +38 -0
- package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +38 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +44 -0
- package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +38 -0
- package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +44 -0
- package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +29 -0
- package/fesm2022/nanahoshi-mona-ui-notification.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-spinner.mjs +2 -2
- package/fesm2022/nanahoshi-mona-ui-tree-view.mjs +2 -2
- package/file-upload/package.json +4 -0
- package/i18n/catalogs/en-US.messages.json +29 -0
- package/internal/live-announcer/package.json +4 -0
- package/llms.txt +6 -4
- package/locales/ar-sa/ar-sa.messages.json +29 -0
- package/locales/de-de/de-de.messages.json +29 -0
- package/locales/es-es/es-es.messages.json +29 -0
- package/locales/fr-fr/fr-fr.messages.json +29 -0
- package/locales/id-id/id-id.messages.json +29 -0
- package/locales/it-it/it-it.messages.json +29 -0
- package/locales/ja-jp/ja-jp.messages.json +29 -0
- package/locales/ko-kr/ko-kr.messages.json +29 -0
- package/locales/pl-pl/pl-pl.messages.json +29 -0
- package/locales/pt-br/pt-br.messages.json +29 -0
- package/locales/ru-ru/ru-ru.messages.json +29 -0
- package/locales/tr-tr/tr-tr.messages.json +29 -0
- package/locales/zh-cn/zh-cn.messages.json +29 -0
- package/locales/zh-tw/zh-tw.messages.json +29 -0
- package/package.json +9 -1
- package/types/nanahoshi-mona-ui-file-upload.d.ts +366 -0
- package/types/nanahoshi-mona-ui-grid.d.ts +142 -64
- package/types/nanahoshi-mona-ui-i18n.d.ts +60 -0
- package/types/nanahoshi-mona-ui-internal-live-announcer.d.ts +12 -0
- package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-de-de.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-es-es.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-id-id.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-it-it.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +29 -0
- package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +29 -0
package/docs/grid-columns.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# Columns
|
|
2
2
|
|
|
3
|
-
>
|
|
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 {
|
|
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
|
-
| [`
|
|
203
|
-
| [`
|
|
204
|
-
| [`
|
|
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
|
-
| [`
|
|
211
|
-
| [`
|
|
212
|
-
| [`
|
|
213
|
-
| [`
|
|
214
|
-
| [`
|
|
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
|
|
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
|
|
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,3 @@
|
|
|
1
|
-
import { LiveAnnouncer } from "@angular/cdk/a11y";
|
|
2
1
|
import { Clipboard } from "@angular/cdk/clipboard";
|
|
3
2
|
import { NgTemplateOutlet } from "@angular/common";
|
|
4
3
|
import * as i0 from "@angular/core";
|
|
@@ -7,6 +6,7 @@ import { takeUntilDestroyed } from "@angular/core/rxjs-interop";
|
|
|
7
6
|
import { LucideChevronsUpDown, LucideCopy, LucideDropletOff } from "@lucide/angular";
|
|
8
7
|
import { ButtonDirective } from "@nanahoshi/mona-ui/button";
|
|
9
8
|
import { FIELD_ASSOCIATION_BOUNDARY, formatAlpha, hex2rgba, hsva2rgba, injectEffectiveDisabled, injectLabelAssociation, isValidHex, parseColor, rgba2hex, rgba2hsla, rgba2hsva } from "@nanahoshi/mona-ui/internal";
|
|
9
|
+
import { injectLiveAnnouncer } from "@nanahoshi/mona-ui/internal/live-announcer";
|
|
10
10
|
import { DropdownButtonComponent, DropdownButtonItemComponent, DropdownButtonTextTemplateDirective } from "@nanahoshi/mona-ui/dropdown-button";
|
|
11
11
|
import { NumericTextBoxComponent, NumericTextBoxPrefixTemplateDirective } from "@nanahoshi/mona-ui/numeric-text-box";
|
|
12
12
|
import { SliderComponent } from "@nanahoshi/mona-ui/slider";
|
|
@@ -126,7 +126,7 @@ var ColorGradientComponent = class ColorGradientComponent {
|
|
|
126
126
|
#internalValueUpdatePending;
|
|
127
127
|
#lastInternalValue;
|
|
128
128
|
constructor() {
|
|
129
|
-
this.#announcer =
|
|
129
|
+
this.#announcer = injectLiveAnnouncer();
|
|
130
130
|
this.#clipboard = inject(Clipboard);
|
|
131
131
|
this.#destroyRef = inject(DestroyRef);
|
|
132
132
|
this.#document = inject(DOCUMENT);
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import * as i1 from "@angular/cdk/a11y";
|
|
2
|
-
import { A11yModule, LiveAnnouncer } from "@angular/cdk/a11y";
|
|
3
1
|
import * as i0 from "@angular/core";
|
|
4
2
|
import { Component, DestroyRef, Directive, ElementRef, Injector, Renderer2, TemplateRef, afterNextRender, afterRenderEffect, booleanAttribute, computed, contentChild, effect, inject, input, model, output, signal, untracked, viewChild } from "@angular/core";
|
|
5
3
|
import { ImmutableSet } from "@mirei/ts-collections";
|
|
6
4
|
import { MonaI18nService, formatNumber } from "@nanahoshi/mona-ui/i18n";
|
|
7
5
|
import { createElementControlId, inertOutside, positionGlobalOverlay } from "@nanahoshi/mona-ui/internal";
|
|
6
|
+
import { injectLiveAnnouncer } from "@nanahoshi/mona-ui/internal/live-announcer";
|
|
8
7
|
import { cva } from "class-variance-authority";
|
|
8
|
+
import * as i1 from "@angular/cdk/a11y";
|
|
9
|
+
import { A11yModule } from "@angular/cdk/a11y";
|
|
9
10
|
import { DOCUMENT, NgTemplateOutlet } from "@angular/common";
|
|
10
11
|
import { PopupService } from "@nanahoshi/mona-ui/popup";
|
|
11
12
|
import { merge, take } from "rxjs";
|
|
@@ -134,7 +135,7 @@ var CommandComponent = class CommandComponent {
|
|
|
134
135
|
this.#i18n = inject(MonaI18nService);
|
|
135
136
|
this.#inputElement = signal(null, ...ngDevMode ? [{ debugName: "#inputElement" }] : /* istanbul ignore next */ []);
|
|
136
137
|
this.#items = signal(ImmutableSet.create(), ...ngDevMode ? [{ debugName: "#items" }] : /* istanbul ignore next */ []);
|
|
137
|
-
this.#liveAnnouncer =
|
|
138
|
+
this.#liveAnnouncer = injectLiveAnnouncer();
|
|
138
139
|
this.#visibleItems = computed(() => this.#items().where((item) => item.visible()).toArray(), ...ngDevMode ? [{ debugName: "#visibleItems" }] : /* istanbul ignore next */ []);
|
|
139
140
|
this.baseClass = computed(() => commandBaseThemeVariants({ rounded: this.rounded() }), ...ngDevMode ? [{ debugName: "baseClass" }] : /* istanbul ignore next */ []);
|
|
140
141
|
this.activeItem = this.#activeItem.asReadonly();
|
|
@@ -7,8 +7,8 @@ import { PopupCloseEvent, PopupCloseSource, PopupService, dropdownPopupAnimation
|
|
|
7
7
|
import { Subject, filter, fromEvent, switchMap, take, takeUntil } from "rxjs";
|
|
8
8
|
import { ConnectionPositionPair } from "@angular/cdk/overlay";
|
|
9
9
|
import { focusCanReturn, themeOverlaySurfaceClasses } from "@nanahoshi/mona-ui/internal";
|
|
10
|
-
import { LiveAnnouncer } from "@angular/cdk/a11y";
|
|
11
10
|
import { MonaI18nService, formatNumber } from "@nanahoshi/mona-ui/i18n";
|
|
11
|
+
import { injectLiveAnnouncer } from "@nanahoshi/mona-ui/internal/live-announcer";
|
|
12
12
|
import { cva } from "class-variance-authority";
|
|
13
13
|
const DROPDOWN_DATA_INPUT_TOKEN = new InjectionToken("DROPDOWN_DATA_INPUT");
|
|
14
14
|
const DropdownDataInputToken = DROPDOWN_DATA_INPUT_TOKEN;
|
|
@@ -929,7 +929,7 @@ var DropdownLiveRegionDirective = class DropdownLiveRegionDirective {
|
|
|
929
929
|
#dropdownService = inject(DropdownService);
|
|
930
930
|
#i18n = inject(MonaI18nService);
|
|
931
931
|
#listService = inject(ListService);
|
|
932
|
-
#liveAnnouncer =
|
|
932
|
+
#liveAnnouncer = injectLiveAnnouncer();
|
|
933
933
|
#messages = this.#i18n.componentMessages("dropdowns", DROPDOWNS_DEFAULT_MESSAGES);
|
|
934
934
|
constructor() {
|
|
935
935
|
let lastState = null;
|