@md-plugins/search-ui 0.1.0-rc.18 → 0.1.0-rc.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +95 -100
- package/dist/index.d.ts +95 -100
- package/dist/index.mjs +414 -520
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,133 +1,128 @@
|
|
|
1
1
|
type MaybePromise<T> = T | Promise<T>;
|
|
2
2
|
type SearchRecordType = 'page' | 'heading' | 'content';
|
|
3
3
|
interface SearchRecordSource {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
file: string;
|
|
5
|
+
relativeFile: string;
|
|
6
6
|
}
|
|
7
7
|
interface SearchRecord {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
id: string;
|
|
9
|
+
type: SearchRecordType;
|
|
10
|
+
title: string;
|
|
11
|
+
content: string;
|
|
12
|
+
url: string;
|
|
13
|
+
path: string;
|
|
14
|
+
anchor?: string;
|
|
15
|
+
section?: string;
|
|
16
|
+
hierarchy: string[];
|
|
17
|
+
tags: string[];
|
|
18
|
+
source: SearchRecordSource;
|
|
19
|
+
meta?: Record<string, unknown>;
|
|
20
20
|
}
|
|
21
21
|
interface SearchIndex {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
generatedAt: string;
|
|
23
|
+
recordCount: number;
|
|
24
|
+
records: SearchRecord[];
|
|
25
25
|
}
|
|
26
26
|
interface SearchResult {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
url: string;
|
|
30
|
+
content: string;
|
|
31
|
+
score: number;
|
|
32
|
+
type: SearchRecordType;
|
|
33
|
+
path: string;
|
|
34
|
+
section?: string;
|
|
35
|
+
hierarchy: string[];
|
|
36
|
+
tags: string[];
|
|
37
|
+
record: SearchRecord;
|
|
38
38
|
}
|
|
39
39
|
interface SearchOptions {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
limit?: number;
|
|
41
|
+
collapseDuplicateResults?: boolean;
|
|
42
42
|
}
|
|
43
43
|
interface SearchProvider {
|
|
44
|
-
|
|
44
|
+
search: (query: string, options?: SearchOptions) => MaybePromise<SearchResult[]>;
|
|
45
45
|
}
|
|
46
46
|
interface JsonSearchProviderOptions {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
src?: string;
|
|
48
|
+
index?: SearchIndex | SearchRecord[];
|
|
49
|
+
fetcher?: typeof fetch;
|
|
50
50
|
}
|
|
51
51
|
interface MdSearchSelectEventDetail {
|
|
52
|
-
|
|
52
|
+
result: SearchResult;
|
|
53
53
|
}
|
|
54
54
|
interface CreateSearchOptions {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
target: Element;
|
|
56
|
+
src?: string;
|
|
57
|
+
provider?: SearchProvider;
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
triggerLabel?: string;
|
|
60
|
+
panelTitle?: string;
|
|
61
|
+
searchLabel?: string;
|
|
62
|
+
theme?: 'light' | 'dark';
|
|
63
|
+
shortcut?: string;
|
|
64
|
+
minQueryLength?: number;
|
|
65
|
+
maxResults?: number;
|
|
66
|
+
showDuplicateResults?: boolean;
|
|
67
67
|
}
|
|
68
|
-
|
|
69
68
|
declare const HTMLElementBase: {
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
new (): HTMLElement;
|
|
70
|
+
prototype: HTMLElement;
|
|
72
71
|
};
|
|
73
72
|
declare class MdSearchElement extends HTMLElementBase {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
73
|
+
static observedAttributes: string[];
|
|
74
|
+
provider?: SearchProvider;
|
|
75
|
+
private readonly root;
|
|
76
|
+
private readonly elementId;
|
|
77
|
+
private results;
|
|
78
|
+
private query;
|
|
79
|
+
private opened;
|
|
80
|
+
private loading;
|
|
81
|
+
private errorMessage;
|
|
82
|
+
private activeIndex;
|
|
83
|
+
private searchTimer;
|
|
84
|
+
private searchRequestId;
|
|
85
|
+
private selectionStart;
|
|
86
|
+
private selectionEnd;
|
|
87
|
+
connectedCallback(): void;
|
|
88
|
+
disconnectedCallback(): void;
|
|
89
|
+
attributeChangedCallback(name: string): void;
|
|
90
|
+
open(): void;
|
|
91
|
+
close(): void;
|
|
92
|
+
toggle(): void;
|
|
93
|
+
private get src();
|
|
94
|
+
private get placeholder();
|
|
95
|
+
private get triggerLabel();
|
|
96
|
+
private get panelTitle();
|
|
97
|
+
private get searchLabel();
|
|
98
|
+
private get shortcut();
|
|
99
|
+
private get minQueryLength();
|
|
100
|
+
private get maxResults();
|
|
101
|
+
private get showDuplicateResults();
|
|
102
|
+
private get activeResult();
|
|
103
|
+
private getProvider;
|
|
104
|
+
private readonly onGlobalKeydown;
|
|
105
|
+
private readonly onInput;
|
|
106
|
+
private readonly onDialogKeydown;
|
|
107
|
+
private runSearch;
|
|
108
|
+
private focusInput;
|
|
109
|
+
private setActiveIndex;
|
|
110
|
+
private syncInputAria;
|
|
111
|
+
private syncActiveResult;
|
|
112
|
+
private selectResult;
|
|
113
|
+
private bindResultEvents;
|
|
114
|
+
private renderResultsContainer;
|
|
115
|
+
private renderResults;
|
|
116
|
+
private render;
|
|
117
|
+
private bindEvents;
|
|
119
118
|
}
|
|
120
119
|
declare function defineMdSearchElement(name?: string): void;
|
|
121
120
|
declare function createSearch(options: CreateSearchOptions): MdSearchElement;
|
|
122
|
-
|
|
123
121
|
declare function searchRecords(records: SearchRecord[], query: string, options?: SearchOptions): SearchResult[];
|
|
124
122
|
declare function createStaticSearchProvider(records: SearchRecord[]): SearchProvider;
|
|
125
123
|
declare function createJsonSearchProvider(options?: JsonSearchProviderOptions): SearchProvider;
|
|
126
|
-
|
|
127
124
|
declare function normalizeSearchQuery(value: string): string;
|
|
128
125
|
declare function createSearchTerms(query: string): string[];
|
|
129
126
|
declare function normalizeSearchableText(value: unknown): string;
|
|
130
127
|
declare function createSearchSnippet(content: string, terms: string[], length?: number): string;
|
|
131
|
-
|
|
132
|
-
export { MdSearchElement, createJsonSearchProvider, createSearch, createSearchSnippet, createSearchTerms, createStaticSearchProvider, defineMdSearchElement, normalizeSearchQuery, normalizeSearchableText, searchRecords };
|
|
133
|
-
export type { CreateSearchOptions, JsonSearchProviderOptions, MaybePromise, MdSearchSelectEventDetail, SearchIndex, SearchOptions, SearchProvider, SearchRecord, SearchRecordSource, SearchRecordType, SearchResult };
|
|
128
|
+
export { type CreateSearchOptions, type JsonSearchProviderOptions, type MaybePromise, MdSearchElement, type MdSearchSelectEventDetail, type SearchIndex, type SearchOptions, type SearchProvider, type SearchRecord, type SearchRecordSource, type SearchRecordType, type SearchResult, createJsonSearchProvider, createSearch, createSearchSnippet, createSearchTerms, createStaticSearchProvider, defineMdSearchElement, normalizeSearchQuery, normalizeSearchableText, searchRecords };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,133 +1,128 @@
|
|
|
1
1
|
type MaybePromise<T> = T | Promise<T>;
|
|
2
2
|
type SearchRecordType = 'page' | 'heading' | 'content';
|
|
3
3
|
interface SearchRecordSource {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
file: string;
|
|
5
|
+
relativeFile: string;
|
|
6
6
|
}
|
|
7
7
|
interface SearchRecord {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
8
|
+
id: string;
|
|
9
|
+
type: SearchRecordType;
|
|
10
|
+
title: string;
|
|
11
|
+
content: string;
|
|
12
|
+
url: string;
|
|
13
|
+
path: string;
|
|
14
|
+
anchor?: string;
|
|
15
|
+
section?: string;
|
|
16
|
+
hierarchy: string[];
|
|
17
|
+
tags: string[];
|
|
18
|
+
source: SearchRecordSource;
|
|
19
|
+
meta?: Record<string, unknown>;
|
|
20
20
|
}
|
|
21
21
|
interface SearchIndex {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
generatedAt: string;
|
|
23
|
+
recordCount: number;
|
|
24
|
+
records: SearchRecord[];
|
|
25
25
|
}
|
|
26
26
|
interface SearchResult {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
27
|
+
id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
url: string;
|
|
30
|
+
content: string;
|
|
31
|
+
score: number;
|
|
32
|
+
type: SearchRecordType;
|
|
33
|
+
path: string;
|
|
34
|
+
section?: string;
|
|
35
|
+
hierarchy: string[];
|
|
36
|
+
tags: string[];
|
|
37
|
+
record: SearchRecord;
|
|
38
38
|
}
|
|
39
39
|
interface SearchOptions {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
limit?: number;
|
|
41
|
+
collapseDuplicateResults?: boolean;
|
|
42
42
|
}
|
|
43
43
|
interface SearchProvider {
|
|
44
|
-
|
|
44
|
+
search: (query: string, options?: SearchOptions) => MaybePromise<SearchResult[]>;
|
|
45
45
|
}
|
|
46
46
|
interface JsonSearchProviderOptions {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
src?: string;
|
|
48
|
+
index?: SearchIndex | SearchRecord[];
|
|
49
|
+
fetcher?: typeof fetch;
|
|
50
50
|
}
|
|
51
51
|
interface MdSearchSelectEventDetail {
|
|
52
|
-
|
|
52
|
+
result: SearchResult;
|
|
53
53
|
}
|
|
54
54
|
interface CreateSearchOptions {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
target: Element;
|
|
56
|
+
src?: string;
|
|
57
|
+
provider?: SearchProvider;
|
|
58
|
+
placeholder?: string;
|
|
59
|
+
triggerLabel?: string;
|
|
60
|
+
panelTitle?: string;
|
|
61
|
+
searchLabel?: string;
|
|
62
|
+
theme?: 'light' | 'dark';
|
|
63
|
+
shortcut?: string;
|
|
64
|
+
minQueryLength?: number;
|
|
65
|
+
maxResults?: number;
|
|
66
|
+
showDuplicateResults?: boolean;
|
|
67
67
|
}
|
|
68
|
-
|
|
69
68
|
declare const HTMLElementBase: {
|
|
70
|
-
|
|
71
|
-
|
|
69
|
+
new (): HTMLElement;
|
|
70
|
+
prototype: HTMLElement;
|
|
72
71
|
};
|
|
73
72
|
declare class MdSearchElement extends HTMLElementBase {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
73
|
+
static observedAttributes: string[];
|
|
74
|
+
provider?: SearchProvider;
|
|
75
|
+
private readonly root;
|
|
76
|
+
private readonly elementId;
|
|
77
|
+
private results;
|
|
78
|
+
private query;
|
|
79
|
+
private opened;
|
|
80
|
+
private loading;
|
|
81
|
+
private errorMessage;
|
|
82
|
+
private activeIndex;
|
|
83
|
+
private searchTimer;
|
|
84
|
+
private searchRequestId;
|
|
85
|
+
private selectionStart;
|
|
86
|
+
private selectionEnd;
|
|
87
|
+
connectedCallback(): void;
|
|
88
|
+
disconnectedCallback(): void;
|
|
89
|
+
attributeChangedCallback(name: string): void;
|
|
90
|
+
open(): void;
|
|
91
|
+
close(): void;
|
|
92
|
+
toggle(): void;
|
|
93
|
+
private get src();
|
|
94
|
+
private get placeholder();
|
|
95
|
+
private get triggerLabel();
|
|
96
|
+
private get panelTitle();
|
|
97
|
+
private get searchLabel();
|
|
98
|
+
private get shortcut();
|
|
99
|
+
private get minQueryLength();
|
|
100
|
+
private get maxResults();
|
|
101
|
+
private get showDuplicateResults();
|
|
102
|
+
private get activeResult();
|
|
103
|
+
private getProvider;
|
|
104
|
+
private readonly onGlobalKeydown;
|
|
105
|
+
private readonly onInput;
|
|
106
|
+
private readonly onDialogKeydown;
|
|
107
|
+
private runSearch;
|
|
108
|
+
private focusInput;
|
|
109
|
+
private setActiveIndex;
|
|
110
|
+
private syncInputAria;
|
|
111
|
+
private syncActiveResult;
|
|
112
|
+
private selectResult;
|
|
113
|
+
private bindResultEvents;
|
|
114
|
+
private renderResultsContainer;
|
|
115
|
+
private renderResults;
|
|
116
|
+
private render;
|
|
117
|
+
private bindEvents;
|
|
119
118
|
}
|
|
120
119
|
declare function defineMdSearchElement(name?: string): void;
|
|
121
120
|
declare function createSearch(options: CreateSearchOptions): MdSearchElement;
|
|
122
|
-
|
|
123
121
|
declare function searchRecords(records: SearchRecord[], query: string, options?: SearchOptions): SearchResult[];
|
|
124
122
|
declare function createStaticSearchProvider(records: SearchRecord[]): SearchProvider;
|
|
125
123
|
declare function createJsonSearchProvider(options?: JsonSearchProviderOptions): SearchProvider;
|
|
126
|
-
|
|
127
124
|
declare function normalizeSearchQuery(value: string): string;
|
|
128
125
|
declare function createSearchTerms(query: string): string[];
|
|
129
126
|
declare function normalizeSearchableText(value: unknown): string;
|
|
130
127
|
declare function createSearchSnippet(content: string, terms: string[], length?: number): string;
|
|
131
|
-
|
|
132
|
-
export { MdSearchElement, createJsonSearchProvider, createSearch, createSearchSnippet, createSearchTerms, createStaticSearchProvider, defineMdSearchElement, normalizeSearchQuery, normalizeSearchableText, searchRecords };
|
|
133
|
-
export type { CreateSearchOptions, JsonSearchProviderOptions, MaybePromise, MdSearchSelectEventDetail, SearchIndex, SearchOptions, SearchProvider, SearchRecord, SearchRecordSource, SearchRecordType, SearchResult };
|
|
128
|
+
export { type CreateSearchOptions, type JsonSearchProviderOptions, type MaybePromise, MdSearchElement, type MdSearchSelectEventDetail, type SearchIndex, type SearchOptions, type SearchProvider, type SearchRecord, type SearchRecordSource, type SearchRecordType, type SearchResult, createJsonSearchProvider, createSearch, createSearchSnippet, createSearchTerms, createStaticSearchProvider, defineMdSearchElement, normalizeSearchQuery, normalizeSearchableText, searchRecords };
|