igniteui-astro-components 0.0.16 → 0.0.18

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "igniteui-astro-components",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
4
4
  "description": "Reusable Astro components, layouts, and integrations for Infragistics / Ignite UI documentation sites. Replaces the Starlight defaults with project-specific implementations.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -43,6 +43,7 @@
43
43
  "./components/GlobalNavBar.astro": "./src/components/GlobalNavBar/GlobalNavBar.astro",
44
44
  "./components/GlobalFooter.astro": "./src/components/GlobalFooter/GlobalFooter.astro",
45
45
  "./components/DocsSubHeader.astro": "./src/components/DocsSubHeader/DocsSubHeader.astro",
46
+ "./components/CopyCode.astro": "./src/components/CopyCode/CopyCode.astro",
46
47
  "./components/Search.astro": "./src/components/Search/Search.astro",
47
48
  "./components/SearchAdvanced.astro": "./src/components/SearchAdvanced/SearchAdvanced.astro",
48
49
  "./components/ThemingWidget.astro": "./src/components/ThemingWidget/ThemingWidget.astro",
@@ -120,7 +120,7 @@ const crumbs = sidebarCrumbs.length > 0 ? sidebarCrumbs : (pageTitle ? [pageTitl
120
120
 
121
121
  <div class="igd-logo">
122
122
  <Fragment set:html={logoRaw} />
123
- <h1>{logoText}</h1>
123
+ <span class="igd-logo-text">{logoText}</span>
124
124
  </div>
125
125
 
126
126
  <div class="igd-docs-subheader__content">
@@ -38,11 +38,11 @@
38
38
  }
39
39
  }
40
40
 
41
- > h1 {
41
+ > .igd-logo-text {
42
42
  @include type-style('body-2') {
43
43
  margin: 0;
44
44
  };
45
-
45
+
46
46
  opacity: 1;
47
47
  transition: opacity 200ms ease, transform 200ms ease;
48
48
  }
@@ -61,7 +61,7 @@
61
61
  position: relative;
62
62
  }
63
63
 
64
- h1 {
64
+ .igd-logo-text {
65
65
  opacity: 0;
66
66
  transform: translateY(4px);
67
67
  position: absolute;
@@ -186,7 +186,9 @@ import './Search.scss';
186
186
  }
187
187
  updateSearchHint();
188
188
 
189
- document.getElementById('search-trigger')?.addEventListener('click', () => openSearch());
189
+ document.addEventListener('click', (e: Event) => {
190
+ if ((e.target as Element).closest('#search-trigger')) openSearch();
191
+ });
190
192
 
191
193
  document.addEventListener('keydown', (e: KeyboardEvent) => {
192
194
  if ((e.ctrlKey || e.metaKey) && e.key === 'k') {
@@ -202,26 +204,24 @@ import './Search.scss';
202
204
  });
203
205
 
204
206
  let debounceTimer: ReturnType<typeof setTimeout> | null = null;
205
- document.querySelector('igc-input.igd-search-input')?.addEventListener('igcInput', () => {
207
+ document.addEventListener('igcInput', (e: Event) => {
208
+ if (!(e.target as Element).closest('igc-input.igd-search-input')) return;
206
209
  if (debounceTimer !== null) clearTimeout(debounceTimer);
207
210
  const val = (document.querySelector<any>('igc-input.igd-search-input')?.value as string) ?? '';
208
211
  debounceTimer = setTimeout(() => runSearch(val), INPUT_DEBOUNCE_MS);
209
212
  });
210
213
 
211
- document.querySelector('.igd-search-clear')?.addEventListener('click', () => {
212
- const input = document.querySelector<any>('igc-input.igd-search-input');
213
- if (!input) return;
214
- input.value = '';
215
- input.focus();
216
- runSearch('');
217
- });
218
-
219
- document.querySelector('.igd-search-shell .search-close')?.addEventListener('click', () => {
220
- document.querySelector<any>('igc-dialog.igd-search-dialog')?.hide();
221
- });
222
-
223
- document.querySelector('.igd-search-shell')?.addEventListener('click', (e: Event) => {
224
- if ((e.target as Element).closest('a[href]')) {
214
+ document.addEventListener('click', (e: Event) => {
215
+ const target = e.target as Element;
216
+ if (target.closest('.igd-search-clear')) {
217
+ const input = document.querySelector<any>('igc-input.igd-search-input');
218
+ if (!input) return;
219
+ input.value = '';
220
+ input.focus();
221
+ runSearch('');
222
+ } else if (target.closest('.igd-search-shell .search-close')) {
223
+ document.querySelector<any>('igc-dialog.igd-search-dialog')?.hide();
224
+ } else if (target.closest('.igd-search-shell') && target.closest('a[href]')) {
225
225
  document.querySelector<any>('igc-dialog.igd-search-dialog')?.hide();
226
226
  }
227
227
  });
@@ -255,7 +255,8 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
255
255
  private tabsEl!: IgcTabsComponent;
256
256
  private statusEl!: HTMLElement;
257
257
  private flatListEl!: HTMLElement;
258
- private indexPromise: Promise<IndexedPage[]> | null = null;
258
+ private currentIndexPromise: Promise<IndexedPage[]> | null = null;
259
+ private allIndexPromise: Promise<IndexedPage[]> | null = null;
259
260
  private currentTab: string = 'all';
260
261
  private currentMatches: Map<string, Match[]> = new Map();
261
262
  private currentQuery: string = '';
@@ -395,6 +396,9 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
395
396
  if (this.scopeSelect) {
396
397
  this.scopeSelect.addEventListener('igcChange', () => {
397
398
  this.scope = this.scopeSelect!.value === 'all' ? 'all' : 'current';
399
+ // Start loading the full index as soon as the user switches to 'all'
400
+ // so it is ready when they type (or re-run the current query).
401
+ if (this.scope === 'all') this.loadIndex();
398
402
  if (this.currentQuery) this.runSearch();
399
403
  this.syncScopeTooltip();
400
404
  });
@@ -476,9 +480,24 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
476
480
  }
477
481
 
478
482
  private loadIndex(): Promise<IndexedPage[]> {
479
- if (this.indexPromise) return this.indexPromise;
480
- this.indexPromise = this.fetchIndex();
481
- return this.indexPromise;
483
+ if (this.showScope && this.scope === 'current' && this.currentPkg && this.currentVersion) {
484
+ if (!this.currentIndexPromise) this.currentIndexPromise = this.fetchCurrentVersion();
485
+ return this.currentIndexPromise;
486
+ }
487
+ if (!this.allIndexPromise) this.allIndexPromise = this.fetchIndex();
488
+ return this.allIndexPromise;
489
+ }
490
+
491
+ private async fetchCurrentVersion(): Promise<IndexedPage[]> {
492
+ const baseUrl = this.indexUrl.replace(/[^/]*$/, '');
493
+ try {
494
+ const res = await fetch(`${baseUrl}${this.currentPkg}/${this.currentVersion}.json`);
495
+ if (!res.ok) return [];
496
+ const d = await res.json();
497
+ return Array.isArray(d?.pages) ? d.pages as IndexedPage[] : [];
498
+ } catch {
499
+ return [];
500
+ }
482
501
  }
483
502
 
484
503
  private async fetchIndex(): Promise<IndexedPage[]> {
@@ -536,6 +555,17 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
536
555
  return;
537
556
  }
538
557
 
558
+ // Avoid searching on very short queries — a single or two-character query matches
559
+ // virtually everything and causes the classify + render path to freeze the main thread.
560
+ if (q.length < 3) {
561
+ this.statusEl.textContent = 'Type at least 3 characters to search\u2026';
562
+ this.tabsEl.hidden = true;
563
+ this.tabsEl.innerHTML = '';
564
+ this.flatListEl.hidden = true;
565
+ this.flatListEl.innerHTML = '';
566
+ return;
567
+ }
568
+
539
569
  this.statusEl.textContent = 'Searching\u2026';
540
570
 
541
571
  let pages: IndexedPage[];
@@ -829,15 +859,20 @@ const resolvedIndexUrl = indexUrl ?? `${basePath}api-search-index/manifest.json`
829
859
  `</igc-tab>`
830
860
  );
831
861
 
832
- // Per-category tabs — full result list in each tab body
862
+ // Per-category tabs — capped to avoid freezing the main thread when many
863
+ // results match (e.g. a short query against a large cross-version index).
864
+ const MAX_PER_CATEGORY_TAB = 100;
833
865
  for (const cat of this.categories) {
834
866
  const list = this.currentMatches.get(cat.id) ?? [];
835
867
  if (list.length === 0) continue;
836
868
  const isSelected = this.currentTab === cat.id;
869
+ const displayList = list.slice(0, MAX_PER_CATEGORY_TAB);
870
+ const hasMore = list.length > MAX_PER_CATEGORY_TAB;
837
871
  tabsHtml.push(
838
872
  `<igc-tab data-tab-id="${cat.id}" label="${escapeHtml(cat.label)}"${isSelected ? ' selected' : ''}>` +
839
873
  `<span slot="suffix" class="igd-search-tab-count">/${list.length}/</span>` +
840
- `<igc-list class="igd-search-results">${list.map(m => this.matchHtml(m)).join('')}</igc-list>` +
874
+ `<igc-list class="igd-search-results">${displayList.map(m => this.matchHtml(m)).join('')}</igc-list>` +
875
+ (hasMore ? `<p class="igd-search-refine-hint">Showing first ${MAX_PER_CATEGORY_TAB} of ${list.length} matches &mdash; refine your search to narrow results.</p>` : '') +
841
876
  `</igc-tab>`
842
877
  );
843
878
  }
@@ -108,6 +108,26 @@
108
108
  .igd-search-tab-count {
109
109
  color: light-dark(var(--ig-gray-500), var(--ig-gray-300));
110
110
  }
111
+
112
+ .igd-search-refine-hint {
113
+ @include type-style('caption') {
114
+ margin: 0;
115
+ }
116
+
117
+ padding-inline-start: calc(#{rem(26px)} + #{rem(16px)});
118
+ margin-block-start: rem(16px);
119
+ color: light-dark(var(--ig-gray-600), var(--ig-gray-400));
120
+ }
121
+
122
+ .igd-search-refine-hint {
123
+ @include type-style('caption') {
124
+ margin: 0;
125
+ }
126
+
127
+ padding-inline-start: calc(#{rem(26px)} + #{rem(16px)});
128
+ margin-block-start: rem(16px);
129
+ color: light-dark(var(--ig-gray-600), var(--ig-gray-400));
130
+ }
111
131
 
112
132
  igc-divider {
113
133
  --color: light-dark(var(--ig-gray-400), var(--ig-gray-300));