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,305 @@
1
+ /**
2
+ * Typed platform configuration — replaces the per-platform `replacements`
3
+ * array in docConfig.json with a first-class TypeScript object.
4
+ *
5
+ * Components and MDX files import `getPlatformContext()` directly instead of
6
+ * relying on string-replacement tokens like {Platform} or {ProductName}.
7
+ */
8
+
9
+ import fs from 'node:fs';
10
+ import path from 'node:path';
11
+
12
+ export type PlatformName = 'Angular' | 'React' | 'WebComponents' | 'Blazor';
13
+
14
+ export interface ApiPackageConfig {
15
+ /** TypeDoc documentation root URL (no trailing slash). */
16
+ docRoot: string;
17
+ /**
18
+ * Package identifier as it appears in the TypeDoc URL path.
19
+ * Core packages use hyphens ("igniteui-react"),
20
+ * sub-packages use underscores ("igniteui_react_charts").
21
+ */
22
+ packageId: string;
23
+ /**
24
+ * When true the package prefix is omitted from the class URL, e.g.
25
+ * Angular docs use `/classes/IgxGridComponent.html` (no `packageId.` prefix).
26
+ */
27
+ noPackagePrefix?: boolean;
28
+ /**
29
+ * When true the class name casing is preserved as-is (no .toLowerCase()).
30
+ * New-style API sites (react-apis-new, wc-apis-new, blazor-apis-new) use PascalCase URLs.
31
+ */
32
+ preserveCase?: boolean;
33
+ /**
34
+ * Optional suffix appended to the class name before lowercasing, e.g.
35
+ * Angular DV packages append "Component" so `CategoryChart` resolves to
36
+ * `igniteui_angular_charts.igxcategorychartcomponent.html`.
37
+ * Only applied when `prefixed={true}`.
38
+ */
39
+ classSuffix?: string;
40
+ /**
41
+ * When true, member anchor names are PascalCase (first letter uppercased).
42
+ * Blazor TypeDoc uses PascalCase anchors, e.g. `#SingleExpand` instead of `#singleExpand`.
43
+ */
44
+ pascalCaseMembers?: boolean;
45
+ }
46
+
47
+ export interface PlatformContext {
48
+ name: PlatformName;
49
+ /** Lower-case slug used in URLs, e.g. "angular" */
50
+ lower: string;
51
+ /** Component class prefix, e.g. "Igx" / "Igr" / "Igc" / "Igb" */
52
+ prefix: string;
53
+ productName: string;
54
+ productSpinal: string;
55
+ /**
56
+ * Per-package API documentation config keyed by short name.
57
+ * "core" is always the main component package.
58
+ * Other keys match the logical package category: "charts", "grids",
59
+ * "gauges", "maps", "inputs", "layouts", "excel", "spreadsheet", etc.
60
+ *
61
+ * URL for a class: {docRoot}/classes/{packageId}.{PrefixType}.html
62
+ * URL for a member: {docRoot}/classes/{packageId}.{PrefixType}.html#{member}
63
+ */
64
+ apiPackages: Record<string, ApiPackageConfig>;
65
+ packages: {
66
+ common: string;
67
+ charts: string;
68
+ grids: string;
69
+ gauges: string;
70
+ maps: string;
71
+ };
72
+ links: {
73
+ github: string;
74
+ forums: string;
75
+ repoSamples: string;
76
+ };
77
+ }
78
+
79
+ const PLATFORMS: Record<PlatformName, PlatformContext> = {
80
+ Angular: {
81
+ name: 'Angular',
82
+ lower: 'angular',
83
+ prefix: 'Igx',
84
+ productName: 'Ignite UI for Angular',
85
+ productSpinal: 'ignite-ui-angular',
86
+ apiPackages: {
87
+ core: { docRoot: 'https://staging.infragistics.com/angular-apis-new/angular/igniteui-angular/latest', packageId: 'igniteui-angular', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
88
+ charts: { docRoot: 'https://staging.infragistics.com/angular-apis-new/angular/igniteui-angular-charts/latest', packageId: 'igniteui-angular-charts', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
89
+ grids: { docRoot: 'https://staging.infragistics.com/angular-apis-new/angular/igniteui-angular/latest', packageId: 'igniteui-angular', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
90
+ gauges: { docRoot: 'https://staging.infragistics.com/angular-apis-new/angular/igniteui-angular-gauges/latest', packageId: 'igniteui-angular-gauges', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
91
+ maps: { docRoot: 'https://staging.infragistics.com/angular-apis-new/angular/igniteui-angular-maps/latest', packageId: 'igniteui-angular-maps', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
92
+ excel: { docRoot: 'https://staging.infragistics.com/angular-apis-new/angular/igniteui-angular-excel/latest', packageId: 'igniteui-angular-excel', noPackagePrefix: true, preserveCase: true },
93
+ spreadsheet: { docRoot: 'https://staging.infragistics.com/angular-apis-new/angular/igniteui-angular-spreadsheet/latest', packageId: 'igniteui-angular-spreadsheet', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
94
+ inputs: { docRoot: 'https://staging.infragistics.com/angular-apis-new/angular/igniteui-angular-inputs/latest', packageId: 'igniteui-angular-inputs', noPackagePrefix: true, preserveCase: true },
95
+ layouts: { docRoot: 'https://staging.infragistics.com/angular-apis-new/angular/igniteui-angular-layouts/latest', packageId: 'igniteui-angular-layouts', noPackagePrefix: true, preserveCase: true },
96
+ },
97
+ packages: {
98
+ common: 'igniteui-angular',
99
+ charts: 'igniteui-angular-charts',
100
+ grids: 'igniteui-angular',
101
+ gauges: 'igniteui-angular-gauges',
102
+ maps: 'igniteui-angular-maps',
103
+ },
104
+ links: {
105
+ github: 'https://github.com/IgniteUI/igniteui-angular',
106
+ forums: 'https://www.infragistics.com/community/forums/f/ignite-ui-for-angular',
107
+ repoSamples: 'https://github.com/IgniteUI/igniteui-angular-examples/tree/master/samples',
108
+ },
109
+ },
110
+ React: {
111
+ name: 'React',
112
+ lower: 'react',
113
+ prefix: 'Igr',
114
+ productName: 'Ignite UI for React',
115
+ productSpinal: 'ignite-ui-react',
116
+ apiPackages: {
117
+ core: { docRoot: 'https://staging.infragistics.com/react-apis-new/react/igniteui-react/19.5.1', packageId: 'igniteui-react', noPackagePrefix: true, preserveCase: true },
118
+ charts: { docRoot: 'https://staging.infragistics.com/react-apis-new/react/igniteui-react-charts/latest', packageId: 'igniteui-react-charts', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
119
+ grids: { docRoot: 'https://staging.infragistics.com/react-apis-new/react/igniteui-react-grids/19.5.1', packageId: 'igniteui-react-grids', noPackagePrefix: true, preserveCase: true },
120
+ gauges: { docRoot: 'https://staging.infragistics.com/react-apis-new/react/igniteui-react-gauges/latest', packageId: 'igniteui-react-gauges', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
121
+ maps: { docRoot: 'https://staging.infragistics.com/react-apis-new/react/igniteui-react-maps/latest', packageId: 'igniteui-react-maps', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
122
+ inputs: { docRoot: 'https://staging.infragistics.com/react-apis-new/react/igniteui-react-inputs/latest', packageId: 'igniteui-react-inputs', noPackagePrefix: true, preserveCase: true },
123
+ layouts: { docRoot: 'https://staging.infragistics.com/react-apis-new/react/igniteui-react-layouts/latest', packageId: 'igniteui-react-layouts', noPackagePrefix: true, preserveCase: true },
124
+ excel: { docRoot: 'https://staging.infragistics.com/react-apis-new/react/igniteui-react-excel/latest', packageId: 'igniteui-react-excel', noPackagePrefix: true, preserveCase: true },
125
+ spreadsheet: { docRoot: 'https://staging.infragistics.com/react-apis-new/react/igniteui-react-spreadsheet/latest', packageId: 'igniteui-react-spreadsheet', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
126
+ datasources: { docRoot: 'https://staging.infragistics.com/react-apis-new/react/igniteui-react-datasources/latest', packageId: 'igniteui-react-datasources', noPackagePrefix: true, preserveCase: true },
127
+ 'grid-lite': { docRoot: 'https://staging.infragistics.com/react-apis-new/react/igniteui-react-grids/19.5.1', packageId: 'igniteui-react-grids', noPackagePrefix: true, preserveCase: true },
128
+ },
129
+ packages: {
130
+ common: '@infragistics/igniteui-react',
131
+ charts: '@infragistics/igniteui-react-charts',
132
+ grids: '@infragistics/igniteui-react-grids',
133
+ gauges: '@infragistics/igniteui-react-gauges',
134
+ maps: '@infragistics/igniteui-react-maps',
135
+ },
136
+ links: {
137
+ github: 'https://github.com/IgniteUI/igniteui-react',
138
+ forums: 'https://www.infragistics.com/community/forums/f/ignite-ui-for-react',
139
+ repoSamples: 'https://github.com/IgniteUI/igniteui-react-examples/tree/master/samples',
140
+ },
141
+ },
142
+ WebComponents: {
143
+ name: 'WebComponents',
144
+ lower: 'webcomponents',
145
+ prefix: 'Igc',
146
+ productName: 'Ignite UI for Web Components',
147
+ productSpinal: 'ignite-ui-web-components',
148
+ apiPackages: {
149
+ core: { docRoot: 'https://staging.infragistics.com/wc-apis-new/wc/igniteui-webcomponents/latest', packageId: 'igniteui-webcomponents', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
150
+ charts: { docRoot: 'https://staging.infragistics.com/wc-apis-new/wc/igniteui-webcomponents-charts/latest', packageId: 'igniteui-webcomponents-charts', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
151
+ grids: { docRoot: 'https://staging.infragistics.com/wc-apis-new/wc/igniteui-webcomponents-grids/latest', packageId: 'igniteui-webcomponents-grids', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
152
+ gauges: { docRoot: 'https://staging.infragistics.com/wc-apis-new/wc/igniteui-webcomponents-gauges/latest', packageId: 'igniteui-webcomponents-gauges', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
153
+ maps: { docRoot: 'https://staging.infragistics.com/wc-apis-new/wc/igniteui-webcomponents-maps/latest', packageId: 'igniteui-webcomponents-maps', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
154
+ inputs: { docRoot: 'https://staging.infragistics.com/wc-apis-new/wc/igniteui-webcomponents-inputs/latest', packageId: 'igniteui-webcomponents-inputs', noPackagePrefix: true, preserveCase: true },
155
+ layouts: { docRoot: 'https://staging.infragistics.com/wc-apis-new/wc/igniteui-webcomponents-layouts/latest', packageId: 'igniteui-webcomponents-layouts', noPackagePrefix: true, preserveCase: true },
156
+ excel: { docRoot: 'https://staging.infragistics.com/wc-apis-new/wc/igniteui-webcomponents-excel/latest', packageId: 'igniteui-webcomponents-excel', noPackagePrefix: true, preserveCase: true },
157
+ spreadsheet: { docRoot: 'https://staging.infragistics.com/wc-apis-new/wc/igniteui-webcomponents-spreadsheet/latest', packageId: 'igniteui-webcomponents-spreadsheet', noPackagePrefix: true, preserveCase: true, classSuffix: 'Component' },
158
+ datasources: { docRoot: 'https://staging.infragistics.com/wc-apis-new/wc/igniteui-webcomponents-datasources/latest', packageId: 'igniteui-webcomponents-datasources', noPackagePrefix: true, preserveCase: true },
159
+ 'grid-lite': { docRoot: 'https://staging.infragistics.com/wc-apis-new/wc/igniteui-grid-lite/latest', packageId: 'igniteui-grid-lite', noPackagePrefix: true, preserveCase: true },
160
+ },
161
+ packages: {
162
+ common: 'igniteui-webcomponents',
163
+ charts: 'igniteui-webcomponents-charts',
164
+ grids: 'igniteui-webcomponents-grids',
165
+ gauges: 'igniteui-webcomponents-gauges',
166
+ maps: 'igniteui-webcomponents-maps',
167
+ },
168
+ links: {
169
+ github: 'https://github.com/IgniteUI/igniteui-webcomponents',
170
+ forums: 'https://www.infragistics.com/community/forums/f/ignite-ui-for-web-components',
171
+ repoSamples: 'https://github.com/IgniteUI/igniteui-webcomponents-examples/tree/master/samples',
172
+ },
173
+ },
174
+ Blazor: {
175
+ name: 'Blazor',
176
+ lower: 'blazor',
177
+ prefix: 'Igb',
178
+ productName: 'Ignite UI for Blazor',
179
+ productSpinal: 'ignite-ui-blazor',
180
+ apiPackages: {
181
+ core: { docRoot: 'https://staging.infragistics.com/blazor-apis-new/blazor/IgniteUI.Blazor/25.1.x', packageId: 'IgniteUI.Blazor', noPackagePrefix: true, preserveCase: true, pascalCaseMembers: true },
182
+ charts: { docRoot: 'https://staging.infragistics.com/blazor-apis-new/blazor/IgniteUI.Blazor/25.1.x', packageId: 'IgniteUI.Blazor', noPackagePrefix: true, preserveCase: true, pascalCaseMembers: true },
183
+ grids: { docRoot: 'https://staging.infragistics.com/blazor-apis-new/blazor/IgniteUI.Blazor/25.1.x', packageId: 'IgniteUI.Blazor', noPackagePrefix: true, preserveCase: true, pascalCaseMembers: true },
184
+ gauges: { docRoot: 'https://staging.infragistics.com/blazor-apis-new/blazor/IgniteUI.Blazor/25.1.x', packageId: 'IgniteUI.Blazor', noPackagePrefix: true, preserveCase: true, pascalCaseMembers: true },
185
+ maps: { docRoot: 'https://staging.infragistics.com/blazor-apis-new/blazor/IgniteUI.Blazor/25.1.x', packageId: 'IgniteUI.Blazor', noPackagePrefix: true, preserveCase: true, pascalCaseMembers: true },
186
+ excel: { docRoot: 'https://staging.infragistics.com/blazor-apis-new/blazor/IgniteUI.Blazor.Documents.Excel/25.1.x', packageId: 'IgniteUI.Blazor.Documents.Excel', noPackagePrefix: true, preserveCase: true, pascalCaseMembers: true },
187
+ spreadsheet: { docRoot: 'https://staging.infragistics.com/blazor-apis-new/blazor/IgniteUI.Blazor/25.1.x', packageId: 'IgniteUI.Blazor', noPackagePrefix: true, preserveCase: true, pascalCaseMembers: true },
188
+ 'grid-lite': { docRoot: 'https://staging.infragistics.com/blazor-apis-new/blazor/IgniteUI.Blazor.GridLite/25.1.x', packageId: 'IgniteUI.Blazor.GridLite', noPackagePrefix: true, preserveCase: true, pascalCaseMembers: true },
189
+ },
190
+ packages: {
191
+ common: 'IgniteUI.Blazor',
192
+ charts: 'IgniteUI.Blazor',
193
+ grids: 'IgniteUI.Blazor',
194
+ gauges: 'IgniteUI.Blazor',
195
+ maps: 'IgniteUI.Blazor',
196
+ },
197
+ links: {
198
+ github: 'https://github.com/IgniteUI/igniteui-blazor',
199
+ forums: 'https://www.infragistics.com/community/forums/f/ignite-ui-for-blazor',
200
+ repoSamples: 'https://github.com/IgniteUI/igniteui-blazor-examples/tree/master/samples',
201
+ },
202
+ },
203
+ };
204
+
205
+ let _ctx: PlatformContext | null = null;
206
+ let _env: Record<string, string> | null = null;
207
+
208
+ /**
209
+ * Returns the platform context for the current build.
210
+ * Resolution order: PLATFORM env var → .platform.json → 'React' default.
211
+ *
212
+ * Result is cached for the build lifetime.
213
+ */
214
+ export function getPlatformContext(): PlatformContext {
215
+ if (_ctx) return _ctx;
216
+
217
+ let name: PlatformName = 'React';
218
+
219
+ const envPlatform = process.env.PLATFORM as PlatformName | undefined;
220
+ if (envPlatform && PLATFORMS[envPlatform]) {
221
+ name = envPlatform;
222
+ } else {
223
+ try {
224
+ const cfgPath = path.resolve(process.cwd(), '.platform.json');
225
+ if (fs.existsSync(cfgPath)) {
226
+ const cfg = JSON.parse(fs.readFileSync(cfgPath, 'utf-8'));
227
+ if (cfg.platform && PLATFORMS[cfg.platform as PlatformName]) {
228
+ name = cfg.platform as PlatformName;
229
+ }
230
+ }
231
+ } catch { /* use default */ }
232
+ }
233
+
234
+ _ctx = PLATFORMS[name];
235
+ return _ctx;
236
+ }
237
+
238
+ /**
239
+ * Reads the environment variables for the current build mode.
240
+ * Resolves {environment:key} tokens used by components and the Vite plugin.
241
+ *
242
+ * Returns an empty object if environment.json is not found (e.g. before
243
+ * generate.mjs has run — or when environment.json is absorbed into this config
244
+ * in a full MDX migration).
245
+ */
246
+ export function getEnvVars(): Record<string, string> {
247
+ if (_env) return _env;
248
+
249
+ const { name } = getPlatformContext();
250
+ const lang = process.env.LANG_CODE ?? 'en';
251
+ const mode = process.env.DOCS_ENV ?? process.env.NODE_ENV ?? 'development';
252
+
253
+ // Primary: generated/environment.json (written by generate.mjs when present)
254
+ try {
255
+ const envPath = path.resolve(process.cwd(), 'generated', name, lang, 'environment.json');
256
+ const all = JSON.parse(fs.readFileSync(envPath, 'utf-8'));
257
+ const vars = (all[mode] ?? all['development'] ?? {}) as Record<string, string>;
258
+ if (Object.keys(vars).length > 0) {
259
+ _env = vars;
260
+ return _env;
261
+ }
262
+ } catch { /* fall through */ }
263
+
264
+ // Secondary: DOCS_SOURCE_PATH-based environment.json (Angular docs approach)
265
+ try {
266
+ const sourcePath = process.env.DOCS_SOURCE_PATH;
267
+ if (sourcePath) {
268
+ const sourceRoot = path.resolve(sourcePath);
269
+ const parent = path.dirname(sourceRoot);
270
+ const candidates = [
271
+ path.join(sourceRoot, 'en', 'environment.json'),
272
+ path.join(sourceRoot, 'environment.json'),
273
+ path.join(parent, 'environment.json'),
274
+ path.join(parent, 'en', 'environment.json'),
275
+ ];
276
+ const envPath = candidates.find(c => fs.existsSync(c));
277
+ if (envPath) {
278
+ const all = JSON.parse(fs.readFileSync(envPath, 'utf-8'));
279
+ const vars = (all[mode] ?? all['production'] ?? {}) as Record<string, string>;
280
+ if (Object.keys(vars).length > 0) {
281
+ _env = vars;
282
+ return _env;
283
+ }
284
+ }
285
+ }
286
+ } catch { /* fall through to docConfig fallback */ }
287
+
288
+ // Fallback: read samplesBrowsers directly from docConfig.json — no generate step needed.
289
+ // This is the only source needed in a full-MDX build where generate.mjs is not run.
290
+ try {
291
+ const docConfig = JSON.parse(fs.readFileSync(path.resolve(process.cwd(), 'docConfig.json'), 'utf-8'));
292
+ const demosUrl: string = docConfig[name]?.samplesBrowsers?.[mode]
293
+ ?? docConfig[name]?.samplesBrowsers?.['development']
294
+ ?? '';
295
+ _env = {
296
+ dvDemosBaseUrl: demosUrl,
297
+ demosBaseUrl: demosUrl,
298
+ infragisticsBaseUrl: 'https://www.infragistics.com',
299
+ };
300
+ } catch {
301
+ _env = {};
302
+ }
303
+
304
+ return _env!;
305
+ }
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Pure sidebar tree helpers — no DOM, no I/O.
3
+ * Shared by the SSR components and any consumer that walks the tree.
4
+ */
5
+
6
+ import type { SidebarEntry, SidebarGroup } from './types';
7
+
8
+ export const isGroup = (e: SidebarEntry): e is SidebarGroup => 'items' in e;
9
+
10
+ export const normalizeSlug = (slug: string): string => slug.replace(/^\/|\/$/g, '');
11
+
12
+ export const isActive = (slug: string, current: string): boolean =>
13
+ normalizeSlug(slug) === normalizeSlug(current);
14
+
15
+ /** True if any descendant link matches the current slug. */
16
+ export const hasActive = (items: SidebarEntry[], current: string): boolean =>
17
+ items.some((item) =>
18
+ isGroup(item) ? hasActive(item.items, current) : isActive(item.slug, current),
19
+ );
20
+
21
+ /** Stable path key: ancestor labels + own label, joined with `>`. */
22
+ export const joinPath = (ancestors: string[], label: string): string =>
23
+ [...ancestors, label].join('>');
24
+
25
+ /**
26
+ * Initial open state for a group:
27
+ * • forced open if it contains the active page
28
+ * • otherwise driven by the group's `collapsed` flag (open when not collapsed)
29
+ *
30
+ * Convention used by `buildSidebarFromToc`: root groups have `collapsed:false`,
31
+ * nested groups have `collapsed:true`.
32
+ */
33
+ export const isInitiallyOpen = (group: SidebarGroup, currentSlug: string): boolean =>
34
+ hasActive(group.items, currentSlug) || group.collapsed === false;
35
+
36
+ /**
37
+ * Walk the sidebar tree to find the active link, returning the chain of
38
+ * ancestor group labels (root-first). Returns `[]` if the slug is not found.
39
+ *
40
+ * getAncestorTrail(tree, 'grids/data-grid/editing')
41
+ * // → ['Grids & Lists', 'Data Grid', 'Editing']
42
+ */
43
+ export const getAncestorTrail = (
44
+ items: SidebarEntry[],
45
+ currentSlug: string,
46
+ trail: string[] = [],
47
+ ): string[] => {
48
+ for (const item of items) {
49
+ if (isGroup(item)) {
50
+ const found = getAncestorTrail(item.items, currentSlug, [...trail, item.label]);
51
+ if (found.length > 0) return found;
52
+ } else if (isActive(item.slug, currentSlug)) {
53
+ return trail;
54
+ }
55
+ }
56
+ return [];
57
+ };
58
+
59
+ /** Returns the active link's own label, or `''` if the slug is not in the tree. */
60
+ export const getActiveLabel = (items: SidebarEntry[], currentSlug: string): string => {
61
+ for (const item of items) {
62
+ if (isGroup(item)) {
63
+ const found = getActiveLabel(item.items, currentSlug);
64
+ if (found) return found;
65
+ } else if (isActive(item.slug, currentSlug)) {
66
+ return item.label;
67
+ }
68
+ }
69
+ return '';
70
+ };
71
+
72
+ /**
73
+ * Breadcrumb for the current page, starting **below** the root group (root is
74
+ * dropped — UI shows the site title there) and ending with the active item's
75
+ * own label. Returns `[]` if the page is not in the sidebar.
76
+ */
77
+ export const getBreadcrumb = (items: SidebarEntry[], currentSlug: string): string[] => {
78
+ const ancestors = getAncestorTrail(items, currentSlug).slice(1);
79
+ const leaf = getActiveLabel(items, currentSlug);
80
+ return leaf ? [...ancestors, leaf] : ancestors;
81
+ };
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Sidebar data types — shared between the build-time TOC builder
3
+ * (`src/sidebar.ts`) and the runtime sidebar components
4
+ * (`src/components/DocsSidebar/*`).
5
+ *
6
+ * Single source of truth, no duplication.
7
+ */
8
+
9
+ export type SidebarBadgeVariant =
10
+ | 'note'
11
+ | 'danger'
12
+ | 'success'
13
+ | 'caution'
14
+ | 'tip'
15
+ | 'default';
16
+
17
+ export interface SidebarBadge {
18
+ text: string;
19
+ variant: SidebarBadgeVariant;
20
+ }
21
+
22
+ export interface SidebarLink {
23
+ label: string;
24
+ slug: string;
25
+ badge?: SidebarBadge;
26
+ attrs?: Record<string, string | number | boolean | undefined>;
27
+ }
28
+
29
+ export interface SidebarGroup {
30
+ label: string;
31
+ items: SidebarEntry[];
32
+ /** When `true`, the group is rendered closed by default. Defaults to open. */
33
+ collapsed?: boolean;
34
+ }
35
+
36
+ export type SidebarEntry = SidebarLink | SidebarGroup;