igniteui-astro-components 0.0.26 → 0.0.28
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 +82 -74
- package/package.json +16 -9
- package/src/components/CopyCode/CopyCode.astro +21 -7
- package/src/components/DocsBreadcrumb/DocsBreadcrumb.astro +33 -21
- package/src/components/DocsBreadcrumb/DocsBreadcrumb.scss +44 -43
- package/src/components/DocsBreadcrumb/README.md +10 -14
- package/src/components/DocsSidebar/DocsSidebar.astro +47 -45
- package/src/components/DocsSidebar/DocsSidebar.scss +120 -122
- package/src/components/DocsSidebar/README.md +25 -21
- package/src/components/DocsSidebar/SidebarFilterInput.astro +24 -29
- package/src/components/DocsSidebar/SidebarFilterInput.scss +90 -89
- package/src/components/DocsSidebar/SidebarLabel.astro +35 -26
- package/src/components/DocsSidebar/sidebar-filter.ts +93 -56
- package/src/components/DocsSubHeader/DocsSubHeader.astro +256 -185
- package/src/components/DocsSubHeader/DocsSubHeader.scss +181 -169
- package/src/components/DocsSubHeader/README.md +18 -16
- package/src/components/DocsToc/DocsToc.astro +301 -280
- package/src/components/DocsToc/DocsToc.scss +20 -21
- package/src/components/DocsToc/README.md +11 -9
- package/src/components/DocsToc/toTreeNodes.ts +3 -8
- package/src/components/DocsTree/DocsTree.astro +32 -20
- package/src/components/DocsTree/DocsTreeItem.astro +35 -30
- package/src/components/DocsTree/README.md +16 -15
- package/src/components/DocsTree/docs-tree.scss +267 -268
- package/src/components/GlobalFooter/GlobalFooter.astro +10 -10
- package/src/components/GlobalFooter/README.md +3 -2
- package/src/components/GlobalNavBar/GlobalNavBar.astro +4 -2
- package/src/components/GlobalNavBar/GlobalNavBar.module.scss +222 -222
- package/src/components/GlobalNavBar/README.md +3 -2
- package/src/components/LicenseIndicator/LicenseIndicator.astro +7 -5
- package/src/components/LicenseIndicator/LicenseIndicator.scss +3 -3
- package/src/components/MobileSidebarToggle/MobileSidebarToggle.astro +16 -17
- package/src/components/MobileSidebarToggle/README.md +3 -2
- package/src/components/MobileTocToggle/MobileTocToggle.astro +75 -61
- package/src/components/MobileTocToggle/MobileTocToggle.scss +65 -59
- package/src/components/Search/README.md +1 -0
- package/src/components/Search/Search.astro +137 -109
- package/src/components/Search/Search.scss +20 -20
- package/src/components/SearchAdvanced/README.md +21 -15
- package/src/components/SearchAdvanced/SearchAdvanced.astro +220 -133
- package/src/components/SearchAdvanced/SearchAdvanced.scss +152 -153
- package/src/components/mdx/ApiLink/ApiLink.astro +133 -113
- package/src/components/mdx/ApiLink/ApiLink.scss +9 -9
- package/src/components/mdx/ApiLink/README.md +26 -22
- package/src/components/mdx/ApiLink/api-link-index.ts +196 -173
- package/src/components/mdx/ApiRef/ApiRef.astro +54 -51
- package/src/components/mdx/ApiRef/README.md +20 -15
- package/src/components/mdx/Badge/Badge.astro +14 -14
- package/src/components/mdx/Badge/Badge.scss +61 -56
- package/src/components/mdx/Badge/README.md +24 -19
- package/src/components/mdx/DocsAside/DocsAside.astro +30 -37
- package/src/components/mdx/DocsAside/DocsAside.scss +82 -82
- package/src/components/mdx/DocsAside/README.md +22 -22
- package/src/components/mdx/Faq/Faq.astro +86 -0
- package/src/components/mdx/Faq/Faq.scss +105 -0
- package/src/components/mdx/Faq/FaqItem.astro +117 -0
- package/src/components/mdx/Faq/README.md +223 -0
- package/src/components/mdx/Faq/types.ts +34 -0
- package/src/components/mdx/PlatformBlock/PlatformBlock.astro +3 -2
- package/src/components/mdx/PlatformBlock/README.md +6 -8
- package/src/components/mdx/Sample/README.md +21 -16
- package/src/components/mdx/Sample/Sample.astro +97 -74
- package/src/components/mdx/Sample/Sample.scss +132 -132
- package/src/content-helper.ts +71 -72
- package/src/content.config.ts +1 -6
- package/src/integration.ts +566 -512
- package/src/layouts/DocsLayout/DocsLayout.astro +228 -182
- package/src/layouts/DocsLayout/DocsLayout.scss +261 -261
- package/src/layouts/DocsLayout/README.md +24 -35
- package/src/lib/nav-helpers.ts +88 -82
- package/src/lib/types.ts +76 -76
- package/src/llms.ts +205 -166
- package/src/platform.ts +312 -162
- package/src/plugins/rehype-heading-anchors.ts +45 -45
- package/src/plugins/rehype-pagefind-ignore.ts +19 -19
- package/src/plugins/rehype-table-wrapper.ts +30 -30
- package/src/plugins/remark-docfx.ts +12 -0
- package/src/plugins/remark-env-vars.ts +12 -4
- package/src/plugins/remark-md-links.ts +10 -4
- package/src/scripts/icon-manifest.ts +13 -5
- package/src/scripts/sample-widget.ts +557 -501
- package/src/sidebar.ts +103 -97
- package/src/styles/global/_code-blocks.scss +43 -44
- package/src/styles/global/_component-themes.scss +151 -153
- package/src/styles/global/_icon-gallery.scss +81 -81
- package/src/styles/global/_index.scss +0 -1
- package/src/styles/global/_markdown.scss +816 -787
- package/src/styles/global/_palette.scss +456 -110
- package/src/styles/global/_search-shared.scss +402 -398
- package/src/styles/global/_type-scale.scss +127 -127
- package/src/styles/global/_variables.scss +138 -111
- package/src/styles/theme.scss +49 -40
- package/src/virtual-modules.d.ts +11 -2
|
@@ -1,96 +1,97 @@
|
|
|
1
1
|
@use 'igniteui-theming/sass/typography' as *;
|
|
2
2
|
|
|
3
3
|
.docs-sidebar {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
4
|
+
igc-input {
|
|
5
|
+
--ig-input-group-input-suffix-color: light-dark(var(--ig-gray-900), var(--ig-gray-800));
|
|
6
|
+
--ig-input-group-input-suffix-color--filled: light-dark(var(--ig-gray-900), var(--ig-gray-800));
|
|
7
|
+
--ig-input-group-input-suffix-color--focused: light-dark(
|
|
8
|
+
var(--ig-gray-900),
|
|
9
|
+
var(--ig-gray-800)
|
|
10
|
+
);
|
|
11
|
+
--ig-input-group-idle-text-color: light-dark(var(--ig-gray-900), var(--ig-gray-800));
|
|
12
|
+
--ig-input-group-filled-text-color: light-dark(var(--ig-gray-900), var(--ig-gray-900));
|
|
13
|
+
--ig-input-group-placeholder-color: var(--ig-gray-500);
|
|
14
|
+
--ig-input-group-hover-placeholder-color: var(--ig-gray-500);
|
|
15
|
+
|
|
16
|
+
--ig-flat-button-hover-background: transparent;
|
|
17
|
+
--ig-flat-button-focus-background: transparent;
|
|
18
|
+
--ig-flat-button-icon-color-hover: var(--igd-accent);
|
|
19
|
+
--ig-flat-button-icon-color-focus: var(--igd-accent);
|
|
20
|
+
--border-border-radius: var(--igd-border-radius-xl);
|
|
21
|
+
--border-background: light-dark(var(--ig-gray-50), var(--ig-gray-50));
|
|
22
|
+
--border-color: light-dark(var(--ig-gray-300), var(--ig-gray-100));
|
|
23
|
+
--hover-border-color: light-dark(var(--ig-gray-400), var(--ig-gray-100));
|
|
24
|
+
|
|
25
|
+
igc-icon-button[variant='flat'] {
|
|
26
|
+
--background: transparent;
|
|
27
|
+
--hover-background: transparent;
|
|
28
|
+
--focus-background: transparent;
|
|
29
|
+
--active-background: transparent;
|
|
30
|
+
--foreground: var(--ig-gray-800);
|
|
31
|
+
--foreground-hover: var(--ig-primary-800);
|
|
32
|
+
--foreground-focus: var(--ig-primary-800);
|
|
33
|
+
--foreground-active: var(--ig-primary-800);
|
|
34
|
+
|
|
35
|
+
padding: 0;
|
|
36
|
+
|
|
37
|
+
&::part(base) {
|
|
38
|
+
&::after {
|
|
39
|
+
display: none;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
igc-icon {
|
|
45
|
+
--size: #{rem(24px)};
|
|
46
|
+
padding: 0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
> igc-icon {
|
|
50
|
+
--size: #{rem(24px)};
|
|
51
|
+
|
|
52
|
+
aspect-ratio: 1;
|
|
53
|
+
margin-inline-end: rem(4px);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
igc-input::part(prefix) {
|
|
58
|
+
padding-inline: 0;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
igc-input::part(input) {
|
|
62
|
+
@include type-style('body-2') {
|
|
63
|
+
margin: 0;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
padding-inline: rem(16px);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
igc-button {
|
|
70
|
+
padding: 0;
|
|
71
|
+
|
|
72
|
+
&::part(base) {
|
|
73
|
+
padding-inline: rem(6px);
|
|
74
|
+
min-width: fit-content;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// TODO I am unable to styles the input, can't reach the part, log an issue in to the library.
|
|
78
|
+
//&::part(input) {
|
|
79
|
+
// padding-inline-start: 0;
|
|
80
|
+
// padding-inline-end: rem(32px);
|
|
81
|
+
//}
|
|
82
|
+
}
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
.sidebar-filter-status {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
86
|
+
@include type-style('body-2') {
|
|
87
|
+
margin: 0 !important;
|
|
88
|
+
line-height: 1;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
color: light-dark(var(--ig-gray-500), var(--ig-gray-700));
|
|
92
|
+
padding-inline: rem(16px) 0;
|
|
93
|
+
|
|
94
|
+
&:empty {
|
|
95
|
+
display: none;
|
|
96
|
+
}
|
|
96
97
|
}
|
|
@@ -23,35 +23,44 @@ interface Props {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
const { node, isLeaf } = Astro.props;
|
|
26
|
-
const childCount = !isLeaf ? (node.children?.length ?? 0) : 0;
|
|
27
26
|
const badges = (node.meta?.badges ?? []) as SidebarBadge[];
|
|
28
27
|
---
|
|
29
28
|
|
|
30
|
-
{
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
{
|
|
30
|
+
isLeaf ? (
|
|
31
|
+
<>
|
|
32
|
+
<div class="igd-label-and-badge">
|
|
33
33
|
<span class="docs-tree-label">{node.label}</span>
|
|
34
34
|
{badges.length > 0 && (
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
35
|
+
<div class="igd-badge-container">
|
|
36
|
+
{badges
|
|
37
|
+
.filter((b) => b.variant !== 'premium')
|
|
38
|
+
.map((badge) => (
|
|
39
|
+
<>
|
|
40
|
+
<Badge variant={badge.variant} class="sidebar-badge" aria-hidden="true">
|
|
41
|
+
<span>{badge.text}</span>
|
|
42
|
+
</Badge>
|
|
43
|
+
<span class="visually-hidden">, {badge.text}</span>
|
|
44
|
+
</>
|
|
45
|
+
))}
|
|
46
|
+
{badges.some((b) => b.variant === 'premium') && (
|
|
47
|
+
<>
|
|
48
|
+
<igc-icon
|
|
49
|
+
name="premium"
|
|
50
|
+
collection="docs"
|
|
51
|
+
class="sidebar-premium-icon"
|
|
52
|
+
aria-hidden="true"
|
|
53
|
+
/>
|
|
54
|
+
<span class="visually-hidden">, Premium</span>
|
|
55
|
+
</>
|
|
56
|
+
)}
|
|
57
|
+
</div>
|
|
49
58
|
)}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
) : (
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
</div>
|
|
60
|
+
</>
|
|
61
|
+
) : (
|
|
62
|
+
<span class="group-label-text">
|
|
63
|
+
<span>{node.label}</span>
|
|
64
|
+
</span>
|
|
65
|
+
)
|
|
66
|
+
}
|
|
@@ -22,21 +22,39 @@
|
|
|
22
22
|
* sidebar-filter-scroll → scrollTop of the scroll container
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
const FILTER_KEY
|
|
25
|
+
const FILTER_KEY = 'sidebar-filter-value';
|
|
26
26
|
const DETAILS_KEY = 'sidebar-filter-details';
|
|
27
|
-
const SCROLL_KEY
|
|
27
|
+
const SCROLL_KEY = 'sidebar-filter-scroll';
|
|
28
28
|
|
|
29
29
|
const SCROLL_SELECTOR = '[data-sidebar-scroll]';
|
|
30
|
-
const ITEM_SELECTOR
|
|
31
|
-
const GROUP_SELECTOR
|
|
30
|
+
const ITEM_SELECTOR = 'igc-tree-item[data-path]';
|
|
31
|
+
const GROUP_SELECTOR = 'igc-tree-item[data-group-key]';
|
|
32
32
|
|
|
33
33
|
let _isClientSideNav = false;
|
|
34
34
|
|
|
35
35
|
// ── Storage helpers ──────────────────────────────────────────────────────────
|
|
36
36
|
|
|
37
|
-
const safeGet
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const safeGet = (k: string): string => {
|
|
38
|
+
try {
|
|
39
|
+
return sessionStorage.getItem(k) ?? '';
|
|
40
|
+
} catch {
|
|
41
|
+
return '';
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const safeSet = (k: string, v: string) => {
|
|
45
|
+
try {
|
|
46
|
+
sessionStorage.setItem(k, v);
|
|
47
|
+
} catch {
|
|
48
|
+
/* quota */
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const safeRemove = (k: string) => {
|
|
52
|
+
try {
|
|
53
|
+
sessionStorage.removeItem(k);
|
|
54
|
+
} catch {
|
|
55
|
+
/* */
|
|
56
|
+
}
|
|
57
|
+
};
|
|
40
58
|
|
|
41
59
|
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
42
60
|
|
|
@@ -61,15 +79,19 @@ const collectExpandedKeys = (root: ParentNode): string[] => {
|
|
|
61
79
|
const applyExpandedAttr = (root: ParentNode, openKeys: Set<string>): void => {
|
|
62
80
|
root.querySelectorAll<HTMLElement>(GROUP_SELECTOR).forEach((el) => {
|
|
63
81
|
// Always keep ancestors of the active page open.
|
|
64
|
-
if (el.querySelector('a[aria-current="page"]')) {
|
|
82
|
+
if (el.querySelector('a[aria-current="page"]')) {
|
|
83
|
+
el.setAttribute('expanded', '');
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
65
86
|
const key = el.dataset.groupKey;
|
|
66
87
|
if (key && openKeys.has(key)) el.setAttribute('expanded', '');
|
|
67
|
-
else
|
|
88
|
+
else el.removeAttribute('expanded');
|
|
68
89
|
});
|
|
69
90
|
};
|
|
70
91
|
|
|
71
|
-
const tokenize = (q: string): string[]
|
|
72
|
-
const itemPath = (el: HTMLElement): string =>
|
|
92
|
+
const tokenize = (q: string): string[] => q.toLowerCase().split(/\s+/).filter(Boolean);
|
|
93
|
+
const itemPath = (el: HTMLElement): string =>
|
|
94
|
+
(el.dataset.path ?? el.dataset.label ?? '').toLowerCase();
|
|
73
95
|
|
|
74
96
|
// ── Cross-navigation hooks ───────────────────────────────────────────────────
|
|
75
97
|
|
|
@@ -83,13 +105,13 @@ document.addEventListener('astro:before-preparation', () => {
|
|
|
83
105
|
// (which tracks user-intent expand state including manual collapses during filter).
|
|
84
106
|
// When NOT filtering, DETAILS_KEY was already kept up-to-date by onItemToggle,
|
|
85
107
|
// so we leave it as-is.
|
|
86
|
-
const host
|
|
108
|
+
const host = document.querySelector<HTMLElement>('sidebar-filter[data-filtering]');
|
|
87
109
|
const intended = host?.dataset.openSnapshot;
|
|
88
110
|
if (intended !== undefined) safeSet(DETAILS_KEY, intended);
|
|
89
111
|
});
|
|
90
112
|
|
|
91
113
|
document.addEventListener('astro:before-swap', (e) => {
|
|
92
|
-
const newDoc
|
|
114
|
+
const newDoc = (e as unknown as { newDocument: Document }).newDocument;
|
|
93
115
|
const newScroll = newDoc.querySelector<HTMLElement>(SCROLL_SELECTOR);
|
|
94
116
|
if (newScroll) newScroll.style.visibility = 'hidden';
|
|
95
117
|
|
|
@@ -105,36 +127,36 @@ type FilterClearEl = HTMLElement & { hidden: boolean };
|
|
|
105
127
|
|
|
106
128
|
class SidebarFilter extends HTMLElement {
|
|
107
129
|
private hasFilter = false;
|
|
108
|
-
private input!:
|
|
130
|
+
private input!: FilterInputEl;
|
|
109
131
|
private clearBtn!: FilterClearEl;
|
|
110
|
-
private status!:
|
|
111
|
-
private scrollEl:
|
|
112
|
-
private items:
|
|
113
|
-
private groups:
|
|
132
|
+
private status!: HTMLElement;
|
|
133
|
+
private scrollEl: HTMLElement | null = null;
|
|
134
|
+
private items: HTMLElement[] = [];
|
|
135
|
+
private groups: HTMLElement[] = [];
|
|
114
136
|
|
|
115
137
|
/** User-intent expand state during active filter. */
|
|
116
|
-
private openSnapshot:
|
|
138
|
+
private openSnapshot: Set<string> | null = null;
|
|
117
139
|
/** Pre-filter snapshot; restored on Esc / clear. */
|
|
118
140
|
private preFilterSnapshot: Set<string> | null = null;
|
|
119
141
|
/** Suppress event-driven persistence while programmatically changing state. */
|
|
120
142
|
private suppressPersist = false;
|
|
121
143
|
|
|
122
144
|
connectedCallback(): void {
|
|
123
|
-
const input
|
|
145
|
+
const input = this.querySelector<FilterInputEl>('[data-sidebar-filter-input]');
|
|
124
146
|
const clearBtn = this.querySelector<FilterClearEl>('[data-sidebar-filter-clear]');
|
|
125
|
-
const status
|
|
147
|
+
const status = this.querySelector<HTMLElement>('[data-sidebar-filter-status]');
|
|
126
148
|
const hasFilter = !!(input && clearBtn && status);
|
|
127
149
|
this.hasFilter = hasFilter;
|
|
128
150
|
|
|
129
151
|
if (hasFilter) {
|
|
130
|
-
this.input
|
|
152
|
+
this.input = input;
|
|
131
153
|
this.clearBtn = clearBtn;
|
|
132
|
-
this.status
|
|
154
|
+
this.status = status;
|
|
133
155
|
}
|
|
134
156
|
|
|
135
157
|
this.scrollEl = this.querySelector<HTMLElement>(SCROLL_SELECTOR);
|
|
136
|
-
this.items
|
|
137
|
-
this.groups
|
|
158
|
+
this.items = [...this.querySelectorAll<HTMLElement>(ITEM_SELECTOR)];
|
|
159
|
+
this.groups = [...this.querySelectorAll<HTMLElement>(GROUP_SELECTOR)];
|
|
138
160
|
|
|
139
161
|
// On a hard load (non-client-nav) DETAILS_KEY may be stale or empty.
|
|
140
162
|
// Prime it now from the SSR DOM attributes so onItemToggle can safely
|
|
@@ -143,7 +165,8 @@ class SidebarFilter extends HTMLElement {
|
|
|
143
165
|
safeSet(DETAILS_KEY, collectExpandedKeys(this).join('\n'));
|
|
144
166
|
}
|
|
145
167
|
|
|
146
|
-
if (hasFilter) this.bindEvents();
|
|
168
|
+
if (hasFilter) this.bindEvents();
|
|
169
|
+
else this.bindTreeEvents();
|
|
147
170
|
this.restoreOnConnect();
|
|
148
171
|
}
|
|
149
172
|
|
|
@@ -151,7 +174,7 @@ class SidebarFilter extends HTMLElement {
|
|
|
151
174
|
|
|
152
175
|
private bindEvents(): void {
|
|
153
176
|
this.input.addEventListener('igcInput', this.onFilterInput as EventListener);
|
|
154
|
-
this.input.addEventListener('keydown',
|
|
177
|
+
this.input.addEventListener('keydown', this.onFilterKeydown);
|
|
155
178
|
this.clearBtn.addEventListener('click', this.onClearClick);
|
|
156
179
|
this.bindTreeEvents();
|
|
157
180
|
}
|
|
@@ -160,7 +183,7 @@ class SidebarFilter extends HTMLElement {
|
|
|
160
183
|
private bindTreeEvents(): void {
|
|
161
184
|
// igcItemExpanded / igcItemCollapsed are dispatched on <igc-tree> with
|
|
162
185
|
// the igc-tree-item instance in event.detail — NOT in e.target.
|
|
163
|
-
this.addEventListener('igcItemExpanded',
|
|
186
|
+
this.addEventListener('igcItemExpanded', this.onItemToggle as EventListener);
|
|
164
187
|
this.addEventListener('igcItemCollapsed', this.onItemToggle as EventListener);
|
|
165
188
|
}
|
|
166
189
|
|
|
@@ -194,8 +217,9 @@ class SidebarFilter extends HTMLElement {
|
|
|
194
217
|
if (window.scrollY !== y) window.scrollTo({ top: y, behavior: 'instant' as ScrollBehavior });
|
|
195
218
|
if (--this.pinFrames > 0) requestAnimationFrame(tick);
|
|
196
219
|
else {
|
|
197
|
-
if (this.prevScrollBehavior)
|
|
198
|
-
|
|
220
|
+
if (this.prevScrollBehavior)
|
|
221
|
+
document.documentElement.style.setProperty('scroll-behavior', this.prevScrollBehavior);
|
|
222
|
+
else document.documentElement.style.removeProperty('scroll-behavior');
|
|
199
223
|
this.prevScrollBehavior = null;
|
|
200
224
|
}
|
|
201
225
|
};
|
|
@@ -212,13 +236,13 @@ class SidebarFilter extends HTMLElement {
|
|
|
212
236
|
|
|
213
237
|
// The events are dispatched on <igc-tree>; the actual item is in e.detail.
|
|
214
238
|
const item = (e as CustomEvent<HTMLElement>).detail;
|
|
215
|
-
const key
|
|
239
|
+
const key = item?.dataset?.groupKey;
|
|
216
240
|
if (!key) return;
|
|
217
241
|
|
|
218
242
|
if (this.openSnapshot) {
|
|
219
243
|
// Filter active — update user-intent snapshot, not live state.
|
|
220
244
|
if (e.type === 'igcItemExpanded') this.openSnapshot.add(key);
|
|
221
|
-
else
|
|
245
|
+
else this.openSnapshot.delete(key);
|
|
222
246
|
this.syncSnapshotAttr();
|
|
223
247
|
safeSet(DETAILS_KEY, [...this.openSnapshot].join('\n'));
|
|
224
248
|
return;
|
|
@@ -229,22 +253,22 @@ class SidebarFilter extends HTMLElement {
|
|
|
229
253
|
// `expanded` property to the attribute asynchronously; the attribute
|
|
230
254
|
// is still the old value at the time this synchronous event fires.
|
|
231
255
|
const saved = safeGet(DETAILS_KEY);
|
|
232
|
-
const keys
|
|
256
|
+
const keys = new Set(saved ? saved.split('\n').filter(Boolean) : []);
|
|
233
257
|
if (e.type === 'igcItemExpanded') keys.add(key);
|
|
234
|
-
else
|
|
258
|
+
else keys.delete(key);
|
|
235
259
|
safeSet(DETAILS_KEY, [...keys].join('\n'));
|
|
236
260
|
};
|
|
237
261
|
|
|
238
262
|
private syncSnapshotAttr(): void {
|
|
239
263
|
if (this.openSnapshot) this.dataset.openSnapshot = [...this.openSnapshot].join('\n');
|
|
240
|
-
else
|
|
264
|
+
else delete this.dataset.openSnapshot;
|
|
241
265
|
}
|
|
242
266
|
|
|
243
267
|
// ── Restore on connect ───────────────────────────────────────────────────
|
|
244
268
|
|
|
245
269
|
private restoreOnConnect(): void {
|
|
246
270
|
const isClientNav = _isClientSideNav;
|
|
247
|
-
_isClientSideNav
|
|
271
|
+
_isClientSideNav = false;
|
|
248
272
|
|
|
249
273
|
if (this.hasFilter) {
|
|
250
274
|
const saved = isClientNav ? safeGet(FILTER_KEY) : '';
|
|
@@ -280,18 +304,23 @@ class SidebarFilter extends HTMLElement {
|
|
|
280
304
|
} else {
|
|
281
305
|
// On hard refresh, wait for astro:page-load (which scrolls the page
|
|
282
306
|
// back to top and runs initSidebarHeights) before centering.
|
|
283
|
-
document.addEventListener(
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
sidebar
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
307
|
+
document.addEventListener(
|
|
308
|
+
'astro:page-load',
|
|
309
|
+
() => {
|
|
310
|
+
requestAnimationFrame(() => {
|
|
311
|
+
if (!this.isConnected) return;
|
|
312
|
+
const sidebar = this.closest<HTMLElement>('.docs-sidebar');
|
|
313
|
+
if (sidebar) {
|
|
314
|
+
sidebar.style.maxHeight =
|
|
315
|
+
Math.max(0, window.innerHeight - sidebar.getBoundingClientRect().top) + 'px';
|
|
316
|
+
}
|
|
317
|
+
sc.style.visibility = '';
|
|
318
|
+
const active = this.querySelector<HTMLAnchorElement>('a[aria-current="page"]');
|
|
319
|
+
if (active) this.scrollToCenter(active, sc);
|
|
320
|
+
});
|
|
321
|
+
},
|
|
322
|
+
{ once: true },
|
|
323
|
+
);
|
|
295
324
|
}
|
|
296
325
|
}
|
|
297
326
|
|
|
@@ -316,11 +345,14 @@ class SidebarFilter extends HTMLElement {
|
|
|
316
345
|
const trimmed = rawQuery.trim();
|
|
317
346
|
this.syncClearButton(trimmed);
|
|
318
347
|
|
|
319
|
-
if (!trimmed) {
|
|
348
|
+
if (!trimmed) {
|
|
349
|
+
this.exitFilterMode();
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
320
352
|
|
|
321
353
|
if (!this.openSnapshot) {
|
|
322
|
-
const current
|
|
323
|
-
this.openSnapshot
|
|
354
|
+
const current = new Set(collectExpandedKeys(this));
|
|
355
|
+
this.openSnapshot = new Set(current);
|
|
324
356
|
this.preFilterSnapshot = source === 'user' ? new Set(current) : null;
|
|
325
357
|
this.syncSnapshotAttr();
|
|
326
358
|
}
|
|
@@ -358,7 +390,7 @@ class SidebarFilter extends HTMLElement {
|
|
|
358
390
|
safeSet(DETAILS_KEY, [...restore].join('\n'));
|
|
359
391
|
}
|
|
360
392
|
|
|
361
|
-
this.openSnapshot
|
|
393
|
+
this.openSnapshot = null;
|
|
362
394
|
this.preFilterSnapshot = null;
|
|
363
395
|
this.syncSnapshotAttr();
|
|
364
396
|
this.ensureActiveAncestorsExpanded();
|
|
@@ -385,10 +417,14 @@ class SidebarFilter extends HTMLElement {
|
|
|
385
417
|
/** Run fn with event-driven persistence suppressed. */
|
|
386
418
|
private withSuppressed(fn: () => void): void {
|
|
387
419
|
this.suppressPersist = true;
|
|
388
|
-
try {
|
|
420
|
+
try {
|
|
421
|
+
fn();
|
|
422
|
+
} finally {
|
|
389
423
|
// igcItem* events may fire after a render cycle; release the suppress
|
|
390
424
|
// flag after the next task to be safe.
|
|
391
|
-
setTimeout(() => {
|
|
425
|
+
setTimeout(() => {
|
|
426
|
+
this.suppressPersist = false;
|
|
427
|
+
}, 0);
|
|
392
428
|
}
|
|
393
429
|
}
|
|
394
430
|
|
|
@@ -422,7 +458,7 @@ class SidebarFilter extends HTMLElement {
|
|
|
422
458
|
private markMatches(matches: Set<HTMLElement>): void {
|
|
423
459
|
for (const el of this.items) {
|
|
424
460
|
if (matches.has(el)) el.dataset.filterMatch = 'true';
|
|
425
|
-
else
|
|
461
|
+
else delete el.dataset.filterMatch;
|
|
426
462
|
}
|
|
427
463
|
}
|
|
428
464
|
|
|
@@ -441,7 +477,8 @@ class SidebarFilter extends HTMLElement {
|
|
|
441
477
|
|
|
442
478
|
private updateStatus(state: 'no-match' | null): void {
|
|
443
479
|
if (!this.hasFilter) return;
|
|
444
|
-
this.status.textContent =
|
|
480
|
+
this.status.textContent =
|
|
481
|
+
state === 'no-match' ? (this.dataset.noResults ?? 'No topics match') : '';
|
|
445
482
|
}
|
|
446
483
|
|
|
447
484
|
private syncClearButton(value: string): void {
|