igniteui-astro-components 0.0.1

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.
Files changed (63) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +374 -0
  3. package/package.json +109 -0
  4. package/src/components/DocsSidebar/DocsSidebar.astro +99 -0
  5. package/src/components/DocsSidebar/README.md +166 -0
  6. package/src/components/DocsSidebar/SidebarFilterInput.astro +74 -0
  7. package/src/components/DocsSidebar/SidebarLabel.astro +40 -0
  8. package/src/components/DocsSidebar/sidebar-filter.ts +393 -0
  9. package/src/components/DocsSidebar/toTreeNodes.ts +66 -0
  10. package/src/components/DocsSubHeader/DocsSubHeader.astro +320 -0
  11. package/src/components/DocsSubHeader/README.md +74 -0
  12. package/src/components/DocsToc/DocsToc.astro +307 -0
  13. package/src/components/DocsToc/README.md +68 -0
  14. package/src/components/DocsToc/toTreeNodes.ts +57 -0
  15. package/src/components/DocsTree/DocsTree.astro +66 -0
  16. package/src/components/DocsTree/DocsTreeItem.astro +84 -0
  17. package/src/components/DocsTree/README.md +105 -0
  18. package/src/components/DocsTree/docs-tree.css +227 -0
  19. package/src/components/DocsTree/types.ts +47 -0
  20. package/src/components/GlobalFooter/GlobalFooter.astro +90 -0
  21. package/src/components/GlobalFooter/GlobalFooter.module.scss +23 -0
  22. package/src/components/GlobalFooter/README.md +35 -0
  23. package/src/components/GlobalNavBar/GlobalNavBar.astro +218 -0
  24. package/src/components/GlobalNavBar/GlobalNavBar.module.scss +215 -0
  25. package/src/components/GlobalNavBar/README.md +49 -0
  26. package/src/components/MobileSidebarToggle/MobileSidebarToggle.astro +112 -0
  27. package/src/components/MobileSidebarToggle/README.md +31 -0
  28. package/src/components/Search/README.md +43 -0
  29. package/src/components/Search/Search.astro +222 -0
  30. package/src/components/ThemingWidget/README.md +35 -0
  31. package/src/components/ThemingWidget/ThemingWidget.astro +152 -0
  32. package/src/components/mdx/ApiLink/ApiLink.astro +121 -0
  33. package/src/components/mdx/ApiLink/README.md +68 -0
  34. package/src/components/mdx/ApiRef/ApiRef.astro +92 -0
  35. package/src/components/mdx/ApiRef/README.md +50 -0
  36. package/src/components/mdx/DocsAside/DocsAside.astro +86 -0
  37. package/src/components/mdx/DocsAside/README.md +66 -0
  38. package/src/components/mdx/DocsAside/icons/caution.svg +3 -0
  39. package/src/components/mdx/DocsAside/icons/danger.svg +3 -0
  40. package/src/components/mdx/DocsAside/icons/note.svg +3 -0
  41. package/src/components/mdx/DocsAside/icons/tip.svg +4 -0
  42. package/src/components/mdx/PlatformBlock/PlatformBlock.astro +24 -0
  43. package/src/components/mdx/PlatformBlock/README.md +57 -0
  44. package/src/components/mdx/Sample/README.md +59 -0
  45. package/src/components/mdx/Sample/Sample.astro +142 -0
  46. package/src/content-helper.ts +159 -0
  47. package/src/content.config.ts +17 -0
  48. package/src/index.ts +42 -0
  49. package/src/integration.ts +841 -0
  50. package/src/layouts/DocsLayout/DocsLayout.astro +307 -0
  51. package/src/layouts/DocsLayout/README.md +124 -0
  52. package/src/lib/nav-helpers.ts +155 -0
  53. package/src/lib/platform-context.ts +305 -0
  54. package/src/lib/sidebar/helpers.ts +81 -0
  55. package/src/lib/sidebar/types.ts +36 -0
  56. package/src/llms.ts +315 -0
  57. package/src/platform.ts +281 -0
  58. package/src/plugins/remark-docfx.ts +368 -0
  59. package/src/scripts/sample-widget.ts +516 -0
  60. package/src/sidebar.ts +167 -0
  61. package/src/styles/custom.scss +254 -0
  62. package/src/styles/ig-theme.scss +43 -0
  63. package/src/virtual-modules.d.ts +35 -0
@@ -0,0 +1,227 @@
1
+ /*
2
+ * docs-tree.css — single styling locus for the DocsTree base component.
3
+ *
4
+ * Layered as:
5
+ * 1. Base rules + CSS custom-property contract (both variants)
6
+ * 2. Web component shadow-part normalization
7
+ * 3. [data-variant="sidebar"] overrides
8
+ * 4. [data-variant="toc"] overrides
9
+ *
10
+ * Designers tune values via the `--docs-tree-*` variables. Structural rules
11
+ * live below the variables; per-variant tweaks at the bottom.
12
+ *
13
+ * Layout rules that don't belong to the tree itself (sidebar-filter-igc,
14
+ * .sidebar-scroll, .toc-sidebar, docs-toc h2) stay in their owning component
15
+ * .astro files.
16
+ */
17
+
18
+ /* ── 1. Base + CSS custom-property contract ──────────────────────────────── */
19
+
20
+ igc-tree {
21
+ display: block;
22
+ --docs-tree-row-pad-y: 0.3rem;
23
+ --docs-tree-row-pad-x: 0.5rem;
24
+ --docs-tree-row-radius: 0.25rem;
25
+ --docs-tree-row-color: var(--sl-color-text, inherit);
26
+ --docs-tree-row-hover-bg: color-mix(in srgb, var(--sl-color-accent) 8%, transparent);
27
+ --docs-tree-row-hover-color: var(--sl-color-accent, #3b82f6);
28
+ --docs-tree-row-active-bg: color-mix(in srgb, var(--sl-color-accent) 12%, transparent);
29
+ --docs-tree-row-active-color: var(--sl-color-accent, #3b82f6);
30
+ --docs-tree-group-color: var(--sl-color-gray-3, #888);
31
+ --docs-tree-nested-rule: 1px solid var(--sl-color-hairline, #e2e4e9);
32
+ --docs-tree-nested-pad-x: 0.75rem;
33
+
34
+ /* Web component variables consumed by igc-tree itself. */
35
+ --ig-tree-background: transparent;
36
+ --igc-tree-indentation-size: 0px;
37
+ }
38
+
39
+ /* ── 2. Shadow-part normalization ─────────────────────────────────────────── */
40
+
41
+ igc-tree-item::part(wrapper) {
42
+ padding: 0;
43
+ background: transparent;
44
+ border-radius: 0;
45
+ min-height: unset;
46
+ gap: 0;
47
+ cursor: default;
48
+ }
49
+ igc-tree-item::part(wrapper):hover {
50
+ background: transparent;
51
+ }
52
+ igc-tree-item::part(label) {
53
+ flex: 1;
54
+ min-width: 0;
55
+ overflow: visible;
56
+ }
57
+
58
+ /*
59
+ * Hide the default expand indicator across both variants. The sidebar
60
+ * draws its own caret inside the label slot via SidebarLabel; the toc
61
+ * has no expand UI at all (the scroll-spy drives `expanded` behind the
62
+ * scenes). Replaces the old slot-override pattern.
63
+ */
64
+ igc-tree-item::part(indicator) {
65
+ display: none;
66
+ }
67
+
68
+ /*
69
+ * Keyboard focus and SSR active state are gated on host-level state and
70
+ * styled through the wrapper part:
71
+ * • :focus-visible — keyboard focus on the item host (roving tabindex
72
+ * means only one item is focused at a time; not used for mouse).
73
+ * • [active] — DocsTreeItem sets the `active` attribute on
74
+ * <igc-tree-item> whenever activeId matches the node's id.
75
+ */
76
+ igc-tree-item:focus-visible::part(wrapper) {
77
+ outline: 2px solid var(--sl-color-accent, #3b82f6);
78
+ outline-offset: -2px;
79
+ border-radius: var(--docs-tree-row-radius);
80
+ }
81
+ igc-tree-item[active]::part(wrapper) {
82
+ border-radius: var(--docs-tree-row-radius);
83
+ background: color-mix(in srgb, var(--sl-color-accent) 5%, transparent);
84
+ }
85
+
86
+ /* Default label/link styling — used when consumer omits renderLabel. */
87
+ .docs-tree-link {
88
+ display: flex;
89
+ align-items: center;
90
+ gap: 0.5rem;
91
+ padding: var(--docs-tree-row-pad-y) var(--docs-tree-row-pad-x);
92
+ border-radius: var(--docs-tree-row-radius);
93
+ font-size: var(--sl-text-sm, 0.875rem);
94
+ color: var(--docs-tree-row-color);
95
+ text-decoration: none;
96
+ line-height: 1.4;
97
+ cursor: pointer;
98
+ }
99
+ .docs-tree-link:hover {
100
+ background: var(--docs-tree-row-hover-bg);
101
+ color: var(--docs-tree-row-hover-color);
102
+ text-decoration: none;
103
+ }
104
+ .docs-tree-link[aria-current='page'],
105
+ .docs-tree-link[aria-current='true'] {
106
+ background: var(--docs-tree-row-active-bg);
107
+ color: var(--docs-tree-row-active-color);
108
+ font-weight: 600;
109
+ }
110
+ .docs-tree-label {
111
+ flex: 1;
112
+ min-width: 0;
113
+ overflow: hidden;
114
+ text-overflow: ellipsis;
115
+ white-space: nowrap;
116
+ }
117
+
118
+ /* ── 3. Sidebar variant ──────────────────────────────────────────────────── */
119
+
120
+ /* Group label container (the .docs-tree-group emitted by DocsTreeItem). */
121
+ igc-tree[data-variant='sidebar'] .docs-tree-group {
122
+ display: flex;
123
+ align-items: center;
124
+ gap: 0.5rem;
125
+ font-size: var(--sl-text-xs, 0.75rem);
126
+ font-weight: 700;
127
+ text-transform: uppercase;
128
+ letter-spacing: 0.07em;
129
+ color: var(--docs-tree-group-color);
130
+ padding: 0.5rem 0 0.25rem;
131
+ cursor: pointer;
132
+ user-select: none;
133
+ }
134
+ igc-tree[data-variant='sidebar'] .group-label-text {
135
+ flex: 1;
136
+ min-width: 0;
137
+ overflow: hidden;
138
+ text-overflow: ellipsis;
139
+ white-space: nowrap;
140
+ }
141
+
142
+ /* Caret rotates when the parent <igc-tree-item> reflects [expanded]. */
143
+ igc-tree[data-variant='sidebar'] .group-caret {
144
+ flex-shrink: 0;
145
+ margin-inline-start: auto;
146
+ color: var(--docs-tree-group-color);
147
+ transform: rotate(0deg);
148
+ transition: transform 120ms ease-out;
149
+ }
150
+ igc-tree[data-variant='sidebar'] igc-tree-item[expanded] > [slot='label'] .group-caret {
151
+ transform: rotate(90deg);
152
+ }
153
+ @media (prefers-reduced-motion: reduce) {
154
+ igc-tree[data-variant='sidebar'] .group-caret { transition: none; }
155
+ }
156
+
157
+ /* Nested items: rule + indent. data-depth >= 1 = nested. */
158
+ igc-tree[data-variant='sidebar'] igc-tree-item[data-depth]:not([data-depth='0'])::part(wrapper) {
159
+ padding-inline-start: var(--docs-tree-nested-pad-x);
160
+ border-inline-start: var(--docs-tree-nested-rule);
161
+ margin-inline-start: 0.25rem;
162
+ }
163
+
164
+ /* Badges (rendered by SidebarLabel.astro inside the leaf <a>). */
165
+ igc-tree[data-variant='sidebar'] .sl-badge {
166
+ display: inline-flex;
167
+ align-items: center;
168
+ border-radius: 0.25rem;
169
+ padding: 0.1rem 0.35rem;
170
+ font-size: 0.65rem;
171
+ font-weight: 700;
172
+ text-transform: uppercase;
173
+ letter-spacing: 0.05em;
174
+ border: 1px solid currentColor;
175
+ margin-inline-start: auto;
176
+ flex-shrink: 0;
177
+ }
178
+ igc-tree[data-variant='sidebar'] .sl-badge.default { color: var(--sl-color-gray-3); }
179
+ igc-tree[data-variant='sidebar'] .sl-badge.note { color: hsl(234, 90%, 60%); }
180
+ igc-tree[data-variant='sidebar'] .sl-badge.tip { color: hsl(134, 70%, 38%); }
181
+ igc-tree[data-variant='sidebar'] .sl-badge.success { color: hsl(134, 70%, 38%); }
182
+ igc-tree[data-variant='sidebar'] .sl-badge.caution { color: hsl(40, 90%, 45%); }
183
+ igc-tree[data-variant='sidebar'] .sl-badge.danger { color: hsl(0, 85%, 52%); }
184
+
185
+ /* Filter visibility — driven by <sidebar-filter>. */
186
+ sidebar-filter[data-filtering] igc-tree[data-variant='sidebar'] igc-tree-item[data-path]:not([data-filter-match]) {
187
+ display: none;
188
+ }
189
+
190
+ /* ── 4. Toc variant ──────────────────────────────────────────────────────── */
191
+
192
+ /*
193
+ * Toc has no visible expand UI — the scroll-spy drives `expanded` on
194
+ * parent items behind the scenes; nested entries simply appear when
195
+ * the active section enters their parent. The base `::part(indicator)`
196
+ * rule above already hides the native chevron.
197
+ */
198
+
199
+ /* Toc rows are tighter than sidebar rows. */
200
+ igc-tree[data-variant='toc'] .docs-tree-link {
201
+ display: block;
202
+ padding: 0.25rem 0.5rem;
203
+ color: var(--sl-color-gray-4, #666);
204
+ transition: color 0.15s, background-color 0.15s;
205
+ }
206
+ igc-tree[data-variant='toc'] .docs-tree-link:hover {
207
+ color: var(--sl-color-text, inherit);
208
+ background-color: var(--sl-color-gray-1, #f5f5f5);
209
+ }
210
+ igc-tree[data-variant='toc'] .docs-tree-link[aria-current='true'] {
211
+ color: var(--sl-color-accent-high, #3b82f6);
212
+ background-color: var(--sl-color-accent-low, #eff6ff);
213
+ }
214
+
215
+ /* Top-level toc entries (h2) are bolder. */
216
+ igc-tree[data-variant='toc'] igc-tree-item[data-depth='0'] > [slot='label'] > .docs-tree-link {
217
+ font-weight: 600;
218
+ color: var(--sl-color-text, inherit);
219
+ }
220
+ igc-tree[data-variant='toc'] igc-tree-item[data-depth='0'] > [slot='label'] > .docs-tree-link:hover {
221
+ color: var(--sl-color-text, inherit);
222
+ }
223
+
224
+ /* Nested toc entries get a small indent. */
225
+ igc-tree[data-variant='toc'] igc-tree-item[data-depth]:not([data-depth='0'])::part(wrapper) {
226
+ padding-inline-start: var(--docs-tree-nested-pad-x);
227
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Shared tree data shape for DocsTree — the base tree component that backs
3
+ * both DocsSidebar and DocsToc.
4
+ *
5
+ * Consumers (DocsSidebar, DocsToc) keep their own domain types
6
+ * (SidebarEntry, MarkdownHeading) and convert to TreeNode via small adapters
7
+ * colocated with each consumer:
8
+ * • `src/components/DocsSidebar/toTreeNodes.ts`
9
+ * • `src/components/DocsToc/toTreeNodes.ts`
10
+ */
11
+
12
+ export type TreeVariant = 'sidebar' | 'toc';
13
+
14
+ export interface TreeNode {
15
+ /** Stable identity. Surfaced as `data-tree-id` on the rendered <igc-tree-item>. */
16
+ id: string;
17
+
18
+ /** Plain-text label. Used as the default fallback when no `renderLabel` is given. */
19
+ label: string;
20
+
21
+ /**
22
+ * Present on leaves and on toc nodes (toc parents are also links to their
23
+ * own heading). When present, the label slot is wrapped in `<a href>`.
24
+ */
25
+ href?: string;
26
+
27
+ /**
28
+ * SSR-time expand hint. Sidebar uses this for initial open state; DocsToc
29
+ * renders nodes collapsed at SSR and manages expansion at runtime.
30
+ */
31
+ expanded?: boolean;
32
+
33
+ children?: TreeNode[];
34
+
35
+ /**
36
+ * camelCase keys → kebab-case `data-*` attributes on the <igc-tree-item>.
37
+ * The sidebar filter custom element relies on `data-path`, `data-group-key`,
38
+ * `data-label`, `data-slug`. Pass them here so they survive into the DOM.
39
+ */
40
+ itemData?: Record<string, string>;
41
+
42
+ /** Spread on the leaf <a>. Used for the sidebar's `attrs` passthrough. */
43
+ linkAttrs?: Record<string, string | number | boolean | undefined>;
44
+
45
+ /** Free-form metadata for the consumer's `renderLabel` to read (e.g. badge). */
46
+ meta?: Record<string, unknown>;
47
+ }
@@ -0,0 +1,90 @@
1
+ ---
2
+ /**
3
+ * GlobalFooter
4
+ *
5
+ * Renders the platform-appropriate global footer directly in the light DOM.
6
+ * This component is separate from Starlight's own Footer override (which
7
+ * provides the "Edit this page" link and pagination). Mount it INSIDE the
8
+ * Starlight Footer override to place it below the docs navigation footer.
9
+ *
10
+ * Props:
11
+ * theme – product theme (default: 'angular')
12
+ * lang – locale (default: 'en')
13
+ */
14
+ interface Props {
15
+ /** Override the platform for this instance. Defaults to virtual module value. */
16
+ theme?: NavTheme;
17
+ /** Override the locale. Defaults to virtual module navLang. */
18
+ lang?: NavLang;
19
+ }
20
+
21
+ import {
22
+ platform as virtualPlatform,
23
+ navLang as virtualNavLang,
24
+ abPrefetched, abFooterHtml, abFooterUtilsHtml, abFooterCopyrightHtml, abContactSalesHtml,
25
+ } from 'virtual:docs-template/nav-html';
26
+ import { fetchIgNav } from '../../lib/nav-helpers.ts';
27
+ import styles from './GlobalFooter.module.scss';
28
+ import type { NavLang, NavTheme } from '../../platform.ts';
29
+
30
+ const { theme, lang } = Astro.props as Props;
31
+
32
+ // Props override the virtual module values (allows per-page overrides)
33
+ const resolvedPlatform = theme ?? virtualPlatform ?? 'igniteui';
34
+ const resolvedLang = (lang ?? virtualNavLang ?? 'en') as NavLang;
35
+
36
+ const isAppBuilder = resolvedPlatform === 'appbuilder';
37
+ const isIgPlatform = !isAppBuilder;
38
+
39
+ // For IG platforms, fetch footer HTML directly (cached per locale per build).
40
+ const igNav = isIgPlatform ? await fetchIgNav(resolvedLang) : null;
41
+ ---
42
+ <div class={styles.footer}>
43
+
44
+ {/* === IgniteUI / default Infragistics footer — fetched via fetchIgNav() === */}
45
+ {
46
+ isIgPlatform && igNav?.prefetched && (
47
+ <>
48
+ <Fragment set:html={igNav.uiFooterHtml} />
49
+ {igNav.footerHtml && <Fragment set:html={igNav.footerHtml} />}
50
+ </>
51
+ )
52
+ }
53
+
54
+ {/* === AppBuilder footer (prebuild) === */}
55
+ {
56
+ isAppBuilder && abPrefetched && (
57
+ <>
58
+ {abContactSalesHtml && <Fragment set:html={abContactSalesHtml} />}
59
+ <Fragment set:html={abFooterHtml} />
60
+ {abFooterUtilsHtml && <Fragment set:html={abFooterUtilsHtml} />}
61
+ {abFooterCopyrightHtml && <Fragment set:html={abFooterCopyrightHtml} />}
62
+
63
+ <script is:inline>
64
+ window.addEventListener('load', function () {
65
+ if (window.leadTracker && typeof window.leadTracker.execute === 'function') {
66
+ window.leadTracker.execute({
67
+ macro: 'LeadTracker', lang: 'en',
68
+ leadFormID: 'lead-form_2',
69
+ reaptchaKey: '6Lc-MFAaAAAAAIWi7UOrSUfUZnVmDUSsXjzS4BgY',
70
+ redirectUrl: '', thankYouMessage: '1',
71
+ formContainerId: 'modal-contact-sales-pricing',
72
+ productCode: 'B7', leadProductCode: '', packageName: '',
73
+ productResourceType: '', osSupport: '', installerType: '',
74
+ eventTypeParam: 'contact sales', eventDetailParam: 'form submitted',
75
+ prohibitFreeMail: true, showRequestDemo: false,
76
+ googleEventType: 'Form Submit',
77
+ googleEventLabel: 'Slingshot - Contact Sales Pricing',
78
+ googleEventTypeDownload: '', googleEventLabelDownload: '',
79
+ zoomWebinarId: ''
80
+ });
81
+ }
82
+ if (window.customModal && typeof window.customModal.init === 'function') {
83
+ window.customModal.init();
84
+ }
85
+ });
86
+ </script>
87
+ </>
88
+ )
89
+ }
90
+ </div>
@@ -0,0 +1,23 @@
1
+ /*
2
+ * GlobalFooter — CSS Module styles
3
+ *
4
+ * Theming tokens (override from consumer CSS):
5
+ * --footer-bg background colour (default: #f8f8f8)
6
+ */
7
+
8
+ .footer {
9
+ --footer-bg: #f8f8f8;
10
+
11
+ // Element selector — not hashed by CSS Modules.
12
+ footer {
13
+ position: relative;
14
+ z-index: 1000;
15
+ }
16
+
17
+ // .footer is a class name from injected footerHtml — must use :global()
18
+ // so CSS Modules doesn't hash it and break the match.
19
+ :global(.footer) {
20
+ background-color: var(--footer-bg, inherit);
21
+ padding: 15px 0;
22
+ }
23
+ }
@@ -0,0 +1,35 @@
1
+ # GlobalFooter
2
+
3
+ Renders the platform-appropriate global footer in the light DOM. Supports the same platform themes as `GlobalNavBar`.
4
+
5
+ ## Import
6
+
7
+ ```astro
8
+ import GlobalFooter from 'igniteui-astro-components/components/GlobalFooter.astro';
9
+ ```
10
+
11
+ ## Props
12
+
13
+ | Prop | Type | Default | Description |
14
+ |------|------|---------|-------------|
15
+ | `theme` | `NavTheme` | virtual module value | Override the platform theme for this instance. |
16
+ | `lang` | `NavLang` | virtual module value | Override the locale (`'en'` \| `'jp'` \| `'kr'`). |
17
+
18
+ ## Behaviour
19
+
20
+ - **Pre-build path** — renders pre-fetched footer HTML when available.
21
+ - **Static fallback** — falls back to a minimal server-side footer in dev.
22
+ - Separate from Starlight's own Footer override. If you are using Starlight, mount this component *inside* the Starlight Footer override so both footers appear in the correct order.
23
+
24
+ ## Example
25
+
26
+ ```astro
27
+ ---
28
+ import GlobalFooter from 'igniteui-astro-components/components/GlobalFooter.astro';
29
+ ---
30
+ <GlobalFooter />
31
+ ```
32
+
33
+ ## Configuration
34
+
35
+ Same as `GlobalNavBar` — set `platform` and `navLang` in `createDocsSite()`.
@@ -0,0 +1,218 @@
1
+ ---
2
+ /**
3
+ * GlobalNavBar
4
+ *
5
+ * Renders the platform-appropriate global navigation bar directly in the
6
+ * light DOM. Platform is driven by `siteMetaIntegration({ platform })` in
7
+ * astro.config.ts (exported from the virtual module) and can be overridden
8
+ * per-instance via the `theme` prop.
9
+ *
10
+ * Platforms:
11
+ * igniteui / angular / react / blazor / web-components / slingshot
12
+ * → IG global nav (infragistics.com). Prebuild path uses virtual module
13
+ * headerHtml. Static fallback renders the minimal nav server-side.
14
+ * appbuilder
15
+ * → AppBuilder nav (appbuilder.dev). Prebuild uses abHeaderHtml.
16
+ * Runtime fallback uses the XHR includeContent pattern.
17
+ *
18
+ * CDN styles/scripts for each platform are already injected into <head> by
19
+ * getPlatformHead() in astro.config.ts — not repeated here.
20
+ */
21
+ import {
22
+ platform as virtualPlatform,
23
+ navLang as virtualNavLang,
24
+ abPrefetched,
25
+ abHeaderHtml,
26
+ } from 'virtual:docs-template/nav-html';
27
+ import { fetchIgNav } from '../../lib/nav-helpers.ts';
28
+ import styles from './GlobalNavBar.module.scss';
29
+ import type { NavLang, NavTheme } from '../../platform.ts';
30
+
31
+ interface Props {
32
+ /** Override the platform for this instance. Defaults to virtual module value. */
33
+ theme?: NavTheme;
34
+ /** Override the locale. Defaults to virtual module navLang. */
35
+ lang?: NavLang;
36
+ }
37
+
38
+ const { theme, lang } = Astro.props as Props;
39
+
40
+ // Props override the virtual module values (allows per-page overrides)
41
+ const resolvedPlatform = theme ?? virtualPlatform ?? 'igniteui';
42
+ const resolvedLang = (lang ?? virtualNavLang ?? 'en') as NavLang;
43
+
44
+ const isJa = resolvedLang === 'jp';
45
+ const isKr = resolvedLang === 'kr';
46
+ const isAppBuilder = resolvedPlatform === 'appbuilder';
47
+ // All IG-family platforms share the same global nav
48
+ const isIgPlatform = !isAppBuilder;
49
+
50
+ const igBase = isJa ? 'https://jp.infragistics.com' : 'https://www.infragistics.com';
51
+
52
+ // For IG platforms, fetch nav HTML directly (cached per locale per build).
53
+ // AppBuilder still uses the virtual module path below.
54
+ const igNav = isIgPlatform ? await fetchIgNav(resolvedLang) : null;
55
+ ---
56
+
57
+ {/* ============================================================
58
+ IG-family global nav (angular, react, blazor, web-components,
59
+ slingshot, igniteui)
60
+ ============================================================ */}
61
+ <div class={styles.navBar} transition:persist="global-nav-bar">
62
+ {/* IG nav — fetched directly via fetchIgNav(); falls back to static markup */}
63
+ {isIgPlatform && igNav?.prefetched && <Fragment set:html={igNav.headerHtml} />}
64
+
65
+ {/* Static fallback — rendered when the fetch is unavailable (offline build) */}
66
+ {isIgPlatform && !igNav?.prefetched && (
67
+ <header id="header" class="globalnav" data-nav-auto-init="false">
68
+ <section id="header-wrap" class="globalnav__container" data-default-height="175" data-sticky-height="60">
69
+ <section class="globalnav__primary clearfix">
70
+ <div class="globalnav__wrapper">
71
+ <div class="globalnav__brand">
72
+ <a href={igBase}>
73
+ <img class="globalnav__logo" src="https://static.infragistics.com/marketing/Website/products/ignite-ui/ignite-ui-logo.svg" alt="Infragistics Logo" />
74
+ </a>
75
+ </div>
76
+ <nav class="globalnav__nav">
77
+ {isJa ? (
78
+ <ul class="globalnav__menu">
79
+ <li class="globalnav__item"><a class="globalnav__link" href="https://jp.infragistics.com/products">製品</a></li>
80
+ <li class="globalnav__item"><a class="globalnav__link" href="https://jp.infragistics.com/community/blogs">ブログ</a></li>
81
+ <li class="globalnav__item"><a class="globalnav__link" href="https://jp.infragistics.com/support">サポート</a></li>
82
+ </ul>
83
+ ) : isKr ? (
84
+ <ul class="globalnav__menu">
85
+ <li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/products">제품</a></li>
86
+ <li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/community/blogs">블로그</a></li>
87
+ <li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/support">지원</a></li>
88
+ </ul>
89
+ ) : (
90
+ <ul class="globalnav__menu">
91
+ <li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/products">Products</a></li>
92
+ <li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/community/blogs">Blog</a></li>
93
+ <li class="globalnav__item"><a class="globalnav__link" href="https://www.infragistics.com/support">Support</a></li>
94
+ </ul>
95
+ )}
96
+ </nav>
97
+ <div class="globalnav__overlay"></div>
98
+ </div>
99
+ </section>
100
+ </section>
101
+ </header>
102
+ )}
103
+
104
+ {/* ============================================================
105
+ AppBuilder nav
106
+ ============================================================ */}
107
+ {isAppBuilder && (
108
+ <>
109
+ {/* Prebuild path — AB header HTML captured at build time */}
110
+ {abPrefetched && (
111
+ <>
112
+ <Fragment set:html={abHeaderHtml} />
113
+ <script is:inline>
114
+ window.addEventListener('load', function () {
115
+ // Fix language-bar links (depends on current page URL at runtime)
116
+ var langBar = document.querySelector('.mega-lang-bar');
117
+ if (langBar) {
118
+ langBar.innerHTML =
119
+ '<a class="mega-custom-icon mega-menu-link" href="#" aria-expanded="false" tabindex="0" aria-label="LangBar">' +
120
+ '<span class="mega-indicator" aria-hidden="true"></span></a>' +
121
+ '<ul class="mega-sub-menu"><li class="mega-menu-item" id="mega-menu-item-8148"><div class="wovn-languages">' +
122
+ '<a href="' + window.location.href.replace('/ja/help/', '/help/') + '" style="display:block;padding-left:10px;color:gray;font-weight:300;">English</a>' +
123
+ '<a href="' + window.location.href.replace('/help/', '/ja/help/') + '" style="display:block;padding-left:10px;color:gray;font-weight:300;">日本語</a>' +
124
+ '</div></li></ul>';
125
+ }
126
+ // Initialise mega menu
127
+ if (window.jQuery && typeof window.jQuery('.max-mega-menu').maxmegamenu === 'function') {
128
+ window.jQuery('.max-mega-menu').maxmegamenu();
129
+ }
130
+ // Search toggle
131
+ var searchIcon = document.querySelector('.mega-search .search-icon');
132
+ var searchInput = document.querySelector('.mega-search input[type=text]');
133
+ if (searchIcon) searchIcon.onclick = function () { _abSearchToggle(); };
134
+ if (searchInput) searchInput.onblur = function () { _abSearchToggle(); };
135
+
136
+ function _abSearchToggle() {
137
+ var form = document.querySelector('.mega-search');
138
+ var inp = document.querySelector('.mega-search input[type=text]');
139
+ if (!form) return;
140
+ if (form.classList.contains('mega-search-open')) {
141
+ form.classList.replace('mega-search-open', 'mega-search-closed');
142
+ if (inp) { inp.setAttribute('placeholder', ''); inp.value = ''; inp.setAttribute('tabindex', '0'); }
143
+ } else {
144
+ form.classList.replace('mega-search-closed', 'mega-search-open');
145
+ if (inp) { inp.setAttribute('placeholder', 'Search...'); inp.focus(); inp.setAttribute('tabindex', '-1'); }
146
+ }
147
+ }
148
+ });
149
+ </script>
150
+ </>
151
+ )}
152
+
153
+ {/*
154
+ Runtime fallback — XHR fetch of AB header at page load.
155
+ ---------------------------------------------------------
156
+ This path executes when the build-time prefetch of
157
+ https://www.appbuilder.dev/header-footer-export was unavailable
158
+ (abPrefetched === false).
159
+
160
+ It fires a client-side XHR on window load and injects the returned
161
+ headerHtml into #ab-nav-container. The footerHtml is appended to
162
+ document.getElementById('footer'), which may conflict with the
163
+ GlobalFooter component rendered by CustomPageFrame.
164
+
165
+ Known downsides:
166
+ - Visible layout shift: header appears only after the page load event.
167
+ - Requires the client to reach appbuilder.dev at runtime (cross-origin).
168
+ - The footer injection target (#footer) is fragile and couples
169
+ this component to the DOM shape of GlobalFooter.
170
+
171
+ TODO: Consider removing this fallback entirely. If the build-time
172
+ prefetch is consistently reliable, this branch is never reached. A static
173
+ minimal fallback or a clear error state would be more predictable than a
174
+ delayed XHR-driven render.
175
+ */}
176
+ {!abPrefetched && (
177
+ <>
178
+ <div id="ab-nav-container"></div>
179
+ <script is:inline>
180
+ (function () {
181
+ var includeContent = {
182
+ settings: {
183
+ url: 'https://www.appbuilder.dev/header-footer-export',
184
+ selector: '#header-container',
185
+ },
186
+ processInclude: function () {
187
+ var self = this;
188
+ var xhr = new XMLHttpRequest();
189
+ xhr.open('GET', self.settings.url, true);
190
+ xhr.onreadystatechange = function () {
191
+ if (xhr.readyState === 4 && xhr.status === 200) {
192
+ try {
193
+ var data = JSON.parse(xhr.responseText);
194
+ var header = data.headerHtml || '';
195
+ var footer = data.footerHtml || '';
196
+ var container = document.getElementById('ab-nav-container');
197
+ if (container) container.innerHTML = header;
198
+ var footerEl = document.getElementById('footer');
199
+ if (footerEl) footerEl.innerHTML += footer;
200
+ } catch (e) {
201
+ /* no-op – nav unavailable */
202
+ }
203
+ }
204
+ };
205
+ xhr.send();
206
+ },
207
+ };
208
+ window.addEventListener('load', function () {
209
+ includeContent.processInclude();
210
+ });
211
+ })();
212
+ </script>
213
+ </>
214
+ )}
215
+ </>
216
+ )}
217
+
218
+ </div>