@@ -98,3 +98,83 @@ type ARIAPropertyToAttribute<K extends string> =
9898 K extends `aria${infer Suffix } Element${infer OptS } ` ?
9999 `aria-${Lowercase < Suffix > } ` :
100100 K extends `aria${infer Suffix } ` ? `aria-${Lowercase < Suffix > } ` : K ;
101+
102+ /**
103+ * An extension of `ARIAMixin` that enforces strict value types for aria
104+ * properties.
105+ *
106+ * This is needed for correct typing in render functions with lit analyzer.
107+ *
108+ * @example
109+ * render() {
110+ * const {ariaLabel} = this as ARIAMixinStrict;
111+ * return html`
112+ * <button aria-label=${ariaLabel || nothing}>
113+ * <slot></slot>
114+ * </button>
115+ * `;
116+ * }
117+ */
118+ export interface ARIAMixinStrict extends ARIAMixin {
119+ ariaAtomic : 'true' | 'false' | null ;
120+ ariaAutoComplete : 'none' | 'inline' | 'list' | 'both' | null ;
121+ ariaBusy : 'true' | 'false' | null ;
122+ ariaChecked : 'true' | 'false' | null ;
123+ ariaColCount : `${number } `| null ;
124+ ariaColIndex : `${number } `| null ;
125+ ariaColSpan : `${number } `| null ;
126+ ariaCurrent : 'page' | 'step' | 'location' | 'date' | 'time' | 'true' | 'false' | null ;
127+ ariaDisabled : 'true' | 'false' | null ;
128+ ariaExpanded : 'true' | 'false' | null ;
129+ ariaHasPopup : 'false' | 'true' | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog' | null ;
130+ ariaHidden : 'true' | 'false' | null ;
131+ ariaInvalid : 'true' | 'false' | null ;
132+ ariaKeyShortcuts : string | null ;
133+ ariaLabel : string | null ;
134+ ariaLevel : `${number } `| null ;
135+ ariaLive : 'assertive' | 'off' | 'polite' | null ;
136+ ariaModal : 'true' | 'false' | null ;
137+ ariaMultiLine : 'true' | 'false' | null ;
138+ ariaMultiSelectable : 'true' | 'false' | null ;
139+ ariaOrientation : 'horizontal' | 'vertical' | 'undefined' | null ;
140+ ariaPlaceholder : string | null ;
141+ ariaPosInSet : `${number } `| null ;
142+ ariaPressed : 'true' | 'false' | null ;
143+ ariaReadOnly : 'true' | 'false' | null ;
144+ ariaRequired : 'true' | 'false' | null ;
145+ ariaRoleDescription : string | null ;
146+ ariaRowCount : `${number } `| null ;
147+ ariaRowIndex : `${number } `| null ;
148+ ariaRowSpan : `${number } `| null ;
149+ ariaSelected : 'true' | 'false' | null ;
150+ ariaSetSize : `${number } `| null ;
151+ ariaSort : 'ascending' | 'descending' | 'none' | 'other' | null ;
152+ ariaValueMax : `${number } `| null ;
153+ ariaValueMin : `${number } `| null ;
154+ ariaValueNow : `${number } `| null ;
155+ ariaValueText : string | null ;
156+ role : ARIARole | null ;
157+ }
158+
159+ /**
160+ * Valid values for `role`.
161+ */
162+ export type ARIARole =
163+ 'alert' | 'alertdialog' | 'button' | 'checkbox' | 'dialog' | 'gridcell' | 'link' | 'log' |
164+ 'marquee' | 'menuitem' | 'menuitemcheckbox' | 'menuitemradio' | 'option' |
165+ 'progressbar' | 'radio' | 'scrollbar' | 'searchbox' | 'slider' | 'spinbutton' |
166+ 'status' | 'switch' | 'tab' | 'tabpanel' | 'textbox' | 'timer' | 'tooltip' | 'treeitem' |
167+ 'combobox' | 'grid' | 'listbox' | 'menu' | 'menubar' | 'radiogroup' | 'tablist' | 'tree' |
168+ 'treegrid' | 'application' | 'article' | 'cell' | 'columnheader' | 'definition' |
169+ 'directory' | 'document' | 'feed' | 'figure' | 'group' | 'heading' | 'img' | 'list' |
170+ 'listitem' | 'math' | 'none' | 'note' | 'presentation' | 'region' | 'row' | 'rowgroup' |
171+ 'rowheader' | 'separator' | 'table' | 'term' | 'text' | 'toolbar' | 'banner' |
172+ 'complementary' | 'contentinfo' | 'form' | 'main' | 'navigation' | 'region' | 'search' |
173+ 'doc-abstract' | 'doc-acknowledgments' | 'doc-afterword' | 'doc-appendix' |
174+ 'doc-backlink' | 'doc-biblioentry' | 'doc-bibliography' | 'doc-biblioref' |
175+ 'doc-chapter' | 'doc-colophon' | 'doc-conclusion' | 'doc-cover' | 'doc-credit' |
176+ 'doc-credits' | 'doc-dedication' | 'doc-endnote' | 'doc-endnotes' | 'doc-epigraph' |
177+ 'doc-epilogue' | 'doc-errata' | 'doc-example' | 'doc-footnote' | 'doc-foreword' |
178+ 'doc-glossary' | 'doc-glossref' | 'doc-index' | 'doc-introduction' | 'doc-noteref' |
179+ 'doc-notice' | 'doc-pagebreak' | 'doc-pagelist' | 'doc-part' | 'doc-preface' |
180+ 'doc-prologue' | 'doc-pullquote' | 'doc-qna' | 'doc-subtitle' | 'doc-tip' | 'doc-toc' ;
0 commit comments