@agent-native/toolkit 0.6.0 → 0.8.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/README.md +17 -1
- package/agent-native.eject.json +411 -0
- package/dist/chat-history/ChatHistoryList.d.ts +103 -0
- package/dist/chat-history/ChatHistoryList.d.ts.map +1 -0
- package/dist/chat-history/ChatHistoryList.js +109 -0
- package/dist/chat-history/ChatHistoryList.js.map +1 -0
- package/dist/chat-history/ChatHistoryList.spec.d.ts +2 -0
- package/dist/chat-history/ChatHistoryList.spec.d.ts.map +1 -0
- package/dist/chat-history/ChatHistoryList.spec.js +283 -0
- package/dist/chat-history/ChatHistoryList.spec.js.map +1 -0
- package/dist/chat-history/index.d.ts +2 -0
- package/dist/chat-history/index.d.ts.map +1 -0
- package/dist/chat-history/index.js +2 -0
- package/dist/chat-history/index.js.map +1 -0
- package/dist/chat-history.css +314 -0
- package/package.json +20 -1
- package/src/app-shell/header-actions.tsx +84 -0
- package/src/app-shell/index.ts +1 -0
- package/src/chat-history/ChatHistoryList.spec.tsx +453 -0
- package/src/chat-history/ChatHistoryList.tsx +469 -0
- package/src/chat-history/index.ts +7 -0
- package/src/chat-history.css +314 -0
- package/src/collab-ui/AgentPresenceChip.tsx +69 -0
- package/src/collab-ui/LiveCursorOverlay.tsx +241 -0
- package/src/collab-ui/PresenceBar.tsx +346 -0
- package/src/collab-ui/RecentEditHighlights.tsx +225 -0
- package/src/collab-ui/RemoteSelectionRings.tsx +227 -0
- package/src/collab-ui/agent-identity.ts +16 -0
- package/src/collab-ui/index.ts +39 -0
- package/src/collab-ui/lead-client.ts +32 -0
- package/src/collab-ui/types.spec.ts +18 -0
- package/src/collab-ui/types.ts +96 -0
- package/src/composer/AgentComposerFrame.tsx +59 -0
- package/src/composer/ComposerPlusMenu.tsx +983 -0
- package/src/composer/MentionPopover.tsx +412 -0
- package/src/composer/PastedTextChip.tsx +150 -0
- package/src/composer/PromptComposer.spec.ts +73 -0
- package/src/composer/PromptComposer.tsx +718 -0
- package/src/composer/RealtimeVoiceMode.spec.tsx +771 -0
- package/src/composer/RealtimeVoiceMode.tsx +856 -0
- package/src/composer/TiptapComposer.spec.ts +390 -0
- package/src/composer/TiptapComposer.tsx +2936 -0
- package/src/composer/VoiceButton.spec.ts +33 -0
- package/src/composer/VoiceButton.tsx +255 -0
- package/src/composer/asset-picker-url.spec.ts +56 -0
- package/src/composer/asset-picker-url.ts +80 -0
- package/src/composer/attachment-accept.spec.ts +22 -0
- package/src/composer/attachment-accept.ts +71 -0
- package/src/composer/draft-key.spec.ts +19 -0
- package/src/composer/draft-key.ts +7 -0
- package/src/composer/extensions/FileReference.tsx +55 -0
- package/src/composer/extensions/MentionReference.tsx +93 -0
- package/src/composer/extensions/SkillReference.tsx +56 -0
- package/src/composer/index.ts +79 -0
- package/src/composer/pasted-text.spec.ts +162 -0
- package/src/composer/pasted-text.ts +160 -0
- package/src/composer/prompt-attachments.spec.ts +80 -0
- package/src/composer/prompt-attachments.ts +93 -0
- package/src/composer/realtime-voice-audio-level.spec.ts +32 -0
- package/src/composer/realtime-voice-audio-level.ts +64 -0
- package/src/composer/realtime-voice-transcript.spec.ts +95 -0
- package/src/composer/realtime-voice-transcript.ts +134 -0
- package/src/composer/runtime-adapters.tsx +343 -0
- package/src/composer/types.ts +66 -0
- package/src/composer/use-file-search.ts +64 -0
- package/src/composer/use-mention-search.ts +90 -0
- package/src/composer/use-skills.ts +45 -0
- package/src/composer/useRealtimeVoiceMode.spec.ts +818 -0
- package/src/composer/useRealtimeVoiceMode.tsx +2117 -0
- package/src/composer/useVoiceDictation.spec.ts +45 -0
- package/src/composer/useVoiceDictation.ts +1191 -0
- package/src/context-ui/ContextMeter.tsx +101 -0
- package/src/context-ui/ContextSegmentRow.tsx +184 -0
- package/src/context-ui/ContextTreemap.tsx +125 -0
- package/src/context-ui/ContextXRayPanel.tsx +377 -0
- package/src/context-ui/format.ts +42 -0
- package/src/context-ui/index.ts +15 -0
- package/src/context-ui/types.ts +43 -0
- package/src/design-tweaks/index.ts +1 -0
- package/src/design-tweaks/visual-style-controls.tsx +1084 -0
- package/src/editor/BubbleToolbar.tsx +253 -0
- package/src/editor/CodeBlockNode.tsx +254 -0
- package/src/editor/DragHandle.spec.ts +588 -0
- package/src/editor/DragHandle.ts +1437 -0
- package/src/editor/ImageExtension.roundtrip.spec.ts +117 -0
- package/src/editor/ImageExtension.ts +306 -0
- package/src/editor/RegistryBlockContext.tsx +107 -0
- package/src/editor/RegistryBlockNode.spec.ts +279 -0
- package/src/editor/RegistryBlockNode.tsx +652 -0
- package/src/editor/RichMarkdownEditor.collab.spec.ts +79 -0
- package/src/editor/RichMarkdownEditor.roundtrip.spec.ts +226 -0
- package/src/editor/RichMarkdownEditor.tsx +81 -0
- package/src/editor/RunId.ts +61 -0
- package/src/editor/SharedRichEditor.tsx +321 -0
- package/src/editor/SlashCommandMenu.tsx +310 -0
- package/src/editor/disableHistory.spec.ts +85 -0
- package/src/editor/extensions.ts +402 -0
- package/src/editor/gfmDoc.spec.ts +230 -0
- package/src/editor/gfmDoc.ts +92 -0
- package/src/editor/index.ts +93 -0
- package/src/editor/registrySlashCommands.ts +131 -0
- package/src/editor/structuralReorderUndo.spec.ts +144 -0
- package/src/editor/surgical-apply.spec.ts +279 -0
- package/src/editor/surgical-apply.ts +192 -0
- package/src/editor/useCollabReconcile.concurrent.spec.ts +422 -0
- package/src/editor/useCollabReconcile.idempotent.spec.ts +324 -0
- package/src/editor/useCollabReconcile.ts +589 -0
- package/src/editor.css +510 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/use-mobile.tsx +21 -0
- package/src/hooks/use-toast.ts +188 -0
- package/src/index.ts +8 -0
- package/src/onboarding/index.ts +1 -0
- package/src/provider.tsx +47 -0
- package/src/sharing/VisibilityBadge.spec.ts +96 -0
- package/src/sharing/VisibilityBadge.tsx +37 -0
- package/src/sharing/index.ts +4 -0
- package/src/styles.css +21 -0
- package/src/ui/accordion.tsx +56 -0
- package/src/ui/alert-dialog.tsx +141 -0
- package/src/ui/alert.tsx +59 -0
- package/src/ui/aspect-ratio.tsx +5 -0
- package/src/ui/avatar.tsx +48 -0
- package/src/ui/badge.tsx +37 -0
- package/src/ui/breadcrumb.tsx +115 -0
- package/src/ui/button.tsx +78 -0
- package/src/ui/calendar.tsx +214 -0
- package/src/ui/card.tsx +86 -0
- package/src/ui/carousel.tsx +260 -0
- package/src/ui/chart.tsx +375 -0
- package/src/ui/checkbox.tsx +28 -0
- package/src/ui/collapsible.tsx +9 -0
- package/src/ui/command.spec.tsx +51 -0
- package/src/ui/command.tsx +174 -0
- package/src/ui/context-menu.tsx +202 -0
- package/src/ui/date-picker.tsx +64 -0
- package/src/ui/dialog.spec.tsx +43 -0
- package/src/ui/dialog.tsx +146 -0
- package/src/ui/drawer.tsx +126 -0
- package/src/ui/dropdown-menu.tsx +218 -0
- package/src/ui/form.tsx +177 -0
- package/src/ui/hover-card.tsx +27 -0
- package/src/ui/index.ts +52 -0
- package/src/ui/input-otp.tsx +69 -0
- package/src/ui/input.tsx +22 -0
- package/src/ui/label.tsx +24 -0
- package/src/ui/logo.tsx +36 -0
- package/src/ui/menubar.tsx +235 -0
- package/src/ui/navigation-menu.tsx +128 -0
- package/src/ui/pagination.tsx +121 -0
- package/src/ui/popover.tsx +44 -0
- package/src/ui/progress.tsx +26 -0
- package/src/ui/radio-group.tsx +42 -0
- package/src/ui/resizable.tsx +43 -0
- package/src/ui/scroll-area.tsx +46 -0
- package/src/ui/select.tsx +158 -0
- package/src/ui/separator.tsx +29 -0
- package/src/ui/sheet.tsx +160 -0
- package/src/ui/sidebar.tsx +777 -0
- package/src/ui/skeleton.tsx +18 -0
- package/src/ui/slider.tsx +26 -0
- package/src/ui/sonner.tsx +58 -0
- package/src/ui/spinner.tsx +17 -0
- package/src/ui/switch.tsx +27 -0
- package/src/ui/table.tsx +117 -0
- package/src/ui/tabs.tsx +53 -0
- package/src/ui/textarea.tsx +23 -0
- package/src/ui/toast.tsx +127 -0
- package/src/ui/toaster.tsx +33 -0
- package/src/ui/toggle-group.tsx +59 -0
- package/src/ui/toggle.tsx +43 -0
- package/src/ui/tooltip.tsx +53 -0
- package/src/ui/use-toast.ts +3 -0
- package/src/utils.ts +8 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu";
|
|
2
|
+
import { IconCheck, IconChevronRight, IconCircle } from "@tabler/icons-react";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
|
|
7
|
+
const DropdownMenu = DropdownMenuPrimitive.Root;
|
|
8
|
+
|
|
9
|
+
const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
|
10
|
+
|
|
11
|
+
const DropdownMenuGroup = DropdownMenuPrimitive.Group;
|
|
12
|
+
|
|
13
|
+
const DropdownMenuPortal = DropdownMenuPrimitive.Portal;
|
|
14
|
+
|
|
15
|
+
const DropdownMenuSub = DropdownMenuPrimitive.Sub;
|
|
16
|
+
|
|
17
|
+
const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup;
|
|
18
|
+
|
|
19
|
+
const DropdownMenuSubTrigger = React.forwardRef<
|
|
20
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>,
|
|
21
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & {
|
|
22
|
+
inset?: boolean;
|
|
23
|
+
}
|
|
24
|
+
>(({ className, inset, children, ...props }, ref) => (
|
|
25
|
+
<DropdownMenuPrimitive.SubTrigger
|
|
26
|
+
ref={ref}
|
|
27
|
+
className={cn(
|
|
28
|
+
"flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",
|
|
29
|
+
inset && "ps-8",
|
|
30
|
+
className,
|
|
31
|
+
)}
|
|
32
|
+
{...props}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
<IconChevronRight className="ms-auto h-4 w-4 rtl:-scale-x-100" />
|
|
36
|
+
</DropdownMenuPrimitive.SubTrigger>
|
|
37
|
+
));
|
|
38
|
+
DropdownMenuSubTrigger.displayName =
|
|
39
|
+
DropdownMenuPrimitive.SubTrigger.displayName;
|
|
40
|
+
|
|
41
|
+
type DropdownMenuSubContentProps = React.ComponentPropsWithoutRef<
|
|
42
|
+
typeof DropdownMenuPrimitive.SubContent
|
|
43
|
+
> & {
|
|
44
|
+
container?: React.ComponentPropsWithoutRef<
|
|
45
|
+
typeof DropdownMenuPrimitive.Portal
|
|
46
|
+
>["container"];
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const DropdownMenuSubContent = React.forwardRef<
|
|
50
|
+
React.ElementRef<typeof DropdownMenuPrimitive.SubContent>,
|
|
51
|
+
DropdownMenuSubContentProps
|
|
52
|
+
>(({ className, container, ...props }, ref) => (
|
|
53
|
+
<DropdownMenuPrimitive.Portal container={container}>
|
|
54
|
+
<DropdownMenuPrimitive.SubContent
|
|
55
|
+
ref={ref}
|
|
56
|
+
className={cn(
|
|
57
|
+
"z-[290] min-w-[8rem] origin-[var(--radix-dropdown-menu-content-transform-origin)] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-lg will-change-[transform,opacity] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:duration-100 data-[state=open]:duration-150 data-[state=closed]:ease-out data-[state=open]:ease-out data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 motion-reduce:data-[state=open]:zoom-in-100 motion-reduce:data-[state=closed]:zoom-out-100 motion-reduce:data-[side=bottom]:slide-in-from-top-0 motion-reduce:data-[side=left]:slide-in-from-right-0 motion-reduce:data-[side=right]:slide-in-from-left-0 motion-reduce:data-[side=top]:slide-in-from-bottom-0",
|
|
58
|
+
className,
|
|
59
|
+
)}
|
|
60
|
+
{...props}
|
|
61
|
+
/>
|
|
62
|
+
</DropdownMenuPrimitive.Portal>
|
|
63
|
+
));
|
|
64
|
+
DropdownMenuSubContent.displayName =
|
|
65
|
+
DropdownMenuPrimitive.SubContent.displayName;
|
|
66
|
+
|
|
67
|
+
type DropdownMenuContentProps = React.ComponentPropsWithoutRef<
|
|
68
|
+
typeof DropdownMenuPrimitive.Content
|
|
69
|
+
> & {
|
|
70
|
+
// Allows rendering the portal into a custom container; useful when the menu
|
|
71
|
+
// must appear above a specific stacking context (e.g. a fullscreen video player).
|
|
72
|
+
container?: React.ComponentPropsWithoutRef<
|
|
73
|
+
typeof DropdownMenuPrimitive.Portal
|
|
74
|
+
>["container"];
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const DropdownMenuContent = React.forwardRef<
|
|
78
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Content>,
|
|
79
|
+
DropdownMenuContentProps
|
|
80
|
+
>(({ className, container, sideOffset = 4, ...props }, ref) => (
|
|
81
|
+
<DropdownMenuPrimitive.Portal container={container}>
|
|
82
|
+
<DropdownMenuPrimitive.Content
|
|
83
|
+
ref={ref}
|
|
84
|
+
sideOffset={sideOffset}
|
|
85
|
+
className={cn(
|
|
86
|
+
"z-[290] min-w-[8rem] origin-[var(--radix-dropdown-menu-content-transform-origin)] overflow-hidden rounded-md border border-border bg-popover p-1 text-popover-foreground shadow-md will-change-[transform,opacity] data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:duration-100 data-[state=open]:duration-150 data-[state=closed]:ease-out data-[state=open]:ease-out data-[side=bottom]:slide-in-from-top-1 data-[side=left]:slide-in-from-right-1 data-[side=right]:slide-in-from-left-1 data-[side=top]:slide-in-from-bottom-1 motion-reduce:data-[state=open]:zoom-in-100 motion-reduce:data-[state=closed]:zoom-out-100 motion-reduce:data-[side=bottom]:slide-in-from-top-0 motion-reduce:data-[side=left]:slide-in-from-right-0 motion-reduce:data-[side=right]:slide-in-from-left-0 motion-reduce:data-[side=top]:slide-in-from-bottom-0",
|
|
87
|
+
className,
|
|
88
|
+
)}
|
|
89
|
+
{...props}
|
|
90
|
+
/>
|
|
91
|
+
</DropdownMenuPrimitive.Portal>
|
|
92
|
+
));
|
|
93
|
+
DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName;
|
|
94
|
+
|
|
95
|
+
const DropdownMenuItem = React.forwardRef<
|
|
96
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Item>,
|
|
97
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & {
|
|
98
|
+
inset?: boolean;
|
|
99
|
+
}
|
|
100
|
+
>(({ className, inset, ...props }, ref) => (
|
|
101
|
+
<DropdownMenuPrimitive.Item
|
|
102
|
+
ref={ref}
|
|
103
|
+
className={cn(
|
|
104
|
+
"relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
105
|
+
inset && "ps-8",
|
|
106
|
+
className,
|
|
107
|
+
)}
|
|
108
|
+
{...props}
|
|
109
|
+
/>
|
|
110
|
+
));
|
|
111
|
+
DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName;
|
|
112
|
+
|
|
113
|
+
const DropdownMenuCheckboxItem = React.forwardRef<
|
|
114
|
+
React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>,
|
|
115
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem>
|
|
116
|
+
>(({ className, children, checked, ...props }, ref) => (
|
|
117
|
+
<DropdownMenuPrimitive.CheckboxItem
|
|
118
|
+
ref={ref}
|
|
119
|
+
className={cn(
|
|
120
|
+
"relative flex cursor-pointer select-none items-center rounded-sm py-1.5 ps-8 pe-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
121
|
+
className,
|
|
122
|
+
)}
|
|
123
|
+
checked={checked}
|
|
124
|
+
{...props}
|
|
125
|
+
>
|
|
126
|
+
<span className="absolute start-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
127
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
128
|
+
<IconCheck className="h-4 w-4" />
|
|
129
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
130
|
+
</span>
|
|
131
|
+
{children}
|
|
132
|
+
</DropdownMenuPrimitive.CheckboxItem>
|
|
133
|
+
));
|
|
134
|
+
DropdownMenuCheckboxItem.displayName =
|
|
135
|
+
DropdownMenuPrimitive.CheckboxItem.displayName;
|
|
136
|
+
|
|
137
|
+
const DropdownMenuRadioItem = React.forwardRef<
|
|
138
|
+
React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>,
|
|
139
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem>
|
|
140
|
+
>(({ className, children, ...props }, ref) => (
|
|
141
|
+
<DropdownMenuPrimitive.RadioItem
|
|
142
|
+
ref={ref}
|
|
143
|
+
className={cn(
|
|
144
|
+
"relative flex cursor-pointer select-none items-center rounded-sm py-1.5 ps-8 pe-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
145
|
+
className,
|
|
146
|
+
)}
|
|
147
|
+
{...props}
|
|
148
|
+
>
|
|
149
|
+
<span className="absolute start-2 flex h-3.5 w-3.5 items-center justify-center">
|
|
150
|
+
<DropdownMenuPrimitive.ItemIndicator>
|
|
151
|
+
<IconCircle className="h-2 w-2 fill-current" />
|
|
152
|
+
</DropdownMenuPrimitive.ItemIndicator>
|
|
153
|
+
</span>
|
|
154
|
+
{children}
|
|
155
|
+
</DropdownMenuPrimitive.RadioItem>
|
|
156
|
+
));
|
|
157
|
+
DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName;
|
|
158
|
+
|
|
159
|
+
const DropdownMenuLabel = React.forwardRef<
|
|
160
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Label>,
|
|
161
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & {
|
|
162
|
+
inset?: boolean;
|
|
163
|
+
}
|
|
164
|
+
>(({ className, inset, ...props }, ref) => (
|
|
165
|
+
<DropdownMenuPrimitive.Label
|
|
166
|
+
ref={ref}
|
|
167
|
+
className={cn(
|
|
168
|
+
"px-2 py-1.5 text-xs font-semibold text-muted-foreground",
|
|
169
|
+
inset && "ps-8",
|
|
170
|
+
className,
|
|
171
|
+
)}
|
|
172
|
+
{...props}
|
|
173
|
+
/>
|
|
174
|
+
));
|
|
175
|
+
DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName;
|
|
176
|
+
|
|
177
|
+
const DropdownMenuSeparator = React.forwardRef<
|
|
178
|
+
React.ElementRef<typeof DropdownMenuPrimitive.Separator>,
|
|
179
|
+
React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator>
|
|
180
|
+
>(({ className, ...props }, ref) => (
|
|
181
|
+
<DropdownMenuPrimitive.Separator
|
|
182
|
+
ref={ref}
|
|
183
|
+
className={cn("-mx-1 my-1 h-px bg-muted", className)}
|
|
184
|
+
{...props}
|
|
185
|
+
/>
|
|
186
|
+
));
|
|
187
|
+
DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName;
|
|
188
|
+
|
|
189
|
+
const DropdownMenuShortcut = ({
|
|
190
|
+
className,
|
|
191
|
+
...props
|
|
192
|
+
}: React.HTMLAttributes<HTMLSpanElement>) => {
|
|
193
|
+
return (
|
|
194
|
+
<span
|
|
195
|
+
className={cn("ms-auto text-xs tracking-widest opacity-60", className)}
|
|
196
|
+
{...props}
|
|
197
|
+
/>
|
|
198
|
+
);
|
|
199
|
+
};
|
|
200
|
+
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
201
|
+
|
|
202
|
+
export {
|
|
203
|
+
DropdownMenu,
|
|
204
|
+
DropdownMenuTrigger,
|
|
205
|
+
DropdownMenuContent,
|
|
206
|
+
DropdownMenuItem,
|
|
207
|
+
DropdownMenuCheckboxItem,
|
|
208
|
+
DropdownMenuRadioItem,
|
|
209
|
+
DropdownMenuLabel,
|
|
210
|
+
DropdownMenuSeparator,
|
|
211
|
+
DropdownMenuShortcut,
|
|
212
|
+
DropdownMenuGroup,
|
|
213
|
+
DropdownMenuPortal,
|
|
214
|
+
DropdownMenuSub,
|
|
215
|
+
DropdownMenuSubContent,
|
|
216
|
+
DropdownMenuSubTrigger,
|
|
217
|
+
DropdownMenuRadioGroup,
|
|
218
|
+
};
|
package/src/ui/form.tsx
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
import {
|
|
5
|
+
Controller,
|
|
6
|
+
ControllerProps,
|
|
7
|
+
FieldPath,
|
|
8
|
+
FieldValues,
|
|
9
|
+
FormProvider,
|
|
10
|
+
useFormContext,
|
|
11
|
+
} from "react-hook-form";
|
|
12
|
+
|
|
13
|
+
import { cn } from "../utils.js";
|
|
14
|
+
import { Label } from "./label.js";
|
|
15
|
+
|
|
16
|
+
const Form = FormProvider;
|
|
17
|
+
|
|
18
|
+
type FormFieldContextValue<
|
|
19
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
20
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
21
|
+
> = {
|
|
22
|
+
name: TName;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const FormFieldContext = React.createContext<FormFieldContextValue>(
|
|
26
|
+
{} as FormFieldContextValue,
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const FormField = <
|
|
30
|
+
TFieldValues extends FieldValues = FieldValues,
|
|
31
|
+
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
|
|
32
|
+
>({
|
|
33
|
+
...props
|
|
34
|
+
}: ControllerProps<TFieldValues, TName>) => {
|
|
35
|
+
return (
|
|
36
|
+
<FormFieldContext.Provider value={{ name: props.name }}>
|
|
37
|
+
<Controller {...props} />
|
|
38
|
+
</FormFieldContext.Provider>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const useFormField = () => {
|
|
43
|
+
const fieldContext = React.useContext(FormFieldContext);
|
|
44
|
+
const itemContext = React.useContext(FormItemContext);
|
|
45
|
+
const { getFieldState, formState } = useFormContext();
|
|
46
|
+
|
|
47
|
+
const fieldState = getFieldState(fieldContext.name, formState);
|
|
48
|
+
|
|
49
|
+
if (!fieldContext) {
|
|
50
|
+
throw new Error("useFormField should be used within <FormField>");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const { id } = itemContext;
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
id,
|
|
57
|
+
name: fieldContext.name,
|
|
58
|
+
formItemId: `${id}-form-item`,
|
|
59
|
+
formDescriptionId: `${id}-form-item-description`,
|
|
60
|
+
formMessageId: `${id}-form-item-message`,
|
|
61
|
+
...fieldState,
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type FormItemContextValue = {
|
|
66
|
+
id: string;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const FormItemContext = React.createContext<FormItemContextValue>(
|
|
70
|
+
{} as FormItemContextValue,
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
const FormItem = React.forwardRef<
|
|
74
|
+
HTMLDivElement,
|
|
75
|
+
React.HTMLAttributes<HTMLDivElement>
|
|
76
|
+
>(({ className, ...props }, ref) => {
|
|
77
|
+
const id = React.useId();
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<FormItemContext.Provider value={{ id }}>
|
|
81
|
+
<div ref={ref} className={cn("space-y-2", className)} {...props} />
|
|
82
|
+
</FormItemContext.Provider>
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
FormItem.displayName = "FormItem";
|
|
86
|
+
|
|
87
|
+
const FormLabel = React.forwardRef<
|
|
88
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
89
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
|
|
90
|
+
>(({ className, ...props }, ref) => {
|
|
91
|
+
const { error, formItemId } = useFormField();
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<Label
|
|
95
|
+
ref={ref}
|
|
96
|
+
className={cn(error && "text-destructive", className)}
|
|
97
|
+
htmlFor={formItemId}
|
|
98
|
+
{...props}
|
|
99
|
+
/>
|
|
100
|
+
);
|
|
101
|
+
});
|
|
102
|
+
FormLabel.displayName = "FormLabel";
|
|
103
|
+
|
|
104
|
+
const FormControl = React.forwardRef<
|
|
105
|
+
React.ElementRef<typeof Slot>,
|
|
106
|
+
React.ComponentPropsWithoutRef<typeof Slot>
|
|
107
|
+
>(({ ...props }, ref) => {
|
|
108
|
+
const { error, formItemId, formDescriptionId, formMessageId } =
|
|
109
|
+
useFormField();
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<Slot
|
|
113
|
+
ref={ref}
|
|
114
|
+
id={formItemId}
|
|
115
|
+
aria-describedby={
|
|
116
|
+
!error
|
|
117
|
+
? `${formDescriptionId}`
|
|
118
|
+
: `${formDescriptionId} ${formMessageId}`
|
|
119
|
+
}
|
|
120
|
+
aria-invalid={!!error}
|
|
121
|
+
{...props}
|
|
122
|
+
/>
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
FormControl.displayName = "FormControl";
|
|
126
|
+
|
|
127
|
+
const FormDescription = React.forwardRef<
|
|
128
|
+
HTMLParagraphElement,
|
|
129
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
130
|
+
>(({ className, ...props }, ref) => {
|
|
131
|
+
const { formDescriptionId } = useFormField();
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<p
|
|
135
|
+
ref={ref}
|
|
136
|
+
id={formDescriptionId}
|
|
137
|
+
className={cn("text-sm text-muted-foreground", className)}
|
|
138
|
+
{...props}
|
|
139
|
+
/>
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
FormDescription.displayName = "FormDescription";
|
|
143
|
+
|
|
144
|
+
const FormMessage = React.forwardRef<
|
|
145
|
+
HTMLParagraphElement,
|
|
146
|
+
React.HTMLAttributes<HTMLParagraphElement>
|
|
147
|
+
>(({ className, children, ...props }, ref) => {
|
|
148
|
+
const { error, formMessageId } = useFormField();
|
|
149
|
+
const body = error ? String(error?.message) : children;
|
|
150
|
+
|
|
151
|
+
if (!body) {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return (
|
|
156
|
+
<p
|
|
157
|
+
ref={ref}
|
|
158
|
+
id={formMessageId}
|
|
159
|
+
className={cn("text-sm font-medium text-destructive", className)}
|
|
160
|
+
{...props}
|
|
161
|
+
>
|
|
162
|
+
{body}
|
|
163
|
+
</p>
|
|
164
|
+
);
|
|
165
|
+
});
|
|
166
|
+
FormMessage.displayName = "FormMessage";
|
|
167
|
+
|
|
168
|
+
export {
|
|
169
|
+
useFormField,
|
|
170
|
+
Form,
|
|
171
|
+
FormItem,
|
|
172
|
+
FormLabel,
|
|
173
|
+
FormControl,
|
|
174
|
+
FormDescription,
|
|
175
|
+
FormMessage,
|
|
176
|
+
FormField,
|
|
177
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import * as HoverCardPrimitive from "@radix-ui/react-hover-card";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
|
|
4
|
+
import { cn } from "../utils.js";
|
|
5
|
+
|
|
6
|
+
const HoverCard = HoverCardPrimitive.Root;
|
|
7
|
+
|
|
8
|
+
const HoverCardTrigger = HoverCardPrimitive.Trigger;
|
|
9
|
+
|
|
10
|
+
const HoverCardContent = React.forwardRef<
|
|
11
|
+
React.ElementRef<typeof HoverCardPrimitive.Content>,
|
|
12
|
+
React.ComponentPropsWithoutRef<typeof HoverCardPrimitive.Content>
|
|
13
|
+
>(({ className, align = "center", sideOffset = 4, ...props }, ref) => (
|
|
14
|
+
<HoverCardPrimitive.Content
|
|
15
|
+
ref={ref}
|
|
16
|
+
align={align}
|
|
17
|
+
sideOffset={sideOffset}
|
|
18
|
+
className={cn(
|
|
19
|
+
"z-[290] w-64 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[var(--radix-hover-card-content-transform-origin)]",
|
|
20
|
+
className,
|
|
21
|
+
)}
|
|
22
|
+
{...props}
|
|
23
|
+
/>
|
|
24
|
+
));
|
|
25
|
+
HoverCardContent.displayName = HoverCardPrimitive.Content.displayName;
|
|
26
|
+
|
|
27
|
+
export { HoverCard, HoverCardTrigger, HoverCardContent };
|
package/src/ui/index.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export * from "./accordion.js";
|
|
2
|
+
export * from "./alert-dialog.js";
|
|
3
|
+
export * from "./alert.js";
|
|
4
|
+
export * from "./aspect-ratio.js";
|
|
5
|
+
export * from "./avatar.js";
|
|
6
|
+
export * from "./badge.js";
|
|
7
|
+
export * from "./breadcrumb.js";
|
|
8
|
+
export * from "./button.js";
|
|
9
|
+
export * from "./calendar.js";
|
|
10
|
+
export * from "./card.js";
|
|
11
|
+
export * from "./carousel.js";
|
|
12
|
+
export * from "./chart.js";
|
|
13
|
+
export * from "./checkbox.js";
|
|
14
|
+
export * from "./collapsible.js";
|
|
15
|
+
export * from "./command.js";
|
|
16
|
+
export * from "./context-menu.js";
|
|
17
|
+
export * from "./date-picker.js";
|
|
18
|
+
export * from "./dialog.js";
|
|
19
|
+
export * from "./drawer.js";
|
|
20
|
+
export * from "./dropdown-menu.js";
|
|
21
|
+
export * from "./form.js";
|
|
22
|
+
export * from "./hover-card.js";
|
|
23
|
+
export * from "./input-otp.js";
|
|
24
|
+
export * from "./input.js";
|
|
25
|
+
export * from "./label.js";
|
|
26
|
+
export * from "./logo.js";
|
|
27
|
+
export * from "./menubar.js";
|
|
28
|
+
export * from "./navigation-menu.js";
|
|
29
|
+
export * from "./pagination.js";
|
|
30
|
+
export * from "./popover.js";
|
|
31
|
+
export * from "./progress.js";
|
|
32
|
+
export * from "./radio-group.js";
|
|
33
|
+
export * from "./resizable.js";
|
|
34
|
+
export * from "./scroll-area.js";
|
|
35
|
+
export * from "./select.js";
|
|
36
|
+
export * from "./separator.js";
|
|
37
|
+
export * from "./sheet.js";
|
|
38
|
+
export * from "./sidebar.js";
|
|
39
|
+
export * from "./skeleton.js";
|
|
40
|
+
export * from "./slider.js";
|
|
41
|
+
export * from "./sonner.js";
|
|
42
|
+
export * from "./spinner.js";
|
|
43
|
+
export * from "./switch.js";
|
|
44
|
+
export * from "./table.js";
|
|
45
|
+
export * from "./tabs.js";
|
|
46
|
+
export * from "./textarea.js";
|
|
47
|
+
export * from "./toast.js";
|
|
48
|
+
export { Toaster as ToastToaster } from "./toaster.js";
|
|
49
|
+
export * from "./toggle-group.js";
|
|
50
|
+
export * from "./toggle.js";
|
|
51
|
+
export * from "./tooltip.js";
|
|
52
|
+
export * from "./use-toast.js";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { IconPoint } from "@tabler/icons-react";
|
|
2
|
+
import { OTPInput, OTPInputContext } from "input-otp";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
|
|
7
|
+
const InputOTP = React.forwardRef<
|
|
8
|
+
React.ElementRef<typeof OTPInput>,
|
|
9
|
+
React.ComponentPropsWithoutRef<typeof OTPInput>
|
|
10
|
+
>(({ className, containerClassName, ...props }, ref) => (
|
|
11
|
+
<OTPInput
|
|
12
|
+
ref={ref}
|
|
13
|
+
containerClassName={cn(
|
|
14
|
+
"flex items-center gap-2 has-[:disabled]:opacity-50",
|
|
15
|
+
containerClassName,
|
|
16
|
+
)}
|
|
17
|
+
className={cn("disabled:cursor-not-allowed", className)}
|
|
18
|
+
{...props}
|
|
19
|
+
/>
|
|
20
|
+
));
|
|
21
|
+
InputOTP.displayName = "InputOTP";
|
|
22
|
+
|
|
23
|
+
const InputOTPGroup = React.forwardRef<
|
|
24
|
+
React.ElementRef<"div">,
|
|
25
|
+
React.ComponentPropsWithoutRef<"div">
|
|
26
|
+
>(({ className, ...props }, ref) => (
|
|
27
|
+
<div ref={ref} className={cn("flex items-center", className)} {...props} />
|
|
28
|
+
));
|
|
29
|
+
InputOTPGroup.displayName = "InputOTPGroup";
|
|
30
|
+
|
|
31
|
+
const InputOTPSlot = React.forwardRef<
|
|
32
|
+
React.ElementRef<"div">,
|
|
33
|
+
React.ComponentPropsWithoutRef<"div"> & { index: number }
|
|
34
|
+
>(({ index, className, ...props }, ref) => {
|
|
35
|
+
const inputOTPContext = React.useContext(OTPInputContext);
|
|
36
|
+
const { char, hasFakeCaret, isActive } = inputOTPContext.slots[index];
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
ref={ref}
|
|
41
|
+
className={cn(
|
|
42
|
+
"relative flex h-10 w-10 items-center justify-center border-y border-e border-input text-sm transition-all first:rounded-s-md first:border-s last:rounded-e-md",
|
|
43
|
+
isActive && "z-10 ring-2 ring-ring ring-offset-background",
|
|
44
|
+
className,
|
|
45
|
+
)}
|
|
46
|
+
{...props}
|
|
47
|
+
>
|
|
48
|
+
{char}
|
|
49
|
+
{hasFakeCaret && (
|
|
50
|
+
<div className="pointer-events-none absolute inset-0 flex items-center justify-center">
|
|
51
|
+
<div className="h-4 w-px animate-caret-blink bg-foreground duration-1000" />
|
|
52
|
+
</div>
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
InputOTPSlot.displayName = "InputOTPSlot";
|
|
58
|
+
|
|
59
|
+
const InputOTPSeparator = React.forwardRef<
|
|
60
|
+
React.ElementRef<"div">,
|
|
61
|
+
React.ComponentPropsWithoutRef<"div">
|
|
62
|
+
>(({ ...props }, ref) => (
|
|
63
|
+
<div ref={ref} role="separator" {...props}>
|
|
64
|
+
<IconPoint />
|
|
65
|
+
</div>
|
|
66
|
+
));
|
|
67
|
+
InputOTPSeparator.displayName = "InputOTPSeparator";
|
|
68
|
+
|
|
69
|
+
export { InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator };
|
package/src/ui/input.tsx
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import { cn } from "../utils.js";
|
|
4
|
+
|
|
5
|
+
const Input = React.forwardRef<HTMLInputElement, React.ComponentProps<"input">>(
|
|
6
|
+
({ className, type, ...props }, ref) => {
|
|
7
|
+
return (
|
|
8
|
+
<input
|
|
9
|
+
type={type}
|
|
10
|
+
className={cn(
|
|
11
|
+
"flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",
|
|
12
|
+
className,
|
|
13
|
+
)}
|
|
14
|
+
ref={ref}
|
|
15
|
+
{...props}
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
},
|
|
19
|
+
);
|
|
20
|
+
Input.displayName = "Input";
|
|
21
|
+
|
|
22
|
+
export { Input };
|
package/src/ui/label.tsx
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import * as LabelPrimitive from "@radix-ui/react-label";
|
|
2
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "../utils.js";
|
|
6
|
+
|
|
7
|
+
const labelVariants = cva(
|
|
8
|
+
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70",
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const Label = React.forwardRef<
|
|
12
|
+
React.ElementRef<typeof LabelPrimitive.Root>,
|
|
13
|
+
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root> &
|
|
14
|
+
VariantProps<typeof labelVariants>
|
|
15
|
+
>(({ className, ...props }, ref) => (
|
|
16
|
+
<LabelPrimitive.Root
|
|
17
|
+
ref={ref}
|
|
18
|
+
className={cn(labelVariants(), className)}
|
|
19
|
+
{...props}
|
|
20
|
+
/>
|
|
21
|
+
));
|
|
22
|
+
Label.displayName = LabelPrimitive.Root.displayName;
|
|
23
|
+
|
|
24
|
+
export { Label };
|
package/src/ui/logo.tsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { cn } from "../utils.js";
|
|
2
|
+
|
|
3
|
+
interface LogoProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
showIcon?: boolean;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function Logo({ className, showIcon = false }: LogoProps) {
|
|
9
|
+
if (showIcon) {
|
|
10
|
+
return (
|
|
11
|
+
<svg
|
|
12
|
+
viewBox="0 0 24 24"
|
|
13
|
+
fill="none"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
className={className}
|
|
16
|
+
>
|
|
17
|
+
{/* Simple geometric mark - stylized "N" made of two bars */}
|
|
18
|
+
<path
|
|
19
|
+
d="M7 17V7L17 17V7"
|
|
20
|
+
stroke="currentColor"
|
|
21
|
+
strokeWidth="2.5"
|
|
22
|
+
strokeLinecap="round"
|
|
23
|
+
strokeLinejoin="round"
|
|
24
|
+
/>
|
|
25
|
+
</svg>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Stylized text logo
|
|
30
|
+
return (
|
|
31
|
+
<span className={cn("font-logo font-bold tracking-tight", className)}>
|
|
32
|
+
<span className="text-foreground">nutri</span>
|
|
33
|
+
<span className="text-foreground/50">track</span>
|
|
34
|
+
</span>
|
|
35
|
+
);
|
|
36
|
+
}
|