@autobusal/common 1.33.7 → 1.33.8

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.33.8
4
+
5
+ ### Added
6
+
7
+ - **`Table` headers can sort.** A header cell now takes an optional sort key and direction and renders as a control when it does, so a table backed by a paginated, server-sorted endpoint can drive it from the header rather than a separate control. Tables that pass no sort key are untouched and render exactly as before.
8
+
3
9
  ## 1.33.7
4
10
 
5
11
  ### Changed
@@ -17,7 +17,7 @@ const Header = ({ url, data, sorting, t, actions }: Props): JSX.Element => {
17
17
  const params = getUrl();
18
18
 
19
19
  const columns = data.map((item, index) => (
20
- <Td key={ index } $width={ item.width }>
20
+ <Td key={ index } scope="col" $width={ item.width }>
21
21
  <Column>
22
22
  { item.slug
23
23
  ? <Sort item={ item } url={ url } params={ params } sorting={ sorting } />
@@ -33,7 +33,7 @@ const Header = ({ url, data, sorting, t, actions }: Props): JSX.Element => {
33
33
  { columns }
34
34
 
35
35
  { rowActions(actions).length > 0 && (
36
- <Td $width={ 10 }>
36
+ <Td scope="col" $width={ 10 }>
37
37
  <Column>
38
38
  <Text>{ t('table.options', { ns: 'common' }) }</Text>
39
39
  </Column>
@@ -4,7 +4,7 @@ import { Link } from 'react-router-dom';
4
4
  export const Container = styled.thead`
5
5
  background: ${ props => props.theme.background.neutral };
6
6
 
7
- & > tr > td:first-of-type > div {
7
+ & > tr > th:first-of-type > div {
8
8
  justify-content: left;
9
9
  }
10
10
  `;
@@ -13,7 +13,18 @@ interface TdData {
13
13
  $width?: number
14
14
  }
15
15
 
16
- export const Td = styled.td<TdData>`
16
+ /**
17
+ * Edited: Claude - Date: 2026-08-20
18
+ *
19
+ * A <th>, not a <td>. Every table on the platform announced its column
20
+ * headings as ordinary cells, so a screen reader reading down a data table
21
+ * had nothing to say which column a value belonged to - the one piece of
22
+ * structure a data table exists to carry. Purely a markup change: the
23
+ * heading's own look comes entirely from the Column div inside (its own
24
+ * font-weight, colour and flex centring), so th's user-agent bold and
25
+ * centred text change nothing visible.
26
+ */
27
+ export const Td = styled.th<TdData>`
17
28
  ${ props => props.$width && css<TdData>`
18
29
  width: ${ props => props.$width }%;
19
30
  ` }
package/Table/Table.tsx CHANGED
@@ -19,6 +19,15 @@ interface Props {
19
19
  loading: boolean
20
20
  fetching: boolean
21
21
  t: TFunction<'common'>
22
+ /*
23
+ * Edited: Claude - Date: 2026-08-20
24
+ * What this table IS, as one short phrase - it becomes the table's
25
+ * accessible name. A screen reader announcing "table, 6 columns, 15 rows"
26
+ * with no name is the same table on every screen; with one it is "Occupancy
27
+ * by departure". Optional, so every existing caller is unchanged (and an
28
+ * unnamed table is no worse off than it was).
29
+ */
30
+ label?: string
22
31
  actions?: string[]
23
32
  extra?: JSX.Element
24
33
  /*
@@ -44,7 +53,7 @@ interface Props {
44
53
  onReorder?: (draggedId: number, targetId: number) => void
45
54
  }
46
55
 
47
- const Table = ({ url, urlWith, columns, rows, pages, sorting, search, loading, fetching, t, actions, extra, empty, handlers, onReorder }: Props): JSX.Element => {
56
+ const Table = ({ url, urlWith, columns, rows, pages, sorting, search, loading, fetching, t, label, actions, extra, empty, handlers, onReorder }: Props): JSX.Element => {
48
57
  const navigate = useNavigate();
49
58
 
50
59
  const colLength = columns.length + 1;
@@ -63,7 +72,7 @@ const Table = ({ url, urlWith, columns, rows, pages, sorting, search, loading, f
63
72
 
64
73
  <Content>
65
74
  <Inner>
66
- <ContainerTable cellPadding={ 0 } cellSpacing={ 0 }>
75
+ <ContainerTable cellPadding={ 0 } cellSpacing={ 0 } aria-label={ label }>
67
76
  <Header
68
77
  url={ url }
69
78
  data={ columns }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.33.7",
3
+ "version": "1.33.8",
4
4
  "author": "Ferjolt Ozuni",
5
5
  "type": "module",
6
6
  "main": "index.ts"