-
Notifications
You must be signed in to change notification settings - Fork 474
/
Copy pathmatches.d.ts
46 lines (37 loc) · 1.25 KB
/
matches.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {ARIARole} from 'aria-query'
export type MatcherFunction = (
content: string,
element: Element | null,
) => boolean
export type Matcher = MatcherFunction | RegExp | number | string
// Get autocomplete for ARIARole union types, while still supporting another string
// Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-567871939
export type ByRoleMatcher = ARIARole | (string & {})
export type NormalizerFn = (text: string) => string
export interface NormalizerOptions extends DefaultNormalizerOptions {
normalizer?: NormalizerFn
}
export interface MatcherOptions {
exact?: boolean
/** Use normalizer with getDefaultNormalizer instead */
trim?: boolean
/** Use normalizer with getDefaultNormalizer instead */
collapseWhitespace?: boolean
normalizer?: NormalizerFn
/** suppress suggestions for a specific query */
suggest?: boolean
}
export type Match = (
textToMatch: string,
node: HTMLElement | null,
matcher: Matcher,
options?: MatcherOptions,
) => boolean
export interface DefaultNormalizerOptions {
trim?: boolean
collapseWhitespace?: boolean
}
export function getDefaultNormalizer(
options?: DefaultNormalizerOptions,
): NormalizerFn
// N.B. Don't expose fuzzyMatches + matches here: they're not public API