@veluai/velu 0.2.13 → 0.2.15

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 (109) hide show
  1. package/README.md +80 -80
  2. package/dist/cli.js +37 -37
  3. package/package.json +64 -64
  4. package/runtime/velu-ui/base.css +320 -320
  5. package/runtime/velu-ui/components/Accordion.jsx +64 -64
  6. package/runtime/velu-ui/components/ApiClient.jsx +207 -207
  7. package/runtime/velu-ui/components/ApiField.jsx +87 -87
  8. package/runtime/velu-ui/components/ApiPath.jsx +63 -63
  9. package/runtime/velu-ui/components/ApiReferencePage.jsx +384 -384
  10. package/runtime/velu-ui/components/ApiSamples.jsx +36 -36
  11. package/runtime/velu-ui/components/ApiSidebar.jsx +122 -122
  12. package/runtime/velu-ui/components/AskBar.jsx +71 -71
  13. package/runtime/velu-ui/components/Callout.jsx +114 -114
  14. package/runtime/velu-ui/components/Card.jsx +131 -131
  15. package/runtime/velu-ui/components/Chatbot.jsx +885 -885
  16. package/runtime/velu-ui/components/CodeBlock.jsx +375 -375
  17. package/runtime/velu-ui/components/Columns.jsx +56 -56
  18. package/runtime/velu-ui/components/ContextMenu.jsx +298 -273
  19. package/runtime/velu-ui/components/ErrorCard.jsx +138 -138
  20. package/runtime/velu-ui/components/Field.jsx +81 -81
  21. package/runtime/velu-ui/components/Image.jsx +163 -163
  22. package/runtime/velu-ui/components/Logo.jsx +31 -31
  23. package/runtime/velu-ui/components/MethodBadge.jsx +31 -31
  24. package/runtime/velu-ui/components/NavSelect.jsx +108 -108
  25. package/runtime/velu-ui/components/NotFound.jsx +63 -63
  26. package/runtime/velu-ui/components/PageFeedback.jsx +219 -219
  27. package/runtime/velu-ui/components/PageFooter.jsx +145 -145
  28. package/runtime/velu-ui/components/PageHeader.jsx +422 -422
  29. package/runtime/velu-ui/components/PageNav.jsx +77 -77
  30. package/runtime/velu-ui/components/PoweredBy.jsx +51 -51
  31. package/runtime/velu-ui/components/Prompt.jsx +115 -115
  32. package/runtime/velu-ui/components/Search.jsx +460 -460
  33. package/runtime/velu-ui/components/Sidebar.jsx +254 -254
  34. package/runtime/velu-ui/components/SocialLinks.jsx +90 -90
  35. package/runtime/velu-ui/components/Steps.jsx +65 -65
  36. package/runtime/velu-ui/components/ThemeToggle.jsx +48 -48
  37. package/runtime/velu-ui/components/Toc.jsx +537 -537
  38. package/runtime/velu-ui/components/TocBar.jsx +195 -195
  39. package/runtime/velu-ui/components/Tree.jsx +87 -87
  40. package/runtime/velu-ui/components/TryItBar.jsx +102 -102
  41. package/runtime/velu-ui/components/accordion.css +92 -92
  42. package/runtime/velu-ui/components/api-page.css +208 -208
  43. package/runtime/velu-ui/components/api.css +635 -635
  44. package/runtime/velu-ui/components/ask-bar.css +94 -94
  45. package/runtime/velu-ui/components/card.css +105 -105
  46. package/runtime/velu-ui/components/chatbot.css +622 -622
  47. package/runtime/velu-ui/components/code-block.css +263 -263
  48. package/runtime/velu-ui/components/context-menu.css +173 -173
  49. package/runtime/velu-ui/components/docs-layout.css +822 -822
  50. package/runtime/velu-ui/components/field.css +82 -82
  51. package/runtime/velu-ui/components/image.css +237 -237
  52. package/runtime/velu-ui/components/nav-select.css +157 -157
  53. package/runtime/velu-ui/components/not-found.css +94 -94
  54. package/runtime/velu-ui/components/page-feedback.css +241 -241
  55. package/runtime/velu-ui/components/page-footer.css +130 -130
  56. package/runtime/velu-ui/components/page-header.css +558 -558
  57. package/runtime/velu-ui/components/page-nav.css +50 -50
  58. package/runtime/velu-ui/components/powered-by.css +92 -92
  59. package/runtime/velu-ui/components/prompt.css +99 -99
  60. package/runtime/velu-ui/components/search.css +307 -307
  61. package/runtime/velu-ui/components/sidebar.css +205 -205
  62. package/runtime/velu-ui/components/steps.css +77 -77
  63. package/runtime/velu-ui/components/theme-toggle.css +102 -102
  64. package/runtime/velu-ui/components/toc-bar.css +234 -234
  65. package/runtime/velu-ui/components/tree.css +49 -49
  66. package/runtime/velu-ui/index.js +54 -54
  67. package/runtime/velu-ui/lib/api-send.js +92 -92
  68. package/runtime/velu-ui/lib/brand-icons.jsx +103 -103
  69. package/runtime/velu-ui/lib/component-schemas.js +100 -100
  70. package/runtime/velu-ui/lib/copyText.js +64 -64
  71. package/runtime/velu-ui/lib/docs-assistant.js +250 -250
  72. package/runtime/velu-ui/lib/lang-icons.jsx +147 -147
  73. package/runtime/velu-ui/lib/pagefind.js +113 -113
  74. package/runtime/velu-ui/lib/prism-langs.js +957 -957
  75. package/runtime/velu-ui/lib/prism-loader.js +74 -74
  76. package/runtime/velu-ui/lib/resolveIcon.jsx +29 -29
  77. package/runtime/velu-ui/lib/scrollIntoNearestView.js +66 -66
  78. package/runtime/velu-ui/mdx-components.jsx +105 -105
  79. package/runtime/velu-ui/primitives/Cluster.jsx +49 -49
  80. package/runtime/velu-ui/primitives/Stack.jsx +63 -63
  81. package/runtime/velu-ui/primitives/Switcher.jsx +57 -57
  82. package/runtime/velu-ui/primitives/stack.css +3 -3
  83. package/runtime/velu-ui/primitives/switcher.css +25 -25
  84. package/runtime/velu-ui/styles.css +46 -46
  85. package/runtime/velu-ui/tokens.css +4 -4
  86. package/schema/velu.schema.json +423 -423
  87. package/src/lib/extract-mdx-error.js +170 -170
  88. package/src/lib/issues.js +159 -159
  89. package/src/lib/known-components.js +34 -34
  90. package/src/navigation.js +443 -443
  91. package/src/runtime/App.jsx +1669 -1668
  92. package/src/runtime/ErrorBoundary.jsx +54 -54
  93. package/src/runtime/client-entry.jsx +22 -22
  94. package/src/runtime/server-entry.jsx +16 -16
  95. package/src/template.html +48 -48
  96. package/templates/starter/ai-tools/claude-code.mdx +26 -26
  97. package/templates/starter/ai-tools/cursor.mdx +17 -17
  98. package/templates/starter/api-reference/introduction.mdx +43 -43
  99. package/templates/starter/development.mdx +19 -19
  100. package/templates/starter/essentials/code.mdx +29 -29
  101. package/templates/starter/essentials/images.mdx +29 -29
  102. package/templates/starter/essentials/markdown.mdx +25 -25
  103. package/templates/starter/essentials/navigation.mdx +39 -39
  104. package/templates/starter/essentials/settings.mdx +30 -30
  105. package/templates/starter/favicon.svg +6 -6
  106. package/templates/starter/index.mdx +31 -31
  107. package/templates/starter/openapi.json +160 -160
  108. package/templates/starter/quickstart.mdx +31 -31
  109. package/templates/starter/velu.json +41 -41
@@ -1,74 +1,74 @@
1
- import { Prism } from 'prism-react-renderer';
2
- import { LANG_DEPS, LANG_ALIASES, PRISM_LOADERS } from './prism-langs.js';
3
-
4
- /**
5
- * Lazy prism language loader — fetches grammars on demand based on the
6
- * actual `language` props rendered, never bundles all 297 upfront.
7
- *
8
- * - `Prism` is exposed on globalThis so prismjs/components/*.js files
9
- * (which look it up globally) find it when they register grammars.
10
- * - `ensureLang(id)` walks the LANG_DEPS map to load every prerequisite
11
- * in correct order before the target, then resolves once everything is
12
- * registered. Subsequent calls for the same id share the cached promise.
13
- * - Aliases (e.g. `rb` → `ruby`) are resolved up front via LANG_ALIASES.
14
- * - `hasLang(id)` is a sync check used by render to gate highlighting:
15
- * true once `Prism.languages[id]` exists OR the bundled fallback covers
16
- * it. The CodeBlock kicks off ensureLang in an effect, then re-renders
17
- * once `hasLang` flips true.
18
- */
19
-
20
- if (typeof globalThis !== 'undefined' && !globalThis.Prism) {
21
- globalThis.Prism = Prism;
22
- } else if (typeof window !== 'undefined' && !window.Prism) {
23
- window.Prism = Prism;
24
- }
25
-
26
- const loadPromises = new Map();
27
-
28
- export function resolveLang(idOrAlias) {
29
- if (!idOrAlias) return null;
30
- if (LANG_ALIASES[idOrAlias]) return LANG_ALIASES[idOrAlias];
31
- return idOrAlias;
32
- }
33
-
34
- export function hasLang(id) {
35
- if (!id) return true;
36
- const canonical = resolveLang(id);
37
- return Boolean(Prism.languages[canonical]);
38
- }
39
-
40
- async function loadOne(id) {
41
- const loader = PRISM_LOADERS[id];
42
- if (!loader) return;
43
- try {
44
- await loader();
45
- } catch (e) {
46
- console.warn(`[velu-ui] failed to load prism lang: ${id}`, e?.message ?? e);
47
- }
48
- }
49
-
50
- export function ensureLang(idOrAlias) {
51
- const id = resolveLang(idOrAlias);
52
- if (!id) return Promise.resolve();
53
- if (Prism.languages[id]) return Promise.resolve();
54
- let p = loadPromises.get(id);
55
- if (p) return p;
56
-
57
- p = (async () => {
58
- // Load all dependencies first (recursive, sequential at each level).
59
- const deps = LANG_DEPS[id] ?? [];
60
- for (const dep of deps) {
61
- const depId = resolveLang(dep);
62
- if (depId && !Prism.languages[depId]) {
63
- await ensureLang(depId);
64
- }
65
- }
66
- // Load the target language itself.
67
- if (!Prism.languages[id]) {
68
- await loadOne(id);
69
- }
70
- })();
71
-
72
- loadPromises.set(id, p);
73
- return p;
74
- }
1
+ import { Prism } from 'prism-react-renderer';
2
+ import { LANG_DEPS, LANG_ALIASES, PRISM_LOADERS } from './prism-langs.js';
3
+
4
+ /**
5
+ * Lazy prism language loader — fetches grammars on demand based on the
6
+ * actual `language` props rendered, never bundles all 297 upfront.
7
+ *
8
+ * - `Prism` is exposed on globalThis so prismjs/components/*.js files
9
+ * (which look it up globally) find it when they register grammars.
10
+ * - `ensureLang(id)` walks the LANG_DEPS map to load every prerequisite
11
+ * in correct order before the target, then resolves once everything is
12
+ * registered. Subsequent calls for the same id share the cached promise.
13
+ * - Aliases (e.g. `rb` → `ruby`) are resolved up front via LANG_ALIASES.
14
+ * - `hasLang(id)` is a sync check used by render to gate highlighting:
15
+ * true once `Prism.languages[id]` exists OR the bundled fallback covers
16
+ * it. The CodeBlock kicks off ensureLang in an effect, then re-renders
17
+ * once `hasLang` flips true.
18
+ */
19
+
20
+ if (typeof globalThis !== 'undefined' && !globalThis.Prism) {
21
+ globalThis.Prism = Prism;
22
+ } else if (typeof window !== 'undefined' && !window.Prism) {
23
+ window.Prism = Prism;
24
+ }
25
+
26
+ const loadPromises = new Map();
27
+
28
+ export function resolveLang(idOrAlias) {
29
+ if (!idOrAlias) return null;
30
+ if (LANG_ALIASES[idOrAlias]) return LANG_ALIASES[idOrAlias];
31
+ return idOrAlias;
32
+ }
33
+
34
+ export function hasLang(id) {
35
+ if (!id) return true;
36
+ const canonical = resolveLang(id);
37
+ return Boolean(Prism.languages[canonical]);
38
+ }
39
+
40
+ async function loadOne(id) {
41
+ const loader = PRISM_LOADERS[id];
42
+ if (!loader) return;
43
+ try {
44
+ await loader();
45
+ } catch (e) {
46
+ console.warn(`[velu-ui] failed to load prism lang: ${id}`, e?.message ?? e);
47
+ }
48
+ }
49
+
50
+ export function ensureLang(idOrAlias) {
51
+ const id = resolveLang(idOrAlias);
52
+ if (!id) return Promise.resolve();
53
+ if (Prism.languages[id]) return Promise.resolve();
54
+ let p = loadPromises.get(id);
55
+ if (p) return p;
56
+
57
+ p = (async () => {
58
+ // Load all dependencies first (recursive, sequential at each level).
59
+ const deps = LANG_DEPS[id] ?? [];
60
+ for (const dep of deps) {
61
+ const depId = resolveLang(dep);
62
+ if (depId && !Prism.languages[depId]) {
63
+ await ensureLang(depId);
64
+ }
65
+ }
66
+ // Load the target language itself.
67
+ if (!Prism.languages[id]) {
68
+ await loadOne(id);
69
+ }
70
+ })();
71
+
72
+ loadPromises.set(id, p);
73
+ return p;
74
+ }
@@ -1,29 +1,29 @@
1
- import React from 'react';
2
- import { icons as lucideIcons } from 'lucide-react';
3
-
4
- /**
5
- * Resolve an icon prop to a renderable node — shared by Callout, Sidebar, etc.
6
- *
7
- * lucide convention: an icon's id is kebab-case; its component / `icons`-map
8
- * key is the PascalCase form. So "triangle-alert" → "TriangleAlert" →
9
- * lucideIcons.TriangleAlert.
10
- *
11
- * - string → resolved as a lucide id (content-driven; serializable)
12
- * - node → returned as-is (power users / custom elements)
13
- * - nullish or unknown id → null
14
- *
15
- * `iconProps` is spread onto the resolved lucide component (e.g. size,
16
- * strokeWidth). Callers that style the icon via a CSS wrapper (Sidebar) can
17
- * omit it; callers that size inline (Callout) pass it.
18
- */
19
- export default function resolveIcon(icon, iconProps = {}) {
20
- if (icon == null) return null;
21
- if (typeof icon !== 'string') return icon;
22
- const key = icon
23
- .split(/[-_\s]+/)
24
- .filter(Boolean)
25
- .map((s) => s.charAt(0).toUpperCase() + s.slice(1))
26
- .join('');
27
- const Cmp = lucideIcons[key];
28
- return Cmp ? <Cmp {...iconProps} /> : null;
29
- }
1
+ import React from 'react';
2
+ import { icons as lucideIcons } from 'lucide-react';
3
+
4
+ /**
5
+ * Resolve an icon prop to a renderable node — shared by Callout, Sidebar, etc.
6
+ *
7
+ * lucide convention: an icon's id is kebab-case; its component / `icons`-map
8
+ * key is the PascalCase form. So "triangle-alert" → "TriangleAlert" →
9
+ * lucideIcons.TriangleAlert.
10
+ *
11
+ * - string → resolved as a lucide id (content-driven; serializable)
12
+ * - node → returned as-is (power users / custom elements)
13
+ * - nullish or unknown id → null
14
+ *
15
+ * `iconProps` is spread onto the resolved lucide component (e.g. size,
16
+ * strokeWidth). Callers that style the icon via a CSS wrapper (Sidebar) can
17
+ * omit it; callers that size inline (Callout) pass it.
18
+ */
19
+ export default function resolveIcon(icon, iconProps = {}) {
20
+ if (icon == null) return null;
21
+ if (typeof icon !== 'string') return icon;
22
+ const key = icon
23
+ .split(/[-_\s]+/)
24
+ .filter(Boolean)
25
+ .map((s) => s.charAt(0).toUpperCase() + s.slice(1))
26
+ .join('');
27
+ const Cmp = lucideIcons[key];
28
+ return Cmp ? <Cmp {...iconProps} /> : null;
29
+ }
@@ -1,66 +1,66 @@
1
- /**
2
- * scrollIntoNearestView — programmatic "scroll so this element is visible"
3
- * that reliably honours `scroll-padding-top` / `scroll-padding-bottom` on
4
- * the nearest scrollable ancestor.
5
- *
6
- * Why not `el.scrollIntoView({ block: 'nearest' })`?
7
- * Both Chrome and Firefox implement that opt sporadically with respect
8
- * to scroll-padding-* — sometimes treating the full scrollport as the
9
- * target instead of the scroll-padded inset. That matters here because
10
- * docs sidebars + TOC live behind a footer that visually eclipses their
11
- * bottoms; we use `scroll-padding-bottom` to mark that band as off-limits.
12
- * Computing the delta manually guarantees we always pull the element
13
- * above the footer's eclipsed band, on every engine.
14
- *
15
- * The optional `padBottom` (and `padTop`) override the values read from
16
- * the parent's computed style. This is needed when the visible region's
17
- * bottom is driven by a *live* DOM measurement (e.g. a fixed/sticky
18
- * footer's getBoundingClientRect) — that value tracks the user's actual
19
- * scroll position synchronously, whereas CSS scroll-padding-* driven by
20
- * React state lags behind committed renders and can leave the active
21
- * item flush against the footer on fast scrolls.
22
- *
23
- * Behaviour:
24
- * - finds the nearest ancestor with `overflow-y: auto | scroll`
25
- * - does nothing if `el` is already inside that ancestor's
26
- * (effective) scroll-padded visible region — no jitter when the
27
- * active item is already on-screen
28
- * - otherwise scrolls the ancestor by the minimum delta (matching the
29
- * `block: 'nearest'` contract)
30
- *
31
- * @param {HTMLElement} el target element
32
- * @param {{ padTop?: number, padBottom?: number }} [opts]
33
- */
34
- export default function scrollIntoNearestView(el, opts = {}) {
35
- if (!el) return;
36
- let parent = el.parentElement;
37
- while (parent && parent !== document.body) {
38
- const overflowY = getComputedStyle(parent).overflowY;
39
- if (overflowY === 'auto' || overflowY === 'scroll') break;
40
- parent = parent.parentElement;
41
- }
42
- if (!parent || parent === document.body) return;
43
-
44
- const elRect = el.getBoundingClientRect();
45
- const parentRect = parent.getBoundingClientRect();
46
- const cs = getComputedStyle(parent);
47
- const padTop = opts.padTop ?? (parseFloat(cs.scrollPaddingTop) || 0);
48
- const padBottom =
49
- opts.padBottom ?? (parseFloat(cs.scrollPaddingBottom) || 0);
50
-
51
- const visibleTop = parentRect.top + padTop;
52
- const visibleBottom = parentRect.bottom - padBottom;
53
-
54
- let delta = 0;
55
- if (elRect.top < visibleTop) delta = elRect.top - visibleTop;
56
- else if (elRect.bottom > visibleBottom) delta = elRect.bottom - visibleBottom;
57
- if (delta === 0) return;
58
-
59
- // Direct `scrollTop` assignment (not scrollBy/scrollTo with options):
60
- // - universally supported (no behavior:'instant' compat concerns),
61
- // - synchronous,
62
- // - can't be cancelled by a subsequent scroll event,
63
- // which matters because we're often called many times in quick
64
- // succession from scroll-spy updates while the user is mid-scroll.
65
- parent.scrollTop = parent.scrollTop + delta;
66
- }
1
+ /**
2
+ * scrollIntoNearestView — programmatic "scroll so this element is visible"
3
+ * that reliably honours `scroll-padding-top` / `scroll-padding-bottom` on
4
+ * the nearest scrollable ancestor.
5
+ *
6
+ * Why not `el.scrollIntoView({ block: 'nearest' })`?
7
+ * Both Chrome and Firefox implement that opt sporadically with respect
8
+ * to scroll-padding-* — sometimes treating the full scrollport as the
9
+ * target instead of the scroll-padded inset. That matters here because
10
+ * docs sidebars + TOC live behind a footer that visually eclipses their
11
+ * bottoms; we use `scroll-padding-bottom` to mark that band as off-limits.
12
+ * Computing the delta manually guarantees we always pull the element
13
+ * above the footer's eclipsed band, on every engine.
14
+ *
15
+ * The optional `padBottom` (and `padTop`) override the values read from
16
+ * the parent's computed style. This is needed when the visible region's
17
+ * bottom is driven by a *live* DOM measurement (e.g. a fixed/sticky
18
+ * footer's getBoundingClientRect) — that value tracks the user's actual
19
+ * scroll position synchronously, whereas CSS scroll-padding-* driven by
20
+ * React state lags behind committed renders and can leave the active
21
+ * item flush against the footer on fast scrolls.
22
+ *
23
+ * Behaviour:
24
+ * - finds the nearest ancestor with `overflow-y: auto | scroll`
25
+ * - does nothing if `el` is already inside that ancestor's
26
+ * (effective) scroll-padded visible region — no jitter when the
27
+ * active item is already on-screen
28
+ * - otherwise scrolls the ancestor by the minimum delta (matching the
29
+ * `block: 'nearest'` contract)
30
+ *
31
+ * @param {HTMLElement} el target element
32
+ * @param {{ padTop?: number, padBottom?: number }} [opts]
33
+ */
34
+ export default function scrollIntoNearestView(el, opts = {}) {
35
+ if (!el) return;
36
+ let parent = el.parentElement;
37
+ while (parent && parent !== document.body) {
38
+ const overflowY = getComputedStyle(parent).overflowY;
39
+ if (overflowY === 'auto' || overflowY === 'scroll') break;
40
+ parent = parent.parentElement;
41
+ }
42
+ if (!parent || parent === document.body) return;
43
+
44
+ const elRect = el.getBoundingClientRect();
45
+ const parentRect = parent.getBoundingClientRect();
46
+ const cs = getComputedStyle(parent);
47
+ const padTop = opts.padTop ?? (parseFloat(cs.scrollPaddingTop) || 0);
48
+ const padBottom =
49
+ opts.padBottom ?? (parseFloat(cs.scrollPaddingBottom) || 0);
50
+
51
+ const visibleTop = parentRect.top + padTop;
52
+ const visibleBottom = parentRect.bottom - padBottom;
53
+
54
+ let delta = 0;
55
+ if (elRect.top < visibleTop) delta = elRect.top - visibleTop;
56
+ else if (elRect.bottom > visibleBottom) delta = elRect.bottom - visibleBottom;
57
+ if (delta === 0) return;
58
+
59
+ // Direct `scrollTop` assignment (not scrollBy/scrollTo with options):
60
+ // - universally supported (no behavior:'instant' compat concerns),
61
+ // - synchronous,
62
+ // - can't be cancelled by a subsequent scroll event,
63
+ // which matters because we're often called many times in quick
64
+ // succession from scroll-spy updates while the user is mid-scroll.
65
+ parent.scrollTop = parent.scrollTop + delta;
66
+ }
@@ -1,105 +1,105 @@
1
- import React from 'react';
2
- import Callout from './components/Callout.jsx';
3
- import Card, { CardGroup } from './components/Card.jsx';
4
- import Accordion, { AccordionGroup } from './components/Accordion.jsx';
5
- import Columns from './components/Columns.jsx';
6
- import Field from './components/Field.jsx';
7
- import Prompt from './components/Prompt.jsx';
8
- import Steps, { Step } from './components/Steps.jsx';
9
- import Tree, { Folder, File } from './components/Tree.jsx';
10
- import Image from './components/Image.jsx';
11
- import CodeBlock, { CodeGroup } from './components/CodeBlock.jsx';
12
- import MethodBadge from './components/MethodBadge.jsx';
13
- import ApiPath from './components/ApiPath.jsx';
14
- import TryItBar from './components/TryItBar.jsx';
15
- import ApiField from './components/ApiField.jsx';
16
- import ApiClient from './components/ApiClient.jsx';
17
- import ApiSidebar from './components/ApiSidebar.jsx';
18
- import { validateProps } from './lib/component-schemas.js';
19
-
20
- /**
21
- * defaultMdxComponents — the registry the MDXProvider consumes.
22
- *
23
- * Two kinds of entries:
24
- *
25
- * 1. Lowercase keys ('pre', 'h1', …) override the HTML tags that
26
- * Markdown produces. We use these to upgrade plain ``` fenced
27
- * code blocks into our CodeBlock component, etc.
28
- *
29
- * 2. Capitalised keys ('Callout', 'Card', …) match the exact tag
30
- * names authors write in their .mdx, e.g. `<Callout type="warn">`.
31
- * MDX looks up the name in this map and renders our component
32
- * instead of treating it as an unknown HTML element.
33
- *
34
- * Tag-name → component is the only contract here. SSR-safe by
35
- * construction: identical map on server + client → identical render.
36
- */
37
-
38
- /* `pre > code` is how Markdown renders ``` blocks. We pull the
39
- language out of the code-element's className ("language-js" → "js")
40
- and forward children verbatim to CodeBlock. */
41
- function PreOverride({ children }) {
42
- const child = React.Children.only(children);
43
- const className = child?.props?.className || '';
44
- const m = /language-(\S+)/.exec(className);
45
- const language = m ? m[1] : undefined;
46
- const code =
47
- typeof child?.props?.children === 'string'
48
- ? child.props.children.replace(/\n$/, '')
49
- : child?.props?.children;
50
- return (
51
- <CodeBlock language={language}>
52
- {code}
53
- </CodeBlock>
54
- );
55
- }
56
-
57
- /* Wrap a component so its constrained options (see component-schemas.js)
58
- are validated at render time. An invalid option throws a marked error
59
- (`err.veluIssue`) that the dev server turns into a friendly card on the
60
- page AND a clean block in the terminal — the same surface as an unknown
61
- component. Components without a schema pass straight through. */
62
- function checked(name, Comp) {
63
- function Checked(props) {
64
- const issue = validateProps(name, props);
65
- if (issue) {
66
- const err = new Error(issue.title);
67
- err.veluIssue = issue;
68
- throw err;
69
- }
70
- return <Comp {...props} />;
71
- }
72
- Checked.displayName = `Checked(${name})`;
73
- return Checked;
74
- }
75
-
76
- export const defaultMdxComponents = {
77
- /* HTML-tag overrides (lowercase keys). */
78
- pre: PreOverride,
79
-
80
- /* Authored component tags (capitalised keys). */
81
- Callout: checked('Callout', Callout),
82
- Card,
83
- CardGroup,
84
- Accordion,
85
- AccordionGroup,
86
- Columns,
87
- Field,
88
- Prompt,
89
- Steps,
90
- Step,
91
- Tree,
92
- Folder,
93
- File,
94
- Image: checked('Image', Image),
95
- CodeBlock,
96
- CodeGroup,
97
- MethodBadge: checked('MethodBadge', MethodBadge),
98
- ApiPath: checked('ApiPath', ApiPath),
99
- TryItBar,
100
- ApiField,
101
- ApiClient,
102
- ApiSidebar,
103
- };
104
-
105
- export default defaultMdxComponents;
1
+ import React from 'react';
2
+ import Callout from './components/Callout.jsx';
3
+ import Card, { CardGroup } from './components/Card.jsx';
4
+ import Accordion, { AccordionGroup } from './components/Accordion.jsx';
5
+ import Columns from './components/Columns.jsx';
6
+ import Field from './components/Field.jsx';
7
+ import Prompt from './components/Prompt.jsx';
8
+ import Steps, { Step } from './components/Steps.jsx';
9
+ import Tree, { Folder, File } from './components/Tree.jsx';
10
+ import Image from './components/Image.jsx';
11
+ import CodeBlock, { CodeGroup } from './components/CodeBlock.jsx';
12
+ import MethodBadge from './components/MethodBadge.jsx';
13
+ import ApiPath from './components/ApiPath.jsx';
14
+ import TryItBar from './components/TryItBar.jsx';
15
+ import ApiField from './components/ApiField.jsx';
16
+ import ApiClient from './components/ApiClient.jsx';
17
+ import ApiSidebar from './components/ApiSidebar.jsx';
18
+ import { validateProps } from './lib/component-schemas.js';
19
+
20
+ /**
21
+ * defaultMdxComponents — the registry the MDXProvider consumes.
22
+ *
23
+ * Two kinds of entries:
24
+ *
25
+ * 1. Lowercase keys ('pre', 'h1', …) override the HTML tags that
26
+ * Markdown produces. We use these to upgrade plain ``` fenced
27
+ * code blocks into our CodeBlock component, etc.
28
+ *
29
+ * 2. Capitalised keys ('Callout', 'Card', …) match the exact tag
30
+ * names authors write in their .mdx, e.g. `<Callout type="warn">`.
31
+ * MDX looks up the name in this map and renders our component
32
+ * instead of treating it as an unknown HTML element.
33
+ *
34
+ * Tag-name → component is the only contract here. SSR-safe by
35
+ * construction: identical map on server + client → identical render.
36
+ */
37
+
38
+ /* `pre > code` is how Markdown renders ``` blocks. We pull the
39
+ language out of the code-element's className ("language-js" → "js")
40
+ and forward children verbatim to CodeBlock. */
41
+ function PreOverride({ children }) {
42
+ const child = React.Children.only(children);
43
+ const className = child?.props?.className || '';
44
+ const m = /language-(\S+)/.exec(className);
45
+ const language = m ? m[1] : undefined;
46
+ const code =
47
+ typeof child?.props?.children === 'string'
48
+ ? child.props.children.replace(/\n$/, '')
49
+ : child?.props?.children;
50
+ return (
51
+ <CodeBlock language={language}>
52
+ {code}
53
+ </CodeBlock>
54
+ );
55
+ }
56
+
57
+ /* Wrap a component so its constrained options (see component-schemas.js)
58
+ are validated at render time. An invalid option throws a marked error
59
+ (`err.veluIssue`) that the dev server turns into a friendly card on the
60
+ page AND a clean block in the terminal — the same surface as an unknown
61
+ component. Components without a schema pass straight through. */
62
+ function checked(name, Comp) {
63
+ function Checked(props) {
64
+ const issue = validateProps(name, props);
65
+ if (issue) {
66
+ const err = new Error(issue.title);
67
+ err.veluIssue = issue;
68
+ throw err;
69
+ }
70
+ return <Comp {...props} />;
71
+ }
72
+ Checked.displayName = `Checked(${name})`;
73
+ return Checked;
74
+ }
75
+
76
+ export const defaultMdxComponents = {
77
+ /* HTML-tag overrides (lowercase keys). */
78
+ pre: PreOverride,
79
+
80
+ /* Authored component tags (capitalised keys). */
81
+ Callout: checked('Callout', Callout),
82
+ Card,
83
+ CardGroup,
84
+ Accordion,
85
+ AccordionGroup,
86
+ Columns,
87
+ Field,
88
+ Prompt,
89
+ Steps,
90
+ Step,
91
+ Tree,
92
+ Folder,
93
+ File,
94
+ Image: checked('Image', Image),
95
+ CodeBlock,
96
+ CodeGroup,
97
+ MethodBadge: checked('MethodBadge', MethodBadge),
98
+ ApiPath: checked('ApiPath', ApiPath),
99
+ TryItBar,
100
+ ApiField,
101
+ ApiClient,
102
+ ApiSidebar,
103
+ };
104
+
105
+ export default defaultMdxComponents;
@@ -1,49 +1,49 @@
1
- import React from 'react';
2
-
3
- /**
4
- * Cluster — Every Layout primitive. Inline group that wraps onto
5
- * multiple lines when it runs out of horizontal room. Use for chips,
6
- * tags, action button rows, nav links, badge groups — any horizontal
7
- * row of inline-ish items that should break gracefully.
8
- *
9
- * Like Stack, this is pure inline styles (no CSS file needed since
10
- * there's no `> *` selector) — React-native, SSR-safe, tokenized.
11
- * Mirrors the Every Layout custom element but as React with the same
12
- * three knobs.
13
- *
14
- * - `space` gap between items (default --s1)
15
- * - `justify` justify-content (default flex-start)
16
- * - `align` align-items (default flex-start)
17
- * - `as` element tag (default 'div')
18
- *
19
- * @param {object} props
20
- * @param {React.ElementType} [props.as='div']
21
- * @param {string} [props.space='var(--s1)']
22
- * @param {string} [props.justify='flex-start']
23
- * @param {string} [props.align='flex-start']
24
- */
25
- export default function Cluster({
26
- as: Tag = 'div',
27
- space = 'var(--s1)',
28
- justify = 'flex-start',
29
- align = 'flex-start',
30
- style,
31
- children,
32
- ...rest
33
- }) {
34
- return (
35
- <Tag
36
- style={{
37
- display: 'flex',
38
- flexWrap: 'wrap',
39
- justifyContent: justify,
40
- alignItems: align,
41
- gap: space,
42
- ...style,
43
- }}
44
- {...rest}
45
- >
46
- {children}
47
- </Tag>
48
- );
49
- }
1
+ import React from 'react';
2
+
3
+ /**
4
+ * Cluster — Every Layout primitive. Inline group that wraps onto
5
+ * multiple lines when it runs out of horizontal room. Use for chips,
6
+ * tags, action button rows, nav links, badge groups — any horizontal
7
+ * row of inline-ish items that should break gracefully.
8
+ *
9
+ * Like Stack, this is pure inline styles (no CSS file needed since
10
+ * there's no `> *` selector) — React-native, SSR-safe, tokenized.
11
+ * Mirrors the Every Layout custom element but as React with the same
12
+ * three knobs.
13
+ *
14
+ * - `space` gap between items (default --s1)
15
+ * - `justify` justify-content (default flex-start)
16
+ * - `align` align-items (default flex-start)
17
+ * - `as` element tag (default 'div')
18
+ *
19
+ * @param {object} props
20
+ * @param {React.ElementType} [props.as='div']
21
+ * @param {string} [props.space='var(--s1)']
22
+ * @param {string} [props.justify='flex-start']
23
+ * @param {string} [props.align='flex-start']
24
+ */
25
+ export default function Cluster({
26
+ as: Tag = 'div',
27
+ space = 'var(--s1)',
28
+ justify = 'flex-start',
29
+ align = 'flex-start',
30
+ style,
31
+ children,
32
+ ...rest
33
+ }) {
34
+ return (
35
+ <Tag
36
+ style={{
37
+ display: 'flex',
38
+ flexWrap: 'wrap',
39
+ justifyContent: justify,
40
+ alignItems: align,
41
+ gap: space,
42
+ ...style,
43
+ }}
44
+ {...rest}
45
+ >
46
+ {children}
47
+ </Tag>
48
+ );
49
+ }