@autobusal/common 1.33.6 → 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/AiAssist/AiReviewModal.tsx +14 -3
- package/CHANGELOG.md +14 -0
- package/Calendar/Calendar.tsx +8 -2
- package/Password/Password.tsx +11 -2
- package/Required/Required.tsx +10 -2
- package/Required/styles.ts +8 -1
- package/Table/Header/Header.tsx +2 -2
- package/Table/Header/styles.ts +13 -2
- package/Table/Table.tsx +11 -2
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
2
|
import { TFunction } from 'i18next';
|
|
3
|
+
import { sanitizeHtml } from '@autobusal/utilities';
|
|
3
4
|
import Modal from '../Modal/Modal';
|
|
4
5
|
import { useAiAvailable, useAiGenerate, useAiTranslate, useAiImprove } from './services';
|
|
5
6
|
import { Row, Field, Compare, Pane, Draft, Actions } from './styles';
|
|
@@ -146,11 +147,21 @@ const AiReviewModal = ({ mode, text, targetLocale, sourceLocale, onInsert, onClo
|
|
|
146
147
|
</Row>
|
|
147
148
|
) }
|
|
148
149
|
|
|
150
|
+
{ /* Edited: Claude - Date: 2026-08-19
|
|
151
|
+
Both panes are sanitized, for two different reasons. The draft is
|
|
152
|
+
whatever a model wrote: a prompt-injected source document can talk
|
|
153
|
+
it into emitting markup, and this preview renders that straight
|
|
154
|
+
into an admin's browser BEFORE anyone has decided to keep it. The
|
|
155
|
+
source is the same admin-authored CMS HTML every other sink in this
|
|
156
|
+
codebase runs through sanitizeHtml (page/Page.tsx, blog, policies).
|
|
157
|
+
Only the preview is sanitized - Insert still hands the caller the
|
|
158
|
+
raw draft, so nothing the admin actually meant to save is silently
|
|
159
|
+
rewritten on its way into the field. */ }
|
|
149
160
|
{ draft === null && mode === 'translate' && (
|
|
150
161
|
<Pane>
|
|
151
162
|
<h4>{ tc('ai_assist.source') }</h4>
|
|
152
163
|
|
|
153
|
-
<div dangerouslySetInnerHTML={ { __html: text
|
|
164
|
+
<div dangerouslySetInnerHTML={ { __html: sanitizeHtml(text) } } />
|
|
154
165
|
</Pane>
|
|
155
166
|
) }
|
|
156
167
|
|
|
@@ -159,13 +170,13 @@ const AiReviewModal = ({ mode, text, targetLocale, sourceLocale, onInsert, onClo
|
|
|
159
170
|
<Pane>
|
|
160
171
|
<h4>{ tc('ai_assist.source') }</h4>
|
|
161
172
|
|
|
162
|
-
<div dangerouslySetInnerHTML={ { __html: text
|
|
173
|
+
<div dangerouslySetInnerHTML={ { __html: sanitizeHtml(text) } } />
|
|
163
174
|
</Pane>
|
|
164
175
|
|
|
165
176
|
<Pane>
|
|
166
177
|
<h4>{ tc('ai_assist.draft') }</h4>
|
|
167
178
|
|
|
168
|
-
<div dangerouslySetInnerHTML={ { __html: draft } } />
|
|
179
|
+
<div dangerouslySetInnerHTML={ { __html: sanitizeHtml(draft) } } />
|
|
169
180
|
</Pane>
|
|
170
181
|
</Compare>
|
|
171
182
|
) }
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
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
|
+
|
|
9
|
+
## 1.33.7
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- **`Required` renders a real `<label>`, and takes an optional `htmlFor`.** It was a `styled.span` sitting beside the field it named, which is a label to a sighted reader and nothing at all to a screen reader - every field it introduced announced as a bare "edit text". Nothing in the stylesheets selects `label` and a flex item computes identically either way, so this is semantics only.
|
|
14
|
+
- **`Password` and `Calendar` take an optional `id`.** A caller cannot associate a visible label with a field it has no way to name, so the shared inputs had to be able to accept one before the forms using them could be fixed.
|
|
15
|
+
- `AiAssist/AiReviewModal` runs its three HTML panes through `sanitizeHtml`. Everything the model returns is HTML rendered into an admin's browser, and every other sink in the codebase sanitises; this one did not.
|
|
16
|
+
|
|
3
17
|
## 1.33.6
|
|
4
18
|
|
|
5
19
|
### Added
|
package/Calendar/Calendar.tsx
CHANGED
|
@@ -15,6 +15,12 @@ interface Props {
|
|
|
15
15
|
on the search form, which is the site's primary conversion path.
|
|
16
16
|
Optional, so existing callers are unaffected. */
|
|
17
17
|
label?: string
|
|
18
|
+
/* Edited: Claude - Date: 2026-08-19: id for the visible input, so a
|
|
19
|
+
caller that HAS a visible label can associate it properly instead of
|
|
20
|
+
duplicating the text into aria-label. Preferred over `label` where
|
|
21
|
+
both are possible - the association also makes the label a click
|
|
22
|
+
target, which opens the picker. */
|
|
23
|
+
id?: string
|
|
18
24
|
defaultValue?: string
|
|
19
25
|
t: TFunction<'general'>
|
|
20
26
|
validation?: string
|
|
@@ -36,7 +42,7 @@ interface Props {
|
|
|
36
42
|
onChange?: (value: string) => void
|
|
37
43
|
}
|
|
38
44
|
|
|
39
|
-
const Calendar = ({ type, name, label, defaultValue, t, validation, minDate, refs, onUpdate, onChange }: Props): JSX.Element => {
|
|
45
|
+
const Calendar = ({ type, name, label, id, defaultValue, t, validation, minDate, refs, onUpdate, onChange }: Props): JSX.Element => {
|
|
40
46
|
const [ show, setShow ] = useState<boolean>(false);
|
|
41
47
|
|
|
42
48
|
/**
|
|
@@ -75,7 +81,7 @@ const Calendar = ({ type, name, label, defaultValue, t, validation, minDate, ref
|
|
|
75
81
|
|
|
76
82
|
return (
|
|
77
83
|
<Container ref={ ref }>
|
|
78
|
-
<input type="text" aria-label={ label } autoComplete="off" readOnly={ true } value={ prepared } onClick={ () => setShow(true) } />
|
|
84
|
+
<input type="text" id={ id } aria-label={ label } autoComplete="off" readOnly={ true } value={ prepared } onClick={ () => setShow(true) } />
|
|
79
85
|
|
|
80
86
|
{ show && (
|
|
81
87
|
<Picker
|
package/Password/Password.tsx
CHANGED
|
@@ -7,6 +7,15 @@ import { Container } from './styles';
|
|
|
7
7
|
|
|
8
8
|
interface Props {
|
|
9
9
|
name: string
|
|
10
|
+
/**
|
|
11
|
+
* Edited: Claude - Date: 2026-08-19
|
|
12
|
+
* The id to put on the inner input, so a caller's <label htmlFor> can
|
|
13
|
+
* reach it. Optional, because the field's own `name` is what the form
|
|
14
|
+
* payload uses and every existing caller relies on that unchanged - but
|
|
15
|
+
* without an id there is no way to attach a label from outside, and this
|
|
16
|
+
* component owns the only input on the login and reset forms.
|
|
17
|
+
*/
|
|
18
|
+
id?: string
|
|
10
19
|
tabIndex?: number
|
|
11
20
|
validation?: string
|
|
12
21
|
// Pre-fill value (masked). Lets an admin form show a saved secret as dots
|
|
@@ -19,7 +28,7 @@ interface Props {
|
|
|
19
28
|
getValues?: UseFormGetValues<any>
|
|
20
29
|
}
|
|
21
30
|
|
|
22
|
-
const Password = ({ name, tabIndex, validation, defaultValue, t, refs, getValues }: Props): JSX.Element => {
|
|
31
|
+
const Password = ({ name, id, tabIndex, validation, defaultValue, t, refs, getValues }: Props): JSX.Element => {
|
|
23
32
|
const [ show, setShow ] = useState<boolean>(false);
|
|
24
33
|
|
|
25
34
|
const toggle = (): void => {
|
|
@@ -28,7 +37,7 @@ const Password = ({ name, tabIndex, validation, defaultValue, t, refs, getValues
|
|
|
28
37
|
|
|
29
38
|
return (
|
|
30
39
|
<Container>
|
|
31
|
-
<input type={ show ? 'text' : 'password' } tabIndex={ tabIndex } defaultValue={ defaultValue } { ...refs(name, Validate(validation ?? '', t, getValues)) } />
|
|
40
|
+
<input type={ show ? 'text' : 'password' } id={ id } tabIndex={ tabIndex } defaultValue={ defaultValue } { ...refs(name, Validate(validation ?? '', t, getValues)) } />
|
|
32
41
|
|
|
33
42
|
{ show
|
|
34
43
|
? <AiFillEye onClick={ toggle } />
|
package/Required/Required.tsx
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import { Label, Marker } from './styles';
|
|
2
2
|
|
|
3
3
|
interface Props {
|
|
4
|
+
/**
|
|
5
|
+
* Edited: Claude - Date: 2026-08-19
|
|
6
|
+
* The id of the field this labels. Optional so existing callers keep
|
|
7
|
+
* working, but pass it wherever there is a field to point at: without it
|
|
8
|
+
* the visible text is only visually a label, and the input announces as
|
|
9
|
+
* a bare "edit text".
|
|
10
|
+
*/
|
|
11
|
+
htmlFor?: string
|
|
4
12
|
children: React.ReactNode
|
|
5
13
|
}
|
|
6
14
|
|
|
@@ -25,8 +33,8 @@ interface Props {
|
|
|
25
33
|
* asterisk two separate flex items - and the marker dropped onto its own
|
|
26
34
|
* line under the label.
|
|
27
35
|
*/
|
|
28
|
-
const Required = ({ children }: Props): JSX.Element => (
|
|
29
|
-
<Label>
|
|
36
|
+
const Required = ({ htmlFor, children }: Props): JSX.Element => (
|
|
37
|
+
<Label htmlFor={ htmlFor }>
|
|
30
38
|
{ children }
|
|
31
39
|
<Marker aria-hidden="true">*</Marker>
|
|
32
40
|
</Label>
|
package/Required/styles.ts
CHANGED
|
@@ -2,7 +2,14 @@ import styled from 'styled-components';
|
|
|
2
2
|
|
|
3
3
|
// keeps the label and its asterisk as ONE flex item - the form rows are
|
|
4
4
|
// column flex containers, so two items would stack vertically
|
|
5
|
-
|
|
5
|
+
//
|
|
6
|
+
// Edited: Claude - Date: 2026-08-19
|
|
7
|
+
// A real <label>, not a <span>. It was already named Label and already
|
|
8
|
+
// sitting next to the field it names, but a span cannot be associated with
|
|
9
|
+
// an input - so the field reached a screen reader unnamed. Nothing in the
|
|
10
|
+
// stylesheets selects `label`, and a flex item computes the same either
|
|
11
|
+
// way, so this changes semantics only.
|
|
12
|
+
export const Label = styled.label`
|
|
6
13
|
display: inline-flex;
|
|
7
14
|
align-items: baseline;
|
|
8
15
|
`;
|
package/Table/Header/Header.tsx
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>
|
package/Table/Header/styles.ts
CHANGED
|
@@ -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 >
|
|
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
|
-
|
|
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 }
|