(props: Props)
| 10 | onContinue: () => void; onLocalAi: () => void; |
| 11 | } |
| 12 | export default function WelcomePanel(props: Props): JSX.Element { |
| 13 | const panelRef = useRef<HTMLElement>(null); |
| 14 | useEffect(() => { |
| 15 | const previous = document.activeElement as HTMLElement | null; |
| 16 | panelRef.current?.querySelector<HTMLButtonElement>('.cbm-primary')?.focus(); |
| 17 | return () => previous?.focus(); |
| 18 | }, []); |
| 19 | return <div className="cbm-welcome-backdrop"> |
| 20 | <section ref={panelRef} className="cbm-welcome" role="dialog" aria-modal="true" aria-labelledby="cbm-welcome-title" |
| 21 | onKeyDown={(event) => { |
| 22 | if (event.key === 'Escape') { event.stopPropagation(); props.onContinue(); } |
| 23 | if (event.key !== 'Tab') return; |
| 24 | const controls = Array.from(event.currentTarget.querySelectorAll<HTMLElement>('button, select')); |
| 25 | const first = controls[0], last = controls[controls.length - 1]; |
| 26 | if (event.shiftKey && document.activeElement === first) { event.preventDefault(); last?.focus(); } |
| 27 | if (!event.shiftKey && document.activeElement === last) { event.preventDefault(); first?.focus(); } |
| 28 | }}> |
| 29 | <p className="cbm-welcome-eyebrow">{s.welcomeEyebrow}</p> |
| 30 | <h2 id="cbm-welcome-title">{s.welcomeTitle}</h2><p>{s.welcomeDescription}</p> |
| 31 | <div className="cbm-welcome-choices" role="group" aria-label={s.navigation}> |
| 32 | {availableWorkspaces(props.experimentalAgents).map((item) => <button type="button" key={item.id} |
| 33 | aria-pressed={props.workspace === item.id} onClick={() => props.onWorkspace(item.id)}> |
| 34 | <strong>{item.label}</strong><span>{s.descriptions[item.id]}</span> |
| 35 | </button>)} |
| 36 | </div> |
| 37 | <p className="cbm-welcome-note">{s.changeLater}</p> |
| 38 | <footer><button type="button" onClick={props.onLocalAi}>{s.localAi}</button> |
| 39 | <button type="button" className="cbm-primary" autoFocus onClick={props.onContinue}>{s.start}</button></footer> |
| 40 | <p className="cbm-welcome-note">{s.aiOptional}</p> |
| 41 | </section> |
| 42 | </div>; |
| 43 | } |
nothing calls this directly
no test coverage detected