igniteui-astro-components 0.0.27 → 0.0.29
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/README.md +82 -74
- package/package.json +16 -2
- package/src/assets/images/anatomy-test.png +0 -0
- package/src/components/CopyCode/CopyCode.astro +21 -7
- package/src/components/DocsBreadcrumb/DocsBreadcrumb.astro +33 -21
- package/src/components/DocsBreadcrumb/DocsBreadcrumb.scss +44 -43
- package/src/components/DocsBreadcrumb/README.md +10 -14
- package/src/components/DocsSidebar/DocsSidebar.astro +47 -45
- package/src/components/DocsSidebar/DocsSidebar.scss +120 -122
- package/src/components/DocsSidebar/README.md +25 -21
- package/src/components/DocsSidebar/SidebarFilterInput.astro +24 -29
- package/src/components/DocsSidebar/SidebarFilterInput.scss +90 -89
- package/src/components/DocsSidebar/SidebarLabel.astro +35 -26
- package/src/components/DocsSidebar/sidebar-filter.ts +93 -56
- package/src/components/DocsSubHeader/DocsSubHeader.astro +256 -195
- package/src/components/DocsSubHeader/DocsSubHeader.scss +181 -178
- package/src/components/DocsSubHeader/README.md +18 -16
- package/src/components/DocsToc/DocsToc.astro +301 -280
- package/src/components/DocsToc/DocsToc.scss +20 -21
- package/src/components/DocsToc/README.md +11 -9
- package/src/components/DocsToc/toTreeNodes.ts +3 -8
- package/src/components/DocsTree/DocsTree.astro +32 -20
- package/src/components/DocsTree/DocsTreeItem.astro +35 -30
- package/src/components/DocsTree/README.md +16 -15
- package/src/components/DocsTree/docs-tree.scss +267 -268
- package/src/components/GlobalFooter/GlobalFooter.astro +10 -10
- package/src/components/GlobalFooter/README.md +3 -2
- package/src/components/GlobalNavBar/GlobalNavBar.astro +4 -2
- package/src/components/GlobalNavBar/GlobalNavBar.module.scss +222 -222
- package/src/components/GlobalNavBar/README.md +3 -2
- package/src/components/LicenseIndicator/LicenseIndicator.astro +7 -5
- package/src/components/LicenseIndicator/LicenseIndicator.scss +3 -3
- package/src/components/MobileSidebarToggle/MobileSidebarToggle.astro +16 -17
- package/src/components/MobileSidebarToggle/README.md +3 -2
- package/src/components/MobileTocToggle/MobileTocToggle.astro +75 -61
- package/src/components/MobileTocToggle/MobileTocToggle.scss +65 -59
- package/src/components/Search/README.md +1 -0
- package/src/components/Search/Search.astro +137 -109
- package/src/components/Search/Search.scss +20 -20
- package/src/components/SearchAdvanced/README.md +21 -15
- package/src/components/SearchAdvanced/SearchAdvanced.astro +205 -133
- package/src/components/SearchAdvanced/SearchAdvanced.scss +152 -153
- package/src/components/mdx/Anatomy/Anatomy.astro +51 -0
- package/src/components/mdx/Anatomy/Anatomy.scss +40 -0
- package/src/components/mdx/ApiLink/ApiLink.astro +133 -113
- package/src/components/mdx/ApiLink/ApiLink.scss +9 -9
- package/src/components/mdx/ApiLink/README.md +26 -22
- package/src/components/mdx/ApiLink/api-link-index.ts +196 -173
- package/src/components/mdx/ApiRef/ApiRef.astro +54 -51
- package/src/components/mdx/ApiRef/README.md +20 -15
- package/src/components/mdx/Badge/Badge.astro +14 -14
- package/src/components/mdx/Badge/Badge.scss +61 -56
- package/src/components/mdx/Badge/README.md +24 -19
- package/src/components/mdx/DocsAside/DocsAside.astro +30 -37
- package/src/components/mdx/DocsAside/DocsAside.scss +82 -82
- package/src/components/mdx/DocsAside/README.md +22 -22
- package/src/components/mdx/Faq/Faq.astro +86 -0
- package/src/components/mdx/Faq/Faq.scss +105 -0
- package/src/components/mdx/Faq/FaqItem.astro +117 -0
- package/src/components/mdx/Faq/README.md +223 -0
- package/src/components/mdx/Faq/types.ts +34 -0
- package/src/components/mdx/PlatformBlock/PlatformBlock.astro +3 -2
- package/src/components/mdx/PlatformBlock/README.md +6 -8
- package/src/components/mdx/Sample/README.md +21 -16
- package/src/components/mdx/Sample/Sample.astro +97 -74
- package/src/components/mdx/Sample/Sample.scss +132 -132
- package/src/content-helper.ts +71 -72
- package/src/content.config.ts +1 -6
- package/src/integration.ts +566 -512
- package/src/layouts/DocsLayout/DocsLayout.astro +228 -182
- package/src/layouts/DocsLayout/DocsLayout.scss +261 -261
- package/src/layouts/DocsLayout/README.md +24 -35
- package/src/lib/nav-helpers.ts +88 -82
- package/src/lib/types.ts +76 -76
- package/src/llms.ts +205 -166
- package/src/platform.ts +312 -162
- package/src/plugins/rehype-heading-anchors.ts +45 -45
- package/src/plugins/rehype-pagefind-ignore.ts +19 -19
- package/src/plugins/rehype-table-wrapper.ts +30 -30
- package/src/plugins/remark-docfx.ts +12 -0
- package/src/plugins/remark-env-vars.ts +12 -4
- package/src/plugins/remark-md-links.ts +10 -4
- package/src/scripts/icon-manifest.ts +13 -5
- package/src/scripts/sample-widget.ts +557 -501
- package/src/sidebar.ts +103 -97
- package/src/styles/global/_code-blocks.scss +43 -44
- package/src/styles/global/_component-themes.scss +151 -153
- package/src/styles/global/_icon-gallery.scss +81 -81
- package/src/styles/global/_index.scss +0 -1
- package/src/styles/global/_markdown.scss +816 -787
- package/src/styles/global/_palette.scss +456 -110
- package/src/styles/global/_search-shared.scss +402 -398
- package/src/styles/global/_type-scale.scss +127 -127
- package/src/styles/global/_variables.scss +138 -111
- package/src/styles/theme.scss +41 -41
- package/src/virtual-modules.d.ts +11 -2
|
@@ -13,69 +13,79 @@ import './Search.scss';
|
|
|
13
13
|
---
|
|
14
14
|
|
|
15
15
|
<div class="search-decoration">
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
16
|
+
<igc-icon-button
|
|
17
|
+
class="search-trigger-mobile"
|
|
18
|
+
variant="flat"
|
|
19
|
+
aria-label="Search documentation"
|
|
20
|
+
aria-haspopup="dialog"
|
|
21
|
+
aria-controls="search-dialog"
|
|
22
|
+
>
|
|
23
|
+
<igc-icon name="search" collection="docs" aria-hidden="true"></igc-icon>
|
|
24
|
+
</igc-icon-button>
|
|
25
|
+
<igc-input
|
|
26
|
+
id="search-trigger"
|
|
27
|
+
class="search-trigger"
|
|
28
|
+
type="text"
|
|
29
|
+
placeholder="Search"
|
|
30
|
+
readonly
|
|
31
|
+
role="button"
|
|
32
|
+
aria-haspopup="dialog"
|
|
33
|
+
aria-controls="search-dialog"
|
|
34
|
+
aria-label="Search documentation"
|
|
35
|
+
title="Search (Ctrl+K)"
|
|
36
|
+
>
|
|
37
|
+
<igc-icon name="search" collection="docs" slot="prefix" aria-hidden="true"></igc-icon>
|
|
38
|
+
<kbd class="search-trigger__hint" slot="suffix" style="display:none;"
|
|
39
|
+
><kbd>Ctrl</kbd><kbd>K</kbd></kbd
|
|
36
40
|
>
|
|
37
|
-
|
|
38
|
-
<kbd class="search-trigger__hint" slot="suffix" style="display:none;"><kbd>Ctrl</kbd><kbd>K</kbd></kbd>
|
|
39
|
-
</igc-input>
|
|
41
|
+
</igc-input>
|
|
40
42
|
</div>
|
|
41
43
|
|
|
42
|
-
<igc-dialog
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
44
|
+
<igc-dialog
|
|
45
|
+
id="search-dialog"
|
|
46
|
+
class="igd-search-dialog"
|
|
47
|
+
aria-label="Search"
|
|
48
|
+
hide-default-action
|
|
49
|
+
close-on-outside-click
|
|
50
|
+
>
|
|
51
|
+
<div class="igd-search-shell">
|
|
52
|
+
<header class="igd-search-header">
|
|
53
|
+
<igc-input
|
|
54
|
+
type="text"
|
|
55
|
+
class="igd-search-input"
|
|
56
|
+
placeholder="Search documentation"
|
|
57
|
+
autocomplete="off"
|
|
58
|
+
outlined
|
|
59
|
+
aria-label="Search documentation"
|
|
60
|
+
>
|
|
61
|
+
<igc-icon
|
|
62
|
+
class="igd-search-icon"
|
|
63
|
+
name="search"
|
|
64
|
+
collection="docs"
|
|
65
|
+
slot="prefix"
|
|
66
|
+
aria-hidden="true"></igc-icon>
|
|
67
|
+
<igc-icon-button
|
|
68
|
+
slot="suffix"
|
|
69
|
+
class="igd-search-clear"
|
|
70
|
+
variant="flat"
|
|
71
|
+
type="button"
|
|
72
|
+
aria-label="Clear search"
|
|
73
|
+
name="clear"
|
|
74
|
+
collection="docs"
|
|
75
|
+
hidden></igc-icon-button>
|
|
76
|
+
</igc-input>
|
|
77
|
+
</header>
|
|
78
|
+
<div class="igd-search-content">
|
|
79
|
+
<div class="igd-search-status" aria-live="polite"></div>
|
|
80
|
+
<igc-list class="igd-search-results" hidden></igc-list>
|
|
81
|
+
<igc-button class="igd-search-more-btn" variant="flat" type="button" hidden>
|
|
82
|
+
Show more results
|
|
83
|
+
</igc-button>
|
|
78
84
|
</div>
|
|
85
|
+
<footer class="igd-search-footer">
|
|
86
|
+
<igc-button class="search-close" variant="outlined"> Close </igc-button>
|
|
87
|
+
</footer>
|
|
88
|
+
</div>
|
|
79
89
|
</igc-dialog>
|
|
80
90
|
|
|
81
91
|
<script>
|
|
@@ -104,12 +114,12 @@ import './Search.scss';
|
|
|
104
114
|
);
|
|
105
115
|
|
|
106
116
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
|
107
|
-
const _w
|
|
117
|
+
const _w = window as any;
|
|
108
118
|
|
|
109
119
|
const SEARCH_DEBOUNCE_MS = 200;
|
|
110
|
-
const MIN_QUERY_LEN
|
|
111
|
-
const PAGE_SIZE
|
|
112
|
-
const SCAN_BATCH
|
|
120
|
+
const MIN_QUERY_LEN = 2; // 1 char matches (and whole-word-highlights) everything
|
|
121
|
+
const PAGE_SIZE = 10; // results shown per display page
|
|
122
|
+
const SCAN_BATCH = 20; // raw results fetched per phrase-filter pass
|
|
113
123
|
|
|
114
124
|
// Bumped per query; runSearch/renderNextPage bail after each await if it changed,
|
|
115
125
|
// so a slow query can't overwrite a newer one.
|
|
@@ -119,14 +129,14 @@ import './Search.scss';
|
|
|
119
129
|
// we scan Pagefind's lazy handles (pfResults) in batches, keep the phrase matches
|
|
120
130
|
// (matches), and page the display over those. rawConsumed counts handles scanned,
|
|
121
131
|
// displayed counts matches rendered.
|
|
122
|
-
let activeSeq
|
|
123
|
-
let activeTerm
|
|
132
|
+
let activeSeq = 0;
|
|
133
|
+
let activeTerm = '';
|
|
124
134
|
let activeTokens: string[] = [];
|
|
125
135
|
let pfResults: any[] = [];
|
|
126
|
-
let rawConsumed
|
|
136
|
+
let rawConsumed = 0;
|
|
127
137
|
let matches: any[] = [];
|
|
128
|
-
let displayed
|
|
129
|
-
let loadingMore
|
|
138
|
+
let displayed = 0;
|
|
139
|
+
let loadingMore = false;
|
|
130
140
|
|
|
131
141
|
// Cache the promise so concurrent first callers share one import/options/init.
|
|
132
142
|
function loadPagefind(): Promise<any> {
|
|
@@ -137,9 +147,9 @@ import './Search.scss';
|
|
|
137
147
|
// Must run before init(). Tuned so keyword-dense API pages don't bury prose.
|
|
138
148
|
await pf.options?.({
|
|
139
149
|
ranking: {
|
|
140
|
-
termSaturation: 1.0,
|
|
141
|
-
pageLength:
|
|
142
|
-
termFrequency:
|
|
150
|
+
termSaturation: 1.0, // default 1.4
|
|
151
|
+
pageLength: 0.6, // default 0.75
|
|
152
|
+
termFrequency: 1.0,
|
|
143
153
|
termSimilarity: 1.0,
|
|
144
154
|
},
|
|
145
155
|
});
|
|
@@ -170,7 +180,12 @@ import './Search.scss';
|
|
|
170
180
|
function looksRelevant(excerpt: string, queryTokens: string[]): boolean {
|
|
171
181
|
if (queryTokens.length === 0) return true;
|
|
172
182
|
const marks = [...excerpt.matchAll(/<mark[^>]*>([\s\S]*?)<\/mark>/gi)]
|
|
173
|
-
.map((m) =>
|
|
183
|
+
.map((m) =>
|
|
184
|
+
m[1]
|
|
185
|
+
.replace(/<[^>]+>/g, '')
|
|
186
|
+
.replace(/[^a-z0-9]/gi, '')
|
|
187
|
+
.toLowerCase(),
|
|
188
|
+
)
|
|
174
189
|
.filter(Boolean);
|
|
175
190
|
if (marks.length === 0) return true;
|
|
176
191
|
return marks.some((h) => queryTokens.some((t) => h.includes(t)));
|
|
@@ -195,7 +210,7 @@ import './Search.scss';
|
|
|
195
210
|
/** HTML for a single result row from its resolved Pagefind data. */
|
|
196
211
|
function renderResultItem(r: any): string {
|
|
197
212
|
const title = escapeHtml(r.meta?.title ?? r.url);
|
|
198
|
-
const path
|
|
213
|
+
const path = r.meta?.breadcrumb ? escapeHtml(r.meta.breadcrumb) : '';
|
|
199
214
|
return `<igc-list-item>
|
|
200
215
|
<a href="${escapeHtml(r.url)}" class="igd-search-link">
|
|
201
216
|
<span class="igd-search-result-title">${title}</span>
|
|
@@ -208,10 +223,14 @@ import './Search.scss';
|
|
|
208
223
|
// Render the empty state for the active query.
|
|
209
224
|
function showNoResults() {
|
|
210
225
|
const statusEl = document.querySelector<HTMLElement>('.igd-search-status');
|
|
211
|
-
const listEl
|
|
212
|
-
const moreBtn
|
|
213
|
-
if (statusEl)
|
|
214
|
-
|
|
226
|
+
const listEl = document.querySelector<any>('igc-list.igd-search-results');
|
|
227
|
+
const moreBtn = document.querySelector<any>('.igd-search-more-btn');
|
|
228
|
+
if (statusEl)
|
|
229
|
+
statusEl.innerHTML = `<span class="igd-no-results">No results for <strong class="igd-search-query">${escapeHtml(activeTerm)}.</strong></span>`;
|
|
230
|
+
if (listEl) {
|
|
231
|
+
listEl.innerHTML = '';
|
|
232
|
+
listEl.hidden = true;
|
|
233
|
+
}
|
|
215
234
|
if (moreBtn) moreBtn.hidden = true;
|
|
216
235
|
}
|
|
217
236
|
|
|
@@ -221,7 +240,7 @@ import './Search.scss';
|
|
|
221
240
|
async function ensureMatches(seq: number) {
|
|
222
241
|
while (matches.length - displayed < PAGE_SIZE && rawConsumed < pfResults.length) {
|
|
223
242
|
const slice = pfResults.slice(rawConsumed, rawConsumed + SCAN_BATCH);
|
|
224
|
-
const data
|
|
243
|
+
const data = await Promise.all(slice.map((r: any) => r.data()));
|
|
225
244
|
if (seq !== searchSeq) return;
|
|
226
245
|
rawConsumed += slice.length;
|
|
227
246
|
matches.push(...data.filter((r: any) => looksRelevant(r.excerpt ?? '', activeTokens)));
|
|
@@ -232,12 +251,13 @@ import './Search.scss';
|
|
|
232
251
|
// needed. seq ties the work to its query so a stale page can't render.
|
|
233
252
|
async function renderNextPage(seq: number, isFirst = false) {
|
|
234
253
|
const statusEl = document.querySelector<HTMLElement>('.igd-search-status');
|
|
235
|
-
const listEl
|
|
236
|
-
const moreBtn
|
|
254
|
+
const listEl = document.querySelector<any>('igc-list.igd-search-results');
|
|
255
|
+
const moreBtn = document.querySelector<any>('.igd-search-more-btn');
|
|
237
256
|
if (!statusEl || !listEl) return;
|
|
238
257
|
|
|
239
258
|
if (seq !== searchSeq || loadingMore) return;
|
|
240
|
-
if (displayed >= matches.length && rawConsumed >= pfResults.length) {
|
|
259
|
+
if (displayed >= matches.length && rawConsumed >= pfResults.length) {
|
|
260
|
+
// nothing more to show
|
|
241
261
|
if (isFirst) showNoResults();
|
|
242
262
|
return;
|
|
243
263
|
}
|
|
@@ -247,14 +267,15 @@ import './Search.scss';
|
|
|
247
267
|
await ensureMatches(seq);
|
|
248
268
|
} catch {
|
|
249
269
|
if (seq === searchSeq) statusEl.textContent = 'Failed to load search results.';
|
|
250
|
-
return;
|
|
270
|
+
return; // finally still clears loadingMore
|
|
251
271
|
} finally {
|
|
252
272
|
loadingMore = false;
|
|
253
273
|
}
|
|
254
|
-
if (seq !== searchSeq) return;
|
|
274
|
+
if (seq !== searchSeq) return; // user typed more while data() resolved
|
|
255
275
|
|
|
256
276
|
const slice = matches.slice(displayed, displayed + PAGE_SIZE);
|
|
257
|
-
if (slice.length === 0) {
|
|
277
|
+
if (slice.length === 0) {
|
|
278
|
+
// scanned all raw, nothing matched
|
|
258
279
|
if (isFirst) showNoResults();
|
|
259
280
|
if (moreBtn) moreBtn.hidden = true;
|
|
260
281
|
return;
|
|
@@ -273,10 +294,10 @@ import './Search.scss';
|
|
|
273
294
|
|
|
274
295
|
async function runSearch(query: string) {
|
|
275
296
|
const statusEl = document.querySelector<HTMLElement>('.igd-search-status');
|
|
276
|
-
const listEl
|
|
297
|
+
const listEl = document.querySelector<any>('igc-list.igd-search-results');
|
|
277
298
|
const clearBtn = document.querySelector<any>('.igd-search-clear');
|
|
278
|
-
const moreBtn
|
|
279
|
-
const input
|
|
299
|
+
const moreBtn = document.querySelector<any>('.igd-search-more-btn');
|
|
300
|
+
const input = document.querySelector<any>('igc-input.igd-search-input');
|
|
280
301
|
|
|
281
302
|
if (!statusEl || !listEl) return;
|
|
282
303
|
|
|
@@ -285,19 +306,19 @@ import './Search.scss';
|
|
|
285
306
|
|
|
286
307
|
const term = query.trim();
|
|
287
308
|
if (!term) {
|
|
288
|
-
searchSeq++;
|
|
309
|
+
searchSeq++; // invalidate any in-flight search so a late result can't repopulate
|
|
289
310
|
statusEl.textContent = '';
|
|
290
|
-
listEl.innerHTML
|
|
291
|
-
listEl.hidden
|
|
311
|
+
listEl.innerHTML = '';
|
|
312
|
+
listEl.hidden = true;
|
|
292
313
|
if (moreBtn) moreBtn.hidden = true;
|
|
293
314
|
return;
|
|
294
315
|
}
|
|
295
316
|
|
|
296
317
|
if (term.length < MIN_QUERY_LEN) {
|
|
297
|
-
searchSeq++;
|
|
318
|
+
searchSeq++; // cancel any in-flight search
|
|
298
319
|
statusEl.textContent = `Type at least ${MIN_QUERY_LEN} characters to search.`;
|
|
299
|
-
listEl.innerHTML
|
|
300
|
-
listEl.hidden
|
|
320
|
+
listEl.innerHTML = '';
|
|
321
|
+
listEl.hidden = true;
|
|
301
322
|
if (moreBtn) moreBtn.hidden = true;
|
|
302
323
|
return;
|
|
303
324
|
}
|
|
@@ -306,29 +327,30 @@ import './Search.scss';
|
|
|
306
327
|
statusEl.textContent = 'Searching…';
|
|
307
328
|
|
|
308
329
|
const pf = await loadPagefind();
|
|
309
|
-
if (seq !== searchSeq) return;
|
|
330
|
+
if (seq !== searchSeq) return; // superseded while loading the index
|
|
310
331
|
if (!pf) {
|
|
311
332
|
statusEl.textContent = 'Search index not available — run a production build first.';
|
|
312
333
|
return;
|
|
313
334
|
}
|
|
314
335
|
|
|
315
|
-
pf.preload?.(term);
|
|
336
|
+
pf.preload?.(term); // warm the index chunks during the debounce window
|
|
316
337
|
|
|
317
338
|
// debouncedSearch returns null when superseded; search() is a fallback for old bundles.
|
|
318
|
-
const search =
|
|
319
|
-
|
|
320
|
-
|
|
339
|
+
const search =
|
|
340
|
+
typeof pf.debouncedSearch === 'function'
|
|
341
|
+
? await pf.debouncedSearch(term, undefined, SEARCH_DEBOUNCE_MS)
|
|
342
|
+
: await pf.search(term);
|
|
321
343
|
if (search === null) return;
|
|
322
344
|
if (seq !== searchSeq) return;
|
|
323
345
|
|
|
324
346
|
// New result set — reset pagination and render the first page.
|
|
325
|
-
activeSeq
|
|
326
|
-
activeTerm
|
|
327
|
-
pfResults
|
|
328
|
-
activeTokens
|
|
329
|
-
rawConsumed
|
|
330
|
-
matches
|
|
331
|
-
displayed
|
|
347
|
+
activeSeq = seq;
|
|
348
|
+
activeTerm = term;
|
|
349
|
+
pfResults = search.results;
|
|
350
|
+
activeTokens = term.toLowerCase().match(/[a-z0-9]+/g) ?? [];
|
|
351
|
+
rawConsumed = 0;
|
|
352
|
+
matches = [];
|
|
353
|
+
displayed = 0;
|
|
332
354
|
listEl.innerHTML = '';
|
|
333
355
|
|
|
334
356
|
await renderNextPage(seq, true);
|
|
@@ -384,13 +406,17 @@ import './Search.scss';
|
|
|
384
406
|
if (modKey) modKey.textContent = isMac ? '⌘' : 'Ctrl';
|
|
385
407
|
const btn = document.getElementById('search-trigger');
|
|
386
408
|
btn?.setAttribute('aria-keyshortcuts', isMac ? 'Meta+K' : 'Control+K');
|
|
387
|
-
btn?.setAttribute('title',
|
|
409
|
+
btn?.setAttribute('title', isMac ? 'Search (⌘K)' : 'Search (Ctrl+K)');
|
|
388
410
|
hint.style.display = '';
|
|
389
411
|
}
|
|
390
412
|
updateSearchHint();
|
|
391
413
|
|
|
392
414
|
document.addEventListener('click', (e: Event) => {
|
|
393
|
-
if (
|
|
415
|
+
if (
|
|
416
|
+
(e.target as Element).closest('#search-trigger') ||
|
|
417
|
+
(e.target as Element).closest('.search-trigger-mobile')
|
|
418
|
+
)
|
|
419
|
+
openSearch();
|
|
394
420
|
});
|
|
395
421
|
|
|
396
422
|
document.addEventListener('keydown', (e: KeyboardEvent) => {
|
|
@@ -404,7 +430,8 @@ import './Search.scss';
|
|
|
404
430
|
if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
|
|
405
431
|
e.preventDefault();
|
|
406
432
|
const dialog = document.querySelector<any>('igc-dialog.igd-search-dialog');
|
|
407
|
-
if (dialog?.open) dialog.hide();
|
|
433
|
+
if (dialog?.open) dialog.hide();
|
|
434
|
+
else openSearch();
|
|
408
435
|
}
|
|
409
436
|
});
|
|
410
437
|
|
|
@@ -415,7 +442,8 @@ import './Search.scss';
|
|
|
415
442
|
|
|
416
443
|
document.addEventListener('igcInput', (e: Event) => {
|
|
417
444
|
if (!(e.target as Element).closest('igc-input.igd-search-input')) return;
|
|
418
|
-
const val =
|
|
445
|
+
const val =
|
|
446
|
+
(document.querySelector<any>('igc-input.igd-search-input')?.value as string) ?? '';
|
|
419
447
|
// Debouncing + supersession are handled inside runSearch via debouncedSearch.
|
|
420
448
|
runSearch(val);
|
|
421
449
|
});
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
@use '../../styles/global/search-shared' as *;
|
|
3
3
|
|
|
4
4
|
@layer components {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
5
|
+
.igd-search-result-excerpt {
|
|
6
|
+
@include type-style('body-2') {
|
|
7
|
+
margin: 0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
color: light-dark(var(--ig-gray-600), var(--ig-gray-400));
|
|
11
|
+
|
|
12
|
+
mark {
|
|
13
|
+
background: transparent;
|
|
14
|
+
color: var(--igd-accent);
|
|
15
|
+
// No padding/margin: a global `mark` rule adds horizontal padding that
|
|
16
|
+
// shows as a gap once we split a word into <mark>prefix</mark>rest.
|
|
17
|
+
padding: 0;
|
|
18
|
+
margin: 0;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.igd-search-shell {
|
|
23
|
+
grid-template-rows: auto 1fr auto;
|
|
24
|
+
}
|
|
25
25
|
}
|
|
@@ -10,14 +10,14 @@ import SearchAdvanced from 'igniteui-astro-components/components/SearchAdvanced.
|
|
|
10
10
|
|
|
11
11
|
## Props
|
|
12
12
|
|
|
13
|
-
| Prop
|
|
14
|
-
|
|
15
|
-
| `class`
|
|
16
|
-
| `indexUrl`
|
|
17
|
-
| `placeholder` | `string`
|
|
18
|
-
| `showScope`
|
|
19
|
-
| `tabs`
|
|
20
|
-
| `allTabLimit` | `number`
|
|
13
|
+
| Prop | Type | Default | Description |
|
|
14
|
+
| ------------- | ------------- | ---------------------------------- | ----------------------------------------------------- |
|
|
15
|
+
| `class` | `string` | — | CSS class for the outer element |
|
|
16
|
+
| `indexUrl` | `string` | `${BASE_URL}api-search-index.json` | URL to the JSON search index |
|
|
17
|
+
| `placeholder` | `string` | `"Search"` | Search input placeholder text |
|
|
18
|
+
| `showScope` | `boolean` | `false` | Show scope selector (current package / all packages) |
|
|
19
|
+
| `tabs` | `SearchTab[]` | `[]` | Tab categories (besides the always-present "All" tab) |
|
|
20
|
+
| `allTabLimit` | `number` | `10` | Max results per category in the "All" tab |
|
|
21
21
|
|
|
22
22
|
### `SearchTab`
|
|
23
23
|
|
|
@@ -44,6 +44,7 @@ interface SearchTab {
|
|
|
44
44
|
---
|
|
45
45
|
import SearchAdvanced from 'igniteui-astro-components/components/SearchAdvanced.astro';
|
|
46
46
|
---
|
|
47
|
+
|
|
47
48
|
<SearchAdvanced indexUrl="/api-search-index.json" />
|
|
48
49
|
```
|
|
49
50
|
|
|
@@ -54,14 +55,15 @@ import SearchAdvanced from 'igniteui-astro-components/components/SearchAdvanced.
|
|
|
54
55
|
import SearchAdvanced from 'igniteui-astro-components/components/SearchAdvanced.astro';
|
|
55
56
|
|
|
56
57
|
const tabs = [
|
|
57
|
-
{ id: 'names',
|
|
58
|
-
{ id: 'properties',
|
|
59
|
-
{ id: 'accessors',
|
|
60
|
-
{ id: 'methods',
|
|
61
|
-
{ id: 'events',
|
|
58
|
+
{ id: 'names', label: 'Names', kindCodes: ['__name__'] },
|
|
59
|
+
{ id: 'properties', label: 'Properties', kindCodes: ['p'] },
|
|
60
|
+
{ id: 'accessors', label: 'Accessors', kindCodes: ['a'] },
|
|
61
|
+
{ id: 'methods', label: 'Methods', kindCodes: ['m'] },
|
|
62
|
+
{ id: 'events', label: 'Events', kindCodes: ['e'] },
|
|
62
63
|
{ id: 'constructors', label: 'Constructors', kindCodes: ['c'] },
|
|
63
64
|
];
|
|
64
65
|
---
|
|
66
|
+
|
|
65
67
|
<SearchAdvanced showScope tabs={tabs} />
|
|
66
68
|
```
|
|
67
69
|
|
|
@@ -72,10 +74,11 @@ const tabs = [
|
|
|
72
74
|
import SearchAdvanced from 'igniteui-astro-components/components/SearchAdvanced.astro';
|
|
73
75
|
|
|
74
76
|
const tabs = [
|
|
75
|
-
{ id: 'names',
|
|
77
|
+
{ id: 'names', label: 'Types', kindCodes: ['__name__'] },
|
|
76
78
|
{ id: 'members', label: 'Members', kindCodes: ['p', 'a', 'm', 'e', 'c'] },
|
|
77
79
|
];
|
|
78
80
|
---
|
|
81
|
+
|
|
79
82
|
<SearchAdvanced tabs={tabs} indexUrl="/my-index.json" />
|
|
80
83
|
```
|
|
81
84
|
|
|
@@ -93,7 +96,10 @@ The component expects a JSON file with the following structure:
|
|
|
93
96
|
"v": "1.0.0",
|
|
94
97
|
"p": "angular",
|
|
95
98
|
"g": "package-name",
|
|
96
|
-
"m": [
|
|
99
|
+
"m": [
|
|
100
|
+
["memberName", "p"],
|
|
101
|
+
["onClick", "e"]
|
|
102
|
+
]
|
|
97
103
|
}
|
|
98
104
|
]
|
|
99
105
|
}
|