You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/table/README.md
+18-16Lines changed: 18 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,7 +44,15 @@ import {
44
44
} from'@spectrum-web-components/table';
45
45
```
46
46
47
-
## Example
47
+
### Anatomy
48
+
49
+
A table consists of the following parts:
50
+
51
+
- a table head section (`<sp-table-head>`)
52
+
- header cells (`<sp-table-head-cell>`) within the table head section
53
+
- a table body section, ie.`<sp-table-body>`
54
+
- rows (`<sp-table-row>`) within the table body section
55
+
- body cells (`<sp-table-cell>`) within the table body rows
48
56
49
57
```html demo
50
58
<sp-table>
@@ -340,7 +348,7 @@ The `quiet` attribute creates a more subtle table appearance with a transparent
340
348
</sp-tab-panel>
341
349
</sp-tabs>
342
350
343
-
##Virtualized tables
351
+
### Behaviors
344
352
345
353
For large amounts of data, the `<sp-table>` can be virtualised to easily add table rows by using properties.
346
354
@@ -427,7 +435,7 @@ For large amounts of data, the `<sp-table>` can be virtualised to easily add tab
427
435
});
428
436
</script>
429
437
430
-
### How to use it
438
+
#### How to use it
431
439
432
440
The virtualised table takes `items` as either a property or a JSON-encoded string, an array of type `Record`, where the key is a `string` and the value can be whatever you'd like. `items` is then fed into the `renderItem` method, which takes an `item` and its `index` as parameters and renders the `<sp-table-row>` for each item. An example is as follows:
Please note that there is a bug when attempting to select all virtualised elements. The items are selected programatically, it's just not reflected visually.
464
472
465
-
### Virtualized table selection
473
+
#### Virtualized table selection
466
474
467
475
By default the `selected` property will surface an array of item indexes that are currently selected. However, when making a selection on a virtualized table, it can be useful to track selection as something other than indexes. Todo so, set a custom method for the `itemValue`property. The`itemValue` method accepts an item and its index as arguments and should return the value you would like to track in the `selected` property.
468
476
@@ -564,7 +572,7 @@ By default the `selected` property will surface an array of item indexes that ar
564
572
});
565
573
</script>
566
574
567
-
### Row Types
575
+
#### Row Types
568
576
569
577
All values in the item array are assumed to be homogenous by default. This means all of the rendered rows are either delivered as provided, or, in the case you are leveraging `selects`, rendered with an `<sp-table-checkbox-cell>`. However, when virtualizing a table with selection, it can sometimes be useful to surface rows with additional interactions, e.g. "Load more data"links. To support that, you can optionally include the `_$rowType$` brand in your item. The values forthis are outlined by the `RowType`enum and include `ITEM` (0) and `INFORMATION` (1). When`_$rowType$: RowType.INFORMATION` is provided, it instructs the `<sp-table>` not to deliver an `<sp-table-checkbox-cell>`in that row.
570
578
@@ -670,7 +678,7 @@ All values in the item array are assumed to be homogenous by default. This means
670
678
});
671
679
</script>
672
680
673
-
### The `scroller` property
681
+
#### The `scroller` property
674
682
675
683
By default, the virtualized table doesn't contain a scroll bar and will display the entire length of the table body. Use the `scroller` property and specify an inline style for the height to get a `Table` of your desired height that scrolls.
676
684
@@ -796,11 +804,11 @@ For each table column you want to sort, use the `sortable` attribute in its resp
796
804
});
797
805
</script>
798
806
799
-
## Accessibility
807
+
### Accessibility
800
808
801
809
The `<sp-table>` component provides accessibility support for tabular data:
802
810
803
-
### ARIA attributes
811
+
####ARIA attributes
804
812
805
813
The table automatically manages ARIA attributes for proper semantic structure:
806
814
@@ -815,17 +823,15 @@ The table automatically manages ARIA attributes for proper semantic structure:
815
823
-`aria-rowindex` on virtualized table rows
816
824
-`aria-rowcount` on virtualized tables
817
825
818
-
### Selection accessibility
826
+
#### Selection accessibility
819
827
820
828
When using row selection:
821
829
822
830
-`aria-selected` is applied to selectable rows
823
831
- Selection state is announced to screen readers
824
832
- Checkboxes in selection cells are properly labeled
825
833
826
-
### Keyboard navigation
827
-
828
-
#### Sortable column headers
834
+
#### Keyboard navigation
829
835
830
836
Sortable column headers support keyboard interaction:
831
837
@@ -834,14 +840,10 @@ Sortable column headers support keyboard interaction:
834
840
-**Numpad Enter**- Immediately sorts the column
835
841
-**Tab**- Navigates to sortable headers (only sortable headers are focusable)
836
842
837
-
#### Row selection
838
-
839
843
Selectable rows support keyboard interaction:
840
844
841
845
-**Click**- Toggles row selection
842
846
-**Tab**- Navigates through focusable elements
843
847
844
-
#### Scrollable tables
845
-
846
848
-**Tab**- Table body automatically receives `tabindex="0"` when content is scrollable
847
849
-**Mouse wheel**- Scrolls through table content when focused
0 commit comments