@su-labs/table 22.0.0 → 22.1.1
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/CHANGELOG.md +32 -1
- package/README.md +162 -14
- package/fesm2022/su-labs-table.mjs +894 -34
- package/fesm2022/su-labs-table.mjs.map +1 -1
- package/package.json +2 -2
- package/types/su-labs-table.d.ts +273 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,38 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [
|
|
8
|
+
## [22.1.1] - 2026-11-15
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
- The heading pin of a column set up with `pinned: 'end'` pins it back to the end instead of the start
|
|
12
|
+
|
|
13
|
+
## [22.1.0]
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- Pinned columns: `pinned: 'start' | 'end'` on a column keeps it in view while the others scroll, with a soft shadow on its edge while columns pass under it; the move handles and checkboxes stay with columns pinned to the start, the actions with those pinned to the end
|
|
17
|
+
- A pin in the heading of pinned and pinnable columns (`pinnable: true`) pins the column to the start or unpins it (a toggle, announced)
|
|
18
|
+
- `columnControls`: a Columns button with a menu to show, hide, pin and unpin columns: a search for long lists, a Select all checkbox (partly checked while some columns are hidden), a checkbox for each column and a toggle beside it that shows or hides the column's heading pin; Escape or a click outside closes it
|
|
19
|
+
- When the pinned columns would leave too little room to scroll the rest (e.g. on a phone), they stop sticking until there's room
|
|
20
|
+
- `--su-table-pinned-background` and `--su-table-pinned-shadow`
|
|
21
|
+
- Pinned columns show a pin in their heading and a thin line on their edge, so they read as pinned before anything scrolls; `--su-table-pinned-border`
|
|
22
|
+
- Pagination: `pageSize` and `pageSizes` show the rows a page at a time, with a paginator under the table (rows per page, the range on screen, previous and next, announced); `pageChange` emits `{ page, pageSize }`
|
|
23
|
+
- The select-all checkbox selects the rows of the current page; the selection is kept across pages
|
|
24
|
+
- Pinned rows: `rowPinning` adds a Pin button to each row (a toggle, announced) that keeps it above the others on every page, tinted and set off by a line; `pinnedRows` sets the starting pins and `pinnedRowsChange` emits their ids
|
|
25
|
+
- `--su-table-pinned-row-background` and `--su-table-pinned-row-border`
|
|
26
|
+
- Search: `searchable` adds a search box above the table that narrows the rows by the text they show, ignoring case and accents (every word must match), once typing pauses; the number of matches is announced, Escape clears it, pinned rows stay, and reordering is off meanwhile; `searchChange` emits the query
|
|
27
|
+
- The search box and the Columns button share a bar above the table
|
|
28
|
+
- Show and hide columns: `hidden: true` starts a column out of view (its field stays in the row data and comes back on save), with a checkbox for each column in the Columns menu; the last column on view stays shown, and hidden columns are left out of the search
|
|
29
|
+
- Sticky headers: `maxHeight` (any CSS length) lets the table scroll inside; the header stays at the top and the pinned rows stay under it, with a soft shadow while rows scroll beneath; `--su-table-sticky-shadow`
|
|
30
|
+
- Double-click editing: a double-click on an editable cell edits its row, starting in that field with its text selected; while a row is being edited, a double-click elsewhere never drops its changes. `editOnDoubleClick` turns it off. Without other actions, an actions column shows for Save and Cancel while a row is edited
|
|
31
|
+
- Theming: CSS variables for the header (font size and weight, letter spacing, text transform, padding, border), rows (background, text colour, stripes), the selected row's text, the sorted column, hovered editable cells, the caption, checkbox size, the move handle and a drop line showing where a dragged row will land (`--su-table-drop-line-color`, `--su-table-drop-line-width`)
|
|
32
|
+
- `rowClass` adds your own classes to rows; `is-muted` and `is-highlighted` come styled, with their own variables
|
|
33
|
+
- `columnsChange` emits every column's state (`SuTableColumnState`: shown, pinned) after a change in the Columns menu, e.g. to save it
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
- The cell that heads each row is a `<td role="rowheader">` instead of a `<th scope="row">`, styled through `.su-table-row-header` and `--su-table-row-header-weight`
|
|
37
|
+
|
|
38
|
+
### Fixed
|
|
39
|
+
- The table shrinks to fit inside grid and flex layouts, scrolling its columns instead of widening the page
|
|
9
40
|
|
|
10
41
|
## [22.0.0]
|
|
11
42
|
|
package/README.md
CHANGED
|
@@ -108,7 +108,9 @@ export class UsersPage {
|
|
|
108
108
|
}
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
The `edit` action is handled by the table: it edits that row inline (Enter saves, Escape cancels).
|
|
111
|
+
The `edit` action is handled by the table: it edits that row inline (Enter saves, Escape cancels). A double-click on
|
|
112
|
+
an editable cell does the same, starting in that field (`editOnDoubleClick` turns it off); the Edit button stays as the
|
|
113
|
+
way in for keyboards. Selecting rows
|
|
112
114
|
shows a toolbar to edit them together or run the bulk actions.
|
|
113
115
|
|
|
114
116
|
### Custom cells
|
|
@@ -137,6 +139,15 @@ Put anything in a column's cells with a template; `suTableCellOf` only types the
|
|
|
137
139
|
| `actions` | `[]` | `SuTableAction<TRow>[]`, buttons on each row |
|
|
138
140
|
| `selectable` | `false` | Checkboxes to select rows, with a toolbar for the selection |
|
|
139
141
|
| `reorderable` | `false` | A move handle on each row |
|
|
142
|
+
| `columnControls` | `false` | A Columns button with a menu: search, Select all, a checkbox to show each column, and a toggle for the pin in its heading |
|
|
143
|
+
| `pageSize` | `'all'` | Rows per page |
|
|
144
|
+
| `pageSizes` | `[]` | Page sizes to choose from under the table, e.g. `[10, 25, 50, 'all']` |
|
|
145
|
+
| `maxHeight` | — | Any CSS length, e.g. `'28rem'`: the table scrolls inside, keeping the header and pinned rows in view |
|
|
146
|
+
| `editOnDoubleClick` | `true` | A double-click on an editable cell edits its row, starting in that field |
|
|
147
|
+
| `searchable` | `false` | A search box above the table that narrows the rows by their text |
|
|
148
|
+
| `rowPinning` | `false` | A Pin button on each row, keeping it above the others on every page |
|
|
149
|
+
| `pinnedRows` | — | The ids of the rows pinned to start with |
|
|
150
|
+
| `rowClass` | — | Extra classes for a row, e.g. `(row) => (row.active ? null : 'is-muted')` |
|
|
140
151
|
| `labels` | English | `Partial<SuTableLabels>`: any text, e.g. in the page's language |
|
|
141
152
|
|
|
142
153
|
### Outputs
|
|
@@ -148,6 +159,10 @@ Put anything in a column's cells with a template; `suTableCellOf` only types the
|
|
|
148
159
|
| `action` | `{ id, rows }`: the clicked row, or the selected rows for a bulk action |
|
|
149
160
|
| `sortChange` | `{ key, direction } \| null` |
|
|
150
161
|
| `selectionChange` | `readonly TRow[]` |
|
|
162
|
+
| `pageChange` | `{ page, pageSize }`, the page from 0 |
|
|
163
|
+
| `searchChange` | The query, once typing pauses |
|
|
164
|
+
| `columnsChange` | Every column's state (`{ key, header, visible, pinned }`) after a change in the Columns menu |
|
|
165
|
+
| `pinnedRowsChange` | The ids of the pinned rows, in pin order |
|
|
151
166
|
|
|
152
167
|
The table shows your changes right away; update `rows` with the API's answer to keep them, or to undo a failed save.
|
|
153
168
|
|
|
@@ -162,6 +177,10 @@ The table shows your changes right away; update `rows` with the API's answer to
|
|
|
162
177
|
| `edit` | How the field is edited; without it the column is read-only |
|
|
163
178
|
| `validate(value, row)` | A message when an edited value isn't valid, or `null` |
|
|
164
179
|
| `align` | `'start'`, `'center'` or `'end'` |
|
|
180
|
+
| `pinned` | `'start'` or `'end'`: stays in view at that edge while the other columns scroll |
|
|
181
|
+
| `pinnable` | `true` to show the pin in its heading (default: only on pinned columns) |
|
|
182
|
+
| `searchable` | `false` to leave the column out of the search (default `true`) |
|
|
183
|
+
| `hidden` | `true` to start out of view; the field stays in the row data and comes back on save |
|
|
165
184
|
|
|
166
185
|
### Editors
|
|
167
186
|
|
|
@@ -185,6 +204,67 @@ back to the API value, and an optional `validate(value)`.
|
|
|
185
204
|
| `bulk` | Also offered for the selected rows |
|
|
186
205
|
| `hidden(row)` / `disabled(row)` | Leaves the button out, or disables it, for a row |
|
|
187
206
|
|
|
207
|
+
## Pinned columns
|
|
208
|
+
|
|
209
|
+
Pin a column to keep it in view while the others scroll, e.g. the product name on a phone:
|
|
210
|
+
|
|
211
|
+
```ts
|
|
212
|
+
{ key: 'name', header: 'Product', pinned: 'start' },
|
|
213
|
+
{ key: 'price', header: 'Price', pinned: 'end' },
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
Pinned columns move to their edge in the order you list them. The move handles and checkboxes stay with the columns
|
|
217
|
+
pinned to the start, and the actions with those pinned to the end. A soft shadow shows on the pinned edge while other
|
|
218
|
+
columns scroll under it. Pinned columns, and columns marked `pinnable: true`, show a pin in their heading: tapping it pins or
|
|
219
|
+
unpins the column. The Columns menu (`columnControls`) chooses which headings show that pin. If the
|
|
220
|
+
pinned columns would leave too little room for the rest, they stop sticking until there's room again.
|
|
221
|
+
|
|
222
|
+
## Sticky header
|
|
223
|
+
|
|
224
|
+
Give the table a `maxHeight` and it scrolls inside that height, keeping the header at the top and the pinned rows just
|
|
225
|
+
under it, with a soft shadow once rows scroll beneath them:
|
|
226
|
+
|
|
227
|
+
```html
|
|
228
|
+
<su-lib-table caption="Products" [columns]="columns" [rows]="products()" maxHeight="28rem" />
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
Without a `maxHeight` the table grows with its rows and the page scrolls instead. A header can't stick to the page
|
|
232
|
+
itself while the table scrolls sideways, which it needs to do on narrow screens.
|
|
233
|
+
|
|
234
|
+
## Showing and hiding columns
|
|
235
|
+
|
|
236
|
+
Load all of the API's fields and show only some: `hidden: true` starts a column out of view, and with `columnControls`
|
|
237
|
+
the Columns menu has a checkbox for each column beside its pin choice. Hidden fields stay in each row, so a saved row
|
|
238
|
+
still comes back whole; they're left out of the search and the edit fields, and the last column on view can't be
|
|
239
|
+
hidden. Keep the layout with `columnsChange`.
|
|
240
|
+
|
|
241
|
+
## Search
|
|
242
|
+
|
|
243
|
+
`searchable` adds a search box above the table. It matches the text people see (so `€18.50` and `Garden` match, not
|
|
244
|
+
`18.5` and `garden`), ignores case and accents, and needs every word typed to match somewhere in the row. It runs once
|
|
245
|
+
typing pauses and announces how many rows match; Escape clears it. Pinned rows stay, the pages cover the matches, and
|
|
246
|
+
reordering is off while searching. Leave a column out with `searchable: false`.
|
|
247
|
+
|
|
248
|
+
## Pinned rows
|
|
249
|
+
|
|
250
|
+
With `rowPinning`, each row gets a Pin button. Pinned rows stay above the others on every page, in the order they were
|
|
251
|
+
pinned, and aren't counted in the pages or moved by sorting and reordering; unpinning puts a row back where it was.
|
|
252
|
+
Start with some pinned, and keep track of them, e.g. to save them:
|
|
253
|
+
|
|
254
|
+
```html
|
|
255
|
+
<su-lib-table … rowPinning [pinnedRows]="[103]" (pinnedRowsChange)="savePins($event)" />
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Pagination
|
|
259
|
+
|
|
260
|
+
```html
|
|
261
|
+
<su-lib-table caption="Products" [columns]="columns" [rows]="products()" [pageSize]="25" [pageSizes]="[10, 25, 50, 'all']" />
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
Under the table: a rows-per-page choice, the range on screen ("26–50 of 132") and previous and next buttons; each page
|
|
265
|
+
change is announced. Changing the page size keeps the first row on screen in view, sorting goes back to the first page,
|
|
266
|
+
and the select-all checkbox selects the rows of the page on screen while the selection is kept across pages.
|
|
267
|
+
|
|
188
268
|
## Keyboard
|
|
189
269
|
|
|
190
270
|
| Where | Key | Does |
|
|
@@ -197,35 +277,103 @@ back to the API value, and an optional `validate(value)`.
|
|
|
197
277
|
|
|
198
278
|
## Styling
|
|
199
279
|
|
|
200
|
-
Set
|
|
280
|
+
Every colour, border, size and state is a CSS variable. Set them on `:root` (your theme), on `su-lib-table`, or on a
|
|
281
|
+
class for one table:
|
|
201
282
|
|
|
202
283
|
```css
|
|
203
284
|
su-lib-table {
|
|
204
|
-
--su-table-
|
|
205
|
-
--su-table-header-
|
|
206
|
-
--su-table-
|
|
285
|
+
--su-table-header-background: #0f3d2e;
|
|
286
|
+
--su-table-header-color: #d1fae5;
|
|
287
|
+
--su-table-header-text-transform: uppercase;
|
|
288
|
+
--su-table-stripe-background: rgb(16 185 129 / 0.06);
|
|
289
|
+
--su-table-sorted-background: rgb(16 185 129 / 0.1);
|
|
290
|
+
--su-table-drop-line-color: #10b981;
|
|
207
291
|
}
|
|
208
292
|
```
|
|
209
293
|
|
|
294
|
+
### Row states
|
|
295
|
+
|
|
296
|
+
`rowClass` adds your own classes to a row, e.g. to mark inactive rows. The table styles two of them:
|
|
297
|
+
|
|
298
|
+
```ts
|
|
299
|
+
rowClass = (user: User) => (user.active ? null : 'is-muted');
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
| Class | Variables |
|
|
303
|
+
|-------|-----------|
|
|
304
|
+
| `is-muted` | `--su-table-muted-background` (`transparent`), `--su-table-muted-text` (`55%`, how much of the text colour shows) |
|
|
305
|
+
| `is-highlighted` | `--su-table-highlight-background` (a soft amber tint) |
|
|
306
|
+
|
|
307
|
+
Other classes are yours to style from a global stylesheet.
|
|
308
|
+
|
|
309
|
+
### Variables
|
|
310
|
+
|
|
311
|
+
Defaults are in brackets; "tint" means the accent blue at a low opacity.
|
|
312
|
+
|
|
313
|
+
**Table**
|
|
314
|
+
|
|
210
315
|
| Variable | Default |
|
|
211
316
|
|----------|---------|
|
|
212
317
|
| `--su-table-font-family` / `--su-table-font-size` / `--su-table-text-color` | `inherit` / `0.95rem` / `inherit` |
|
|
213
318
|
| `--su-table-background` | `transparent` |
|
|
214
319
|
| `--su-table-border` / `--su-table-radius` | `1px solid rgb(0 0 0 / 0.12)` / `10px` |
|
|
215
|
-
| `--su-table-
|
|
216
|
-
| `--su-table-
|
|
217
|
-
| `--su-table-
|
|
218
|
-
| `--su-table-
|
|
219
|
-
| `--su-table-
|
|
220
|
-
|
|
221
|
-
|
|
320
|
+
| `--su-table-cell-padding` / `--su-table-cell-vertical-align` | `0.6rem 0.75rem` / `middle` |
|
|
321
|
+
| `--su-table-caption-color` / `--su-table-caption-font-size` | `inherit` |
|
|
322
|
+
| `--su-table-accent` | `#2563eb` (checkboxes, pressed pins) |
|
|
323
|
+
| `--su-table-checkbox-size` | `1rem` |
|
|
324
|
+
| `--su-table-focus-outline` | `2px solid currentColor` |
|
|
325
|
+
|
|
326
|
+
**Header**
|
|
327
|
+
|
|
328
|
+
| Variable | Default |
|
|
329
|
+
|----------|---------|
|
|
330
|
+
| `--su-table-header-background` / `--su-table-header-color` | a faint grey / `inherit` |
|
|
331
|
+
| `--su-table-header-font-size` / `--su-table-header-font-weight` | `inherit` / `600` |
|
|
332
|
+
| `--su-table-header-text-transform` / `--su-table-header-letter-spacing` | `none` / `normal` |
|
|
333
|
+
| `--su-table-header-padding` / `--su-table-header-border` | the cell padding / the row border |
|
|
334
|
+
| `--su-table-sticky-shadow` | `0 6px 8px -6px rgb(0 0 0 / 0.25)` (under a sticky header while rows scroll beneath) |
|
|
335
|
+
|
|
336
|
+
**Rows and cells**
|
|
337
|
+
|
|
338
|
+
| Variable | Default |
|
|
339
|
+
|----------|---------|
|
|
340
|
+
| `--su-table-row-background` / `--su-table-row-color` | `transparent` / `inherit` |
|
|
341
|
+
| `--su-table-stripe-background` | the row background (set it for striped rows) |
|
|
342
|
+
| `--su-table-row-border` / `--su-table-row-header-weight` | `1px solid rgb(0 0 0 / 0.08)` / `600` |
|
|
343
|
+
| `--su-table-hover-background` | a faint grey |
|
|
344
|
+
| `--su-table-selected-background` / `--su-table-selected-color` | a tint / `inherit` |
|
|
345
|
+
| `--su-table-sorted-background` | `transparent` (the sorted column's cells and heading) |
|
|
346
|
+
| `--su-table-editable-hover-background` | the text colour at 6% (an editable cell under the pointer) |
|
|
347
|
+
| `--su-table-editing-background` | a tint (the row being edited) |
|
|
348
|
+
|
|
349
|
+
**Reordering**
|
|
350
|
+
|
|
351
|
+
| Variable | Default |
|
|
352
|
+
|----------|---------|
|
|
353
|
+
| `--su-table-handle-color` | `inherit` |
|
|
354
|
+
| `--su-table-grabbed-background` / `--su-table-grabbed-outline` | a tint / `2px solid` blue at 60% |
|
|
355
|
+
| `--su-table-dragging-background` / `--su-table-dragging-shadow` | `Canvas` / `0 8px 24px rgb(0 0 0 / 0.18)` |
|
|
356
|
+
| `--su-table-drop-line-color` / `--su-table-drop-line-width` | `#2563eb` / `2px` (where the dragged row will land) |
|
|
357
|
+
|
|
358
|
+
**Pinned columns and rows**
|
|
359
|
+
|
|
360
|
+
| Variable | Default |
|
|
361
|
+
|----------|---------|
|
|
362
|
+
| `--su-table-pinned-background` | `Canvas` (behind pinned and sticky cells) |
|
|
363
|
+
| `--su-table-pinned-border` / `--su-table-pinned-shadow` | `1px solid rgb(0 0 0 / 0.14)` / `rgb(0 0 0 / 0.22)` |
|
|
364
|
+
| `--su-table-pinned-row-background` / `--su-table-pinned-row-border` | a tint / `2px solid` blue at 40% |
|
|
365
|
+
|
|
366
|
+
**Buttons, inputs and panels**
|
|
367
|
+
|
|
368
|
+
| Variable | Default |
|
|
369
|
+
|----------|---------|
|
|
222
370
|
| `--su-table-button-background` / `--su-table-button-border` / `--su-table-button-color` | `transparent` / `1px solid rgb(0 0 0 / 0.2)` / `inherit` |
|
|
223
371
|
| `--su-table-button-radius` / `--su-table-button-padding` | `6px` / `0.3rem 0.7rem` |
|
|
224
372
|
| `--su-table-primary-background` / `--su-table-primary-color` | `#111` / `#fff` (Save) |
|
|
225
373
|
| `--su-table-danger-color` / `--su-table-danger-border` | `#b42318` / a soft red line |
|
|
226
374
|
| `--su-table-input-background` / `--su-table-input-border` / `--su-table-input-radius` | `transparent` / `1px solid rgb(0 0 0 / 0.25)` / `6px` |
|
|
227
|
-
| `--su-table-panel-background` | a faint
|
|
228
|
-
| `--su-table-
|
|
375
|
+
| `--su-table-panel-background` | a faint grey (selection toolbar and bulk edit) |
|
|
376
|
+
| `--su-table-menu-background` / `--su-table-menu-shadow` | `Canvas` / `0 12px 32px rgb(0 0 0 / 0.18)` (the Columns menu) |
|
|
229
377
|
|
|
230
378
|
## Browser Compatibility
|
|
231
379
|
|