(props: PoliteProps)
| 7 | } |
| 8 | |
| 9 | export default function Polite(props: PoliteProps) { |
| 10 | const { visible, values } = props; |
| 11 | |
| 12 | if (!visible) { |
| 13 | return null; |
| 14 | } |
| 15 | |
| 16 | // Only cut part of values since it's a screen reader |
| 17 | const MAX_COUNT = 50; |
| 18 | |
| 19 | return ( |
| 20 | <span |
| 21 | aria-live="polite" |
| 22 | style={{ width: 0, height: 0, position: 'absolute', overflow: 'hidden', opacity: 0 }} |
| 23 | > |
| 24 | {/* Merge into one string to make screen reader work as expect */} |
| 25 | {`${values |
| 26 | .slice(0, MAX_COUNT) |
| 27 | .map(({ label, value }) => (['number', 'string'].includes(typeof label) ? label : value)) |
| 28 | .join(', ')}`} |
| 29 | {values.length > MAX_COUNT ? ', ...' : null} |
| 30 | </span> |
| 31 | ); |
| 32 | } |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…