@cloudvoyant/helix 0.15.0 → 0.16.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/dist/index.cjs CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
 
20
30
  // src/index.ts
@@ -77,6 +87,11 @@ __export(index_exports, {
77
87
  hstackBase: () => hstackBase,
78
88
  inputVariants: () => inputVariants,
79
89
  itemVariants: () => itemVariants,
90
+ mermaidLoadingBase: () => mermaidLoadingBase,
91
+ mermaidRootBase: () => mermaidRootBase,
92
+ mermaidSourceBase: () => mermaidSourceBase,
93
+ mermaidSvgAspectRatio: () => mermaidSvgAspectRatio,
94
+ mermaidSvgBase: () => mermaidSvgBase,
80
95
  nativeSelectIconBase: () => nativeSelectIconBase,
81
96
  nativeSelectVariants: () => nativeSelectVariants,
82
97
  nativeSelectWrapperBase: () => nativeSelectWrapperBase,
@@ -128,6 +143,8 @@ __export(index_exports, {
128
143
  popoverIndicatorBase: () => popoverIndicatorBase,
129
144
  popoverPositionerBase: () => popoverPositionerBase,
130
145
  popoverTitleBase: () => popoverTitleBase,
146
+ renderMermaidSource: () => renderMermaidSource,
147
+ resolveMermaidThemeVariables: () => resolveMermaidThemeVariables,
131
148
  rowBase: () => rowBase,
132
149
  scrollContentBase: () => scrollContentBase,
133
150
  scrollCornerBase: () => scrollCornerBase,
@@ -939,6 +956,67 @@ var tagsInputItemTextBase = "truncate";
939
956
  var tagsInputItemInputBase = "w-16 border-0 bg-transparent text-xs outline-none";
940
957
  var tagsInputItemDeleteTriggerBase = "flex size-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none [&_svg]:pointer-events-none [&_svg]:size-3 [&_svg]:shrink-0";
941
958
  var tagsInputClearTriggerBase = "ms-auto flex shrink-0 items-center justify-center self-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none [&_svg]:pointer-events-none [&_svg]:size-3.5 [&_svg]:shrink-0";
959
+
960
+ // src/mermaid.ts
961
+ var mermaidRootBase = "not-prose my-4 overflow-x-auto";
962
+ var mermaidSourceBase = "w-full overflow-x-auto bg-muted p-4 font-mono text-sm whitespace-pre";
963
+ var mermaidSvgBase = "flex w-full items-center justify-center [&>svg]:max-w-full";
964
+ var mermaidLoadingBase = "flex min-h-40 w-full items-center justify-center gap-3";
965
+ var mermaidThemeVariableTokens = {
966
+ primaryColor: "--card",
967
+ primaryTextColor: "--foreground",
968
+ primaryBorderColor: "--border",
969
+ lineColor: "--muted-foreground",
970
+ secondaryColor: "--muted",
971
+ tertiaryColor: "--accent",
972
+ background: "--background",
973
+ mainBkg: "--card",
974
+ nodeBorder: "--border"
975
+ };
976
+ var scratchCtx;
977
+ function normalizeMermaidColor(value) {
978
+ scratchCtx ??= document.createElement("canvas").getContext("2d", { willReadFrequently: true });
979
+ if (!scratchCtx) return value;
980
+ scratchCtx.fillStyle = "rgb(1 2 3)";
981
+ scratchCtx.fillStyle = value;
982
+ scratchCtx.clearRect(0, 0, 1, 1);
983
+ scratchCtx.fillRect(0, 0, 1, 1);
984
+ const [r, g, b, a] = scratchCtx.getImageData(0, 0, 1, 1).data;
985
+ if (r === 1 && g === 2 && b === 3 && a === 255) return value;
986
+ if (a === 255) return `#${[r, g, b].map((c) => c.toString(16).padStart(2, "0")).join("")}`;
987
+ return `rgba(${r}, ${g}, ${b}, ${Math.round(a / 255 * 1e3) / 1e3})`;
988
+ }
989
+ function resolveMermaidThemeVariables() {
990
+ const styles = getComputedStyle(document.documentElement);
991
+ const themeVariables = {};
992
+ for (const [key, token] of Object.entries(mermaidThemeVariableTokens)) {
993
+ const value = styles.getPropertyValue(token).trim();
994
+ if (value) themeVariables[key] = normalizeMermaidColor(value);
995
+ }
996
+ return themeVariables;
997
+ }
998
+ var mermaidSeq = 0;
999
+ function mermaidSvgAspectRatio(svg) {
1000
+ const match = /viewBox="\s*[-\d.]+\s+[-\d.]+\s+([-\d.]+)\s+([-\d.]+)"/.exec(svg);
1001
+ if (!match) return void 0;
1002
+ const width = Number(match[1]);
1003
+ const height = Number(match[2]);
1004
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return void 0;
1005
+ return `${width} / ${height}`;
1006
+ }
1007
+ async function renderMermaidSource(code) {
1008
+ const mermaid = (await import("mermaid")).default;
1009
+ const dark = document.documentElement.classList.contains("dark");
1010
+ mermaid.initialize({
1011
+ startOnLoad: false,
1012
+ securityLevel: "strict",
1013
+ suppressErrorRendering: true,
1014
+ theme: dark ? "dark" : "default",
1015
+ themeVariables: resolveMermaidThemeVariables()
1016
+ });
1017
+ const { svg } = await mermaid.render(`helix-mmd-${Date.now()}-${mermaidSeq++}`, code);
1018
+ return svg;
1019
+ }
942
1020
  // Annotate the CommonJS export names for ESM import in node:
943
1021
  0 && (module.exports = {
944
1022
  SIDEBAR_KEYBOARD_SHORTCUT,
@@ -998,6 +1076,11 @@ var tagsInputClearTriggerBase = "ms-auto flex shrink-0 items-center justify-cent
998
1076
  hstackBase,
999
1077
  inputVariants,
1000
1078
  itemVariants,
1079
+ mermaidLoadingBase,
1080
+ mermaidRootBase,
1081
+ mermaidSourceBase,
1082
+ mermaidSvgAspectRatio,
1083
+ mermaidSvgBase,
1001
1084
  nativeSelectIconBase,
1002
1085
  nativeSelectVariants,
1003
1086
  nativeSelectWrapperBase,
@@ -1049,6 +1132,8 @@ var tagsInputClearTriggerBase = "ms-auto flex shrink-0 items-center justify-cent
1049
1132
  popoverIndicatorBase,
1050
1133
  popoverPositionerBase,
1051
1134
  popoverTitleBase,
1135
+ renderMermaidSource,
1136
+ resolveMermaidThemeVariables,
1052
1137
  rowBase,
1053
1138
  scrollContentBase,
1054
1139
  scrollCornerBase,
package/dist/index.d.cts CHANGED
@@ -388,4 +388,51 @@ interface TagsInputProps {
388
388
  className?: string;
389
389
  }
390
390
 
391
- export { type BadgeProps, type BadgeVariants, type ButtonProps, type ButtonVariants, type CardCoverProps, type CardProps, type CardVariants, type CheckboxProps, type CheckboxVariants, type ComboboxItemVariants, type ComboboxProps, type InputProps, type InputVariants, type ItemProps, type ItemVariants, type NativeSelectVariants, type NavbarDensity, type NavbarMenuDensity, type NavbarMenuVariant, type NavbarVariant, type NumberInputProps, type PageGutterContentVariants, type PageGutterVariants, type PageVariants, SIDEBAR_KEYBOARD_SHORTCUT, SIDEBAR_WIDTH, SIDEBAR_WIDTH_ICON, SIDEBAR_WIDTH_MOBILE, type SelectItemData, type SelectProps, type SidebarContextProps, type SidebarMenuButtonVariants, type SwitchProps, type SwitchVariants, THEMES, THEME_NAMES, type TabsIndicatorVariants, type TabsListVariants, type TagsInputProps, type TextareaProps, type ThemeMeta, type ToggleButtonProps, type ToggleButtonVariants, badgeVariants, buttonVariants, cardBodyBase, cardCoverVariants, cardDescriptionBase, cardFooterBase, cardHeaderBase, cardTitleBase, cardVariants, centerBase, checkboxGroupBase, checkboxIndicatorBase, checkboxLabelBase, checkboxVariants, cn, colBase, comboboxClearTriggerBase, comboboxContentBase, comboboxControlBase, comboboxEmptyBase, comboboxInputBase, comboboxItemGroupLabelBase, comboboxItemIndicatorBase, comboboxItemVariants, comboboxListBase, comboboxPositionerBase, comboboxTriggerBase, containerBase, dialogBackdropBase, dialogCloseTriggerBase, dialogContentBase, dialogDescriptionBase, dialogFooterBase, dialogFooterStickyBase, dialogFullscreenContentBase, dialogHeaderBase, dialogHeaderStickyBase, dialogPositionerBase, dialogTitleBase, fieldErrorBase, fieldHelperBase, fieldLabelBase, fieldRequiredIndicatorBase, fieldRootBase, fieldsetErrorBase, fieldsetHelperBase, fieldsetLegendBase, fieldsetRootBase, hstackBase, inputVariants, itemVariants, nativeSelectIconBase, nativeSelectVariants, nativeSelectWrapperBase, navbarActionsBase, navbarActivationAreaBase, navbarBrandBase, navbarContainerBase, navbarDensityVariants, navbarMenuBase, navbarMenuContentBase, navbarMenuIndicatorBase, navbarMenuItemBase, navbarMenuLinkBase, navbarMenuListBase, navbarMenuPlacementVariants, navbarMenuRootBase, navbarMenuTriggerStyle, navbarMenuViewportBase, navbarMenuViewportPositionerBase, navbarMobileActionsBase, navbarMobileBase, navbarMobileContentBase, navbarMobileHeaderBase, navbarMobileMenuBase, navbarMobileMenuContentBase, navbarMobileMenuTriggerBase, navbarShrunkBase, navbarTriggerVariants, navbarVariants, numberInputControlBase, numberInputInputBase, numberInputRootBase, numberInputTriggerBase, pageContentBase, pageFooterBase, pageGutterAreaBase, pageGutterContentVariants, pageGutterVariants, pageSectionBase, pageVariants, paginationEllipsisBase, paginationItemBase, paginationRootBase, paginationTriggerBase, popoverArrowBase, popoverCloseTriggerBase, popoverContentBase, popoverDescriptionBase, popoverIndicatorBase, popoverPositionerBase, popoverTitleBase, rowBase, scrollContentBase, scrollCornerBase, scrollRootBase, scrollScrollbarBase, scrollThumbBase, scrollViewportBase, selectClearTriggerBase, selectContentBase, selectIndicatorBase, selectItemBase, selectItemGroupLabelBase, selectItemIndicatorBase, selectItemTextBase, selectPositionerBase, selectTriggerBase, selectValueBase, sidebarMenuButtonVariants, sidebarStyles, splitterPanelBase, splitterResizeTriggerBase, splitterResizeTriggerIndicatorBase, splitterResizeTriggerSeparatorBase, splitterRootBase, stackBase, switchControlBase, switchLabelBase, switchThumbBase, switchVariants, tabsContentBase, tabsIndicatorBase, tabsIndicatorVariants, tabsListBase, tabsListVariants, tabsRootBase, tabsTriggerBase, tagsInputClearTriggerBase, tagsInputControlBase, tagsInputInputBase, tagsInputItemBase, tagsInputItemDeleteTriggerBase, tagsInputItemInputBase, tagsInputItemTextBase, tagsInputRootBase, textareaBase, toggleButtonVariants, tooltipArrowBase, tooltipContentBase, tooltipPositionerBase, vstackBase, windowBodyBase, windowCloseTriggerBase, windowContentBase, windowControlBase, windowDragTriggerBase, windowHeaderBase, windowPositionerBase, windowResizeTriggerBase, windowStageTriggerBase, windowTitleBase };
391
+ /** Root container: escapes prose margins, keeps wide diagrams scrollable. Height is driven by
392
+ * the diagram's own content (the SVG's natural size, or the prerendered `viewBox` `aspect-ratio`
393
+ * layered via inline style) — never a fixed minimum, so a short diagram is not left sitting in a
394
+ * taller empty container. */
395
+ declare const mermaidRootBase = "not-prose my-4 overflow-x-auto";
396
+ /** Placeholder `<pre>` showing the raw diagram source until (or instead of) rendering.
397
+ * No border or rounded corners — it must look identical to the rendered SVG. */
398
+ declare const mermaidSourceBase = "w-full overflow-x-auto bg-muted p-4 font-mono text-sm whitespace-pre";
399
+ /** Wrapper around the rendered SVG: centered both axes, scaled down to the container width. */
400
+ declare const mermaidSvgBase = "flex w-full items-center justify-center [&>svg]:max-w-full";
401
+ /** Loading state shown while the client-side mermaid render is in flight: a centered spinner +
402
+ * label. Chrome-free so it matches the rendered SVG. Reserves a minimum footprint (`min-h-40`)
403
+ * so the swap doesn't collapse the layout for short diagrams; the rendered SVG takes its natural
404
+ * height (root has no fixed minimum). */
405
+ declare const mermaidLoadingBase = "flex min-h-40 w-full items-center justify-center gap-3";
406
+ /** Props shared by the React and Svelte Mermaid wrappers; framework wrappers intersect
407
+ * these with their host element's HTML attributes. */
408
+ interface MermaidProps {
409
+ /** Mermaid diagram source. */
410
+ code: string;
411
+ /** Pre-rendered SVG markup. When provided the component renders it immediately and never
412
+ * imports `mermaid` client-side — the server-side rendering path. The SVG should carry a
413
+ * `viewBox` so its aspect ratio can be reserved (no layout shift). */
414
+ svg?: string;
415
+ /** Extra classes for the root container. */
416
+ className?: string;
417
+ }
418
+ /** Resolves mermaid `themeVariables` from the shadcn CSS custom properties currently set
419
+ * on `<html>` (so the active color mode and any brand-theme overrides are picked up).
420
+ * Tokens that are undefined are omitted, leaving mermaid's own theme defaults in place. */
421
+ declare function resolveMermaidThemeVariables(): Record<string, string>;
422
+ /** Extracts the width/height ratio from an SVG `viewBox` (e.g. `0 0 800 450` → `800 / 450`).
423
+ * Used to reserve the diagram's aspect ratio on the root container so the client-rendered
424
+ * SVG swap never shifts the layout. Returns `undefined` when the SVG has no parseable viewBox. */
425
+ declare function mermaidSvgAspectRatio(svg: string): string | undefined;
426
+ /**
427
+ * Dynamically import mermaid and render `code` to an SVG string. The import stays
428
+ * client-only and lazy, so mermaid never enters the SSR/initial bundle.
429
+ *
430
+ * Diagrams render with `securityLevel: 'strict'` (mermaid sanitizes the output with
431
+ * DOMPurify and strips click bindings, so untrusted sources cannot execute scripts) and
432
+ * `suppressErrorRendering: true` (without it, mermaid appends a "Syntax error in text"
433
+ * SVG to `document.body` on every failed render). The render-id counter is module-scoped
434
+ * so concurrent renders from any number of components never collide.
435
+ */
436
+ declare function renderMermaidSource(code: string): Promise<string>;
437
+
438
+ export { type BadgeProps, type BadgeVariants, type ButtonProps, type ButtonVariants, type CardCoverProps, type CardProps, type CardVariants, type CheckboxProps, type CheckboxVariants, type ComboboxItemVariants, type ComboboxProps, type InputProps, type InputVariants, type ItemProps, type ItemVariants, type MermaidProps, type NativeSelectVariants, type NavbarDensity, type NavbarMenuDensity, type NavbarMenuVariant, type NavbarVariant, type NumberInputProps, type PageGutterContentVariants, type PageGutterVariants, type PageVariants, SIDEBAR_KEYBOARD_SHORTCUT, SIDEBAR_WIDTH, SIDEBAR_WIDTH_ICON, SIDEBAR_WIDTH_MOBILE, type SelectItemData, type SelectProps, type SidebarContextProps, type SidebarMenuButtonVariants, type SwitchProps, type SwitchVariants, THEMES, THEME_NAMES, type TabsIndicatorVariants, type TabsListVariants, type TagsInputProps, type TextareaProps, type ThemeMeta, type ToggleButtonProps, type ToggleButtonVariants, badgeVariants, buttonVariants, cardBodyBase, cardCoverVariants, cardDescriptionBase, cardFooterBase, cardHeaderBase, cardTitleBase, cardVariants, centerBase, checkboxGroupBase, checkboxIndicatorBase, checkboxLabelBase, checkboxVariants, cn, colBase, comboboxClearTriggerBase, comboboxContentBase, comboboxControlBase, comboboxEmptyBase, comboboxInputBase, comboboxItemGroupLabelBase, comboboxItemIndicatorBase, comboboxItemVariants, comboboxListBase, comboboxPositionerBase, comboboxTriggerBase, containerBase, dialogBackdropBase, dialogCloseTriggerBase, dialogContentBase, dialogDescriptionBase, dialogFooterBase, dialogFooterStickyBase, dialogFullscreenContentBase, dialogHeaderBase, dialogHeaderStickyBase, dialogPositionerBase, dialogTitleBase, fieldErrorBase, fieldHelperBase, fieldLabelBase, fieldRequiredIndicatorBase, fieldRootBase, fieldsetErrorBase, fieldsetHelperBase, fieldsetLegendBase, fieldsetRootBase, hstackBase, inputVariants, itemVariants, mermaidLoadingBase, mermaidRootBase, mermaidSourceBase, mermaidSvgAspectRatio, mermaidSvgBase, nativeSelectIconBase, nativeSelectVariants, nativeSelectWrapperBase, navbarActionsBase, navbarActivationAreaBase, navbarBrandBase, navbarContainerBase, navbarDensityVariants, navbarMenuBase, navbarMenuContentBase, navbarMenuIndicatorBase, navbarMenuItemBase, navbarMenuLinkBase, navbarMenuListBase, navbarMenuPlacementVariants, navbarMenuRootBase, navbarMenuTriggerStyle, navbarMenuViewportBase, navbarMenuViewportPositionerBase, navbarMobileActionsBase, navbarMobileBase, navbarMobileContentBase, navbarMobileHeaderBase, navbarMobileMenuBase, navbarMobileMenuContentBase, navbarMobileMenuTriggerBase, navbarShrunkBase, navbarTriggerVariants, navbarVariants, numberInputControlBase, numberInputInputBase, numberInputRootBase, numberInputTriggerBase, pageContentBase, pageFooterBase, pageGutterAreaBase, pageGutterContentVariants, pageGutterVariants, pageSectionBase, pageVariants, paginationEllipsisBase, paginationItemBase, paginationRootBase, paginationTriggerBase, popoverArrowBase, popoverCloseTriggerBase, popoverContentBase, popoverDescriptionBase, popoverIndicatorBase, popoverPositionerBase, popoverTitleBase, renderMermaidSource, resolveMermaidThemeVariables, rowBase, scrollContentBase, scrollCornerBase, scrollRootBase, scrollScrollbarBase, scrollThumbBase, scrollViewportBase, selectClearTriggerBase, selectContentBase, selectIndicatorBase, selectItemBase, selectItemGroupLabelBase, selectItemIndicatorBase, selectItemTextBase, selectPositionerBase, selectTriggerBase, selectValueBase, sidebarMenuButtonVariants, sidebarStyles, splitterPanelBase, splitterResizeTriggerBase, splitterResizeTriggerIndicatorBase, splitterResizeTriggerSeparatorBase, splitterRootBase, stackBase, switchControlBase, switchLabelBase, switchThumbBase, switchVariants, tabsContentBase, tabsIndicatorBase, tabsIndicatorVariants, tabsListBase, tabsListVariants, tabsRootBase, tabsTriggerBase, tagsInputClearTriggerBase, tagsInputControlBase, tagsInputInputBase, tagsInputItemBase, tagsInputItemDeleteTriggerBase, tagsInputItemInputBase, tagsInputItemTextBase, tagsInputRootBase, textareaBase, toggleButtonVariants, tooltipArrowBase, tooltipContentBase, tooltipPositionerBase, vstackBase, windowBodyBase, windowCloseTriggerBase, windowContentBase, windowControlBase, windowDragTriggerBase, windowHeaderBase, windowPositionerBase, windowResizeTriggerBase, windowStageTriggerBase, windowTitleBase };
package/dist/index.d.ts CHANGED
@@ -388,4 +388,51 @@ interface TagsInputProps {
388
388
  className?: string;
389
389
  }
390
390
 
391
- export { type BadgeProps, type BadgeVariants, type ButtonProps, type ButtonVariants, type CardCoverProps, type CardProps, type CardVariants, type CheckboxProps, type CheckboxVariants, type ComboboxItemVariants, type ComboboxProps, type InputProps, type InputVariants, type ItemProps, type ItemVariants, type NativeSelectVariants, type NavbarDensity, type NavbarMenuDensity, type NavbarMenuVariant, type NavbarVariant, type NumberInputProps, type PageGutterContentVariants, type PageGutterVariants, type PageVariants, SIDEBAR_KEYBOARD_SHORTCUT, SIDEBAR_WIDTH, SIDEBAR_WIDTH_ICON, SIDEBAR_WIDTH_MOBILE, type SelectItemData, type SelectProps, type SidebarContextProps, type SidebarMenuButtonVariants, type SwitchProps, type SwitchVariants, THEMES, THEME_NAMES, type TabsIndicatorVariants, type TabsListVariants, type TagsInputProps, type TextareaProps, type ThemeMeta, type ToggleButtonProps, type ToggleButtonVariants, badgeVariants, buttonVariants, cardBodyBase, cardCoverVariants, cardDescriptionBase, cardFooterBase, cardHeaderBase, cardTitleBase, cardVariants, centerBase, checkboxGroupBase, checkboxIndicatorBase, checkboxLabelBase, checkboxVariants, cn, colBase, comboboxClearTriggerBase, comboboxContentBase, comboboxControlBase, comboboxEmptyBase, comboboxInputBase, comboboxItemGroupLabelBase, comboboxItemIndicatorBase, comboboxItemVariants, comboboxListBase, comboboxPositionerBase, comboboxTriggerBase, containerBase, dialogBackdropBase, dialogCloseTriggerBase, dialogContentBase, dialogDescriptionBase, dialogFooterBase, dialogFooterStickyBase, dialogFullscreenContentBase, dialogHeaderBase, dialogHeaderStickyBase, dialogPositionerBase, dialogTitleBase, fieldErrorBase, fieldHelperBase, fieldLabelBase, fieldRequiredIndicatorBase, fieldRootBase, fieldsetErrorBase, fieldsetHelperBase, fieldsetLegendBase, fieldsetRootBase, hstackBase, inputVariants, itemVariants, nativeSelectIconBase, nativeSelectVariants, nativeSelectWrapperBase, navbarActionsBase, navbarActivationAreaBase, navbarBrandBase, navbarContainerBase, navbarDensityVariants, navbarMenuBase, navbarMenuContentBase, navbarMenuIndicatorBase, navbarMenuItemBase, navbarMenuLinkBase, navbarMenuListBase, navbarMenuPlacementVariants, navbarMenuRootBase, navbarMenuTriggerStyle, navbarMenuViewportBase, navbarMenuViewportPositionerBase, navbarMobileActionsBase, navbarMobileBase, navbarMobileContentBase, navbarMobileHeaderBase, navbarMobileMenuBase, navbarMobileMenuContentBase, navbarMobileMenuTriggerBase, navbarShrunkBase, navbarTriggerVariants, navbarVariants, numberInputControlBase, numberInputInputBase, numberInputRootBase, numberInputTriggerBase, pageContentBase, pageFooterBase, pageGutterAreaBase, pageGutterContentVariants, pageGutterVariants, pageSectionBase, pageVariants, paginationEllipsisBase, paginationItemBase, paginationRootBase, paginationTriggerBase, popoverArrowBase, popoverCloseTriggerBase, popoverContentBase, popoverDescriptionBase, popoverIndicatorBase, popoverPositionerBase, popoverTitleBase, rowBase, scrollContentBase, scrollCornerBase, scrollRootBase, scrollScrollbarBase, scrollThumbBase, scrollViewportBase, selectClearTriggerBase, selectContentBase, selectIndicatorBase, selectItemBase, selectItemGroupLabelBase, selectItemIndicatorBase, selectItemTextBase, selectPositionerBase, selectTriggerBase, selectValueBase, sidebarMenuButtonVariants, sidebarStyles, splitterPanelBase, splitterResizeTriggerBase, splitterResizeTriggerIndicatorBase, splitterResizeTriggerSeparatorBase, splitterRootBase, stackBase, switchControlBase, switchLabelBase, switchThumbBase, switchVariants, tabsContentBase, tabsIndicatorBase, tabsIndicatorVariants, tabsListBase, tabsListVariants, tabsRootBase, tabsTriggerBase, tagsInputClearTriggerBase, tagsInputControlBase, tagsInputInputBase, tagsInputItemBase, tagsInputItemDeleteTriggerBase, tagsInputItemInputBase, tagsInputItemTextBase, tagsInputRootBase, textareaBase, toggleButtonVariants, tooltipArrowBase, tooltipContentBase, tooltipPositionerBase, vstackBase, windowBodyBase, windowCloseTriggerBase, windowContentBase, windowControlBase, windowDragTriggerBase, windowHeaderBase, windowPositionerBase, windowResizeTriggerBase, windowStageTriggerBase, windowTitleBase };
391
+ /** Root container: escapes prose margins, keeps wide diagrams scrollable. Height is driven by
392
+ * the diagram's own content (the SVG's natural size, or the prerendered `viewBox` `aspect-ratio`
393
+ * layered via inline style) — never a fixed minimum, so a short diagram is not left sitting in a
394
+ * taller empty container. */
395
+ declare const mermaidRootBase = "not-prose my-4 overflow-x-auto";
396
+ /** Placeholder `<pre>` showing the raw diagram source until (or instead of) rendering.
397
+ * No border or rounded corners — it must look identical to the rendered SVG. */
398
+ declare const mermaidSourceBase = "w-full overflow-x-auto bg-muted p-4 font-mono text-sm whitespace-pre";
399
+ /** Wrapper around the rendered SVG: centered both axes, scaled down to the container width. */
400
+ declare const mermaidSvgBase = "flex w-full items-center justify-center [&>svg]:max-w-full";
401
+ /** Loading state shown while the client-side mermaid render is in flight: a centered spinner +
402
+ * label. Chrome-free so it matches the rendered SVG. Reserves a minimum footprint (`min-h-40`)
403
+ * so the swap doesn't collapse the layout for short diagrams; the rendered SVG takes its natural
404
+ * height (root has no fixed minimum). */
405
+ declare const mermaidLoadingBase = "flex min-h-40 w-full items-center justify-center gap-3";
406
+ /** Props shared by the React and Svelte Mermaid wrappers; framework wrappers intersect
407
+ * these with their host element's HTML attributes. */
408
+ interface MermaidProps {
409
+ /** Mermaid diagram source. */
410
+ code: string;
411
+ /** Pre-rendered SVG markup. When provided the component renders it immediately and never
412
+ * imports `mermaid` client-side — the server-side rendering path. The SVG should carry a
413
+ * `viewBox` so its aspect ratio can be reserved (no layout shift). */
414
+ svg?: string;
415
+ /** Extra classes for the root container. */
416
+ className?: string;
417
+ }
418
+ /** Resolves mermaid `themeVariables` from the shadcn CSS custom properties currently set
419
+ * on `<html>` (so the active color mode and any brand-theme overrides are picked up).
420
+ * Tokens that are undefined are omitted, leaving mermaid's own theme defaults in place. */
421
+ declare function resolveMermaidThemeVariables(): Record<string, string>;
422
+ /** Extracts the width/height ratio from an SVG `viewBox` (e.g. `0 0 800 450` → `800 / 450`).
423
+ * Used to reserve the diagram's aspect ratio on the root container so the client-rendered
424
+ * SVG swap never shifts the layout. Returns `undefined` when the SVG has no parseable viewBox. */
425
+ declare function mermaidSvgAspectRatio(svg: string): string | undefined;
426
+ /**
427
+ * Dynamically import mermaid and render `code` to an SVG string. The import stays
428
+ * client-only and lazy, so mermaid never enters the SSR/initial bundle.
429
+ *
430
+ * Diagrams render with `securityLevel: 'strict'` (mermaid sanitizes the output with
431
+ * DOMPurify and strips click bindings, so untrusted sources cannot execute scripts) and
432
+ * `suppressErrorRendering: true` (without it, mermaid appends a "Syntax error in text"
433
+ * SVG to `document.body` on every failed render). The render-id counter is module-scoped
434
+ * so concurrent renders from any number of components never collide.
435
+ */
436
+ declare function renderMermaidSource(code: string): Promise<string>;
437
+
438
+ export { type BadgeProps, type BadgeVariants, type ButtonProps, type ButtonVariants, type CardCoverProps, type CardProps, type CardVariants, type CheckboxProps, type CheckboxVariants, type ComboboxItemVariants, type ComboboxProps, type InputProps, type InputVariants, type ItemProps, type ItemVariants, type MermaidProps, type NativeSelectVariants, type NavbarDensity, type NavbarMenuDensity, type NavbarMenuVariant, type NavbarVariant, type NumberInputProps, type PageGutterContentVariants, type PageGutterVariants, type PageVariants, SIDEBAR_KEYBOARD_SHORTCUT, SIDEBAR_WIDTH, SIDEBAR_WIDTH_ICON, SIDEBAR_WIDTH_MOBILE, type SelectItemData, type SelectProps, type SidebarContextProps, type SidebarMenuButtonVariants, type SwitchProps, type SwitchVariants, THEMES, THEME_NAMES, type TabsIndicatorVariants, type TabsListVariants, type TagsInputProps, type TextareaProps, type ThemeMeta, type ToggleButtonProps, type ToggleButtonVariants, badgeVariants, buttonVariants, cardBodyBase, cardCoverVariants, cardDescriptionBase, cardFooterBase, cardHeaderBase, cardTitleBase, cardVariants, centerBase, checkboxGroupBase, checkboxIndicatorBase, checkboxLabelBase, checkboxVariants, cn, colBase, comboboxClearTriggerBase, comboboxContentBase, comboboxControlBase, comboboxEmptyBase, comboboxInputBase, comboboxItemGroupLabelBase, comboboxItemIndicatorBase, comboboxItemVariants, comboboxListBase, comboboxPositionerBase, comboboxTriggerBase, containerBase, dialogBackdropBase, dialogCloseTriggerBase, dialogContentBase, dialogDescriptionBase, dialogFooterBase, dialogFooterStickyBase, dialogFullscreenContentBase, dialogHeaderBase, dialogHeaderStickyBase, dialogPositionerBase, dialogTitleBase, fieldErrorBase, fieldHelperBase, fieldLabelBase, fieldRequiredIndicatorBase, fieldRootBase, fieldsetErrorBase, fieldsetHelperBase, fieldsetLegendBase, fieldsetRootBase, hstackBase, inputVariants, itemVariants, mermaidLoadingBase, mermaidRootBase, mermaidSourceBase, mermaidSvgAspectRatio, mermaidSvgBase, nativeSelectIconBase, nativeSelectVariants, nativeSelectWrapperBase, navbarActionsBase, navbarActivationAreaBase, navbarBrandBase, navbarContainerBase, navbarDensityVariants, navbarMenuBase, navbarMenuContentBase, navbarMenuIndicatorBase, navbarMenuItemBase, navbarMenuLinkBase, navbarMenuListBase, navbarMenuPlacementVariants, navbarMenuRootBase, navbarMenuTriggerStyle, navbarMenuViewportBase, navbarMenuViewportPositionerBase, navbarMobileActionsBase, navbarMobileBase, navbarMobileContentBase, navbarMobileHeaderBase, navbarMobileMenuBase, navbarMobileMenuContentBase, navbarMobileMenuTriggerBase, navbarShrunkBase, navbarTriggerVariants, navbarVariants, numberInputControlBase, numberInputInputBase, numberInputRootBase, numberInputTriggerBase, pageContentBase, pageFooterBase, pageGutterAreaBase, pageGutterContentVariants, pageGutterVariants, pageSectionBase, pageVariants, paginationEllipsisBase, paginationItemBase, paginationRootBase, paginationTriggerBase, popoverArrowBase, popoverCloseTriggerBase, popoverContentBase, popoverDescriptionBase, popoverIndicatorBase, popoverPositionerBase, popoverTitleBase, renderMermaidSource, resolveMermaidThemeVariables, rowBase, scrollContentBase, scrollCornerBase, scrollRootBase, scrollScrollbarBase, scrollThumbBase, scrollViewportBase, selectClearTriggerBase, selectContentBase, selectIndicatorBase, selectItemBase, selectItemGroupLabelBase, selectItemIndicatorBase, selectItemTextBase, selectPositionerBase, selectTriggerBase, selectValueBase, sidebarMenuButtonVariants, sidebarStyles, splitterPanelBase, splitterResizeTriggerBase, splitterResizeTriggerIndicatorBase, splitterResizeTriggerSeparatorBase, splitterRootBase, stackBase, switchControlBase, switchLabelBase, switchThumbBase, switchVariants, tabsContentBase, tabsIndicatorBase, tabsIndicatorVariants, tabsListBase, tabsListVariants, tabsRootBase, tabsTriggerBase, tagsInputClearTriggerBase, tagsInputControlBase, tagsInputInputBase, tagsInputItemBase, tagsInputItemDeleteTriggerBase, tagsInputItemInputBase, tagsInputItemTextBase, tagsInputRootBase, textareaBase, toggleButtonVariants, tooltipArrowBase, tooltipContentBase, tooltipPositionerBase, vstackBase, windowBodyBase, windowCloseTriggerBase, windowContentBase, windowControlBase, windowDragTriggerBase, windowHeaderBase, windowPositionerBase, windowResizeTriggerBase, windowStageTriggerBase, windowTitleBase };
package/dist/index.js CHANGED
@@ -746,6 +746,67 @@ var tagsInputItemTextBase = "truncate";
746
746
  var tagsInputItemInputBase = "w-16 border-0 bg-transparent text-xs outline-none";
747
747
  var tagsInputItemDeleteTriggerBase = "flex size-4 shrink-0 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none [&_svg]:pointer-events-none [&_svg]:size-3 [&_svg]:shrink-0";
748
748
  var tagsInputClearTriggerBase = "ms-auto flex shrink-0 items-center justify-center self-center text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none [&_svg]:pointer-events-none [&_svg]:size-3.5 [&_svg]:shrink-0";
749
+
750
+ // src/mermaid.ts
751
+ var mermaidRootBase = "not-prose my-4 overflow-x-auto";
752
+ var mermaidSourceBase = "w-full overflow-x-auto bg-muted p-4 font-mono text-sm whitespace-pre";
753
+ var mermaidSvgBase = "flex w-full items-center justify-center [&>svg]:max-w-full";
754
+ var mermaidLoadingBase = "flex min-h-40 w-full items-center justify-center gap-3";
755
+ var mermaidThemeVariableTokens = {
756
+ primaryColor: "--card",
757
+ primaryTextColor: "--foreground",
758
+ primaryBorderColor: "--border",
759
+ lineColor: "--muted-foreground",
760
+ secondaryColor: "--muted",
761
+ tertiaryColor: "--accent",
762
+ background: "--background",
763
+ mainBkg: "--card",
764
+ nodeBorder: "--border"
765
+ };
766
+ var scratchCtx;
767
+ function normalizeMermaidColor(value) {
768
+ scratchCtx ??= document.createElement("canvas").getContext("2d", { willReadFrequently: true });
769
+ if (!scratchCtx) return value;
770
+ scratchCtx.fillStyle = "rgb(1 2 3)";
771
+ scratchCtx.fillStyle = value;
772
+ scratchCtx.clearRect(0, 0, 1, 1);
773
+ scratchCtx.fillRect(0, 0, 1, 1);
774
+ const [r, g, b, a] = scratchCtx.getImageData(0, 0, 1, 1).data;
775
+ if (r === 1 && g === 2 && b === 3 && a === 255) return value;
776
+ if (a === 255) return `#${[r, g, b].map((c) => c.toString(16).padStart(2, "0")).join("")}`;
777
+ return `rgba(${r}, ${g}, ${b}, ${Math.round(a / 255 * 1e3) / 1e3})`;
778
+ }
779
+ function resolveMermaidThemeVariables() {
780
+ const styles = getComputedStyle(document.documentElement);
781
+ const themeVariables = {};
782
+ for (const [key, token] of Object.entries(mermaidThemeVariableTokens)) {
783
+ const value = styles.getPropertyValue(token).trim();
784
+ if (value) themeVariables[key] = normalizeMermaidColor(value);
785
+ }
786
+ return themeVariables;
787
+ }
788
+ var mermaidSeq = 0;
789
+ function mermaidSvgAspectRatio(svg) {
790
+ const match = /viewBox="\s*[-\d.]+\s+[-\d.]+\s+([-\d.]+)\s+([-\d.]+)"/.exec(svg);
791
+ if (!match) return void 0;
792
+ const width = Number(match[1]);
793
+ const height = Number(match[2]);
794
+ if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return void 0;
795
+ return `${width} / ${height}`;
796
+ }
797
+ async function renderMermaidSource(code) {
798
+ const mermaid = (await import("mermaid")).default;
799
+ const dark = document.documentElement.classList.contains("dark");
800
+ mermaid.initialize({
801
+ startOnLoad: false,
802
+ securityLevel: "strict",
803
+ suppressErrorRendering: true,
804
+ theme: dark ? "dark" : "default",
805
+ themeVariables: resolveMermaidThemeVariables()
806
+ });
807
+ const { svg } = await mermaid.render(`helix-mmd-${Date.now()}-${mermaidSeq++}`, code);
808
+ return svg;
809
+ }
749
810
  export {
750
811
  SIDEBAR_KEYBOARD_SHORTCUT,
751
812
  SIDEBAR_WIDTH,
@@ -804,6 +865,11 @@ export {
804
865
  hstackBase,
805
866
  inputVariants,
806
867
  itemVariants,
868
+ mermaidLoadingBase,
869
+ mermaidRootBase,
870
+ mermaidSourceBase,
871
+ mermaidSvgAspectRatio,
872
+ mermaidSvgBase,
807
873
  nativeSelectIconBase,
808
874
  nativeSelectVariants,
809
875
  nativeSelectWrapperBase,
@@ -855,6 +921,8 @@ export {
855
921
  popoverIndicatorBase,
856
922
  popoverPositionerBase,
857
923
  popoverTitleBase,
924
+ renderMermaidSource,
925
+ resolveMermaidThemeVariables,
858
926
  rowBase,
859
927
  scrollContentBase,
860
928
  scrollCornerBase,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudvoyant/helix",
3
- "version": "0.15.0",
3
+ "version": "0.16.0",
4
4
  "description": "helix shared component interfaces, cva variants, and theme",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -33,8 +33,17 @@
33
33
  "clsx": "^2.1.1",
34
34
  "tailwind-merge": "^3.6.0"
35
35
  },
36
+ "peerDependencies": {
37
+ "mermaid": "^11.16.0"
38
+ },
39
+ "peerDependenciesMeta": {
40
+ "mermaid": {
41
+ "optional": true
42
+ }
43
+ },
36
44
  "devDependencies": {
37
45
  "@types/node": "^22.0.0",
46
+ "mermaid": "^11.16.0",
38
47
  "vitest": "^2.0.0"
39
48
  },
40
49
  "scripts": {