igniteui-astro-components 0.0.7 → 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/package.json +4 -2
- 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/DocsTree/DocsTree.astro +9 -0
- package/src/components/DocsTree/docs-tree.scss +139 -118
- package/src/components/GlobalNavBar/GlobalNavBar.module.scss +16 -1
- 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 +182 -355
- package/src/components/SearchAdvanced/SearchAdvanced.scss +177 -0
- 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/integration.ts +7 -0
- package/src/layouts/DocsLayout/DocsLayout.astro +58 -16
- package/src/layouts/DocsLayout/DocsLayout.scss +51 -6
- package/src/lib/sidebar/helpers.ts +14 -1
- package/src/lib/sidebar/types.ts +5 -7
- 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 -0
- package/src/scripts/sample-widget.ts +107 -114
- 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/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;
|
|
@@ -458,7 +499,9 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
458
499
|
private clearResults() {
|
|
459
500
|
this.statusEl.textContent = '';
|
|
460
501
|
this.tabsEl.hidden = true;
|
|
461
|
-
this.
|
|
502
|
+
this.tabsEl.innerHTML = '';
|
|
503
|
+
this.flatListEl.hidden = true;
|
|
504
|
+
this.flatListEl.innerHTML = '';
|
|
462
505
|
this.currentMatches = new Map();
|
|
463
506
|
}
|
|
464
507
|
|
|
@@ -684,77 +727,84 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
684
727
|
private renderTabs() {
|
|
685
728
|
const totalCount = Array.from(this.currentMatches.values()).reduce((s, l) => s + l.length, 0);
|
|
686
729
|
|
|
687
|
-
//
|
|
730
|
+
// No-categories fallback: hide tabs, render a plain list
|
|
688
731
|
if (this.categories.length === 0) {
|
|
689
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;
|
|
690
737
|
return;
|
|
691
738
|
}
|
|
692
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)
|
|
693
744
|
const tabsHtml: string[] = [];
|
|
694
|
-
|
|
745
|
+
|
|
746
|
+
// "All" tab — truncated per category with "Show more" buttons
|
|
747
|
+
const allContent: string[] = [];
|
|
695
748
|
for (const cat of this.categories) {
|
|
696
|
-
const
|
|
697
|
-
if (
|
|
698
|
-
|
|
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
|
+
);
|
|
699
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
|
+
|
|
700
784
|
this.tabsEl.innerHTML = tabsHtml.join('');
|
|
701
785
|
this.tabsEl.hidden = totalCount === 0;
|
|
702
|
-
}
|
|
703
786
|
|
|
704
|
-
|
|
705
|
-
|
|
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
|
+
});
|
|
706
796
|
}
|
|
707
797
|
|
|
708
798
|
private renderResults() {
|
|
709
799
|
const totalCount = Array.from(this.currentMatches.values()).reduce((s, l) => s + l.length, 0);
|
|
710
800
|
if (totalCount === 0) {
|
|
711
|
-
this.statusEl.
|
|
712
|
-
? `No results for "
|
|
801
|
+
this.statusEl.innerHTML = this.currentQuery
|
|
802
|
+
? `No results for "<strong class="igd-search-query">${escapeHtml(this.currentQuery)}</strong>".`
|
|
713
803
|
: 'No results.';
|
|
714
|
-
this.resultsEl.replaceChildren();
|
|
715
|
-
return;
|
|
716
|
-
}
|
|
717
|
-
|
|
718
|
-
this.statusEl.textContent = '';
|
|
719
|
-
|
|
720
|
-
const rendered: string[] = [];
|
|
721
|
-
|
|
722
|
-
if (this.categories.length === 0) {
|
|
723
|
-
// No tabs — render all results in one flat list
|
|
724
|
-
const list = this.currentMatches.get('__all__') ?? [];
|
|
725
|
-
for (const m of list) rendered.push(this.matchHtml(m));
|
|
726
|
-
} else if (this.currentTab === 'all') {
|
|
727
|
-
for (const cat of this.categories) {
|
|
728
|
-
const list = this.currentMatches.get(cat.id) ?? [];
|
|
729
|
-
if (list.length === 0) continue;
|
|
730
|
-
rendered.push(`<igc-list-header>${escapeHtml(cat.label)}</igc-list-header>`);
|
|
731
|
-
const slice = list.slice(0, this.allTabLimit);
|
|
732
|
-
for (const m of slice) rendered.push(this.matchHtml(m));
|
|
733
|
-
if (list.length > slice.length) {
|
|
734
|
-
rendered.push(
|
|
735
|
-
`<igc-list-item class="ig-search-more"><button type="button" class="ig-search-more-btn" data-tab="${cat.id}">
|
|
736
|
-
Show all ${list.length} ${escapeHtml(cat.label.toLowerCase())}
|
|
737
|
-
</button></igc-list-item>`
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
804
|
} else {
|
|
742
|
-
|
|
743
|
-
for (const m of list) rendered.push(this.matchHtml(m));
|
|
805
|
+
this.statusEl.textContent = '';
|
|
744
806
|
}
|
|
745
|
-
|
|
746
|
-
this.resultsEl.innerHTML = rendered.join('');
|
|
747
|
-
|
|
748
|
-
this.resultsEl.querySelectorAll<HTMLButtonElement>('.ig-search-more-btn').forEach((btn) => {
|
|
749
|
-
btn.addEventListener('click', () => {
|
|
750
|
-
const tabId = btn.dataset.tab!;
|
|
751
|
-
this.currentTab = tabId;
|
|
752
|
-
const tabEl = this.tabsEl.querySelector<HTMLElement>(`igc-tab[data-tab-id="${tabId}"]`);
|
|
753
|
-
if (tabEl) this.tabsEl.select(tabEl as any);
|
|
754
|
-
this.renderResults();
|
|
755
|
-
this.resultsEl.scrollTop = 0;
|
|
756
|
-
});
|
|
757
|
-
});
|
|
807
|
+
// Content is embedded inside igc-tab bodies by renderTabs(); nothing extra to do here.
|
|
758
808
|
}
|
|
759
809
|
|
|
760
810
|
private matchHtml(m: Match): string {
|
|
@@ -762,13 +812,14 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
762
812
|
const nameCategories = this.categories.filter(c => c.kindCodes.includes('__name__'));
|
|
763
813
|
const isNameMatch = nameCategories.some(c => c.id === m.category);
|
|
764
814
|
const subtitle = isNameMatch || m.category === '__all__'
|
|
765
|
-
? `<span class="
|
|
766
|
-
: `<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>`;
|
|
767
817
|
return `<igc-list-item>
|
|
768
|
-
<a href="${m.url}" class="
|
|
769
|
-
<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>
|
|
770
821
|
</a>
|
|
771
|
-
|
|
822
|
+
|
|
772
823
|
</igc-list-item>`;
|
|
773
824
|
}
|
|
774
825
|
}
|
|
@@ -830,227 +881,3 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
|
|
|
830
881
|
|
|
831
882
|
customElements.define('api-search-advanced', ApiSearchAdvanced);
|
|
832
883
|
</script>
|
|
833
|
-
|
|
834
|
-
<style>
|
|
835
|
-
api-search-advanced { display: contents; }
|
|
836
|
-
|
|
837
|
-
/* Hide dialog content before web components hydrate (prevents FOUC) */
|
|
838
|
-
igc-dialog:not(:defined) { display: none; }
|
|
839
|
-
|
|
840
|
-
button[data-open-modal] {
|
|
841
|
-
display: flex;
|
|
842
|
-
align-items: center;
|
|
843
|
-
gap: 0.5rem;
|
|
844
|
-
border: 0;
|
|
845
|
-
background-color: transparent;
|
|
846
|
-
color: var(--sl-color-gray-1);
|
|
847
|
-
cursor: pointer;
|
|
848
|
-
height: 2.5rem;
|
|
849
|
-
font-size: var(--sl-text-xl);
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
@media (min-width: 50rem) {
|
|
853
|
-
button[data-open-modal] {
|
|
854
|
-
border: 1px solid var(--sl-color-gray-5);
|
|
855
|
-
border-radius: 0.5rem;
|
|
856
|
-
padding-inline-start: 0.75rem;
|
|
857
|
-
padding-inline-end: 0.5rem;
|
|
858
|
-
background-color: var(--sl-color-black);
|
|
859
|
-
color: var(--sl-color-gray-2);
|
|
860
|
-
font-size: var(--sl-text-sm);
|
|
861
|
-
width: 100%;
|
|
862
|
-
max-width: 22rem;
|
|
863
|
-
}
|
|
864
|
-
button[data-open-modal]:hover {
|
|
865
|
-
border-color: var(--sl-color-gray-2);
|
|
866
|
-
color: var(--sl-color-white);
|
|
867
|
-
}
|
|
868
|
-
button[data-open-modal] > :last-child {
|
|
869
|
-
margin-inline-start: auto;
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
|
|
873
|
-
button > kbd {
|
|
874
|
-
border-radius: 0.25rem;
|
|
875
|
-
font-size: 0.625rem;
|
|
876
|
-
gap: 0.25em;
|
|
877
|
-
padding-inline: 0.375rem;
|
|
878
|
-
background-color: var(--sl-color-gray-6);
|
|
879
|
-
}
|
|
880
|
-
kbd { font-family: inherit; }
|
|
881
|
-
</style>
|
|
882
|
-
|
|
883
|
-
<style is:global>
|
|
884
|
-
/* ── Dialog ──────────────────────────────────────────────────── */
|
|
885
|
-
igc-dialog.ig-search-dialog {
|
|
886
|
-
/* Inherited by ::part(base) (native <dialog>) via igc base CSS */
|
|
887
|
-
background-color: var(--sl-color-bg, #fff);
|
|
888
|
-
color: var(--sl-color-text, inherit);
|
|
889
|
-
border: 1px solid var(--sl-color-gray-5, #ddd);
|
|
890
|
-
}
|
|
891
|
-
igc-dialog.ig-search-dialog::part(base) {
|
|
892
|
-
margin: 0;
|
|
893
|
-
padding: 0;
|
|
894
|
-
width: 100%;
|
|
895
|
-
max-width: 100%;
|
|
896
|
-
height: 100vh;
|
|
897
|
-
max-height: 100vh;
|
|
898
|
-
box-shadow: 0 10px 40px rgba(0,0,0,0.25);
|
|
899
|
-
}
|
|
900
|
-
igc-dialog.ig-search-dialog::part(content) {
|
|
901
|
-
padding: 0;
|
|
902
|
-
display: flex;
|
|
903
|
-
flex-direction: column;
|
|
904
|
-
height: 100%;
|
|
905
|
-
}
|
|
906
|
-
igc-dialog.ig-search-dialog::part(backdrop) {
|
|
907
|
-
background-color: rgba(0,0,0,0.4);
|
|
908
|
-
-webkit-backdrop-filter: blur(0.25rem);
|
|
909
|
-
backdrop-filter: blur(0.25rem);
|
|
910
|
-
}
|
|
911
|
-
@media (min-width: 50rem) {
|
|
912
|
-
igc-dialog.ig-search-dialog {
|
|
913
|
-
border-radius: 0.5rem;
|
|
914
|
-
}
|
|
915
|
-
igc-dialog.ig-search-dialog::part(base) {
|
|
916
|
-
margin: auto;
|
|
917
|
-
width: 90%;
|
|
918
|
-
max-width: 42rem;
|
|
919
|
-
height: calc(100vh - 8rem);
|
|
920
|
-
max-height: 48rem;
|
|
921
|
-
border-radius: 0.5rem;
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
|
|
925
|
-
[data-search-modal-open] { overflow: hidden; }
|
|
926
|
-
|
|
927
|
-
/* ── Shell layout ─────────────────────────────────────────────── */
|
|
928
|
-
.ig-search-shell {
|
|
929
|
-
display: flex;
|
|
930
|
-
flex-direction: column;
|
|
931
|
-
min-height: 0;
|
|
932
|
-
flex: 1 1 auto;
|
|
933
|
-
height: 100%;
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
/* ── Header ───────────────────────────────────────────────────── */
|
|
937
|
-
.ig-search-header {
|
|
938
|
-
padding: 0.75rem 1rem 0.5rem;
|
|
939
|
-
border-bottom: 1px solid var(--sl-color-gray-6, #f0f0f0);
|
|
940
|
-
flex-shrink: 0;
|
|
941
|
-
}
|
|
942
|
-
|
|
943
|
-
/* ── Scope selector (igc-select in prefix slot) ────────────── */
|
|
944
|
-
igc-select.ig-search-scope {
|
|
945
|
-
flex-shrink: 0;
|
|
946
|
-
max-width: 14rem;
|
|
947
|
-
min-width: 8rem;
|
|
948
|
-
}
|
|
949
|
-
@media (max-width: 32rem) {
|
|
950
|
-
igc-select.ig-search-scope { max-width: 9rem; min-width: 6rem; }
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
/* ── Search input (igc-input) ─────────────────────────────────── */
|
|
954
|
-
igc-input.ig-search-input {
|
|
955
|
-
width: 100%;
|
|
956
|
-
}
|
|
957
|
-
|
|
958
|
-
/* Clear icon-button in suffix slot */
|
|
959
|
-
igc-icon-button.ig-search-clear {
|
|
960
|
-
color: var(--sl-color-gray-3, #888);
|
|
961
|
-
}
|
|
962
|
-
igc-icon-button.ig-search-clear:hover {
|
|
963
|
-
color: var(--sl-color-text, inherit);
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
/* ── Tabs (igc-tabs) ──────────────────────────────────────────── */
|
|
967
|
-
igc-tabs.ig-search-tabs {
|
|
968
|
-
flex: 0 0 auto;
|
|
969
|
-
overflow: hidden;
|
|
970
|
-
/* Only show the tab header strip; tab body panels are unused */
|
|
971
|
-
max-height: 2.75rem;
|
|
972
|
-
border-bottom: 1px solid var(--sl-color-gray-6, #f0f0f0);
|
|
973
|
-
}
|
|
974
|
-
.ig-search-tab-count {
|
|
975
|
-
color: var(--sl-color-gray-3, #888);
|
|
976
|
-
font-weight: 400;
|
|
977
|
-
font-size: 0.8rem;
|
|
978
|
-
margin-inline-start: 0.25rem;
|
|
979
|
-
}
|
|
980
|
-
|
|
981
|
-
/* ── Status ───────────────────────────────────────────────────── */
|
|
982
|
-
.ig-search-status {
|
|
983
|
-
padding: 0.5rem 1rem 0;
|
|
984
|
-
color: var(--sl-color-gray-3, #888);
|
|
985
|
-
font-size: 0.875rem;
|
|
986
|
-
min-height: 1.25rem;
|
|
987
|
-
flex-shrink: 0;
|
|
988
|
-
}
|
|
989
|
-
.ig-search-status:empty { padding: 0; min-height: 0; }
|
|
990
|
-
|
|
991
|
-
/* ── Results (igc-list) ───────────────────────────────────────── */
|
|
992
|
-
igc-list.ig-search-results {
|
|
993
|
-
overflow-y: auto;
|
|
994
|
-
flex: 1 1 auto;
|
|
995
|
-
min-height: 0;
|
|
996
|
-
padding: 0.5rem 0.5rem 1rem;
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
igc-list.ig-search-results igc-list-header {
|
|
1000
|
-
font-size: 0.75rem;
|
|
1001
|
-
font-weight: 600;
|
|
1002
|
-
text-transform: uppercase;
|
|
1003
|
-
letter-spacing: 0.05em;
|
|
1004
|
-
color: var(--sl-color-gray-3, #888);
|
|
1005
|
-
}
|
|
1006
|
-
|
|
1007
|
-
.ig-search-link {
|
|
1008
|
-
text-decoration: none;
|
|
1009
|
-
color: inherit;
|
|
1010
|
-
}
|
|
1011
|
-
.ig-search-result-title {
|
|
1012
|
-
font-size: 0.95rem;
|
|
1013
|
-
font-weight: 600;
|
|
1014
|
-
color: var(--sl-color-text, inherit);
|
|
1015
|
-
}
|
|
1016
|
-
.ig-search-result-title mark {
|
|
1017
|
-
background: var(--sl-color-accent-low, rgba(90,62,255,0.18));
|
|
1018
|
-
color: inherit;
|
|
1019
|
-
padding: 0 1px;
|
|
1020
|
-
border-radius: 2px;
|
|
1021
|
-
}
|
|
1022
|
-
.ig-search-result-sub {
|
|
1023
|
-
display: flex;
|
|
1024
|
-
gap: 0.5rem;
|
|
1025
|
-
font-size: 0.8rem;
|
|
1026
|
-
color: var(--sl-color-gray-3, #888);
|
|
1027
|
-
flex-wrap: wrap;
|
|
1028
|
-
}
|
|
1029
|
-
.ig-search-kind {
|
|
1030
|
-
display: inline-block;
|
|
1031
|
-
padding: 0 0.375rem;
|
|
1032
|
-
background: var(--sl-color-gray-1, rgba(0,0,0,0.04));
|
|
1033
|
-
border-radius: 0.25rem;
|
|
1034
|
-
font-size: 0.7rem;
|
|
1035
|
-
letter-spacing: 0.04em;
|
|
1036
|
-
font-weight: 500;
|
|
1037
|
-
}
|
|
1038
|
-
|
|
1039
|
-
.ig-search-more {
|
|
1040
|
-
text-align: center;
|
|
1041
|
-
}
|
|
1042
|
-
.ig-search-more-btn {
|
|
1043
|
-
appearance: none;
|
|
1044
|
-
background: transparent;
|
|
1045
|
-
border: 1px solid var(--sl-color-gray-5, #ddd);
|
|
1046
|
-
border-radius: 0.375rem;
|
|
1047
|
-
padding: 0.4rem 0.9rem;
|
|
1048
|
-
color: var(--sl-color-text, inherit);
|
|
1049
|
-
font-size: 0.85rem;
|
|
1050
|
-
cursor: pointer;
|
|
1051
|
-
}
|
|
1052
|
-
.ig-search-more-btn:hover {
|
|
1053
|
-
border-color: var(--sl-color-accent, #5a3eff);
|
|
1054
|
-
color: var(--sl-color-text-accent, inherit);
|
|
1055
|
-
}
|
|
1056
|
-
</style>
|