igniteui-astro-components 1.5.1 → 1.6.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 +9 -18
- package/src/components/DocsSubHeader/DocsSubHeader.astro +54 -61
- 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 +2 -0
|
@@ -31,7 +31,8 @@ defineComponents(
|
|
|
31
31
|
);
|
|
32
32
|
|
|
33
33
|
import './icon-registry';
|
|
34
|
-
import type { Highlighter } from 'shiki';
|
|
34
|
+
import type { BundledLanguage, Highlighter } from 'shiki';
|
|
35
|
+
import { ULTIMATE_UI_PLATFORMS } from '../lib/ultimate-ui-platforms';
|
|
35
36
|
import footerStackblitzIcon from '../components/mdx/Sample/assets/stackblitz.svg?raw';
|
|
36
37
|
import footerOpenExternalIcon from '../components/mdx/Sample/assets/open-external.svg?raw';
|
|
37
38
|
|
|
@@ -47,14 +48,27 @@ const XPLAT_SAMPLES_ORDER: Record<string, string[]> = {
|
|
|
47
48
|
react: ['tsx', 'ts', 'html', 'css'],
|
|
48
49
|
wc: ['tsx', 'ts', 'html', 'css'],
|
|
49
50
|
blazor: ['razor', 'cs', 'js', 'css'],
|
|
51
|
+
// XAML platforms: markup first, then code-behind. Samples are authored as
|
|
52
|
+
// Sample.xaml / Sample.xaml.cs plus optional data-model .cs files.
|
|
53
|
+
winui: ['xaml', 'cs'],
|
|
54
|
+
uno: ['xaml', 'cs'],
|
|
50
55
|
};
|
|
51
56
|
|
|
52
57
|
const XPLAT_CODE_BASE: Record<string, string> = {
|
|
53
58
|
wc: '/assets/code-viewer/',
|
|
54
59
|
react: '/code-viewer/',
|
|
55
60
|
blazor: '/code-viewer/',
|
|
61
|
+
winui: '/code-viewer/',
|
|
62
|
+
uno: '/code-viewer/',
|
|
56
63
|
};
|
|
57
64
|
|
|
65
|
+
/**
|
|
66
|
+
* Platforms whose samples cannot be handed off to StackBlitz / CodeSandbox —
|
|
67
|
+
* they are compiled .NET apps, and their sources are not published in an
|
|
68
|
+
* `igniteui-<platform>-examples` repo. Gates the "open in" footer only.
|
|
69
|
+
*/
|
|
70
|
+
const SANDBOX_UNSUPPORTED_PLATFORMS = new Set(['blazor', 'winui', 'uno']);
|
|
71
|
+
|
|
58
72
|
const DV_PATHS = ['gauges/', 'maps/', 'excel/', 'charts/'];
|
|
59
73
|
const ASSETS_RE = /([.]{0,2}\/)*assets\//g;
|
|
60
74
|
const DEFAULT_CODE_THEME = 'dark-plus';
|
|
@@ -66,6 +80,8 @@ declare const __IGD_SAMPLE_CODE_THEME__: string | undefined;
|
|
|
66
80
|
interface SampleFile {
|
|
67
81
|
fileExtension: string;
|
|
68
82
|
fileHeader: string;
|
|
83
|
+
/** Original file name for platforms exposing multiple markup/source files. */
|
|
84
|
+
fileName?: string;
|
|
69
85
|
content: string;
|
|
70
86
|
isMain: boolean;
|
|
71
87
|
path?: string;
|
|
@@ -88,11 +104,18 @@ interface WidgetContext {
|
|
|
88
104
|
*/
|
|
89
105
|
function normalizePlatform(raw: string): string {
|
|
90
106
|
if (raw === 'webcomponents' || raw === 'web-components') return 'wc';
|
|
107
|
+
if (raw === 'uno-platform') return 'uno';
|
|
91
108
|
return raw;
|
|
92
109
|
}
|
|
93
110
|
|
|
94
111
|
function isXplatPlatform(platform: string): boolean {
|
|
95
|
-
return
|
|
112
|
+
return (
|
|
113
|
+
platform === 'react' ||
|
|
114
|
+
platform === 'wc' ||
|
|
115
|
+
platform === 'blazor' ||
|
|
116
|
+
platform === 'winui' ||
|
|
117
|
+
platform === 'uno'
|
|
118
|
+
);
|
|
96
119
|
}
|
|
97
120
|
|
|
98
121
|
function getSamplePath(iframeSrc: string, demosBaseUrl: string): string {
|
|
@@ -137,7 +160,13 @@ function replaceRelativeAssetUrls(files: SampleFile[], demosBaseUrl: string): vo
|
|
|
137
160
|
|
|
138
161
|
// ─── Code Highlighting ────────────────────────────────────────────────────────
|
|
139
162
|
|
|
140
|
-
|
|
163
|
+
// Shiki has no XAML grammar; XAML is XML, so WinUI/Uno markup highlights as that.
|
|
164
|
+
const LANG_MAP: Record<string, string> = {
|
|
165
|
+
js: 'javascript',
|
|
166
|
+
ts: 'typescript',
|
|
167
|
+
cs: 'csharp',
|
|
168
|
+
xaml: 'xml',
|
|
169
|
+
};
|
|
141
170
|
|
|
142
171
|
const SHIKI_LANGS = [
|
|
143
172
|
'text',
|
|
@@ -151,6 +180,11 @@ const SHIKI_LANGS = [
|
|
|
151
180
|
'razor',
|
|
152
181
|
] as const;
|
|
153
182
|
|
|
183
|
+
// Only the WinUI/Uno samples show these (XAML markup and data files), so they load on first use
|
|
184
|
+
// rather than on every sample page.
|
|
185
|
+
const SHIKI_LAZY_LANGS = ['xml', 'json'] as const;
|
|
186
|
+
const HIGHLIGHT_LANGS: ReadonlySet<string> = new Set([...SHIKI_LANGS, ...SHIKI_LAZY_LANGS]);
|
|
187
|
+
|
|
154
188
|
let _highlighterPromise: Promise<Highlighter> | null = null;
|
|
155
189
|
|
|
156
190
|
function getCodeTheme(): string {
|
|
@@ -174,9 +208,12 @@ function getHighlighter(): Promise<Highlighter> {
|
|
|
174
208
|
}
|
|
175
209
|
|
|
176
210
|
function highlightCode(codeEl: HTMLElement, lang: string): void {
|
|
177
|
-
const safeLang =
|
|
211
|
+
const safeLang = HIGHLIGHT_LANGS.has(lang) ? lang : 'text';
|
|
178
212
|
getHighlighter()
|
|
179
|
-
.then((h) => {
|
|
213
|
+
.then(async (h) => {
|
|
214
|
+
if (!h.getLoadedLanguages().includes(safeLang)) {
|
|
215
|
+
await h.loadLanguage(safeLang as BundledLanguage);
|
|
216
|
+
}
|
|
180
217
|
const tmp = document.createElement('div');
|
|
181
218
|
tmp.innerHTML = h.codeToHtml(codeEl.textContent ?? '', {
|
|
182
219
|
lang: safeLang,
|
|
@@ -198,11 +235,11 @@ function normalizeCodeLang(lang: string | undefined): string {
|
|
|
198
235
|
|
|
199
236
|
// ─── Code Tab Rendering ───────────────────────────────────────────────────────
|
|
200
237
|
|
|
201
|
-
function addCodeTab(igcTabs: HTMLElement, file: SampleFile): void {
|
|
238
|
+
function addCodeTab(igcTabs: HTMLElement, file: SampleFile, useFileName = false): void {
|
|
202
239
|
const lang = normalizeCodeLang(file.fileExtension);
|
|
203
240
|
|
|
204
241
|
const tab = document.createElement('igc-tab');
|
|
205
|
-
tab.setAttribute('label', file.fileHeader.toUpperCase());
|
|
242
|
+
tab.setAttribute('label', (useFileName && file.fileName) || file.fileHeader.toUpperCase());
|
|
206
243
|
|
|
207
244
|
const wrapper = document.createElement('div');
|
|
208
245
|
wrapper.className = 'code-wrapper';
|
|
@@ -449,10 +486,8 @@ class XplatCodeService {
|
|
|
449
486
|
this.platform = platform;
|
|
450
487
|
this.samplesOrder = XPLAT_SAMPLES_ORDER[platform] || ['ts', 'html', 'css'];
|
|
451
488
|
this.codeBase = XPLAT_CODE_BASE[platform] || '/code-viewer/';
|
|
452
|
-
// Gates
|
|
453
|
-
|
|
454
|
-
// it also carries the fullscreen button and the in-sample theme picker.
|
|
455
|
-
this.enableLiveEditing = platform !== 'blazor';
|
|
489
|
+
// Gates the StackBlitz / CodeSandbox footer, not editing of the embedded sample.
|
|
490
|
+
this.enableLiveEditing = !SANDBOX_UNSUPPORTED_PLATFORMS.has(platform);
|
|
456
491
|
}
|
|
457
492
|
|
|
458
493
|
async init(ctx: WidgetContext): Promise<void> {
|
|
@@ -482,11 +517,18 @@ class XplatCodeService {
|
|
|
482
517
|
|
|
483
518
|
(data.sampleFiles || ([] as SampleFile[]))
|
|
484
519
|
.filter((f: SampleFile) => f.isMain)
|
|
485
|
-
.sort(
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
520
|
+
.sort((a: SampleFile, b: SampleFile) => {
|
|
521
|
+
const rank = (file: SampleFile) => {
|
|
522
|
+
const index = this.samplesOrder.indexOf(file.fileHeader);
|
|
523
|
+
return index < 0 && ULTIMATE_UI_PLATFORMS.has(this.platform)
|
|
524
|
+
? Number.MAX_SAFE_INTEGER
|
|
525
|
+
: index;
|
|
526
|
+
};
|
|
527
|
+
return rank(a) - rank(b);
|
|
528
|
+
})
|
|
529
|
+
.forEach((file: SampleFile) =>
|
|
530
|
+
addCodeTab(igcTabs, file, ULTIMATE_UI_PLATFORMS.has(this.platform)),
|
|
531
|
+
);
|
|
490
532
|
|
|
491
533
|
// Use sdk.openProject() to avoid the StackBlitz GitHub clone freeze bug.
|
|
492
534
|
addFooter(
|