igniteui-astro-components 0.0.17 → 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.17",
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": {
@@ -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[]> {