@ctrl-ui/react 0.8.19 → 0.8.21

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 (84) hide show
  1. package/README.md +7 -0
  2. package/dist/action-bar.js +2 -2
  3. package/dist/audio-device-select.js +5 -2
  4. package/dist/blocks/coding-agent.js +22 -12
  5. package/dist/blocks/design-canvas-inspector.js +6 -3
  6. package/dist/blocks/design-canvas.js +17 -11
  7. package/dist/blocks/discussion-markdown-input.d.ts +3 -1
  8. package/dist/blocks/discussion-markdown-input.js +3 -1
  9. package/dist/blocks/discussion.d.ts +3 -1
  10. package/dist/blocks/discussion.js +9 -4
  11. package/dist/blocks/file-explorer.js +47 -25
  12. package/dist/blocks/settings.js +8 -6
  13. package/dist/chat-composer-editor/extensions/mention.d.ts +1 -1
  14. package/dist/chat-message.d.ts +13 -0
  15. package/dist/chat-message.js +198 -3
  16. package/dist/filter-bar/editor.js +5 -2
  17. package/dist/knob-contracts/flow-knobs.d.ts +4 -0
  18. package/dist/knob-contracts/flow-knobs.js +32 -0
  19. package/dist/knob-contracts/item-knobs.d.ts +1 -1
  20. package/dist/knob-contracts/item-knobs.js +4 -1
  21. package/dist/knob-contracts/markdown-editor-knobs.d.ts +1 -1
  22. package/dist/knob-contracts/markdown-editor-knobs.js +1 -0
  23. package/dist/knob-contracts/morphing-panel-knobs.d.ts +1 -1
  24. package/dist/knob-contracts/morphing-panel-knobs.js +2 -1
  25. package/dist/knob-contracts/resize-handle-knobs.d.ts +4 -0
  26. package/dist/knob-contracts/resize-handle-knobs.js +12 -0
  27. package/dist/knob-contracts/sidebar-knobs.d.ts +1 -1
  28. package/dist/knob-contracts/sidebar-knobs.js +10 -0
  29. package/dist/lib/canvas-grid.d.ts +4 -0
  30. package/dist/lib/canvas-grid.js +5 -0
  31. package/dist/markdown-editor/drag-handle.d.ts +6 -0
  32. package/dist/markdown-editor/drag-handle.js +126 -0
  33. package/dist/markdown-editor/suggestions.d.ts +12 -0
  34. package/dist/markdown-editor/suggestions.js +235 -0
  35. package/dist/markdown-editor/toolbar.js +6 -3
  36. package/dist/markdown-editor.js +14 -4
  37. package/dist/styles/index.css +6 -3
  38. package/dist/styles/recipes/chat-message-edit.css +105 -0
  39. package/dist/styles/recipes/flow.css +306 -0
  40. package/dist/styles/recipes/infinite-canvas.css +1 -1
  41. package/dist/styles/recipes/item.css +39 -2
  42. package/dist/styles/recipes/markdown-editor.css +44 -6
  43. package/dist/styles/recipes/morphing-panel.css +53 -12
  44. package/dist/styles/recipes/page-layout.css +11 -1
  45. package/dist/styles/recipes/resize-handle.css +126 -0
  46. package/dist/styles/recipes/sidebar-mobile.css +171 -0
  47. package/dist/styles/recipes/toolbar.css +8 -1
  48. package/dist/styles/theme.css +1 -0
  49. package/dist/ui/app-shell.js +1 -1
  50. package/dist/ui/color-picker.js +1 -1
  51. package/dist/ui/combobox.d.ts +1 -1
  52. package/dist/ui/command.js +1 -1
  53. package/dist/ui/dockable-panel.js +1 -1
  54. package/dist/ui/flow.d.ts +51 -0
  55. package/dist/ui/flow.js +153 -0
  56. package/dist/ui/infinite-canvas.js +3 -3
  57. package/dist/ui/item.d.ts +5 -3
  58. package/dist/ui/item.js +2 -1
  59. package/dist/ui/morphing-panel.d.ts +21 -4
  60. package/dist/ui/morphing-panel.js +152 -36
  61. package/dist/ui/resize-handle.d.ts +11 -0
  62. package/dist/ui/resize-handle.js +26 -0
  63. package/dist/ui/responsive-dialog.js +1 -1
  64. package/dist/ui/sidebar-menu.js +1 -1
  65. package/dist/ui/sidebar-mobile.d.ts +17 -0
  66. package/dist/ui/sidebar-mobile.js +70 -0
  67. package/dist/ui/sidebar-provider.d.ts +1 -0
  68. package/dist/ui/sidebar-provider.js +3 -0
  69. package/dist/ui/sidebar.d.ts +3 -1
  70. package/dist/ui/sidebar.js +100 -48
  71. package/dist/ui/toolbar.d.ts +3 -1
  72. package/dist/ui/toolbar.js +2 -1
  73. package/dist/ui/typography.d.ts +5 -2
  74. package/dist/ui/typography.js +5 -3
  75. package/package.json +5 -1
  76. package/dist/environment-variables.d.ts +0 -125
  77. package/dist/environment-variables.js +0 -512
  78. package/dist/hooks/use-environment-variables.d.ts +0 -50
  79. package/dist/hooks/use-environment-variables.js +0 -188
  80. package/dist/knob-contracts/environment-variables-knobs.d.ts +0 -4
  81. package/dist/knob-contracts/environment-variables-knobs.js +0 -12
  82. package/dist/lib/env-file.d.ts +0 -27
  83. package/dist/lib/env-file.js +0 -218
  84. package/dist/styles/recipes/environment-variables.css +0 -170
@@ -3,10 +3,12 @@ import { cn } from "../lib/cn.js";
3
3
  import { useSkin } from "../skin-provider.js";
4
4
  import { Button } from "./button.js";
5
5
  import { ScrollArea } from "./scroll-area.js";
6
+ import { Drawer, DrawerBody, DrawerClose, DrawerContent, DrawerFooter, DrawerHeader, DrawerTitle } from "./drawer.js";
6
7
  import { Sheet, SheetContent, SheetHeader, SheetTitle } from "./sheet.js";
7
8
  import { SidebarProvider, SidebarSurfaceContext, useSidebar, useSidebarElements, useSidebarSurface } from "./sidebar-provider.js";
8
9
  import { SidebarResizeRail } from "./sidebar-resize-rail.js";
9
10
  import { SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, sidebarMenuButtonSizes, sidebarMenuButtonVariants } from "./sidebar-menu.js";
11
+ import { SidebarMobileNav, SidebarMobileNavItem, SidebarMobileTrigger } from "./sidebar-mobile.js";
10
12
  import { useState } from "react";
11
13
  import { useRender } from "@base-ui/react/use-render";
12
14
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -34,12 +36,13 @@ function Sidebar({ side = "left", collapsible = "offcanvas", ...props }) {
34
36
  })
35
37
  });
36
38
  }
37
- function SidebarSurface({ variant, label = "Navigation", ref, className, children, style, railContainerRef, ...props }) {
39
+ function SidebarSurface({ variant, mobileVariant = "sheet", label = "Navigation", ref, className, children, style, railContainerRef, ...props }) {
38
40
  const { side, collapsible } = useSidebarSurface();
39
- const { offcanvasRef, triggerRef } = useSidebarElements();
41
+ const { offcanvasRef } = useSidebarElements();
40
42
  const skin = useSkin();
41
- const { isMobile, state, openMobile, setOpenMobile, layout, sidebarId } = useSidebar();
43
+ const { isMobile, state, layout, sidebarId } = useSidebar();
42
44
  const resolvedVariant = variant ?? skin.sidebarLayout ?? "sidebar";
45
+ const padded = resolvedVariant === "floating" || resolvedVariant === "inset";
43
46
  const container = useRender({
44
47
  defaultTagName: "div",
45
48
  ref: collapsible === "offcanvas" ? [ref ?? null, offcanvasRef] : ref,
@@ -50,7 +53,7 @@ function SidebarSurface({ variant, label = "Navigation", ref, className, childre
50
53
  "data-control-family": "sidebar",
51
54
  "data-slot": "container",
52
55
  tabIndex: -1,
53
- className: cn(layout === "contained" ? "absolute h-full" : "fixed h-svh", "inset-y-0 z-10 hidden w-(--sidebar-width) lg:flex", side === "left" ? "start-0" : "end-0", resolvedVariant === "floating" || resolvedVariant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)", className),
56
+ className: cn(layout === "contained" ? "absolute h-full" : "fixed h-svh", "inset-y-0 z-10 hidden w-(--sidebar-width) lg:flex", side === "left" ? "start-0" : "end-0", padded ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)", className),
54
57
  children: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
55
58
  "data-control-ui": "sidebar",
56
59
  "data-control-family": "sidebar",
@@ -64,6 +67,16 @@ function SidebarSurface({ variant, label = "Navigation", ref, className, childre
64
67
  })] })
65
68
  }
66
69
  });
70
+ if (isMobile && (collapsible !== "none" || mobileVariant === "drawer")) return /* @__PURE__ */ jsx(SidebarMobileSurface, {
71
+ ...props,
72
+ ref,
73
+ mobileVariant,
74
+ label,
75
+ variant: resolvedVariant,
76
+ className,
77
+ style,
78
+ children
79
+ });
67
80
  if (collapsible === "none") return /* @__PURE__ */ jsxs("div", {
68
81
  ref,
69
82
  "data-control-ui": "sidebar",
@@ -80,46 +93,6 @@ function SidebarSurface({ variant, label = "Navigation", ref, className, childre
80
93
  className: "contents"
81
94
  })]
82
95
  });
83
- if (isMobile) {
84
- const mobileSheetStyle = {
85
- "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
86
- ...style
87
- };
88
- return /* @__PURE__ */ jsx(Sheet, {
89
- open: openMobile,
90
- onOpenChange: setOpenMobile,
91
- children: /* @__PURE__ */ jsxs(SheetContent, {
92
- side,
93
- finalFocus: triggerRef,
94
- className: "w-(--sidebar-width) gap-0 p-0",
95
- style: mobileSheetStyle,
96
- children: [/* @__PURE__ */ jsx(SheetHeader, {
97
- className: "sr-only",
98
- children: /* @__PURE__ */ jsx(SheetTitle, { children: label })
99
- }), /* @__PURE__ */ jsx("div", {
100
- ref,
101
- id: sidebarId,
102
- "data-control-ui": "sidebar",
103
- "data-control-family": "sidebar",
104
- "data-slot": "root",
105
- "data-surface": "panel",
106
- "data-variant": resolvedVariant,
107
- "data-mobile": "",
108
- "data-side": side,
109
- className: cn("flex min-h-0 flex-1 flex-col", className),
110
- style,
111
- ...props,
112
- children: /* @__PURE__ */ jsx("div", {
113
- "data-control-ui": "sidebar",
114
- "data-control-family": "sidebar",
115
- "data-slot": "inner",
116
- className: "flex min-h-0 flex-1 flex-col",
117
- children
118
- })
119
- })]
120
- })
121
- });
122
- }
123
96
  return /* @__PURE__ */ jsxs("div", {
124
97
  className: cn("group peer hidden lg:block", side === "right" && "order-last"),
125
98
  "data-control-ui": "sidebar",
@@ -135,13 +108,87 @@ function SidebarSurface({ variant, label = "Navigation", ref, className, childre
135
108
  "data-control-ui": "sidebar",
136
109
  "data-control-family": "sidebar",
137
110
  "data-slot": "gap",
138
- className: cn("relative w-(--sidebar-width)", "group-data-[collapsible=offcanvas]:w-0", resolvedVariant === "floating" || resolvedVariant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)")
111
+ className: cn("relative w-(--sidebar-width)", "group-data-[collapsible=offcanvas]:w-0", padded ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)")
139
112
  }), container]
140
113
  });
141
114
  }
115
+ function SidebarMobileSurface({ mobileVariant, label, variant, ref, className, children, style, ...props }) {
116
+ const { side } = useSidebarSurface();
117
+ const { openMobile, setOpenMobile, sidebarId } = useSidebar();
118
+ const { activeTriggerRef, triggerRef, insetRef } = useSidebarElements();
119
+ function finalFocus() {
120
+ const trigger = activeTriggerRef.current ?? triggerRef.current;
121
+ return trigger?.isConnected && trigger.checkVisibility() ? trigger : insetRef.current;
122
+ }
123
+ const mobileContent = /* @__PURE__ */ jsx("div", {
124
+ ref,
125
+ id: sidebarId,
126
+ "data-control-ui": "sidebar",
127
+ "data-control-family": "sidebar",
128
+ "data-slot": "root",
129
+ "data-surface": "panel",
130
+ "data-variant": variant,
131
+ "data-mobile": "",
132
+ "data-side": side,
133
+ className: cn("flex min-h-0 flex-1 flex-col", className),
134
+ style,
135
+ ...props,
136
+ children: /* @__PURE__ */ jsx("div", {
137
+ "data-control-ui": "sidebar",
138
+ "data-control-family": "sidebar",
139
+ "data-slot": "inner",
140
+ className: "flex min-h-0 flex-1 flex-col",
141
+ children
142
+ })
143
+ });
144
+ if (mobileVariant === "drawer") return /* @__PURE__ */ jsx(Drawer, {
145
+ open: openMobile,
146
+ onOpenChange: setOpenMobile,
147
+ children: /* @__PURE__ */ jsxs(DrawerContent, {
148
+ side: "bottom",
149
+ finalFocus,
150
+ className: "max-h-[85dvh]",
151
+ children: [
152
+ /* @__PURE__ */ jsx(DrawerHeader, {
153
+ className: "sr-only",
154
+ children: /* @__PURE__ */ jsx(DrawerTitle, { children: label })
155
+ }),
156
+ /* @__PURE__ */ jsx(DrawerBody, {
157
+ padding: "none",
158
+ children: mobileContent
159
+ }),
160
+ /* @__PURE__ */ jsx(DrawerFooter, { children: /* @__PURE__ */ jsx(DrawerClose, {
161
+ render: /* @__PURE__ */ jsx(Button, {
162
+ variant: "surface",
163
+ size: "lg"
164
+ }),
165
+ children: "Close menu"
166
+ }) })
167
+ ]
168
+ })
169
+ });
170
+ const mobileSheetStyle = {
171
+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
172
+ ...style
173
+ };
174
+ return /* @__PURE__ */ jsx(Sheet, {
175
+ open: openMobile,
176
+ onOpenChange: setOpenMobile,
177
+ children: /* @__PURE__ */ jsxs(SheetContent, {
178
+ side,
179
+ finalFocus,
180
+ className: "w-(--sidebar-width) gap-0 p-0",
181
+ style: mobileSheetStyle,
182
+ children: [/* @__PURE__ */ jsx(SheetHeader, {
183
+ className: "sr-only",
184
+ children: /* @__PURE__ */ jsx(SheetTitle, { children: label })
185
+ }), mobileContent]
186
+ })
187
+ });
188
+ }
142
189
  function SidebarTrigger({ className, onClick, size = "sm", label = "Toggle sidebar", ref, ...props }) {
143
190
  const { toggleSidebar, isMobile, openMobile, open, keyboardShortcut, sidebarId } = useSidebar();
144
- const { triggerRef, railRef } = useSidebarElements();
191
+ const { triggerRef, activeTriggerRef, railRef } = useSidebarElements();
145
192
  const shortcutKey = keyboardShortcut?.toUpperCase();
146
193
  return useRender({
147
194
  defaultTagName: "button",
@@ -162,6 +209,7 @@ function SidebarTrigger({ className, onClick, size = "sm", label = "Toggle sideb
162
209
  onClick: (event) => {
163
210
  onClick?.(event);
164
211
  if (event.defaultPrevented) return;
212
+ activeTriggerRef.current = event.currentTarget;
165
213
  toggleSidebar();
166
214
  if (isMobile || open) return;
167
215
  const trigger = event.currentTarget;
@@ -229,7 +277,7 @@ function SidebarInset({ className, render, ref, ...props }) {
229
277
  "data-control-ui": "sidebar",
230
278
  "data-control-family": "sidebar",
231
279
  "data-slot": "inset",
232
- className: cn("relative flex min-w-0 w-full flex-1 flex-col", className)
280
+ className: cn("relative flex min-h-0 min-w-0 w-full flex-1 flex-col", className)
233
281
  }
234
282
  });
235
283
  }
@@ -252,11 +300,15 @@ function SidebarFooter({ className, ...props }) {
252
300
  });
253
301
  }
254
302
  function SidebarContent({ className, children, ...props }) {
303
+ const { state, isMobile } = useSidebar();
304
+ const { collapsible } = useSidebarSurface();
305
+ const iconOnly = !isMobile && state === "collapsed" && collapsible === "icon";
255
306
  return /* @__PURE__ */ jsx(ScrollArea, {
256
307
  "data-control-ui": "sidebar",
257
308
  "data-slot": "content",
258
309
  className: cn("min-h-0 flex-1 group-data-[collapsible=icon]:overflow-hidden", className),
259
310
  lockAxis: "x",
311
+ scrollbarGutter: iconOnly ? "auto" : void 0,
260
312
  viewportClassName: "overscroll-y-contain",
261
313
  ...props,
262
314
  children: /* @__PURE__ */ jsx("div", {
@@ -269,4 +321,4 @@ function SidebarContent({ className, children, ...props }) {
269
321
  });
270
322
  }
271
323
  //#endregion
272
- export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarProvider, SidebarRail, SidebarTrigger, sidebarMenuButtonSizes, sidebarMenuButtonVariants, useSidebar };
324
+ export { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuAction, SidebarMenuBadge, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMobileNav, SidebarMobileNavItem, SidebarMobileTrigger, SidebarProvider, SidebarRail, SidebarTrigger, sidebarMenuButtonSizes, sidebarMenuButtonVariants, useSidebar };
@@ -3,10 +3,12 @@ import { Toolbar as Toolbar$1 } from "@base-ui/react/toolbar";
3
3
  import { CSSProperties, ComponentProps } from "react";
4
4
  //#region src/ui/toolbar.d.ts
5
5
  export type ToolbarVariant = "default" | "inverse" | "floating";
6
+ export type ToolbarChrome = "standalone" | "embedded";
6
7
  export type ToolbarLinkVariant = "default" | "track";
7
8
  export type ToolbarProps = Omit<ComponentProps<"div">, "style"> & {
8
9
  orientation?: "horizontal" | "vertical";
9
10
  variant?: ToolbarVariant;
11
+ chrome?: ToolbarChrome;
10
12
  style?: CSSProperties & ToolbarKnobStyle;
11
13
  };
12
14
  export type ToolbarButtonProps = Omit<ComponentProps<"button">, "style"> & {
@@ -28,7 +30,7 @@ export type ToolbarSeparatorProps = Omit<ComponentProps<"div">, "style"> & {
28
30
  export type ToolbarInputProps = Omit<ComponentProps<"input">, "style"> & {
29
31
  style?: CSSProperties & ToolbarKnobStyle;
30
32
  };
31
- export declare function Toolbar({ orientation, variant, className, children, ...props }: ToolbarProps): import("react").JSX.Element;
33
+ export declare function Toolbar({ orientation, variant, chrome, className, children, ...props }: ToolbarProps): import("react").JSX.Element;
32
34
  type RefinedToolbarButtonProps = ToolbarButtonProps & Pick<ComponentProps<typeof Toolbar$1.Button>, "render">;
33
35
  export declare function ToolbarButton({ iconOnly, className, ...props }: RefinedToolbarButtonProps): import("react").JSX.Element;
34
36
  type RefinedToolbarLinkProps = ToolbarLinkProps & Pick<ComponentProps<typeof Toolbar$1.Link>, "render">;
@@ -3,13 +3,14 @@ import { cn } from "../lib/cn.js";
3
3
  import { Toolbar as Toolbar$1 } from "@base-ui/react/toolbar";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  //#region src/ui/toolbar.tsx
6
- function Toolbar({ orientation = "horizontal", variant = "default", className, children, ...props }) {
6
+ function Toolbar({ orientation = "horizontal", variant = "default", chrome = "standalone", className, children, ...props }) {
7
7
  return /* @__PURE__ */ jsxs(Toolbar$1.Root, {
8
8
  orientation,
9
9
  "data-control-ui": "toolbar",
10
10
  "data-control-family": "toolbar",
11
11
  "data-slot": "root",
12
12
  "data-variant": variant,
13
+ "data-chrome": chrome,
13
14
  className: cn("group/toolbar inline-flex", orientation === "vertical" ? "flex-col items-stretch" : "items-center", className),
14
15
  ...props,
15
16
  children: [variant === "floating" && /* @__PURE__ */ jsx("div", {
@@ -14,7 +14,9 @@ declare const sizeClassNames: {
14
14
  };
15
15
  declare const toneClassNames: {
16
16
  readonly default: undefined;
17
+ readonly foreground: "text-foreground";
17
18
  readonly muted: "text-muted-foreground";
19
+ readonly primary: "text-primary-text";
18
20
  readonly destructive: "text-destructive-text";
19
21
  };
20
22
  declare const weightClassNames: {
@@ -29,10 +31,11 @@ export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
29
31
  export type HeadingProps = ComponentProps<"h1"> & {
30
32
  level: HeadingLevel;
31
33
  size?: TypeSize;
34
+ weight?: TextWeight;
32
35
  tone?: TypeTone;
33
36
  };
34
- export declare function Heading({ level, size, tone, className, ...props }: HeadingProps): import("react").JSX.Element;
35
- export type TextTag = "p" | "span" | "div" | "small" | "strong" | "em" | "li" | "dt" | "dd" | "figcaption" | "legend" | "blockquote";
37
+ export declare function Heading({ level, size, weight, tone, className, ...props }: HeadingProps): import("react").JSX.Element;
38
+ export type TextTag = "p" | "span" | "div" | "small" | "strong" | "em" | "code" | "li" | "dt" | "dd" | "figcaption" | "legend" | "blockquote";
36
39
  export type TextProps = HTMLAttributes<HTMLElement> & {
37
40
  ref?: Ref<HTMLElement>;
38
41
  as?: TextTag;
@@ -15,7 +15,9 @@ const sizeClassNames = {
15
15
  };
16
16
  const toneClassNames = {
17
17
  default: void 0,
18
+ foreground: "text-foreground",
18
19
  muted: "text-muted-foreground",
20
+ primary: "text-primary-text",
19
21
  destructive: "text-destructive-text"
20
22
  };
21
23
  const weightClassNames = {
@@ -31,13 +33,13 @@ const headingSizeByLevel = {
31
33
  5: "heading-4",
32
34
  6: "heading-4"
33
35
  };
34
- function Heading({ level, size = headingSizeByLevel[level], tone = "default", className, ...props }) {
36
+ function Heading({ level, size = headingSizeByLevel[level], weight, tone = "default", className, ...props }) {
35
37
  const Tag = `h${level}`;
36
38
  return /* @__PURE__ */ jsx(Tag, {
37
39
  "data-control-ui": "typography",
38
40
  "data-control-family": "typography",
39
41
  "data-slot": "heading",
40
- className: cn(sizeClassNames[size], toneClassNames[tone], className),
42
+ className: cn(sizeClassNames[size], weight ? weightClassNames[weight] : void 0, toneClassNames[tone], className),
41
43
  ...props
42
44
  });
43
45
  }
@@ -47,7 +49,7 @@ function attachRef(ref, node) {
47
49
  }
48
50
  function Text({ as: Tag = "span", size = "body", weight, tone = "default", className, ref, ...props }) {
49
51
  return /* @__PURE__ */ jsx(Tag, {
50
- ref: (node) => attachRef(ref, node),
52
+ ref: ref ? (node) => attachRef(ref, node) : void 0,
51
53
  "data-control-ui": "typography",
52
54
  "data-control-family": "typography",
53
55
  "data-slot": "text",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl-ui/react",
3
- "version": "0.8.19",
3
+ "version": "0.8.21",
4
4
  "description": "Control UI components, blocks, and primitives with neutral defaults and consumer-owned themes.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -45,6 +45,7 @@
45
45
  "@tiptap/pm": "3.31.4",
46
46
  "@tiptap/react": "3.31.4",
47
47
  "@tiptap/starter-kit": "3.31.4",
48
+ "@xyflow/react": "^12.12.0",
48
49
  "class-variance-authority": "^0.7.1",
49
50
  "clsx": "^2.1.1",
50
51
  "cmdk": "^1.1.1",
@@ -100,6 +101,9 @@
100
101
  "@tiptap/starter-kit": {
101
102
  "optional": true
102
103
  },
104
+ "@xyflow/react": {
105
+ "optional": true
106
+ },
103
107
  "cmdk": {
104
108
  "optional": true
105
109
  },
@@ -1,125 +0,0 @@
1
- import { Button } from "./ui/button.js";
2
- import { EnvironmentVariableRow, EnvironmentVariablesController, UseEnvironmentVariablesOptions } from "./hooks/use-environment-variables.js";
3
- import { EnvironmentVariablesKnobStyle } from "./knob-contracts/environment-variables-knobs.js";
4
- import { CSSProperties, ComponentProps, ReactNode } from "react";
5
- //#region src/environment-variables.d.ts
6
- export type EnvironmentVariablesRowErrors = Record<number, {
7
- key?: ReactNode;
8
- value?: ReactNode;
9
- }>;
10
- export type EnvironmentVariablesSubmitPayload<TRow extends EnvironmentVariableRow = EnvironmentVariableRow> = {
11
- rows: TRow[];
12
- variables: Record<string, string>;
13
- envFileText: string;
14
- reset: () => void;
15
- };
16
- export type EnvironmentVariablesRootProps<TRow extends EnvironmentVariableRow = EnvironmentVariableRow> = Omit<ComponentProps<"form">, "onSubmit"> & {
17
- editor: EnvironmentVariablesController<TRow>;
18
- disabled?: boolean;
19
- readOnly?: boolean;
20
- rowErrors?: EnvironmentVariablesRowErrors;
21
- keyLabel?: ReactNode;
22
- valueLabel?: ReactNode;
23
- keyPlaceholder?: string;
24
- valuePlaceholder?: string;
25
- duplicateKeyMessage?: ReactNode;
26
- revealValueLabel?: (key: string) => string;
27
- onSubmit?: (payload: EnvironmentVariablesSubmitPayload<TRow>) => void | Promise<void>;
28
- } & {
29
- style?: CSSProperties & EnvironmentVariablesKnobStyle;
30
- };
31
- export declare function EnvironmentVariablesRoot<TRow extends EnvironmentVariableRow = EnvironmentVariableRow>({ editor, disabled, readOnly, rowErrors, keyLabel, valueLabel, keyPlaceholder, valuePlaceholder, duplicateKeyMessage, revealValueLabel, onSubmit, className, children, ...props }: EnvironmentVariablesRootProps<TRow>): import("react").JSX.Element;
32
- export type EnvironmentVariablesProps<TRow extends EnvironmentVariableRow = EnvironmentVariableRow> = Omit<EnvironmentVariablesRootProps<TRow>, "editor"> & UseEnvironmentVariablesOptions<TRow> & {
33
- editor?: EnvironmentVariablesController<TRow>;
34
- title?: ReactNode;
35
- description?: ReactNode;
36
- error?: ReactNode;
37
- submitLabel?: ReactNode;
38
- resetLabel?: ReactNode;
39
- addLabel?: ReactNode;
40
- hideDefaultActions?: boolean;
41
- };
42
- declare function EnvironmentVariablesComponent<TRow extends EnvironmentVariableRow = EnvironmentVariableRow>({ editor: providedEditor, initialRows, rows, onRowsChange, createDefaultRow, createRow, getEditableRows, getPreservedRows, maxUploadSize, title, description, error, submitLabel, resetLabel, addLabel, hideDefaultActions, children, onSubmit, ...props }: EnvironmentVariablesProps<TRow>): import("react").JSX.Element;
43
- export type EnvironmentVariablesHeaderProps = ComponentProps<"div"> & {
44
- title?: ReactNode;
45
- description?: ReactNode;
46
- } & {
47
- style?: CSSProperties & EnvironmentVariablesKnobStyle;
48
- };
49
- export declare function EnvironmentVariablesHeader({ title, description, className, children, ...props }: EnvironmentVariablesHeaderProps): import("react").JSX.Element | null;
50
- export type EnvironmentVariablesToolbarProps = ComponentProps<"div"> & {
51
- style?: CSSProperties & EnvironmentVariablesKnobStyle;
52
- };
53
- export declare function EnvironmentVariablesToolbar({ className, children, ...props }: EnvironmentVariablesToolbarProps): import("react").JSX.Element | null;
54
- export type EnvironmentVariablesUploadButtonProps = ComponentProps<typeof Button> & {
55
- inputLabel?: string;
56
- };
57
- export declare function EnvironmentVariablesUploadButton({ inputLabel, children, variant, size, disabled, onClick, ...props }: EnvironmentVariablesUploadButtonProps): import("react").JSX.Element;
58
- export type EnvironmentVariablesRowsProps = ComponentProps<"div"> & {
59
- rowErrors?: EnvironmentVariablesRowErrors;
60
- } & {
61
- style?: CSSProperties & EnvironmentVariablesKnobStyle;
62
- };
63
- export declare function EnvironmentVariablesRows({ rowErrors, className, children, ...props }: EnvironmentVariablesRowsProps): import("react").JSX.Element;
64
- export type EnvironmentVariablesRowProps = Omit<ComponentProps<"div">, "children"> & {
65
- row: EnvironmentVariableRow;
66
- index: number;
67
- rowErrors?: EnvironmentVariablesRowErrors;
68
- } & {
69
- style?: CSSProperties & EnvironmentVariablesKnobStyle;
70
- };
71
- export declare function EnvironmentVariablesRow({ row, index, rowErrors, className, ...props }: EnvironmentVariablesRowProps): import("react").JSX.Element;
72
- export type EnvironmentVariablesAddButtonProps = ComponentProps<typeof Button>;
73
- export declare function EnvironmentVariablesAddButton({ children, variant, size, disabled, onClick, ...props }: EnvironmentVariablesAddButtonProps): import("react").JSX.Element | null;
74
- export type EnvironmentVariablesResetButtonProps = ComponentProps<typeof Button>;
75
- export declare function EnvironmentVariablesResetButton({ children, variant, size, disabled, onClick, ...props }: EnvironmentVariablesResetButtonProps): import("react").JSX.Element | null;
76
- export type EnvironmentVariablesSubmitButtonProps = ComponentProps<typeof Button>;
77
- export declare function EnvironmentVariablesSubmitButton({ children, variant, tone, size, disabled, ...props }: EnvironmentVariablesSubmitButtonProps): import("react").JSX.Element | null;
78
- export type EnvironmentVariablesActionsProps = ComponentProps<"div"> & {
79
- style?: CSSProperties & EnvironmentVariablesKnobStyle;
80
- };
81
- export declare function EnvironmentVariablesActions({ className, ...props }: EnvironmentVariablesActionsProps): import("react").JSX.Element;
82
- export type EnvironmentVariablesMessageProps = Omit<ComponentProps<"div">, "style"> & {
83
- error?: ReactNode;
84
- style?: CSSProperties & EnvironmentVariablesKnobStyle;
85
- };
86
- export declare function EnvironmentVariablesMessage({ error, className, children, ...props }: EnvironmentVariablesMessageProps): import("react").JSX.Element | null;
87
- export type EnvironmentVariablesDuplicateKeysErrorProps = Omit<EnvironmentVariablesMessageProps, "error"> & {
88
- message?: ReactNode;
89
- };
90
- export declare function EnvironmentVariablesDuplicateKeysError({ message, ...props }: EnvironmentVariablesDuplicateKeysErrorProps): import("react").JSX.Element | null;
91
- export type EnvironmentVariablesUploadErrorProps = Omit<EnvironmentVariablesMessageProps, "error">;
92
- export declare function EnvironmentVariablesUploadError(props: EnvironmentVariablesUploadErrorProps): import("react").JSX.Element;
93
- export type EnvironmentVariablesReadOnlyListProps = ComponentProps<"div"> & {
94
- rows?: readonly EnvironmentVariableRow[];
95
- emptyMessage?: ReactNode;
96
- } & {
97
- style?: CSSProperties & EnvironmentVariablesKnobStyle;
98
- };
99
- export declare function EnvironmentVariablesReadOnlyList({ rows, emptyMessage, className, children, ...props }: EnvironmentVariablesReadOnlyListProps): import("react").JSX.Element;
100
- export type EnvironmentVariablesReadOnlyItemProps = Omit<ComponentProps<"div">, "style"> & {
101
- name: ReactNode;
102
- value?: ReactNode;
103
- revealed?: boolean;
104
- hiddenValueLabel?: string;
105
- style?: CSSProperties & EnvironmentVariablesKnobStyle;
106
- };
107
- export declare function EnvironmentVariablesReadOnlyItem({ name, value, revealed, hiddenValueLabel, className, ...props }: EnvironmentVariablesReadOnlyItemProps): import("react").JSX.Element;
108
- export declare const EnvironmentVariables: typeof EnvironmentVariablesComponent & {
109
- Root: typeof EnvironmentVariablesRoot;
110
- Header: typeof EnvironmentVariablesHeader;
111
- Toolbar: typeof EnvironmentVariablesToolbar;
112
- UploadButton: typeof EnvironmentVariablesUploadButton;
113
- UploadError: typeof EnvironmentVariablesUploadError;
114
- Rows: typeof EnvironmentVariablesRows;
115
- Row: typeof EnvironmentVariablesRow;
116
- AddButton: typeof EnvironmentVariablesAddButton;
117
- ResetButton: typeof EnvironmentVariablesResetButton;
118
- SubmitButton: typeof EnvironmentVariablesSubmitButton;
119
- Actions: typeof EnvironmentVariablesActions;
120
- Message: typeof EnvironmentVariablesMessage;
121
- DuplicateKeysError: typeof EnvironmentVariablesDuplicateKeysError;
122
- ReadOnlyList: typeof EnvironmentVariablesReadOnlyList;
123
- ReadOnlyItem: typeof EnvironmentVariablesReadOnlyItem;
124
- };
125
- //#endregion