igniteui-astro-components 0.0.7 → 0.0.9

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.
Files changed (54) hide show
  1. package/package.json +4 -2
  2. package/src/assets/icons/open-link-blank.svg +1 -1
  3. package/src/assets/logos/code-sandbox.svg +14 -0
  4. package/src/assets/logos/stackblitz.svg +13 -0
  5. package/src/components/DocsBreadcrumb/DocsBreadcrumb.astro +3 -3
  6. package/src/components/DocsBreadcrumb/DocsBreadcrumb.scss +13 -4
  7. package/src/components/DocsSidebar/DocsSidebar.astro +19 -8
  8. package/src/components/DocsSidebar/DocsSidebar.scss +140 -3
  9. package/src/components/DocsSidebar/SidebarFilterInput.astro +3 -4
  10. package/src/components/DocsSidebar/SidebarFilterInput.scss +9 -6
  11. package/src/components/DocsSidebar/SidebarLabel.astro +25 -4
  12. package/src/components/DocsSidebar/toTreeNodes.ts +1 -1
  13. package/src/components/DocsSubHeader/DocsSubHeader.astro +128 -302
  14. package/src/components/DocsSubHeader/DocsSubHeader.scss +115 -18
  15. package/src/components/DocsToc/DocsToc.astro +15 -7
  16. package/src/components/DocsToc/DocsToc.scss +10 -11
  17. package/src/components/DocsTree/DocsTree.astro +9 -0
  18. package/src/components/DocsTree/docs-tree.scss +146 -118
  19. package/src/components/GlobalNavBar/GlobalNavBar.module.scss +16 -1
  20. package/src/components/LicenseIndicator/LicenseIndicator.astro +19 -0
  21. package/src/components/LicenseIndicator/LicenseIndicator.scss +5 -0
  22. package/src/components/MobileTocToggle/MobileTocToggle.astro +96 -0
  23. package/src/components/MobileTocToggle/MobileTocToggle.scss +74 -0
  24. package/src/components/Search/Search.astro +45 -15
  25. package/src/components/Search/Search.scss +21 -40
  26. package/src/components/SearchAdvanced/SearchAdvanced.astro +196 -355
  27. package/src/components/SearchAdvanced/SearchAdvanced.scss +208 -0
  28. package/src/components/mdx/ApiRef/README.md +1 -1
  29. package/src/components/mdx/DocsAside/DocsAside.astro +37 -32
  30. package/src/components/mdx/DocsAside/DocsAside.scss +106 -35
  31. package/src/components/mdx/Sample/Sample.astro +55 -45
  32. package/src/components/mdx/Sample/Sample.scss +173 -30
  33. package/src/integration.ts +7 -0
  34. package/src/layouts/DocsLayout/DocsLayout.astro +81 -21
  35. package/src/layouts/DocsLayout/DocsLayout.scss +251 -46
  36. package/src/lib/sidebar/helpers.ts +14 -1
  37. package/src/lib/sidebar/types.ts +5 -7
  38. package/src/plugins/rehype-heading-anchors.ts +74 -0
  39. package/src/plugins/rehype-table-wrapper.ts +49 -0
  40. package/src/plugins/remark-docfx.ts +0 -0
  41. package/src/scripts/sample-widget.ts +107 -114
  42. package/src/styles/global/_breakpoints.scss +15 -37
  43. package/src/styles/global/_code-blocks.scss +1 -1
  44. package/src/styles/global/_component-themes.scss +99 -18
  45. package/src/styles/global/_index.scss +2 -2
  46. package/src/styles/global/_markdown.scss +552 -78
  47. package/src/styles/global/_palette.scss +8 -0
  48. package/src/styles/global/_search-shared.scss +272 -0
  49. package/src/styles/global/_type-scale.scss +2 -2
  50. package/src/styles/global/_variables.scss +55 -13
  51. package/src/styles/theme.scss +98 -11
  52. package/src/assets/icons/copy-clipboard.svg +0 -3
  53. package/src/assets/icons/filter-clear.svg +0 -1
  54. 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 ctrlKey = 'Ctrl';
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,69 @@ 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
- <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>
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
- <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>
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 placement="bottom-start" distance="17" 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 class="igd-search-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
+
139
+ <button
140
+ type="button"
141
+ data-close-modal
142
+ class="search-trigger search-close"
143
+ aria-label="Close search"
144
+ >
145
+ <igc-icon name="close" collection="docs" aria-hidden="true"></igc-icon>
146
+ </button>
147
+ </header>
148
+
149
+ <igc-divider></igc-divider>
150
+
151
+ <div class="igd-search-status" aria-live="polite"></div>
152
+
153
+ <igc-tabs class="igd-search-tabs" activation="manual" hidden></igc-tabs>
154
+ <igc-list class="igd-search-results--flat" hidden></igc-list>
155
+ </div>
156
+ </igc-dialog>
135
157
  </api-search-advanced>
136
158
 
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
159
  <script>
155
160
  import {
156
161
  defineComponents,
@@ -159,12 +164,14 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
159
164
  IgcSelectComponent,
160
165
  IgcSelectItemComponent,
161
166
  IgcIconButtonComponent,
167
+ IgcIconComponent,
162
168
  IgcTabsComponent,
163
169
  IgcTabComponent,
164
170
  IgcListComponent,
165
171
  IgcListItemComponent,
166
- IgcListHeaderComponent,
172
+ IgcDividerComponent,
167
173
  } from 'igniteui-webcomponents';
174
+ import '../../scripts/icon-registry';
168
175
 
169
176
  defineComponents(
170
177
  IgcInputComponent,
@@ -172,11 +179,12 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
172
179
  IgcSelectComponent,
173
180
  IgcSelectItemComponent,
174
181
  IgcIconButtonComponent,
182
+ IgcIconComponent,
175
183
  IgcTabsComponent,
176
184
  IgcTabComponent,
177
185
  IgcListComponent,
178
186
  IgcListItemComponent,
179
- IgcListHeaderComponent,
187
+ IgcDividerComponent,
180
188
  );
181
189
 
182
190
  type IndexedPage = {
@@ -238,9 +246,11 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
238
246
  private input!: IgcInputComponent;
239
247
  private clearBtn!: IgcIconButtonComponent;
240
248
  private scopeSelect: IgcSelectComponent | null = null;
249
+ private scopeTriggerIcon: HTMLElement | null = null;
250
+ private platformIconName: string = '';
241
251
  private tabsEl!: IgcTabsComponent;
242
252
  private statusEl!: HTMLElement;
243
- private resultsEl!: HTMLElement;
253
+ private flatListEl!: HTMLElement;
244
254
  private indexPromise: Promise<IndexedPage[]> | null = null;
245
255
  private currentTab: string = 'all';
246
256
  private currentMatches: Map<string, Match[]> = new Map();
@@ -281,13 +291,52 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
281
291
  }
282
292
 
283
293
  const openBtn = this.querySelector<HTMLButtonElement>('button[data-open-modal]')!;
294
+ const closeBtn = this.querySelector<HTMLButtonElement>('button[data-close-modal]')!;
284
295
  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')!;
296
+ this.input = this.querySelector<IgcInputComponent>('igc-input.igd-search-input')!;
297
+ this.clearBtn = this.querySelector<IgcIconButtonComponent>('.igd-search-clear')!;
298
+ this.scopeSelect = this.querySelector<IgcSelectComponent>('igc-select.igd-search-scope');
299
+ this.scopeTriggerIcon = this.querySelector('#search-scope-trigger-icon');
300
+ this.platformIconName = this.dataset.platformIcon || '';
301
+ this.tabsEl = this.querySelector<IgcTabsComponent>('igc-tabs.igd-search-tabs')!;
302
+ this.statusEl = this.querySelector<HTMLElement>('.igd-search-status')!;
303
+ this.flatListEl = this.querySelector<HTMLElement>('.igd-search-results--flat')!;
304
+
305
+ // Update the keyboard shortcut hint for the current OS.
306
+ const shortcut = this.querySelector<HTMLElement>('kbd.search-trigger__hint');
307
+ if (shortcut) {
308
+ if (/Mac|iPhone|iPod|iPad/i.test(navigator.userAgent)) {
309
+ const modKey = shortcut.querySelector('kbd');
310
+ if (modKey) modKey.textContent = '\u2318';
311
+ openBtn.setAttribute('aria-keyshortcuts', 'Meta+K');
312
+ }
313
+ shortcut.style.display = '';
314
+ }
315
+
316
+ // Auto-detect platform icon from the enclosing docs-subheader-menu when not
317
+ // explicitly provided via the `platform` prop.
318
+ if (!this.platformIconName) {
319
+ const subheader = document.querySelector<HTMLElement>('docs-subheader-menu');
320
+ const detectedPlatform = subheader?.dataset.platform || '';
321
+ const ICONS: Record<string, string> = {
322
+ angular: 'angular-logo', react: 'react-logo',
323
+ blazor: 'blazor-logo', 'web-components': 'wc-logo',
324
+ };
325
+ this.platformIconName = ICONS[detectedPlatform] || '';
326
+ }
327
+
328
+ // Dynamically insert the trigger prefix icon when the platform was resolved
329
+ // at runtime (i.e. not server-side rendered via the explicit `platform` prop).
330
+ if (this.platformIconName && this.scopeSelect && !this.scopeTriggerIcon) {
331
+ const triggerIcon = document.createElement('igc-icon') as HTMLElement;
332
+ triggerIcon.id = 'search-scope-trigger-icon';
333
+ triggerIcon.setAttribute('name', this.platformIconName);
334
+ triggerIcon.setAttribute('collection', 'docs');
335
+ triggerIcon.setAttribute('slot', 'prefix');
336
+ triggerIcon.setAttribute('aria-hidden', 'true');
337
+ this.scopeSelect.prepend(triggerIcon);
338
+ this.scopeTriggerIcon = triggerIcon;
339
+ }
291
340
 
292
341
  if (this.showScope) {
293
342
  this.detectCurrentContext();
@@ -304,12 +353,14 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
304
353
  openBtn.addEventListener('click', open);
305
354
  openBtn.disabled = false;
306
355
 
356
+ closeBtn.addEventListener('click', () => this.closeModal());
357
+
307
358
  this.dialog.addEventListener('igcClosed', () => {
308
359
  document.body.toggleAttribute('data-search-modal-open', false);
309
360
  });
310
361
 
311
- // Close on result-link click (navigation)
312
- this.resultsEl.addEventListener('click', (e) => {
362
+ // Close dialog when a result link is clicked — covers both tab panels and the flat list
363
+ this.querySelector<HTMLElement>('.igd-search-shell')!.addEventListener('click', (e) => {
313
364
  if ((e.target as Element).closest('a[href]')) {
314
365
  this.dialog.hide();
315
366
  }
@@ -329,12 +380,11 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
329
380
  this.onInput();
330
381
  });
331
382
 
383
+ // Track the active tab — igc-tabs handles content visibility automatically
332
384
  this.tabsEl.addEventListener('igcChange', (e) => {
333
385
  const tab = (e as CustomEvent<IgcTabComponent>).detail;
334
386
  const tabId = (tab as HTMLElement)?.dataset?.tabId || 'all';
335
- if (tabId === this.currentTab) return;
336
387
  this.currentTab = tabId;
337
- this.renderResults();
338
388
  });
339
389
 
340
390
  if (this.scopeSelect) {
@@ -360,7 +410,12 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
360
410
  const item = this.scopeSelect.querySelector<HTMLElement & { value: string; disabled: boolean }>('igc-select-item[value="current"]');
361
411
  if (!item) return;
362
412
  if (this.currentPkg && this.currentVersion) {
363
- item.textContent = `${this.currentPkg} ${this.currentVersion}`;
413
+ const labelEl = item.querySelector('[data-scope-label]');
414
+ if (labelEl) {
415
+ labelEl.textContent = `${this.currentPkg} ${this.currentVersion}`;
416
+ } else {
417
+ item.textContent = `${this.currentPkg} ${this.currentVersion}`;
418
+ }
364
419
  } else {
365
420
  item.disabled = true;
366
421
  item.hidden = true;
@@ -458,7 +513,9 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
458
513
  private clearResults() {
459
514
  this.statusEl.textContent = '';
460
515
  this.tabsEl.hidden = true;
461
- this.resultsEl.innerHTML = '';
516
+ this.tabsEl.innerHTML = '';
517
+ this.flatListEl.hidden = true;
518
+ this.flatListEl.innerHTML = '';
462
519
  this.currentMatches = new Map();
463
520
  }
464
521
 
@@ -684,77 +741,84 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
684
741
  private renderTabs() {
685
742
  const totalCount = Array.from(this.currentMatches.values()).reduce((s, l) => s + l.length, 0);
686
743
 
687
- // If no categories configured, don't render tabs
744
+ // No-categories fallback: hide tabs, render a plain list
688
745
  if (this.categories.length === 0) {
689
746
  this.tabsEl.hidden = true;
747
+ this.tabsEl.innerHTML = '';
748
+ const list = this.currentMatches.get('__all__') ?? [];
749
+ this.flatListEl.innerHTML = list.map(m => this.matchHtml(m)).join('');
750
+ this.flatListEl.hidden = list.length === 0;
690
751
  return;
691
752
  }
692
753
 
754
+ this.flatListEl.hidden = true;
755
+ this.flatListEl.innerHTML = '';
756
+
757
+ // Build each igc-tab with its results embedded in the default slot (tab body)
693
758
  const tabsHtml: string[] = [];
694
- tabsHtml.push(this.tabHtml('all', 'All', totalCount, this.currentTab === 'all'));
759
+
760
+ // "All" tab — truncated per category with "Show more" buttons
761
+ const allContent: string[] = [];
695
762
  for (const cat of this.categories) {
696
- const count = this.currentMatches.get(cat.id)?.length ?? 0;
697
- if (count === 0) continue;
698
- tabsHtml.push(this.tabHtml(cat.id, cat.label, count, this.currentTab === cat.id));
763
+ const list = this.currentMatches.get(cat.id) ?? [];
764
+ if (list.length === 0) continue;
765
+ const slice = list.slice(0, this.allTabLimit);
766
+ const items = slice.map(m => this.matchHtml(m)).join('');
767
+ const moreBtn = list.length > slice.length
768
+ ? `<igc-button variant="flat" class="igd-search-more-btn" data-tab="${cat.id}">See` +
769
+ ` all ${list.length} ${escapeHtml(cat.label.toLowerCase())}` +
770
+ `</igc-button>`
771
+ : '';
772
+ allContent.push(
773
+ `<span class="igd-search-category-header">${escapeHtml(cat.label)}</span>` +
774
+ `<igc-list class="igd-search-results">${items}</igc-list>` +
775
+ moreBtn + `<igc-divider></igc-divider>`
776
+ );
699
777
  }
778
+ tabsHtml.push(
779
+ `<igc-tab data-tab-id="all" label="All"${this.currentTab === 'all' ? ' selected' : ''}>` +
780
+ `<span slot="suffix" class="igd-search-tab-count">/${totalCount}/</span>` +
781
+ allContent.join('') +
782
+ `</igc-tab>`
783
+ );
784
+
785
+ // Per-category tabs — full result list in each tab body
786
+ for (const cat of this.categories) {
787
+ const list = this.currentMatches.get(cat.id) ?? [];
788
+ if (list.length === 0) continue;
789
+ const isSelected = this.currentTab === cat.id;
790
+ tabsHtml.push(
791
+ `<igc-tab data-tab-id="${cat.id}" label="${escapeHtml(cat.label)}"${isSelected ? ' selected' : ''}>` +
792
+ `<span slot="suffix" class="igd-search-tab-count">/${list.length}/</span>` +
793
+ `<igc-list class="igd-search-results">${list.map(m => this.matchHtml(m)).join('')}</igc-list>` +
794
+ `</igc-tab>`
795
+ );
796
+ }
797
+
700
798
  this.tabsEl.innerHTML = tabsHtml.join('');
701
799
  this.tabsEl.hidden = totalCount === 0;
702
- }
703
800
 
704
- private tabHtml(id: string, label: string, count: number, selected: boolean): string {
705
- return `<igc-tab data-tab-id="${id}" label="${escapeHtml(label)}"${selected ? ' selected' : ''}><span slot="suffix" class="ig-search-tab-count">${count}</span></igc-tab>`;
801
+ // Wire "Show more" buttons — select the target tab (its content is already rendered)
802
+ this.tabsEl.querySelectorAll<HTMLButtonElement>('.igd-search-more-btn').forEach((btn) => {
803
+ btn.addEventListener('click', () => {
804
+ const tabId = btn.dataset.tab!;
805
+ this.currentTab = tabId;
806
+ const tabEl = this.tabsEl.querySelector<HTMLElement>(`igc-tab[data-tab-id="${tabId}"]`);
807
+ if (tabEl) this.tabsEl.select(tabEl as any);
808
+ });
809
+ });
706
810
  }
707
811
 
708
812
  private renderResults() {
709
813
  const totalCount = Array.from(this.currentMatches.values()).reduce((s, l) => s + l.length, 0);
710
814
  if (totalCount === 0) {
711
- this.statusEl.textContent = this.currentQuery
712
- ? `No results for "${this.currentQuery}".`
815
+ this.statusEl.innerHTML = this.currentQuery
816
+ ? `No results for "<strong class="igd-search-query">${escapeHtml(this.currentQuery)}</strong>".`
713
817
  : '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
818
  } else {
742
- const list = this.currentMatches.get(this.currentTab) ?? [];
743
- for (const m of list) rendered.push(this.matchHtml(m));
819
+ this.statusEl.textContent = '';
744
820
  }
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
- });
821
+ // Content is embedded inside igc-tab bodies by renderTabs(); nothing extra to do here.
758
822
  }
759
823
 
760
824
  private matchHtml(m: Match): string {
@@ -762,13 +826,14 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
762
826
  const nameCategories = this.categories.filter(c => c.kindCodes.includes('__name__'));
763
827
  const isNameMatch = nameCategories.some(c => c.id === m.category);
764
828
  const subtitle = isNameMatch || m.category === '__all__'
765
- ? `<span class="ig-search-kind">${escapeHtml(m.packageLabel)}</span>`
766
- : `<span class="ig-search-kind">${escapeHtml(m.packageLabel)}</span><span class="ig-search-meta">in ${escapeHtml(m.pageName)}</span>`;
829
+ ? `<span class="igd-search-kind">${escapeHtml(m.packageLabel)}</span>`
830
+ : `<span class="igd-search-kind">${escapeHtml(m.packageLabel)}</span><span class="igd-search-meta">in ${escapeHtml(m.pageName)}</span>`;
767
831
  return `<igc-list-item>
768
- <a href="${m.url}" class="ig-search-link" slot="title">
769
- <span class="ig-search-result-title">${highlightedName}</span>
832
+ <a href="${m.url}" class="igd-search-link">
833
+ <span class="igd-search-result-title">${highlightedName}</span>
834
+ <span class="igd-search-result-sub">${subtitle}</span>
770
835
  </a>
771
- <span slot="subtitle" class="ig-search-result-sub">${subtitle}</span>
836
+
772
837
  </igc-list-item>`;
773
838
  }
774
839
  }
@@ -830,227 +895,3 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
830
895
 
831
896
  customElements.define('api-search-advanced', ApiSearchAdvanced);
832
897
  </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>