@locusgraph/loop 0.0.0-stage → 0.1.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 (202) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +35 -2
  3. package/dist/agent/index.d.ts +5 -0
  4. package/dist/agent/index.js +5 -0
  5. package/dist/agent/pulse/gradient-label.d.ts +7 -0
  6. package/dist/agent/pulse/gradient-label.js +23 -0
  7. package/dist/agent/pulse/marks/bars-mark.d.ts +1 -0
  8. package/dist/agent/pulse/marks/bars-mark.js +15 -0
  9. package/dist/agent/pulse/marks/glyph-mark.d.ts +4 -0
  10. package/dist/agent/pulse/marks/glyph-mark.js +17 -0
  11. package/dist/agent/pulse/marks/locus-mark.d.ts +1 -0
  12. package/dist/agent/pulse/marks/locus-mark.js +38 -0
  13. package/dist/agent/pulse/marks/orb-mark.d.ts +1 -0
  14. package/dist/agent/pulse/marks/orb-mark.js +11 -0
  15. package/dist/agent/pulse/marks/spinner-mark.d.ts +1 -0
  16. package/dist/agent/pulse/marks/spinner-mark.js +4 -0
  17. package/dist/agent/pulse/pulse-tone.d.ts +1 -0
  18. package/dist/agent/pulse/pulse-tone.js +1 -0
  19. package/dist/agent/pulse/pulse.d.ts +12 -0
  20. package/dist/agent/pulse/pulse.js +51 -0
  21. package/dist/agent/pulse/use-loop-animation.d.ts +2 -0
  22. package/dist/agent/pulse/use-loop-animation.js +21 -0
  23. package/dist/agent/shared/status-dot.d.ts +1 -0
  24. package/dist/agent/shared/status-dot.js +1 -0
  25. package/dist/agent/steps/step-icon.d.ts +8 -0
  26. package/dist/agent/steps/step-icon.js +31 -0
  27. package/dist/agent/steps/steps.d.ts +7 -0
  28. package/dist/agent/steps/steps.js +39 -0
  29. package/dist/agent/thinking/thinking.d.ts +6 -0
  30. package/dist/agent/thinking/thinking.js +31 -0
  31. package/dist/agent/thinking/thought-duration.d.ts +2 -0
  32. package/dist/agent/thinking/thought-duration.js +13 -0
  33. package/dist/agent/tool/json-block.d.ts +5 -0
  34. package/dist/agent/tool/json-block.js +15 -0
  35. package/dist/agent/tool/tool-status.d.ts +6 -0
  36. package/dist/agent/tool/tool-status.js +26 -0
  37. package/dist/agent/tool/tool.d.ts +7 -0
  38. package/dist/agent/tool/tool.js +14 -0
  39. package/dist/approval/inbox/inbox-row.d.ts +11 -0
  40. package/dist/approval/inbox/inbox-row.js +14 -0
  41. package/dist/approval/inbox/inbox-selection.d.ts +6 -0
  42. package/dist/approval/inbox/inbox-selection.js +21 -0
  43. package/dist/approval/inbox/inbox.d.ts +11 -0
  44. package/dist/approval/inbox/inbox.js +26 -0
  45. package/dist/approval/index.d.ts +9 -0
  46. package/dist/approval/index.js +8 -0
  47. package/dist/approval/memory/memory-choices.d.ts +10 -0
  48. package/dist/approval/memory/memory-choices.js +30 -0
  49. package/dist/approval/memory/memory-review.d.ts +11 -0
  50. package/dist/approval/memory/memory-review.js +31 -0
  51. package/dist/approval/memory/memory-row.d.ts +9 -0
  52. package/dist/approval/memory/memory-row.js +30 -0
  53. package/dist/approval/plan/plan-review.d.ts +13 -0
  54. package/dist/approval/plan/plan-review.js +38 -0
  55. package/dist/approval/plan/plan-step-row.d.ts +13 -0
  56. package/dist/approval/plan/plan-step-row.js +50 -0
  57. package/dist/approval/plan/plan-steps.d.ts +8 -0
  58. package/dist/approval/plan/plan-steps.js +29 -0
  59. package/dist/approval/plan/question-choices.d.ts +10 -0
  60. package/dist/approval/plan/question-choices.js +47 -0
  61. package/dist/approval/plan/question.d.ts +18 -0
  62. package/dist/approval/plan/question.js +35 -0
  63. package/dist/approval/run/run-bar.d.ts +13 -0
  64. package/dist/approval/run/run-bar.js +33 -0
  65. package/dist/approval/shared/decision-line.d.ts +1 -0
  66. package/dist/approval/shared/decision-line.js +1 -0
  67. package/dist/approval/shared/risk-badge.d.ts +10 -0
  68. package/dist/approval/shared/risk-badge.js +26 -0
  69. package/dist/approval/shared/time.d.ts +3 -0
  70. package/dist/approval/shared/time.js +15 -0
  71. package/dist/approval/shared/use-focus-on-mount.d.ts +2 -0
  72. package/dist/approval/shared/use-focus-on-mount.js +9 -0
  73. package/dist/approval/spend/raise-cap-form.d.ts +8 -0
  74. package/dist/approval/spend/raise-cap-form.js +26 -0
  75. package/dist/approval/spend/spend-gate.d.ts +16 -0
  76. package/dist/approval/spend/spend-gate.js +32 -0
  77. package/dist/approval/spend/spend-math.d.ts +5 -0
  78. package/dist/approval/spend/spend-math.js +18 -0
  79. package/dist/approval/spend/spend-meter.d.ts +10 -0
  80. package/dist/approval/spend/spend-meter.js +49 -0
  81. package/dist/approval/tool/approval.d.ts +14 -0
  82. package/dist/approval/tool/approval.js +45 -0
  83. package/dist/approval/tool/args/args-editor.d.ts +16 -0
  84. package/dist/approval/tool/args/args-editor.js +37 -0
  85. package/dist/approval/tool/args/args-field.d.ts +11 -0
  86. package/dist/approval/tool/args/args-field.js +28 -0
  87. package/dist/approval/tool/args/args-validation.d.ts +8 -0
  88. package/dist/approval/tool/args/args-validation.js +59 -0
  89. package/dist/approval/tool/deny-form.d.ts +6 -0
  90. package/dist/approval/tool/deny-form.js +15 -0
  91. package/dist/approval/tool/tool-inputs.d.ts +6 -0
  92. package/dist/approval/tool/tool-inputs.js +53 -0
  93. package/dist/approval/types.d.ts +59 -0
  94. package/dist/approval/types.js +1 -0
  95. package/dist/chat/chat/chat.d.ts +7 -0
  96. package/dist/chat/chat/chat.js +11 -0
  97. package/dist/chat/chat/use-stick-to-bottom.d.ts +7 -0
  98. package/dist/chat/chat/use-stick-to-bottom.js +57 -0
  99. package/dist/chat/composer/composer-actions.d.ts +15 -0
  100. package/dist/chat/composer/composer-actions.js +23 -0
  101. package/dist/chat/composer/composer.d.ts +20 -0
  102. package/dist/chat/composer/composer.js +42 -0
  103. package/dist/chat/composer/use-auto-grow.d.ts +2 -0
  104. package/dist/chat/composer/use-auto-grow.js +14 -0
  105. package/dist/chat/files/file-meta.d.ts +13 -0
  106. package/dist/chat/files/file-meta.js +30 -0
  107. package/dist/chat/files/files.d.ts +9 -0
  108. package/dist/chat/files/files.js +39 -0
  109. package/dist/chat/index.d.ts +7 -0
  110. package/dist/chat/index.js +7 -0
  111. package/dist/chat/reply/fenced-code.d.ts +8 -0
  112. package/dist/chat/reply/fenced-code.js +29 -0
  113. package/dist/chat/reply/markdown-components.d.ts +2 -0
  114. package/dist/chat/reply/markdown-components.js +22 -0
  115. package/dist/chat/reply/reply.d.ts +8 -0
  116. package/dist/chat/reply/reply.js +21 -0
  117. package/dist/chat/turn/group-parts.d.ts +24 -0
  118. package/dist/chat/turn/group-parts.js +35 -0
  119. package/dist/chat/turn/turn.d.ts +11 -0
  120. package/dist/chat/turn/turn.js +45 -0
  121. package/dist/cost/context.d.ts +13 -0
  122. package/dist/cost/context.js +35 -0
  123. package/dist/cost/cost-steps.d.ts +17 -0
  124. package/dist/cost/cost-steps.js +24 -0
  125. package/dist/cost/cost.d.ts +8 -0
  126. package/dist/cost/cost.js +37 -0
  127. package/dist/cost/index.d.ts +4 -0
  128. package/dist/cost/index.js +4 -0
  129. package/dist/cost/model-picker.d.ts +11 -0
  130. package/dist/cost/model-picker.js +9 -0
  131. package/dist/cost/shared/context-breakdown.d.ts +15 -0
  132. package/dist/cost/shared/context-breakdown.js +17 -0
  133. package/dist/cost/shared/meter-marks.d.ts +9 -0
  134. package/dist/cost/shared/meter-marks.js +16 -0
  135. package/dist/cost/shared/model-option-row.d.ts +14 -0
  136. package/dist/cost/shared/model-option-row.js +32 -0
  137. package/dist/cost/shared/step-cost-row.d.ts +15 -0
  138. package/dist/cost/shared/step-cost-row.js +34 -0
  139. package/dist/cost/shared/usage-totals.d.ts +11 -0
  140. package/dist/cost/shared/usage-totals.js +26 -0
  141. package/dist/index.d.ts +7 -0
  142. package/dist/index.js +7 -0
  143. package/dist/memory/cite.d.ts +8 -0
  144. package/dist/memory/cite.js +19 -0
  145. package/dist/memory/index.d.ts +5 -0
  146. package/dist/memory/index.js +4 -0
  147. package/dist/memory/memorized.d.ts +14 -0
  148. package/dist/memory/memorized.js +19 -0
  149. package/dist/memory/recall.d.ts +9 -0
  150. package/dist/memory/recall.js +24 -0
  151. package/dist/memory/shared/disclosure.d.ts +6 -0
  152. package/dist/memory/shared/disclosure.js +6 -0
  153. package/dist/memory/shared/host-label.d.ts +6 -0
  154. package/dist/memory/shared/host-label.js +34 -0
  155. package/dist/memory/shared/source-mark.d.ts +5 -0
  156. package/dist/memory/shared/source-mark.js +6 -0
  157. package/dist/memory/sources.d.ts +9 -0
  158. package/dist/memory/sources.js +22 -0
  159. package/dist/shared/decision-summary.d.ts +18 -0
  160. package/dist/shared/decision-summary.js +25 -0
  161. package/dist/shared/panel-empty.d.ts +8 -0
  162. package/dist/shared/panel-empty.js +5 -0
  163. package/dist/shared/panel.d.ts +19 -0
  164. package/dist/shared/panel.js +21 -0
  165. package/dist/shared/status-dot.d.ts +6 -0
  166. package/dist/shared/status-dot.js +12 -0
  167. package/dist/sources.css +1 -0
  168. package/dist/thread/actions/action-button.d.ts +8 -0
  169. package/dist/thread/actions/action-button.js +5 -0
  170. package/dist/thread/actions/actions.d.ts +13 -0
  171. package/dist/thread/actions/actions.js +21 -0
  172. package/dist/thread/actions/branch-switcher.d.ts +10 -0
  173. package/dist/thread/actions/branch-switcher.js +7 -0
  174. package/dist/thread/canvas/canvas.d.ts +14 -0
  175. package/dist/thread/canvas/canvas.js +12 -0
  176. package/dist/thread/canvas/version-switcher.d.ts +12 -0
  177. package/dist/thread/canvas/version-switcher.js +11 -0
  178. package/dist/thread/code/code.d.ts +10 -0
  179. package/dist/thread/code/code.js +33 -0
  180. package/dist/thread/code/copy-code-button.d.ts +6 -0
  181. package/dist/thread/code/copy-code-button.js +18 -0
  182. package/dist/thread/code/highlight.d.ts +1 -0
  183. package/dist/thread/code/highlight.js +39 -0
  184. package/dist/thread/history/history-row.d.ts +14 -0
  185. package/dist/thread/history/history-row.js +17 -0
  186. package/dist/thread/history/history.d.ts +15 -0
  187. package/dist/thread/history/history.js +10 -0
  188. package/dist/thread/history/thread-groups.d.ts +8 -0
  189. package/dist/thread/history/thread-groups.js +46 -0
  190. package/dist/thread/history/thread-item-menu.d.ts +7 -0
  191. package/dist/thread/history/thread-item-menu.js +6 -0
  192. package/dist/thread/history/thread-title-editor.d.ts +7 -0
  193. package/dist/thread/history/thread-title-editor.js +25 -0
  194. package/dist/thread/index.d.ts +8 -0
  195. package/dist/thread/index.js +5 -0
  196. package/dist/thread/starters/starters.d.ts +12 -0
  197. package/dist/thread/starters/starters.js +15 -0
  198. package/dist/thread/use-copied.d.ts +5 -0
  199. package/dist/thread/use-copied.js +22 -0
  200. package/dist/types.d.ts +70 -0
  201. package/dist/types.js +3 -0
  202. package/package.json +57 -3
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "@locusgraph/components";
3
+ export function PanelEmpty({ icon, title, description, className, ...props }) {
4
+ return (_jsxs("div", { "data-slot": "panel-empty", ...props, className: cn("flex flex-col items-center gap-1 px-6 pt-8 pb-10 text-center [&_svg]:mb-1 [&_svg]:size-5 [&_svg]:text-muted-foreground", className), children: [icon, _jsx("p", { className: "text-sm font-medium", children: title }), description && _jsx("p", { className: "max-w-xs text-xs text-muted-foreground", children: description })] }));
5
+ }
@@ -0,0 +1,19 @@
1
+ import type { ComponentProps, ReactNode } from "react";
2
+ import { type StatusTone } from "./status-dot.js";
3
+ export declare function ApprovalPanel({ className, ...props }: ComponentProps<"section">): import("react").JSX.Element;
4
+ export type PanelTone = StatusTone;
5
+ type PanelHeaderProps = {
6
+ icon: ReactNode;
7
+ eyebrow: string;
8
+ status?: string;
9
+ tone?: PanelTone;
10
+ aside?: ReactNode;
11
+ };
12
+ export declare function PanelHeader({ icon, eyebrow, status, tone, aside }: PanelHeaderProps): import("react").JSX.Element;
13
+ export declare function PanelTitle({ className, ...props }: ComponentProps<"h3">): import("react").JSX.Element;
14
+ export declare function PanelBody({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
15
+ export declare function PanelFooter({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
16
+ export declare function LiveStatus({ message }: {
17
+ message: string;
18
+ }): import("react").JSX.Element;
19
+ export {};
@@ -0,0 +1,21 @@
1
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "@locusgraph/components";
3
+ import { StatusDot } from "./status-dot.js";
4
+ export function ApprovalPanel({ className, ...props }) {
5
+ return (_jsx("section", { className: cn("flex min-w-0 flex-col bg-card text-card-foreground ring-1 ring-border", className), ...props }));
6
+ }
7
+ export function PanelHeader({ icon, eyebrow, status, tone = "idle", aside }) {
8
+ return (_jsxs("header", { "data-slot": "panel-header", className: "eyebrow flex items-center gap-2 px-5 pt-4 [&_svg]:size-3.5 [&_svg]:shrink-0", children: [icon, _jsx("span", { className: "min-w-0 truncate", children: eyebrow }), _jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-1.5", children: [aside && _jsx("span", { className: "mr-2 tabular-nums", children: aside }), status && (_jsxs(_Fragment, { children: [_jsx(StatusDot, { tone: tone }), _jsx("span", { children: status })] }))] })] }));
9
+ }
10
+ export function PanelTitle({ className, ...props }) {
11
+ return (_jsx("h3", { className: cn("px-5 pt-2 font-sans text-base leading-snug font-semibold tracking-tight text-balance", className), ...props }));
12
+ }
13
+ export function PanelBody({ className, ...props }) {
14
+ return _jsx("div", { className: cn("flex flex-col gap-4 px-5 pt-4 pb-5", className), ...props });
15
+ }
16
+ export function PanelFooter({ className, ...props }) {
17
+ return (_jsx("div", { className: cn("flex flex-wrap items-center justify-end gap-2 border-t bg-muted/70 px-5 py-3", className), ...props }));
18
+ }
19
+ export function LiveStatus({ message }) {
20
+ return (_jsx("p", { role: "status", "aria-live": "polite", className: "sr-only", children: message }));
21
+ }
@@ -0,0 +1,6 @@
1
+ export type StatusTone = "running" | "waiting" | "done" | "danger" | "idle";
2
+ export declare const statusDotTones: Record<StatusTone, string>;
3
+ export declare function StatusDot({ tone, className }: {
4
+ tone: StatusTone;
5
+ className?: string;
6
+ }): import("react").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { cn } from "@locusgraph/components";
3
+ export const statusDotTones = {
4
+ running: "bg-warn motion-safe:animate-pulse",
5
+ waiting: "bg-warn motion-safe:animate-pulse",
6
+ done: "bg-good",
7
+ danger: "bg-destructive",
8
+ idle: "bg-muted-foreground/50",
9
+ };
10
+ export function StatusDot({ tone, className }) {
11
+ return (_jsx("span", { "aria-hidden": true, "data-slot": "status-dot", "data-tone": tone, className: cn("size-1.5 shrink-0 rounded-full", statusDotTones[tone], className) }));
12
+ }
@@ -0,0 +1 @@
1
+ @source "./";
@@ -0,0 +1,8 @@
1
+ import { Button } from "@locusgraph/components";
2
+ import type { ComponentProps, ReactNode } from "react";
3
+ type ActionButtonProps = Omit<ComponentProps<typeof Button>, "aria-label" | "children"> & {
4
+ label: string;
5
+ children: ReactNode;
6
+ };
7
+ export declare function ActionButton({ label, children, ...props }: ActionButtonProps): import("react").JSX.Element;
8
+ export {};
@@ -0,0 +1,5 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Button, Tooltip, TooltipContent, TooltipTrigger } from "@locusgraph/components";
3
+ export function ActionButton({ label, children, ...props }) {
4
+ return (_jsxs(Tooltip, { children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": label, className: "text-muted-foreground hover:bg-accent hover:text-foreground [&_svg]:size-4", ...props, children: children }) }), _jsx(TooltipContent, { children: label })] }));
5
+ }
@@ -0,0 +1,13 @@
1
+ import type { ComponentProps } from "react";
2
+ import { type MessageBranch } from "./branch-switcher.js";
3
+ export type MessageFeedback = "up" | "down" | null;
4
+ type ActionsProps = ComponentProps<"div"> & {
5
+ onCopy?: () => void;
6
+ onRetry?: () => void;
7
+ feedback?: MessageFeedback;
8
+ onFeedback?: (feedback: MessageFeedback) => void;
9
+ branch?: MessageBranch;
10
+ onBranchChange?: (index: number) => void;
11
+ };
12
+ export declare function Actions({ onCopy, onRetry, feedback, onFeedback, branch, onBranchChange, className, ...props }: ActionsProps): import("react").JSX.Element | null;
13
+ export {};
@@ -0,0 +1,21 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Checkmark as CheckIcon, Copy as CopyIcon, Renew as RefreshCwIcon, ThumbsDown as ThumbsDownIcon, ThumbsUp as ThumbsUpIcon, } from "@carbon/icons-react";
4
+ import { cn, TooltipProvider } from "@locusgraph/components";
5
+ import { useCopied } from "../use-copied.js";
6
+ import { ActionButton } from "./action-button.js";
7
+ import { BranchSwitcher } from "./branch-switcher.js";
8
+ function toggledFeedback(current, chosen) {
9
+ return current === chosen ? null : chosen;
10
+ }
11
+ export function Actions({ onCopy, onRetry, feedback = null, onFeedback, branch, onBranchChange, className, ...props }) {
12
+ const { copied, markCopied } = useCopied();
13
+ const showBranch = branch !== undefined && branch.count > 1 && onBranchChange !== undefined;
14
+ if (!onCopy && !onRetry && !onFeedback && !showBranch) {
15
+ return null;
16
+ }
17
+ return (_jsx(TooltipProvider, { children: _jsxs("div", { "data-slot": "actions", role: "toolbar", "aria-label": "Message actions", className: cn("flex items-center gap-0.5", className), ...props, children: [showBranch && _jsx(BranchSwitcher, { branch: branch, onBranchChange: onBranchChange }), showBranch && (onCopy || onRetry || onFeedback) && (_jsx("span", { "aria-hidden": true, className: "mx-1 h-3.5 w-px bg-border" })), onCopy && (_jsx(ActionButton, { label: copied ? "Copied" : "Copy", onClick: () => {
18
+ onCopy();
19
+ markCopied();
20
+ }, children: copied ? _jsx(CheckIcon, { className: "text-good" }) : _jsx(CopyIcon, {}) })), onRetry && (_jsx(ActionButton, { label: "Retry", onClick: onRetry, children: _jsx(RefreshCwIcon, {}) })), onFeedback && (_jsxs(_Fragment, { children: [_jsx(ActionButton, { label: "Good response", "aria-pressed": feedback === "up", className: cn(feedback === "up" && "text-foreground"), onClick: () => onFeedback(toggledFeedback(feedback, "up")), children: _jsx(ThumbsUpIcon, { className: cn(feedback === "up" && "fill-current") }) }), _jsx(ActionButton, { label: "Bad response", "aria-pressed": feedback === "down", className: cn(feedback === "down" && "text-foreground"), onClick: () => onFeedback(toggledFeedback(feedback, "down")), children: _jsx(ThumbsDownIcon, { className: cn(feedback === "down" && "fill-current") }) })] })), copied && (_jsx("span", { role: "status", className: "sr-only", children: "Copied" }))] }) }));
21
+ }
@@ -0,0 +1,10 @@
1
+ export type MessageBranch = {
2
+ index: number;
3
+ count: number;
4
+ };
5
+ type BranchSwitcherProps = {
6
+ branch: MessageBranch;
7
+ onBranchChange: (index: number) => void;
8
+ };
9
+ export declare function BranchSwitcher({ branch, onBranchChange }: BranchSwitcherProps): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,7 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ChevronLeft as ChevronLeftIcon, ChevronRight as ChevronRightIcon, } from "@carbon/icons-react";
3
+ import { ActionButton } from "./action-button.js";
4
+ export function BranchSwitcher({ branch, onBranchChange }) {
5
+ const position = branch.index + 1;
6
+ return (_jsxs("div", { "data-slot": "branch-switcher", role: "group", "aria-label": "Reply versions", className: "flex items-center", children: [_jsx(ActionButton, { label: "Previous version", disabled: branch.index <= 0, onClick: () => onBranchChange(branch.index - 1), children: _jsx(ChevronLeftIcon, {}) }), _jsx("span", { "aria-live": "polite", className: "min-w-9 text-center font-mono text-xs text-muted-foreground tabular-nums", children: `${position} / ${branch.count}` }), _jsx(ActionButton, { label: "Next version", disabled: position >= branch.count, onClick: () => onBranchChange(branch.index + 1), children: _jsx(ChevronRightIcon, {}) })] }));
7
+ }
@@ -0,0 +1,14 @@
1
+ import type { ComponentProps, ReactNode } from "react";
2
+ import { type CanvasVersion } from "./version-switcher.js";
3
+ type CanvasProps = Omit<ComponentProps<"aside">, "title"> & {
4
+ title: string;
5
+ kind?: string;
6
+ versions?: CanvasVersion[];
7
+ versionId?: string;
8
+ onVersionChange?: (id: string) => void;
9
+ actions?: ReactNode;
10
+ onClose?: () => void;
11
+ children: ReactNode;
12
+ };
13
+ export declare function Canvas({ title, kind, versions, versionId, onVersionChange, actions, onClose, children, className, ...props }: CanvasProps): import("react").JSX.Element;
14
+ export {};
@@ -0,0 +1,12 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Close as XIcon } from "@carbon/icons-react";
4
+ import { Button, cn, ScrollArea } from "@locusgraph/components";
5
+ import { VersionSwitcher } from "./version-switcher.js";
6
+ function currentVersionOf(versions, versionId) {
7
+ return versions.find((version) => version.id === versionId) ?? versions.at(-1);
8
+ }
9
+ export function Canvas({ title, kind, versions = [], versionId, onVersionChange, actions, onClose, children, className, ...props }) {
10
+ const current = currentVersionOf(versions, versionId);
11
+ return (_jsxs("aside", { "data-slot": "canvas", "aria-label": title, className: cn("flex h-full min-h-0 min-w-0 flex-col bg-card text-card-foreground ring-1 ring-border", className), ...props, children: [_jsxs("header", { className: "flex items-start gap-3 border-b px-5 pt-3.5 pb-3", children: [_jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [kind && _jsx("span", { className: "eyebrow", children: kind }), _jsx("h2", { className: "truncate font-sans text-base leading-snug font-semibold tracking-tight", children: title })] }), _jsxs("div", { className: "-mr-2 flex shrink-0 items-center gap-0.5 text-muted-foreground", children: [actions, onClose && (_jsx(Button, { type: "button", variant: "ghost", size: "icon-sm", "aria-label": "Close panel", className: "text-muted-foreground hover:text-foreground", onClick: onClose, children: _jsx(XIcon, {}) }))] })] }), _jsx(ScrollArea, { className: "min-h-0 flex-1", children: _jsx("div", { "data-slot": "canvas-content", className: "px-5 py-4 has-[>[data-slot=code]:only-child]:p-0 [&>[data-slot=code]:only-child]:ring-0", children: children }) }), current && (_jsx("footer", { className: "flex h-10 items-center gap-2 border-t bg-muted/30 pr-3 pl-5", children: _jsx(VersionSwitcher, { versions: versions, current: current, onVersionChange: onVersionChange }) }))] }));
12
+ }
@@ -0,0 +1,12 @@
1
+ export type CanvasVersion = {
2
+ id: string;
3
+ label: string;
4
+ createdAt: string;
5
+ };
6
+ type VersionSwitcherProps = {
7
+ versions: CanvasVersion[];
8
+ current: CanvasVersion;
9
+ onVersionChange?: (id: string) => void;
10
+ };
11
+ export declare function VersionSwitcher({ versions, current, onVersionChange }: VersionSwitcherProps): import("react").JSX.Element;
12
+ export {};
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ChevronDown as ChevronDownIcon } from "@carbon/icons-react";
3
+ import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuTrigger, } from "@locusgraph/components";
4
+ import { formatDate } from "@locusgraph/utils";
5
+ export function VersionSwitcher({ versions, current, onVersionChange }) {
6
+ const label = (_jsxs("span", { className: "flex items-center gap-2 font-mono text-[11px] tabular-nums", children: [_jsx("span", { "data-slot": "canvas-current-version", children: current.label }), versions.length > 1 && _jsxs("span", { className: "text-muted-foreground", children: ["of ", versions.length] }), _jsx("time", { dateTime: current.createdAt, className: "text-muted-foreground", children: formatDate(current.createdAt) })] }));
7
+ if (versions.length < 2 || !onVersionChange) {
8
+ return label;
9
+ }
10
+ return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { type: "button", variant: "ghost", size: "xs", className: "-ml-2 font-normal", "aria-label": `Version ${current.label}, choose another version`, children: [label, _jsx(ChevronDownIcon, {})] }) }), _jsx(DropdownMenuContent, { align: "start", sideOffset: 6, children: _jsx(DropdownMenuRadioGroup, { value: current.id, onValueChange: onVersionChange, children: versions.map((version) => (_jsxs(DropdownMenuRadioItem, { value: version.id, children: [_jsx("span", { className: "font-mono text-xs", children: version.label }), _jsx("span", { className: "ml-auto pl-4 text-xs text-muted-foreground", children: formatDate(version.createdAt) })] }, version.id))) }) })] }));
11
+ }
@@ -0,0 +1,10 @@
1
+ import { type ComponentProps } from "react";
2
+ type CodeProps = Omit<ComponentProps<"figure">, "children"> & {
3
+ code: string;
4
+ language?: string;
5
+ filename?: string;
6
+ showCopy?: boolean;
7
+ onCopy?: (code: string) => void;
8
+ };
9
+ export declare function Code({ code, language, filename, showCopy, onCopy, className, ...props }: CodeProps): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,33 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { cn } from "@locusgraph/components";
4
+ import { useEffect, useState } from "react";
5
+ import { CopyCodeButton } from "./copy-code-button.js";
6
+ import { highlightToHtml } from "./highlight.js";
7
+ const codeAreaClass = cn("overflow-x-auto bg-muted/40 px-4 py-3 font-mono text-xs leading-relaxed", "[&_pre]:bg-transparent! [&_pre]:outline-none", "[&_.shiki_span]:text-(--shiki-light) dark:[&_.shiki_span]:text-(--shiki-dark)");
8
+ function useHighlightedHtml(code, language) {
9
+ const [html, setHtml] = useState(null);
10
+ useEffect(() => {
11
+ let current = true;
12
+ setHtml(null);
13
+ highlightToHtml(code, language)
14
+ .then((highlighted) => {
15
+ if (current) {
16
+ setHtml(highlighted);
17
+ }
18
+ })
19
+ .catch(() => {
20
+ if (current) {
21
+ setHtml(null);
22
+ }
23
+ });
24
+ return () => {
25
+ current = false;
26
+ };
27
+ }, [code, language]);
28
+ return html;
29
+ }
30
+ export function Code({ code, language = "text", filename, showCopy = true, onCopy, className, ...props }) {
31
+ const html = useHighlightedHtml(code, language);
32
+ return (_jsxs("figure", { "data-slot": "code", "data-language": language, className: cn("min-w-0 bg-card text-card-foreground ring-1 ring-border", className), ...props, children: [_jsxs("figcaption", { className: "flex h-8 items-center justify-between gap-2 border-b pr-1 pl-3", children: [filename ? (_jsx("span", { className: "min-w-0 truncate font-mono text-xs text-foreground", children: filename })) : (_jsx("span", { className: "eyebrow", children: language })), _jsxs("span", { className: "flex shrink-0 items-center gap-2", children: [filename && _jsx("span", { className: "eyebrow", children: language }), showCopy && _jsx(CopyCodeButton, { code: code, onCopy: onCopy })] })] }), html ? (_jsx("div", { "data-slot": "code-area", className: codeAreaClass, dangerouslySetInnerHTML: { __html: html } })) : (_jsx("pre", { "data-slot": "code-area", className: codeAreaClass, children: _jsx("code", { children: code }) }))] }));
33
+ }
@@ -0,0 +1,6 @@
1
+ type CopyCodeButtonProps = {
2
+ code: string;
3
+ onCopy?: (code: string) => void;
4
+ };
5
+ export declare function CopyCodeButton({ code, onCopy }: CopyCodeButtonProps): import("react").JSX.Element;
6
+ export {};
@@ -0,0 +1,18 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Checkmark as CheckIcon, Copy as CopyIcon } from "@carbon/icons-react";
3
+ import { Button } from "@locusgraph/components";
4
+ import { useCopied, writeToClipboard } from "../use-copied.js";
5
+ export function CopyCodeButton({ code, onCopy }) {
6
+ const { copied, markCopied } = useCopied();
7
+ const copy = async () => {
8
+ if (onCopy) {
9
+ onCopy(code);
10
+ markCopied();
11
+ return;
12
+ }
13
+ if (await writeToClipboard(code)) {
14
+ markCopied();
15
+ }
16
+ };
17
+ return (_jsx(Button, { type: "button", variant: "ghost", size: "icon-xs", "aria-label": copied ? "Copied" : "Copy code", className: "text-muted-foreground hover:text-foreground", onClick: copy, children: copied ? _jsx(CheckIcon, { className: "text-good" }) : _jsx(CopyIcon, {}) }));
18
+ }
@@ -0,0 +1 @@
1
+ export declare function highlightToHtml(code: string, language: string): Promise<string | null>;
@@ -0,0 +1,39 @@
1
+ const lightTheme = "github-light";
2
+ const darkTheme = "github-dark";
3
+ let highlighter;
4
+ function loadHighlighter() {
5
+ highlighter ??= Promise.all([
6
+ import("shiki/core"),
7
+ import("shiki/engine/javascript"),
8
+ import("shiki/themes"),
9
+ ]).then(([core, engine, themes]) => core.createHighlighterCore({
10
+ themes: [themes.bundledThemes[lightTheme](), themes.bundledThemes[darkTheme]()],
11
+ langs: [],
12
+ engine: engine.createJavaScriptRegexEngine(),
13
+ }));
14
+ return highlighter;
15
+ }
16
+ async function loadLanguage(loaded, language) {
17
+ if (loaded.getLoadedLanguages().includes(language)) {
18
+ return true;
19
+ }
20
+ const { bundledLanguages } = await import("shiki/langs");
21
+ const loader = bundledLanguages[language];
22
+ if (!loader) {
23
+ return false;
24
+ }
25
+ await loaded.loadLanguage(loader());
26
+ return true;
27
+ }
28
+ export async function highlightToHtml(code, language) {
29
+ const normalized = language.toLowerCase();
30
+ const loaded = await loadHighlighter();
31
+ if (!(await loadLanguage(loaded, normalized))) {
32
+ return null;
33
+ }
34
+ return loaded.codeToHtml(code, {
35
+ lang: normalized,
36
+ themes: { light: lightTheme, dark: darkTheme },
37
+ defaultColor: false,
38
+ });
39
+ }
@@ -0,0 +1,14 @@
1
+ export type HistoryItem = {
2
+ id: string;
3
+ title: string;
4
+ updatedAt: string;
5
+ };
6
+ type HistoryRowProps = {
7
+ thread: HistoryItem;
8
+ active: boolean;
9
+ onSelect: (id: string) => void;
10
+ onRename?: (id: string, title: string) => void;
11
+ onArchive?: (id: string) => void;
12
+ };
13
+ export declare function HistoryRow({ thread, active, onSelect, onRename, onArchive }: HistoryRowProps): import("react").JSX.Element;
14
+ export {};
@@ -0,0 +1,17 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { cn } from "@locusgraph/components";
3
+ import { useState } from "react";
4
+ import { formatTimeOfDay } from "./thread-groups.js";
5
+ import { ThreadItemMenu } from "./thread-item-menu.js";
6
+ import { ThreadTitleEditor } from "./thread-title-editor.js";
7
+ const timeHiddenByMenuClass = "max-sm:hidden sm:group-focus-within:invisible sm:group-hover:invisible sm:group-has-[[data-state=open]]:invisible";
8
+ export function HistoryRow({ thread, active, onSelect, onRename, onArchive }) {
9
+ const [editing, setEditing] = useState(false);
10
+ const hasMenu = onRename !== undefined || onArchive !== undefined;
11
+ return (_jsxs("li", { "data-slot": "history-item", "data-active": active || undefined, className: cn("group relative flex items-center motion-safe:transition-colors", active
12
+ ? "bg-accent text-accent-foreground before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-foreground"
13
+ : "text-foreground/85 hover:bg-accent/40"), children: [editing && onRename ? (_jsx("div", { className: "flex-1 px-1 py-0.5", children: _jsx(ThreadTitleEditor, { title: thread.title, onCommit: (title) => {
14
+ onRename(thread.id, title);
15
+ setEditing(false);
16
+ }, onCancel: () => setEditing(false) }) })) : (_jsxs("button", { type: "button", "aria-current": active ? "page" : undefined, onClick: () => onSelect(thread.id), onDoubleClick: onRename ? () => setEditing(true) : undefined, className: cn("flex min-w-0 flex-1 items-center gap-3 py-1.5 pl-2 text-left text-sm outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring", hasMenu ? "pr-8 sm:pr-2" : "pr-2", active && "font-medium"), children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: thread.title }), _jsx("time", { dateTime: thread.updatedAt, suppressHydrationWarning: true, className: cn("shrink-0 font-mono text-[11px] font-normal text-muted-foreground tabular-nums", hasMenu && timeHiddenByMenuClass), children: formatTimeOfDay(thread.updatedAt) })] })), hasMenu && !editing && (_jsx("div", { className: "absolute top-1/2 right-1 -translate-y-1/2", children: _jsx(ThreadItemMenu, { title: thread.title, onRename: onRename ? () => setEditing(true) : undefined, onArchive: onArchive ? () => onArchive(thread.id) : undefined }) }))] }));
17
+ }
@@ -0,0 +1,15 @@
1
+ import type { ComponentProps } from "react";
2
+ import { type HistoryItem } from "./history-row.js";
3
+ type HistoryProps = Omit<ComponentProps<"nav">, "onSelect"> & {
4
+ threads: HistoryItem[];
5
+ activeId?: string | null;
6
+ onSelect: (id: string) => void;
7
+ onNew?: () => void;
8
+ onRename?: (id: string, title: string) => void;
9
+ onArchive?: (id: string) => void;
10
+ label?: string;
11
+ emptyText?: string;
12
+ now?: Date | string;
13
+ };
14
+ export declare function History({ threads, activeId, onSelect, onNew, onRename, onArchive, label, emptyText, now, className, ...props }: HistoryProps): import("react").JSX.Element;
15
+ export {};
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { Add as PlusIcon } from "@carbon/icons-react";
4
+ import { Button, cn, ScrollArea } from "@locusgraph/components";
5
+ import { HistoryRow } from "./history-row.js";
6
+ import { groupThreadsByDay } from "./thread-groups.js";
7
+ export function History({ threads, activeId = null, onSelect, onNew, onRename, onArchive, label = "Conversations", emptyText = "No conversations yet.", now = new Date(), className, ...props }) {
8
+ const groups = groupThreadsByDay(threads, now);
9
+ return (_jsxs("nav", { "data-slot": "history", "aria-label": label, className: cn("flex min-h-0 flex-col gap-2", className), ...props, children: [_jsxs("div", { className: "flex h-7 items-center justify-between gap-2 px-2", children: [_jsx("span", { className: "text-sm font-medium text-foreground", children: label }), onNew && (_jsxs(Button, { type: "button", variant: "outline", size: "xs", onClick: onNew, children: [_jsx(PlusIcon, {}), "New chat"] }))] }), threads.length === 0 ? (_jsx("p", { className: "px-2 py-6 text-sm text-muted-foreground", children: emptyText })) : (_jsx(ScrollArea, { className: "min-h-0 flex-1", children: _jsx("div", { className: "flex flex-col gap-4 pr-2.5 pb-2", children: groups.map((group) => (_jsxs("section", { "aria-labelledby": `thread-group-${group.key}`, children: [_jsx("h3", { id: `thread-group-${group.key}`, className: "eyebrow px-2 pb-1", suppressHydrationWarning: true, children: group.label }), _jsx("ul", { className: "flex flex-col", children: group.threads.map((thread) => (_jsx(HistoryRow, { thread: thread, active: thread.id === activeId, onSelect: onSelect, onRename: onRename, onArchive: onArchive }, thread.id))) })] }, group.key))) }) }))] }));
10
+ }
@@ -0,0 +1,8 @@
1
+ import type { HistoryItem } from "./history-row.js";
2
+ export type ThreadGroup = {
3
+ key: string;
4
+ label: string;
5
+ threads: HistoryItem[];
6
+ };
7
+ export declare function formatTimeOfDay(value: string): string;
8
+ export declare function groupThreadsByDay(threads: HistoryItem[], now: Date | string): ThreadGroup[];
@@ -0,0 +1,46 @@
1
+ const timeOfDay = new Intl.DateTimeFormat("en-US", {
2
+ hour: "2-digit",
3
+ minute: "2-digit",
4
+ hourCycle: "h23",
5
+ });
6
+ const calendarDate = new Intl.DateTimeFormat("en-US", { dateStyle: "medium" });
7
+ function localDayStart(value) {
8
+ const date = new Date(value);
9
+ if (Number.isNaN(date.getTime())) {
10
+ return undefined;
11
+ }
12
+ return new Date(date.getFullYear(), date.getMonth(), date.getDate());
13
+ }
14
+ function daysBetween(earlier, later) {
15
+ const utcOf = (date) => Date.UTC(date.getFullYear(), date.getMonth(), date.getDate());
16
+ return Math.round((utcOf(later) - utcOf(earlier)) / 86_400_000);
17
+ }
18
+ function dayLabel(day, today) {
19
+ if (!day) {
20
+ return "Earlier";
21
+ }
22
+ const daysAgo = today ? daysBetween(day, today) : Number.NaN;
23
+ if (daysAgo === 0) {
24
+ return "Today";
25
+ }
26
+ if (daysAgo === 1) {
27
+ return "Yesterday";
28
+ }
29
+ return calendarDate.format(day);
30
+ }
31
+ export function formatTimeOfDay(value) {
32
+ const date = new Date(value);
33
+ return Number.isNaN(date.getTime()) ? "" : timeOfDay.format(date);
34
+ }
35
+ export function groupThreadsByDay(threads, now) {
36
+ const today = localDayStart(now);
37
+ const groups = new Map();
38
+ for (const thread of threads) {
39
+ const day = localDayStart(thread.updatedAt);
40
+ const key = day ? String(day.getTime()) : "earlier";
41
+ const group = groups.get(key) ?? { key, label: dayLabel(day, today), threads: [] };
42
+ group.threads.push(thread);
43
+ groups.set(key, group);
44
+ }
45
+ return [...groups.values()];
46
+ }
@@ -0,0 +1,7 @@
1
+ type ThreadItemMenuProps = {
2
+ title: string;
3
+ onRename?: () => void;
4
+ onArchive?: () => void;
5
+ };
6
+ export declare function ThreadItemMenu({ title, onRename, onArchive }: ThreadItemMenuProps): import("react").JSX.Element;
7
+ export {};
@@ -0,0 +1,6 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Archive as ArchiveIcon, OverflowMenuHorizontal as EllipsisIcon, Edit as PencilIcon, } from "@carbon/icons-react";
3
+ import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@locusgraph/components";
4
+ export function ThreadItemMenu({ title, onRename, onArchive }) {
5
+ return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { type: "button", variant: "ghost", size: "icon-xs", "aria-label": `Options for ${title}`, className: "shrink-0 text-muted-foreground sm:opacity-0 sm:group-focus-within:opacity-100 sm:group-hover:opacity-100 sm:data-[state=open]:opacity-100", children: _jsx(EllipsisIcon, {}) }) }), _jsxs(DropdownMenuContent, { align: "end", children: [onRename && (_jsxs(DropdownMenuItem, { onSelect: onRename, children: [_jsx(PencilIcon, {}), "Rename"] })), onArchive && (_jsxs(DropdownMenuItem, { onSelect: onArchive, children: [_jsx(ArchiveIcon, {}), "Archive"] }))] })] }));
6
+ }
@@ -0,0 +1,7 @@
1
+ type ThreadTitleEditorProps = {
2
+ title: string;
3
+ onCommit: (title: string) => void;
4
+ onCancel: () => void;
5
+ };
6
+ export declare function ThreadTitleEditor({ title, onCommit, onCancel }: ThreadTitleEditorProps): import("react").JSX.Element;
7
+ export {};
@@ -0,0 +1,25 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { Input } from "@locusgraph/components";
3
+ import { useState } from "react";
4
+ export function ThreadTitleEditor({ title, onCommit, onCancel }) {
5
+ const [draft, setDraft] = useState(title);
6
+ const commit = () => {
7
+ const trimmed = draft.trim();
8
+ if (trimmed && trimmed !== title) {
9
+ onCommit(trimmed);
10
+ }
11
+ else {
12
+ onCancel();
13
+ }
14
+ };
15
+ return (_jsx(Input, { "data-slot": "thread-title-editor", "aria-label": "Chat title", autoFocus: true, value: draft, className: "h-7 text-sm", onChange: (event) => setDraft(event.target.value), onFocus: (event) => event.target.select(), onBlur: commit, onKeyDown: (event) => {
16
+ if (event.key === "Enter") {
17
+ event.preventDefault();
18
+ commit();
19
+ }
20
+ if (event.key === "Escape") {
21
+ event.preventDefault();
22
+ onCancel();
23
+ }
24
+ } }));
25
+ }
@@ -0,0 +1,8 @@
1
+ export * from "./actions/actions.js";
2
+ export type { MessageBranch } from "./actions/branch-switcher.js";
3
+ export * from "./canvas/canvas.js";
4
+ export type { CanvasVersion } from "./canvas/version-switcher.js";
5
+ export * from "./code/code.js";
6
+ export * from "./history/history.js";
7
+ export type { HistoryItem } from "./history/history-row.js";
8
+ export * from "./starters/starters.js";
@@ -0,0 +1,5 @@
1
+ export * from "./actions/actions.js";
2
+ export * from "./canvas/canvas.js";
3
+ export * from "./code/code.js";
4
+ export * from "./history/history.js";
5
+ export * from "./starters/starters.js";
@@ -0,0 +1,12 @@
1
+ import type { ComponentProps } from "react";
2
+ export type Starter = string | {
3
+ text: string;
4
+ label?: string;
5
+ };
6
+ type StartersProps = Omit<ComponentProps<"div">, "onSelect"> & {
7
+ suggestions: Starter[];
8
+ onSelect: (text: string) => void;
9
+ disabled?: boolean;
10
+ };
11
+ export declare function Starters({ suggestions, onSelect, disabled, className, ...props }: StartersProps): import("react").JSX.Element | null;
12
+ export {};
@@ -0,0 +1,15 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { ArrowUpRight as ArrowUpRightIcon } from "@carbon/icons-react";
3
+ import { cn } from "@locusgraph/components";
4
+ function textOf(suggestion) {
5
+ return typeof suggestion === "string" ? suggestion : suggestion.text;
6
+ }
7
+ function labelOf(suggestion) {
8
+ return typeof suggestion === "string" ? suggestion : (suggestion.label ?? suggestion.text);
9
+ }
10
+ export function Starters({ suggestions, onSelect, disabled = false, className, ...props }) {
11
+ if (suggestions.length === 0) {
12
+ return null;
13
+ }
14
+ return (_jsx("div", { "data-slot": "starters", role: "group", "aria-label": "Suggested prompts", className: cn("flex flex-col divide-y bg-card ring-1 ring-border", className), ...props, children: suggestions.map((suggestion) => (_jsxs("button", { type: "button", disabled: disabled, onClick: () => onSelect(textOf(suggestion)), className: "group flex w-full items-center gap-3 px-3 py-2.5 text-left text-sm outline-none hover:bg-accent/50 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 motion-safe:transition-colors", children: [_jsx("span", { className: "min-w-0 flex-1 text-pretty", children: labelOf(suggestion) }), _jsx(ArrowUpRightIcon, { "aria-hidden": true, className: "size-3.5 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 motion-safe:transition-opacity" })] }, textOf(suggestion)))) }));
15
+ }
@@ -0,0 +1,5 @@
1
+ export declare function useCopied(): {
2
+ copied: boolean;
3
+ markCopied: () => void;
4
+ };
5
+ export declare function writeToClipboard(text: string): Promise<boolean>;
@@ -0,0 +1,22 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+ const copiedDurationMs = 1500;
3
+ export function useCopied() {
4
+ const [copied, setCopied] = useState(false);
5
+ const timer = useRef(undefined);
6
+ useEffect(() => () => clearTimeout(timer.current), []);
7
+ const markCopied = () => {
8
+ setCopied(true);
9
+ clearTimeout(timer.current);
10
+ timer.current = setTimeout(() => setCopied(false), copiedDurationMs);
11
+ };
12
+ return { copied, markCopied };
13
+ }
14
+ export async function writeToClipboard(text) {
15
+ try {
16
+ await navigator.clipboard.writeText(text);
17
+ return true;
18
+ }
19
+ catch {
20
+ return false;
21
+ }
22
+ }