@veluai/velu 0.2.25 → 0.2.28

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 (114) hide show
  1. package/README.md +80 -80
  2. package/dist/cli.js +44 -44
  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 +125 -125
  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/ChangelogFilters.jsx +75 -75
  16. package/runtime/velu-ui/components/Chatbot.jsx +972 -972
  17. package/runtime/velu-ui/components/CodeBlock.jsx +375 -375
  18. package/runtime/velu-ui/components/Columns.jsx +56 -56
  19. package/runtime/velu-ui/components/ContextMenu.jsx +327 -327
  20. package/runtime/velu-ui/components/ErrorCard.jsx +138 -138
  21. package/runtime/velu-ui/components/Field.jsx +81 -81
  22. package/runtime/velu-ui/components/Image.jsx +163 -163
  23. package/runtime/velu-ui/components/Logo.jsx +31 -31
  24. package/runtime/velu-ui/components/MethodBadge.jsx +31 -31
  25. package/runtime/velu-ui/components/NavSelect.jsx +108 -108
  26. package/runtime/velu-ui/components/NotFound.jsx +63 -63
  27. package/runtime/velu-ui/components/PageFeedback.jsx +219 -219
  28. package/runtime/velu-ui/components/PageFooter.jsx +145 -145
  29. package/runtime/velu-ui/components/PageHeader.jsx +422 -422
  30. package/runtime/velu-ui/components/PageNav.jsx +77 -77
  31. package/runtime/velu-ui/components/PoweredBy.jsx +51 -51
  32. package/runtime/velu-ui/components/Prompt.jsx +115 -115
  33. package/runtime/velu-ui/components/Search.jsx +460 -460
  34. package/runtime/velu-ui/components/Sidebar.jsx +246 -246
  35. package/runtime/velu-ui/components/SocialLinks.jsx +90 -90
  36. package/runtime/velu-ui/components/Steps.jsx +65 -65
  37. package/runtime/velu-ui/components/ThemeToggle.jsx +48 -48
  38. package/runtime/velu-ui/components/Toc.jsx +537 -537
  39. package/runtime/velu-ui/components/TocBar.jsx +195 -195
  40. package/runtime/velu-ui/components/Tree.jsx +87 -87
  41. package/runtime/velu-ui/components/TryItBar.jsx +102 -102
  42. package/runtime/velu-ui/components/Update.jsx +92 -92
  43. package/runtime/velu-ui/components/accordion.css +92 -92
  44. package/runtime/velu-ui/components/api-page.css +208 -208
  45. package/runtime/velu-ui/components/api.css +635 -635
  46. package/runtime/velu-ui/components/ask-bar.css +103 -103
  47. package/runtime/velu-ui/components/card.css +105 -105
  48. package/runtime/velu-ui/components/changelog-filters.css +43 -43
  49. package/runtime/velu-ui/components/chatbot.css +687 -687
  50. package/runtime/velu-ui/components/code-block.css +263 -263
  51. package/runtime/velu-ui/components/context-menu.css +199 -199
  52. package/runtime/velu-ui/components/docs-layout.css +822 -822
  53. package/runtime/velu-ui/components/field.css +82 -82
  54. package/runtime/velu-ui/components/image.css +237 -237
  55. package/runtime/velu-ui/components/nav-select.css +157 -157
  56. package/runtime/velu-ui/components/not-found.css +94 -94
  57. package/runtime/velu-ui/components/page-feedback.css +261 -261
  58. package/runtime/velu-ui/components/page-footer.css +130 -130
  59. package/runtime/velu-ui/components/page-header.css +558 -558
  60. package/runtime/velu-ui/components/page-nav.css +50 -50
  61. package/runtime/velu-ui/components/powered-by.css +92 -92
  62. package/runtime/velu-ui/components/prompt.css +99 -99
  63. package/runtime/velu-ui/components/search.css +307 -307
  64. package/runtime/velu-ui/components/sidebar.css +205 -205
  65. package/runtime/velu-ui/components/steps.css +77 -77
  66. package/runtime/velu-ui/components/theme-toggle.css +102 -102
  67. package/runtime/velu-ui/components/toc-bar.css +234 -234
  68. package/runtime/velu-ui/components/tree.css +49 -49
  69. package/runtime/velu-ui/components/update.css +111 -111
  70. package/runtime/velu-ui/index.js +58 -58
  71. package/runtime/velu-ui/lib/api-send.js +118 -118
  72. package/runtime/velu-ui/lib/brand-icons.jsx +103 -103
  73. package/runtime/velu-ui/lib/component-schemas.js +100 -100
  74. package/runtime/velu-ui/lib/copyText.js +64 -64
  75. package/runtime/velu-ui/lib/docs-assistant.js +273 -273
  76. package/runtime/velu-ui/lib/lang-icons.jsx +147 -147
  77. package/runtime/velu-ui/lib/page-feedback.js +72 -72
  78. package/runtime/velu-ui/lib/pagefind.js +116 -116
  79. package/runtime/velu-ui/lib/prism-langs.js +957 -957
  80. package/runtime/velu-ui/lib/prism-loader.js +74 -74
  81. package/runtime/velu-ui/lib/resolveIcon.jsx +29 -29
  82. package/runtime/velu-ui/lib/scrollIntoNearestView.js +66 -66
  83. package/runtime/velu-ui/mdx-components.jsx +107 -107
  84. package/runtime/velu-ui/primitives/Cluster.jsx +49 -49
  85. package/runtime/velu-ui/primitives/Stack.jsx +63 -63
  86. package/runtime/velu-ui/primitives/Switcher.jsx +57 -57
  87. package/runtime/velu-ui/primitives/stack.css +3 -3
  88. package/runtime/velu-ui/primitives/switcher.css +25 -25
  89. package/runtime/velu-ui/styles.css +48 -48
  90. package/runtime/velu-ui/tokens.css +4 -4
  91. package/schema/velu.schema.json +419 -419
  92. package/src/lib/extract-mdx-error.js +170 -170
  93. package/src/lib/issues.js +159 -159
  94. package/src/lib/known-components.js +35 -35
  95. package/src/navigation.js +459 -459
  96. package/src/runtime/App.jsx +1754 -1754
  97. package/src/runtime/ErrorBoundary.jsx +54 -54
  98. package/src/runtime/client-entry.jsx +27 -27
  99. package/src/runtime/server-entry.jsx +24 -24
  100. package/src/template.html +48 -48
  101. package/templates/starter/ai-tools/claude-code.mdx +26 -26
  102. package/templates/starter/ai-tools/cursor.mdx +17 -17
  103. package/templates/starter/api-reference/introduction.mdx +43 -43
  104. package/templates/starter/development.mdx +19 -19
  105. package/templates/starter/essentials/code.mdx +29 -29
  106. package/templates/starter/essentials/images.mdx +29 -29
  107. package/templates/starter/essentials/markdown.mdx +25 -25
  108. package/templates/starter/essentials/navigation.mdx +39 -39
  109. package/templates/starter/essentials/settings.mdx +30 -30
  110. package/templates/starter/favicon.svg +6 -6
  111. package/templates/starter/index.mdx +31 -31
  112. package/templates/starter/openapi.json +160 -160
  113. package/templates/starter/quickstart.mdx +31 -31
  114. package/templates/starter/velu.json +40 -40
@@ -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,107 +1,107 @@
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 Update from './components/Update.jsx';
11
- import Image from './components/Image.jsx';
12
- import CodeBlock, { CodeGroup } from './components/CodeBlock.jsx';
13
- import MethodBadge from './components/MethodBadge.jsx';
14
- import ApiPath from './components/ApiPath.jsx';
15
- import TryItBar from './components/TryItBar.jsx';
16
- import ApiField from './components/ApiField.jsx';
17
- import ApiClient from './components/ApiClient.jsx';
18
- import ApiSidebar from './components/ApiSidebar.jsx';
19
- import { validateProps } from './lib/component-schemas.js';
20
-
21
- /**
22
- * defaultMdxComponents — the registry the MDXProvider consumes.
23
- *
24
- * Two kinds of entries:
25
- *
26
- * 1. Lowercase keys ('pre', 'h1', …) override the HTML tags that
27
- * Markdown produces. We use these to upgrade plain ``` fenced
28
- * code blocks into our CodeBlock component, etc.
29
- *
30
- * 2. Capitalised keys ('Callout', 'Card', …) match the exact tag
31
- * names authors write in their .mdx, e.g. `<Callout type="warn">`.
32
- * MDX looks up the name in this map and renders our component
33
- * instead of treating it as an unknown HTML element.
34
- *
35
- * Tag-name → component is the only contract here. SSR-safe by
36
- * construction: identical map on server + client → identical render.
37
- */
38
-
39
- /* `pre > code` is how Markdown renders ``` blocks. We pull the
40
- language out of the code-element's className ("language-js" → "js")
41
- and forward children verbatim to CodeBlock. */
42
- function PreOverride({ children }) {
43
- const child = React.Children.only(children);
44
- const className = child?.props?.className || '';
45
- const m = /language-(\S+)/.exec(className);
46
- const language = m ? m[1] : undefined;
47
- const code =
48
- typeof child?.props?.children === 'string'
49
- ? child.props.children.replace(/\n$/, '')
50
- : child?.props?.children;
51
- return (
52
- <CodeBlock language={language}>
53
- {code}
54
- </CodeBlock>
55
- );
56
- }
57
-
58
- /* Wrap a component so its constrained options (see component-schemas.js)
59
- are validated at render time. An invalid option throws a marked error
60
- (`err.veluIssue`) that the dev server turns into a friendly card on the
61
- page AND a clean block in the terminal — the same surface as an unknown
62
- component. Components without a schema pass straight through. */
63
- function checked(name, Comp) {
64
- function Checked(props) {
65
- const issue = validateProps(name, props);
66
- if (issue) {
67
- const err = new Error(issue.title);
68
- err.veluIssue = issue;
69
- throw err;
70
- }
71
- return <Comp {...props} />;
72
- }
73
- Checked.displayName = `Checked(${name})`;
74
- return Checked;
75
- }
76
-
77
- export const defaultMdxComponents = {
78
- /* HTML-tag overrides (lowercase keys). */
79
- pre: PreOverride,
80
-
81
- /* Authored component tags (capitalised keys). */
82
- Callout: checked('Callout', Callout),
83
- Card,
84
- CardGroup,
85
- Accordion,
86
- AccordionGroup,
87
- Columns,
88
- Field,
89
- Prompt,
90
- Steps,
91
- Step,
92
- Tree,
93
- Folder,
94
- File,
95
- Update,
96
- Image: checked('Image', Image),
97
- CodeBlock,
98
- CodeGroup,
99
- MethodBadge: checked('MethodBadge', MethodBadge),
100
- ApiPath: checked('ApiPath', ApiPath),
101
- TryItBar,
102
- ApiField,
103
- ApiClient,
104
- ApiSidebar,
105
- };
106
-
107
- 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 Update from './components/Update.jsx';
11
+ import Image from './components/Image.jsx';
12
+ import CodeBlock, { CodeGroup } from './components/CodeBlock.jsx';
13
+ import MethodBadge from './components/MethodBadge.jsx';
14
+ import ApiPath from './components/ApiPath.jsx';
15
+ import TryItBar from './components/TryItBar.jsx';
16
+ import ApiField from './components/ApiField.jsx';
17
+ import ApiClient from './components/ApiClient.jsx';
18
+ import ApiSidebar from './components/ApiSidebar.jsx';
19
+ import { validateProps } from './lib/component-schemas.js';
20
+
21
+ /**
22
+ * defaultMdxComponents — the registry the MDXProvider consumes.
23
+ *
24
+ * Two kinds of entries:
25
+ *
26
+ * 1. Lowercase keys ('pre', 'h1', …) override the HTML tags that
27
+ * Markdown produces. We use these to upgrade plain ``` fenced
28
+ * code blocks into our CodeBlock component, etc.
29
+ *
30
+ * 2. Capitalised keys ('Callout', 'Card', …) match the exact tag
31
+ * names authors write in their .mdx, e.g. `<Callout type="warn">`.
32
+ * MDX looks up the name in this map and renders our component
33
+ * instead of treating it as an unknown HTML element.
34
+ *
35
+ * Tag-name → component is the only contract here. SSR-safe by
36
+ * construction: identical map on server + client → identical render.
37
+ */
38
+
39
+ /* `pre > code` is how Markdown renders ``` blocks. We pull the
40
+ language out of the code-element's className ("language-js" → "js")
41
+ and forward children verbatim to CodeBlock. */
42
+ function PreOverride({ children }) {
43
+ const child = React.Children.only(children);
44
+ const className = child?.props?.className || '';
45
+ const m = /language-(\S+)/.exec(className);
46
+ const language = m ? m[1] : undefined;
47
+ const code =
48
+ typeof child?.props?.children === 'string'
49
+ ? child.props.children.replace(/\n$/, '')
50
+ : child?.props?.children;
51
+ return (
52
+ <CodeBlock language={language}>
53
+ {code}
54
+ </CodeBlock>
55
+ );
56
+ }
57
+
58
+ /* Wrap a component so its constrained options (see component-schemas.js)
59
+ are validated at render time. An invalid option throws a marked error
60
+ (`err.veluIssue`) that the dev server turns into a friendly card on the
61
+ page AND a clean block in the terminal — the same surface as an unknown
62
+ component. Components without a schema pass straight through. */
63
+ function checked(name, Comp) {
64
+ function Checked(props) {
65
+ const issue = validateProps(name, props);
66
+ if (issue) {
67
+ const err = new Error(issue.title);
68
+ err.veluIssue = issue;
69
+ throw err;
70
+ }
71
+ return <Comp {...props} />;
72
+ }
73
+ Checked.displayName = `Checked(${name})`;
74
+ return Checked;
75
+ }
76
+
77
+ export const defaultMdxComponents = {
78
+ /* HTML-tag overrides (lowercase keys). */
79
+ pre: PreOverride,
80
+
81
+ /* Authored component tags (capitalised keys). */
82
+ Callout: checked('Callout', Callout),
83
+ Card,
84
+ CardGroup,
85
+ Accordion,
86
+ AccordionGroup,
87
+ Columns,
88
+ Field,
89
+ Prompt,
90
+ Steps,
91
+ Step,
92
+ Tree,
93
+ Folder,
94
+ File,
95
+ Update,
96
+ Image: checked('Image', Image),
97
+ CodeBlock,
98
+ CodeGroup,
99
+ MethodBadge: checked('MethodBadge', MethodBadge),
100
+ ApiPath: checked('ApiPath', ApiPath),
101
+ TryItBar,
102
+ ApiField,
103
+ ApiClient,
104
+ ApiSidebar,
105
+ };
106
+
107
+ 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
+ }