@ctrl-ui/react 0.8.18 → 0.8.19

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 (50) hide show
  1. package/dist/blocks/coding-agent.js +1 -1
  2. package/dist/blocks/design-canvas-inspector.js +1 -1
  3. package/dist/blocks/design-canvas.js +9 -5
  4. package/dist/blocks/discussion-markdown-input.d.ts +12 -0
  5. package/dist/blocks/discussion-markdown-input.js +34 -0
  6. package/dist/blocks/discussion.d.ts +7 -3
  7. package/dist/blocks/discussion.js +77 -16
  8. package/dist/blocks/file-explorer.js +4 -4
  9. package/dist/blocks/settings.js +5 -3
  10. package/dist/knob-contracts/label-knobs.d.ts +4 -0
  11. package/dist/knob-contracts/label-knobs.js +4 -0
  12. package/dist/knob-contracts/markdown-editor-knobs.d.ts +4 -0
  13. package/dist/knob-contracts/markdown-editor-knobs.js +16 -0
  14. package/dist/knob-contracts/switch-knobs.d.ts +1 -1
  15. package/dist/knob-contracts/switch-knobs.js +1 -0
  16. package/dist/markdown-editor/context.d.ts +22 -0
  17. package/dist/markdown-editor/context.js +10 -0
  18. package/dist/markdown-editor/extensions.d.ts +10 -0
  19. package/dist/markdown-editor/extensions.js +139 -0
  20. package/dist/markdown-editor/toolbar.d.ts +9 -0
  21. package/dist/markdown-editor/toolbar.js +336 -0
  22. package/dist/markdown-editor/uploads.d.ts +23 -0
  23. package/dist/markdown-editor/uploads.js +32 -0
  24. package/dist/markdown-editor/use-image-uploads.d.ts +12 -0
  25. package/dist/markdown-editor/use-image-uploads.js +120 -0
  26. package/dist/markdown-editor.d.ts +27 -0
  27. package/dist/markdown-editor.js +192 -0
  28. package/dist/styles/index.css +4 -2
  29. package/dist/styles/recipes/code.css +4 -0
  30. package/dist/styles/recipes/field.css +1 -1
  31. package/dist/styles/recipes/label.css +19 -0
  32. package/dist/styles/recipes/markdown-editor.css +196 -0
  33. package/dist/styles/recipes/switch.css +17 -5
  34. package/dist/ui/app-shell.js +1 -1
  35. package/dist/ui/autocomplete.js +1 -1
  36. package/dist/ui/code.js +1 -0
  37. package/dist/ui/combobox.js +1 -1
  38. package/dist/ui/command.js +1 -1
  39. package/dist/ui/dockable-panel.js +1 -1
  40. package/dist/ui/label.d.ts +8 -0
  41. package/dist/ui/label.js +14 -0
  42. package/dist/ui/markdown.d.ts +2 -1
  43. package/dist/ui/markdown.js +3 -3
  44. package/dist/ui/responsive-dialog.js +1 -1
  45. package/dist/ui/sidebar-menu.js +1 -1
  46. package/dist/ui/sidebar.js +1 -1
  47. package/dist/ui/typography.d.ts +44 -0
  48. package/dist/ui/typography.js +59 -0
  49. package/dist/ui/use-switch-drag.js +1 -1
  50. package/package.json +37 -1
@@ -0,0 +1,44 @@
1
+ import { ComponentProps, HTMLAttributes, Ref } from "react";
2
+ //#region src/ui/typography.d.ts
3
+ declare const sizeClassNames: {
4
+ readonly display: "text-display";
5
+ readonly "heading-1": "text-heading-1";
6
+ readonly "heading-2": "text-heading-2";
7
+ readonly "heading-3": "text-heading-3";
8
+ readonly "heading-4": "text-heading-4";
9
+ readonly "body-lg": "text-body-lg";
10
+ readonly body: "text-body";
11
+ readonly label: "text-label";
12
+ readonly caption: "text-caption";
13
+ readonly micro: "text-micro";
14
+ };
15
+ declare const toneClassNames: {
16
+ readonly default: undefined;
17
+ readonly muted: "text-muted-foreground";
18
+ readonly destructive: "text-destructive-text";
19
+ };
20
+ declare const weightClassNames: {
21
+ readonly normal: "font-normal";
22
+ readonly medium: "font-medium";
23
+ readonly semibold: "font-semibold";
24
+ };
25
+ export type TypeSize = keyof typeof sizeClassNames;
26
+ export type TypeTone = keyof typeof toneClassNames;
27
+ export type TextWeight = keyof typeof weightClassNames;
28
+ export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
29
+ export type HeadingProps = ComponentProps<"h1"> & {
30
+ level: HeadingLevel;
31
+ size?: TypeSize;
32
+ tone?: TypeTone;
33
+ };
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";
36
+ export type TextProps = HTMLAttributes<HTMLElement> & {
37
+ ref?: Ref<HTMLElement>;
38
+ as?: TextTag;
39
+ size?: TypeSize;
40
+ weight?: TextWeight;
41
+ tone?: TypeTone;
42
+ };
43
+ export declare function Text({ as: Tag, size, weight, tone, className, ref, ...props }: TextProps): import("react").JSX.Element;
44
+ //#endregion
@@ -0,0 +1,59 @@
1
+ import { cn } from "../lib/cn.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ //#region src/ui/typography.tsx
4
+ const sizeClassNames = {
5
+ display: "text-display",
6
+ "heading-1": "text-heading-1",
7
+ "heading-2": "text-heading-2",
8
+ "heading-3": "text-heading-3",
9
+ "heading-4": "text-heading-4",
10
+ "body-lg": "text-body-lg",
11
+ body: "text-body",
12
+ label: "text-label",
13
+ caption: "text-caption",
14
+ micro: "text-micro"
15
+ };
16
+ const toneClassNames = {
17
+ default: void 0,
18
+ muted: "text-muted-foreground",
19
+ destructive: "text-destructive-text"
20
+ };
21
+ const weightClassNames = {
22
+ normal: "font-normal",
23
+ medium: "font-medium",
24
+ semibold: "font-semibold"
25
+ };
26
+ const headingSizeByLevel = {
27
+ 1: "heading-1",
28
+ 2: "heading-2",
29
+ 3: "heading-3",
30
+ 4: "heading-4",
31
+ 5: "heading-4",
32
+ 6: "heading-4"
33
+ };
34
+ function Heading({ level, size = headingSizeByLevel[level], tone = "default", className, ...props }) {
35
+ const Tag = `h${level}`;
36
+ return /* @__PURE__ */ jsx(Tag, {
37
+ "data-control-ui": "typography",
38
+ "data-control-family": "typography",
39
+ "data-slot": "heading",
40
+ className: cn(sizeClassNames[size], toneClassNames[tone], className),
41
+ ...props
42
+ });
43
+ }
44
+ function attachRef(ref, node) {
45
+ if (typeof ref === "function") return ref(node);
46
+ if (ref) ref.current = node;
47
+ }
48
+ function Text({ as: Tag = "span", size = "body", weight, tone = "default", className, ref, ...props }) {
49
+ return /* @__PURE__ */ jsx(Tag, {
50
+ ref: (node) => attachRef(ref, node),
51
+ "data-control-ui": "typography",
52
+ "data-control-family": "typography",
53
+ "data-slot": "text",
54
+ className: cn(sizeClassNames[size], weight ? weightClassNames[weight] : void 0, toneClassNames[tone], className),
55
+ ...props
56
+ });
57
+ }
58
+ //#endregion
59
+ export { Heading, Text };
@@ -25,7 +25,7 @@ function useSwitchDrag() {
25
25
  if (!(event.isPrimary && event.button === 0 && !isSwitchLocked(root)) || !thumbRef.current) return;
26
26
  setDragProgress(null);
27
27
  const styles = getComputedStyle(root);
28
- const travel = root.clientWidth - Number.parseFloat(styles.paddingLeft) - Number.parseFloat(styles.paddingRight) - thumbRef.current.offsetWidth;
28
+ const travel = root.clientWidth - Number.parseFloat(styles.paddingLeft) - Number.parseFloat(styles.paddingRight) - Number.parseFloat(styles.getPropertyValue("--cui-switch-thumb-inline-size"));
29
29
  if (travel <= 0) return;
30
30
  const progress = root.hasAttribute("data-checked") ? 1 : 0;
31
31
  gestureRef.current = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctrl-ui/react",
3
- "version": "0.8.18",
3
+ "version": "0.8.19",
4
4
  "description": "Control UI components, blocks, and primitives with neutral defaults and consumer-owned themes.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -36,6 +36,15 @@
36
36
  "peerDependencies": {
37
37
  "@base-ui/react": "^1.8.0",
38
38
  "@tanstack/react-virtual": "^3.14.13",
39
+ "@tiptap/core": "3.31.4",
40
+ "@tiptap/extension-image": "3.31.4",
41
+ "@tiptap/extension-list": "3.31.4",
42
+ "@tiptap/extension-paragraph": "3.31.4",
43
+ "@tiptap/extension-table": "3.31.4",
44
+ "@tiptap/markdown": "3.31.4",
45
+ "@tiptap/pm": "3.31.4",
46
+ "@tiptap/react": "3.31.4",
47
+ "@tiptap/starter-kit": "3.31.4",
39
48
  "class-variance-authority": "^0.7.1",
40
49
  "clsx": "^2.1.1",
41
50
  "cmdk": "^1.1.1",
@@ -64,6 +73,33 @@
64
73
  "@tanstack/react-virtual": {
65
74
  "optional": true
66
75
  },
76
+ "@tiptap/core": {
77
+ "optional": true
78
+ },
79
+ "@tiptap/extension-image": {
80
+ "optional": true
81
+ },
82
+ "@tiptap/extension-list": {
83
+ "optional": true
84
+ },
85
+ "@tiptap/extension-paragraph": {
86
+ "optional": true
87
+ },
88
+ "@tiptap/extension-table": {
89
+ "optional": true
90
+ },
91
+ "@tiptap/markdown": {
92
+ "optional": true
93
+ },
94
+ "@tiptap/pm": {
95
+ "optional": true
96
+ },
97
+ "@tiptap/react": {
98
+ "optional": true
99
+ },
100
+ "@tiptap/starter-kit": {
101
+ "optional": true
102
+ },
67
103
  "cmdk": {
68
104
  "optional": true
69
105
  },