Skip to content

Commit

Permalink
FEAT/adding types for the role attribute instead of string (#237)
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Fiorette <[email protected]>
Co-authored-by: Arthur Fiorette <[email protected]>
  • Loading branch information
AugustinSorel and arthurfiorette authored Jun 19, 2024
1 parent d3b8797 commit b42e517
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/slimy-ducks-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@kitajs/html': minor
---

Added `role` attribute types
75 changes: 74 additions & 1 deletion packages/html/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ declare namespace JSX {
hidden?: undefined | string | boolean;
id?: undefined | number | string;
popover?: undefined | boolean | 'auto' | 'manual';
role?: undefined | string;
role?: undefined | AriaRole;
lang?: undefined | string;
draggable?: undefined | string | boolean;
spellcheck?: undefined | string | boolean;
Expand Down Expand Up @@ -852,3 +852,76 @@ declare namespace JSX {
wbr: HtmlTag;
}
}

// All the WAI-ARIA 1.1 role attribute values from https://www.w3.org/TR/wai-aria-1.1/#role_definitions
type AriaRole =
| "alert"
| "alertdialog"
| "application"
| "article"
| "banner"
| "button"
| "cell"
| "checkbox"
| "columnheader"
| "combobox"
| "complementary"
| "contentinfo"
| "definition"
| "dialog"
| "directory"
| "document"
| "feed"
| "figure"
| "form"
| "grid"
| "gridcell"
| "group"
| "heading"
| "img"
| "link"
| "list"
| "listbox"
| "listitem"
| "log"
| "main"
| "marquee"
| "math"
| "menu"
| "menubar"
| "menuitem"
| "menuitemcheckbox"
| "menuitemradio"
| "navigation"
| "none"
| "note"
| "option"
| "presentation"
| "progressbar"
| "radio"
| "radiogroup"
| "region"
| "row"
| "rowgroup"
| "rowheader"
| "scrollbar"
| "search"
| "searchbox"
| "separator"
| "slider"
| "spinbutton"
| "status"
| "switch"
| "tab"
| "table"
| "tablist"
| "tabpanel"
| "term"
| "textbox"
| "timer"
| "toolbar"
| "tooltip"
| "tree"
| "treegrid"
| "treeitem"
| (string & {});

0 comments on commit b42e517

Please sign in to comment.