igniteui-astro-components 0.0.6 → 0.0.8
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 +9 -8
- package/package.json +7 -5
- package/src/assets/icons/open-link-blank.svg +1 -1
- package/src/assets/logos/code-sandbox.svg +14 -0
- package/src/assets/logos/stackblitz.svg +13 -0
- package/src/components/DocsBreadcrumb/DocsBreadcrumb.scss +1 -1
- package/src/components/DocsSidebar/DocsSidebar.astro +15 -8
- package/src/components/DocsSidebar/DocsSidebar.scss +152 -2
- package/src/components/DocsSidebar/SidebarFilterInput.scss +7 -3
- package/src/components/DocsSidebar/SidebarLabel.astro +25 -4
- package/src/components/DocsSidebar/toTreeNodes.ts +1 -1
- package/src/components/DocsSubHeader/DocsSubHeader.astro +119 -302
- package/src/components/DocsSubHeader/DocsSubHeader.scss +111 -11
- package/src/components/DocsToc/DocsToc.astro +5 -2
- package/src/components/DocsToc/toTreeNodes.ts +1 -1
- package/src/components/DocsTree/DocsTree.astro +9 -0
- package/src/components/DocsTree/docs-tree.scss +139 -118
- package/src/components/GlobalFooter/GlobalFooter.astro +12 -62
- package/src/components/GlobalFooter/README.md +7 -10
- package/src/components/GlobalNavBar/GlobalNavBar.astro +8 -193
- package/src/components/GlobalNavBar/GlobalNavBar.module.scss +16 -6
- package/src/components/GlobalNavBar/README.md +8 -15
- package/src/components/LicenseIndicator/LicenseIndicator.astro +19 -0
- package/src/components/LicenseIndicator/LicenseIndicator.scss +5 -0
- package/src/components/Search/Search.astro +34 -15
- package/src/components/Search/Search.scss +10 -42
- package/src/components/SearchAdvanced/SearchAdvanced.astro +202 -366
- package/src/components/SearchAdvanced/SearchAdvanced.scss +177 -0
- package/src/components/ThemingWidget/ThemingWidget.astro +5 -10
- package/src/components/mdx/ApiRef/README.md +1 -1
- package/src/components/mdx/DocsAside/DocsAside.astro +37 -32
- package/src/components/mdx/DocsAside/DocsAside.scss +123 -35
- package/src/components/mdx/Sample/Sample.astro +55 -45
- package/src/components/mdx/Sample/Sample.scss +173 -30
- package/src/content.config.ts +1 -1
- package/src/integration.ts +25 -141
- package/src/layouts/DocsLayout/DocsLayout.astro +61 -20
- package/src/layouts/DocsLayout/DocsLayout.scss +51 -6
- package/src/lib/nav-helpers.ts +11 -4
- package/src/lib/sidebar/helpers.ts +14 -1
- package/src/lib/sidebar/types.ts +5 -7
- package/src/platform.ts +9 -16
- package/src/plugins/rehype-heading-anchors.ts +74 -0
- package/src/plugins/rehype-table-wrapper.ts +49 -0
- package/src/plugins/remark-docfx.ts +0 -368
- package/src/plugins/remark-env-vars.ts +110 -0
- package/src/plugins/remark-html-transforms.ts +32 -0
- package/src/plugins/remark-md-links.ts +75 -0
- package/src/scripts/sample-widget.ts +107 -116
- package/src/sidebar.ts +6 -7
- package/src/styles/global/_breakpoints.scss +4 -4
- package/src/styles/global/_code-blocks.scss +1 -1
- package/src/styles/global/_component-themes.scss +118 -18
- package/src/styles/global/_index.scss +2 -2
- package/src/styles/global/_markdown.scss +444 -32
- package/src/styles/global/_palette.scss +7 -0
- package/src/styles/global/_search-shared.scss +273 -0
- package/src/styles/global/_variables.scss +58 -3
- package/src/styles/theme.scss +80 -11
- package/src/virtual-modules.d.ts +1 -13
- package/src/assets/icons/copy-clipboard.svg +0 -3
- package/src/assets/icons/filter-clear.svg +0 -1
- package/src/styles/custom.scss +0 -20
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
+
import './SearchAdvanced.scss';
|
|
2
3
|
/**
|
|
3
4
|
* SearchAdvanced
|
|
4
5
|
*
|
|
@@ -50,8 +51,17 @@ export interface Props {
|
|
|
50
51
|
tabs?: SearchTab[];
|
|
51
52
|
/** Maximum results per category shown in the "All" tab. Defaults to 10 */
|
|
52
53
|
allTabLimit?: number;
|
|
54
|
+
/** Current platform key (angular, react, blazor, web-components). Used to show the platform logo in the scope selector. */
|
|
55
|
+
platform?: string;
|
|
53
56
|
}
|
|
54
57
|
|
|
58
|
+
const PLATFORM_ICONS: Record<string, string> = {
|
|
59
|
+
angular: 'angular-logo',
|
|
60
|
+
react: 'react-logo',
|
|
61
|
+
blazor: 'blazor-logo',
|
|
62
|
+
'web-components': 'wc-logo',
|
|
63
|
+
};
|
|
64
|
+
|
|
55
65
|
const {
|
|
56
66
|
class: className,
|
|
57
67
|
indexUrl,
|
|
@@ -59,9 +69,11 @@ const {
|
|
|
59
69
|
showScope = false,
|
|
60
70
|
tabs = [],
|
|
61
71
|
allTabLimit = 10,
|
|
72
|
+
platform = '',
|
|
62
73
|
} = Astro.props;
|
|
63
74
|
|
|
64
|
-
const
|
|
75
|
+
const platformIcon = platform ? (PLATFORM_ICONS[platform] ?? null) : null;
|
|
76
|
+
|
|
65
77
|
// Strip any origin (scheme + host) from BASE_URL so only the path prefix is
|
|
66
78
|
// used. When Astro builds in SSG mode the Node.js process may have
|
|
67
79
|
// process.env.BASE_URL set to a full URL (e.g. "http://localhost:4567") which
|
|
@@ -81,76 +93,58 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
81
93
|
data-tabs={JSON.stringify(tabs)}
|
|
82
94
|
data-all-tab-limit={allTabLimit}
|
|
83
95
|
data-show-scope={showScope ? 'true' : 'false'}
|
|
96
|
+
data-platform-icon={platformIcon ?? ''}
|
|
84
97
|
>
|
|
85
98
|
<button
|
|
86
99
|
data-open-modal
|
|
87
100
|
disabled
|
|
88
101
|
aria-label={placeholder}
|
|
89
102
|
aria-keyshortcuts="Control+K"
|
|
103
|
+
class="search-trigger"
|
|
104
|
+
|
|
90
105
|
>
|
|
91
|
-
<
|
|
92
|
-
<span class="search-
|
|
93
|
-
|
|
94
|
-
|
|
106
|
+
<igc-icon name="search" collection="docs" aria-hidden="true"></igc-icon>
|
|
107
|
+
<span class="search-trigger__lable" aria-hidden="true">{placeholder}</span>
|
|
108
|
+
|
|
109
|
+
<kbd class="search-trigger__hint" style="display: none;">
|
|
110
|
+
<kbd>Ctrl</kbd><kbd>K</kbd>
|
|
95
111
|
</kbd>
|
|
96
112
|
</button>
|
|
97
113
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
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>
|
|
114
|
+
<igc-dialog aria-label={placeholder} class="igd-search-dialog" hide-default-action close-on-outside-click>
|
|
115
|
+
<div class="igd-search-shell">
|
|
116
|
+
<header class="igd-search-header">
|
|
117
|
+
<igc-select slot="prefix" class="igd-search-scope" outlined aria-label="Search scope" value="current">
|
|
118
|
+
{platformIcon && <igc-icon id="search-scope-trigger-icon" name={platformIcon} collection="docs" slot="prefix" aria-hidden="true"></igc-icon>}
|
|
119
|
+
<igc-select-item value="current">
|
|
120
|
+
<span data-scope-label>Current package</span>
|
|
121
|
+
</igc-select-item>
|
|
122
|
+
<igc-select-item value="all">All packages</igc-select-item>
|
|
123
|
+
</igc-select>
|
|
124
|
+
|
|
125
|
+
<igc-divider vertical></igc-divider>
|
|
126
|
+
|
|
127
|
+
<igc-input
|
|
128
|
+
type="text"
|
|
129
|
+
class="igd-search-input"
|
|
130
|
+
placeholder={placeholder}
|
|
131
|
+
autocomplete="off"
|
|
132
|
+
outlined
|
|
133
|
+
aria-label={placeholder}
|
|
134
|
+
>
|
|
135
|
+
<igc-icon name="search" collection="docs" slot="prefix" aria-hidden="true"></igc-icon>
|
|
136
|
+
<igc-icon-button slot="suffix" class="igd-search-clear" variant="flat" type="button" aria-label="Clear search" name="clear" collection="docs" hidden></igc-icon-button>
|
|
137
|
+
</igc-input>
|
|
138
|
+
</header>
|
|
139
|
+
|
|
140
|
+
<div class="igd-search-status" aria-live="polite"></div>
|
|
141
|
+
|
|
142
|
+
<igc-tabs class="igd-search-tabs" activation="manual" hidden></igc-tabs>
|
|
143
|
+
<igc-list class="igd-search-results--flat" hidden></igc-list>
|
|
144
|
+
</div>
|
|
145
|
+
</igc-dialog>
|
|
135
146
|
</api-search-advanced>
|
|
136
147
|
|
|
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
148
|
<script>
|
|
155
149
|
import {
|
|
156
150
|
defineComponents,
|
|
@@ -159,12 +153,14 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
159
153
|
IgcSelectComponent,
|
|
160
154
|
IgcSelectItemComponent,
|
|
161
155
|
IgcIconButtonComponent,
|
|
156
|
+
IgcIconComponent,
|
|
162
157
|
IgcTabsComponent,
|
|
163
158
|
IgcTabComponent,
|
|
164
159
|
IgcListComponent,
|
|
165
160
|
IgcListItemComponent,
|
|
166
|
-
|
|
161
|
+
IgcDividerComponent,
|
|
167
162
|
} from 'igniteui-webcomponents';
|
|
163
|
+
import '../../scripts/icon-registry';
|
|
168
164
|
|
|
169
165
|
defineComponents(
|
|
170
166
|
IgcInputComponent,
|
|
@@ -172,11 +168,12 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
172
168
|
IgcSelectComponent,
|
|
173
169
|
IgcSelectItemComponent,
|
|
174
170
|
IgcIconButtonComponent,
|
|
171
|
+
IgcIconComponent,
|
|
175
172
|
IgcTabsComponent,
|
|
176
173
|
IgcTabComponent,
|
|
177
174
|
IgcListComponent,
|
|
178
175
|
IgcListItemComponent,
|
|
179
|
-
|
|
176
|
+
IgcDividerComponent,
|
|
180
177
|
);
|
|
181
178
|
|
|
182
179
|
type IndexedPage = {
|
|
@@ -238,9 +235,11 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
238
235
|
private input!: IgcInputComponent;
|
|
239
236
|
private clearBtn!: IgcIconButtonComponent;
|
|
240
237
|
private scopeSelect: IgcSelectComponent | null = null;
|
|
238
|
+
private scopeTriggerIcon: HTMLElement | null = null;
|
|
239
|
+
private platformIconName: string = '';
|
|
241
240
|
private tabsEl!: IgcTabsComponent;
|
|
242
241
|
private statusEl!: HTMLElement;
|
|
243
|
-
private
|
|
242
|
+
private flatListEl!: HTMLElement;
|
|
244
243
|
private indexPromise: Promise<IndexedPage[]> | null = null;
|
|
245
244
|
private currentTab: string = 'all';
|
|
246
245
|
private currentMatches: Map<string, Match[]> = new Map();
|
|
@@ -282,12 +281,50 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
282
281
|
|
|
283
282
|
const openBtn = this.querySelector<HTMLButtonElement>('button[data-open-modal]')!;
|
|
284
283
|
this.dialog = this.querySelector<IgcDialogComponent>('igc-dialog')!;
|
|
285
|
-
this.input = this.querySelector<IgcInputComponent>('igc-input.
|
|
286
|
-
this.clearBtn = this.querySelector<IgcIconButtonComponent>('.
|
|
287
|
-
this.scopeSelect = this.querySelector<IgcSelectComponent>('igc-select.
|
|
288
|
-
this.
|
|
289
|
-
this.
|
|
290
|
-
this.
|
|
284
|
+
this.input = this.querySelector<IgcInputComponent>('igc-input.igd-search-input')!;
|
|
285
|
+
this.clearBtn = this.querySelector<IgcIconButtonComponent>('.igd-search-clear')!;
|
|
286
|
+
this.scopeSelect = this.querySelector<IgcSelectComponent>('igc-select.igd-search-scope');
|
|
287
|
+
this.scopeTriggerIcon = this.querySelector('#search-scope-trigger-icon');
|
|
288
|
+
this.platformIconName = this.dataset.platformIcon || '';
|
|
289
|
+
this.tabsEl = this.querySelector<IgcTabsComponent>('igc-tabs.igd-search-tabs')!;
|
|
290
|
+
this.statusEl = this.querySelector<HTMLElement>('.igd-search-status')!;
|
|
291
|
+
this.flatListEl = this.querySelector<HTMLElement>('.igd-search-results--flat')!;
|
|
292
|
+
|
|
293
|
+
// Update the keyboard shortcut hint for the current OS.
|
|
294
|
+
const shortcut = this.querySelector<HTMLElement>('kbd.search-trigger__hint');
|
|
295
|
+
if (shortcut) {
|
|
296
|
+
if (/Mac|iPhone|iPod|iPad/i.test(navigator.userAgent)) {
|
|
297
|
+
const modKey = shortcut.querySelector('kbd');
|
|
298
|
+
if (modKey) modKey.textContent = '\u2318';
|
|
299
|
+
openBtn.setAttribute('aria-keyshortcuts', 'Meta+K');
|
|
300
|
+
}
|
|
301
|
+
shortcut.style.display = '';
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Auto-detect platform icon from the enclosing docs-subheader-menu when not
|
|
305
|
+
// explicitly provided via the `platform` prop.
|
|
306
|
+
if (!this.platformIconName) {
|
|
307
|
+
const subheader = document.querySelector<HTMLElement>('docs-subheader-menu');
|
|
308
|
+
const detectedPlatform = subheader?.dataset.platform || '';
|
|
309
|
+
const ICONS: Record<string, string> = {
|
|
310
|
+
angular: 'angular-logo', react: 'react-logo',
|
|
311
|
+
blazor: 'blazor-logo', 'web-components': 'wc-logo',
|
|
312
|
+
};
|
|
313
|
+
this.platformIconName = ICONS[detectedPlatform] || '';
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
// Dynamically insert the trigger prefix icon when the platform was resolved
|
|
317
|
+
// at runtime (i.e. not server-side rendered via the explicit `platform` prop).
|
|
318
|
+
if (this.platformIconName && this.scopeSelect && !this.scopeTriggerIcon) {
|
|
319
|
+
const triggerIcon = document.createElement('igc-icon') as HTMLElement;
|
|
320
|
+
triggerIcon.id = 'search-scope-trigger-icon';
|
|
321
|
+
triggerIcon.setAttribute('name', this.platformIconName);
|
|
322
|
+
triggerIcon.setAttribute('collection', 'docs');
|
|
323
|
+
triggerIcon.setAttribute('slot', 'prefix');
|
|
324
|
+
triggerIcon.setAttribute('aria-hidden', 'true');
|
|
325
|
+
this.scopeSelect.prepend(triggerIcon);
|
|
326
|
+
this.scopeTriggerIcon = triggerIcon;
|
|
327
|
+
}
|
|
291
328
|
|
|
292
329
|
if (this.showScope) {
|
|
293
330
|
this.detectCurrentContext();
|
|
@@ -308,8 +345,8 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
308
345
|
document.body.toggleAttribute('data-search-modal-open', false);
|
|
309
346
|
});
|
|
310
347
|
|
|
311
|
-
// Close
|
|
312
|
-
this.
|
|
348
|
+
// Close dialog when a result link is clicked — covers both tab panels and the flat list
|
|
349
|
+
this.querySelector<HTMLElement>('.igd-search-shell')!.addEventListener('click', (e) => {
|
|
313
350
|
if ((e.target as Element).closest('a[href]')) {
|
|
314
351
|
this.dialog.hide();
|
|
315
352
|
}
|
|
@@ -329,12 +366,11 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
329
366
|
this.onInput();
|
|
330
367
|
});
|
|
331
368
|
|
|
369
|
+
// Track the active tab — igc-tabs handles content visibility automatically
|
|
332
370
|
this.tabsEl.addEventListener('igcChange', (e) => {
|
|
333
371
|
const tab = (e as CustomEvent<IgcTabComponent>).detail;
|
|
334
372
|
const tabId = (tab as HTMLElement)?.dataset?.tabId || 'all';
|
|
335
|
-
if (tabId === this.currentTab) return;
|
|
336
373
|
this.currentTab = tabId;
|
|
337
|
-
this.renderResults();
|
|
338
374
|
});
|
|
339
375
|
|
|
340
376
|
if (this.scopeSelect) {
|
|
@@ -360,7 +396,12 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
360
396
|
const item = this.scopeSelect.querySelector<HTMLElement & { value: string; disabled: boolean }>('igc-select-item[value="current"]');
|
|
361
397
|
if (!item) return;
|
|
362
398
|
if (this.currentPkg && this.currentVersion) {
|
|
363
|
-
|
|
399
|
+
const labelEl = item.querySelector('[data-scope-label]');
|
|
400
|
+
if (labelEl) {
|
|
401
|
+
labelEl.textContent = `${this.currentPkg} ${this.currentVersion}`;
|
|
402
|
+
} else {
|
|
403
|
+
item.textContent = `${this.currentPkg} ${this.currentVersion}`;
|
|
404
|
+
}
|
|
364
405
|
} else {
|
|
365
406
|
item.disabled = true;
|
|
366
407
|
item.hidden = true;
|
|
@@ -380,23 +421,32 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
380
421
|
}
|
|
381
422
|
|
|
382
423
|
private async fetchIndex(): Promise<IndexedPage[]> {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
424
|
+
let data: unknown;
|
|
425
|
+
try {
|
|
426
|
+
const r = await fetch(this.indexUrl);
|
|
427
|
+
if (!r.ok) return [];
|
|
428
|
+
data = await r.json();
|
|
429
|
+
} catch {
|
|
430
|
+
return [];
|
|
431
|
+
}
|
|
386
432
|
|
|
387
433
|
// Single-file format: { pages: [...] }
|
|
388
|
-
if (Array.isArray(data?.pages)) {
|
|
389
|
-
return data.pages as IndexedPage[];
|
|
434
|
+
if (Array.isArray((data as any)?.pages)) {
|
|
435
|
+
return (data as any).pages as IndexedPage[];
|
|
390
436
|
}
|
|
391
437
|
|
|
392
438
|
// Manifest format: { files: ["pkg/version.json", ...] }
|
|
393
|
-
if (Array.isArray(data?.files)) {
|
|
439
|
+
if (Array.isArray((data as any)?.files)) {
|
|
394
440
|
const baseUrl = this.indexUrl.replace(/[^/]*$/, '');
|
|
395
|
-
const fetches = (data.files as string[]).map(async (file: string) => {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
441
|
+
const fetches: Promise<IndexedPage[]>[] = ((data as any).files as string[]).map(async (file: string) => {
|
|
442
|
+
try {
|
|
443
|
+
const res = await fetch(`${baseUrl}${file}`);
|
|
444
|
+
if (!res.ok) return [];
|
|
445
|
+
const d = await res.json();
|
|
446
|
+
return Array.isArray(d?.pages) ? d.pages as IndexedPage[] : [];
|
|
447
|
+
} catch {
|
|
448
|
+
return [];
|
|
449
|
+
}
|
|
400
450
|
});
|
|
401
451
|
const results = await Promise.all(fetches);
|
|
402
452
|
return results.flat();
|
|
@@ -449,7 +499,9 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
449
499
|
private clearResults() {
|
|
450
500
|
this.statusEl.textContent = '';
|
|
451
501
|
this.tabsEl.hidden = true;
|
|
452
|
-
this.
|
|
502
|
+
this.tabsEl.innerHTML = '';
|
|
503
|
+
this.flatListEl.hidden = true;
|
|
504
|
+
this.flatListEl.innerHTML = '';
|
|
453
505
|
this.currentMatches = new Map();
|
|
454
506
|
}
|
|
455
507
|
|
|
@@ -675,77 +727,84 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
675
727
|
private renderTabs() {
|
|
676
728
|
const totalCount = Array.from(this.currentMatches.values()).reduce((s, l) => s + l.length, 0);
|
|
677
729
|
|
|
678
|
-
//
|
|
730
|
+
// No-categories fallback: hide tabs, render a plain list
|
|
679
731
|
if (this.categories.length === 0) {
|
|
680
732
|
this.tabsEl.hidden = true;
|
|
733
|
+
this.tabsEl.innerHTML = '';
|
|
734
|
+
const list = this.currentMatches.get('__all__') ?? [];
|
|
735
|
+
this.flatListEl.innerHTML = list.map(m => this.matchHtml(m)).join('');
|
|
736
|
+
this.flatListEl.hidden = list.length === 0;
|
|
681
737
|
return;
|
|
682
738
|
}
|
|
683
739
|
|
|
740
|
+
this.flatListEl.hidden = true;
|
|
741
|
+
this.flatListEl.innerHTML = '';
|
|
742
|
+
|
|
743
|
+
// Build each igc-tab with its results embedded in the default slot (tab body)
|
|
684
744
|
const tabsHtml: string[] = [];
|
|
685
|
-
|
|
745
|
+
|
|
746
|
+
// "All" tab — truncated per category with "Show more" buttons
|
|
747
|
+
const allContent: string[] = [];
|
|
686
748
|
for (const cat of this.categories) {
|
|
687
|
-
const
|
|
688
|
-
if (
|
|
689
|
-
|
|
749
|
+
const list = this.currentMatches.get(cat.id) ?? [];
|
|
750
|
+
if (list.length === 0) continue;
|
|
751
|
+
const slice = list.slice(0, this.allTabLimit);
|
|
752
|
+
const items = slice.map(m => this.matchHtml(m)).join('');
|
|
753
|
+
const moreBtn = list.length > slice.length
|
|
754
|
+
? `<igc-button variant="flat" class="igd-search-more-btn" data-tab="${cat.id}">See` +
|
|
755
|
+
` all ${list.length} ${escapeHtml(cat.label.toLowerCase())}` +
|
|
756
|
+
`</igc-button>`
|
|
757
|
+
: '';
|
|
758
|
+
allContent.push(
|
|
759
|
+
`<span class="igd-search-category-header">${escapeHtml(cat.label)}</span>` +
|
|
760
|
+
`<igc-list class="igd-search-results">${items}</igc-list>` +
|
|
761
|
+
moreBtn
|
|
762
|
+
);
|
|
690
763
|
}
|
|
764
|
+
tabsHtml.push(
|
|
765
|
+
`<igc-tab data-tab-id="all" label="All"${this.currentTab === 'all' ? ' selected' : ''}>` +
|
|
766
|
+
`<span slot="suffix" class="igd-search-tab-count">/${totalCount}/</span>` +
|
|
767
|
+
allContent.join('') +
|
|
768
|
+
`</igc-tab>`
|
|
769
|
+
);
|
|
770
|
+
|
|
771
|
+
// Per-category tabs — full result list in each tab body
|
|
772
|
+
for (const cat of this.categories) {
|
|
773
|
+
const list = this.currentMatches.get(cat.id) ?? [];
|
|
774
|
+
if (list.length === 0) continue;
|
|
775
|
+
const isSelected = this.currentTab === cat.id;
|
|
776
|
+
tabsHtml.push(
|
|
777
|
+
`<igc-tab data-tab-id="${cat.id}" label="${escapeHtml(cat.label)}"${isSelected ? ' selected' : ''}>` +
|
|
778
|
+
`<span slot="suffix" class="igd-search-tab-count">/${list.length}/</span>` +
|
|
779
|
+
`<igc-list class="igd-search-results">${list.map(m => this.matchHtml(m)).join('')}</igc-list>` +
|
|
780
|
+
`</igc-tab>`
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
|
|
691
784
|
this.tabsEl.innerHTML = tabsHtml.join('');
|
|
692
785
|
this.tabsEl.hidden = totalCount === 0;
|
|
693
|
-
}
|
|
694
786
|
|
|
695
|
-
|
|
696
|
-
|
|
787
|
+
// Wire "Show more" buttons — select the target tab (its content is already rendered)
|
|
788
|
+
this.tabsEl.querySelectorAll<HTMLButtonElement>('.igd-search-more-btn').forEach((btn) => {
|
|
789
|
+
btn.addEventListener('click', () => {
|
|
790
|
+
const tabId = btn.dataset.tab!;
|
|
791
|
+
this.currentTab = tabId;
|
|
792
|
+
const tabEl = this.tabsEl.querySelector<HTMLElement>(`igc-tab[data-tab-id="${tabId}"]`);
|
|
793
|
+
if (tabEl) this.tabsEl.select(tabEl as any);
|
|
794
|
+
});
|
|
795
|
+
});
|
|
697
796
|
}
|
|
698
797
|
|
|
699
798
|
private renderResults() {
|
|
700
799
|
const totalCount = Array.from(this.currentMatches.values()).reduce((s, l) => s + l.length, 0);
|
|
701
800
|
if (totalCount === 0) {
|
|
702
|
-
this.statusEl.
|
|
703
|
-
? `No results for "
|
|
801
|
+
this.statusEl.innerHTML = this.currentQuery
|
|
802
|
+
? `No results for "<strong class="igd-search-query">${escapeHtml(this.currentQuery)}</strong>".`
|
|
704
803
|
: '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
804
|
} else {
|
|
733
|
-
|
|
734
|
-
for (const m of list) rendered.push(this.matchHtml(m));
|
|
805
|
+
this.statusEl.textContent = '';
|
|
735
806
|
}
|
|
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
|
-
});
|
|
807
|
+
// Content is embedded inside igc-tab bodies by renderTabs(); nothing extra to do here.
|
|
749
808
|
}
|
|
750
809
|
|
|
751
810
|
private matchHtml(m: Match): string {
|
|
@@ -753,13 +812,14 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
753
812
|
const nameCategories = this.categories.filter(c => c.kindCodes.includes('__name__'));
|
|
754
813
|
const isNameMatch = nameCategories.some(c => c.id === m.category);
|
|
755
814
|
const subtitle = isNameMatch || m.category === '__all__'
|
|
756
|
-
? `<span class="
|
|
757
|
-
: `<span class="
|
|
815
|
+
? `<span class="igd-search-kind">${escapeHtml(m.packageLabel)}</span>`
|
|
816
|
+
: `<span class="igd-search-kind">${escapeHtml(m.packageLabel)}</span><span class="igd-search-meta">in ${escapeHtml(m.pageName)}</span>`;
|
|
758
817
|
return `<igc-list-item>
|
|
759
|
-
<a href="${m.url}" class="
|
|
760
|
-
<span class="
|
|
818
|
+
<a href="${m.url}" class="igd-search-link">
|
|
819
|
+
<span class="igd-search-result-title">${highlightedName}</span>
|
|
820
|
+
<span class="igd-search-result-sub">${subtitle}</span>
|
|
761
821
|
</a>
|
|
762
|
-
|
|
822
|
+
|
|
763
823
|
</igc-list-item>`;
|
|
764
824
|
}
|
|
765
825
|
}
|
|
@@ -821,227 +881,3 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
821
881
|
|
|
822
882
|
customElements.define('api-search-advanced', ApiSearchAdvanced);
|
|
823
883
|
</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>
|