Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: suggestions for which query to use #586

Merged
merged 34 commits into from May 29, 2020
Merged
Changes from 2 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
0cf9fd9
feat: suggestions for which query to use
May 25, 2020
7cb52ba
coverage bumped
May 25, 2020
e0b7f69
Merge branch 'master' into feature/suggestions
benmonro May 25, 2020
75c492c
more tests, label text working
May 25, 2020
51c377c
more cases for labelText
May 25, 2020
be480ad
removed commented out code
May 25, 2020
63b26cb
added *ByDisplayValue
May 25, 2020
a0dc8f9
all queries supported now
May 26, 2020
5ee9649
cleanup
May 26, 2020
625ce15
added types for suggestions
May 26, 2020
1db13e6
export suggestions from index
May 26, 2020
30e64e2
fixed a couple lint warnings
May 26, 2020
e3bdcff
Update src/__tests__/suggestions.js
benmonro May 29, 2020
a9394b0
Update src/config.js
benmonro May 29, 2020
b496f09
Update src/__tests__/suggestions.js
benmonro May 29, 2020
32883e7
Update src/config.js
benmonro May 29, 2020
7354bc7
Update src/suggestions.js
benmonro May 29, 2020
effdd92
Update src/query-helpers.js
benmonro May 29, 2020
0d5c6e4
PR feedback
May 29, 2020
7ec23c2
refactor to getLabelFor
May 29, 2020
515bee0
Merge branch 'feature/suggestions' of https://github.com/benmonro/dom…
benmonro May 29, 2020
cf78610
formatting
benmonro May 29, 2020
042bd93
added support for suggest:false
benmonro May 29, 2020
e536d05
case ignored regex
benmonro May 29, 2020
8fb28da
using full query name for get & getAll & query
benmonro May 29, 2020
18b1813
suggest on labeltext
benmonro May 29, 2020
2a741e9
suggest on queryAllBy
benmonro May 29, 2020
ac9e9df
more tests
benmonro May 29, 2020
53460df
rename showSuggs to throwSuggs
benmonro May 29, 2020
fa69912
PR feedback
benmonro May 29, 2020
8861c24
Merge branch 'master' into feature/suggestions
benmonro May 29, 2020
7ec0b97
matches.d.ts
benmonro May 29, 2020
51618bd
Merge branch 'feature/suggestions' of https://github.com/benmonro/dom…
benmonro May 29, 2020
9cec773
Update types/matches.d.ts
benmonro May 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
38 changes: 21 additions & 17 deletions types/matches.d.ts
@@ -1,29 +1,33 @@
export type MatcherFunction = (content: string, element: HTMLElement) => boolean;
export type Matcher = string | RegExp | MatcherFunction;
export type MatcherFunction = (content: string, element: HTMLElement) => boolean
export type Matcher = string | RegExp | MatcherFunction

export type NormalizerFn = (text: string) => string;
export type NormalizerFn = (text: string) => string

export interface MatcherOptions {
exact?: boolean;
/** Use normalizer with getDefaultNormalizer instead */
trim?: boolean;
/** Use normalizer with getDefaultNormalizer instead */
collapseWhitespace?: boolean;
normalizer?: NormalizerFn;
exact?: boolean
/** Use normalizer with getDefaultNormalizer instead */
trim?: boolean
/** Use normalizer with getDefaultNormalizer instead */
collapseWhitespace?: boolean
normalizer?: NormalizerFn
/** set query suppress suggestions */
benmonro marked this conversation as resolved.
Show resolved Hide resolved
suggest?: boolean
}

export type Match = (
textToMatch: string,
node: HTMLElement | null,
matcher: Matcher,
options?: MatcherOptions,
) => boolean;
textToMatch: string,
node: HTMLElement | null,
matcher: Matcher,
options?: MatcherOptions,
) => boolean

export interface DefaultNormalizerOptions {
trim?: boolean;
collapseWhitespace?: boolean;
trim?: boolean
collapseWhitespace?: boolean
}

export function getDefaultNormalizer(options?: DefaultNormalizerOptions): NormalizerFn;
export function getDefaultNormalizer(
options?: DefaultNormalizerOptions,
): NormalizerFn

// N.B. Don't expose fuzzyMatches + matches here: they're not public API