Skip to content

Commit 951b539

Browse files
committed
refactor: use aria-query for types
1 parent 94a9685 commit 951b539

File tree

3 files changed

+8
-138
lines changed

3 files changed

+8
-138
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
],
4040
"dependencies": {
4141
"@babel/runtime": "^7.10.3",
42+
"@types/aria-query": "^4.2.0",
4243
"aria-query": "^4.2.2",
4344
"dom-accessibility-api": "^0.4.5",
4445
"pretty-format": "^25.5.0"

types/matches.d.ts

Lines changed: 4 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,13 @@
1+
import { ARIARole } from 'aria-query'
2+
13
export type MatcherFunction = (content: string, element: HTMLElement) => boolean
24
export type Matcher = string | RegExp | MatcherFunction
35

46
// important to use String here
57
// this gives us intellisense but it can also accept values
68
// that are not included in the union types
7-
export type ByRoleMatcher = AllowedRoles | String | RegExp | MatcherFunction
8-
export type AllowedRoles =
9-
| 'alert'
10-
| 'alertdialog'
11-
| 'application'
12-
| 'article'
13-
| 'banner'
14-
| 'blockquote'
15-
| 'button'
16-
| 'caption'
17-
| 'cell'
18-
| 'checkbox'
19-
| 'code'
20-
| 'columnheader'
21-
| 'combobox'
22-
| 'complementary'
23-
| 'contentinfo'
24-
| 'definition'
25-
| 'deletion'
26-
| 'dialog'
27-
| 'directory'
28-
| 'document'
29-
| 'emphasis'
30-
| 'feed'
31-
| 'figure'
32-
| 'form'
33-
| 'generic'
34-
| 'grid'
35-
| 'gridcell'
36-
| 'group'
37-
| 'heading'
38-
| 'img'
39-
| 'insertion'
40-
| 'link'
41-
| 'list'
42-
| 'listbox'
43-
| 'listitem'
44-
| 'log'
45-
| 'main'
46-
| 'marquee'
47-
| 'math'
48-
| 'menu'
49-
| 'menubar'
50-
| 'menuitem'
51-
| 'menuitemcheckbox'
52-
| 'menuitemradio'
53-
| 'meter'
54-
| 'navigation'
55-
| 'none'
56-
| 'note'
57-
| 'option'
58-
| 'paragraph'
59-
| 'presentation'
60-
| 'progressbar'
61-
| 'radio'
62-
| 'radiogroup'
63-
| 'region'
64-
| 'row'
65-
| 'rowgroup'
66-
| 'rowheader'
67-
| 'scrollbar'
68-
| 'search'
69-
| 'searchbox'
70-
| 'separator'
71-
| 'slider'
72-
| 'spinbutton'
73-
| 'status'
74-
| 'strong'
75-
| 'subscript'
76-
| 'superscript'
77-
| 'switch'
78-
| 'tab'
79-
| 'table'
80-
| 'tablist'
81-
| 'tabpanel'
82-
| 'term'
83-
| 'textbox'
84-
| 'time'
85-
| 'timer'
86-
| 'toolbar'
87-
| 'tooltip'
88-
| 'tree'
89-
| 'treegrid'
90-
| 'treeitem'
91-
| 'command'
92-
| 'composite'
93-
| 'input'
94-
| 'landmark'
95-
| 'range'
96-
| 'roletype'
97-
| 'section'
98-
| 'sectionhead'
99-
| 'select'
100-
| 'structure'
101-
| 'widget'
102-
| 'window'
103-
| 'doc-abstract'
104-
| 'doc-acknowledgments'
105-
| 'doc-afterword'
106-
| 'doc-appendix'
107-
| 'doc-backlink'
108-
| 'doc-biblioentry'
109-
| 'doc-bibliography'
110-
| 'doc-biblioref'
111-
| 'doc-chapter'
112-
| 'doc-colophon'
113-
| 'doc-conclusion'
114-
| 'doc-cover'
115-
| 'doc-credit'
116-
| 'doc-credits'
117-
| 'doc-dedication'
118-
| 'doc-endnote'
119-
| 'doc-endnotes'
120-
| 'doc-epigraph'
121-
| 'doc-epilogue'
122-
| 'doc-errata'
123-
| 'doc-example'
124-
| 'doc-footnote'
125-
| 'doc-foreword'
126-
| 'doc-glossary'
127-
| 'doc-glossref'
128-
| 'doc-index'
129-
| 'doc-introduction'
130-
| 'doc-noteref'
131-
| 'doc-notice'
132-
| 'doc-pagebreak'
133-
| 'doc-pagelist'
134-
| 'doc-part'
135-
| 'doc-preface'
136-
| 'doc-prologue'
137-
| 'doc-pullquote'
138-
| 'doc-qna'
139-
| 'doc-subtitle'
140-
| 'doc-tip'
141-
| 'doc-toc'
9+
// eslint-disable-next-line ban-types
10+
export type ByRoleMatcher = ARIARole | String | RegExp | MatcherFunction
14211

14312
export type NormalizerFn = (text: string) => string
14413

types/queries.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {Matcher, MatcherOptions, ByRoleMatcher} from './matches'
2-
import {SelectorMatcherOptions} from './query-helpers'
3-
import {waitForOptions} from './wait-for'
1+
import { Matcher, MatcherOptions, ByRoleMatcher } from './matches'
2+
import { SelectorMatcherOptions } from './query-helpers'
3+
import { waitForOptions } from './wait-for'
44

55
export type QueryByBoundAttribute = (
66
container: HTMLElement,

0 commit comments

Comments
 (0)