igniteui-astro-components 0.0.6 → 0.0.8

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/README.md +9 -8
  2. package/package.json +7 -5
  3. package/src/assets/icons/open-link-blank.svg +1 -1
  4. package/src/assets/logos/code-sandbox.svg +14 -0
  5. package/src/assets/logos/stackblitz.svg +13 -0
  6. package/src/components/DocsBreadcrumb/DocsBreadcrumb.scss +1 -1
  7. package/src/components/DocsSidebar/DocsSidebar.astro +15 -8
  8. package/src/components/DocsSidebar/DocsSidebar.scss +152 -2
  9. package/src/components/DocsSidebar/SidebarFilterInput.scss +7 -3
  10. package/src/components/DocsSidebar/SidebarLabel.astro +25 -4
  11. package/src/components/DocsSidebar/toTreeNodes.ts +1 -1
  12. package/src/components/DocsSubHeader/DocsSubHeader.astro +119 -302
  13. package/src/components/DocsSubHeader/DocsSubHeader.scss +111 -11
  14. package/src/components/DocsToc/DocsToc.astro +5 -2
  15. package/src/components/DocsToc/toTreeNodes.ts +1 -1
  16. package/src/components/DocsTree/DocsTree.astro +9 -0
  17. package/src/components/DocsTree/docs-tree.scss +139 -118
  18. package/src/components/GlobalFooter/GlobalFooter.astro +12 -62
  19. package/src/components/GlobalFooter/README.md +7 -10
  20. package/src/components/GlobalNavBar/GlobalNavBar.astro +8 -193
  21. package/src/components/GlobalNavBar/GlobalNavBar.module.scss +16 -6
  22. package/src/components/GlobalNavBar/README.md +8 -15
  23. package/src/components/LicenseIndicator/LicenseIndicator.astro +19 -0
  24. package/src/components/LicenseIndicator/LicenseIndicator.scss +5 -0
  25. package/src/components/Search/Search.astro +34 -15
  26. package/src/components/Search/Search.scss +10 -42
  27. package/src/components/SearchAdvanced/SearchAdvanced.astro +202 -366
  28. package/src/components/SearchAdvanced/SearchAdvanced.scss +177 -0
  29. package/src/components/ThemingWidget/ThemingWidget.astro +5 -10
  30. package/src/components/mdx/ApiRef/README.md +1 -1
  31. package/src/components/mdx/DocsAside/DocsAside.astro +37 -32
  32. package/src/components/mdx/DocsAside/DocsAside.scss +123 -35
  33. package/src/components/mdx/Sample/Sample.astro +55 -45
  34. package/src/components/mdx/Sample/Sample.scss +173 -30
  35. package/src/content.config.ts +1 -1
  36. package/src/integration.ts +25 -141
  37. package/src/layouts/DocsLayout/DocsLayout.astro +61 -20
  38. package/src/layouts/DocsLayout/DocsLayout.scss +51 -6
  39. package/src/lib/nav-helpers.ts +11 -4
  40. package/src/lib/sidebar/helpers.ts +14 -1
  41. package/src/lib/sidebar/types.ts +5 -7
  42. package/src/platform.ts +9 -16
  43. package/src/plugins/rehype-heading-anchors.ts +74 -0
  44. package/src/plugins/rehype-table-wrapper.ts +49 -0
  45. package/src/plugins/remark-docfx.ts +0 -368
  46. package/src/plugins/remark-env-vars.ts +110 -0
  47. package/src/plugins/remark-html-transforms.ts +32 -0
  48. package/src/plugins/remark-md-links.ts +75 -0
  49. package/src/scripts/sample-widget.ts +107 -116
  50. package/src/sidebar.ts +6 -7
  51. package/src/styles/global/_breakpoints.scss +4 -4
  52. package/src/styles/global/_code-blocks.scss +1 -1
  53. package/src/styles/global/_component-themes.scss +118 -18
  54. package/src/styles/global/_index.scss +2 -2
  55. package/src/styles/global/_markdown.scss +444 -32
  56. package/src/styles/global/_palette.scss +7 -0
  57. package/src/styles/global/_search-shared.scss +273 -0
  58. package/src/styles/global/_variables.scss +58 -3
  59. package/src/styles/theme.scss +80 -11
  60. package/src/virtual-modules.d.ts +1 -13
  61. package/src/assets/icons/copy-clipboard.svg +0 -3
  62. package/src/assets/icons/filter-clear.svg +0 -1
  63. package/src/styles/custom.scss +0 -20
@@ -9,13 +9,37 @@
9
9
  margin: 0;
10
10
  z-index: 0;
11
11
 
12
+ @media (max-width: #{$bp-tablet-max}) {
13
+ --igd-page-layout-grid: 1fr;
14
+ --igd-page-padding: #{rem(38px)};
15
+
16
+ .search-trigger__lable,
17
+ .search-trigger__hint {
18
+ display: none;
19
+ }
20
+
21
+ .search-trigger {
22
+ border-inline-end: var(--igd-app-outline);
23
+ }
24
+ }
25
+
12
26
  @media (min-width: #{$bp-tablet-min}) {
13
27
  justify-content: center;
14
28
  padding-inline: 0;
29
+
30
+ .igd-docs-subheader {
31
+ --igd-page-layout-grid: auto 1fr;
32
+ }
33
+ }
34
+
35
+ @media (min-width: #{$bp-desktop-min}) {
36
+ .igd-docs-subheader {
37
+ --igd-page-layout-grid: #{minmax(rem(300px), rem(400px)) 1fr};
38
+ }
15
39
  }
16
40
 
17
41
  @media (max-width: #{$bp-mobile-horizontal-max}) {
18
- padding-inline: rem(32px);
42
+ padding-inline: 0;
19
43
  }
20
44
 
21
45
  &:not(:has(.igd-right-sidebar)) {
@@ -37,7 +61,7 @@
37
61
  }
38
62
 
39
63
  @media (max-width: #{$bp-mobile-horizontal-max}) {
40
- padding-inline: rem(32px);
64
+ padding-inline: 0;
41
65
  }
42
66
 
43
67
  &:not(:has(.igd-right-sidebar)) {
@@ -104,6 +128,14 @@
104
128
  border-inline: var(--igd-app-outline);
105
129
  width: clamp(rem(300px), 100%, rem(940px));
106
130
  margin-inline-start: auto;
131
+
132
+ @media (max-width: #{$bp-mobile-horizontal-max}) {
133
+ border: none;
134
+ }
135
+ }
136
+
137
+ .igd-main-content__page + aside {
138
+ margin-inline-end: auto;
107
139
  }
108
140
 
109
141
  .igd-main-content__inner {
@@ -111,15 +143,28 @@
111
143
  gap: rem(70px);
112
144
  padding-inline: rem(70px) rem(32px);
113
145
  position: relative;
146
+
147
+ @media (max-width: #{$bp-sidebar-max}) {
148
+ padding-inline: rem(34px) rem(16px);
149
+ gap: rem(24px);
150
+ }
114
151
 
115
- aside {
116
- margin-inline-end: auto;
152
+ @media (max-width: #{$bp-tablet-max}) {
153
+ padding-inline: rem(16px);
154
+ gap: rem(16px)
155
+ }
156
+
157
+ @media (max-width: #{$bp-mobile-horizontal-max}) {
158
+ padding: 0;
159
+
160
+ aside {
161
+ display: none;
162
+ }
117
163
  }
118
164
  }
119
165
 
120
166
  .content {
121
167
  max-width: 60rem;
122
168
  margin: 0 auto;
123
- padding-inline: var(--igd-page-padding);
124
- padding-block-end: var(--igd-page-padding);
169
+ padding: 0;
125
170
  }
@@ -10,20 +10,27 @@
10
10
  * - components/GlobalFooter/GlobalFooter.astro
11
11
  */
12
12
 
13
- import { JSDOM } from 'jsdom';
13
+ import { createRequire } from 'node:module';
14
14
  import type { NavLang } from '../platform.ts';
15
15
 
16
+ // createRequire anchored to this file so it always resolves jsdom from
17
+ // igniteui-astro-components/node_modules, regardless of where the consumer
18
+ // project has its node_modules.
19
+ const _require = createRequire(import.meta.url);
20
+
16
21
  // ---------------------------------------------------------------------------
17
22
  // Low-level HTML helpers
18
23
  // ---------------------------------------------------------------------------
19
24
 
20
25
  /**
21
26
  * Strip all <script> tags from an HTML string using a DOM parser.
22
- * The nav HTML fetched from infragistics.com may contain inline or external
23
- * scripts that don't belong in the docs page. Platform-specific scripts are
24
- * already injected cleanly via getPlatformHead().
27
+ *
28
+ * Uses createRequire so Vite/Rollup cannot statically trace the jsdom import —
29
+ * jsdom is resolved at Node runtime and never bundled into the prerender chunk.
25
30
  */
26
31
  export function stripScripts(html: string): string {
32
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
33
+ const { JSDOM } = _require('jsdom') as typeof import('jsdom');
27
34
  const dom = new JSDOM(html);
28
35
  const { document } = dom.window;
29
36
  document.querySelectorAll('script').forEach((el: Element) => el.remove());
@@ -3,7 +3,7 @@
3
3
  * Shared by the SSR components and any consumer that walks the tree.
4
4
  */
5
5
 
6
- import type { SidebarEntry, SidebarGroup } from './types';
6
+ import type { SidebarEntry, SidebarGroup, SidebarLink } from './types';
7
7
 
8
8
  export const isGroup = (e: SidebarEntry): e is SidebarGroup => 'items' in e;
9
9
 
@@ -69,6 +69,19 @@ export const getActiveLabel = (items: SidebarEntry[], currentSlug: string): stri
69
69
  return '';
70
70
  };
71
71
 
72
+ /** Returns the active SidebarLink for the current slug, or null if not found. */
73
+ export const getActiveLink = (items: SidebarEntry[], currentSlug: string): SidebarLink | null => {
74
+ for (const item of items) {
75
+ if (isGroup(item)) {
76
+ const found = getActiveLink(item.items, currentSlug);
77
+ if (found) return found;
78
+ } else if (isActive(item.slug, currentSlug)) {
79
+ return item;
80
+ }
81
+ }
82
+ return null;
83
+ };
84
+
72
85
  /**
73
86
  * Breadcrumb for the current page, starting **below** the root group (root is
74
87
  * dropped — UI shows the site title there) and ending with the active item's
@@ -7,12 +7,10 @@
7
7
  */
8
8
 
9
9
  export type SidebarBadgeVariant =
10
- | 'note'
11
- | 'danger'
12
- | 'success'
13
- | 'caution'
14
- | 'tip'
15
- | 'default';
10
+ | 'new'
11
+ | 'updated'
12
+ | 'preview'
13
+ | 'premium';
16
14
 
17
15
  export interface SidebarBadge {
18
16
  text: string;
@@ -22,7 +20,7 @@ export interface SidebarBadge {
22
20
  export interface SidebarLink {
23
21
  label: string;
24
22
  slug: string;
25
- badge?: SidebarBadge;
23
+ badges?: SidebarBadge[];
26
24
  attrs?: Record<string, string | number | boolean | undefined>;
27
25
  }
28
26
 
package/src/platform.ts CHANGED
@@ -2,30 +2,23 @@
2
2
  * platform.ts
3
3
  *
4
4
  * Central registry of per-platform CDN assets (styles / scripts) and nav
5
- * endpoint configuration, ported from igniteui-docfx-template:
6
- * - template/partials/head.tmpl.partial (styles + AppBuilder init script)
7
- * - template/partials/scripts.tmpl.partial (scripts per platform)
8
- * - template/conceptual.html.primary.js (platform flag derivation)
5
+ * endpoint configuration.
9
6
  *
10
7
  * Usage from astro.config.ts:
11
8
  * import { getPlatformHead } from './src/platform.ts';
12
- * // inside starlight({ head: getPlatformHead('angular', 'en') })
13
- *
14
- * Usage from integration.ts:
15
- * import { getNavConfig } from './platform.ts';
16
- * const { navType, navUrl } = getNavConfig(platform, navLang);
9
+ * // inside createDocsSite({ head: getPlatformHead('angular', 'en') })
17
10
  */
18
11
 
19
12
  // ---------------------------------------------------------------------------
20
13
  // Types
21
14
  // ---------------------------------------------------------------------------
22
15
 
23
- /** HTML tag names accepted by Starlight's `head` array. */
16
+ /** HTML tag names accepted by the `head` array. */
24
17
  export type HeadTag =
25
18
  | 'title' | 'link' | 'style' | 'base'
26
19
  | 'meta' | 'script' | 'noscript' | 'template';
27
20
 
28
- /** Single entry in Starlight's `head` array — tag, attrs, optional content. */
21
+ /** Single entry in the `head` array — tag, attrs, optional content. */
29
22
  export type HeadEntry = {
30
23
  tag: HeadTag;
31
24
  attrs?: Record<string, string | boolean | undefined>;
@@ -75,8 +68,8 @@ export interface NavConfig {
75
68
  // ---------------------------------------------------------------------------
76
69
  const IG_STYLES: HeadEntry[] = [
77
70
  // Bootstrap is wrapped in a CSS cascade layer so its global resets do not
78
- // bleed into the Starlight theme. The layer priority order is declared at
79
- // the top of custom.css: @layer bootstrap, starlight.core, starlight.overrides
71
+ // bleed into the docs theme. The layer priority order is declared at
72
+ // the top of custom.scss: @layer bootstrap
80
73
  // Note: @import layer() does not support the `integrity` SRI attribute.
81
74
  {
82
75
  tag: 'style',
@@ -116,7 +109,7 @@ const APPBUILDER_STYLES: HeadEntry[] = [
116
109
  { tag: 'link', attrs: { rel: 'stylesheet', href: 'https://staging.appbuilder.dev/wp-content/plugins/megamenu-pro/icons/genericons/genericons/genericons.css', media: 'all' } },
117
110
  { tag: 'link', attrs: { rel: 'stylesheet', href: 'https://staging.appbuilder.dev/wp-content/plugins/megamenu-pro/icons/fontawesome6/css/all.min.css', media: 'all' } },
118
111
  // Bootstrap v4.4 partials — wrapped in a CSS cascade layer so they don't
119
- // override the Starlight theme. See custom.css @layer declaration.
112
+ // override the docs theme. See custom.scss @layer declaration.
120
113
  {
121
114
  tag: 'style',
122
115
  content: [
@@ -238,8 +231,8 @@ export const IGDOCS_PLATFORMS: Record<string, PlatformMeta> = {
238
231
  };
239
232
 
240
233
  /**
241
- * Returns an array of Starlight `head` entries for the given platform.
242
- * Pass the result directly to `starlight({ head: getPlatformHead(...) })`.
234
+ * Returns an array of head entries for the given platform.
235
+ * Pass the result to `createDocsSite({ head: getPlatformHead(...) })`.
243
236
  *
244
237
  * @param platform - Platform identifier.
245
238
  * @param lang - Locale — not currently used but kept for API completeness.
@@ -0,0 +1,74 @@
1
+ import { visit } from 'unist-util-visit';
2
+ import Slugger from 'github-slugger';
3
+
4
+ const HEADING_TAGS = new Set(['h2', 'h3', 'h4', 'h5', 'h6']);
5
+
6
+ // Extract the text content of a hast node (ignores child elements, reads text/raw nodes).
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ function textContent(node: any): string {
9
+ let text = '';
10
+ visit(node, (child) => {
11
+ if (child.type === 'text' || child.type === 'raw') text += child.value ?? '';
12
+ });
13
+ return text;
14
+ }
15
+
16
+ /**
17
+ * Rehype plugin that appends a copy-link icon button to every heading
18
+ * (h2–h6).
19
+ *
20
+ * Runs before Astro's internal `rehypeHeadingIds` pass so it must
21
+ * generate its own slug using the same `github-slugger` algorithm.
22
+ * If the heading already has an `id` (e.g. set in raw HTML), it is reused.
23
+ * Headings without an existing id get one assigned here — `rehypeHeadingIds`
24
+ * will then see the id already present and skip re-assigning it, ensuring
25
+ * the button href and the heading's id always match.
26
+ */
27
+ export function rehypeHeadingAnchors() {
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ return (tree: any) => {
30
+ const slugger = new Slugger();
31
+
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ visit(tree, 'element', (node: any) => {
34
+ if (!HEADING_TAGS.has(node.tagName)) return;
35
+
36
+ node.properties ??= {};
37
+
38
+ // Reuse an existing id or generate one from heading text.
39
+ if (typeof node.properties.id !== 'string') {
40
+ node.properties.id = slugger.slug(textContent(node));
41
+ } else {
42
+ // Keep slugger in sync so it doesn't generate duplicate ids.
43
+ slugger.slug(node.properties.id);
44
+ }
45
+
46
+ const id = node.properties.id as string;
47
+
48
+ const iconButton = {
49
+ type: 'element',
50
+ tagName: 'igc-icon-button',
51
+ properties: {
52
+ class: 'igd-anchor-link',
53
+ href: `#${id}`,
54
+ variant: 'flat',
55
+ 'aria-label': 'Link to this section',
56
+ tabIndex: 0,
57
+ },
58
+ children: [
59
+ {
60
+ type: 'element',
61
+ tagName: 'igc-icon',
62
+ properties: {
63
+ name: 'link',
64
+ collection: 'docs',
65
+ },
66
+ children: [],
67
+ },
68
+ ],
69
+ };
70
+
71
+ node.children.push(iconButton);
72
+ });
73
+ };
74
+ }
@@ -0,0 +1,49 @@
1
+ import { visit } from 'unist-util-visit';
2
+
3
+ let _counter = 0;
4
+
5
+ /**
6
+ * Rehype plugin that wraps every <table> in a scroll container div.
7
+ * The wrapper is fully accessible per the recommendations in:
8
+ * https://piccalil.li/blog/styling-tables-the-modern-css-way/
9
+ *
10
+ * - role="region" + aria-labelledby pointing to the <caption> (or a generated id)
11
+ * - tabindex="0" makes the scroll region keyboard-focusable
12
+ */
13
+ export function rehypeTableWrapper() {
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ return (tree: any) => {
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ visit(tree, 'element', (node: any, index: number | undefined, parent: any) => {
18
+ if (node.tagName !== 'table' || !parent || index == null) return;
19
+
20
+ // Find an existing <caption> to use as the accessible label.
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ const caption = node.children?.find((c: any) => c.tagName === 'caption');
23
+ let labelId: string;
24
+
25
+ if (caption) {
26
+ // Reuse or assign an id on the caption element.
27
+ labelId = caption.properties?.id || `igd-table-caption-${++_counter}`;
28
+ caption.properties = { ...caption.properties, id: labelId };
29
+ } else {
30
+ // No caption — generate a unique id for the wrapper itself.
31
+ labelId = `igd-table-${++_counter}`;
32
+ }
33
+
34
+ const wrapper = {
35
+ type: 'element',
36
+ tagName: 'div',
37
+ properties: {
38
+ className: ['igd-table-wrapper'],
39
+ role: 'region',
40
+ 'aria-labelledby': labelId,
41
+ tabIndex: 0,
42
+ },
43
+ children: [node],
44
+ };
45
+
46
+ parent.children[index] = wrapper;
47
+ });
48
+ };
49
+ }