@nadicodeai/ui 0.20.0 → 0.22.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.
- package/AGENTS.md +4 -3
- package/README.md +14 -21
- package/dist/agents.d.ts +10 -0
- package/dist/agents.d.ts.map +1 -0
- package/dist/agents.js +9 -0
- package/dist/components/badge.d.ts +1 -1
- package/dist/components/brand-icons/apple.d.ts +18 -0
- package/dist/components/brand-icons/apple.d.ts.map +1 -0
- package/dist/components/brand-icons/apple.js +22 -0
- package/dist/components/brand-icons/brand-icon.d.ts +22 -0
- package/dist/components/brand-icons/brand-icon.d.ts.map +1 -0
- package/dist/components/brand-icons/brand-icon.js +26 -0
- package/dist/components/brand-icons/linux.d.ts +18 -0
- package/dist/components/brand-icons/linux.d.ts.map +1 -0
- package/dist/components/brand-icons/linux.js +25 -0
- package/dist/components/brand-icons/windows.d.ts +18 -0
- package/dist/components/brand-icons/windows.d.ts.map +1 -0
- package/dist/components/brand-icons/windows.js +22 -0
- package/dist/components/brand-icons.d.ts +5 -0
- package/dist/components/brand-icons.d.ts.map +1 -0
- package/dist/components/brand-icons.js +10 -0
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.js +1 -1
- package/dist/components/card-marketing.js +2 -2
- package/dist/components/card.d.ts +4 -3
- package/dist/components/card.d.ts.map +1 -1
- package/dist/components/card.js +12 -2
- package/dist/components/chart-breakdown-table.js +1 -1
- package/dist/components/chart-bullet-bar.d.ts +18 -2
- package/dist/components/chart-bullet-bar.d.ts.map +1 -1
- package/dist/components/chart-bullet-bar.js +62 -9
- package/dist/components/chart-date-range-control.d.ts +11 -1
- package/dist/components/chart-date-range-control.d.ts.map +1 -1
- package/dist/components/chart-date-range-control.js +13 -3
- package/dist/components/chart-entity-colors.d.ts +7 -1
- package/dist/components/chart-entity-colors.d.ts.map +1 -1
- package/dist/components/chart-entity-colors.js +7 -1
- package/dist/components/chart-kpi-stat.d.ts.map +1 -1
- package/dist/components/chart-kpi-stat.js +1 -1
- package/dist/components/chart-time-series.d.ts.map +1 -1
- package/dist/components/chart-time-series.js +62 -4
- package/dist/components/chart.js +2 -2
- package/dist/components/code-editor-mockup.js +1 -1
- package/dist/components/nav-bar.js +1 -1
- package/dist/components/radio-group.d.ts +1 -1
- package/dist/components/radio-group.d.ts.map +1 -1
- package/dist/components/radio-group.js +2 -2
- package/dist/components/theme-mode-switcher.d.ts +10 -3
- package/dist/components/theme-mode-switcher.d.ts.map +1 -1
- package/dist/components/theme-mode-switcher.js +14 -7
- package/dist/components/use-case-bento.d.ts +2 -4
- package/dist/components/use-case-bento.d.ts.map +1 -1
- package/dist/components/use-case-bento.js +2 -3
- package/dist/eslint/index.js +91 -0
- package/dist/eslint/rules/jsx-class-utility.js +231 -0
- package/dist/eslint/rules/no-deprecated-zod-api.js +156 -0
- package/dist/eslint/rules/no-design-system-src-import.js +11 -0
- package/dist/eslint/rules/no-invalid-token-utility.js +46 -0
- package/dist/eslint/rules/no-native-visible-control.js +86 -0
- package/dist/eslint/rules/no-raw-color-utility.js +109 -0
- package/dist/eslint/rules/no-raw-focus-ring-width.js +30 -0
- package/dist/eslint/rules/no-raw-logo-import.js +41 -0
- package/dist/eslint/rules/no-shadcn-appearance-override.js +191 -0
- package/dist/eslint/rules/no-token-category-bypass.js +53 -0
- package/dist/eslint/rules/no-ui-src-import.js +10 -0
- package/dist/eslint/rules/no-unpinned-vercel-functions-import.js +100 -0
- package/dist/eslint/rules/src-import-boundary.js +207 -0
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +0 -1
- package/dist/index.d.ts +1 -16
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -16
- package/dist/internal/assistant-ui/attachment.d.ts +5 -0
- package/dist/internal/assistant-ui/attachment.d.ts.map +1 -0
- package/dist/internal/assistant-ui/attachment.js +93 -0
- package/dist/internal/assistant-ui/follow-up-suggestions.d.ts +3 -0
- package/dist/internal/assistant-ui/follow-up-suggestions.d.ts.map +1 -0
- package/dist/internal/assistant-ui/follow-up-suggestions.js +8 -0
- package/dist/internal/assistant-ui/markdown-text.d.ts +2 -0
- package/dist/internal/assistant-ui/markdown-text.d.ts.map +1 -0
- package/dist/internal/assistant-ui/markdown-text.js +54 -0
- package/dist/internal/assistant-ui/reasoning.d.ts +31 -0
- package/dist/internal/assistant-ui/reasoning.d.ts.map +1 -0
- package/dist/internal/assistant-ui/reasoning.js +118 -0
- package/dist/internal/assistant-ui/thread.d.ts +26 -0
- package/dist/internal/assistant-ui/thread.d.ts.map +1 -0
- package/dist/internal/assistant-ui/thread.js +118 -0
- package/dist/internal/assistant-ui/tool-fallback.d.ts +10 -0
- package/dist/internal/assistant-ui/tool-fallback.d.ts.map +1 -0
- package/dist/internal/assistant-ui/tool-fallback.js +163 -0
- package/dist/internal/assistant-ui/tool-group.d.ts +18 -0
- package/dist/internal/assistant-ui/tool-group.d.ts.map +1 -0
- package/dist/internal/assistant-ui/tool-group.js +44 -0
- package/dist/internal/assistant-ui/tooltip-icon-button.d.ts +8 -0
- package/dist/internal/assistant-ui/tooltip-icon-button.d.ts.map +1 -0
- package/dist/internal/assistant-ui/tooltip-icon-button.js +10 -0
- package/dist/styles/globals.css +3 -209
- package/docs/agents/nadicodeai-ui.md +4 -6
- package/docs/component-classification.md +1 -1
- package/docs/consuming-cross-repo.md +32 -3
- package/docs/contract.md +16 -6
- package/docs/migration/base-ui-migration.md +0 -11
- package/docs/product-compositions.md +1 -1
- package/llms.txt +5 -6
- package/package.json +17 -29
- package/skills/nadicodeai-ui/SKILL.md +5 -7
- package/dist/ai-elements.d.ts +0 -49
- package/dist/ai-elements.d.ts.map +0 -1
- package/dist/ai-elements.js +0 -48
- package/dist/components/agent-avatar.d.ts +0 -7
- package/dist/components/agent-avatar.d.ts.map +0 -1
- package/dist/components/agent-avatar.js +0 -6
- package/dist/components/agent-chat.d.ts +0 -20
- package/dist/components/agent-chat.d.ts.map +0 -1
- package/dist/components/agent-chat.js +0 -10
- package/dist/components/agent-composer.d.ts +0 -56
- package/dist/components/agent-composer.d.ts.map +0 -1
- package/dist/components/agent-composer.js +0 -56
- package/dist/components/agent-message.d.ts +0 -117
- package/dist/components/agent-message.d.ts.map +0 -1
- package/dist/components/agent-message.js +0 -99
- package/dist/components/agent-thread.d.ts +0 -26
- package/dist/components/agent-thread.d.ts.map +0 -1
- package/dist/components/agent-thread.js +0 -63
- package/dist/components/agent-tool-approval.d.ts +0 -27
- package/dist/components/agent-tool-approval.d.ts.map +0 -1
- package/dist/components/agent-tool-approval.js +0 -43
- package/dist/components/ai-elements/agent.d.ts +0 -27
- package/dist/components/ai-elements/agent.d.ts.map +0 -1
- package/dist/components/ai-elements/agent.js +0 -25
- package/dist/components/ai-elements/artifact.d.ts +0 -24
- package/dist/components/ai-elements/artifact.d.ts.map +0 -1
- package/dist/components/ai-elements/artifact.js +0 -20
- package/dist/components/ai-elements/attachments.d.ts +0 -55
- package/dist/components/ai-elements/attachments.d.ts.map +0 -1
- package/dist/components/ai-elements/attachments.js +0 -125
- package/dist/components/ai-elements/audio-player.d.ts +0 -30
- package/dist/components/ai-elements/audio-player.d.ts.map +0 -1
- package/dist/components/ai-elements/audio-player.js +0 -41
- package/dist/components/ai-elements/canvas.d.ts +0 -8
- package/dist/components/ai-elements/canvas.d.ts.map +0 -1
- package/dist/components/ai-elements/canvas.js +0 -5
- package/dist/components/ai-elements/chain-of-thought.d.ts +0 -30
- package/dist/components/ai-elements/chain-of-thought.d.ts.map +0 -1
- package/dist/components/ai-elements/chain-of-thought.js +0 -49
- package/dist/components/ai-elements/checkpoint.d.ts +0 -12
- package/dist/components/ai-elements/checkpoint.d.ts.map +0 -1
- package/dist/components/ai-elements/checkpoint.js +0 -10
- package/dist/components/ai-elements/code-block.d.ts +0 -53
- package/dist/components/ai-elements/code-block.d.ts.map +0 -1
- package/dist/components/ai-elements/code-block.js +0 -239
- package/dist/components/ai-elements/commit.d.ts +0 -65
- package/dist/components/ai-elements/commit.d.ts.map +0 -1
- package/dist/components/ai-elements/commit.js +0 -83
- package/dist/components/ai-elements/confirmation.d.ts +0 -50
- package/dist/components/ai-elements/confirmation.d.ts.map +0 -1
- package/dist/components/ai-elements/confirmation.js +0 -57
- package/dist/components/ai-elements/connection.d.ts +0 -6
- package/dist/components/ai-elements/connection.d.ts.map +0 -1
- package/dist/components/ai-elements/connection.js +0 -10
- package/dist/components/ai-elements/context.d.ts +0 -33
- package/dist/components/ai-elements/context.d.ts.map +0 -1
- package/dist/components/ai-elements/context.js +0 -147
- package/dist/components/ai-elements/controls.d.ts +0 -5
- package/dist/components/ai-elements/controls.d.ts.map +0 -1
- package/dist/components/ai-elements/controls.js +0 -5
- package/dist/components/ai-elements/conversation.d.ts +0 -24
- package/dist/components/ai-elements/conversation.d.ts.map +0 -1
- package/dist/components/ai-elements/conversation.js +0 -41
- package/dist/components/ai-elements/edge.d.ts +0 -6
- package/dist/components/ai-elements/edge.d.ts.map +0 -1
- package/dist/components/ai-elements/edge.js +0 -88
- package/dist/components/ai-elements/environment-variables.d.ts +0 -39
- package/dist/components/ai-elements/environment-variables.d.ts.map +0 -1
- package/dist/components/ai-elements/environment-variables.js +0 -60
- package/dist/components/ai-elements/file-tree.d.ts +0 -27
- package/dist/components/ai-elements/file-tree.d.ts.map +0 -1
- package/dist/components/ai-elements/file-tree.js +0 -73
- package/dist/components/ai-elements/image.d.ts +0 -7
- package/dist/components/ai-elements/image.d.ts.map +0 -1
- package/dist/components/ai-elements/image.js +0 -3
- package/dist/components/ai-elements/inline-citation.d.ts +0 -39
- package/dist/components/ai-elements/inline-citation.d.ts.map +0 -1
- package/dist/components/ai-elements/inline-citation.js +0 -86
- package/dist/components/ai-elements/jsx-preview.d.ts +0 -30
- package/dist/components/ai-elements/jsx-preview.d.ts.map +0 -1
- package/dist/components/ai-elements/jsx-preview.js +0 -159
- package/dist/components/ai-elements/message.d.ts +0 -38
- package/dist/components/ai-elements/message.d.ts.map +0 -1
- package/dist/components/ai-elements/message.js +0 -91
- package/dist/components/ai-elements/mic-selector.d.ts +0 -46
- package/dist/components/ai-elements/mic-selector.d.ts.map +0 -1
- package/dist/components/ai-elements/mic-selector.js +0 -180
- package/dist/components/ai-elements/model-selector.d.ts +0 -36
- package/dist/components/ai-elements/model-selector.d.ts.map +0 -1
- package/dist/components/ai-elements/model-selector.js +0 -18
- package/dist/components/ai-elements/node.d.ts +0 -22
- package/dist/components/ai-elements/node.d.ts.map +0 -1
- package/dist/components/ai-elements/node.js +0 -12
- package/dist/components/ai-elements/open-in-chat.d.ts +0 -27
- package/dist/components/ai-elements/open-in-chat.d.ts.map +0 -1
- package/dist/components/ai-elements/open-in-chat.js +0 -81
- package/dist/components/ai-elements/package-info.d.ts +0 -30
- package/dist/components/ai-elements/package-info.d.ts.map +0 -1
- package/dist/components/ai-elements/package-info.js +0 -50
- package/dist/components/ai-elements/panel.d.ts +0 -6
- package/dist/components/ai-elements/panel.d.ts.map +0 -1
- package/dist/components/ai-elements/panel.js +0 -5
- package/dist/components/ai-elements/persona.d.ts +0 -49
- package/dist/components/ai-elements/persona.d.ts.map +0 -1
- package/dist/components/ai-elements/persona.js +0 -175
- package/dist/components/ai-elements/plan.d.ts +0 -27
- package/dist/components/ai-elements/plan.d.ts.map +0 -1
- package/dist/components/ai-elements/plan.js +0 -34
- package/dist/components/ai-elements/prompt-input.d.ts +0 -149
- package/dist/components/ai-elements/prompt-input.d.ts.map +0 -1
- package/dist/components/ai-elements/prompt-input.js +0 -704
- package/dist/components/ai-elements/queue.d.ts +0 -62
- package/dist/components/ai-elements/queue.d.ts.map +0 -1
- package/dist/components/ai-elements/queue.js +0 -24
- package/dist/components/ai-elements/reasoning.d.ts +0 -27
- package/dist/components/ai-elements/reasoning.d.ts.map +0 -1
- package/dist/components/ai-elements/reasoning.js +0 -92
- package/dist/components/ai-elements/sandbox.d.ts +0 -25
- package/dist/components/ai-elements/sandbox.d.ts.map +0 -1
- package/dist/components/ai-elements/sandbox.js +0 -15
- package/dist/components/ai-elements/schema-display.d.ts +0 -56
- package/dist/components/ai-elements/schema-display.d.ts.map +0 -1
- package/dist/components/ai-elements/schema-display.js +0 -90
- package/dist/components/ai-elements/shimmer.d.ts +0 -10
- package/dist/components/ai-elements/shimmer.d.ts.map +0 -1
- package/dist/components/ai-elements/shimmer.js +0 -11
- package/dist/components/ai-elements/snippet.d.ts +0 -19
- package/dist/components/ai-elements/snippet.d.ts.map +0 -1
- package/dist/components/ai-elements/snippet.js +0 -32
- package/dist/components/ai-elements/sources.d.ts +0 -13
- package/dist/components/ai-elements/sources.d.ts.map +0 -1
- package/dist/components/ai-elements/sources.js +0 -9
- package/dist/components/ai-elements/speech-input.d.ts +0 -55
- package/dist/components/ai-elements/speech-input.d.ts.map +0 -1
- package/dist/components/ai-elements/speech-input.js +0 -187
- package/dist/components/ai-elements/stack-trace.d.ts +0 -38
- package/dist/components/ai-elements/stack-trace.d.ts.map +0 -1
- package/dist/components/ai-elements/stack-trace.js +0 -181
- package/dist/components/ai-elements/suggestion.d.ts +0 -11
- package/dist/components/ai-elements/suggestion.d.ts.map +0 -1
- package/dist/components/ai-elements/suggestion.js +0 -13
- package/dist/components/ai-elements/task.d.ts +0 -15
- package/dist/components/ai-elements/task.d.ts.map +0 -1
- package/dist/components/ai-elements/task.js +0 -10
- package/dist/components/ai-elements/terminal.d.ts +0 -28
- package/dist/components/ai-elements/terminal.d.ts.map +0 -1
- package/dist/components/ai-elements/terminal.js +0 -55
- package/dist/components/ai-elements/test-results.d.ts +0 -59
- package/dist/components/ai-elements/test-results.d.ts.map +0 -1
- package/dist/components/ai-elements/test-results.js +0 -98
- package/dist/components/ai-elements/tool.d.ts +0 -32
- package/dist/components/ai-elements/tool.d.ts.map +0 -1
- package/dist/components/ai-elements/tool.js +0 -49
- package/dist/components/ai-elements/toolbar.d.ts +0 -6
- package/dist/components/ai-elements/toolbar.d.ts.map +0 -1
- package/dist/components/ai-elements/toolbar.js +0 -5
- package/dist/components/ai-elements/transcription.d.ts +0 -17
- package/dist/components/ai-elements/transcription.d.ts.map +0 -1
- package/dist/components/ai-elements/transcription.js +0 -36
- package/dist/components/ai-elements/voice-selector.d.ts +0 -65
- package/dist/components/ai-elements/voice-selector.d.ts.map +0 -1
- package/dist/components/ai-elements/voice-selector.js +0 -224
- package/dist/components/ai-elements/web-preview.d.ts +0 -35
- package/dist/components/ai-elements/web-preview.d.ts.map +0 -1
- package/dist/components/ai-elements/web-preview.js +0 -66
- package/dist/components/artifact-panel.d.ts +0 -130
- package/dist/components/artifact-panel.d.ts.map +0 -1
- package/dist/components/artifact-panel.js +0 -180
- package/dist/components/attachment.d.ts +0 -24
- package/dist/components/attachment.d.ts.map +0 -1
- package/dist/components/attachment.js +0 -68
- package/dist/components/bubble.d.ts +0 -17
- package/dist/components/bubble.d.ts.map +0 -1
- package/dist/components/bubble.js +0 -59
- package/dist/components/demo-surface.d.ts +0 -34
- package/dist/components/demo-surface.d.ts.map +0 -1
- package/dist/components/demo-surface.js +0 -21
- package/dist/components/files-preview.d.ts +0 -36
- package/dist/components/files-preview.d.ts.map +0 -1
- package/dist/components/files-preview.js +0 -85
- package/dist/components/marker.d.ts +0 -11
- package/dist/components/marker.d.ts.map +0 -1
- package/dist/components/marker.js +0 -34
- package/dist/components/message-scroller.d.ts +0 -17
- package/dist/components/message-scroller.d.ts.map +0 -1
- package/dist/components/message-scroller.js +0 -29
- package/dist/components/message.d.ts +0 -11
- package/dist/components/message.d.ts.map +0 -1
- package/dist/components/message.js +0 -21
- package/dist/components/state-notice.d.ts +0 -13
- package/dist/components/state-notice.d.ts.map +0 -1
- package/dist/components/state-notice.js +0 -8
- package/dist/components/watch-it-work-band.d.ts +0 -12
- package/dist/components/watch-it-work-band.d.ts.map +0 -1
- package/dist/components/watch-it-work-band.js +0 -8
- package/dist/hooks/use-controllable-state.d.ts +0 -9
- package/dist/hooks/use-controllable-state.d.ts.map +0 -1
- package/dist/hooks/use-controllable-state.js +0 -23
- package/dist/lib/agent-attachment.d.ts +0 -11
- package/dist/lib/agent-attachment.d.ts.map +0 -1
- package/dist/lib/agent-attachment.js +0 -19
- package/dist/lib/agent-contracts.d.ts +0 -132
- package/dist/lib/agent-contracts.d.ts.map +0 -1
- package/dist/lib/agent-contracts.js +0 -6
- package/dist/lib/agent-state.d.ts +0 -22
- package/dist/lib/agent-state.d.ts.map +0 -1
- package/dist/lib/agent-state.js +0 -96
- package/dist/lib/agent-work-state.d.ts +0 -36
- package/dist/lib/agent-work-state.d.ts.map +0 -1
- package/dist/lib/agent-work-state.js +0 -36
- package/dist/lib/message-scroller-primitive/components.d.ts +0 -17
- package/dist/lib/message-scroller-primitive/components.d.ts.map +0 -1
- package/dist/lib/message-scroller-primitive/components.js +0 -204
- package/dist/lib/message-scroller-primitive/geometry.d.ts +0 -51
- package/dist/lib/message-scroller-primitive/geometry.d.ts.map +0 -1
- package/dist/lib/message-scroller-primitive/geometry.js +0 -199
- package/dist/lib/message-scroller-primitive/index.d.ts +0 -12
- package/dist/lib/message-scroller-primitive/index.d.ts.map +0 -1
- package/dist/lib/message-scroller-primitive/index.js +0 -12
- package/dist/lib/message-scroller-primitive/stores.d.ts +0 -6
- package/dist/lib/message-scroller-primitive/stores.d.ts.map +0 -1
- package/dist/lib/message-scroller-primitive/stores.js +0 -53
- package/dist/lib/message-scroller-primitive/types.d.ts +0 -88
- package/dist/lib/message-scroller-primitive/types.d.ts.map +0 -1
- package/dist/lib/message-scroller-primitive/types.js +0 -40
- package/dist/lib/message-scroller-primitive/use-message-scroller-commands.d.ts +0 -19
- package/dist/lib/message-scroller-primitive/use-message-scroller-commands.d.ts.map +0 -1
- package/dist/lib/message-scroller-primitive/use-message-scroller-commands.js +0 -188
- package/dist/lib/message-scroller-primitive/use-message-scroller-controller.d.ts +0 -7
- package/dist/lib/message-scroller-primitive/use-message-scroller-controller.d.ts.map +0 -1
- package/dist/lib/message-scroller-primitive/use-message-scroller-controller.js +0 -506
- package/dist/lib/message-scroller-primitive/use-message-scroller-refs.d.ts +0 -49
- package/dist/lib/message-scroller-primitive/use-message-scroller-refs.d.ts.map +0 -1
- package/dist/lib/message-scroller-primitive/use-message-scroller-refs.js +0 -90
- package/dist/lib/message-scroller-primitive/use-render.d.ts +0 -22
- package/dist/lib/message-scroller-primitive/use-render.d.ts.map +0 -1
- package/dist/lib/message-scroller-primitive/use-render.js +0 -113
- package/dist/lib/message-scroller-primitive/utils.d.ts +0 -4
- package/dist/lib/message-scroller-primitive/utils.d.ts.map +0 -1
- package/dist/lib/message-scroller-primitive/utils.js +0 -9
- package/docs/agent-work-surfaces.md +0 -132
- package/docs/migration/ai-elements-vendoring.md +0 -29
- package/docs/terminal-tui-semantics.md +0 -172
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { Button } from "../button";
|
|
2
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../select";
|
|
3
|
-
import type { ComponentProps, HTMLAttributes } from "react";
|
|
4
|
-
import type { BundledLanguage, ThemedToken } from "shiki";
|
|
5
|
-
type CodeThemeToken = ThemedToken & {
|
|
6
|
-
darkBgColor?: string;
|
|
7
|
-
darkColor?: string;
|
|
8
|
-
darkFontStyle?: ThemedToken["fontStyle"];
|
|
9
|
-
};
|
|
10
|
-
type CodeBlockProps = HTMLAttributes<HTMLDivElement> & {
|
|
11
|
-
code: string;
|
|
12
|
-
language: BundledLanguage;
|
|
13
|
-
showLineNumbers?: boolean;
|
|
14
|
-
};
|
|
15
|
-
interface TokenizedCode {
|
|
16
|
-
tokens: CodeThemeToken[][];
|
|
17
|
-
fg: string;
|
|
18
|
-
bg: string;
|
|
19
|
-
darkFg: string;
|
|
20
|
-
darkBg: string;
|
|
21
|
-
}
|
|
22
|
-
export declare const highlightCode: (code: string, language: BundledLanguage, callback?: (result: TokenizedCode) => void) => TokenizedCode | null;
|
|
23
|
-
export declare const CodeBlockContainer: ({ className, language, style, ...props }: HTMLAttributes<HTMLDivElement> & {
|
|
24
|
-
language: string;
|
|
25
|
-
}) => import("react").JSX.Element;
|
|
26
|
-
export declare const CodeBlockHeader: ({ children, className, ...props }: HTMLAttributes<HTMLDivElement>) => import("react").JSX.Element;
|
|
27
|
-
export declare const CodeBlockTitle: ({ children, className, ...props }: HTMLAttributes<HTMLDivElement>) => import("react").JSX.Element;
|
|
28
|
-
export declare const CodeBlockFilename: ({ children, className, ...props }: HTMLAttributes<HTMLSpanElement>) => import("react").JSX.Element;
|
|
29
|
-
export declare const CodeBlockActions: ({ children, className, ...props }: HTMLAttributes<HTMLDivElement>) => import("react").JSX.Element;
|
|
30
|
-
export declare const CodeBlockContent: ({ code, language, showLineNumbers, }: {
|
|
31
|
-
code: string;
|
|
32
|
-
language: BundledLanguage;
|
|
33
|
-
showLineNumbers?: boolean;
|
|
34
|
-
}) => import("react").JSX.Element;
|
|
35
|
-
export declare const CodeBlock: ({ code, language, showLineNumbers, className, children, ...props }: CodeBlockProps) => import("react").JSX.Element;
|
|
36
|
-
export type CodeBlockCopyButtonProps = ComponentProps<typeof Button> & {
|
|
37
|
-
onCopy?: () => void;
|
|
38
|
-
onError?: (error: Error) => void;
|
|
39
|
-
timeout?: number;
|
|
40
|
-
};
|
|
41
|
-
export declare const CodeBlockCopyButton: ({ onCopy, onError, timeout, children, className, ...props }: CodeBlockCopyButtonProps) => import("react").JSX.Element;
|
|
42
|
-
export type CodeBlockLanguageSelectorProps = ComponentProps<typeof Select>;
|
|
43
|
-
export declare const CodeBlockLanguageSelector: (props: CodeBlockLanguageSelectorProps) => import("react").JSX.Element;
|
|
44
|
-
export type CodeBlockLanguageSelectorTriggerProps = ComponentProps<typeof SelectTrigger>;
|
|
45
|
-
export declare const CodeBlockLanguageSelectorTrigger: ({ className, ...props }: CodeBlockLanguageSelectorTriggerProps) => import("react").JSX.Element;
|
|
46
|
-
export type CodeBlockLanguageSelectorValueProps = ComponentProps<typeof SelectValue>;
|
|
47
|
-
export declare const CodeBlockLanguageSelectorValue: (props: CodeBlockLanguageSelectorValueProps) => import("react").JSX.Element;
|
|
48
|
-
export type CodeBlockLanguageSelectorContentProps = ComponentProps<typeof SelectContent>;
|
|
49
|
-
export declare const CodeBlockLanguageSelectorContent: ({ align, ...props }: CodeBlockLanguageSelectorContentProps) => import("react").JSX.Element;
|
|
50
|
-
export type CodeBlockLanguageSelectorItemProps = ComponentProps<typeof SelectItem>;
|
|
51
|
-
export declare const CodeBlockLanguageSelectorItem: (props: CodeBlockLanguageSelectorItemProps) => import("react").JSX.Element;
|
|
52
|
-
export {};
|
|
53
|
-
//# sourceMappingURL=code-block.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"code-block.d.ts","sourceRoot":"","sources":["../../../src/components/ai-elements/code-block.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIpG,OAAO,KAAK,EAAE,cAAc,EAAiB,cAAc,EAAE,MAAM,OAAO,CAAC;AAE3E,OAAO,KAAK,EACV,eAAe,EAGf,WAAW,EAEZ,MAAM,OAAO,CAAC;AAYf,KAAK,cAAc,GAAG,WAAW,GAAG;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,WAAW,CAAC,WAAW,CAAC,CAAC;CAC1C,CAAC;AAqFF,KAAK,cAAc,GAAG,cAAc,CAAC,cAAc,CAAC,GAAG;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,eAAe,CAAC;IAC1B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,UAAU,aAAa;IACrB,MAAM,EAAE,cAAc,EAAE,EAAE,CAAC;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM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AE9E,CAAC;AAEF,MAAM,MAAM,qCAAqC,GAAG,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC;AAEzF,eAAO,MAAM,gCAAgC,GAAI,yBAG9C,qCAAqC,gCAMvC,CAAC;AAEF,MAAM,MAAM,mCAAmC,GAAG,cAAc,CAAC,OAAO,WAAW,CAAC,CAAC;AAErF,eAAO,MAAM,8BAA8B,GAAI,OAAO,mCAAmC,gCAExF,CAAC;AAEF,MAAM,MAAM,qCAAqC,GAAG,cAAc,CAAC,OAAO,aAAa,CAAC,CAAC;AAEzF,eAAO,MAAM,gCAAgC,GAAI,qBAG9C,qCAAqC,gCAA+C,CAAC;AAExF,MAAM,MAAM,kCAAkC,GAAG,cAAc,CAAC,OAAO,UAAU,CAAC,CAAC;AAEnF,eAAO,MAAM,6BAA6B,GAAI,OAAO,kCAAkC,gCAEtF,CAAC"}
|
|
@@ -1,239 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Button } from "../button.js";
|
|
4
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../select.js";
|
|
5
|
-
import { cn } from "../../lib/utils.js";
|
|
6
|
-
import { useCopyToClipboard } from "../../lib/use-copy-to-clipboard.js";
|
|
7
|
-
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
8
|
-
import { createContext, memo, useContext, useEffect, useMemo, useState } from "react";
|
|
9
|
-
import { createHighlighter } from "shiki";
|
|
10
|
-
// Shiki uses bitflags for font styles: 1=italic, 2=bold, 4=underline
|
|
11
|
-
// oxlint-disable-next-line eslint(no-bitwise)
|
|
12
|
-
const isItalic = (fontStyle) => fontStyle && fontStyle & 1;
|
|
13
|
-
// oxlint-disable-next-line eslint(no-bitwise)
|
|
14
|
-
const isBold = (fontStyle) => fontStyle && fontStyle & 2;
|
|
15
|
-
const isUnderline = (fontStyle) =>
|
|
16
|
-
// oxlint-disable-next-line eslint(no-bitwise)
|
|
17
|
-
fontStyle && fontStyle & 4;
|
|
18
|
-
const addKeysToTokens = (lines) => lines.map((line, lineIdx) => ({
|
|
19
|
-
key: `line-${lineIdx}`,
|
|
20
|
-
tokens: line.map((token, tokenIdx) => ({
|
|
21
|
-
key: `line-${lineIdx}-${tokenIdx}`,
|
|
22
|
-
token,
|
|
23
|
-
})),
|
|
24
|
-
}));
|
|
25
|
-
const tokenStyle = (token) => {
|
|
26
|
-
const htmlStyle = { ...token.htmlStyle };
|
|
27
|
-
delete htmlStyle.background;
|
|
28
|
-
delete htmlStyle.backgroundColor;
|
|
29
|
-
delete htmlStyle.color;
|
|
30
|
-
delete htmlStyle.fontStyle;
|
|
31
|
-
delete htmlStyle.fontWeight;
|
|
32
|
-
delete htmlStyle.textDecoration;
|
|
33
|
-
const darkFontStyle = token.darkFontStyle ?? token.fontStyle;
|
|
34
|
-
return {
|
|
35
|
-
...htmlStyle,
|
|
36
|
-
"--shiki-code-token-dark-bg": token.darkBgColor ?? token.bgColor,
|
|
37
|
-
"--shiki-code-token-dark-color": token.darkColor ?? token.color,
|
|
38
|
-
"--shiki-code-token-dark-font-style": isItalic(darkFontStyle) ? "italic" : "normal",
|
|
39
|
-
"--shiki-code-token-dark-font-weight": isBold(darkFontStyle) ? "bold" : "normal",
|
|
40
|
-
"--shiki-code-token-dark-text-decoration": isUnderline(darkFontStyle) ? "underline" : "none",
|
|
41
|
-
"--shiki-code-token-light-bg": token.bgColor,
|
|
42
|
-
"--shiki-code-token-light-color": token.color,
|
|
43
|
-
"--shiki-code-token-light-font-style": isItalic(token.fontStyle) ? "italic" : "normal",
|
|
44
|
-
"--shiki-code-token-light-font-weight": isBold(token.fontStyle) ? "bold" : "normal",
|
|
45
|
-
"--shiki-code-token-light-text-decoration": isUnderline(token.fontStyle) ? "underline" : "none",
|
|
46
|
-
};
|
|
47
|
-
};
|
|
48
|
-
// Syntax colors are resolved by the shared UI globals stylesheet so light/dark
|
|
49
|
-
// can switch without re-tokenizing. Importing that stylesheet is part of the
|
|
50
|
-
// package contract for CodeBlock consumers.
|
|
51
|
-
const TokenSpan = ({ token }) => (_jsx("span", { "data-nc-code-token": "", style: tokenStyle(token), children: token.content }));
|
|
52
|
-
// Line number styles using CSS counters
|
|
53
|
-
const LINE_NUMBER_CLASSES = cn("block", "before:content-[counter(line)]", "before:inline-block", "before:[counter-increment:line]", "before:w-8", "before:mr-4", "before:text-right", "before:text-muted-foreground/50", "before:font-mono", "before:select-none");
|
|
54
|
-
// Line rendering component
|
|
55
|
-
const LineSpan = ({ keyedLine, showLineNumbers, }) => (_jsx("span", { className: showLineNumbers ? LINE_NUMBER_CLASSES : "block", children: keyedLine.tokens.length === 0
|
|
56
|
-
? "\n"
|
|
57
|
-
: keyedLine.tokens.map(({ token, key }) => _jsx(TokenSpan, { token: token }, key)) }));
|
|
58
|
-
// Context
|
|
59
|
-
const CodeBlockContext = createContext({
|
|
60
|
-
code: "",
|
|
61
|
-
});
|
|
62
|
-
// Highlighter cache (singleton per language)
|
|
63
|
-
const highlighterCache = new Map();
|
|
64
|
-
// Token cache
|
|
65
|
-
const tokensCache = new Map();
|
|
66
|
-
// Subscribers for async token updates
|
|
67
|
-
const subscribers = new Map();
|
|
68
|
-
const getTokensCacheKey = (code, language) => {
|
|
69
|
-
const start = code.slice(0, 100);
|
|
70
|
-
const end = code.length > 100 ? code.slice(-100) : "";
|
|
71
|
-
return `${language}:${code.length}:${start}:${end}`;
|
|
72
|
-
};
|
|
73
|
-
const getHighlighter = (language) => {
|
|
74
|
-
const cached = highlighterCache.get(language);
|
|
75
|
-
if (cached) {
|
|
76
|
-
return cached;
|
|
77
|
-
}
|
|
78
|
-
const highlighterPromise = createHighlighter({
|
|
79
|
-
langs: [language],
|
|
80
|
-
themes: ["github-light", "github-dark"],
|
|
81
|
-
});
|
|
82
|
-
highlighterCache.set(language, highlighterPromise);
|
|
83
|
-
return highlighterPromise;
|
|
84
|
-
};
|
|
85
|
-
const tokenFromThemeVariants = (token) => {
|
|
86
|
-
const light = token.variants.light ?? {};
|
|
87
|
-
const dark = token.variants.dark ?? light;
|
|
88
|
-
return {
|
|
89
|
-
bgColor: light.bgColor,
|
|
90
|
-
color: light.color,
|
|
91
|
-
content: token.content,
|
|
92
|
-
darkBgColor: dark.bgColor,
|
|
93
|
-
darkColor: dark.color,
|
|
94
|
-
darkFontStyle: dark.fontStyle,
|
|
95
|
-
fontStyle: light.fontStyle,
|
|
96
|
-
htmlStyle: light.htmlStyle,
|
|
97
|
-
offset: token.offset,
|
|
98
|
-
};
|
|
99
|
-
};
|
|
100
|
-
// Create raw tokens for immediate display while highlighting loads
|
|
101
|
-
const createRawTokens = (code) => ({
|
|
102
|
-
bg: "transparent",
|
|
103
|
-
darkBg: "transparent",
|
|
104
|
-
darkFg: "inherit",
|
|
105
|
-
fg: "inherit",
|
|
106
|
-
tokens: code.split("\n").map((line) => line === ""
|
|
107
|
-
? []
|
|
108
|
-
: [
|
|
109
|
-
{
|
|
110
|
-
color: "inherit",
|
|
111
|
-
content: line,
|
|
112
|
-
darkColor: "inherit",
|
|
113
|
-
darkFontStyle: undefined,
|
|
114
|
-
},
|
|
115
|
-
]),
|
|
116
|
-
});
|
|
117
|
-
// Synchronous highlight with callback for async results
|
|
118
|
-
export const highlightCode = (code, language,
|
|
119
|
-
// oxlint-disable-next-line eslint-plugin-promise(prefer-await-to-callbacks)
|
|
120
|
-
callback) => {
|
|
121
|
-
const tokensCacheKey = getTokensCacheKey(code, language);
|
|
122
|
-
// Return cached result if available
|
|
123
|
-
const cached = tokensCache.get(tokensCacheKey);
|
|
124
|
-
if (cached) {
|
|
125
|
-
return cached;
|
|
126
|
-
}
|
|
127
|
-
// Subscribe callback if provided
|
|
128
|
-
if (callback) {
|
|
129
|
-
if (!subscribers.has(tokensCacheKey)) {
|
|
130
|
-
subscribers.set(tokensCacheKey, new Set());
|
|
131
|
-
}
|
|
132
|
-
subscribers.get(tokensCacheKey)?.add(callback);
|
|
133
|
-
}
|
|
134
|
-
// Start highlighting in background - fire-and-forget async pattern
|
|
135
|
-
getHighlighter(language)
|
|
136
|
-
// oxlint-disable-next-line eslint-plugin-promise(prefer-await-to-then)
|
|
137
|
-
.then((highlighter) => {
|
|
138
|
-
const availableLangs = highlighter.getLoadedLanguages();
|
|
139
|
-
const langToUse = availableLangs.includes(language) ? language : "text";
|
|
140
|
-
const tokens = highlighter.codeToTokensWithThemes(code, {
|
|
141
|
-
lang: langToUse,
|
|
142
|
-
themes: {
|
|
143
|
-
dark: "github-dark",
|
|
144
|
-
light: "github-light",
|
|
145
|
-
},
|
|
146
|
-
});
|
|
147
|
-
const lightTheme = highlighter.getTheme("github-light");
|
|
148
|
-
const darkTheme = highlighter.getTheme("github-dark");
|
|
149
|
-
const tokenized = {
|
|
150
|
-
bg: lightTheme.bg ?? "transparent",
|
|
151
|
-
darkBg: darkTheme.bg ?? "transparent",
|
|
152
|
-
darkFg: darkTheme.fg ?? "inherit",
|
|
153
|
-
fg: lightTheme.fg ?? "inherit",
|
|
154
|
-
tokens: tokens.map((line) => line.map(tokenFromThemeVariants)),
|
|
155
|
-
};
|
|
156
|
-
// Cache the result
|
|
157
|
-
tokensCache.set(tokensCacheKey, tokenized);
|
|
158
|
-
// Notify all subscribers
|
|
159
|
-
const subs = subscribers.get(tokensCacheKey);
|
|
160
|
-
if (subs) {
|
|
161
|
-
for (const sub of subs) {
|
|
162
|
-
sub(tokenized);
|
|
163
|
-
}
|
|
164
|
-
subscribers.delete(tokensCacheKey);
|
|
165
|
-
}
|
|
166
|
-
})
|
|
167
|
-
// oxlint-disable-next-line eslint-plugin-promise(prefer-await-to-then), eslint-plugin-promise(prefer-await-to-callbacks)
|
|
168
|
-
.catch((error) => {
|
|
169
|
-
console.error("Failed to highlight code:", error);
|
|
170
|
-
subscribers.delete(tokensCacheKey);
|
|
171
|
-
});
|
|
172
|
-
return null;
|
|
173
|
-
};
|
|
174
|
-
const CodeBlockBody = memo(({ tokenized, showLineNumbers, className, }) => {
|
|
175
|
-
const preStyle = useMemo(() => ({
|
|
176
|
-
"--shiki-code-block-dark-bg": tokenized.darkBg,
|
|
177
|
-
"--shiki-code-block-dark-fg": tokenized.darkFg,
|
|
178
|
-
"--shiki-code-block-light-bg": tokenized.bg,
|
|
179
|
-
"--shiki-code-block-light-fg": tokenized.fg,
|
|
180
|
-
}), [tokenized.bg, tokenized.darkBg, tokenized.darkFg, tokenized.fg]);
|
|
181
|
-
const keyedLines = useMemo(() => addKeysToTokens(tokenized.tokens), [tokenized.tokens]);
|
|
182
|
-
return (_jsx("pre", { className: cn("m-0 p-4 text-sm", className), "data-nc-code-block-body": "", style: preStyle, children: _jsx("code", { className: cn("font-mono text-sm", showLineNumbers && "[counter-increment:line_0] [counter-reset:line]"), children: keyedLines.map((keyedLine) => (_jsx(LineSpan, { keyedLine: keyedLine, showLineNumbers: showLineNumbers }, keyedLine.key))) }) }));
|
|
183
|
-
}, (prevProps, nextProps) => prevProps.tokenized === nextProps.tokenized &&
|
|
184
|
-
prevProps.showLineNumbers === nextProps.showLineNumbers &&
|
|
185
|
-
prevProps.className === nextProps.className);
|
|
186
|
-
CodeBlockBody.displayName = "CodeBlockBody";
|
|
187
|
-
export const CodeBlockContainer = ({ className, language, style, ...props }) => (_jsx("div", { className: cn("group relative w-full overflow-hidden rounded-md border bg-background text-foreground", className), "data-language": language, style: {
|
|
188
|
-
containIntrinsicSize: "auto 200px",
|
|
189
|
-
contentVisibility: "auto",
|
|
190
|
-
...style,
|
|
191
|
-
}, ...props }));
|
|
192
|
-
export const CodeBlockHeader = ({ children, className, ...props }) => (_jsx("div", { className: cn("flex items-center justify-between border-b bg-muted/80 px-3 py-2 text-muted-foreground text-xs", className), ...props, children: children }));
|
|
193
|
-
export const CodeBlockTitle = ({ children, className, ...props }) => (_jsx("div", { className: cn("flex items-center gap-2", className), ...props, children: children }));
|
|
194
|
-
export const CodeBlockFilename = ({ children, className, ...props }) => (_jsx("span", { className: cn("font-mono", className), ...props, children: children }));
|
|
195
|
-
export const CodeBlockActions = ({ children, className, ...props }) => (_jsx("div", { className: cn("-my-1 -mr-1 flex items-center gap-2", className), ...props, children: children }));
|
|
196
|
-
export const CodeBlockContent = ({ code, language, showLineNumbers = false, }) => {
|
|
197
|
-
// Memoized raw tokens for immediate display
|
|
198
|
-
const rawTokens = useMemo(() => createRawTokens(code), [code]);
|
|
199
|
-
// Async highlighting result (populated after mount so hydration stays stable)
|
|
200
|
-
const [asyncTokens, setAsyncTokens] = useState(null);
|
|
201
|
-
useEffect(() => {
|
|
202
|
-
let cancelled = false;
|
|
203
|
-
setAsyncTokens(null);
|
|
204
|
-
const cached = highlightCode(code, language, (result) => {
|
|
205
|
-
if (!cancelled) {
|
|
206
|
-
setAsyncTokens(result);
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
if (cached && !cancelled) {
|
|
210
|
-
setAsyncTokens(cached);
|
|
211
|
-
}
|
|
212
|
-
return () => {
|
|
213
|
-
cancelled = true;
|
|
214
|
-
};
|
|
215
|
-
}, [code, language]);
|
|
216
|
-
const tokenized = asyncTokens ?? rawTokens;
|
|
217
|
-
return (_jsx("div", { className: "relative overflow-auto", children: _jsx(CodeBlockBody, { showLineNumbers: showLineNumbers, tokenized: tokenized }) }));
|
|
218
|
-
};
|
|
219
|
-
export const CodeBlock = ({ code, language, showLineNumbers = false, className, children, ...props }) => {
|
|
220
|
-
const contextValue = useMemo(() => ({ code }), [code]);
|
|
221
|
-
return (_jsx(CodeBlockContext.Provider, { value: contextValue, children: _jsxs(CodeBlockContainer, { className: className, language: language, ...props, children: [children, _jsx(CodeBlockContent, { code: code, language: language, showLineNumbers: showLineNumbers })] }) }));
|
|
222
|
-
};
|
|
223
|
-
export const CodeBlockCopyButton = ({ onCopy, onError, timeout = 2000, children, className, ...props }) => {
|
|
224
|
-
const { code } = useContext(CodeBlockContext);
|
|
225
|
-
const { copyToClipboard, isCopied } = useCopyToClipboard({
|
|
226
|
-
text: code,
|
|
227
|
-
onCopy,
|
|
228
|
-
onError,
|
|
229
|
-
timeout,
|
|
230
|
-
skipWhileCopied: true,
|
|
231
|
-
});
|
|
232
|
-
const Icon = isCopied ? CheckIcon : CopyIcon;
|
|
233
|
-
return (_jsx(Button, { className: cn("shrink-0", className), onClick: copyToClipboard, size: "icon", variant: "ghost", ...props, children: children ?? _jsx(Icon, { size: 14 }) }));
|
|
234
|
-
};
|
|
235
|
-
export const CodeBlockLanguageSelector = (props) => (_jsx(Select, { ...props }));
|
|
236
|
-
export const CodeBlockLanguageSelectorTrigger = ({ className, ...props }) => (_jsx(SelectTrigger, { className: cn("h-7 border-none bg-transparent px-2 text-xs shadow-none", className), size: "sm", ...props }));
|
|
237
|
-
export const CodeBlockLanguageSelectorValue = (props) => (_jsx(SelectValue, { ...props }));
|
|
238
|
-
export const CodeBlockLanguageSelectorContent = ({ align = "end", ...props }) => _jsx(SelectContent, { align: align, ...props });
|
|
239
|
-
export const CodeBlockLanguageSelectorItem = (props) => (_jsx(SelectItem, { ...props }));
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Avatar } from "../avatar";
|
|
2
|
-
import { Button } from "../button";
|
|
3
|
-
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../collapsible";
|
|
4
|
-
import { FileIcon } from "lucide-react";
|
|
5
|
-
import type { ComponentProps, HTMLAttributes } from "react";
|
|
6
|
-
export type CommitProps = ComponentProps<typeof Collapsible>;
|
|
7
|
-
export declare const Commit: ({ className, children, ...props }: CommitProps) => import("react").JSX.Element;
|
|
8
|
-
export type CommitHeaderProps = ComponentProps<typeof CollapsibleTrigger>;
|
|
9
|
-
export declare const CommitHeader: ({ className, children, ...props }: CommitHeaderProps) => import("react").JSX.Element;
|
|
10
|
-
export type CommitHashProps = HTMLAttributes<HTMLSpanElement>;
|
|
11
|
-
export declare const CommitHash: ({ className, children, ...props }: CommitHashProps) => import("react").JSX.Element;
|
|
12
|
-
export type CommitMessageProps = HTMLAttributes<HTMLSpanElement>;
|
|
13
|
-
export declare const CommitMessage: ({ className, children, ...props }: CommitMessageProps) => import("react").JSX.Element;
|
|
14
|
-
export type CommitMetadataProps = HTMLAttributes<HTMLDivElement>;
|
|
15
|
-
export declare const CommitMetadata: ({ className, children, ...props }: CommitMetadataProps) => import("react").JSX.Element;
|
|
16
|
-
export type CommitSeparatorProps = HTMLAttributes<HTMLSpanElement>;
|
|
17
|
-
export declare const CommitSeparator: ({ className, children, ...props }: CommitSeparatorProps) => import("react").JSX.Element;
|
|
18
|
-
export type CommitInfoProps = HTMLAttributes<HTMLDivElement>;
|
|
19
|
-
export declare const CommitInfo: ({ className, children, ...props }: CommitInfoProps) => import("react").JSX.Element;
|
|
20
|
-
export type CommitAuthorProps = HTMLAttributes<HTMLDivElement>;
|
|
21
|
-
export declare const CommitAuthor: ({ className, children, ...props }: CommitAuthorProps) => import("react").JSX.Element;
|
|
22
|
-
export type CommitAuthorAvatarProps = ComponentProps<typeof Avatar> & {
|
|
23
|
-
initials: string;
|
|
24
|
-
};
|
|
25
|
-
export declare const CommitAuthorAvatar: ({ initials, className, ...props }: CommitAuthorAvatarProps) => import("react").JSX.Element;
|
|
26
|
-
export type CommitTimestampProps = HTMLAttributes<HTMLTimeElement> & {
|
|
27
|
-
date: Date;
|
|
28
|
-
};
|
|
29
|
-
export declare const CommitTimestamp: ({ date, className, children, ...props }: CommitTimestampProps) => import("react").JSX.Element;
|
|
30
|
-
export type CommitActionsProps = HTMLAttributes<HTMLDivElement>;
|
|
31
|
-
export declare const CommitActions: ({ className, children, ...props }: CommitActionsProps) => import("react").JSX.Element;
|
|
32
|
-
export type CommitCopyButtonProps = ComponentProps<typeof Button> & {
|
|
33
|
-
hash: string;
|
|
34
|
-
onCopy?: () => void;
|
|
35
|
-
onError?: (error: Error) => void;
|
|
36
|
-
timeout?: number;
|
|
37
|
-
};
|
|
38
|
-
export declare const CommitCopyButton: ({ hash, onCopy, onError, timeout, children, className, ...props }: CommitCopyButtonProps) => import("react").JSX.Element;
|
|
39
|
-
export type CommitContentProps = ComponentProps<typeof CollapsibleContent>;
|
|
40
|
-
export declare const CommitContent: ({ className, children, ...props }: CommitContentProps) => import("react").JSX.Element;
|
|
41
|
-
export type CommitFilesProps = HTMLAttributes<HTMLDivElement>;
|
|
42
|
-
export declare const CommitFiles: ({ className, children, ...props }: CommitFilesProps) => import("react").JSX.Element;
|
|
43
|
-
export type CommitFileProps = HTMLAttributes<HTMLDivElement>;
|
|
44
|
-
export declare const CommitFile: ({ className, children, ...props }: CommitFileProps) => import("react").JSX.Element;
|
|
45
|
-
export type CommitFileInfoProps = HTMLAttributes<HTMLDivElement>;
|
|
46
|
-
export declare const CommitFileInfo: ({ className, children, ...props }: CommitFileInfoProps) => import("react").JSX.Element;
|
|
47
|
-
export type CommitFileStatusProps = HTMLAttributes<HTMLSpanElement> & {
|
|
48
|
-
status: "added" | "modified" | "deleted" | "renamed";
|
|
49
|
-
};
|
|
50
|
-
export declare const CommitFileStatus: ({ status, className, children, ...props }: CommitFileStatusProps) => import("react").JSX.Element;
|
|
51
|
-
export type CommitFileIconProps = ComponentProps<typeof FileIcon>;
|
|
52
|
-
export declare const CommitFileIcon: ({ className, ...props }: CommitFileIconProps) => import("react").JSX.Element;
|
|
53
|
-
export type CommitFilePathProps = HTMLAttributes<HTMLSpanElement>;
|
|
54
|
-
export declare const CommitFilePath: ({ className, children, ...props }: CommitFilePathProps) => import("react").JSX.Element;
|
|
55
|
-
export type CommitFileChangesProps = HTMLAttributes<HTMLDivElement>;
|
|
56
|
-
export declare const CommitFileChanges: ({ className, children, ...props }: CommitFileChangesProps) => import("react").JSX.Element;
|
|
57
|
-
export type CommitFileAdditionsProps = HTMLAttributes<HTMLSpanElement> & {
|
|
58
|
-
count: number;
|
|
59
|
-
};
|
|
60
|
-
export declare const CommitFileAdditions: ({ count, className, children, ...props }: CommitFileAdditionsProps) => import("react").JSX.Element | null;
|
|
61
|
-
export type CommitFileDeletionsProps = HTMLAttributes<HTMLSpanElement> & {
|
|
62
|
-
count: number;
|
|
63
|
-
};
|
|
64
|
-
export declare const CommitFileDeletions: ({ count, className, children, ...props }: CommitFileDeletionsProps) => import("react").JSX.Element | null;
|
|
65
|
-
//# sourceMappingURL=commit.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"commit.d.ts","sourceRoot":"","sources":["../../../src/components/ai-elements/commit.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAkB,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAG/F,OAAO,EAAuB,QAAQ,EAAsC,MAAM,cAAc,CAAC;AACjG,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAG5D,MAAM,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,WAAW,CAAC,CAAC;AAE7D,eAAO,MAAM,MAAM,GAAI,mCAAmC,WAAW,gCAIpE,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,cAAc,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE1E,eAAO,MAAM,YAAY,GAAI,mCAAmC,iBAAiB,gCAehF,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;AAE9D,eAAO,MAAM,UAAU,GAAI,mCAAmC,eAAe,gCAK5E,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;AAEjE,eAAO,MAAM,aAAa,GAAI,mCAAmC,kBAAkB,gCAIlF,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAEjE,eAAO,MAAM,cAAc,GAAI,mCAAmC,mBAAmB,gCAOpF,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;AAEnE,e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AM,mBAAmB,GAAI,0CAKjC,wBAAwB,uCAe1B,CAAC"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { Avatar, AvatarFallback } from "../avatar.js";
|
|
4
|
-
import { Button } from "../button.js";
|
|
5
|
-
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "../collapsible.js";
|
|
6
|
-
import { cn } from "../../lib/utils.js";
|
|
7
|
-
import { useCopyToClipboard } from "../../lib/use-copy-to-clipboard.js";
|
|
8
|
-
import { CheckIcon, CopyIcon, FileIcon, GitCommitIcon, MinusIcon, PlusIcon } from "lucide-react";
|
|
9
|
-
import { useCallback, useEffect, useState } from "react";
|
|
10
|
-
export const Commit = ({ className, children, ...props }) => (_jsx(Collapsible, { className: cn("rounded-lg border bg-background", className), ...props, children: children }));
|
|
11
|
-
export const CommitHeader = ({ className, children, ...props }) => (_jsx(CollapsibleTrigger, { nativeButton: false, render: _jsx("div", { className: cn("group flex cursor-pointer items-center justify-between gap-4 p-3 text-left transition-colors hover:opacity-80", className), children: children }), ...props }));
|
|
12
|
-
export const CommitHash = ({ className, children, ...props }) => (_jsxs("span", { className: cn("font-mono text-xs", className), ...props, children: [_jsx(GitCommitIcon, { className: "mr-1 inline-block size-3" }), children] }));
|
|
13
|
-
export const CommitMessage = ({ className, children, ...props }) => (_jsx("span", { className: cn("font-medium text-sm", className), ...props, children: children }));
|
|
14
|
-
export const CommitMetadata = ({ className, children, ...props }) => (_jsx("div", { className: cn("flex items-center gap-2 text-muted-foreground text-xs", className), ...props, children: children }));
|
|
15
|
-
export const CommitSeparator = ({ className, children, ...props }) => (_jsx("span", { className: className, ...props, children: children ?? "•" }));
|
|
16
|
-
export const CommitInfo = ({ className, children, ...props }) => (_jsx("div", { className: cn("flex flex-1 flex-col", className), ...props, children: children }));
|
|
17
|
-
export const CommitAuthor = ({ className, children, ...props }) => (_jsx("div", { className: cn("flex items-center", className), ...props, children: children }));
|
|
18
|
-
export const CommitAuthorAvatar = ({ initials, className, ...props }) => (_jsx(Avatar, { className: cn("size-8", className), ...props, children: _jsx(AvatarFallback, { className: "text-xs", children: initials }) }));
|
|
19
|
-
const relativeTimeFormat = new Intl.RelativeTimeFormat("en", {
|
|
20
|
-
numeric: "auto",
|
|
21
|
-
});
|
|
22
|
-
const formatRelativeDate = (date) => {
|
|
23
|
-
const days = Math.round((date.getTime() - Date.now()) / (1000 * 60 * 60 * 24));
|
|
24
|
-
return relativeTimeFormat.format(days, "day");
|
|
25
|
-
};
|
|
26
|
-
export const CommitTimestamp = ({ date, className, children, ...props }) => {
|
|
27
|
-
const [formatted, setFormatted] = useState("");
|
|
28
|
-
const updateFormatted = useCallback(() => {
|
|
29
|
-
setFormatted(formatRelativeDate(date));
|
|
30
|
-
}, [date]);
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
updateFormatted();
|
|
33
|
-
}, [updateFormatted]);
|
|
34
|
-
return (_jsx("time", { className: cn("text-xs", className), dateTime: date.toISOString(), ...props, children: children ?? formatted }));
|
|
35
|
-
};
|
|
36
|
-
const handleActionsClick = (e) => e.stopPropagation();
|
|
37
|
-
const handleActionsKeyDown = (e) => e.stopPropagation();
|
|
38
|
-
export const CommitActions = ({ className, children, ...props }) => (
|
|
39
|
-
// eslint-disable-next-line jsx-a11y/no-noninteractive-element-interactions -- The group only intercepts bubbled events from its interactive child controls so the parent commit is not activated.
|
|
40
|
-
_jsx("div", { className: cn("flex items-center gap-1", className), onClick: handleActionsClick, onKeyDown: handleActionsKeyDown, role: "group", ...props, children: children }));
|
|
41
|
-
export const CommitCopyButton = ({ hash, onCopy, onError, timeout = 2000, children, className, ...props }) => {
|
|
42
|
-
const { copyToClipboard, isCopied } = useCopyToClipboard({
|
|
43
|
-
text: hash,
|
|
44
|
-
onCopy,
|
|
45
|
-
onError,
|
|
46
|
-
timeout,
|
|
47
|
-
skipWhileCopied: true,
|
|
48
|
-
});
|
|
49
|
-
const Icon = isCopied ? CheckIcon : CopyIcon;
|
|
50
|
-
return (_jsx(Button, { className: cn("size-7 shrink-0", className), onClick: copyToClipboard, size: "icon", variant: "ghost", ...props, children: children ?? _jsx(Icon, { size: 14 }) }));
|
|
51
|
-
};
|
|
52
|
-
export const CommitContent = ({ className, children, ...props }) => (_jsx(CollapsibleContent, { className: cn("border-t p-3", className), ...props, children: children }));
|
|
53
|
-
export const CommitFiles = ({ className, children, ...props }) => (_jsx("div", { className: cn("flex flex-col gap-1", className), ...props, children: children }));
|
|
54
|
-
export const CommitFile = ({ className, children, ...props }) => (_jsx("div", { className: cn("flex items-center justify-between gap-2 rounded px-2 py-1 text-sm hover:bg-muted/50", className), ...props, children: children }));
|
|
55
|
-
export const CommitFileInfo = ({ className, children, ...props }) => (_jsx("div", { className: cn("flex min-w-0 items-center gap-2", className), ...props, children: children }));
|
|
56
|
-
const fileStatusStyles = {
|
|
57
|
-
added: "text-[var(--nc-success-deep)]",
|
|
58
|
-
deleted: "text-destructive",
|
|
59
|
-
modified: "text-[var(--nc-warning-deep)]",
|
|
60
|
-
renamed: "text-[var(--nc-link-deep)]",
|
|
61
|
-
};
|
|
62
|
-
const fileStatusLabels = {
|
|
63
|
-
added: "A",
|
|
64
|
-
deleted: "D",
|
|
65
|
-
modified: "M",
|
|
66
|
-
renamed: "R",
|
|
67
|
-
};
|
|
68
|
-
export const CommitFileStatus = ({ status, className, children, ...props }) => (_jsx("span", { className: cn("font-medium font-mono text-xs", fileStatusStyles[status], className), ...props, children: children ?? fileStatusLabels[status] }));
|
|
69
|
-
export const CommitFileIcon = ({ className, ...props }) => (_jsx(FileIcon, { className: cn("size-3.5 shrink-0 text-muted-foreground", className), ...props }));
|
|
70
|
-
export const CommitFilePath = ({ className, children, ...props }) => (_jsx("span", { className: cn("truncate font-mono text-xs", className), ...props, children: children }));
|
|
71
|
-
export const CommitFileChanges = ({ className, children, ...props }) => (_jsx("div", { className: cn("flex shrink-0 items-center gap-1 font-mono text-xs", className), ...props, children: children }));
|
|
72
|
-
export const CommitFileAdditions = ({ count, className, children, ...props }) => {
|
|
73
|
-
if (count <= 0) {
|
|
74
|
-
return null;
|
|
75
|
-
}
|
|
76
|
-
return (_jsx("span", { className: cn("text-[var(--nc-success-deep)]", className), ...props, children: children ?? (_jsxs(_Fragment, { children: [_jsx(PlusIcon, { className: "inline-block size-3" }), count] })) }));
|
|
77
|
-
};
|
|
78
|
-
export const CommitFileDeletions = ({ count, className, children, ...props }) => {
|
|
79
|
-
if (count <= 0) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
return (_jsx("span", { className: cn("text-destructive", className), ...props, children: children ?? (_jsxs(_Fragment, { children: [_jsx(MinusIcon, { className: "inline-block size-3" }), count] })) }));
|
|
83
|
-
};
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { Alert, AlertDescription } from "../alert";
|
|
2
|
-
import { Button } from "../button";
|
|
3
|
-
import type { ToolUIPart } from "ai";
|
|
4
|
-
import type { ComponentProps, ReactNode } from "react";
|
|
5
|
-
type ToolUIPartApproval = {
|
|
6
|
-
id: string;
|
|
7
|
-
approved?: never;
|
|
8
|
-
reason?: never;
|
|
9
|
-
} | {
|
|
10
|
-
id: string;
|
|
11
|
-
approved: boolean;
|
|
12
|
-
reason?: string;
|
|
13
|
-
} | {
|
|
14
|
-
id: string;
|
|
15
|
-
approved: true;
|
|
16
|
-
reason?: string;
|
|
17
|
-
} | {
|
|
18
|
-
id: string;
|
|
19
|
-
approved: true;
|
|
20
|
-
reason?: string;
|
|
21
|
-
} | {
|
|
22
|
-
id: string;
|
|
23
|
-
approved: false;
|
|
24
|
-
reason?: string;
|
|
25
|
-
} | undefined;
|
|
26
|
-
export type ConfirmationProps = ComponentProps<typeof Alert> & {
|
|
27
|
-
approval?: ToolUIPartApproval;
|
|
28
|
-
state: ToolUIPart["state"];
|
|
29
|
-
};
|
|
30
|
-
export declare const Confirmation: ({ className, approval, state, ...props }: ConfirmationProps) => import("react").JSX.Element | null;
|
|
31
|
-
export type ConfirmationTitleProps = ComponentProps<typeof AlertDescription>;
|
|
32
|
-
export declare const ConfirmationTitle: ({ className, ...props }: ConfirmationTitleProps) => import("react").JSX.Element;
|
|
33
|
-
export interface ConfirmationRequestProps {
|
|
34
|
-
children?: ReactNode;
|
|
35
|
-
}
|
|
36
|
-
export declare const ConfirmationRequest: ({ children }: ConfirmationRequestProps) => ReactNode;
|
|
37
|
-
export interface ConfirmationAcceptedProps {
|
|
38
|
-
children?: ReactNode;
|
|
39
|
-
}
|
|
40
|
-
export declare const ConfirmationAccepted: ({ children }: ConfirmationAcceptedProps) => ReactNode;
|
|
41
|
-
export interface ConfirmationRejectedProps {
|
|
42
|
-
children?: ReactNode;
|
|
43
|
-
}
|
|
44
|
-
export declare const ConfirmationRejected: ({ children }: ConfirmationRejectedProps) => ReactNode;
|
|
45
|
-
export type ConfirmationActionsProps = ComponentProps<"div">;
|
|
46
|
-
export declare const ConfirmationActions: ({ className, ...props }: ConfirmationActionsProps) => import("react").JSX.Element | null;
|
|
47
|
-
export type ConfirmationActionProps = ComponentProps<typeof Button>;
|
|
48
|
-
export declare const ConfirmationAction: (props: ConfirmationActionProps) => import("react").JSX.Element;
|
|
49
|
-
export {};
|
|
50
|
-
//# sourceMappingURL=confirmation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"confirmation.d.ts","sourceRoot":"","sources":["../../../src/components/ai-elements/confirmation.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAGvD,KAAK,kBAAkB,GACnB;IACE,EAAE,EAAE,MAA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MAAM,oBAAoB,GAAI,cAAc,yBAAyB,cAY3E,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;AAE7D,eAAO,MAAM,mBAAmB,GAAI,yBAAyB,wBAAwB,uCAWpF,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC;AAEpE,eAAO,MAAM,kBAAkB,GAAI,OAAO,uBAAuB,gCAEhE,CAAC"}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { Alert, AlertDescription } from "../alert.js";
|
|
4
|
-
import { Button } from "../button.js";
|
|
5
|
-
import { cn } from "../../lib/utils.js";
|
|
6
|
-
import { createContext, useContext, useMemo } from "react";
|
|
7
|
-
const ConfirmationContext = createContext(null);
|
|
8
|
-
const useConfirmation = () => {
|
|
9
|
-
const context = useContext(ConfirmationContext);
|
|
10
|
-
if (!context) {
|
|
11
|
-
throw new Error("Confirmation components must be used within Confirmation");
|
|
12
|
-
}
|
|
13
|
-
return context;
|
|
14
|
-
};
|
|
15
|
-
export const Confirmation = ({ className, approval, state, ...props }) => {
|
|
16
|
-
const contextValue = useMemo(() => ({ approval, state }), [approval, state]);
|
|
17
|
-
if (!approval || state === "input-streaming" || state === "input-available") {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return (_jsx(ConfirmationContext.Provider, { value: contextValue, children: _jsx(Alert, { className: cn("flex flex-col gap-2", className), ...props }) }));
|
|
21
|
-
};
|
|
22
|
-
export const ConfirmationTitle = ({ className, ...props }) => (_jsx(AlertDescription, { className: cn("inline", className), ...props }));
|
|
23
|
-
export const ConfirmationRequest = ({ children }) => {
|
|
24
|
-
const { state } = useConfirmation();
|
|
25
|
-
// Only show when approval is requested
|
|
26
|
-
if (state !== "approval-requested") {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
return children;
|
|
30
|
-
};
|
|
31
|
-
export const ConfirmationAccepted = ({ children }) => {
|
|
32
|
-
const { approval, state } = useConfirmation();
|
|
33
|
-
// Only show when approved and in response states
|
|
34
|
-
if (!approval?.approved ||
|
|
35
|
-
(state !== "approval-responded" && state !== "output-denied" && state !== "output-available")) {
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
return children;
|
|
39
|
-
};
|
|
40
|
-
export const ConfirmationRejected = ({ children }) => {
|
|
41
|
-
const { approval, state } = useConfirmation();
|
|
42
|
-
// Only show when rejected and in response states
|
|
43
|
-
if (approval?.approved !== false ||
|
|
44
|
-
(state !== "approval-responded" && state !== "output-denied" && state !== "output-available")) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return children;
|
|
48
|
-
};
|
|
49
|
-
export const ConfirmationActions = ({ className, ...props }) => {
|
|
50
|
-
const { state } = useConfirmation();
|
|
51
|
-
// Only show when approval is requested
|
|
52
|
-
if (state !== "approval-requested") {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
return (_jsx("div", { className: cn("flex items-center justify-end gap-2 self-end", className), ...props }));
|
|
56
|
-
};
|
|
57
|
-
export const ConfirmationAction = (props) => (_jsx(Button, { className: "h-8 px-3 text-sm", type: "button", ...props }));
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { ConnectionLineComponent } from "@xyflow/react";
|
|
2
|
-
import type { ComponentProps } from "react";
|
|
3
|
-
export declare const Connection: ConnectionLineComponent;
|
|
4
|
-
export type ConnectionPreviewProps = ComponentProps<"svg">;
|
|
5
|
-
export declare const ConnectionPreview: ({ className, ...props }: ConnectionPreviewProps) => import("react").JSX.Element;
|
|
6
|
-
//# sourceMappingURL=connection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/components/ai-elements/connection.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,uBAAuB,EAAgC,MAAM,eAAe,CAAC;AAC3F,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAI5C,eAAO,MAAM,UAAU,EAAE,uBAkBxB,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;AAE3D,eAAO,MAAM,iBAAiB,GAAI,yBAAyB,sBAAsB,gCAWhF,CAAC"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
const HALF = 0.5;
|
|
4
|
-
export const Connection = ({ fromX, fromY, toX, toY }) => (_jsxs("g", { children: [_jsx("path", { className: "animated", d: `M${fromX},${fromY} C ${fromX + (toX - fromX) * HALF},${fromY} ${fromX + (toX - fromX) * HALF},${toY} ${toX},${toY}`, fill: "none", stroke: "var(--color-ring)", strokeWidth: 1 }), _jsx("circle", { cx: toX, cy: toY, fill: "var(--color-background)", r: 3, stroke: "var(--color-ring)", strokeWidth: 1 })] }));
|
|
5
|
-
export const ConnectionPreview = ({ className, ...props }) => (_jsx("svg", { className: className, viewBox: "0 0 160 40", ...props, children: _jsx(Connection, { ...{
|
|
6
|
-
fromX: 10,
|
|
7
|
-
fromY: 20,
|
|
8
|
-
toX: 150,
|
|
9
|
-
toY: 20,
|
|
10
|
-
} }) }));
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Button } from "../button";
|
|
2
|
-
import { HoverCard, HoverCardContent } from "../hover-card";
|
|
3
|
-
import type { LanguageModelUsage } from "ai";
|
|
4
|
-
import type { ComponentProps } from "react";
|
|
5
|
-
type ModelId = string;
|
|
6
|
-
interface ContextSchema {
|
|
7
|
-
usedTokens: number;
|
|
8
|
-
maxTokens: number;
|
|
9
|
-
usage?: LanguageModelUsage;
|
|
10
|
-
modelId?: ModelId;
|
|
11
|
-
}
|
|
12
|
-
export type ContextProps = ComponentProps<typeof HoverCard> & ContextSchema;
|
|
13
|
-
export declare const Context: ({ usedTokens, maxTokens, usage, modelId, ...props }: ContextProps) => import("react").JSX.Element;
|
|
14
|
-
export type ContextTriggerProps = ComponentProps<typeof Button>;
|
|
15
|
-
export declare const ContextTrigger: ({ children, ...props }: ContextTriggerProps) => import("react").JSX.Element;
|
|
16
|
-
export type ContextContentProps = ComponentProps<typeof HoverCardContent>;
|
|
17
|
-
export declare const ContextContent: ({ className, ...props }: ContextContentProps) => import("react").JSX.Element;
|
|
18
|
-
export type ContextContentHeaderProps = ComponentProps<"div">;
|
|
19
|
-
export declare const ContextContentHeader: ({ children, className, ...props }: ContextContentHeaderProps) => import("react").JSX.Element;
|
|
20
|
-
export type ContextContentBodyProps = ComponentProps<"div">;
|
|
21
|
-
export declare const ContextContentBody: ({ children, className, ...props }: ContextContentBodyProps) => import("react").JSX.Element;
|
|
22
|
-
export type ContextContentFooterProps = ComponentProps<"div">;
|
|
23
|
-
export declare const ContextContentFooter: ({ children, className, ...props }: ContextContentFooterProps) => import("react").JSX.Element;
|
|
24
|
-
export type ContextInputUsageProps = ComponentProps<"div">;
|
|
25
|
-
export declare const ContextInputUsage: ({ className, children, ...props }: ContextInputUsageProps) => string | number | bigint | true | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null;
|
|
26
|
-
export type ContextOutputUsageProps = ComponentProps<"div">;
|
|
27
|
-
export declare const ContextOutputUsage: ({ className, children, ...props }: ContextOutputUsageProps) => string | number | bigint | true | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null;
|
|
28
|
-
export type ContextReasoningUsageProps = ComponentProps<"div">;
|
|
29
|
-
export declare const ContextReasoningUsage: ({ className, children, ...props }: ContextReasoningUsageProps) => string | number | bigint | true | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null;
|
|
30
|
-
export type ContextCacheUsageProps = ComponentProps<"div">;
|
|
31
|
-
export declare const ContextCacheUsage: ({ className, children, ...props }: ContextCacheUsageProps) => string | number | bigint | true | import("react").JSX.Element | Iterable<import("react").ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined> | null;
|
|
32
|
-
export {};
|
|
33
|
-
//# sourceMappingURL=context.d.ts.map
|