@hex-core/components 1.4.0 → 1.6.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.
Files changed (127) hide show
  1. package/dist/_tsup-dts-rollup.d.ts +3556 -0
  2. package/dist/accordion.d.ts +4 -13
  3. package/dist/alert-dialog.d.ts +11 -34
  4. package/dist/alert.d.ts +4 -17
  5. package/dist/aspect-ratio.d.ts +1 -7
  6. package/dist/attachment.d.ts +4 -0
  7. package/dist/attachment.js +157 -0
  8. package/dist/attachment.js.map +1 -0
  9. package/dist/avatar.d.ts +3 -11
  10. package/dist/badge.d.ts +3 -22
  11. package/dist/breadcrumb.d.ts +7 -27
  12. package/dist/button.d.ts +3 -13
  13. package/dist/calendar.d.ts +1 -17
  14. package/dist/card.d.ts +6 -16
  15. package/dist/checkbox.d.ts +2 -11
  16. package/dist/citation.d.ts +2 -0
  17. package/dist/citation.js +70 -0
  18. package/dist/citation.js.map +1 -0
  19. package/dist/cluster.d.ts +3 -34
  20. package/dist/code-block-copy.d.ts +2 -0
  21. package/dist/code-block-copy.js +108 -0
  22. package/dist/code-block-copy.js.map +1 -0
  23. package/dist/code-block.d.ts +3 -0
  24. package/dist/code-block.js +90 -0
  25. package/dist/code-block.js.map +1 -0
  26. package/dist/collapsible.d.ts +3 -11
  27. package/dist/color-picker.d.ts +2 -44
  28. package/dist/combobox.d.ts +3 -45
  29. package/dist/command.d.ts +9 -111
  30. package/dist/composer.d.ts +2 -0
  31. package/dist/composer.js +75 -0
  32. package/dist/composer.js.map +1 -0
  33. package/dist/container.d.ts +3 -41
  34. package/dist/context-menu.d.ts +12 -37
  35. package/dist/data-table.d.ts +2 -33
  36. package/dist/date-picker.d.ts +2 -43
  37. package/dist/dialog.d.ts +11 -46
  38. package/dist/drawer.d.ts +10 -41
  39. package/dist/dropdown-menu.d.ts +13 -39
  40. package/dist/dropzone.d.ts +3 -54
  41. package/dist/dropzone.js +46 -44
  42. package/dist/dropzone.js.map +1 -1
  43. package/dist/empty.d.ts +3 -0
  44. package/dist/empty.js +94 -0
  45. package/dist/empty.js.map +1 -0
  46. package/dist/error-state.d.ts +3 -0
  47. package/dist/error-state.js +67 -0
  48. package/dist/error-state.js.map +1 -0
  49. package/dist/file-tree.d.ts +3 -53
  50. package/dist/form.d.ts +8 -45
  51. package/dist/grid.d.ts +3 -50
  52. package/dist/hover-card.d.ts +3 -11
  53. package/dist/index.d.ts +325 -179
  54. package/dist/index.js +1592 -122
  55. package/dist/index.js.map +1 -1
  56. package/dist/input-otp.d.ts +5 -19
  57. package/dist/input.d.ts +2 -6
  58. package/dist/label.d.ts +2 -11
  59. package/dist/loading-indicator.d.ts +3 -0
  60. package/dist/loading-indicator.js +64 -0
  61. package/dist/loading-indicator.js.map +1 -0
  62. package/dist/loading.d.ts +3 -0
  63. package/dist/loading.js +80 -0
  64. package/dist/loading.js.map +1 -0
  65. package/dist/markdown.d.ts +2 -0
  66. package/dist/markdown.js +28 -0
  67. package/dist/markdown.js.map +1 -0
  68. package/dist/menubar.d.ts +11 -35
  69. package/dist/message-actions.d.ts +2 -0
  70. package/dist/message-actions.js +28 -0
  71. package/dist/message-actions.js.map +1 -0
  72. package/dist/message-list.d.ts +2 -0
  73. package/dist/message-list.js +49 -0
  74. package/dist/message-list.js.map +1 -0
  75. package/dist/message.d.ts +3 -0
  76. package/dist/message.js +35 -0
  77. package/dist/message.js.map +1 -0
  78. package/dist/multi-combobox.d.ts +3 -51
  79. package/dist/navigation-menu.d.ts +9 -23
  80. package/dist/pagination.d.ts +7 -40
  81. package/dist/popover.d.ts +4 -13
  82. package/dist/progress.d.ts +1 -10
  83. package/dist/radio-group.d.ts +2 -9
  84. package/dist/reasoning.d.ts +2 -0
  85. package/dist/reasoning.js +90 -0
  86. package/dist/reasoning.js.map +1 -0
  87. package/dist/resizable.d.ts +3 -28
  88. package/dist/schemas.d.ts +79 -121
  89. package/dist/schemas.js +1649 -1
  90. package/dist/schemas.js.map +1 -1
  91. package/dist/scroll-area.d.ts +3 -18
  92. package/dist/select.d.ts +8 -21
  93. package/dist/separator.d.ts +2 -11
  94. package/dist/sheet.d.ts +10 -39
  95. package/dist/sidebar.d.ts +8 -75
  96. package/dist/skeleton.d.ts +1 -11
  97. package/dist/slider.d.ts +2 -20
  98. package/dist/sonner.d.ts +2 -14
  99. package/dist/spacer.d.ts +3 -38
  100. package/dist/stack.d.ts +3 -34
  101. package/dist/stepper.d.ts +4 -48
  102. package/dist/suggestion.d.ts +2 -0
  103. package/dist/suggestion.js +55 -0
  104. package/dist/suggestion.js.map +1 -0
  105. package/dist/switch.d.ts +2 -11
  106. package/dist/table.d.ts +8 -24
  107. package/dist/tabs.d.ts +4 -13
  108. package/dist/tag.d.ts +3 -0
  109. package/dist/tag.js +107 -0
  110. package/dist/tag.js.map +1 -0
  111. package/dist/textarea.d.ts +2 -10
  112. package/dist/time-picker.d.ts +2 -34
  113. package/dist/timeline.d.ts +4 -42
  114. package/dist/toggle-group.d.ts +2 -17
  115. package/dist/toggle.d.ts +2 -19
  116. package/dist/tool-call.d.ts +2 -0
  117. package/dist/tool-call.js +133 -0
  118. package/dist/tool-call.js.map +1 -0
  119. package/dist/toolbar.d.ts +8 -0
  120. package/dist/toolbar.js +120 -0
  121. package/dist/toolbar.js.map +1 -0
  122. package/dist/tooltip.d.ts +4 -13
  123. package/dist/tree.d.ts +3 -0
  124. package/dist/tree.js +275 -0
  125. package/dist/tree.js.map +1 -0
  126. package/package.json +5 -1
  127. package/dist/button-variants-Bx6gCUFp.d.ts +0 -19
@@ -0,0 +1,108 @@
1
+ "use client";
2
+ import * as React from 'react';
3
+ import { clsx } from 'clsx';
4
+ import { twMerge } from 'tailwind-merge';
5
+ import { jsx, jsxs } from 'react/jsx-runtime';
6
+
7
+ function cn(...inputs) {
8
+ return twMerge(clsx(inputs));
9
+ }
10
+ var RESET_DELAY_MS = 1500;
11
+ function CodeBlockCopy({ code, className, ...props }) {
12
+ const [state, setState] = React.useState("idle");
13
+ React.useEffect(() => {
14
+ if (state === "idle") return;
15
+ const id = window.setTimeout(() => setState("idle"), RESET_DELAY_MS);
16
+ return () => window.clearTimeout(id);
17
+ }, [state]);
18
+ async function handleClick() {
19
+ try {
20
+ await navigator.clipboard.writeText(code);
21
+ setState("copied");
22
+ } catch {
23
+ setState("error");
24
+ }
25
+ }
26
+ const ariaLabel = state === "copied" ? "Copied" : state === "error" ? "Copy failed" : "Copy code";
27
+ return /* @__PURE__ */ jsx(
28
+ "button",
29
+ {
30
+ type: "button",
31
+ onClick: handleClick,
32
+ "aria-label": ariaLabel,
33
+ title: ariaLabel,
34
+ className: cn(
35
+ "inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground",
36
+ "transition-all duration-[var(--duration-normal,200ms)] ease-out",
37
+ "hover:bg-foreground/10 hover:text-foreground",
38
+ "focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
39
+ className
40
+ ),
41
+ ...props,
42
+ children: state === "copied" ? /* @__PURE__ */ jsx(CheckGlyph, {}) : state === "error" ? /* @__PURE__ */ jsx(ErrorGlyph, {}) : /* @__PURE__ */ jsx(CopyGlyph, {})
43
+ }
44
+ );
45
+ }
46
+ function CopyGlyph() {
47
+ return /* @__PURE__ */ jsxs(
48
+ "svg",
49
+ {
50
+ "aria-hidden": true,
51
+ viewBox: "0 0 16 16",
52
+ width: "13",
53
+ height: "13",
54
+ fill: "none",
55
+ stroke: "currentColor",
56
+ strokeWidth: "1.5",
57
+ strokeLinecap: "round",
58
+ strokeLinejoin: "round",
59
+ children: [
60
+ /* @__PURE__ */ jsx("rect", { x: "5", y: "5", width: "9", height: "9", rx: "1.5" }),
61
+ /* @__PURE__ */ jsx("path", { d: "M11 5V3.5A1.5 1.5 0 0 0 9.5 2h-6A1.5 1.5 0 0 0 2 3.5v6A1.5 1.5 0 0 0 3.5 11H5" })
62
+ ]
63
+ }
64
+ );
65
+ }
66
+ function CheckGlyph() {
67
+ return /* @__PURE__ */ jsx(
68
+ "svg",
69
+ {
70
+ "aria-hidden": true,
71
+ viewBox: "0 0 16 16",
72
+ width: "13",
73
+ height: "13",
74
+ fill: "none",
75
+ stroke: "currentColor",
76
+ strokeWidth: "1.5",
77
+ strokeLinecap: "round",
78
+ strokeLinejoin: "round",
79
+ className: "text-emerald-500",
80
+ children: /* @__PURE__ */ jsx("path", { d: "M3 8l3.5 3.5L13 5" })
81
+ }
82
+ );
83
+ }
84
+ function ErrorGlyph() {
85
+ return /* @__PURE__ */ jsxs(
86
+ "svg",
87
+ {
88
+ "aria-hidden": true,
89
+ viewBox: "0 0 16 16",
90
+ width: "13",
91
+ height: "13",
92
+ fill: "none",
93
+ stroke: "currentColor",
94
+ strokeWidth: "1.5",
95
+ strokeLinecap: "round",
96
+ strokeLinejoin: "round",
97
+ className: "text-destructive",
98
+ children: [
99
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6.5" }),
100
+ /* @__PURE__ */ jsx("path", { d: "M8 5v3.5M8 11v.01" })
101
+ ]
102
+ }
103
+ );
104
+ }
105
+
106
+ export { CodeBlockCopy };
107
+ //# sourceMappingURL=code-block-copy.js.map
108
+ //# sourceMappingURL=code-block-copy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/utils.ts","../src/ai/code-block/code-block-copy.tsx"],"names":[],"mappings":";;;;;AAQO,SAAS,MAAM,MAAA,EAAsB;AAC3C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC5B;ACLA,IAAM,cAAA,GAAiB,IAAA;AAyBvB,SAAS,cAAc,EAAE,IAAA,EAAM,SAAA,EAAW,GAAG,OAAM,EAAuB;AACzE,EAAA,MAAM,CAAC,KAAA,EAAO,QAAQ,CAAA,GAAU,eAAoB,MAAM,CAAA;AAE1D,EAAM,gBAAU,MAAM;AACrB,IAAA,IAAI,UAAU,MAAA,EAAQ;AACtB,IAAA,MAAM,KAAK,MAAA,CAAO,UAAA,CAAW,MAAM,QAAA,CAA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,EAAU,kBAAA;AAAA,MAEV,QAAA,EAAA;AAAA,wBAAA,GAAA,CAAC,YAAO,EAAA,EAAG,GAAA,EAAI,EAAA,EAAG,GAAA,EAAI,GAAE,KAAA,EAAM,CAAA;AAAA,wBAC9B,GAAA,CAAC,MAAA,EAAA,EAAK,CAAA,EAAE,mBAAA,EAAoB;AAAA;AAAA;AAAA,GAC7B;AAEF","file":"code-block-copy.js","sourcesContent":["import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merge class names with Tailwind CSS conflict resolution.\n * @param inputs - Class values (strings, arrays, objects) to merge\n * @returns A single merged class string with Tailwind conflicts resolved\n */\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\nconst RESET_DELAY_MS = 1500;\n\n/**\n * Copy-to-clipboard button for the `CodeBlock` header. Lives in a\n * client-only file so the surrounding `CodeBlock` (an async Server\n * Component) can render server-side while this island hydrates on the\n * client for `navigator.clipboard` access.\n *\n * @example\n * <CodeBlockCopy code={code} />\n */\nexport interface CodeBlockCopyProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {\n\t/** The code text to copy. Must be plain text (not the highlighted HTML). */\n\tcode: string;\n}\n\n/**\n * Renders the copy button. Switches to a check icon for ~1.5s after a\n * successful copy.\n *\n * @param props - the raw code string\n * @returns A button that copies on click\n */\ntype CopyState = \"idle\" | \"copied\" | \"error\";\n\nfunction CodeBlockCopy({ code, className, ...props }: CodeBlockCopyProps) {\n\tconst [state, setState] = React.useState<CopyState>(\"idle\");\n\n\tReact.useEffect(() => {\n\t\tif (state === \"idle\") return;\n\t\tconst id = window.setTimeout(() => setState(\"idle\"), RESET_DELAY_MS);\n\t\treturn () => window.clearTimeout(id);\n\t}, [state]);\n\n\tasync function handleClick() {\n\t\ttry {\n\t\t\tawait navigator.clipboard.writeText(code);\n\t\t\tsetState(\"copied\");\n\t\t} catch {\n\t\t\tsetState(\"error\");\n\t\t}\n\t}\n\n\tconst ariaLabel =\n\t\tstate === \"copied\" ? \"Copied\" : state === \"error\" ? \"Copy failed\" : \"Copy code\";\n\n\treturn (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tonClick={handleClick}\n\t\t\taria-label={ariaLabel}\n\t\t\ttitle={ariaLabel}\n\t\t\tclassName={cn(\n\t\t\t\t\"inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground\",\n\t\t\t\t\"transition-all duration-[var(--duration-normal,200ms)] ease-out\",\n\t\t\t\t\"hover:bg-foreground/10 hover:text-foreground\",\n\t\t\t\t\"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t{state === \"copied\" ? <CheckGlyph /> : state === \"error\" ? <ErrorGlyph /> : <CopyGlyph />}\n\t\t</button>\n\t);\n}\n\nfunction CopyGlyph() {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\twidth=\"13\"\n\t\t\theight=\"13\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"1.5\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t>\n\t\t\t<rect x=\"5\" y=\"5\" width=\"9\" height=\"9\" rx=\"1.5\" />\n\t\t\t<path d=\"M11 5V3.5A1.5 1.5 0 0 0 9.5 2h-6A1.5 1.5 0 0 0 2 3.5v6A1.5 1.5 0 0 0 3.5 11H5\" />\n\t\t</svg>\n\t);\n}\n\nfunction CheckGlyph() {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\twidth=\"13\"\n\t\t\theight=\"13\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"1.5\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t\tclassName=\"text-emerald-500\"\n\t\t>\n\t\t\t<path d=\"M3 8l3.5 3.5L13 5\" />\n\t\t</svg>\n\t);\n}\n\nfunction ErrorGlyph() {\n\treturn (\n\t\t<svg\n\t\t\taria-hidden\n\t\t\tviewBox=\"0 0 16 16\"\n\t\t\twidth=\"13\"\n\t\t\theight=\"13\"\n\t\t\tfill=\"none\"\n\t\t\tstroke=\"currentColor\"\n\t\t\tstrokeWidth=\"1.5\"\n\t\t\tstrokeLinecap=\"round\"\n\t\t\tstrokeLinejoin=\"round\"\n\t\t\tclassName=\"text-destructive\"\n\t\t>\n\t\t\t<circle cx=\"8\" cy=\"8\" r=\"6.5\" />\n\t\t\t<path d=\"M8 5v3.5M8 11v.01\" />\n\t\t</svg>\n\t);\n}\n\nexport { CodeBlockCopy };\n"]}
@@ -0,0 +1,3 @@
1
+ export { SupportedLang_alias_1 as SupportedLang } from './_tsup-dts-rollup.js';
2
+ export { CodeBlockProps_alias_1 as CodeBlockProps } from './_tsup-dts-rollup.js';
3
+ export { CodeBlock_alias_1 as CodeBlock } from './_tsup-dts-rollup.js';
@@ -0,0 +1,90 @@
1
+ import { cache } from 'react';
2
+ import { codeToHtml } from 'shiki';
3
+ import { clsx } from 'clsx';
4
+ import { twMerge } from 'tailwind-merge';
5
+ import { CodeBlockCopy } from './code-block-copy.js';
6
+ import { jsxs, jsx } from 'react/jsx-runtime';
7
+
8
+ // src/ai/code-block/code-block.tsx
9
+ function cn(...inputs) {
10
+ return twMerge(clsx(inputs));
11
+ }
12
+ var LABEL_TO_LANG = {
13
+ pnpm: "bash",
14
+ npm: "bash",
15
+ yarn: "bash",
16
+ bun: "bash",
17
+ bash: "bash",
18
+ sh: "bash",
19
+ shell: "bash",
20
+ zsh: "bash",
21
+ ts: "ts",
22
+ typescript: "ts",
23
+ tsx: "tsx",
24
+ js: "js",
25
+ javascript: "js",
26
+ jsx: "jsx",
27
+ json: "json",
28
+ css: "css",
29
+ html: "html",
30
+ md: "md",
31
+ markdown: "md",
32
+ py: "py",
33
+ python: "py",
34
+ text: "text",
35
+ prompt: "text",
36
+ plain: "text"
37
+ };
38
+ var DEFAULT_THEMES = { light: "github-light-high-contrast", dark: "github-dark" };
39
+ var cachedCodeToHtml = cache(
40
+ async (code, lang, themesKey, themes) => {
41
+ return codeToHtml(code, { lang, themes, defaultColor: false });
42
+ }
43
+ );
44
+ function resolveLang(label, language) {
45
+ if (language) return language;
46
+ if (label) {
47
+ const fromLabel = LABEL_TO_LANG[label.toLowerCase()];
48
+ if (fromLabel) return fromLabel;
49
+ }
50
+ return "text";
51
+ }
52
+ async function CodeBlock({
53
+ code,
54
+ label,
55
+ language,
56
+ themes = DEFAULT_THEMES,
57
+ className
58
+ }) {
59
+ const lang = resolveLang(label, language);
60
+ const themesKey = `${themes.light}|${themes.dark}`;
61
+ const html = await cachedCodeToHtml(code, lang, themesKey, themes);
62
+ const displayLabel = label ?? lang;
63
+ return /* @__PURE__ */ jsxs(
64
+ "div",
65
+ {
66
+ className: cn(
67
+ "group relative overflow-hidden rounded-lg border bg-card text-card-foreground",
68
+ className
69
+ ),
70
+ children: [
71
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b bg-muted/40 px-3 py-1.5", children: [
72
+ /* @__PURE__ */ jsx("span", { className: "font-mono text-xs font-medium text-muted-foreground", children: displayLabel }),
73
+ /* @__PURE__ */ jsx(CodeBlockCopy, { code })
74
+ ] }),
75
+ /* @__PURE__ */ jsx(
76
+ "div",
77
+ {
78
+ "data-shiki": "",
79
+ className: "overflow-x-auto p-4 font-mono text-sm [&_pre]:!bg-transparent",
80
+ dangerouslySetInnerHTML: { __html: html }
81
+ }
82
+ )
83
+ ]
84
+ }
85
+ );
86
+ }
87
+
88
+ export { CodeBlock };
89
+ //# sourceMappingURL=code-block.js.map
90
+ //# sourceMappingURL=code-block.js.map
@@ -0,0 +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AA;AAAA,GACD;AAEF","file":"code-block.js","sourcesContent":["import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merge class names with Tailwind CSS conflict resolution.\n * @param inputs - Class values (strings, arrays, objects) to merge\n * @returns A single merged class string with Tailwind conflicts resolved\n */\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","import * as React from \"react\";\nimport { cache } from \"react\";\nimport { codeToHtml } from \"shiki\";\nimport { cn } from \"../../lib/utils.js\";\nimport { CodeBlockCopy } from \"./code-block-copy.js\";\n\n/**\n * Languages we surface in the prop type. Plain literal union of real\n * Shiki grammar IDs — kept literal (not `Extract<BundledLanguage, …>`)\n * because Shiki's full bundled-language union is 600+ literals, and\n * deriving from it forced the rollup-dts pass past a 4GB heap. The\n * literals here are all standard Shiki grammar IDs; if Shiki removes\n * one upstream, `codeToHtml` will throw at runtime — acceptable trade.\n */\nexport type SupportedLang =\n\t| \"bash\"\n\t| \"ts\"\n\t| \"tsx\"\n\t| \"js\"\n\t| \"jsx\"\n\t| \"json\"\n\t| \"css\"\n\t| \"html\"\n\t| \"md\"\n\t| \"py\"\n\t| \"text\";\n\nconst LABEL_TO_LANG: Record<string, SupportedLang> = {\n\tpnpm: \"bash\",\n\tnpm: \"bash\",\n\tyarn: \"bash\",\n\tbun: \"bash\",\n\tbash: \"bash\",\n\tsh: \"bash\",\n\tshell: \"bash\",\n\tzsh: \"bash\",\n\tts: \"ts\",\n\ttypescript: \"ts\",\n\ttsx: \"tsx\",\n\tjs: \"js\",\n\tjavascript: \"js\",\n\tjsx: \"jsx\",\n\tjson: \"json\",\n\tcss: \"css\",\n\thtml: \"html\",\n\tmd: \"md\",\n\tmarkdown: \"md\",\n\tpy: \"py\",\n\tpython: \"py\",\n\ttext: \"text\",\n\tprompt: \"text\",\n\tplain: \"text\",\n};\n\nconst DEFAULT_THEMES = { light: \"github-light-high-contrast\", dark: \"github-dark\" } as const;\n\n/**\n * Per-render-tree memoization of `codeToHtml`. React's `cache()` dedupes\n * identical (code, lang, theme) combos within a single RSC render pass —\n * useful when a page renders many copies of the same install snippet.\n * Shiki itself caches grammars/themes per process, so this layer only\n * eliminates duplicate parse + tokenize work within one request.\n */\nconst cachedCodeToHtml = cache(\n\tasync (code: string, lang: SupportedLang, themesKey: string, themes: { light: string; dark: string }) => {\n\t\tvoid themesKey;\n\t\treturn codeToHtml(code, { lang, themes, defaultColor: false });\n\t},\n);\n\nfunction resolveLang(label?: string, language?: SupportedLang): SupportedLang {\n\tif (language) return language;\n\tif (label) {\n\t\tconst fromLabel = LABEL_TO_LANG[label.toLowerCase()];\n\t\tif (fromLabel) return fromLabel;\n\t}\n\treturn \"text\";\n}\n\n/**\n * Syntax-highlighted code block with a language-label header and a copy\n * button. Highlighting runs server-side via Shiki using a dual-theme\n * (default: github-light / github-dark) so the same HTML flips on\n * `data-theme`/`prefers-color-scheme` without client-side rehydration.\n *\n * Async Server Component — render inside RSC trees or pre-render in\n * static contexts. For client-side streaming code blocks, plug Streamdown's\n * built-in code rendering via `Markdown components={{ pre: … }}` instead.\n *\n * @example\n * <CodeBlock label=\"pnpm\" code=\"pnpm add @hex-core/components\" />\n * @example\n * <CodeBlock language=\"tsx\" code={src} />\n */\nexport interface CodeBlockProps {\n\tcode: string;\n\t/** Optional header label (e.g. \"pnpm\", \"tsx\"). Inferred from `language` if omitted. */\n\tlabel?: string;\n\t/** Explicit Shiki grammar key. Overrides inference from `label`. */\n\tlanguage?: SupportedLang;\n\t/** Override the default github-light / github-dark theme pair. */\n\tthemes?: { light: string; dark: string };\n\tclassName?: string;\n}\n\n/**\n * Async Server Component that highlights `code` server-side and emits the\n * resulting HTML with a header + copy island.\n *\n * @param props - code, optional label/language/themes\n * @returns A bordered card wrapping the highlighted code\n */\nasync function CodeBlock({\n\tcode,\n\tlabel,\n\tlanguage,\n\tthemes = DEFAULT_THEMES,\n\tclassName,\n}: CodeBlockProps) {\n\tconst lang = resolveLang(label, language);\n\tconst themesKey = `${themes.light}|${themes.dark}`;\n\tconst html = await cachedCodeToHtml(code, lang, themesKey, themes);\n\tconst displayLabel = label ?? lang;\n\n\treturn (\n\t\t<div\n\t\t\tclassName={cn(\n\t\t\t\t\"group relative overflow-hidden rounded-lg border bg-card text-card-foreground\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t<div className=\"flex items-center justify-between border-b bg-muted/40 px-3 py-1.5\">\n\t\t\t\t<span className=\"font-mono text-xs font-medium text-muted-foreground\">{displayLabel}</span>\n\t\t\t\t<CodeBlockCopy code={code} />\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tdata-shiki=\"\"\n\t\t\t\tclassName=\"overflow-x-auto p-4 font-mono text-sm [&_pre]:!bg-transparent\"\n\t\t\t\t// biome-ignore lint/security/noDangerouslySetInnerHtml: Shiki output is trusted server-rendered HTML\n\t\t\t\tdangerouslySetInnerHTML={{ __html: html }}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n\nexport { CodeBlock };\n"]}
@@ -1,11 +1,3 @@
1
- import * as React from 'react';
2
- import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
3
-
4
- /** Root container controlling the expanded state of the content. */
5
- declare const Collapsible: React.ForwardRefExoticComponent<CollapsiblePrimitive.CollapsibleProps & React.RefAttributes<HTMLDivElement>>;
6
- /** The element that toggles the Collapsible open/closed. */
7
- declare const CollapsibleTrigger: React.ForwardRefExoticComponent<CollapsiblePrimitive.CollapsibleTriggerProps & React.RefAttributes<HTMLButtonElement>>;
8
- /** The collapsible content shown/hidden by the trigger. */
9
- declare const CollapsibleContent: React.ForwardRefExoticComponent<CollapsiblePrimitive.CollapsibleContentProps & React.RefAttributes<HTMLDivElement>>;
10
-
11
- export { Collapsible, CollapsibleContent, CollapsibleTrigger };
1
+ export { Collapsible_alias_1 as Collapsible } from './_tsup-dts-rollup.js';
2
+ export { CollapsibleTrigger_alias_1 as CollapsibleTrigger } from './_tsup-dts-rollup.js';
3
+ export { CollapsibleContent_alias_1 as CollapsibleContent } from './_tsup-dts-rollup.js';
@@ -1,44 +1,2 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
-
3
- /** Props for the ColorPicker component. */
4
- interface ColorPickerProps {
5
- /**
6
- * Current color as an HSL triplet string (`"<H> <S>% <L>%"`, e.g. `"240 5.9% 10%"`).
7
- * Match the format used by `@hex-core/tokens`; round-trip safe.
8
- */
9
- value: string;
10
- /**
11
- * Called with the next HSL triplet whenever the user drags a slider or commits a valid hex value.
12
- * Not called for invalid hex input — the picker keeps the prior value until the input parses cleanly.
13
- */
14
- onChange: (value: string) => void;
15
- /**
16
- * Disable interaction. Native `disabled` attribute is set on the trigger so the
17
- * popover doesn't open via mouse or keyboard activation. Tab focus still lands
18
- * on the trigger per browser defaults; if you want to fully remove it from the
19
- * tab order, wrap in a parent that handles `tabIndex` accordingly.
20
- */
21
- disabled?: boolean;
22
- /** Accessible name for the trigger button (defaults to "Pick color"). */
23
- "aria-label"?: string;
24
- /** Additional class names merged onto the trigger. */
25
- className?: string;
26
- }
27
- /**
28
- * HSL-native color picker. Edits an HSL triplet directly via three sliders
29
- * (H/S/L), with a hex input as a display adapter.
30
- *
31
- * Round-trip safe: triplet → hex → triplet preserves the slider state because
32
- * sliders are the source of truth and hex updates them only when valid.
33
- *
34
- * @param props - Controlled component; `value` and `onChange` are required.
35
- * @returns A trigger button that opens a popover with H/S/L sliders + hex input.
36
- * @example
37
- * ```tsx
38
- * const [color, setColor] = React.useState("240 5.9% 10%");
39
- * <ColorPicker value={color} onChange={setColor} aria-label="Primary color" />
40
- * ```
41
- */
42
- declare function ColorPicker({ value, onChange, disabled, "aria-label": ariaLabel, className, }: ColorPickerProps): react_jsx_runtime.JSX.Element;
43
-
44
- export { ColorPicker, type ColorPickerProps };
1
+ export { ColorPickerProps_alias_1 as ColorPickerProps } from './_tsup-dts-rollup.js';
2
+ export { ColorPicker_alias_1 as ColorPicker } from './_tsup-dts-rollup.js';
@@ -1,45 +1,3 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
-
3
- interface ComboboxOption {
4
- /** The value returned from onChange (stable, unique). */
5
- value: string;
6
- /** The display label shown in the list and the trigger. */
7
- label: string;
8
- /** Mark as non-selectable. */
9
- disabled?: boolean;
10
- }
11
- interface ComboboxProps {
12
- /** The list of selectable options. */
13
- options: ComboboxOption[];
14
- /** Controlled selected value. */
15
- value?: string;
16
- /** Fired when the user picks an option: (value: string) => void */
17
- onChange?: (value: string) => void;
18
- /** Text shown on the trigger when nothing is selected. */
19
- placeholder?: string;
20
- /** Input placeholder inside the popover list. */
21
- searchPlaceholder?: string;
22
- /** Text shown when no options match the search. */
23
- emptyText?: string;
24
- /** Disable the trigger. */
25
- disabled?: boolean;
26
- /** Extra class names on the trigger button. */
27
- className?: string;
28
- /** Accessible label for the trigger (required when no adjacent visible label). */
29
- "aria-label"?: string;
30
- /** Id of an external visible label that names this combobox. */
31
- "aria-labelledby"?: string;
32
- }
33
- /**
34
- * Searchable select input built on Command + Popover.
35
- *
36
- * Pass `options` with `{ value, label }` shape. The selected label is shown on
37
- * the trigger; the popover contains a CommandInput and filtered CommandList.
38
- * @returns A trigger button that opens a filtered option list.
39
- */
40
- declare function Combobox({ options, value, onChange, placeholder, searchPlaceholder, emptyText, disabled, className, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, }: ComboboxProps): react_jsx_runtime.JSX.Element;
41
- declare namespace Combobox {
42
- var displayName: string;
43
- }
44
-
45
- export { Combobox, type ComboboxOption, type ComboboxProps };
1
+ export { Combobox_alias_1 as Combobox } from './_tsup-dts-rollup.js';
2
+ export { ComboboxOption_alias_1 as ComboboxOption } from './_tsup-dts-rollup.js';
3
+ export { ComboboxProps_alias_1 as ComboboxProps } from './_tsup-dts-rollup.js';
package/dist/command.d.ts CHANGED
@@ -1,111 +1,9 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as React from 'react';
3
- import { Dialog } from './dialog.js';
4
- import '@radix-ui/react-dialog';
5
-
6
- /** Root Command container drives search, filtering, and keyboard navigation over items. */
7
- declare const Command: React.ForwardRefExoticComponent<Omit<{
8
- children?: React.ReactNode;
9
- } & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
10
- ref?: React.Ref<HTMLDivElement>;
11
- } & {
12
- asChild?: boolean;
13
- }, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
14
- label?: string;
15
- shouldFilter?: boolean;
16
- filter?: (value: string, search: string, keywords?: string[]) => number;
17
- defaultValue?: string;
18
- value?: string;
19
- onValueChange?: (value: string) => void;
20
- loop?: boolean;
21
- disablePointerSelection?: boolean;
22
- vimBindings?: boolean;
23
- } & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
24
- interface CommandDialogProps extends React.ComponentPropsWithoutRef<typeof Dialog> {
25
- /** Command children (CommandInput + CommandList + CommandItem, etc.) */
26
- children: React.ReactNode;
27
- /** Accessible title for the dialog (screen-reader only by default). */
28
- title?: string;
29
- /** Accessible description for the dialog (screen-reader only by default). */
30
- description?: string;
31
- }
32
- /**
33
- * Command menu rendered inside a Dialog — a ⌘K-style launcher.
34
- * @param props - Forwarded to the underlying Dialog (open, onOpenChange, etc.)
35
- * @returns A Dialog containing a Command menu.
36
- */
37
- declare function CommandDialog({ title, description, children, ...props }: CommandDialogProps): react_jsx_runtime.JSX.Element;
38
- /** Search input for the Command menu. Fires onValueChange as the user types. */
39
- declare const CommandInput: React.ForwardRefExoticComponent<Omit<Omit<Pick<Pick<React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "key" | keyof React.InputHTMLAttributes<HTMLInputElement>> & {
40
- ref?: React.Ref<HTMLInputElement>;
41
- } & {
42
- asChild?: boolean;
43
- }, "asChild" | "key" | keyof React.InputHTMLAttributes<HTMLInputElement>>, "onChange" | "type" | "value"> & {
44
- value?: string;
45
- onValueChange?: (search: string) => void;
46
- } & React.RefAttributes<HTMLInputElement>, "ref"> & React.RefAttributes<HTMLInputElement>>;
47
- /** Scrollable list that contains CommandGroup / CommandItem / CommandEmpty. */
48
- declare const CommandList: React.ForwardRefExoticComponent<Omit<{
49
- children?: React.ReactNode;
50
- } & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
51
- ref?: React.Ref<HTMLDivElement>;
52
- } & {
53
- asChild?: boolean;
54
- }, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
55
- label?: string;
56
- } & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
57
- /** Rendered when no items match the current search. */
58
- declare const CommandEmpty: React.ForwardRefExoticComponent<Omit<{
59
- children?: React.ReactNode;
60
- } & Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
61
- ref?: React.Ref<HTMLDivElement>;
62
- } & {
63
- asChild?: boolean;
64
- }, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>> & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
65
- /** Logical group of items — renders a heading and filters as a unit. */
66
- declare const CommandGroup: React.ForwardRefExoticComponent<Omit<{
67
- children?: React.ReactNode;
68
- } & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
69
- ref?: React.Ref<HTMLDivElement>;
70
- } & {
71
- asChild?: boolean;
72
- }, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>>, "heading" | "value"> & {
73
- heading?: React.ReactNode;
74
- value?: string;
75
- forceMount?: boolean;
76
- } & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
77
- /**
78
- * Horizontal rule between groups. Renders as a presentational `<div>` (no role)
79
- * so it can sit inside CommandList (role=listbox) without violating ARIA's
80
- * required-children rule for listbox. The line is purely decorative — cmdk's
81
- * built-in Separator hardcodes `role="separator"`, which axe rejects in this
82
- * context, so we render the divider directly.
83
- *
84
- * The `data-cmdk-separator` attribute is preserved so existing CSS / test
85
- * selectors that target cmdk's separator continue to match.
86
- */
87
- declare const CommandSeparator: React.ForwardRefExoticComponent<React.HTMLAttributes<HTMLDivElement> & React.RefAttributes<HTMLDivElement>>;
88
- /** Selectable item. onSelect fires on Enter or click. */
89
- declare const CommandItem: React.ForwardRefExoticComponent<Omit<{
90
- children?: React.ReactNode;
91
- } & Omit<Pick<Pick<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "key" | keyof React.HTMLAttributes<HTMLDivElement>> & {
92
- ref?: React.Ref<HTMLDivElement>;
93
- } & {
94
- asChild?: boolean;
95
- }, "asChild" | "key" | keyof React.HTMLAttributes<HTMLDivElement>>, "onSelect" | "disabled" | "value"> & {
96
- disabled?: boolean;
97
- onSelect?: (value: string) => void;
98
- value?: string;
99
- keywords?: string[];
100
- forceMount?: boolean;
101
- } & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
102
- /**
103
- * Keyboard shortcut hint (e.g. '⌘K') aligned to the right of an item.
104
- * @returns A muted inline span rendered at the end of a CommandItem.
105
- */
106
- declare function CommandShortcut({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>): react_jsx_runtime.JSX.Element;
107
- declare namespace CommandShortcut {
108
- var displayName: string;
109
- }
110
-
111
- export { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut };
1
+ export { Command_alias_1 as Command } from './_tsup-dts-rollup.js';
2
+ export { CommandDialog_alias_1 as CommandDialog } from './_tsup-dts-rollup.js';
3
+ export { CommandInput_alias_1 as CommandInput } from './_tsup-dts-rollup.js';
4
+ export { CommandList_alias_1 as CommandList } from './_tsup-dts-rollup.js';
5
+ export { CommandEmpty_alias_1 as CommandEmpty } from './_tsup-dts-rollup.js';
6
+ export { CommandGroup_alias_1 as CommandGroup } from './_tsup-dts-rollup.js';
7
+ export { CommandItem_alias_1 as CommandItem } from './_tsup-dts-rollup.js';
8
+ export { CommandShortcut_alias_1 as CommandShortcut } from './_tsup-dts-rollup.js';
9
+ export { CommandSeparator_alias_1 as CommandSeparator } from './_tsup-dts-rollup.js';
@@ -0,0 +1,2 @@
1
+ export { ComposerProps_alias_1 as ComposerProps } from './_tsup-dts-rollup.js';
2
+ export { Composer_alias_1 as Composer } from './_tsup-dts-rollup.js';
@@ -0,0 +1,75 @@
1
+ "use client";
2
+ import { clsx } from 'clsx';
3
+ import { twMerge } from 'tailwind-merge';
4
+ import { jsxs, jsx } from 'react/jsx-runtime';
5
+
6
+ function cn(...inputs) {
7
+ return twMerge(clsx(inputs));
8
+ }
9
+ function Composer({
10
+ value,
11
+ onValueChange,
12
+ onSubmit,
13
+ disabled,
14
+ placeholder,
15
+ submitOnEnter = true,
16
+ textareaAriaLabel,
17
+ children,
18
+ className,
19
+ ...rest
20
+ }) {
21
+ function trySubmit() {
22
+ const trimmed = value.trim();
23
+ if (!trimmed || disabled) return;
24
+ onSubmit(trimmed);
25
+ }
26
+ function handleKeyDown(event) {
27
+ if (!submitOnEnter) return;
28
+ if (event.key === "Enter" && !event.shiftKey && !event.nativeEvent.isComposing) {
29
+ event.preventDefault();
30
+ trySubmit();
31
+ }
32
+ }
33
+ function handleSubmit(event) {
34
+ event.preventDefault();
35
+ trySubmit();
36
+ }
37
+ return /* @__PURE__ */ jsxs(
38
+ "form",
39
+ {
40
+ ...rest,
41
+ onSubmit: handleSubmit,
42
+ className: cn(
43
+ "flex items-end gap-2 rounded-lg border bg-background p-2",
44
+ "focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",
45
+ "transition-all duration-[var(--duration-normal,200ms)] ease-out",
46
+ className
47
+ ),
48
+ children: [
49
+ /* @__PURE__ */ jsx(
50
+ "textarea",
51
+ {
52
+ value,
53
+ onChange: (event) => onValueChange(event.target.value),
54
+ onKeyDown: handleKeyDown,
55
+ disabled,
56
+ placeholder,
57
+ "aria-label": textareaAriaLabel ?? placeholder ?? "Message",
58
+ rows: 1,
59
+ className: cn(
60
+ "flex-1 resize-none bg-transparent px-2 py-1.5 text-sm leading-6",
61
+ "placeholder:text-muted-foreground focus:outline-none",
62
+ "disabled:cursor-not-allowed disabled:opacity-50",
63
+ "max-h-48 min-h-[2.25rem] overflow-y-auto"
64
+ )
65
+ }
66
+ ),
67
+ children
68
+ ]
69
+ }
70
+ );
71
+ }
72
+
73
+ export { Composer };
74
+ //# sourceMappingURL=composer.js.map
75
+ //# sourceMappingURL=composer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/lib/utils.ts","../src/ai/composer/composer.tsx"],"names":[],"mappings":";;;;AAQO,SAAS,MAAM,MAAA,EAAsB;AAC3C,EAAA,OAAO,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAC5B;ACoCA,SAAS,QAAA,CAAS;AAAA,EACjB,KAAA;AAAA,EACA,aAAA;AAAA,EACA,QAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA;AAAA,EACA,aAAA,GAAgB,IAAA;AAAA,EAChB,iBAAA;AAAA,EACA,QAAA;AAAA,EACA,SAAA;AAAA,EACA,GAAG;AACJ,CAAA,EAAkB;AACjB,EAAA,SAAS,SAAA,GAAY;AACpB,IAAA,MAAM,OAAA,GAAU,MAAM,IAAA,EAAK;AAC3B,IAAA,IAAI,CAAC,WAAW,QAAA,EAAU;AAC1B,IAAA,QAAA,CAAS,OAAO,CAAA;AAAA,EACjB;AAEA,EAAA,SAAS,cAAc,KAAA,EAAiD;AACvE,IAAA,IAAI,CAAC,aAAA,EAAe;AACpB,IAAA,IAAI,KAAA,CAAM,QAAQ,OAAA,IAAW,CAAC,MAAM,QAAA,IAAY,CAAC,KAAA,CAAM,WAAA,CAAY,WAAA,EAAa;AAC/E,MAAA,KAAA,CAAM,cAAA,EAAe;AACrB,MAAA,SAAA,EAAU;AAAA,IACX;AAAA,EACD;AAEA,EAAA,SAAS,aAAa,KAAA,EAAyC;AAC9D,IAAA,KAAA,CAAM,cAAA,EAAe;AACrB,IAAA,SAAA,EAAU;AAAA,EACX;AAEA,EAAA,uBACC,IAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,GAAG,IAAA;AAAA,MACJ,QAAA,EAAU,YAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACV,0DAAA;AAAA,QACA,uEAAA;AAAA,QACA,iEAAA;AAAA,QACA;AAAA,OACD;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,UAAA;AAAA,UAAA;AAAA,YACA,KAAA;AAAA,YACA,UAAU,CAAC,KAAA,KAAU,aAAA,CAAc,KAAA,CAAM,OAAO,KAAK,CAAA;AAAA,YACrD,SAAA,EAAW,aAAA;AAAA,YACX,QAAA;AAAA,YACA,WAAA;AAAA,YACA,YAAA,EAAY,qBAAqB,WAAA,IAAe,SAAA;AAAA,YAChD,IAAA,EAAM,CAAA;AAAA,YACN,SAAA,EAAW,EAAA;AAAA,cACV,iEAAA;AAAA,cACA,sDAAA;AAAA,cACA,iDAAA;AAAA,cACA;AAAA;AACD;AAAA,SACD;AAAA,QACC;AAAA;AAAA;AAAA,GACF;AAEF","file":"composer.js","sourcesContent":["import { type ClassValue, clsx } from \"clsx\";\nimport { twMerge } from \"tailwind-merge\";\n\n/**\n * Merge class names with Tailwind CSS conflict resolution.\n * @param inputs - Class values (strings, arrays, objects) to merge\n * @returns A single merged class string with Tailwind conflicts resolved\n */\nexport function cn(...inputs: ClassValue[]) {\n\treturn twMerge(clsx(inputs));\n}\n","\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"../../lib/utils.js\";\n\n/**\n * Multi-line text input + submission shell for chat composers. Headless on\n * data flow — `value`/`onValueChange` are required so the consumer keeps\n * input state wherever fits (a `useChat` hook, a parent form, local state).\n *\n * Submits on Enter (without Shift). Children render after the textarea —\n * the canonical place for attachment buttons + a send button.\n *\n * Spreads remaining props onto the underlying `<form>`, so consumers can\n * pass `aria-label`, `id`, `name`, `data-*`, and similar attributes.\n *\n * @example\n * <Composer\n * value={input}\n * onValueChange={setInput}\n * onSubmit={(v) => sendMessage(v)}\n * placeholder=\"Ask anything…\"\n * >\n * <Button type=\"submit\">Send</Button>\n * </Composer>\n */\nexport interface ComposerProps\n\textends Omit<React.FormHTMLAttributes<HTMLFormElement>, \"onSubmit\" | \"children\"> {\n\tvalue: string;\n\tonValueChange: (value: string) => void;\n\tonSubmit: (value: string) => void;\n\tdisabled?: boolean;\n\tplaceholder?: string;\n\t/** Submit on Enter without Shift. Default true. */\n\tsubmitOnEnter?: boolean;\n\t/** Accessible name for the textarea. Defaults to `placeholder` when set, else \"Message\". */\n\ttextareaAriaLabel?: string;\n\t/** Trailing slot — attachment buttons, send button, etc. */\n\tchildren?: React.ReactNode;\n}\n\n/**\n * Renders a chat composer with a textarea + slot for action buttons.\n * @param props - controlled value/handlers + slot children\n * @returns A form element with a textarea and trailing slot\n */\nfunction Composer({\n\tvalue,\n\tonValueChange,\n\tonSubmit,\n\tdisabled,\n\tplaceholder,\n\tsubmitOnEnter = true,\n\ttextareaAriaLabel,\n\tchildren,\n\tclassName,\n\t...rest\n}: ComposerProps) {\n\tfunction trySubmit() {\n\t\tconst trimmed = value.trim();\n\t\tif (!trimmed || disabled) return;\n\t\tonSubmit(trimmed);\n\t}\n\n\tfunction handleKeyDown(event: React.KeyboardEvent<HTMLTextAreaElement>) {\n\t\tif (!submitOnEnter) return;\n\t\tif (event.key === \"Enter\" && !event.shiftKey && !event.nativeEvent.isComposing) {\n\t\t\tevent.preventDefault();\n\t\t\ttrySubmit();\n\t\t}\n\t}\n\n\tfunction handleSubmit(event: React.FormEvent<HTMLFormElement>) {\n\t\tevent.preventDefault();\n\t\ttrySubmit();\n\t}\n\n\treturn (\n\t\t<form\n\t\t\t{...rest}\n\t\t\tonSubmit={handleSubmit}\n\t\t\tclassName={cn(\n\t\t\t\t\"flex items-end gap-2 rounded-lg border bg-background p-2\",\n\t\t\t\t\"focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2\",\n\t\t\t\t\"transition-all duration-[var(--duration-normal,200ms)] ease-out\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t>\n\t\t\t<textarea\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={(event) => onValueChange(event.target.value)}\n\t\t\t\tonKeyDown={handleKeyDown}\n\t\t\t\tdisabled={disabled}\n\t\t\t\tplaceholder={placeholder}\n\t\t\t\taria-label={textareaAriaLabel ?? placeholder ?? \"Message\"}\n\t\t\t\trows={1}\n\t\t\t\tclassName={cn(\n\t\t\t\t\t\"flex-1 resize-none bg-transparent px-2 py-1.5 text-sm leading-6\",\n\t\t\t\t\t\"placeholder:text-muted-foreground focus:outline-none\",\n\t\t\t\t\t\"disabled:cursor-not-allowed disabled:opacity-50\",\n\t\t\t\t\t\"max-h-48 min-h-[2.25rem] overflow-y-auto\",\n\t\t\t\t)}\n\t\t\t/>\n\t\t\t{children}\n\t\t</form>\n\t);\n}\n\nexport { Composer };\n"]}
@@ -1,41 +1,3 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import * as class_variance_authority_types from 'class-variance-authority/types';
3
- import { VariantProps } from 'class-variance-authority';
4
- import * as React from 'react';
5
-
6
- /**
7
- * CVA variants for Container — max-width wrapper bound to `--container-*` tokens.
8
- * Variant names match token names (`sm`/`md`/`lg`/`xl`/`full`); `full` removes the clamp.
9
- * Padding maps to `--space-*` tokens.
10
- */
11
- declare const containerVariants: (props?: ({
12
- size?: "sm" | "lg" | "md" | "xl" | "full" | null | undefined;
13
- padding?: "none" | "sm" | "lg" | "md" | null | undefined;
14
- } & class_variance_authority_types.ClassProp) | undefined) => string;
15
- /** Props for the Container component. */
16
- interface ContainerProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof containerVariants> {
17
- /**
18
- * Render as a different element via Radix `Slot`. Pass `<Container asChild><main>...</main></Container>`
19
- * to render the layout as a `<main>` (or `<section>`, `<article>`, etc.) and inherit landmark semantics.
20
- */
21
- asChild?: boolean;
22
- }
23
- /**
24
- * A centered max-width wrapper for page content. Use to constrain reading-width sections.
25
- * Pass `asChild` to render as a semantic landmark (`<main>`, `<section>`, etc.) instead of a plain `<div>`.
26
- *
27
- * @param props - Container props including `size`, `padding`, and optional `asChild`.
28
- * @returns A wrapper element with `mx-auto`, max-width clamp, and optional horizontal padding.
29
- * @example
30
- * ```tsx
31
- * <Container size="lg" padding="md" asChild>
32
- * <main>
33
- * <h1>Article title</h1>
34
- * <p>Reading-width content...</p>
35
- * </main>
36
- * </Container>
37
- * ```
38
- */
39
- declare function Container({ className, size, padding, asChild, ...props }: ContainerProps): react_jsx_runtime.JSX.Element;
40
-
41
- export { Container, type ContainerProps, containerVariants };
1
+ export { ContainerProps_alias_1 as ContainerProps } from './_tsup-dts-rollup.js';
2
+ export { Container_alias_1 as Container } from './_tsup-dts-rollup.js';
3
+ export { containerVariants_alias_1 as containerVariants } from './_tsup-dts-rollup.js';