11 lines
543 B
TypeScript
11 lines
543 B
TypeScript
/** An unavailable control's props. With a reason it stays focusable (`aria-disabled`, which
|
|
* `FocusSafeButton` keeps inert to a click, and the reason read out with its name; the caller shows
|
|
* it in a tooltip — DESIGN.md "Unavailable with a reason stays focusable"); without one it is
|
|
* plainly off. */
|
|
export function unavailable(disabled: boolean | undefined, reason: string | undefined) {
|
|
if (!disabled) return {};
|
|
return reason
|
|
? { "aria-disabled": true as const, "aria-description": reason }
|
|
: { disabled: true };
|
|
}
|