igniteui-astro-components 0.0.4 → 0.0.6
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/package.json +4 -3
- package/src/components/DocsSidebar/DocsSidebar.astro +10 -2
- package/src/components/DocsSidebar/sidebar-filter.ts +26 -12
- package/src/components/DocsSubHeader/DocsSubHeader.astro +348 -48
- package/src/components/DocsSubHeader/README.md +41 -0
- package/src/components/SearchAdvanced/README.md +105 -0
- package/src/components/SearchAdvanced/SearchAdvanced.astro +1047 -0
- package/src/components/mdx/ApiLink/ApiLink.astro +2 -2
- package/src/components/mdx/ApiRef/ApiRef.astro +2 -2
- package/src/components/mdx/PlatformBlock/PlatformBlock.astro +2 -2
- package/src/components/mdx/Sample/Sample.astro +3 -3
- package/src/index.ts +2 -2
- package/src/layouts/DocsLayout/DocsLayout.astro +13 -2
- package/src/lib/types.ts +66 -0
- package/src/virtual-modules.d.ts +11 -0
- package/src/lib/platform-context.ts +0 -305
|
@@ -0,0 +1,1047 @@
|
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* SearchAdvanced
|
|
4
|
+
*
|
|
5
|
+
* Client-side search dialog that loads a JSON search index and performs
|
|
6
|
+
* all matching against symbol and member names — never against page body content.
|
|
7
|
+
*
|
|
8
|
+
* Result UI:
|
|
9
|
+
* • Configurable tabs (only non-empty categories are shown, with their count)
|
|
10
|
+
* • "All" tab (always present) shows up to N results per category
|
|
11
|
+
* • Other tabs show all matches for that category
|
|
12
|
+
*
|
|
13
|
+
* Built so it has no runtime dependency on Starlight CSS — the trigger
|
|
14
|
+
* button, dialog, and all styles are self-contained.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export interface SearchTab {
|
|
18
|
+
/** Unique identifier for this tab/category */
|
|
19
|
+
id: string;
|
|
20
|
+
/** Display label for the tab */
|
|
21
|
+
label: string;
|
|
22
|
+
/**
|
|
23
|
+
* Kind codes from the index that map to this category.
|
|
24
|
+
* Use `['__name__']` for the special "page names" category.
|
|
25
|
+
* For member kinds: 'p' = property, 'a' = accessor, 'm' = method, 'e' = event, 'c' = constructor.
|
|
26
|
+
*/
|
|
27
|
+
kindCodes: string[];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Props {
|
|
31
|
+
/** CSS class for the outer element */
|
|
32
|
+
class?: string;
|
|
33
|
+
/**
|
|
34
|
+
* URL (or path) to the search index.
|
|
35
|
+
*
|
|
36
|
+
* Supports two modes:
|
|
37
|
+
* - **Single file**: URL pointing to a JSON file with a `{ pages: [...] }` shape.
|
|
38
|
+
* - **Manifest**: URL pointing to a `manifest.json` with a `{ files: [...] }` shape.
|
|
39
|
+
* Each listed file is fetched relative to the manifest URL and their pages
|
|
40
|
+
* are merged. This supports incremental / per-version builds.
|
|
41
|
+
*
|
|
42
|
+
* Defaults to `${BASE_URL}api-search-index/manifest.json`.
|
|
43
|
+
*/
|
|
44
|
+
indexUrl?: string;
|
|
45
|
+
/** Search input placeholder. Defaults to "Search" */
|
|
46
|
+
placeholder?: string;
|
|
47
|
+
/** Show scope selector (current package / all packages). Defaults to false */
|
|
48
|
+
showScope?: boolean;
|
|
49
|
+
/** Tab categories to show (besides the always-present "All" tab). Defaults to none (only "All") */
|
|
50
|
+
tabs?: SearchTab[];
|
|
51
|
+
/** Maximum results per category shown in the "All" tab. Defaults to 10 */
|
|
52
|
+
allTabLimit?: number;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const {
|
|
56
|
+
class: className,
|
|
57
|
+
indexUrl,
|
|
58
|
+
placeholder = 'Search',
|
|
59
|
+
showScope = false,
|
|
60
|
+
tabs = [],
|
|
61
|
+
allTabLimit = 10,
|
|
62
|
+
} = Astro.props;
|
|
63
|
+
|
|
64
|
+
const ctrlKey = 'Ctrl';
|
|
65
|
+
// Strip any origin (scheme + host) from BASE_URL so only the path prefix is
|
|
66
|
+
// used. When Astro builds in SSG mode the Node.js process may have
|
|
67
|
+
// process.env.BASE_URL set to a full URL (e.g. "http://localhost:4567") which
|
|
68
|
+
// leaks into import.meta.env.BASE_URL for server-side template expressions and
|
|
69
|
+
// causes the data attributes to embed an absolute origin that breaks previews.
|
|
70
|
+
const rawBase = import.meta.env.BASE_URL ?? '/';
|
|
71
|
+
const basePath = (() => {
|
|
72
|
+
try { return new URL(rawBase).pathname; } catch { return rawBase; }
|
|
73
|
+
})().replace(/\/?$/, '/');
|
|
74
|
+
const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`;
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
<api-search-advanced
|
|
78
|
+
class={className}
|
|
79
|
+
data-base={basePath}
|
|
80
|
+
data-index-url={resolvedIndexUrl}
|
|
81
|
+
data-tabs={JSON.stringify(tabs)}
|
|
82
|
+
data-all-tab-limit={allTabLimit}
|
|
83
|
+
data-show-scope={showScope ? 'true' : 'false'}
|
|
84
|
+
>
|
|
85
|
+
<button
|
|
86
|
+
data-open-modal
|
|
87
|
+
disabled
|
|
88
|
+
aria-label={placeholder}
|
|
89
|
+
aria-keyshortcuts="Control+K"
|
|
90
|
+
>
|
|
91
|
+
<svg aria-hidden="true" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2"><circle cx="11" cy="11" r="7"></circle><path d="m20 20-3.5-3.5"></path></svg>
|
|
92
|
+
<span class="search-label" aria-hidden="true">{placeholder}</span>
|
|
93
|
+
<kbd class="search-kbd" style="display: none;">
|
|
94
|
+
<kbd>{ctrlKey}</kbd><kbd>K</kbd>
|
|
95
|
+
</kbd>
|
|
96
|
+
</button>
|
|
97
|
+
|
|
98
|
+
<igc-dialog aria-label={placeholder} class="ig-search-dialog" hide-default-action close-on-outside-click>
|
|
99
|
+
<div class="ig-search-shell">
|
|
100
|
+
<header class="ig-search-header">
|
|
101
|
+
<igc-input
|
|
102
|
+
type="text"
|
|
103
|
+
class="ig-search-input"
|
|
104
|
+
placeholder={placeholder}
|
|
105
|
+
autocomplete="off"
|
|
106
|
+
outlined
|
|
107
|
+
aria-label={placeholder}
|
|
108
|
+
>
|
|
109
|
+
{showScope ? (
|
|
110
|
+
<igc-select slot="prefix" class="ig-search-scope" outlined aria-label="Search scope" value="current">
|
|
111
|
+
<igc-select-item value="current">Current package</igc-select-item>
|
|
112
|
+
<igc-select-item value="all">All packages</igc-select-item>
|
|
113
|
+
</igc-select>
|
|
114
|
+
) : (
|
|
115
|
+
<svg slot="prefix" aria-hidden="true" viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2">
|
|
116
|
+
<circle cx="11" cy="11" r="7"></circle>
|
|
117
|
+
<path d="m20 20-3.5-3.5"></path>
|
|
118
|
+
</svg>
|
|
119
|
+
)}
|
|
120
|
+
<igc-icon-button slot="suffix" class="ig-search-clear" variant="flat" type="button" aria-label="Clear search" hidden>
|
|
121
|
+
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2">
|
|
122
|
+
<path d="M6 6 18 18 M18 6 6 18"></path>
|
|
123
|
+
</svg>
|
|
124
|
+
</igc-icon-button>
|
|
125
|
+
</igc-input>
|
|
126
|
+
</header>
|
|
127
|
+
|
|
128
|
+
<igc-tabs class="ig-search-tabs" activation="manual" hidden></igc-tabs>
|
|
129
|
+
|
|
130
|
+
<div class="ig-search-status" aria-live="polite"></div>
|
|
131
|
+
|
|
132
|
+
<igc-list class="ig-search-results"></igc-list>
|
|
133
|
+
</div>
|
|
134
|
+
</igc-dialog>
|
|
135
|
+
</api-search-advanced>
|
|
136
|
+
|
|
137
|
+
<script is:inline>
|
|
138
|
+
/* Show the platform-correct keyboard shortcut hint after hydration. */
|
|
139
|
+
(() => {
|
|
140
|
+
const el = document.querySelector('api-search-advanced');
|
|
141
|
+
if (!el) return;
|
|
142
|
+
const openBtn = el.querySelector('button[data-open-modal]');
|
|
143
|
+
const shortcut = openBtn?.querySelector('kbd');
|
|
144
|
+
if (!openBtn || !(shortcut instanceof HTMLElement)) return;
|
|
145
|
+
const platformKey = shortcut.querySelector('kbd');
|
|
146
|
+
if (platformKey && /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform)) {
|
|
147
|
+
platformKey.textContent = '\u2318';
|
|
148
|
+
openBtn.setAttribute('aria-keyshortcuts', 'Meta+K');
|
|
149
|
+
}
|
|
150
|
+
shortcut.style.display = '';
|
|
151
|
+
})();
|
|
152
|
+
</script>
|
|
153
|
+
|
|
154
|
+
<script>
|
|
155
|
+
import {
|
|
156
|
+
defineComponents,
|
|
157
|
+
IgcInputComponent,
|
|
158
|
+
IgcDialogComponent,
|
|
159
|
+
IgcSelectComponent,
|
|
160
|
+
IgcSelectItemComponent,
|
|
161
|
+
IgcIconButtonComponent,
|
|
162
|
+
IgcTabsComponent,
|
|
163
|
+
IgcTabComponent,
|
|
164
|
+
IgcListComponent,
|
|
165
|
+
IgcListItemComponent,
|
|
166
|
+
IgcListHeaderComponent,
|
|
167
|
+
} from 'igniteui-webcomponents';
|
|
168
|
+
|
|
169
|
+
defineComponents(
|
|
170
|
+
IgcInputComponent,
|
|
171
|
+
IgcDialogComponent,
|
|
172
|
+
IgcSelectComponent,
|
|
173
|
+
IgcSelectItemComponent,
|
|
174
|
+
IgcIconButtonComponent,
|
|
175
|
+
IgcTabsComponent,
|
|
176
|
+
IgcTabComponent,
|
|
177
|
+
IgcListComponent,
|
|
178
|
+
IgcListItemComponent,
|
|
179
|
+
IgcListHeaderComponent,
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
type IndexedPage = {
|
|
183
|
+
u: string;
|
|
184
|
+
n: string;
|
|
185
|
+
k: string;
|
|
186
|
+
v: string;
|
|
187
|
+
p: string;
|
|
188
|
+
g: string;
|
|
189
|
+
m: Array<[string, string]>;
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
type TabConfig = {
|
|
193
|
+
id: string;
|
|
194
|
+
label: string;
|
|
195
|
+
kindCodes: string[];
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
type Match = {
|
|
199
|
+
name: string;
|
|
200
|
+
pageName: string;
|
|
201
|
+
url: string;
|
|
202
|
+
category: string;
|
|
203
|
+
matchTier: number;
|
|
204
|
+
qPos: number;
|
|
205
|
+
hasPrefix: boolean;
|
|
206
|
+
typeWeight: number;
|
|
207
|
+
kindLabel: string;
|
|
208
|
+
metaLabel: string;
|
|
209
|
+
packageLabel: string;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
const PAGE_KIND_LABEL: Record<string, string> = {
|
|
213
|
+
class: 'class',
|
|
214
|
+
interface: 'interface',
|
|
215
|
+
enum: 'enum',
|
|
216
|
+
type: 'type',
|
|
217
|
+
variable: 'variable',
|
|
218
|
+
function: 'function',
|
|
219
|
+
module: 'module',
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
const PAGE_KIND_WEIGHT: Record<string, number> = {
|
|
223
|
+
class: 0, interface: 1, enum: 2, type: 3, function: 4, variable: 5, module: 6,
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
const KIND_CODE_TO_LABEL: Record<string, string> = {
|
|
227
|
+
p: 'property',
|
|
228
|
+
a: 'accessor',
|
|
229
|
+
m: 'method',
|
|
230
|
+
e: 'event',
|
|
231
|
+
c: 'constructor',
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
const INPUT_DEBOUNCE_MS = 100;
|
|
235
|
+
|
|
236
|
+
class ApiSearchAdvanced extends HTMLElement {
|
|
237
|
+
private dialog!: IgcDialogComponent;
|
|
238
|
+
private input!: IgcInputComponent;
|
|
239
|
+
private clearBtn!: IgcIconButtonComponent;
|
|
240
|
+
private scopeSelect: IgcSelectComponent | null = null;
|
|
241
|
+
private tabsEl!: IgcTabsComponent;
|
|
242
|
+
private statusEl!: HTMLElement;
|
|
243
|
+
private resultsEl!: HTMLElement;
|
|
244
|
+
private indexPromise: Promise<IndexedPage[]> | null = null;
|
|
245
|
+
private currentTab: string = 'all';
|
|
246
|
+
private currentMatches: Map<string, Match[]> = new Map();
|
|
247
|
+
private currentQuery: string = '';
|
|
248
|
+
private debounceTimer: ReturnType<typeof setTimeout> | null = null;
|
|
249
|
+
private basePath: string = '/';
|
|
250
|
+
private indexUrl: string = '';
|
|
251
|
+
private currentPlatform: string = '';
|
|
252
|
+
private currentPkg: string = '';
|
|
253
|
+
private currentVersion: string = '';
|
|
254
|
+
private scope: 'current' | 'all' = 'current';
|
|
255
|
+
private categories: TabConfig[] = [];
|
|
256
|
+
private allTabLimit: number = 10;
|
|
257
|
+
private showScope: boolean = false;
|
|
258
|
+
private kindCodeToCategory: Map<string, string> = new Map();
|
|
259
|
+
|
|
260
|
+
connectedCallback() {
|
|
261
|
+
this.basePath = this.dataset.base || '/';
|
|
262
|
+
this.indexUrl = this.dataset.indexUrl || `${this.basePath}api-search-index.json`;
|
|
263
|
+
this.allTabLimit = parseInt(this.dataset.allTabLimit || '10', 10) || 10;
|
|
264
|
+
this.showScope = this.dataset.showScope === 'true';
|
|
265
|
+
|
|
266
|
+
// Parse tab configuration
|
|
267
|
+
try {
|
|
268
|
+
const tabsData: TabConfig[] = JSON.parse(this.dataset.tabs || '[]');
|
|
269
|
+
this.categories = tabsData;
|
|
270
|
+
} catch {
|
|
271
|
+
this.categories = [];
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
// Build kind code → category mapping
|
|
275
|
+
for (const cat of this.categories) {
|
|
276
|
+
for (const code of cat.kindCodes) {
|
|
277
|
+
if (code !== '__name__') {
|
|
278
|
+
this.kindCodeToCategory.set(code, cat.id);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
const openBtn = this.querySelector<HTMLButtonElement>('button[data-open-modal]')!;
|
|
284
|
+
this.dialog = this.querySelector<IgcDialogComponent>('igc-dialog')!;
|
|
285
|
+
this.input = this.querySelector<IgcInputComponent>('igc-input.ig-search-input')!;
|
|
286
|
+
this.clearBtn = this.querySelector<IgcIconButtonComponent>('.ig-search-clear')!;
|
|
287
|
+
this.scopeSelect = this.querySelector<IgcSelectComponent>('igc-select.ig-search-scope');
|
|
288
|
+
this.tabsEl = this.querySelector<IgcTabsComponent>('igc-tabs.ig-search-tabs')!;
|
|
289
|
+
this.statusEl = this.querySelector<HTMLElement>('.ig-search-status')!;
|
|
290
|
+
this.resultsEl = this.querySelector<HTMLElement>('.ig-search-results')!;
|
|
291
|
+
|
|
292
|
+
if (this.showScope) {
|
|
293
|
+
this.detectCurrentContext();
|
|
294
|
+
this.updateScopeOption();
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
const open = async () => {
|
|
298
|
+
await this.dialog.show();
|
|
299
|
+
document.body.toggleAttribute('data-search-modal-open', true);
|
|
300
|
+
this.loadIndex();
|
|
301
|
+
this.input.focus();
|
|
302
|
+
};
|
|
303
|
+
|
|
304
|
+
openBtn.addEventListener('click', open);
|
|
305
|
+
openBtn.disabled = false;
|
|
306
|
+
|
|
307
|
+
this.dialog.addEventListener('igcClosed', () => {
|
|
308
|
+
document.body.toggleAttribute('data-search-modal-open', false);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
// Close on result-link click (navigation)
|
|
312
|
+
this.resultsEl.addEventListener('click', (e) => {
|
|
313
|
+
if ((e.target as Element).closest('a[href]')) {
|
|
314
|
+
this.dialog.hide();
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
window.addEventListener('keydown', (e) => {
|
|
319
|
+
if ((e.metaKey === true || e.ctrlKey === true) && e.key === 'k') {
|
|
320
|
+
this.dialog.open ? this.closeModal() : open();
|
|
321
|
+
e.preventDefault();
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
this.input.addEventListener('igcInput', () => this.onInput());
|
|
326
|
+
this.clearBtn.addEventListener('click', () => {
|
|
327
|
+
this.input.value = '';
|
|
328
|
+
this.input.focus();
|
|
329
|
+
this.onInput();
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
this.tabsEl.addEventListener('igcChange', (e) => {
|
|
333
|
+
const tab = (e as CustomEvent<IgcTabComponent>).detail;
|
|
334
|
+
const tabId = (tab as HTMLElement)?.dataset?.tabId || 'all';
|
|
335
|
+
if (tabId === this.currentTab) return;
|
|
336
|
+
this.currentTab = tabId;
|
|
337
|
+
this.renderResults();
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
if (this.scopeSelect) {
|
|
341
|
+
this.scopeSelect.addEventListener('igcChange', () => {
|
|
342
|
+
this.scope = this.scopeSelect!.value === 'all' ? 'all' : 'current';
|
|
343
|
+
if (this.currentQuery) this.runSearch();
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
private detectCurrentContext() {
|
|
349
|
+
const path = window.location.pathname;
|
|
350
|
+
const stripped = path.startsWith(this.basePath) ? path.slice(this.basePath.length) : path.replace(/^\/+/, '');
|
|
351
|
+
const segs = stripped.split('/').filter(Boolean);
|
|
352
|
+
const baseSegs = this.basePath.split('/').filter(Boolean);
|
|
353
|
+
this.currentPlatform = baseSegs[baseSegs.length - 1] || '';
|
|
354
|
+
this.currentPkg = segs[0] || '';
|
|
355
|
+
this.currentVersion = segs[1] || '';
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
private updateScopeOption() {
|
|
359
|
+
if (!this.scopeSelect) return;
|
|
360
|
+
const item = this.scopeSelect.querySelector<HTMLElement & { value: string; disabled: boolean }>('igc-select-item[value="current"]');
|
|
361
|
+
if (!item) return;
|
|
362
|
+
if (this.currentPkg && this.currentVersion) {
|
|
363
|
+
item.textContent = `${this.currentPkg} ${this.currentVersion}`;
|
|
364
|
+
} else {
|
|
365
|
+
item.disabled = true;
|
|
366
|
+
item.hidden = true;
|
|
367
|
+
this.scopeSelect.value = 'all';
|
|
368
|
+
this.scope = 'all';
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
private closeModal() {
|
|
373
|
+
this.dialog.hide();
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
private loadIndex(): Promise<IndexedPage[]> {
|
|
377
|
+
if (this.indexPromise) return this.indexPromise;
|
|
378
|
+
this.indexPromise = this.fetchIndex();
|
|
379
|
+
return this.indexPromise;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
private async fetchIndex(): Promise<IndexedPage[]> {
|
|
383
|
+
const r = await fetch(this.indexUrl);
|
|
384
|
+
if (!r.ok) throw new Error(`HTTP ${r.status}`);
|
|
385
|
+
const data = await r.json();
|
|
386
|
+
|
|
387
|
+
// Single-file format: { pages: [...] }
|
|
388
|
+
if (Array.isArray(data?.pages)) {
|
|
389
|
+
return data.pages as IndexedPage[];
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
// Manifest format: { files: ["pkg/version.json", ...] }
|
|
393
|
+
if (Array.isArray(data?.files)) {
|
|
394
|
+
const baseUrl = this.indexUrl.replace(/[^/]*$/, '');
|
|
395
|
+
const fetches = (data.files as string[]).map(async (file: string) => {
|
|
396
|
+
const res = await fetch(`${baseUrl}${file}`);
|
|
397
|
+
if (!res.ok) return [];
|
|
398
|
+
const d = await res.json();
|
|
399
|
+
return Array.isArray(d?.pages) ? d.pages as IndexedPage[] : [];
|
|
400
|
+
});
|
|
401
|
+
const results = await Promise.all(fetches);
|
|
402
|
+
return results.flat();
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
return [];
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
private onInput() {
|
|
409
|
+
if (this.debounceTimer !== null) clearTimeout(this.debounceTimer);
|
|
410
|
+
this.debounceTimer = setTimeout(() => this.runSearch(), INPUT_DEBOUNCE_MS);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
private async runSearch() {
|
|
414
|
+
const raw = (this.input.value as string) ?? '';
|
|
415
|
+
const q = raw.trim().toLowerCase();
|
|
416
|
+
this.currentQuery = q;
|
|
417
|
+
this.clearBtn.hidden = !raw;
|
|
418
|
+
// igc-input uses [slot="suffix"]:not([hidden]) to show the suffix container.
|
|
419
|
+
// It doesn't observe attribute mutations on slotted elements, so we must
|
|
420
|
+
// force a re-render whenever the clear button's visibility changes.
|
|
421
|
+
(this.input as unknown as { requestUpdate(): void }).requestUpdate?.();
|
|
422
|
+
|
|
423
|
+
if (!q) {
|
|
424
|
+
this.clearResults();
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
this.statusEl.textContent = 'Searching\u2026';
|
|
429
|
+
|
|
430
|
+
let pages: IndexedPage[];
|
|
431
|
+
try {
|
|
432
|
+
pages = await this.loadIndex();
|
|
433
|
+
} catch (err) {
|
|
434
|
+
this.statusEl.textContent = `Search unavailable: ${(err as Error).message}`;
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
if (q !== this.currentQuery) return;
|
|
439
|
+
|
|
440
|
+
const buckets = this.classify(pages, q);
|
|
441
|
+
this.currentMatches = buckets;
|
|
442
|
+
if (this.currentTab !== 'all' && (buckets.get(this.currentTab)?.length ?? 0) === 0) {
|
|
443
|
+
this.currentTab = 'all';
|
|
444
|
+
}
|
|
445
|
+
this.renderTabs();
|
|
446
|
+
this.renderResults();
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
private clearResults() {
|
|
450
|
+
this.statusEl.textContent = '';
|
|
451
|
+
this.tabsEl.hidden = true;
|
|
452
|
+
this.resultsEl.innerHTML = '';
|
|
453
|
+
this.currentMatches = new Map();
|
|
454
|
+
}
|
|
455
|
+
|
|
456
|
+
private async runBrowse() {
|
|
457
|
+
this.statusEl.textContent = '';
|
|
458
|
+
|
|
459
|
+
let pages: IndexedPage[];
|
|
460
|
+
try {
|
|
461
|
+
pages = await this.loadIndex();
|
|
462
|
+
} catch (err) {
|
|
463
|
+
this.statusEl.textContent = `Search unavailable: ${(err as Error).message}`;
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
const nameCategories = this.categories.filter(c => c.kindCodes.includes('__name__'));
|
|
468
|
+
|
|
469
|
+
let scoped: IndexedPage[];
|
|
470
|
+
if (this.showScope && this.scope === 'current' && this.currentPkg && this.currentVersion) {
|
|
471
|
+
scoped = pages.filter((p) =>
|
|
472
|
+
p.p === this.currentPlatform &&
|
|
473
|
+
p.g === this.currentPkg &&
|
|
474
|
+
p.v === this.currentVersion
|
|
475
|
+
);
|
|
476
|
+
} else if (this.showScope) {
|
|
477
|
+
const platformPages = this.currentPlatform
|
|
478
|
+
? pages.filter((p) => p.p === this.currentPlatform)
|
|
479
|
+
: pages;
|
|
480
|
+
scoped = pickHighestVersionWinners(platformPages);
|
|
481
|
+
} else {
|
|
482
|
+
scoped = pickHighestVersionWinners(pages);
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
const buckets: Map<string, Match[]> = new Map();
|
|
486
|
+
for (const cat of this.categories) buckets.set(cat.id, []);
|
|
487
|
+
|
|
488
|
+
for (const page of scoped) {
|
|
489
|
+
const isPlatformPrefixed = /^(Igx|Igr|Igc|Igb)[A-Z]/.test(page.n);
|
|
490
|
+
const pageWeight = PAGE_KIND_WEIGHT[page.k] ?? 8;
|
|
491
|
+
const meta = `${page.g} / ${page.v}`;
|
|
492
|
+
|
|
493
|
+
for (const nameCat of nameCategories) {
|
|
494
|
+
buckets.get(nameCat.id)?.push({
|
|
495
|
+
name: page.n,
|
|
496
|
+
pageName: page.n,
|
|
497
|
+
url: page.u,
|
|
498
|
+
category: nameCat.id,
|
|
499
|
+
matchTier: 0,
|
|
500
|
+
qPos: 0,
|
|
501
|
+
hasPrefix: isPlatformPrefixed,
|
|
502
|
+
typeWeight: pageWeight,
|
|
503
|
+
kindLabel: PAGE_KIND_LABEL[page.k] || page.k,
|
|
504
|
+
metaLabel: meta,
|
|
505
|
+
packageLabel: meta,
|
|
506
|
+
});
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
for (const [memberName, kindCode] of page.m) {
|
|
510
|
+
const catId = this.kindCodeToCategory.get(kindCode);
|
|
511
|
+
if (!catId) continue;
|
|
512
|
+
buckets.get(catId)?.push({
|
|
513
|
+
name: memberName,
|
|
514
|
+
pageName: page.n,
|
|
515
|
+
url: page.u + '#' + memberName,
|
|
516
|
+
category: catId,
|
|
517
|
+
matchTier: 0,
|
|
518
|
+
qPos: 0,
|
|
519
|
+
hasPrefix: isPlatformPrefixed,
|
|
520
|
+
typeWeight: pageWeight,
|
|
521
|
+
kindLabel: KIND_CODE_TO_LABEL[kindCode] || kindCode,
|
|
522
|
+
metaLabel: `${page.n} / ${page.g}`,
|
|
523
|
+
packageLabel: meta,
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
// Sort all buckets alphabetically by name
|
|
529
|
+
for (const list of buckets.values()) {
|
|
530
|
+
list.sort((a, b) => a.name.localeCompare(b.name));
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
this.currentMatches = buckets;
|
|
534
|
+
|
|
535
|
+
if (this.currentTab !== 'all' && (buckets.get(this.currentTab)?.length ?? 0) === 0) {
|
|
536
|
+
this.currentTab = 'all';
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
this.renderTabs();
|
|
540
|
+
this.renderResults();
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
private classify(pages: IndexedPage[], q: string): Map<string, Match[]> {
|
|
544
|
+
const buckets: Map<string, Match[]> = new Map();
|
|
545
|
+
for (const cat of this.categories) {
|
|
546
|
+
buckets.set(cat.id, []);
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// Determine which categories handle page names
|
|
550
|
+
const nameCategories = this.categories.filter(c => c.kindCodes.includes('__name__'));
|
|
551
|
+
|
|
552
|
+
let scoped: IndexedPage[];
|
|
553
|
+
if (this.showScope && this.scope === 'current' && this.currentPkg && this.currentVersion) {
|
|
554
|
+
scoped = pages.filter((p) =>
|
|
555
|
+
p.p === this.currentPlatform &&
|
|
556
|
+
p.g === this.currentPkg &&
|
|
557
|
+
p.v === this.currentVersion
|
|
558
|
+
);
|
|
559
|
+
} else if (this.showScope) {
|
|
560
|
+
const platformPages = this.currentPlatform
|
|
561
|
+
? pages.filter((p) => p.p === this.currentPlatform)
|
|
562
|
+
: pages;
|
|
563
|
+
scoped = pickHighestVersionWinners(platformPages);
|
|
564
|
+
} else {
|
|
565
|
+
scoped = pickHighestVersionWinners(pages);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
for (const page of scoped) {
|
|
569
|
+
const isPlatformPrefixed = /^(Igx|Igr|Igc|Igb)[A-Z]/.test(page.n);
|
|
570
|
+
const pageWeight = PAGE_KIND_WEIGHT[page.k] ?? 8;
|
|
571
|
+
const meta = `${page.g} / ${page.v}`;
|
|
572
|
+
|
|
573
|
+
// Match page names
|
|
574
|
+
const tier = matchTier(page.n, q);
|
|
575
|
+
if (tier !== null) {
|
|
576
|
+
for (const nameCat of nameCategories) {
|
|
577
|
+
if (!buckets.has(nameCat.id)) buckets.set(nameCat.id, []);
|
|
578
|
+
buckets.get(nameCat.id)!.push({
|
|
579
|
+
name: page.n,
|
|
580
|
+
pageName: page.n,
|
|
581
|
+
url: page.u,
|
|
582
|
+
category: nameCat.id,
|
|
583
|
+
matchTier: tier,
|
|
584
|
+
qPos: positionInName(page.n, q),
|
|
585
|
+
hasPrefix: isPlatformPrefixed,
|
|
586
|
+
typeWeight: pageWeight,
|
|
587
|
+
kindLabel: PAGE_KIND_LABEL[page.k] || page.k,
|
|
588
|
+
metaLabel: meta,
|
|
589
|
+
packageLabel: meta,
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
// If no categories defined, put everything in a default bucket
|
|
594
|
+
if (nameCategories.length === 0 && this.categories.length === 0) {
|
|
595
|
+
if (!buckets.has('__all__')) buckets.set('__all__', []);
|
|
596
|
+
buckets.get('__all__')!.push({
|
|
597
|
+
name: page.n,
|
|
598
|
+
pageName: page.n,
|
|
599
|
+
url: page.u,
|
|
600
|
+
category: '__all__',
|
|
601
|
+
matchTier: tier,
|
|
602
|
+
qPos: positionInName(page.n, q),
|
|
603
|
+
hasPrefix: isPlatformPrefixed,
|
|
604
|
+
typeWeight: pageWeight,
|
|
605
|
+
kindLabel: PAGE_KIND_LABEL[page.k] || page.k,
|
|
606
|
+
metaLabel: meta,
|
|
607
|
+
packageLabel: meta,
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
// Match members
|
|
613
|
+
for (const [memberName, kindCode] of page.m) {
|
|
614
|
+
const memberTier = matchTier(memberName, q);
|
|
615
|
+
if (memberTier === null) continue;
|
|
616
|
+
|
|
617
|
+
const catId = this.kindCodeToCategory.get(kindCode);
|
|
618
|
+
if (catId) {
|
|
619
|
+
if (!buckets.has(catId)) buckets.set(catId, []);
|
|
620
|
+
buckets.get(catId)!.push({
|
|
621
|
+
name: memberName,
|
|
622
|
+
pageName: page.n,
|
|
623
|
+
url: page.u + '#' + memberName,
|
|
624
|
+
category: catId,
|
|
625
|
+
matchTier: memberTier,
|
|
626
|
+
qPos: positionInName(memberName, q),
|
|
627
|
+
hasPrefix: isPlatformPrefixed,
|
|
628
|
+
typeWeight: pageWeight,
|
|
629
|
+
kindLabel: KIND_CODE_TO_LABEL[kindCode] || kindCode,
|
|
630
|
+
metaLabel: `${page.n} / ${page.g}`,
|
|
631
|
+
packageLabel: meta,
|
|
632
|
+
});
|
|
633
|
+
} else if (this.categories.length === 0) {
|
|
634
|
+
// No tabs configured — all results go into one bucket
|
|
635
|
+
if (!buckets.has('__all__')) buckets.set('__all__', []);
|
|
636
|
+
buckets.get('__all__')!.push({
|
|
637
|
+
name: memberName,
|
|
638
|
+
pageName: page.n,
|
|
639
|
+
url: page.u + '#' + memberName,
|
|
640
|
+
category: '__all__',
|
|
641
|
+
matchTier: memberTier,
|
|
642
|
+
qPos: positionInName(memberName, q),
|
|
643
|
+
hasPrefix: isPlatformPrefixed,
|
|
644
|
+
typeWeight: pageWeight,
|
|
645
|
+
kindLabel: KIND_CODE_TO_LABEL[kindCode] || kindCode,
|
|
646
|
+
metaLabel: `${page.n} / ${page.g}`,
|
|
647
|
+
packageLabel: meta,
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
// Sort each bucket
|
|
654
|
+
for (const [catId, list] of buckets.entries()) {
|
|
655
|
+
const isNameCat = nameCategories.some(c => c.id === catId);
|
|
656
|
+
if (isNameCat) {
|
|
657
|
+
list.sort((a, b) => {
|
|
658
|
+
if (a.typeWeight !== b.typeWeight) return a.typeWeight - b.typeWeight;
|
|
659
|
+
return a.name.localeCompare(b.name);
|
|
660
|
+
});
|
|
661
|
+
} else {
|
|
662
|
+
list.sort((a, b) => {
|
|
663
|
+
if (a.matchTier !== b.matchTier) return a.matchTier - b.matchTier;
|
|
664
|
+
if (a.hasPrefix !== b.hasPrefix) return a.hasPrefix ? -1 : 1;
|
|
665
|
+
if (a.qPos !== b.qPos) return a.qPos - b.qPos;
|
|
666
|
+
if (a.typeWeight !== b.typeWeight) return a.typeWeight - b.typeWeight;
|
|
667
|
+
return a.name.localeCompare(b.name);
|
|
668
|
+
});
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
return buckets;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
private renderTabs() {
|
|
676
|
+
const totalCount = Array.from(this.currentMatches.values()).reduce((s, l) => s + l.length, 0);
|
|
677
|
+
|
|
678
|
+
// If no categories configured, don't render tabs
|
|
679
|
+
if (this.categories.length === 0) {
|
|
680
|
+
this.tabsEl.hidden = true;
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
const tabsHtml: string[] = [];
|
|
685
|
+
tabsHtml.push(this.tabHtml('all', 'All', totalCount, this.currentTab === 'all'));
|
|
686
|
+
for (const cat of this.categories) {
|
|
687
|
+
const count = this.currentMatches.get(cat.id)?.length ?? 0;
|
|
688
|
+
if (count === 0) continue;
|
|
689
|
+
tabsHtml.push(this.tabHtml(cat.id, cat.label, count, this.currentTab === cat.id));
|
|
690
|
+
}
|
|
691
|
+
this.tabsEl.innerHTML = tabsHtml.join('');
|
|
692
|
+
this.tabsEl.hidden = totalCount === 0;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
private tabHtml(id: string, label: string, count: number, selected: boolean): string {
|
|
696
|
+
return `<igc-tab data-tab-id="${id}" label="${escapeHtml(label)}"${selected ? ' selected' : ''}><span slot="suffix" class="ig-search-tab-count">${count}</span></igc-tab>`;
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
private renderResults() {
|
|
700
|
+
const totalCount = Array.from(this.currentMatches.values()).reduce((s, l) => s + l.length, 0);
|
|
701
|
+
if (totalCount === 0) {
|
|
702
|
+
this.statusEl.textContent = this.currentQuery
|
|
703
|
+
? `No results for "${this.currentQuery}".`
|
|
704
|
+
: 'No results.';
|
|
705
|
+
this.resultsEl.replaceChildren();
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
this.statusEl.textContent = '';
|
|
710
|
+
|
|
711
|
+
const rendered: string[] = [];
|
|
712
|
+
|
|
713
|
+
if (this.categories.length === 0) {
|
|
714
|
+
// No tabs — render all results in one flat list
|
|
715
|
+
const list = this.currentMatches.get('__all__') ?? [];
|
|
716
|
+
for (const m of list) rendered.push(this.matchHtml(m));
|
|
717
|
+
} else if (this.currentTab === 'all') {
|
|
718
|
+
for (const cat of this.categories) {
|
|
719
|
+
const list = this.currentMatches.get(cat.id) ?? [];
|
|
720
|
+
if (list.length === 0) continue;
|
|
721
|
+
rendered.push(`<igc-list-header>${escapeHtml(cat.label)}</igc-list-header>`);
|
|
722
|
+
const slice = list.slice(0, this.allTabLimit);
|
|
723
|
+
for (const m of slice) rendered.push(this.matchHtml(m));
|
|
724
|
+
if (list.length > slice.length) {
|
|
725
|
+
rendered.push(
|
|
726
|
+
`<igc-list-item class="ig-search-more"><button type="button" class="ig-search-more-btn" data-tab="${cat.id}">
|
|
727
|
+
Show all ${list.length} ${escapeHtml(cat.label.toLowerCase())}
|
|
728
|
+
</button></igc-list-item>`
|
|
729
|
+
);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
} else {
|
|
733
|
+
const list = this.currentMatches.get(this.currentTab) ?? [];
|
|
734
|
+
for (const m of list) rendered.push(this.matchHtml(m));
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
this.resultsEl.innerHTML = rendered.join('');
|
|
738
|
+
|
|
739
|
+
this.resultsEl.querySelectorAll<HTMLButtonElement>('.ig-search-more-btn').forEach((btn) => {
|
|
740
|
+
btn.addEventListener('click', () => {
|
|
741
|
+
const tabId = btn.dataset.tab!;
|
|
742
|
+
this.currentTab = tabId;
|
|
743
|
+
const tabEl = this.tabsEl.querySelector<HTMLElement>(`igc-tab[data-tab-id="${tabId}"]`);
|
|
744
|
+
if (tabEl) this.tabsEl.select(tabEl as any);
|
|
745
|
+
this.renderResults();
|
|
746
|
+
this.resultsEl.scrollTop = 0;
|
|
747
|
+
});
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
private matchHtml(m: Match): string {
|
|
752
|
+
const highlightedName = highlight(m.name, this.currentQuery);
|
|
753
|
+
const nameCategories = this.categories.filter(c => c.kindCodes.includes('__name__'));
|
|
754
|
+
const isNameMatch = nameCategories.some(c => c.id === m.category);
|
|
755
|
+
const subtitle = isNameMatch || m.category === '__all__'
|
|
756
|
+
? `<span class="ig-search-kind">${escapeHtml(m.packageLabel)}</span>`
|
|
757
|
+
: `<span class="ig-search-kind">${escapeHtml(m.packageLabel)}</span><span class="ig-search-meta">in ${escapeHtml(m.pageName)}</span>`;
|
|
758
|
+
return `<igc-list-item>
|
|
759
|
+
<a href="${m.url}" class="ig-search-link" slot="title">
|
|
760
|
+
<span class="ig-search-result-title">${highlightedName}</span>
|
|
761
|
+
</a>
|
|
762
|
+
<span slot="subtitle" class="ig-search-result-sub">${subtitle}</span>
|
|
763
|
+
</igc-list-item>`;
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
function matchTier(name: string, q: string): number | null {
|
|
768
|
+
const n = name.toLowerCase();
|
|
769
|
+
if (n === q) return 0;
|
|
770
|
+
if (n.startsWith(q)) return 1;
|
|
771
|
+
if (n.includes(q)) return 2;
|
|
772
|
+
return null;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
function positionInName(name: string, q: string): number {
|
|
776
|
+
const i = name.toLowerCase().indexOf(q);
|
|
777
|
+
return i < 0 ? 99 : Math.min(i, 99);
|
|
778
|
+
}
|
|
779
|
+
|
|
780
|
+
function compareVersions(a: string, b: string): number {
|
|
781
|
+
const ap = a.replace(/[^0-9.]/g, '').split('.').map(Number);
|
|
782
|
+
const bp = b.replace(/[^0-9.]/g, '').split('.').map(Number);
|
|
783
|
+
for (let i = 0; i < Math.max(ap.length, bp.length); i++) {
|
|
784
|
+
const d = (ap[i] || 0) - (bp[i] || 0);
|
|
785
|
+
if (d !== 0) return d;
|
|
786
|
+
}
|
|
787
|
+
return 0;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
function pickHighestVersionWinners(pages: IndexedPage[]): IndexedPage[] {
|
|
791
|
+
const winners = new Map<string, IndexedPage>();
|
|
792
|
+
for (const p of pages) {
|
|
793
|
+
const key = `${p.p}|${p.g}|${p.k}|${p.n}`;
|
|
794
|
+
const existing = winners.get(key);
|
|
795
|
+
if (!existing || compareVersions(p.v, existing.v) > 0) {
|
|
796
|
+
winners.set(key, p);
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return Array.from(winners.values());
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
function highlight(text: string, q: string): string {
|
|
803
|
+
if (!q) return escapeHtml(text);
|
|
804
|
+
const i = text.toLowerCase().indexOf(q);
|
|
805
|
+
if (i < 0) return escapeHtml(text);
|
|
806
|
+
return (
|
|
807
|
+
escapeHtml(text.slice(0, i)) +
|
|
808
|
+
'<mark>' + escapeHtml(text.slice(i, i + q.length)) + '</mark>' +
|
|
809
|
+
escapeHtml(text.slice(i + q.length))
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
function escapeHtml(s: string): string {
|
|
814
|
+
return s
|
|
815
|
+
.replace(/&/g, '&')
|
|
816
|
+
.replace(/</g, '<')
|
|
817
|
+
.replace(/>/g, '>')
|
|
818
|
+
.replace(/"/g, '"')
|
|
819
|
+
.replace(/'/g, ''');
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
customElements.define('api-search-advanced', ApiSearchAdvanced);
|
|
823
|
+
</script>
|
|
824
|
+
|
|
825
|
+
<style>
|
|
826
|
+
api-search-advanced { display: contents; }
|
|
827
|
+
|
|
828
|
+
/* Hide dialog content before web components hydrate (prevents FOUC) */
|
|
829
|
+
igc-dialog:not(:defined) { display: none; }
|
|
830
|
+
|
|
831
|
+
button[data-open-modal] {
|
|
832
|
+
display: flex;
|
|
833
|
+
align-items: center;
|
|
834
|
+
gap: 0.5rem;
|
|
835
|
+
border: 0;
|
|
836
|
+
background-color: transparent;
|
|
837
|
+
color: var(--sl-color-gray-1);
|
|
838
|
+
cursor: pointer;
|
|
839
|
+
height: 2.5rem;
|
|
840
|
+
font-size: var(--sl-text-xl);
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
@media (min-width: 50rem) {
|
|
844
|
+
button[data-open-modal] {
|
|
845
|
+
border: 1px solid var(--sl-color-gray-5);
|
|
846
|
+
border-radius: 0.5rem;
|
|
847
|
+
padding-inline-start: 0.75rem;
|
|
848
|
+
padding-inline-end: 0.5rem;
|
|
849
|
+
background-color: var(--sl-color-black);
|
|
850
|
+
color: var(--sl-color-gray-2);
|
|
851
|
+
font-size: var(--sl-text-sm);
|
|
852
|
+
width: 100%;
|
|
853
|
+
max-width: 22rem;
|
|
854
|
+
}
|
|
855
|
+
button[data-open-modal]:hover {
|
|
856
|
+
border-color: var(--sl-color-gray-2);
|
|
857
|
+
color: var(--sl-color-white);
|
|
858
|
+
}
|
|
859
|
+
button[data-open-modal] > :last-child {
|
|
860
|
+
margin-inline-start: auto;
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
button > kbd {
|
|
865
|
+
border-radius: 0.25rem;
|
|
866
|
+
font-size: 0.625rem;
|
|
867
|
+
gap: 0.25em;
|
|
868
|
+
padding-inline: 0.375rem;
|
|
869
|
+
background-color: var(--sl-color-gray-6);
|
|
870
|
+
}
|
|
871
|
+
kbd { font-family: inherit; }
|
|
872
|
+
</style>
|
|
873
|
+
|
|
874
|
+
<style is:global>
|
|
875
|
+
/* ── Dialog ──────────────────────────────────────────────────── */
|
|
876
|
+
igc-dialog.ig-search-dialog {
|
|
877
|
+
/* Inherited by ::part(base) (native <dialog>) via igc base CSS */
|
|
878
|
+
background-color: var(--sl-color-bg, #fff);
|
|
879
|
+
color: var(--sl-color-text, inherit);
|
|
880
|
+
border: 1px solid var(--sl-color-gray-5, #ddd);
|
|
881
|
+
}
|
|
882
|
+
igc-dialog.ig-search-dialog::part(base) {
|
|
883
|
+
margin: 0;
|
|
884
|
+
padding: 0;
|
|
885
|
+
width: 100%;
|
|
886
|
+
max-width: 100%;
|
|
887
|
+
height: 100vh;
|
|
888
|
+
max-height: 100vh;
|
|
889
|
+
box-shadow: 0 10px 40px rgba(0,0,0,0.25);
|
|
890
|
+
}
|
|
891
|
+
igc-dialog.ig-search-dialog::part(content) {
|
|
892
|
+
padding: 0;
|
|
893
|
+
display: flex;
|
|
894
|
+
flex-direction: column;
|
|
895
|
+
height: 100%;
|
|
896
|
+
}
|
|
897
|
+
igc-dialog.ig-search-dialog::part(backdrop) {
|
|
898
|
+
background-color: rgba(0,0,0,0.4);
|
|
899
|
+
-webkit-backdrop-filter: blur(0.25rem);
|
|
900
|
+
backdrop-filter: blur(0.25rem);
|
|
901
|
+
}
|
|
902
|
+
@media (min-width: 50rem) {
|
|
903
|
+
igc-dialog.ig-search-dialog {
|
|
904
|
+
border-radius: 0.5rem;
|
|
905
|
+
}
|
|
906
|
+
igc-dialog.ig-search-dialog::part(base) {
|
|
907
|
+
margin: auto;
|
|
908
|
+
width: 90%;
|
|
909
|
+
max-width: 42rem;
|
|
910
|
+
height: calc(100vh - 8rem);
|
|
911
|
+
max-height: 48rem;
|
|
912
|
+
border-radius: 0.5rem;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
[data-search-modal-open] { overflow: hidden; }
|
|
917
|
+
|
|
918
|
+
/* ── Shell layout ─────────────────────────────────────────────── */
|
|
919
|
+
.ig-search-shell {
|
|
920
|
+
display: flex;
|
|
921
|
+
flex-direction: column;
|
|
922
|
+
min-height: 0;
|
|
923
|
+
flex: 1 1 auto;
|
|
924
|
+
height: 100%;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/* ── Header ───────────────────────────────────────────────────── */
|
|
928
|
+
.ig-search-header {
|
|
929
|
+
padding: 0.75rem 1rem 0.5rem;
|
|
930
|
+
border-bottom: 1px solid var(--sl-color-gray-6, #f0f0f0);
|
|
931
|
+
flex-shrink: 0;
|
|
932
|
+
}
|
|
933
|
+
|
|
934
|
+
/* ── Scope selector (igc-select in prefix slot) ────────────── */
|
|
935
|
+
igc-select.ig-search-scope {
|
|
936
|
+
flex-shrink: 0;
|
|
937
|
+
max-width: 14rem;
|
|
938
|
+
min-width: 8rem;
|
|
939
|
+
}
|
|
940
|
+
@media (max-width: 32rem) {
|
|
941
|
+
igc-select.ig-search-scope { max-width: 9rem; min-width: 6rem; }
|
|
942
|
+
}
|
|
943
|
+
|
|
944
|
+
/* ── Search input (igc-input) ─────────────────────────────────── */
|
|
945
|
+
igc-input.ig-search-input {
|
|
946
|
+
width: 100%;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
/* Clear icon-button in suffix slot */
|
|
950
|
+
igc-icon-button.ig-search-clear {
|
|
951
|
+
color: var(--sl-color-gray-3, #888);
|
|
952
|
+
}
|
|
953
|
+
igc-icon-button.ig-search-clear:hover {
|
|
954
|
+
color: var(--sl-color-text, inherit);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
/* ── Tabs (igc-tabs) ──────────────────────────────────────────── */
|
|
958
|
+
igc-tabs.ig-search-tabs {
|
|
959
|
+
flex: 0 0 auto;
|
|
960
|
+
overflow: hidden;
|
|
961
|
+
/* Only show the tab header strip; tab body panels are unused */
|
|
962
|
+
max-height: 2.75rem;
|
|
963
|
+
border-bottom: 1px solid var(--sl-color-gray-6, #f0f0f0);
|
|
964
|
+
}
|
|
965
|
+
.ig-search-tab-count {
|
|
966
|
+
color: var(--sl-color-gray-3, #888);
|
|
967
|
+
font-weight: 400;
|
|
968
|
+
font-size: 0.8rem;
|
|
969
|
+
margin-inline-start: 0.25rem;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
/* ── Status ───────────────────────────────────────────────────── */
|
|
973
|
+
.ig-search-status {
|
|
974
|
+
padding: 0.5rem 1rem 0;
|
|
975
|
+
color: var(--sl-color-gray-3, #888);
|
|
976
|
+
font-size: 0.875rem;
|
|
977
|
+
min-height: 1.25rem;
|
|
978
|
+
flex-shrink: 0;
|
|
979
|
+
}
|
|
980
|
+
.ig-search-status:empty { padding: 0; min-height: 0; }
|
|
981
|
+
|
|
982
|
+
/* ── Results (igc-list) ───────────────────────────────────────── */
|
|
983
|
+
igc-list.ig-search-results {
|
|
984
|
+
overflow-y: auto;
|
|
985
|
+
flex: 1 1 auto;
|
|
986
|
+
min-height: 0;
|
|
987
|
+
padding: 0.5rem 0.5rem 1rem;
|
|
988
|
+
}
|
|
989
|
+
|
|
990
|
+
igc-list.ig-search-results igc-list-header {
|
|
991
|
+
font-size: 0.75rem;
|
|
992
|
+
font-weight: 600;
|
|
993
|
+
text-transform: uppercase;
|
|
994
|
+
letter-spacing: 0.05em;
|
|
995
|
+
color: var(--sl-color-gray-3, #888);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
.ig-search-link {
|
|
999
|
+
text-decoration: none;
|
|
1000
|
+
color: inherit;
|
|
1001
|
+
}
|
|
1002
|
+
.ig-search-result-title {
|
|
1003
|
+
font-size: 0.95rem;
|
|
1004
|
+
font-weight: 600;
|
|
1005
|
+
color: var(--sl-color-text, inherit);
|
|
1006
|
+
}
|
|
1007
|
+
.ig-search-result-title mark {
|
|
1008
|
+
background: var(--sl-color-accent-low, rgba(90,62,255,0.18));
|
|
1009
|
+
color: inherit;
|
|
1010
|
+
padding: 0 1px;
|
|
1011
|
+
border-radius: 2px;
|
|
1012
|
+
}
|
|
1013
|
+
.ig-search-result-sub {
|
|
1014
|
+
display: flex;
|
|
1015
|
+
gap: 0.5rem;
|
|
1016
|
+
font-size: 0.8rem;
|
|
1017
|
+
color: var(--sl-color-gray-3, #888);
|
|
1018
|
+
flex-wrap: wrap;
|
|
1019
|
+
}
|
|
1020
|
+
.ig-search-kind {
|
|
1021
|
+
display: inline-block;
|
|
1022
|
+
padding: 0 0.375rem;
|
|
1023
|
+
background: var(--sl-color-gray-1, rgba(0,0,0,0.04));
|
|
1024
|
+
border-radius: 0.25rem;
|
|
1025
|
+
font-size: 0.7rem;
|
|
1026
|
+
letter-spacing: 0.04em;
|
|
1027
|
+
font-weight: 500;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
.ig-search-more {
|
|
1031
|
+
text-align: center;
|
|
1032
|
+
}
|
|
1033
|
+
.ig-search-more-btn {
|
|
1034
|
+
appearance: none;
|
|
1035
|
+
background: transparent;
|
|
1036
|
+
border: 1px solid var(--sl-color-gray-5, #ddd);
|
|
1037
|
+
border-radius: 0.375rem;
|
|
1038
|
+
padding: 0.4rem 0.9rem;
|
|
1039
|
+
color: var(--sl-color-text, inherit);
|
|
1040
|
+
font-size: 0.85rem;
|
|
1041
|
+
cursor: pointer;
|
|
1042
|
+
}
|
|
1043
|
+
.ig-search-more-btn:hover {
|
|
1044
|
+
border-color: var(--sl-color-accent, #5a3eff);
|
|
1045
|
+
color: var(--sl-color-text-accent, inherit);
|
|
1046
|
+
}
|
|
1047
|
+
</style>
|