igniteui-astro-components 1.5.1 → 1.7.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 +1 -0
- package/package.json +5 -2
- package/src/assets/icons/check-bold.svg +3 -0
- package/src/assets/icons/clear-bold.svg +3 -0
- package/src/components/DocsSidebar/DocsSidebar.astro +23 -20
- package/src/components/DocsSidebar/sidebar-filter.ts +53 -5
- package/src/components/DocsSidebar/toTreeNodes.ts +21 -5
- package/src/components/DocsSubHeader/DocsSubHeader.astro +75 -69
- package/src/components/DocsSubHeader/README.md +14 -1
- package/src/components/mdx/ApiLink/ApiLink.astro +5 -0
- package/src/components/mdx/DoDont/DoDont.astro +332 -0
- package/src/components/mdx/DoDont/DoDont.scss +247 -0
- package/src/components/mdx/DoDont/README.md +134 -0
- package/src/layouts/DocsLayout/DocsLayout.astro +27 -35
- package/src/lib/types.ts +8 -1
- package/src/lib/ultimate-ui-platforms.ts +10 -0
- package/src/llms.ts +4 -3
- package/src/platform.ts +55 -3
- package/src/plugins/remark-env-vars.ts +2 -0
- package/src/scripts/sample-widget.ts +58 -16
- package/src/virtual-modules.d.ts +3 -1
package/README.md
CHANGED
|
@@ -268,6 +268,7 @@ const sidebar: SidebarEntry[] = [/* … your tree … */];
|
|
|
268
268
|
| -------------------------------------- | ----------------------------------------------------- | ---------------------------------------------------- |
|
|
269
269
|
| `…/components/mdx/ApiLink.astro` | Inline link to an API symbol with platform-aware URLs | [README](src/components/mdx/ApiLink/README.md) |
|
|
270
270
|
| `…/components/mdx/ApiRef.astro` | Block API reference card | [README](src/components/mdx/ApiRef/README.md) |
|
|
271
|
+
| `…/components/mdx/DoDont.astro` | Side-by-side Do / Don't image guidance panels | [README](src/components/mdx/DoDont/README.md) |
|
|
271
272
|
| `…/components/mdx/PlatformBlock.astro` | Show content only on selected platforms | [README](src/components/mdx/PlatformBlock/README.md) |
|
|
272
273
|
| `…/components/mdx/Sample.astro` | Embedded code-view sample widget | [README](src/components/mdx/Sample/README.md) |
|
|
273
274
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "igniteui-astro-components",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.0",
|
|
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": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"author": "Infragistics",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/IgniteUI/igniteui-astro-components"
|
|
13
|
+
"url": "git+https://github.com/IgniteUI/igniteui-astro-components.git"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"astro",
|
|
@@ -66,6 +66,7 @@
|
|
|
66
66
|
"./components/mdx/ApiRef.astro": "./src/components/mdx/ApiRef/ApiRef.astro",
|
|
67
67
|
"./components/mdx/ApiLink.astro": "./src/components/mdx/ApiLink/ApiLink.astro",
|
|
68
68
|
"./components/mdx/DocsAside.astro": "./src/components/mdx/DocsAside/DocsAside.astro",
|
|
69
|
+
"./components/mdx/DoDont.astro": "./src/components/mdx/DoDont/DoDont.astro",
|
|
69
70
|
"./components/mdx/Badge.astro": "./src/components/mdx/Badge/Badge.astro",
|
|
70
71
|
"./components/mdx/Faq.astro": "./src/components/mdx/Faq/Faq.astro",
|
|
71
72
|
"./components/mdx/FaqItem.astro": "./src/components/mdx/Faq/FaqItem.astro",
|
|
@@ -118,6 +119,8 @@
|
|
|
118
119
|
"access": "public"
|
|
119
120
|
},
|
|
120
121
|
"scripts": {
|
|
122
|
+
"test": "node --test \"scripts/**/*.test.mjs\"",
|
|
123
|
+
"test:sample-widget": "node --test scripts/sample-widget.test.mjs",
|
|
121
124
|
"playground": "npm run playground:dev",
|
|
122
125
|
"playground:dev": "astro sync --root playground && astro dev --root playground --port 4567",
|
|
123
126
|
"playground:build": "astro sync --root playground && astro build --root playground",
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
trailingSlash as configuredTrailingSlash,
|
|
14
14
|
} from 'virtual:docs-template/site-meta';
|
|
15
15
|
import { platform as virtualPlatform } from 'virtual:docs-template/nav-html';
|
|
16
|
+
import { ULTIMATE_UI_PLATFORMS, platformLabelFor } from '../../platform';
|
|
16
17
|
import SidebarFilterInput from './SidebarFilterInput.astro';
|
|
17
18
|
import './DocsSidebar.scss';
|
|
18
19
|
import SidebarLabel from './SidebarLabel.astro';
|
|
@@ -36,42 +37,45 @@ interface Props {
|
|
|
36
37
|
* (exposed via the virtual module). Falls back to `true` if not configured.
|
|
37
38
|
*/
|
|
38
39
|
trailingSlash?: boolean;
|
|
39
|
-
/** Logo text shown in the slide-in sidebar
|
|
40
|
+
/** Logo text shown in the slide-in sidebar. Defaults to the current product family. */
|
|
40
41
|
logoText?: string;
|
|
41
42
|
/** Platform label shown below logoText (e.g. 'Angular'). Auto-detected from virtual module when omitted. */
|
|
42
43
|
platformLabel?: string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Keep one branch of the tree open at a time: only the current page's
|
|
46
|
+
* groups are open on load, and expanding a group collapses the others.
|
|
47
|
+
* The filter still opens every group with a match. Defaults to true.
|
|
48
|
+
*/
|
|
49
|
+
singleBranchExpand?: boolean;
|
|
43
50
|
}
|
|
44
51
|
|
|
45
|
-
const PLATFORM_LABELS: Record<string, string> = {
|
|
46
|
-
angular: 'Angular',
|
|
47
|
-
react: 'React',
|
|
48
|
-
blazor: 'Blazor',
|
|
49
|
-
'web-components': 'Web Components',
|
|
50
|
-
};
|
|
51
|
-
|
|
52
52
|
const useTrailingSlash = configuredTrailingSlash !== 'never';
|
|
53
53
|
const {
|
|
54
54
|
currentSlug = '',
|
|
55
55
|
items: itemsProp,
|
|
56
56
|
showFilter = true,
|
|
57
57
|
trailingSlash = useTrailingSlash,
|
|
58
|
-
logoText = 'Ignite UI',
|
|
59
|
-
platformLabel =
|
|
58
|
+
logoText = ULTIMATE_UI_PLATFORMS.has(virtualPlatform ?? '') ? 'Ultimate UI' : 'Ignite UI',
|
|
59
|
+
platformLabel = platformLabelFor(virtualPlatform),
|
|
60
|
+
singleBranchExpand = true,
|
|
60
61
|
} = Astro.props;
|
|
61
62
|
const items = (itemsProp ?? sidebarData) as SidebarEntry[];
|
|
62
|
-
const nodes = toTreeNodes(items, currentSlug, { trailingSlash });
|
|
63
|
+
const nodes = toTreeNodes(items, currentSlug, { trailingSlash, singleBranch: singleBranchExpand });
|
|
63
64
|
const activeId = normalizeSlug(currentSlug);
|
|
64
65
|
---
|
|
65
66
|
|
|
66
|
-
<sidebar-filter
|
|
67
|
+
<sidebar-filter
|
|
68
|
+
class="docs-sidebar"
|
|
69
|
+
id="docs-sidebar"
|
|
70
|
+
data-no-results="No topics match"
|
|
71
|
+
data-single-branch-expand={singleBranchExpand ? '' : undefined}
|
|
72
|
+
>
|
|
67
73
|
<div class="igd-sidebar-logo">
|
|
68
74
|
{/* Keep as <span>, not <h1> — avoids competing with the page <h1> in search. */}
|
|
69
75
|
<span class="igd-logo-text">{logoText}</span>
|
|
70
76
|
{platformLabel && <span class="igd-logo__platform">for {platformLabel}</span>}
|
|
71
77
|
</div>
|
|
72
|
-
<div class="sidebar-gutter">
|
|
73
|
-
{showFilter && <SidebarFilterInput />}
|
|
74
|
-
</div>
|
|
78
|
+
<div class="sidebar-gutter">{showFilter && <SidebarFilterInput />}</div>
|
|
75
79
|
<div class="sidebar-scroll" data-sidebar-scroll>
|
|
76
80
|
<DocsTree
|
|
77
81
|
nodes={nodes}
|
|
@@ -82,18 +86,17 @@ const activeId = normalizeSlug(currentSlug);
|
|
|
82
86
|
renderLabel={SidebarLabel}
|
|
83
87
|
/>
|
|
84
88
|
</div>
|
|
85
|
-
{
|
|
86
|
-
/* Shared tooltip showing the full text of a truncated (line-clamped) label.
|
|
89
|
+
{/* Shared tooltip showing the full text of a truncated (line-clamped) label.
|
|
87
90
|
Anchored at runtime to the hovered/focused row by sidebar-tooltip.ts, which
|
|
88
|
-
also owns show/hide — hence the empty trigger lists. */
|
|
89
|
-
}
|
|
91
|
+
also owns show/hide — hence the empty trigger lists. */}
|
|
90
92
|
<igc-tooltip
|
|
91
93
|
data-sidebar-tooltip
|
|
92
94
|
class="igd-sidebar-tooltip"
|
|
93
95
|
placement="right"
|
|
94
96
|
show-triggers=""
|
|
95
97
|
hide-triggers=""
|
|
96
|
-
with-arrow
|
|
98
|
+
with-arrow
|
|
99
|
+
></igc-tooltip>
|
|
97
100
|
</sidebar-filter>
|
|
98
101
|
<div class="docs-sidebar-backdrop" id="docs-sidebar-backdrop" aria-hidden="true"></div>
|
|
99
102
|
|
|
@@ -75,8 +75,13 @@ const collectExpandedKeys = (root: ParentNode): string[] => {
|
|
|
75
75
|
/**
|
|
76
76
|
* Apply expanded state using setAttribute / removeAttribute.
|
|
77
77
|
* Used ONLY in astro:before-swap on not-yet-upgraded DOM nodes.
|
|
78
|
+
* With `onlyActiveBranch`, the saved keys are ignored.
|
|
78
79
|
*/
|
|
79
|
-
const applyExpandedAttr = (
|
|
80
|
+
const applyExpandedAttr = (
|
|
81
|
+
root: ParentNode,
|
|
82
|
+
openKeys: Set<string>,
|
|
83
|
+
onlyActiveBranch: boolean,
|
|
84
|
+
): void => {
|
|
80
85
|
root.querySelectorAll<HTMLElement>(GROUP_SELECTOR).forEach((el) => {
|
|
81
86
|
// Always keep ancestors of the active page open.
|
|
82
87
|
if (el.querySelector('a[aria-current="page"]')) {
|
|
@@ -84,7 +89,7 @@ const applyExpandedAttr = (root: ParentNode, openKeys: Set<string>): void => {
|
|
|
84
89
|
return;
|
|
85
90
|
}
|
|
86
91
|
const key = el.dataset.groupKey;
|
|
87
|
-
if (key && openKeys.has(key)) el.setAttribute('expanded', '');
|
|
92
|
+
if (!onlyActiveBranch && key && openKeys.has(key)) el.setAttribute('expanded', '');
|
|
88
93
|
else el.removeAttribute('expanded');
|
|
89
94
|
});
|
|
90
95
|
};
|
|
@@ -115,13 +120,20 @@ document.addEventListener('astro:before-swap', (e) => {
|
|
|
115
120
|
const newScroll = newDoc.querySelector<HTMLElement>(SCROLL_SELECTOR);
|
|
116
121
|
if (newScroll) newScroll.style.visibility = 'hidden';
|
|
117
122
|
|
|
123
|
+
// Single-branch: the new page's branch replaces the saved one, unless the
|
|
124
|
+
// filter carries over and keeps every group it opened.
|
|
125
|
+
const onlyActiveBranch =
|
|
126
|
+
!!newDoc.querySelector('sidebar-filter[data-single-branch-expand]') &&
|
|
127
|
+
!!newDoc.querySelector(`${GROUP_SELECTOR} a[aria-current="page"]`) &&
|
|
128
|
+
!safeGet(FILTER_KEY);
|
|
129
|
+
|
|
118
130
|
const raw = safeGet(DETAILS_KEY);
|
|
119
|
-
applyExpandedAttr(newDoc, new Set(raw ? raw.split('\n').filter(Boolean) : []));
|
|
131
|
+
applyExpandedAttr(newDoc, new Set(raw ? raw.split('\n').filter(Boolean) : []), onlyActiveBranch);
|
|
120
132
|
});
|
|
121
133
|
|
|
122
134
|
// ── Custom element ───────────────────────────────────────────────────────────
|
|
123
135
|
|
|
124
|
-
type ExpandableEl = HTMLElement & { expanded: boolean };
|
|
136
|
+
type ExpandableEl = HTMLElement & { expanded: boolean; collapseWithEvent(): Promise<void> };
|
|
125
137
|
type FilterInputEl = HTMLElement & { value: string; focus(): void };
|
|
126
138
|
type FilterClearEl = HTMLElement & { hidden: boolean };
|
|
127
139
|
|
|
@@ -185,6 +197,7 @@ class SidebarFilter extends HTMLElement {
|
|
|
185
197
|
// the igc-tree-item instance in event.detail — NOT in e.target.
|
|
186
198
|
this.addEventListener('igcItemExpanded', this.onItemToggle as EventListener);
|
|
187
199
|
this.addEventListener('igcItemCollapsed', this.onItemToggle as EventListener);
|
|
200
|
+
this.addEventListener('igcItemExpanding', this.onItemExpanding as EventListener);
|
|
188
201
|
}
|
|
189
202
|
|
|
190
203
|
private onFilterInput = (): void => {
|
|
@@ -259,6 +272,22 @@ class SidebarFilter extends HTMLElement {
|
|
|
259
272
|
safeSet(DETAILS_KEY, [...keys].join('\n'));
|
|
260
273
|
};
|
|
261
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Single-branch: a user expand collapses every open group outside the new
|
|
277
|
+
* branch. igc-tree's own `singleBranchExpand` isn't used: turning it on
|
|
278
|
+
* collapses every group, the current page's included, and while filtering
|
|
279
|
+
* the next expand would collapse the groups the filter opened.
|
|
280
|
+
*/
|
|
281
|
+
private onItemExpanding = (e: Event): void => {
|
|
282
|
+
// While filtering, every group with a match stays open.
|
|
283
|
+
if (!this.singleBranch || this.openSnapshot) return;
|
|
284
|
+
|
|
285
|
+
const item = (e as CustomEvent<HTMLElement>).detail;
|
|
286
|
+
for (const el of this.groups as ExpandableEl[]) {
|
|
287
|
+
if (el.expanded && !el.contains(item)) void el.collapseWithEvent();
|
|
288
|
+
}
|
|
289
|
+
};
|
|
290
|
+
|
|
262
291
|
private syncSnapshotAttr(): void {
|
|
263
292
|
if (this.openSnapshot) this.dataset.openSnapshot = [...this.openSnapshot].join('\n');
|
|
264
293
|
else delete this.dataset.openSnapshot;
|
|
@@ -384,7 +413,11 @@ class SidebarFilter extends HTMLElement {
|
|
|
384
413
|
// Clear match marks — CSS restores visibility automatically.
|
|
385
414
|
for (const el of this.items) delete el.dataset.filterMatch;
|
|
386
415
|
|
|
387
|
-
|
|
416
|
+
// Single-branch: return to the current page's branch, not to the groups
|
|
417
|
+
// that were open before filtering, which may be a second branch.
|
|
418
|
+
const restore = this.singleBranch
|
|
419
|
+
? this.activeBranchKeys()
|
|
420
|
+
: (this.preFilterSnapshot ?? this.openSnapshot);
|
|
388
421
|
if (restore) {
|
|
389
422
|
this.withSuppressed(() => this.setExpandedState(restore!));
|
|
390
423
|
safeSet(DETAILS_KEY, [...restore].join('\n'));
|
|
@@ -462,6 +495,21 @@ class SidebarFilter extends HTMLElement {
|
|
|
462
495
|
}
|
|
463
496
|
}
|
|
464
497
|
|
|
498
|
+
private get singleBranch(): boolean {
|
|
499
|
+
return this.hasAttribute('data-single-branch-expand');
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
/** Keys of the groups that contain the active page. */
|
|
503
|
+
private activeBranchKeys(): Set<string> {
|
|
504
|
+
const keys = new Set<string>();
|
|
505
|
+
for (const el of this.groups) {
|
|
506
|
+
if (el.dataset.groupKey && el.querySelector('a[aria-current="page"]')) {
|
|
507
|
+
keys.add(el.dataset.groupKey);
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
return keys;
|
|
511
|
+
}
|
|
512
|
+
|
|
465
513
|
private ensureActiveAncestorsExpanded(): void {
|
|
466
514
|
const active = this.querySelector<HTMLAnchorElement>('a[aria-current="page"]');
|
|
467
515
|
if (!active) return;
|
|
@@ -14,7 +14,13 @@
|
|
|
14
14
|
|
|
15
15
|
import type { TreeNode } from '../DocsTree/types';
|
|
16
16
|
import type { SidebarEntry } from '../../lib/sidebar/types';
|
|
17
|
-
import {
|
|
17
|
+
import {
|
|
18
|
+
hasActive,
|
|
19
|
+
isGroup,
|
|
20
|
+
isInitiallyOpen,
|
|
21
|
+
joinPath,
|
|
22
|
+
normalizeSlug,
|
|
23
|
+
} from '../../lib/sidebar/helpers';
|
|
18
24
|
|
|
19
25
|
const base = import.meta.env.BASE_URL.replace(/\/$/, '');
|
|
20
26
|
|
|
@@ -33,16 +39,20 @@ const toNode = (
|
|
|
33
39
|
ancestors: string[],
|
|
34
40
|
currentSlug: string,
|
|
35
41
|
trailingSlash: boolean,
|
|
42
|
+
singleBranch: boolean,
|
|
36
43
|
): TreeNode => {
|
|
37
44
|
const path = joinPath(ancestors, entry.label);
|
|
38
45
|
|
|
39
46
|
if (isGroup(entry)) {
|
|
47
|
+
const expanded = singleBranch
|
|
48
|
+
? hasActive(entry.items, currentSlug)
|
|
49
|
+
: isInitiallyOpen(entry, currentSlug);
|
|
40
50
|
return {
|
|
41
51
|
id: path,
|
|
42
52
|
label: entry.label,
|
|
43
|
-
expanded:
|
|
53
|
+
expanded: expanded || undefined,
|
|
44
54
|
children: entry.items.map((child) =>
|
|
45
|
-
toNode(child, [...ancestors, entry.label], currentSlug, trailingSlash),
|
|
55
|
+
toNode(child, [...ancestors, entry.label], currentSlug, trailingSlash, singleBranch),
|
|
46
56
|
),
|
|
47
57
|
itemData: {
|
|
48
58
|
path,
|
|
@@ -69,10 +79,16 @@ const toNode = (
|
|
|
69
79
|
export interface ToTreeNodesOptions {
|
|
70
80
|
/** Append trailing slash to sidebar links. Defaults to `true`. */
|
|
71
81
|
trailingSlash?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* Open only the groups that contain the current page, ignoring each
|
|
84
|
+
* group's `collapsed` flag. Defaults to `false`.
|
|
85
|
+
*/
|
|
86
|
+
singleBranch?: boolean;
|
|
72
87
|
}
|
|
73
88
|
|
|
74
89
|
export const toTreeNodes = (
|
|
75
90
|
entries: SidebarEntry[],
|
|
76
91
|
currentSlug: string,
|
|
77
|
-
{ trailingSlash = true }: ToTreeNodesOptions = {},
|
|
78
|
-
): TreeNode[] =>
|
|
92
|
+
{ trailingSlash = true, singleBranch = false }: ToTreeNodesOptions = {},
|
|
93
|
+
): TreeNode[] =>
|
|
94
|
+
entries.map((entry) => toNode(entry, [], currentSlug, trailingSlash, singleBranch));
|
|
@@ -13,6 +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 { ULTIMATE_UI_PLATFORMS, platformLabelFor } from '../../platform';
|
|
16
17
|
import {
|
|
17
18
|
productLinks,
|
|
18
19
|
sidebar as sidebarData,
|
|
@@ -72,8 +73,11 @@ interface Props {
|
|
|
72
73
|
* Items for the package/platform selector dropdown. When omitted the selector is hidden.
|
|
73
74
|
* Each entry is either a plain string label, or an object with a `label`, optional `value`
|
|
74
75
|
* (defaults to `label`), and optional `href` to navigate to when selected.
|
|
76
|
+
* Set `base` to the root URL of the entry's docs site to keep the reader on the current
|
|
77
|
+
* page: selecting the entry goes to the current URL with this site's base swapped for `base`.
|
|
78
|
+
* Nothing checks that the page exists there; redirect missing pages on the server.
|
|
75
79
|
*/
|
|
76
|
-
packages?: Array<string | { label: string; value?: string; href?: string }>;
|
|
80
|
+
packages?: Array<string | { label: string; value?: string; href?: string; base?: string }>;
|
|
77
81
|
/** Currently selected package value (must match one of `packages`). */
|
|
78
82
|
selectedPackage?: string;
|
|
79
83
|
/** Label rendered before the package selector. Defaults to `'Package'`. */
|
|
@@ -91,7 +95,7 @@ interface Props {
|
|
|
91
95
|
/**
|
|
92
96
|
* Text label shown in the logo area when the GlobalNavBar is visible.
|
|
93
97
|
* Fades out and is replaced by the SVG logo once the subheader becomes sticky.
|
|
94
|
-
* Defaults to `'
|
|
98
|
+
* Defaults to `'Ignite UI'` for web products and `'Ultimate UI'` for WinUI/Uno.
|
|
95
99
|
*/
|
|
96
100
|
logoText?: string;
|
|
97
101
|
}
|
|
@@ -110,18 +114,18 @@ const {
|
|
|
110
114
|
versionLabel = 'Version',
|
|
111
115
|
showThemeToggle = false,
|
|
112
116
|
themeStorageKey = 'docs-theme',
|
|
113
|
-
logoText = 'Ignite UI',
|
|
117
|
+
logoText = ULTIMATE_UI_PLATFORMS.has(virtualPlatform ?? '') ? 'Ultimate UI' : 'Ignite UI',
|
|
114
118
|
} = Astro.props;
|
|
115
119
|
const resolvedSiteTitle = siteTitleProp ?? siteTitle;
|
|
116
120
|
const currentPlatform = virtualPlatform ?? null;
|
|
117
121
|
const resolvedLinks = (productLinksProp ?? productLinks) as ProductLink[];
|
|
118
122
|
const filteredLinks = resolvedLinks.filter((l: ProductLink) => l.platform !== currentPlatform);
|
|
119
|
-
type PackageEntry = string | { label: string; value?: string; href?: string };
|
|
123
|
+
type PackageEntry = string | { label: string; value?: string; href?: string; base?: string };
|
|
120
124
|
const rawPackages = packagesProp ?? (virtualPackages?.length > 0 ? virtualPackages : undefined);
|
|
121
125
|
const packages = (rawPackages as PackageEntry[] | undefined)?.map((p: PackageEntry) =>
|
|
122
126
|
typeof p === 'string'
|
|
123
|
-
? { label: p, value: p, href: undefined }
|
|
124
|
-
: { label: p.label, value: p.value ?? p.label, href: p.href },
|
|
127
|
+
? { label: p, value: p, href: undefined, base: undefined }
|
|
128
|
+
: { label: p.label, value: p.value ?? p.label, href: p.href, base: p.base },
|
|
125
129
|
);
|
|
126
130
|
const selectedPackage =
|
|
127
131
|
selectedPackageProp ?? (virtualSelectedPackage || undefined) ?? packages?.[0]?.value;
|
|
@@ -134,13 +138,7 @@ const resolvedSidebar = (sidebarItems ?? sidebarData) as SidebarEntry[];
|
|
|
134
138
|
const sidebarCrumbs = currentSlug ? getBreadcrumb(resolvedSidebar, currentSlug) : [];
|
|
135
139
|
const crumbs = sidebarCrumbs.length > 0 ? sidebarCrumbs : pageTitle ? [pageTitle] : [];
|
|
136
140
|
|
|
137
|
-
const
|
|
138
|
-
angular: 'Angular',
|
|
139
|
-
react: 'React',
|
|
140
|
-
blazor: 'Blazor',
|
|
141
|
-
'web-components': 'Web Components',
|
|
142
|
-
};
|
|
143
|
-
const platformLabel = currentPlatform ? (PLATFORM_LABELS[currentPlatform] ?? null) : null;
|
|
141
|
+
const platformLabel = platformLabelFor(currentPlatform);
|
|
144
142
|
---
|
|
145
143
|
|
|
146
144
|
<docs-subheader-menu class="igd-docs-subheader" data-platform={currentPlatform ?? ''}>
|
|
@@ -165,65 +163,63 @@ const platformLabel = currentPlatform ? (PLATFORM_LABELS[currentPlatform] ?? nul
|
|
|
165
163
|
|
|
166
164
|
<div class="igd-docs-subheader__content">
|
|
167
165
|
<!-- Search (overridable via named slot) -->
|
|
168
|
-
<slot name="search"
|
|
166
|
+
<slot name="search">
|
|
167
|
+
<Search />
|
|
168
|
+
</slot>
|
|
169
169
|
|
|
170
170
|
{/* Package selector */}
|
|
171
|
-
{
|
|
172
|
-
|
|
173
|
-
<>
|
|
174
|
-
<igc-select
|
|
175
|
-
distance="4"
|
|
176
|
-
id="package-select"
|
|
177
|
-
class="igd-package-select"
|
|
178
|
-
outlined
|
|
179
|
-
value={selectedPackage}
|
|
180
|
-
aria-label={packageLabel}
|
|
181
|
-
>
|
|
182
|
-
{platformIcon && (
|
|
183
|
-
<igc-icon name={platformIcon} collection="docs" slot="prefix" aria-hidden="true" />
|
|
184
|
-
)}
|
|
185
|
-
{packages.map((p) => {
|
|
186
|
-
const icon = getPlatformIcon(p.value ?? '') ?? getPlatformIcon(p.label ?? '');
|
|
187
|
-
return (
|
|
188
|
-
<igc-select-item value={p.value} data-href={p.href}>
|
|
189
|
-
{icon && (
|
|
190
|
-
<igc-icon slot="prefix" name={icon} collection="docs" aria-hidden="true" />
|
|
191
|
-
)}
|
|
192
|
-
{p.label}
|
|
193
|
-
</igc-select-item>
|
|
194
|
-
);
|
|
195
|
-
})}
|
|
196
|
-
</igc-select>
|
|
197
|
-
<igc-tooltip
|
|
198
|
-
id="package-tooltip"
|
|
199
|
-
class="igd-package-select-tooltip"
|
|
200
|
-
anchor="package-select"
|
|
201
|
-
placement="bottom"
|
|
202
|
-
with-arrow
|
|
203
|
-
>
|
|
204
|
-
{selectedPackageLabel}
|
|
205
|
-
</igc-tooltip>
|
|
206
|
-
</>
|
|
207
|
-
)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
<!-- Version selector -->
|
|
211
|
-
{
|
|
212
|
-
versions && versions.length > 0 && (
|
|
171
|
+
{packages && packages.length > 0 && (
|
|
172
|
+
<>
|
|
213
173
|
<igc-select
|
|
214
174
|
distance="4"
|
|
215
|
-
id="
|
|
216
|
-
class="igd-
|
|
175
|
+
id="package-select"
|
|
176
|
+
class="igd-package-select"
|
|
217
177
|
outlined
|
|
218
|
-
value={
|
|
219
|
-
aria-label={
|
|
178
|
+
value={selectedPackage}
|
|
179
|
+
aria-label={packageLabel}
|
|
220
180
|
>
|
|
221
|
-
{
|
|
222
|
-
<igc-
|
|
223
|
-
)
|
|
181
|
+
{platformIcon && (
|
|
182
|
+
<igc-icon name={platformIcon} collection="docs" slot="prefix" aria-hidden="true" />
|
|
183
|
+
)}
|
|
184
|
+
{packages.map((p) => {
|
|
185
|
+
const icon = getPlatformIcon(p.value ?? '') ?? getPlatformIcon(p.label ?? '');
|
|
186
|
+
return (
|
|
187
|
+
<igc-select-item value={p.value} data-href={p.href} data-base={p.base}>
|
|
188
|
+
{icon && (
|
|
189
|
+
<igc-icon slot="prefix" name={icon} collection="docs" aria-hidden="true" />
|
|
190
|
+
)}
|
|
191
|
+
{p.label}
|
|
192
|
+
</igc-select-item>
|
|
193
|
+
);
|
|
194
|
+
})}
|
|
224
195
|
</igc-select>
|
|
225
|
-
|
|
226
|
-
|
|
196
|
+
<igc-tooltip
|
|
197
|
+
id="package-tooltip"
|
|
198
|
+
class="igd-package-select-tooltip"
|
|
199
|
+
anchor="package-select"
|
|
200
|
+
placement="bottom"
|
|
201
|
+
with-arrow
|
|
202
|
+
>
|
|
203
|
+
{selectedPackageLabel}
|
|
204
|
+
</igc-tooltip>
|
|
205
|
+
</>
|
|
206
|
+
)}
|
|
207
|
+
|
|
208
|
+
<!-- Version selector -->
|
|
209
|
+
{versions && versions.length > 0 && (
|
|
210
|
+
<igc-select
|
|
211
|
+
distance="4"
|
|
212
|
+
id="version-select"
|
|
213
|
+
class="igd-version-select"
|
|
214
|
+
outlined
|
|
215
|
+
value={selectedVersion}
|
|
216
|
+
aria-label={versionLabel}
|
|
217
|
+
>
|
|
218
|
+
{versions.map((v) => (
|
|
219
|
+
<igc-select-item value={v}>{v}</igc-select-item>
|
|
220
|
+
))}
|
|
221
|
+
</igc-select>
|
|
222
|
+
)}
|
|
227
223
|
|
|
228
224
|
<!-- TODO WHY WE NEED THIS? -->
|
|
229
225
|
<!--{filteredLinks.length > 0 && (-->
|
|
@@ -240,6 +236,18 @@ const platformLabel = currentPlatform ? (PLATFORM_LABELS[currentPlatform] ?? nul
|
|
|
240
236
|
</docs-subheader-menu>
|
|
241
237
|
|
|
242
238
|
<script>
|
|
239
|
+
/**
|
|
240
|
+
* Where selecting a package entry should navigate. With a `base` (root URL of the entry's
|
|
241
|
+
* docs site) it is this page's URL with the site's own base swapped for the entry's; the
|
|
242
|
+
* server handles a page that does not exist there. Otherwise it is the entry's `href`.
|
|
243
|
+
*/
|
|
244
|
+
function packageHref({ href, base }: DOMStringMap): string | undefined {
|
|
245
|
+
const currentBase = import.meta.env.BASE_URL.replace(/\/$/, '');
|
|
246
|
+
const { pathname, search, hash } = window.location;
|
|
247
|
+
if (!base || !pathname.startsWith(currentBase)) return href;
|
|
248
|
+
return `${base.replace(/\/$/, '')}${pathname.slice(currentBase.length)}${search}${hash}`;
|
|
249
|
+
}
|
|
250
|
+
|
|
243
251
|
if (!customElements.get('docs-subheader-menu')) {
|
|
244
252
|
class DocsSubHeaderMenu extends HTMLElement {
|
|
245
253
|
connectedCallback() {
|
|
@@ -283,7 +291,7 @@ const platformLabel = currentPlatform ? (PLATFORM_LABELS[currentPlatform] ?? nul
|
|
|
283
291
|
const item = packageSelect.querySelector<HTMLElement>(
|
|
284
292
|
`igc-select-item[value="${val}"]`,
|
|
285
293
|
);
|
|
286
|
-
const href = item
|
|
294
|
+
const href = item && packageHref(item.dataset);
|
|
287
295
|
if (href) window.location.href = href;
|
|
288
296
|
// Sync tooltip content with the new selection label
|
|
289
297
|
if (packageTooltip) {
|
|
@@ -394,12 +402,10 @@ const platformLabel = currentPlatform ? (PLATFORM_LABELS[currentPlatform] ?? nul
|
|
|
394
402
|
function initSelectors() {
|
|
395
403
|
const packageSelect = document.querySelector('#package-select');
|
|
396
404
|
if (packageSelect) {
|
|
405
|
+
// Navigation on change is handled by <docs-subheader-menu>.
|
|
397
406
|
packageSelect.addEventListener('igcChange', (e: Event) => {
|
|
398
407
|
const val = (e as CustomEvent).detail?.value ?? (packageSelect as any).value;
|
|
399
|
-
const item = packageSelect.querySelector<HTMLElement>(`igc-select-item[value="${val}"]`);
|
|
400
408
|
syncTriggerIcon(packageSelect, val);
|
|
401
|
-
const href = item?.dataset?.href;
|
|
402
|
-
if (href) window.location.href = href;
|
|
403
409
|
});
|
|
404
410
|
}
|
|
405
411
|
}
|
|
@@ -16,7 +16,7 @@ import DocsSubHeader from 'igniteui-astro-components/components/DocsSubHeader.as
|
|
|
16
16
|
| ----------------- | ------------------------------------------------------ | -------------- | ---------------------------------------------------------------------- |
|
|
17
17
|
| `productLinks` | `{ label: string; href: string; platform?: string }[]` | virtual module | Override the cross-product navigation links. |
|
|
18
18
|
| `sidebarItems` | `SidebarEntry[]` | virtual module | Override the sidebar tree used for breadcrumb generation. |
|
|
19
|
-
| `packages` | `string[]`
|
|
19
|
+
| `packages` | `(string \| PackageEntry)[]` | virtual module | Entries for the package selector dropdown. Hidden when omitted. |
|
|
20
20
|
| `selectedPackage` | `string` | — | Currently selected package (must match one of `packages`). |
|
|
21
21
|
| `packageLabel` | `string` | `'Package'` | Label rendered before the package selector. |
|
|
22
22
|
| `versions` | `string[]` | — | Version labels for the version selector dropdown. Hidden when omitted. |
|
|
@@ -25,6 +25,15 @@ import DocsSubHeader from 'igniteui-astro-components/components/DocsSubHeader.as
|
|
|
25
25
|
| `showThemeToggle` | `boolean` | `false` | Show a light/dark theme toggle button. |
|
|
26
26
|
| `themeStorageKey` | `string` | `'docs-theme'` | `localStorage` key for persisting the theme preference. |
|
|
27
27
|
|
|
28
|
+
`PackageEntry` is `{ label: string; value?: string; href?: string; base?: string }`:
|
|
29
|
+
|
|
30
|
+
| Field | Description |
|
|
31
|
+
| ------- | -------------------------------------------------------------------------------- |
|
|
32
|
+
| `label` | Text shown in the dropdown. |
|
|
33
|
+
| `value` | Value matched against `selectedPackage`. Defaults to `label`. |
|
|
34
|
+
| `href` | Where selecting the entry navigates, e.g. the platform's getting started page. |
|
|
35
|
+
| `base` | Root URL of the entry's docs site. Switching keeps the current page (see below). |
|
|
36
|
+
|
|
28
37
|
## Slots
|
|
29
38
|
|
|
30
39
|
| Slot | Default | Description |
|
|
@@ -33,6 +42,10 @@ import DocsSubHeader from 'igniteui-astro-components/components/DocsSubHeader.as
|
|
|
33
42
|
|
|
34
43
|
## Behaviour
|
|
35
44
|
|
|
45
|
+
- Selecting a package navigates to its `href`. When the entry also has a `base`, it goes to the same
|
|
46
|
+
page on that site instead: the current URL with this site's base (`import.meta.env.BASE_URL`)
|
|
47
|
+
swapped for `base`, keeping the query and `#hash`. Nothing checks that the page exists there, so
|
|
48
|
+
the server should redirect missing pages, e.g. to the platform's getting started page.
|
|
36
49
|
- Product links from the virtual module are shown; the currently active platform link is hidden.
|
|
37
50
|
- The search button opens the Pagefind dialog (see `Search` component).
|
|
38
51
|
- CSS custom properties used for positioning:
|
|
@@ -26,6 +26,11 @@ type SassProps = {
|
|
|
26
26
|
|
|
27
27
|
/** Props for TypeDoc API documentation links. */
|
|
28
28
|
type TypeDocProps = {
|
|
29
|
+
/**
|
|
30
|
+
* Marks a deliberately authored raw ApiLink in strict-xplat documentation.
|
|
31
|
+
* This is an authoring/checker annotation and has no rendering effect.
|
|
32
|
+
*/
|
|
33
|
+
raw?: boolean;
|
|
29
34
|
/**
|
|
30
35
|
* TypeDoc symbol kind. Narrows registry lookup when the same symbol exists
|
|
31
36
|
* as multiple TypeDoc kinds.
|