igniteui-astro-components 1.3.0 → 1.5.0
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/README.md +112 -2
- package/package.json +22 -20
- package/src/chrome/contract.d.mts +12 -0
- package/src/chrome/contract.mjs +92 -0
- package/src/chrome/integration.ts +173 -0
- package/src/components/DocsSidebar/DocsSidebar.astro +21 -1
- package/src/components/DocsSidebar/DocsSidebar.scss +31 -2
- package/src/components/DocsSidebar/README.md +12 -0
- package/src/components/DocsSidebar/SidebarLabel.astro +1 -1
- package/src/components/DocsSidebar/sidebar-tooltip.ts +174 -0
- package/src/components/DocsTree/DocsTreeItem.astro +9 -3
- package/src/components/DocsTree/README.md +13 -12
- package/src/components/DocsTree/docs-tree.scss +106 -39
- package/src/components/ThemingWidget/README.md +2 -1
- package/src/components/mdx/Sample/README.md +13 -0
- package/src/components/mdx/Sample/Sample.astro +160 -114
- package/src/components/mdx/Sample/Sample.scss +59 -58
- package/src/integration.ts +14 -1
- package/src/layouts/DocsLayout/DocsLayout.astro +56 -8
- package/src/layouts/DocsLayout/README.md +17 -0
- package/src/platform.ts +39 -11
- package/src/scripts/sample-widget.ts +31 -18
- package/src/virtual-modules.d.ts +7 -0
|
@@ -75,6 +75,19 @@ const resolvedSiteTitle = siteTitleProp ?? siteTitle;
|
|
|
75
75
|
const licenseType = license === 'commercial' ? 'premium' : license === 'MIT' ? 'opensource' : false;
|
|
76
76
|
const navTheme = (virtualPlatform ?? import.meta.env.VITE_NAV_THEME ?? 'igniteui') as string;
|
|
77
77
|
const showGlobalNav = navTheme !== 'none';
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* The Infragistics header and footer, chosen per build:
|
|
81
|
+
*
|
|
82
|
+
* 1. `navLang: 'jp'` — the legacy chrome fetched from jp.infragistics.com
|
|
83
|
+
* (GlobalNavBar / GlobalFooter), until a Japanese fragment is published;
|
|
84
|
+
* 2. the site registers igChrome({ snapshot }) — the marketing site's own
|
|
85
|
+
* exported chrome, from the site's snapshot (src/chrome/integration.ts).
|
|
86
|
+
* Nothing is fetched at build or at runtime;
|
|
87
|
+
* 3. otherwise — the legacy fetched chrome, unchanged.
|
|
88
|
+
*/
|
|
89
|
+
const chromeSnapshot =
|
|
90
|
+
navLang !== 'jp' && typeof __IG_CHROME__ !== 'undefined' ? __IG_CHROME__ : null;
|
|
78
91
|
const pageTitle = title ? `${title} | ${resolvedSiteTitle}` : resolvedSiteTitle;
|
|
79
92
|
|
|
80
93
|
type HeadEntry = {
|
|
@@ -103,6 +116,15 @@ type HeadEntry = {
|
|
|
103
116
|
content ? <Tag {...attrs} set:html={content} /> : <Tag {...attrs} />,
|
|
104
117
|
)
|
|
105
118
|
}
|
|
119
|
+
{
|
|
120
|
+
chromeSnapshot && (
|
|
121
|
+
<meta
|
|
122
|
+
name="ig-chrome"
|
|
123
|
+
content={`${chromeSnapshot.contract} build=${chromeSnapshot.build}`}
|
|
124
|
+
/>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
{chromeSnapshot && <Fragment set:html={chromeSnapshot.head} />}
|
|
106
128
|
<slot name="head" />
|
|
107
129
|
<ClientRouter />
|
|
108
130
|
<script is:inline>
|
|
@@ -178,10 +200,16 @@ type HeadEntry = {
|
|
|
178
200
|
});
|
|
179
201
|
});
|
|
180
202
|
|
|
203
|
+
function navChildEl() {
|
|
204
|
+
var root = document.querySelector('[data-astro-transition-persist="global-nav-bar"]');
|
|
205
|
+
if (!root) return null;
|
|
206
|
+
// The synced header sits in a display:contents wrapper with no box of
|
|
207
|
+
// its own, so measure the header element itself.
|
|
208
|
+
return root.querySelector('header.nv') || root.firstElementChild;
|
|
209
|
+
}
|
|
210
|
+
|
|
181
211
|
function updateNavHeight() {
|
|
182
|
-
var navChild =
|
|
183
|
-
'[data-astro-transition-persist="global-nav-bar"] > *:first-child',
|
|
184
|
-
);
|
|
212
|
+
var navChild = navChildEl();
|
|
185
213
|
if (!navChild) return;
|
|
186
214
|
var h = navChild.getBoundingClientRect().height;
|
|
187
215
|
if (h > 0) {
|
|
@@ -193,9 +221,7 @@ type HeadEntry = {
|
|
|
193
221
|
document.addEventListener('astro:page-load', updateNavHeight);
|
|
194
222
|
window.addEventListener('resize', updateNavHeight);
|
|
195
223
|
updateNavHeight();
|
|
196
|
-
var _navChild =
|
|
197
|
-
'[data-astro-transition-persist="global-nav-bar"] > *:first-child',
|
|
198
|
-
);
|
|
224
|
+
var _navChild = navChildEl();
|
|
199
225
|
if (_navChild) new ResizeObserver(updateNavHeight).observe(_navChild);
|
|
200
226
|
|
|
201
227
|
// Clamp sidebar height so it never overlaps the footer.
|
|
@@ -263,7 +289,18 @@ type HeadEntry = {
|
|
|
263
289
|
</head>
|
|
264
290
|
<body>
|
|
265
291
|
<!-- INFRAGISTICS HEADER/NAVIGATION -->
|
|
266
|
-
{
|
|
292
|
+
{
|
|
293
|
+
showGlobalNav &&
|
|
294
|
+
(chromeSnapshot ? (
|
|
295
|
+
/* `.nv` is `position: sticky`, so the wrapper has to be sticky too, or the
|
|
296
|
+
nav would stop at the bottom of a wrapper exactly its own height. */
|
|
297
|
+
<div transition:persist="global-nav-bar" style="position: sticky; top: 0; z-index: 50">
|
|
298
|
+
<Fragment set:html={chromeSnapshot.header} />
|
|
299
|
+
</div>
|
|
300
|
+
) : (
|
|
301
|
+
<GlobalNavBar lang={navLang} />
|
|
302
|
+
))
|
|
303
|
+
}
|
|
267
304
|
|
|
268
305
|
<!-- MAIN PAGE GRID LAYOUT -->
|
|
269
306
|
<!-- We don't set the CSS grid directly to the body -->
|
|
@@ -321,7 +358,18 @@ type HeadEntry = {
|
|
|
321
358
|
|
|
322
359
|
<!-- Footer is inside the grid so the sidebar's sticky containing block extends through it.
|
|
323
360
|
The JS initSidebarHeights() clamps sidebar max-height to prevent visual overlap. -->
|
|
324
|
-
|
|
361
|
+
{
|
|
362
|
+
chromeSnapshot ? (
|
|
363
|
+
/* Full width of the grid, found by initSidebarHeights() through
|
|
364
|
+
data-igd-footer, and persisted across navigations: the exported
|
|
365
|
+
script wires the footer's accordion once, on first load. */
|
|
366
|
+
<div style="grid-column: 1 / -1" data-igd-footer transition:persist="global-footer">
|
|
367
|
+
<Fragment set:html={chromeSnapshot.footer} />
|
|
368
|
+
</div>
|
|
369
|
+
) : (
|
|
370
|
+
<GlobalFooter lang={navLang} />
|
|
371
|
+
)
|
|
372
|
+
}
|
|
325
373
|
</div>
|
|
326
374
|
</body>
|
|
327
375
|
</html>
|
|
@@ -100,6 +100,23 @@ const slug = Astro.params.slug ?? '';
|
|
|
100
100
|
</DocsLayout>
|
|
101
101
|
```
|
|
102
102
|
|
|
103
|
+
## Header and footer
|
|
104
|
+
|
|
105
|
+
`DocsLayout` renders the Infragistics header and footer itself; which one
|
|
106
|
+
depends on the build:
|
|
107
|
+
|
|
108
|
+
| Build | Header / footer |
|
|
109
|
+
| ------------------------------------------- | ---------------------------------------------------------------- |
|
|
110
|
+
| the site registers `igChrome({ snapshot })` | the marketing site's exported chrome, from the site's snapshot |
|
|
111
|
+
| `navLang: 'jp'` | the legacy chrome fetched from `jp.infragistics.com/navigation` |
|
|
112
|
+
| otherwise | the legacy chrome fetched from `www.infragistics.com/navigation` |
|
|
113
|
+
|
|
114
|
+
With a snapshot, the head part goes into `<head>` (with
|
|
115
|
+
`<meta name="ig-chrome" content="v1 build=…">`), the header into the sticky,
|
|
116
|
+
persisted `global-nav-bar` wrapper, and the footer into a full-width grid cell
|
|
117
|
+
with `data-igd-footer`, persisted across navigations. See
|
|
118
|
+
[The Infragistics header and footer](../../../README.md#the-infragistics-header-and-footer).
|
|
119
|
+
|
|
103
120
|
## Virtual module dependencies
|
|
104
121
|
|
|
105
122
|
`DocsLayout` imports from two virtual modules. When using `siteMetaIntegration`
|
package/src/platform.ts
CHANGED
|
@@ -60,6 +60,18 @@ export interface NavConfig {
|
|
|
60
60
|
navUrl: string | null;
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
+
/** The legacy fetched chrome's own CSS. Kept last in IG_STYLES, as before. */
|
|
64
|
+
const IG_LEGACY_CHROME_STYLES: HeadEntry[] = [
|
|
65
|
+
{
|
|
66
|
+
tag: 'link',
|
|
67
|
+
attrs: { rel: 'stylesheet', href: 'https://www.infragistics.com/css/navigation.css' },
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
tag: 'link',
|
|
71
|
+
attrs: { rel: 'stylesheet', href: 'https://www.infragistics.com/css/footer.css' },
|
|
72
|
+
},
|
|
73
|
+
];
|
|
74
|
+
|
|
63
75
|
// ---------------------------------------------------------------------------
|
|
64
76
|
// Shared IG styles — used by: angular, react, blazor, web-components, slingshot
|
|
65
77
|
// ---------------------------------------------------------------------------
|
|
@@ -95,18 +107,12 @@ const IG_STYLES: HeadEntry[] = [
|
|
|
95
107
|
tag: 'link',
|
|
96
108
|
attrs: { rel: 'stylesheet', href: 'https://fonts.googleapis.com/icon?family=Material+Icons' },
|
|
97
109
|
},
|
|
98
|
-
|
|
99
|
-
tag: 'link',
|
|
100
|
-
attrs: { rel: 'stylesheet', href: 'https://www.infragistics.com/css/navigation.css' },
|
|
101
|
-
},
|
|
102
|
-
{
|
|
103
|
-
tag: 'link',
|
|
104
|
-
attrs: { rel: 'stylesheet', href: 'https://www.infragistics.com/css/footer.css' },
|
|
105
|
-
},
|
|
110
|
+
...IG_LEGACY_CHROME_STYLES,
|
|
106
111
|
];
|
|
107
112
|
|
|
108
113
|
// ---------------------------------------------------------------------------
|
|
109
114
|
// Shared IG scripts — used by: angular, react, blazor, web-components, slingshot
|
|
115
|
+
// All three belong to the legacy fetched chrome.
|
|
110
116
|
// ---------------------------------------------------------------------------
|
|
111
117
|
const IG_SCRIPTS: HeadEntry[] = [
|
|
112
118
|
{
|
|
@@ -380,23 +386,45 @@ export const IGDOCS_PLATFORMS: Record<string, PlatformMeta> = {
|
|
|
380
386
|
},
|
|
381
387
|
};
|
|
382
388
|
|
|
389
|
+
/**
|
|
390
|
+
* The legacy fetched chrome's own CSS and JS: navigation.css, footer.css,
|
|
391
|
+
* jQuery 3.1, plugins.nav.js and navigation.js. Only needed where that chrome
|
|
392
|
+
* renders: a site without igChrome(), or a Japanese build. Matched by entry,
|
|
393
|
+
* not by URL, so a changed URL or a cache-busting query cannot slip past it.
|
|
394
|
+
*/
|
|
395
|
+
const LEGACY_CHROME = new Set<HeadEntry>([...IG_LEGACY_CHROME_STYLES, ...IG_SCRIPTS]);
|
|
396
|
+
|
|
397
|
+
export interface PlatformHeadOptions {
|
|
398
|
+
/**
|
|
399
|
+
* Include the legacy fetched chrome's CSS/JS. Default `true`. Pass `false`
|
|
400
|
+
* when the build renders the synced chrome (igChrome) instead.
|
|
401
|
+
*/
|
|
402
|
+
legacyChrome?: boolean;
|
|
403
|
+
}
|
|
404
|
+
|
|
383
405
|
/**
|
|
384
406
|
* Returns an array of head entries for the given platform.
|
|
385
407
|
* Pass the result to `createDocsSite({ head: getPlatformHead(...) })`.
|
|
386
408
|
*
|
|
387
409
|
* @param platform - Platform identifier.
|
|
388
410
|
* @param lang - Locale — not currently used but kept for API completeness.
|
|
411
|
+
* @param options - See PlatformHeadOptions.
|
|
389
412
|
*/
|
|
390
|
-
export function getPlatformHead(
|
|
413
|
+
export function getPlatformHead(
|
|
414
|
+
platform: string,
|
|
415
|
+
_lang = 'en',
|
|
416
|
+
{ legacyChrome = true }: PlatformHeadOptions = {},
|
|
417
|
+
): HeadEntry[] {
|
|
391
418
|
const def = PLATFORM_DEFS[platform as PlatformKey];
|
|
392
419
|
if (!def) {
|
|
393
420
|
console.warn(`[docs-template] Unknown platform "${platform}" — no head entries injected.`);
|
|
394
421
|
return [];
|
|
395
422
|
}
|
|
423
|
+
const keep = (entry: HeadEntry) => legacyChrome || !LEGACY_CHROME.has(entry);
|
|
396
424
|
return [
|
|
397
425
|
{ tag: 'meta', attrs: { property: 'docs:platform', content: platform } },
|
|
398
|
-
...def.styles,
|
|
399
|
-
...def.scripts,
|
|
426
|
+
...def.styles.filter(keep),
|
|
427
|
+
...def.scripts.filter(keep),
|
|
400
428
|
];
|
|
401
429
|
}
|
|
402
430
|
|
|
@@ -252,6 +252,7 @@ function addFooter(
|
|
|
252
252
|
explicitEditor: string | null,
|
|
253
253
|
onStackblitz: (() => void) | null,
|
|
254
254
|
_onCodeSandbox: (() => void) | null,
|
|
255
|
+
showFullscreen = true,
|
|
255
256
|
): void {
|
|
256
257
|
// A footer may already be server-rendered (e.g. the playground's MockSample);
|
|
257
258
|
// don't append a second one.
|
|
@@ -291,26 +292,29 @@ function addFooter(
|
|
|
291
292
|
// footer.appendChild(btn);
|
|
292
293
|
// }
|
|
293
294
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
295
|
+
if (showFullscreen) {
|
|
296
|
+
const fsBtn = document.createElement('igc-icon-button') as HTMLElement;
|
|
297
|
+
fsBtn.setAttribute('name', 'open-external');
|
|
298
|
+
fsBtn.setAttribute('collection', FOOTER_ICON_COLLECTION);
|
|
299
|
+
fsBtn.setAttribute('variant', 'flat');
|
|
300
|
+
fsBtn.setAttribute('aria-label', 'Open in full screen');
|
|
301
|
+
fsBtn.className = 'igd-full-screen-btn igd-edit-in-btn';
|
|
302
|
+
if (iframeSrc) {
|
|
303
|
+
const fullscreenSrc = iframeSrc + (iframeSrc.includes('?') ? '&' : '?') + 'nav=0';
|
|
304
|
+
fsBtn.setAttribute('href', fullscreenSrc);
|
|
305
|
+
fsBtn.setAttribute('target', '_blank');
|
|
306
|
+
}
|
|
307
|
+
actions.appendChild(fsBtn);
|
|
304
308
|
}
|
|
305
|
-
actions.appendChild(
|
|
306
|
-
footer.appendChild(actions);
|
|
309
|
+
if (actions.childElementCount) footer.appendChild(actions);
|
|
307
310
|
|
|
308
311
|
if (themingBar) {
|
|
309
312
|
themingBar.hidden = false;
|
|
310
313
|
footer.appendChild(themingBar);
|
|
311
314
|
}
|
|
312
315
|
|
|
313
|
-
|
|
316
|
+
// Nothing to show (e.g. a `hideCode` sample without a theme picker): no footer.
|
|
317
|
+
if (footer.childElementCount) widget.appendChild(footer);
|
|
314
318
|
}
|
|
315
319
|
|
|
316
320
|
// ─── Angular Code Service ─────────────────────────────────────────────────────
|
|
@@ -629,7 +633,7 @@ function setFitSize(iframe: HTMLIFrameElement, size: { height?: number; width?:
|
|
|
629
633
|
iframe.style.width = `${Math.ceil(size.width)}px`;
|
|
630
634
|
// The frame defaults to full width (see Sample.scss); once the iframe
|
|
631
635
|
// has a definite px width, let the frame shrink-wrap it so the host's
|
|
632
|
-
//
|
|
636
|
+
// alignment (position) can move the content-sized box around.
|
|
633
637
|
const frame = iframe.closest<HTMLElement>('.igd-sample-frame');
|
|
634
638
|
if (frame) frame.style.width = 'auto';
|
|
635
639
|
}
|
|
@@ -641,7 +645,7 @@ function setFitSize(iframe: HTMLIFrameElement, size: { height?: number; width?:
|
|
|
641
645
|
* block-level demo content stretches to the viewport width, so instead we take
|
|
642
646
|
* the right-most element box. Demos with intrinsically sized content (a lone
|
|
643
647
|
* avatar, a button…) shrink the iframe to that content, letting the host's
|
|
644
|
-
*
|
|
648
|
+
* alignment actually center/end-align it. Full-width demos measure the
|
|
645
649
|
* viewport width and are left as-is.
|
|
646
650
|
*
|
|
647
651
|
* Resizable containers are excluded entirely: there the user's drag owns the
|
|
@@ -832,7 +836,7 @@ function wireResizable(container: HTMLElement): void {
|
|
|
832
836
|
const startW = frame.getBoundingClientRect().width;
|
|
833
837
|
// A centered frame grows from both sides, so the handle covers half
|
|
834
838
|
// the width change per pixel moved.
|
|
835
|
-
const factor = getComputedStyle(
|
|
839
|
+
const factor = getComputedStyle(frame).justifySelf === 'center' ? 2 : 1;
|
|
836
840
|
|
|
837
841
|
const onMove = (ev: PointerEvent) => setWidth(startW + (ev.clientX - startX) * factor);
|
|
838
842
|
const onUp = (ev: PointerEvent) => {
|
|
@@ -924,6 +928,8 @@ export function initSampleWidgets(): void {
|
|
|
924
928
|
const demosBaseUrl = widget.dataset.demosBaseUrl || '';
|
|
925
929
|
const githubSrc = widget.dataset.githubSrc || '';
|
|
926
930
|
const platform = normalizePlatform(widget.dataset.platform || 'angular');
|
|
931
|
+
// `hideCode` samples render no tabs: only the demo and the theme picker.
|
|
932
|
+
const hideCode = widget.dataset.hideCode === 'true';
|
|
927
933
|
|
|
928
934
|
if (!iframeSrc) return;
|
|
929
935
|
|
|
@@ -931,7 +937,7 @@ export function initSampleWidgets(): void {
|
|
|
931
937
|
const samplePane = widget.querySelector<HTMLElement>('.igd-sample-container');
|
|
932
938
|
const iframe = widget.querySelector<HTMLIFrameElement>('iframe');
|
|
933
939
|
|
|
934
|
-
if (!igcTabs) return;
|
|
940
|
+
if (!igcTabs && !hideCode) return;
|
|
935
941
|
|
|
936
942
|
const exampleTabId = `${widget.id}-example`;
|
|
937
943
|
|
|
@@ -988,7 +994,7 @@ export function initSampleWidgets(): void {
|
|
|
988
994
|
}
|
|
989
995
|
|
|
990
996
|
// Toggle fullscreen button visibility based on active tab.
|
|
991
|
-
igcTabs
|
|
997
|
+
igcTabs?.addEventListener('igcChange', (e: Event) => {
|
|
992
998
|
const detail = (e as CustomEvent<HTMLElement>).detail;
|
|
993
999
|
const btn = widget.querySelector<HTMLElement>('.igd-full-screen-btn');
|
|
994
1000
|
if (btn) {
|
|
@@ -1033,6 +1039,13 @@ export function initSampleWidgets(): void {
|
|
|
1033
1039
|
}
|
|
1034
1040
|
}
|
|
1035
1041
|
|
|
1042
|
+
// No code to fetch and nothing to live-edit or open in full screen: the
|
|
1043
|
+
// footer carries only the theme picker, right away.
|
|
1044
|
+
if (hideCode || !igcTabs) {
|
|
1045
|
+
addFooter(widget, iframeSrc, null, null, null, false);
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
|
|
1036
1049
|
if (!demosBaseUrl && !isXplatPlatform(platform)) return;
|
|
1037
1050
|
|
|
1038
1051
|
const service = isXplatPlatform(platform)
|
package/src/virtual-modules.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { PlatformContext } from './lib/types.ts';
|
|
2
2
|
|
|
3
3
|
declare global {
|
|
4
|
+
/**
|
|
5
|
+
* The synced marketing chrome, defined at build time by the igChrome()
|
|
6
|
+
* integration (src/chrome/integration.ts). Undeclared when it isn't
|
|
7
|
+
* registered: read it as `typeof __IG_CHROME__ !== 'undefined'`.
|
|
8
|
+
*/
|
|
9
|
+
const __IG_CHROME__: import('./chrome/integration').IgChromeData;
|
|
10
|
+
|
|
4
11
|
namespace App {
|
|
5
12
|
interface Locals {
|
|
6
13
|
platformContext?: PlatformContext;
|