igniteui-astro-components 0.0.12 → 0.0.13
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.
|
|
3
|
+
"version": "0.0.13",
|
|
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": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* moved to the `DocsBreadcrumb` component, rendered inside the main frame.
|
|
14
14
|
*/
|
|
15
15
|
import { platform as virtualPlatform } from 'virtual:docs-template/nav-html';
|
|
16
|
-
import { productLinks, sidebar as sidebarData, title as siteTitle } from 'virtual:docs-template/site-meta';
|
|
16
|
+
import { productLinks, sidebar as sidebarData, title as siteTitle, packages as virtualPackages, selectedPackage as virtualSelectedPackage } from 'virtual:docs-template/site-meta';
|
|
17
17
|
import Search from '../Search/Search.astro';
|
|
18
18
|
import type { SidebarEntry } from '../../lib/sidebar/types';
|
|
19
19
|
import { getBreadcrumb } from '../../lib/sidebar/helpers';
|
|
@@ -55,9 +55,13 @@ interface Props {
|
|
|
55
55
|
* Defaults to the virtual module value.
|
|
56
56
|
*/
|
|
57
57
|
sidebarItems?: SidebarEntry[];
|
|
58
|
-
/**
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Items for the package/platform selector dropdown. When omitted the selector is hidden.
|
|
60
|
+
* Each entry is either a plain string label, or an object with a `label`, optional `value`
|
|
61
|
+
* (defaults to `label`), and optional `href` to navigate to when selected.
|
|
62
|
+
*/
|
|
63
|
+
packages?: Array<string | { label: string; value?: string; href?: string }>;
|
|
64
|
+
/** Currently selected package value (must match one of `packages`). */
|
|
61
65
|
selectedPackage?: string;
|
|
62
66
|
/** Label rendered before the package selector. Defaults to `'Package'`. */
|
|
63
67
|
packageLabel?: string;
|
|
@@ -85,8 +89,8 @@ const {
|
|
|
85
89
|
siteTitle: siteTitleProp,
|
|
86
90
|
productLinks: productLinksProp,
|
|
87
91
|
sidebarItems,
|
|
88
|
-
packages,
|
|
89
|
-
selectedPackage,
|
|
92
|
+
packages: packagesProp,
|
|
93
|
+
selectedPackage: selectedPackageProp,
|
|
90
94
|
packageLabel = 'Package',
|
|
91
95
|
versions,
|
|
92
96
|
selectedVersion,
|
|
@@ -97,9 +101,15 @@ const {
|
|
|
97
101
|
} = Astro.props;
|
|
98
102
|
const resolvedSiteTitle = siteTitleProp ?? siteTitle;
|
|
99
103
|
const currentPlatform = virtualPlatform ?? null;
|
|
100
|
-
const platformIcon = currentPlatform ? (PLATFORM_ICONS[currentPlatform] ?? null) : null;
|
|
101
104
|
const resolvedLinks = (productLinksProp ?? productLinks) as ProductLink[];
|
|
102
105
|
const filteredLinks = resolvedLinks.filter((l: ProductLink) => l.platform !== currentPlatform);
|
|
106
|
+
type PackageEntry = string | { label: string; value?: string; href?: string };
|
|
107
|
+
const rawPackages = packagesProp ?? (virtualPackages.length > 0 ? virtualPackages : undefined);
|
|
108
|
+
const packages = (rawPackages as PackageEntry[] | undefined)?.map((p: PackageEntry) =>
|
|
109
|
+
typeof p === 'string' ? { label: p, value: p, href: undefined } : { label: p.label, value: p.value ?? p.label, href: p.href }
|
|
110
|
+
);
|
|
111
|
+
const selectedPackage = selectedPackageProp ?? (virtualSelectedPackage || undefined);
|
|
112
|
+
const platformIcon = PLATFORM_ICONS[selectedPackage ?? currentPlatform ?? ''] ?? null;
|
|
103
113
|
|
|
104
114
|
const resolvedSidebar = (sidebarItems ?? sidebarData) as SidebarEntry[];
|
|
105
115
|
const sidebarCrumbs = currentSlug ? getBreadcrumb(resolvedSidebar, currentSlug) : [];
|
|
@@ -119,10 +129,10 @@ const crumbs = sidebarCrumbs.length > 0 ? sidebarCrumbs : (pageTitle ? [pageTitl
|
|
|
119
129
|
|
|
120
130
|
<!-- Package selector (optional) -->
|
|
121
131
|
{packages && packages.length > 0 && (
|
|
122
|
-
<igc-select distance="17"
|
|
132
|
+
<igc-select distance="17" id="package-select" class="igd-package-select" outlined value={selectedPackage} aria-label={packageLabel}>
|
|
123
133
|
{platformIcon && <igc-icon name={platformIcon} collection="docs" slot="prefix" aria-hidden="true"></igc-icon>}
|
|
124
134
|
{packages.map((p) => (
|
|
125
|
-
|
|
135
|
+
<igc-select-item value={p.value} data-href={p.href}>{p.label}</igc-select-item>
|
|
126
136
|
))}
|
|
127
137
|
</igc-select>
|
|
128
138
|
)}
|
|
@@ -180,6 +190,17 @@ const crumbs = sidebarCrumbs.length > 0 ? sidebarCrumbs : (pageTitle ? [pageTitl
|
|
|
180
190
|
if (!customElements.get('docs-subheader-menu')) {
|
|
181
191
|
class DocsSubHeaderMenu extends HTMLElement {
|
|
182
192
|
connectedCallback() {
|
|
193
|
+
// Package selector navigation
|
|
194
|
+
const packageSelect = this.querySelector('#package-select');
|
|
195
|
+
if (packageSelect) {
|
|
196
|
+
packageSelect.addEventListener('igcChange', (e: Event) => {
|
|
197
|
+
const val = (e as CustomEvent).detail?.value ?? (packageSelect as any).value;
|
|
198
|
+
const item = packageSelect.querySelector<HTMLElement>(`igc-select-item[value="${val}"]`);
|
|
199
|
+
const href = item?.dataset?.href;
|
|
200
|
+
if (href) window.location.href = href;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
183
204
|
// Sidebar toggle
|
|
184
205
|
const sidebarBtn = this.querySelector<HTMLButtonElement>('[data-sidebar-toggle]');
|
|
185
206
|
if (sidebarBtn) {
|
|
@@ -243,6 +264,32 @@ const crumbs = sidebarCrumbs.length > 0 ? sidebarCrumbs : (pageTitle ? [pageTitl
|
|
|
243
264
|
this.classList.remove('igd-docs-subheader--pinned');
|
|
244
265
|
});
|
|
245
266
|
}
|
|
267
|
+
|
|
268
|
+
// Close open selects on scroll, and prevent the browser's
|
|
269
|
+
// focus-triggered scrollIntoView from jumping the page when a
|
|
270
|
+
// select is clicked while the user is scrolled down.
|
|
271
|
+
const selectsForScroll = Array.from(
|
|
272
|
+
this.querySelectorAll<HTMLElement>('#package-select, #version-select')
|
|
273
|
+
);
|
|
274
|
+
selectsForScroll.forEach(select => {
|
|
275
|
+
let savedY: number | null = null;
|
|
276
|
+
let guardTimer: ReturnType<typeof setTimeout> | null = null;
|
|
277
|
+
|
|
278
|
+
// pointerdown fires before focus is assigned to save scroll position
|
|
279
|
+
select.addEventListener('pointerdown', () => {
|
|
280
|
+
savedY = window.scrollY;
|
|
281
|
+
if (guardTimer) clearTimeout(guardTimer);
|
|
282
|
+
guardTimer = setTimeout(() => { savedY = null; guardTimer = null; }, 300);
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
window.addEventListener('scroll', () => {
|
|
286
|
+
if (savedY !== null) {
|
|
287
|
+
window.scrollTo({ top: savedY, left: 0, behavior: 'instant' });
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
if ((select as any).open) (select as any).hide();
|
|
291
|
+
}, { passive: true });
|
|
292
|
+
});
|
|
246
293
|
}
|
|
247
294
|
}
|
|
248
295
|
|
|
@@ -251,8 +298,8 @@ const crumbs = sidebarCrumbs.length > 0 ? sidebarCrumbs : (pageTitle ? [pageTitl
|
|
|
251
298
|
</script>
|
|
252
299
|
|
|
253
300
|
<script>
|
|
254
|
-
import { defineComponents, IgcIconComponent, IgcIconButtonComponent } from 'igniteui-webcomponents';
|
|
301
|
+
import { defineComponents, IgcIconComponent, IgcIconButtonComponent, IgcSelectComponent, IgcSelectItemComponent } from 'igniteui-webcomponents';
|
|
255
302
|
import '../../scripts/icon-registry';
|
|
256
|
-
defineComponents(IgcIconComponent, IgcIconButtonComponent);
|
|
303
|
+
defineComponents(IgcIconComponent, IgcIconButtonComponent, IgcSelectComponent, IgcSelectItemComponent);
|
|
257
304
|
</script>
|
|
258
305
|
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
align-items: center;
|
|
76
76
|
height: 100%;
|
|
77
77
|
gap: rem(16px);
|
|
78
|
+
min-width: 0;
|
|
78
79
|
|
|
79
80
|
> igc-select:first-of-type {
|
|
80
81
|
margin-inline-start: auto;
|
|
@@ -85,6 +86,23 @@
|
|
|
85
86
|
}
|
|
86
87
|
}
|
|
87
88
|
|
|
89
|
+
.igd-package-select,
|
|
90
|
+
.igd-version-select {
|
|
91
|
+
flex-shrink: 0;
|
|
92
|
+
position: relative;
|
|
93
|
+
width: fit-content;
|
|
94
|
+
max-width: rem(180px);
|
|
95
|
+
|
|
96
|
+
&::part(base) {
|
|
97
|
+
position: absolute;
|
|
98
|
+
inset-block-start: 100%;
|
|
99
|
+
inset-inline-end: 0;
|
|
100
|
+
width: max-content;
|
|
101
|
+
min-width: 100%;
|
|
102
|
+
z-index: 100;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
88
106
|
// Hidden by default. DocsLayout.scss reveals it on tablet/mobile (when the sidebar is hidden).
|
|
89
107
|
.subheader-sidebar-toggle {
|
|
90
108
|
display: none;
|
|
@@ -35,9 +35,25 @@ export interface Props {
|
|
|
35
35
|
license?: string;
|
|
36
36
|
/** Set to true on 404 pages to add the `igd-page-layout--404` modifier class. */
|
|
37
37
|
is404?: boolean;
|
|
38
|
+
/** Package names for the subheader package selector. When omitted the selector is hidden. */
|
|
39
|
+
packages?: string[];
|
|
40
|
+
/** Currently selected package (must match one of `packages`). */
|
|
41
|
+
selectedPackage?: string;
|
|
42
|
+
/** Label rendered before the package selector. Defaults to `'Package'`. */
|
|
43
|
+
packageLabel?: string;
|
|
44
|
+
/** Version labels for the subheader version selector. When omitted the selector is hidden. */
|
|
45
|
+
versions?: string[];
|
|
46
|
+
/** Currently selected version (must match one of `versions`). */
|
|
47
|
+
selectedVersion?: string;
|
|
48
|
+
/** Label rendered before the version selector. Defaults to `'Version'`. */
|
|
49
|
+
versionLabel?: string;
|
|
50
|
+
/** Show a light/dark theme toggle button in the subheader. */
|
|
51
|
+
showThemeToggle?: boolean;
|
|
52
|
+
/** `localStorage` key for persisting the theme. Defaults to `'docs-theme'`. */
|
|
53
|
+
themeStorageKey?: string;
|
|
38
54
|
}
|
|
39
55
|
|
|
40
|
-
const { title, description, keywords, hasToc = true, hasSidebar = true, currentSlug = '', siteTitle: siteTitleProp, license, is404 = false } = Astro.props;
|
|
56
|
+
const { title, description, keywords, hasToc = true, hasSidebar = true, currentSlug = '', siteTitle: siteTitleProp, license, is404 = false, packages, selectedPackage, packageLabel, versions, selectedVersion, versionLabel, showThemeToggle, themeStorageKey } = Astro.props;
|
|
41
57
|
const resolvedSiteTitle = siteTitleProp ?? siteTitle;
|
|
42
58
|
const licenseType = license === 'commercial' ? 'premium' : license === 'MIT' ? 'opensource' : false;
|
|
43
59
|
const navTheme = (virtualPlatform ?? import.meta.env.VITE_NAV_THEME ?? 'igniteui') as string;
|
|
@@ -224,7 +240,7 @@ type HeadEntry = { tag: string; attrs?: Record<string, string | boolean | undefi
|
|
|
224
240
|
<!-- TODO: WE DONT NEED TO CALCULAtE THE IG HEADER HEIGHT ANYMORE - REMOVE IT -->
|
|
225
241
|
<!-- <DocsSubHeader style={ `--docs-global-nav-height: ${ showGlobalNav ? '4.7rem': '0' }` } data-nav-height-wrapper/> -->
|
|
226
242
|
<slot name="subheader">
|
|
227
|
-
<DocsSubHeader pageTitle={title} currentSlug={currentSlug} siteTitle={siteTitleProp} />
|
|
243
|
+
<DocsSubHeader pageTitle={title} currentSlug={currentSlug} siteTitle={siteTitleProp} packages={packages} selectedPackage={selectedPackage} packageLabel={packageLabel} versions={versions} selectedVersion={selectedVersion} versionLabel={versionLabel} showThemeToggle={showThemeToggle} themeStorageKey={themeStorageKey} />
|
|
228
244
|
</slot>
|
|
229
245
|
|
|
230
246
|
|