@ctrl-ui/react 0.9.12 → 0.9.13

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 (42) hide show
  1. package/README.md +2 -0
  2. package/dist/knob-contracts/field-knobs.d.ts +1 -1
  3. package/dist/knob-contracts/field-knobs.js +1 -0
  4. package/dist/knob-contracts/gradient-editor-knobs.d.ts +1 -1
  5. package/dist/knob-contracts/gradient-editor-knobs.js +1 -4
  6. package/dist/knob-contracts/popup-knobs.d.ts +1 -1
  7. package/dist/knob-contracts/popup-knobs.js +2 -0
  8. package/dist/lib/phone-input-format.js +1 -1
  9. package/dist/styles/recipes/card.css +8 -0
  10. package/dist/styles/recipes/color-picker-values.css +4 -18
  11. package/dist/styles/recipes/color-picker.css +3 -4
  12. package/dist/styles/recipes/field-parts.css +8 -1
  13. package/dist/styles/recipes/gradient-editor.css +3 -47
  14. package/dist/styles/recipes/markdown.css +5 -1
  15. package/dist/styles/recipes/popup-lists.css +17 -0
  16. package/dist/styles/recipes/popup.css +3 -0
  17. package/dist/styles/theme.css +4 -0
  18. package/dist/ui/autocomplete.d.ts +3 -0
  19. package/dist/ui/autocomplete.js +17 -2
  20. package/dist/ui/chart-cartesian.d.ts +60 -57
  21. package/dist/ui/chart-cartesian.js +7 -7
  22. package/dist/ui/chart-colors.d.ts +4 -2
  23. package/dist/ui/chart-colors.js +6 -2
  24. package/dist/ui/chart-marks.d.ts +4 -4
  25. package/dist/ui/chart-marks.js +14 -5
  26. package/dist/ui/chart-series.d.ts +9 -6
  27. package/dist/ui/chart-series.js +3 -2
  28. package/dist/ui/color-picker-swatches.d.ts +4 -3
  29. package/dist/ui/color-picker-swatches.js +7 -8
  30. package/dist/ui/command.d.ts +12 -0
  31. package/dist/ui/command.js +31 -1
  32. package/dist/ui/field.js +1 -1
  33. package/dist/ui/gradient-editor.d.ts +3 -2
  34. package/dist/ui/gradient-editor.js +7 -8
  35. package/dist/ui/markdown-components.d.ts +27 -0
  36. package/dist/ui/markdown-components.js +57 -0
  37. package/dist/ui/markdown-elements.d.ts +6 -25
  38. package/dist/ui/markdown-elements.js +19 -53
  39. package/dist/ui/markdown.d.ts +2 -7
  40. package/dist/ui/markdown.js +3 -20
  41. package/dist/ui/phone-input.js +2 -2
  42. package/package.json +5 -1
@@ -1,3 +1,4 @@
1
+ import { ButtonKnobStyle } from "../knob-contracts/button-knobs.js";
1
2
  import { ColorPickerKnobStyle } from "../knob-contracts/color-picker-knobs.js";
2
3
  import { CSSProperties, ComponentProps, ReactNode } from "react";
3
4
  //#region src/ui/color-picker-swatches.d.ts
@@ -12,12 +13,12 @@ export type ColorPickerSwatchProps = Omit<Omit<ComponentProps<"button">, "color"
12
13
  } & {
13
14
  color: string;
14
15
  };
15
- export type ColorPickerSwatchAddProps = Omit<Omit<ComponentProps<"button">, "onClick">, "style"> & {
16
- style?: CSSProperties & ColorPickerKnobStyle;
16
+ export type ColorPickerSwatchAddProps = Omit<ComponentProps<"button">, "onClick" | "style"> & {
17
+ style?: CSSProperties & ButtonKnobStyle;
17
18
  } & {
18
19
  onAdd?: (value: string) => void;
19
20
  };
20
21
  export declare function ColorPickerSwatches({ colors, label, className, children, ...props }: ColorPickerSwatchesProps): import("react").JSX.Element;
21
22
  export declare function ColorPickerSwatch({ color, className, "aria-label": ariaLabel, ...props }: ColorPickerSwatchProps): import("react").JSX.Element;
22
- export declare function ColorPickerSwatchAdd({ onAdd, className, children, ...props }: ColorPickerSwatchAddProps): import("react").JSX.Element;
23
+ export declare function ColorPickerSwatchAdd({ onAdd, children, ...props }: ColorPickerSwatchAddProps): import("react").JSX.Element;
23
24
  //#endregion
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { cn } from "../lib/cn.js";
3
+ import { Button } from "./button.js";
3
4
  import { formatColor, parseColor } from "../lib/color.js";
4
5
  import { useColorPicker } from "./color-picker-context.js";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -57,17 +58,16 @@ function ColorPickerSwatch({ color, className, "aria-label": ariaLabel, ...props
57
58
  })]
58
59
  });
59
60
  }
60
- function ColorPickerSwatchAdd({ onAdd, className, children, ...props }) {
61
+ function ColorPickerSwatchAdd({ onAdd, children, ...props }) {
61
62
  const { valueString, disabled } = useColorPicker();
62
- return /* @__PURE__ */ jsx("button", {
63
- type: "button",
64
- "data-control-ui": "color-picker",
65
- "data-control-family": "color-picker",
66
- "data-slot": "swatch-add",
63
+ return /* @__PURE__ */ jsx(Button, {
64
+ variant: "dashed",
65
+ size: "xs",
66
+ iconOnly: true,
67
+ "data-color-picker-swatch-add": "true",
67
68
  "aria-label": "Add current color",
68
69
  disabled,
69
70
  onClick: () => onAdd?.(valueString),
70
- className: cn("relative flex shrink-0 cursor-pointer items-center justify-center disabled:cursor-not-allowed", className),
71
71
  ...props,
72
72
  children: children ?? /* @__PURE__ */ jsx(PlusIcon, {})
73
73
  });
@@ -81,7 +81,6 @@ function sameColor(a, b) {
81
81
  function PlusIcon() {
82
82
  return /* @__PURE__ */ jsx("svg", {
83
83
  viewBox: "0 0 16 16",
84
- className: "size-3.5",
85
84
  fill: "none",
86
85
  stroke: "currentColor",
87
86
  strokeWidth: "1.5",
@@ -46,6 +46,18 @@ export type CommandItemProps = Omit<ComponentProps<typeof Command$1.Item>, "styl
46
46
  style?: CSSProperties & PopupKnobStyle;
47
47
  };
48
48
  export declare function CommandItem({ className, disabled, onSelect, ...props }: CommandItemProps): import("react").JSX.Element;
49
+ export type CommandItemContentProps = Omit<ComponentProps<"div">, "style"> & {
50
+ style?: CSSProperties & PopupKnobStyle;
51
+ };
52
+ export declare function CommandItemContent({ className, ...props }: CommandItemContentProps): import("react").JSX.Element;
53
+ export type CommandItemTitleProps = Omit<ComponentProps<"span">, "style"> & {
54
+ style?: CSSProperties & PopupKnobStyle;
55
+ };
56
+ export declare function CommandItemTitle({ className, ...props }: CommandItemTitleProps): import("react").JSX.Element;
57
+ export type CommandItemDescriptionProps = Omit<ComponentProps<"span">, "style"> & {
58
+ style?: CSSProperties & PopupKnobStyle;
59
+ };
60
+ export declare function CommandItemDescription({ className, ...props }: CommandItemDescriptionProps): import("react").JSX.Element;
49
61
  export type CommandShortcutProps = Omit<ComponentProps<"span">, "style"> & {
50
62
  style?: CSSProperties & PopupKnobStyle;
51
63
  };
@@ -225,6 +225,36 @@ function CommandItem({ className, disabled, onSelect, ...props }) {
225
225
  onSelect: handleSelect
226
226
  });
227
227
  }
228
+ function CommandItemContent({ className, ...props }) {
229
+ return /* @__PURE__ */ jsx("div", {
230
+ "data-control-ui": "command",
231
+ "data-popup-kind": "command",
232
+ "data-control-family": "popup",
233
+ "data-slot": "item-content",
234
+ className: cn("flex min-w-0 flex-1 flex-col", className),
235
+ ...props
236
+ });
237
+ }
238
+ function CommandItemTitle({ className, ...props }) {
239
+ return /* @__PURE__ */ jsx("span", {
240
+ "data-control-ui": "command",
241
+ "data-popup-kind": "command",
242
+ "data-control-family": "popup",
243
+ "data-slot": "item-title",
244
+ className: cn("truncate", className),
245
+ ...props
246
+ });
247
+ }
248
+ function CommandItemDescription({ className, ...props }) {
249
+ return /* @__PURE__ */ jsx("span", {
250
+ "data-control-ui": "command",
251
+ "data-popup-kind": "command",
252
+ "data-control-family": "popup",
253
+ "data-slot": "item-description",
254
+ className: cn("truncate", className),
255
+ ...props
256
+ });
257
+ }
228
258
  function CommandShortcut({ className, ...props }) {
229
259
  return /* @__PURE__ */ jsx("span", {
230
260
  "data-control-ui": "command",
@@ -238,4 +268,4 @@ function CommandShortcut({ className, ...props }) {
238
268
  });
239
269
  }
240
270
  //#endregion
241
- export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandLoading, CommandSeparator, CommandShortcut };
271
+ export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandItemContent, CommandItemDescription, CommandItemTitle, CommandList, CommandLoading, CommandSeparator, CommandShortcut };
package/dist/ui/field.js CHANGED
@@ -53,7 +53,7 @@ function FieldLabel({ className, variant = "default", ...props }) {
53
53
  "data-slot": "label",
54
54
  "data-variant": variant,
55
55
  "data-focus-ring": variant === "card" ? "within" : void 0,
56
- className: cn(variant === "card" && "flex w-full cursor-pointer items-start gap-3 has-[[data-disabled]]:cursor-not-allowed [&>[data-control-family=choice]]:mt-[calc((1lh_-_var(--spacing)*4)/2)]", className),
56
+ className: cn(variant === "card" && "flex w-full cursor-pointer items-start gap-3 self-stretch has-[[data-disabled]]:cursor-not-allowed [&>[data-control-family=choice]]:mt-[calc((1lh_-_var(--spacing)*4)/2)]", className),
57
57
  ...props
58
58
  });
59
59
  }
@@ -1,3 +1,4 @@
1
+ import { ButtonKnobStyle } from "../knob-contracts/button-knobs.js";
1
2
  import { GradientEditorKnobStyle } from "../knob-contracts/gradient-editor-knobs.js";
2
3
  import { GradientInterpolation, GradientStop, GradientType, GradientValue } from "../lib/gradient.js";
3
4
  import { CSSProperties, ComponentProps, RefObject } from "react";
@@ -20,7 +21,7 @@ export type GradientEditorStopProps = Omit<ComponentProps<"button">, "style"> &
20
21
  style?: CSSProperties & GradientEditorKnobStyle;
21
22
  };
22
23
  export type GradientEditorStopAddProps = Omit<ComponentProps<"button">, "onClick" | "style"> & {
23
- style?: CSSProperties & GradientEditorKnobStyle;
24
+ style?: CSSProperties & ButtonKnobStyle;
24
25
  };
25
26
  type GradientEditorContextValue = GradientValue & {
26
27
  gradient: string;
@@ -42,6 +43,6 @@ export declare function GradientEditor({ value: controlledValue, defaultValue, o
42
43
  export declare function GradientEditorPreview({ className, style, "aria-label": ariaLabel, ...props }: GradientEditorPreviewProps): import("react").JSX.Element;
43
44
  export declare function GradientEditorTrack({ className, children, style, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }: GradientEditorTrackProps): import("react").JSX.Element;
44
45
  export declare function GradientEditorStop({ stop, className, style, onPointerDown, onKeyDown, onFocus, onDoubleClick, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ref, ...props }: GradientEditorStopProps): import("react").JSX.Element;
45
- export declare function GradientEditorStopAdd({ className, children, ...props }: GradientEditorStopAddProps): import("react").JSX.Element;
46
+ export declare function GradientEditorStopAdd({ children, ...props }: GradientEditorStopAddProps): import("react").JSX.Element;
46
47
  //#endregion
47
48
  export type { GradientInterpolation, GradientStop, GradientType, GradientValue };
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { cn } from "../lib/cn.js";
3
+ import { Button } from "./button.js";
3
4
  import { useColorArea } from "../hooks/use-color-area.js";
4
5
  import { formatGradient, gradientColorAt } from "../lib/gradient.js";
5
6
  import { createContext, useContext, useRef, useState } from "react";
@@ -244,20 +245,18 @@ function GradientEditorStop({ stop, className, style, onPointerDown, onKeyDown,
244
245
  ...props
245
246
  });
246
247
  }
247
- function GradientEditorStopAdd({ className, children, ...props }) {
248
+ function GradientEditorStopAdd({ children, ...props }) {
248
249
  const { addStop } = useGradientEditor();
249
- return /* @__PURE__ */ jsx("button", {
250
- type: "button",
251
- "data-control-ui": "gradient-editor",
252
- "data-control-family": "gradient-editor",
253
- "data-slot": "stop-add",
250
+ return /* @__PURE__ */ jsx(Button, {
251
+ variant: "dashed",
252
+ size: "xs",
253
+ iconOnly: true,
254
+ "data-gradient-editor-stop-add": "true",
254
255
  "aria-label": "Add gradient stop",
255
256
  onClick: () => addStop(.5),
256
- className: cn("flex shrink-0 cursor-pointer items-center justify-center", className),
257
257
  ...props,
258
258
  children: children ?? /* @__PURE__ */ jsx("svg", {
259
259
  viewBox: "0 0 16 16",
260
- className: "size-3.5",
261
260
  fill: "none",
262
261
  stroke: "currentColor",
263
262
  strokeWidth: "1.5",
@@ -0,0 +1,27 @@
1
+ import { MarkdownA, MarkdownBlockquote, MarkdownCodeProps, MarkdownEm, MarkdownH1, MarkdownH2, MarkdownH3, MarkdownH4, MarkdownH5, MarkdownH6, MarkdownHr, MarkdownInlineCode, MarkdownInput, MarkdownLi, MarkdownOl, MarkdownP, MarkdownStrong, MarkdownTable, MarkdownTd, MarkdownTh, MarkdownUl } from "./markdown-elements.js";
2
+ //#region src/ui/markdown-components.d.ts
3
+ export declare function MarkdownCode({ className, children, node: _node, ...props }: MarkdownCodeProps): import("react").JSX.Element;
4
+ export declare const markdownComponents: {
5
+ input: typeof MarkdownInput;
6
+ code: typeof MarkdownCode;
7
+ inlineCode: typeof MarkdownInlineCode;
8
+ h1: typeof MarkdownH1;
9
+ h2: typeof MarkdownH2;
10
+ h3: typeof MarkdownH3;
11
+ h4: typeof MarkdownH4;
12
+ h5: typeof MarkdownH5;
13
+ h6: typeof MarkdownH6;
14
+ p: typeof MarkdownP;
15
+ ul: typeof MarkdownUl;
16
+ ol: typeof MarkdownOl;
17
+ li: typeof MarkdownLi;
18
+ a: typeof MarkdownA;
19
+ blockquote: typeof MarkdownBlockquote;
20
+ hr: typeof MarkdownHr;
21
+ strong: typeof MarkdownStrong;
22
+ em: typeof MarkdownEm;
23
+ table: typeof MarkdownTable;
24
+ th: typeof MarkdownTh;
25
+ td: typeof MarkdownTd;
26
+ };
27
+ //#endregion
@@ -0,0 +1,57 @@
1
+ "use client";
2
+ import { Code, CodeActions, CodeContent, CodeCopy, CodeHeader, CodeTitle } from "./code.js";
3
+ import { CodeDiff } from "./code-diff.js";
4
+ import { MarkdownA, MarkdownBlockquote, MarkdownEm, MarkdownH1, MarkdownH2, MarkdownH3, MarkdownH4, MarkdownH5, MarkdownH6, MarkdownHr, MarkdownInlineCode, MarkdownInput, MarkdownLi, MarkdownOl, MarkdownP, MarkdownStrong, MarkdownTable, MarkdownTd, MarkdownTh, MarkdownUl } from "./markdown-elements.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ //#region src/ui/markdown-components.tsx
7
+ function textValue(children) {
8
+ return Array.isArray(children) ? children.join("") : String(children ?? "");
9
+ }
10
+ function languageFromClassName(className) {
11
+ return /language-([\w-]+)/.exec(className ?? "")?.[1];
12
+ }
13
+ function MarkdownCode({ className, children, node: _node, ...props }) {
14
+ const lang = languageFromClassName(className);
15
+ const rawValue = textValue(children);
16
+ if (!lang && !rawValue.includes("\n")) return /* @__PURE__ */ jsx(MarkdownInlineCode, {
17
+ className,
18
+ ...props,
19
+ children
20
+ });
21
+ const value = rawValue.replace(/^\n/, "").replace(/\n$/, "");
22
+ if (lang === "diff" && value.includes("@@")) return /* @__PURE__ */ jsx(CodeDiff, {
23
+ patch: value,
24
+ lang: "diff",
25
+ diffStyle: "unified"
26
+ });
27
+ return /* @__PURE__ */ jsxs(Code, { children: [/* @__PURE__ */ jsxs(CodeHeader, { children: [lang ? /* @__PURE__ */ jsx(CodeTitle, { children: lang }) : null, /* @__PURE__ */ jsx(CodeActions, { children: /* @__PURE__ */ jsx(CodeCopy, { value }) })] }), /* @__PURE__ */ jsx(CodeContent, {
28
+ code: value,
29
+ lang,
30
+ highlight: lang ? "auto" : "none"
31
+ })] });
32
+ }
33
+ const markdownComponents = {
34
+ input: MarkdownInput,
35
+ code: MarkdownCode,
36
+ inlineCode: MarkdownInlineCode,
37
+ h1: MarkdownH1,
38
+ h2: MarkdownH2,
39
+ h3: MarkdownH3,
40
+ h4: MarkdownH4,
41
+ h5: MarkdownH5,
42
+ h6: MarkdownH6,
43
+ p: MarkdownP,
44
+ ul: MarkdownUl,
45
+ ol: MarkdownOl,
46
+ li: MarkdownLi,
47
+ a: MarkdownA,
48
+ blockquote: MarkdownBlockquote,
49
+ hr: MarkdownHr,
50
+ strong: MarkdownStrong,
51
+ em: MarkdownEm,
52
+ table: MarkdownTable,
53
+ th: MarkdownTh,
54
+ td: MarkdownTd
55
+ };
56
+ //#endregion
57
+ export { MarkdownCode, markdownComponents };
@@ -1,7 +1,7 @@
1
1
  import { MarkdownKnobStyle } from "../knob-contracts/markdown-knobs.js";
2
2
  import { CSSProperties, ComponentProps, JSX } from "react";
3
3
  //#region src/ui/markdown-elements.d.ts
4
- type MarkdownCodeProps = ComponentProps<"code"> & {
4
+ export type MarkdownCodeProps = ComponentProps<"code"> & {
5
5
  node?: unknown;
6
6
  } & {
7
7
  style?: CSSProperties & MarkdownKnobStyle;
@@ -11,10 +11,14 @@ type MarkdownElementProps<Tag extends keyof JSX.IntrinsicElements> = ComponentPr
11
11
  } & {
12
12
  style?: CSSProperties & MarkdownKnobStyle;
13
13
  };
14
+ export type MarkdownRootProps = Omit<ComponentProps<"div">, "style"> & {
15
+ style?: CSSProperties & MarkdownKnobStyle;
16
+ };
17
+ export declare function MarkdownRoot({ className, ...props }: MarkdownRootProps): JSX.Element;
18
+ export declare function MarkdownFlow(props: MarkdownRootProps): JSX.Element;
14
19
  export declare function MarkdownInput({ type, checked, className, node: _node, ...props }: MarkdownElementProps<"input">): JSX.Element;
15
20
  export declare function MarkdownInlineCode({ className, children, node: _node, ...props }: MarkdownCodeProps): JSX.Element;
16
21
  export declare function MarkdownPre({ children, node: _node }: MarkdownElementProps<"pre">): JSX.Element;
17
- export declare function MarkdownCode({ className, children, node: _node, ...props }: MarkdownCodeProps): JSX.Element;
18
22
  export declare function MarkdownH1({ className, node: _node, ...props }: MarkdownElementProps<"h1">): JSX.Element;
19
23
  export declare function MarkdownH2({ className, node: _node, ...props }: MarkdownElementProps<"h2">): JSX.Element;
20
24
  export declare function MarkdownH3({ className, node: _node, ...props }: MarkdownElementProps<"h3">): JSX.Element;
@@ -33,27 +37,4 @@ export declare function MarkdownEm({ className, node: _node, ...props }: Markdow
33
37
  export declare function MarkdownTable({ className, children, node: _node, ...props }: MarkdownElementProps<"table">): JSX.Element;
34
38
  export declare function MarkdownTh({ className, node: _node, ...props }: MarkdownElementProps<"th">): JSX.Element;
35
39
  export declare function MarkdownTd({ className, node: _node, ...props }: MarkdownElementProps<"td">): JSX.Element;
36
- export declare const markdownComponents: {
37
- input: typeof MarkdownInput;
38
- code: typeof MarkdownCode;
39
- inlineCode: typeof MarkdownInlineCode;
40
- h1: typeof MarkdownH1;
41
- h2: typeof MarkdownH2;
42
- h3: typeof MarkdownH3;
43
- h4: typeof MarkdownH4;
44
- h5: typeof MarkdownH5;
45
- h6: typeof MarkdownH6;
46
- p: typeof MarkdownP;
47
- ul: typeof MarkdownUl;
48
- ol: typeof MarkdownOl;
49
- li: typeof MarkdownLi;
50
- a: typeof MarkdownA;
51
- blockquote: typeof MarkdownBlockquote;
52
- hr: typeof MarkdownHr;
53
- strong: typeof MarkdownStrong;
54
- em: typeof MarkdownEm;
55
- table: typeof MarkdownTable;
56
- th: typeof MarkdownTh;
57
- td: typeof MarkdownTd;
58
- };
59
40
  //#endregion
@@ -2,13 +2,28 @@
2
2
  import { cn } from "../lib/cn.js";
3
3
  import { ScrollArea } from "./scroll-area.js";
4
4
  import { Heading } from "./typography.js";
5
- import { Code, CodeActions, CodeContent, CodeCopy, CodeHeader, CodeTitle } from "./code.js";
6
5
  import { Checkbox } from "./checkbox.js";
7
- import { CodeDiff } from "./code-diff.js";
8
6
  import { markdownHeadingAttributes } from "./markdown-heading.js";
9
7
  import { createContext, use, useId } from "react";
10
- import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
+ import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
11
9
  //#region src/ui/markdown-elements.tsx
10
+ function MarkdownRoot({ className, ...props }) {
11
+ return /* @__PURE__ */ jsx("div", {
12
+ "data-control-ui": "markdown",
13
+ "data-control-family": "markdown",
14
+ "data-slot": "root",
15
+ className: cn("[&>*:first-child]:mt-0 [&>*:last-child]:mb-0", className),
16
+ ...props
17
+ });
18
+ }
19
+ function MarkdownFlow(props) {
20
+ return /* @__PURE__ */ jsx("div", {
21
+ "data-control-ui": "markdown",
22
+ "data-control-family": "markdown",
23
+ "data-slot": "flow",
24
+ ...props
25
+ });
26
+ }
12
27
  const MarkdownTaskLabelContext = createContext(void 0);
13
28
  function MarkdownInput({ type, checked, className, node: _node, ...props }) {
14
29
  const labelId = use(MarkdownTaskLabelContext);
@@ -26,12 +41,6 @@ function MarkdownInput({ type, checked, className, node: _node, ...props }) {
26
41
  "aria-labelledby": labelId
27
42
  });
28
43
  }
29
- function textValue(children) {
30
- return Array.isArray(children) ? children.join("") : String(children ?? "");
31
- }
32
- function languageFromClassName(className) {
33
- return /language-([\w-]+)/.exec(className ?? "")?.[1];
34
- }
35
44
  function MarkdownInlineCode({ className, children, node: _node, ...props }) {
36
45
  return /* @__PURE__ */ jsx("code", {
37
46
  "data-control-ui": "markdown",
@@ -45,26 +54,6 @@ function MarkdownInlineCode({ className, children, node: _node, ...props }) {
45
54
  function MarkdownPre({ children, node: _node }) {
46
55
  return /* @__PURE__ */ jsx(Fragment$1, { children });
47
56
  }
48
- function MarkdownCode({ className, children, node: _node, ...props }) {
49
- const lang = languageFromClassName(className);
50
- const rawValue = textValue(children);
51
- if (!lang && !rawValue.includes("\n")) return /* @__PURE__ */ jsx(MarkdownInlineCode, {
52
- className,
53
- ...props,
54
- children
55
- });
56
- const value = rawValue.replace(/^\n/, "").replace(/\n$/, "");
57
- if (lang === "diff" && value.includes("@@")) return /* @__PURE__ */ jsx(CodeDiff, {
58
- patch: value,
59
- lang: "diff",
60
- diffStyle: "unified"
61
- });
62
- return /* @__PURE__ */ jsxs(Code, { children: [/* @__PURE__ */ jsxs(CodeHeader, { children: [lang ? /* @__PURE__ */ jsx(CodeTitle, { children: lang }) : null, /* @__PURE__ */ jsx(CodeActions, { children: /* @__PURE__ */ jsx(CodeCopy, { value }) })] }), /* @__PURE__ */ jsx(CodeContent, {
63
- code: value,
64
- lang,
65
- highlight: lang ? "auto" : "none"
66
- })] });
67
- }
68
57
  function MarkdownH1({ className, node: _node, ...props }) {
69
58
  const { class: headingClass } = markdownHeadingAttributes(1);
70
59
  return /* @__PURE__ */ jsx(Heading, {
@@ -253,28 +242,5 @@ function MarkdownTd({ className, node: _node, ...props }) {
253
242
  ...props
254
243
  });
255
244
  }
256
- const markdownComponents = {
257
- input: MarkdownInput,
258
- code: MarkdownCode,
259
- inlineCode: MarkdownInlineCode,
260
- h1: MarkdownH1,
261
- h2: MarkdownH2,
262
- h3: MarkdownH3,
263
- h4: MarkdownH4,
264
- h5: MarkdownH5,
265
- h6: MarkdownH6,
266
- p: MarkdownP,
267
- ul: MarkdownUl,
268
- ol: MarkdownOl,
269
- li: MarkdownLi,
270
- a: MarkdownA,
271
- blockquote: MarkdownBlockquote,
272
- hr: MarkdownHr,
273
- strong: MarkdownStrong,
274
- em: MarkdownEm,
275
- table: MarkdownTable,
276
- th: MarkdownTh,
277
- td: MarkdownTd
278
- };
279
245
  //#endregion
280
- export { MarkdownA, MarkdownBlockquote, MarkdownCode, MarkdownEm, MarkdownH1, MarkdownH2, MarkdownH3, MarkdownH4, MarkdownH5, MarkdownH6, MarkdownHr, MarkdownInlineCode, MarkdownInput, MarkdownLi, MarkdownOl, MarkdownP, MarkdownPre, MarkdownStrong, MarkdownTable, MarkdownTd, MarkdownTh, MarkdownUl, markdownComponents };
246
+ export { MarkdownA, MarkdownBlockquote, MarkdownEm, MarkdownFlow, MarkdownH1, MarkdownH2, MarkdownH3, MarkdownH4, MarkdownH5, MarkdownH6, MarkdownHr, MarkdownInlineCode, MarkdownInput, MarkdownLi, MarkdownOl, MarkdownP, MarkdownPre, MarkdownRoot, MarkdownStrong, MarkdownTable, MarkdownTd, MarkdownTh, MarkdownUl };
@@ -1,15 +1,10 @@
1
- import { MarkdownKnobStyle } from "../knob-contracts/markdown-knobs.js";
2
- import { CSSProperties, ComponentProps } from "react";
1
+ import { MarkdownRootProps } from "./markdown-elements.js";
2
+ import { ComponentProps } from "react";
3
3
  //#region src/ui/markdown.d.ts
4
- export type MarkdownRootProps = Omit<ComponentProps<"div">, "style"> & {
5
- style?: CSSProperties & MarkdownKnobStyle;
6
- };
7
4
  export type MarkdownProps = Omit<MarkdownRootProps, "children"> & {
8
5
  content: string;
9
6
  mode?: "streaming" | "static";
10
7
  };
11
- export declare function MarkdownRoot({ className, ...props }: MarkdownRootProps): import("react").JSX.Element;
12
- export declare function MarkdownFlow(props: MarkdownRootProps): import("react").JSX.Element;
13
8
  export declare function Markdown({ content, mode, className, ...props }: MarkdownProps): import("react").JSX.Element;
14
9
  export type MarkdownComponentProps = ComponentProps<typeof Markdown>;
15
10
  //#endregion
@@ -1,26 +1,9 @@
1
1
  "use client";
2
- import { cn } from "../lib/cn.js";
3
- import { markdownComponents } from "./markdown-elements.js";
2
+ import { MarkdownFlow, MarkdownRoot } from "./markdown-elements.js";
3
+ import { markdownComponents } from "./markdown-components.js";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  import { Streamdown } from "streamdown";
6
6
  //#region src/ui/markdown.tsx
7
- function MarkdownRoot({ className, ...props }) {
8
- return /* @__PURE__ */ jsx("div", {
9
- "data-control-ui": "markdown",
10
- "data-control-family": "markdown",
11
- "data-slot": "root",
12
- className: cn("[&>*:first-child]:mt-0 [&>*:last-child]:mb-0", className),
13
- ...props
14
- });
15
- }
16
- function MarkdownFlow(props) {
17
- return /* @__PURE__ */ jsx("div", {
18
- "data-control-ui": "markdown",
19
- "data-control-family": "markdown",
20
- "data-slot": "flow",
21
- ...props
22
- });
23
- }
24
7
  function Markdown({ content, mode = "streaming", className, ...props }) {
25
8
  return /* @__PURE__ */ jsx(MarkdownRoot, {
26
9
  className,
@@ -36,4 +19,4 @@ function Markdown({ content, mode = "streaming", className, ...props }) {
36
19
  });
37
20
  }
38
21
  //#endregion
39
- export { Markdown, MarkdownFlow, MarkdownRoot };
22
+ export { Markdown };
@@ -3,12 +3,12 @@ import { cn } from "../lib/cn.js";
3
3
  import { Popover, PopoverContent, PopoverTrigger } from "./popover.js";
4
4
  import { InputGroup, InputGroupAddon } from "./input-group.js";
5
5
  import { Input } from "./input.js";
6
- import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "./command.js";
7
6
  import { normalizePhoneInputText, normalizePhoneInputValue } from "../lib/phone-input-format.js";
7
+ import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "./command.js";
8
8
  import { useState } from "react";
9
9
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
- import flags from "react-phone-number-input/flags";
11
10
  import PhoneNumberInput, { getCountryCallingCode, parsePhoneNumber } from "react-phone-number-input/max";
11
+ import flags from "react-phone-number-input/flags";
12
12
  //#region src/ui/phone-input.tsx
13
13
  const FLAG_COMPONENTS = flags;
14
14
  const PhoneNumberInputWithRef = PhoneNumberInput;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl-ui/react",
3
- "version": "0.9.12",
3
+ "version": "0.9.13",
4
4
  "description": "100+ React components for Tailwind CSS and shadcn/ui: pickers, trees, editors, canvases, app templates, and AI chat surfaces, with neutral defaults and consumer-owned themes.",
5
5
  "keywords": [
6
6
  "react",
@@ -61,6 +61,7 @@
61
61
  },
62
62
  "peerDependencies": {
63
63
  "@base-ui/react": "^1.9.0",
64
+ "@biomejs/biome": ">=2.4.11",
64
65
  "@tanstack/charts": "^1.1.0",
65
66
  "@tanstack/react-virtual": "^3.14.13",
66
67
  "@tiptap/core": "3.31.4",
@@ -98,6 +99,9 @@
98
99
  "zod": "^4.6.5"
99
100
  },
100
101
  "peerDependenciesMeta": {
102
+ "@biomejs/biome": {
103
+ "optional": true
104
+ },
101
105
  "@tanstack/charts": {
102
106
  "optional": true
103
107
  },