moi-computer 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/LICENSE +95 -0
  2. package/README.md +71 -0
  3. package/bin/moi.mjs +25 -0
  4. package/bunfig.toml +3 -0
  5. package/client/CLAUDE.md +12 -0
  6. package/client/api/workspaces.ts +158 -0
  7. package/client/assets/claude.svg +3 -0
  8. package/client/assets/favicon.png +0 -0
  9. package/client/assets/hermes-nous.png +0 -0
  10. package/client/assets/mcp/.gitkeep +0 -0
  11. package/client/assets/mcp/atlassian.png +0 -0
  12. package/client/assets/mcp/discord.png +0 -0
  13. package/client/assets/mcp/figma.png +0 -0
  14. package/client/assets/mcp/github.png +0 -0
  15. package/client/assets/mcp/gitlab.png +0 -0
  16. package/client/assets/mcp/granola.png +0 -0
  17. package/client/assets/mcp/hubspot.png +0 -0
  18. package/client/assets/mcp/linear.png +0 -0
  19. package/client/assets/mcp/neon.png +0 -0
  20. package/client/assets/mcp/notion.png +0 -0
  21. package/client/assets/mcp/sentry.png +0 -0
  22. package/client/assets/mcp/slack.png +0 -0
  23. package/client/assets/mcp/stripe.png +0 -0
  24. package/client/assets/mcp/supabase.png +0 -0
  25. package/client/assets/mcp/vercel.png +0 -0
  26. package/client/assets/moi-logo.svg +11 -0
  27. package/client/assets/openclaw.svg +22 -0
  28. package/client/components/App.tsx +35 -0
  29. package/client/components/BottomPanel.tsx +33 -0
  30. package/client/components/ChatInput.tsx +62 -0
  31. package/client/components/ChatPanel.tsx +206 -0
  32. package/client/components/ChatPopup.tsx +60 -0
  33. package/client/components/CustomizePanel.tsx +117 -0
  34. package/client/components/HiddenPanel.tsx +79 -0
  35. package/client/components/HomePage.tsx +17 -0
  36. package/client/components/MarkdownContent.tsx +41 -0
  37. package/client/components/ThreadSelector.tsx +88 -0
  38. package/client/components/TurnView.tsx +618 -0
  39. package/client/components/WidgetErrorBoundary.tsx +46 -0
  40. package/client/components/WidgetFrame.tsx +66 -0
  41. package/client/components/WidgetGrid.tsx +113 -0
  42. package/client/components/WidgetShell.tsx +44 -0
  43. package/client/components/Widgets.tsx +132 -0
  44. package/client/components/WorkspacePreview.tsx +48 -0
  45. package/client/components/WorkspacesPage.tsx +237 -0
  46. package/client/components/layout/SidebarLayout.tsx +260 -0
  47. package/client/components/playground/LedLogo.tsx +181 -0
  48. package/client/components/playground/PixelPainter.tsx +105 -0
  49. package/client/components/playground/PlaygroundPage.tsx +71 -0
  50. package/client/components/routes/workspace/[id].tsx +282 -0
  51. package/client/components/ui/button.tsx +48 -0
  52. package/client/components/ui/dropdown-menu.tsx +257 -0
  53. package/client/components/ui/input.tsx +21 -0
  54. package/client/components/ui/popover.tsx +79 -0
  55. package/client/components/ui/textarea.tsx +18 -0
  56. package/client/externalize-react.ts +29 -0
  57. package/client/hooks/useChat.ts +88 -0
  58. package/client/hooks/useFitsSidebar.ts +34 -0
  59. package/client/hooks/useGridReconcile.ts +73 -0
  60. package/client/hooks/useMeiEvents.ts +66 -0
  61. package/client/hooks/useScrollFade.ts +38 -0
  62. package/client/hooks/useWidget.ts +72 -0
  63. package/client/hooks/useWidgetList.ts +30 -0
  64. package/client/hooks/useWorkspaceTheme.ts +76 -0
  65. package/client/index.css +182 -0
  66. package/client/index.html +43 -0
  67. package/client/index.tsx +19 -0
  68. package/client/lib/WorkspaceContext.tsx +24 -0
  69. package/client/lib/WorkspaceLayoutContext.tsx +92 -0
  70. package/client/lib/cn.ts +6 -0
  71. package/client/lib/grid-pack.ts +35 -0
  72. package/client/lib/group-turns.ts +44 -0
  73. package/client/lib/mcp-icons.ts +53 -0
  74. package/client/lib/ws.ts +129 -0
  75. package/client/main.tsx +23 -0
  76. package/client/store/chat.tsx +162 -0
  77. package/client/store/ui.ts +21 -0
  78. package/client/theme.css +66 -0
  79. package/lib/claude-adapter.ts +602 -0
  80. package/lib/format.ts +212 -0
  81. package/lib/themes.ts +89 -0
  82. package/lib/types.ts +144 -0
  83. package/package.json +117 -0
  84. package/server/CLAUDE.md +6 -0
  85. package/server/agent.ts +132 -0
  86. package/server/build-widget.ts +343 -0
  87. package/server/cli.ts +632 -0
  88. package/server/constants.ts +3 -0
  89. package/server/control.ts +98 -0
  90. package/server/functions-worker.ts +89 -0
  91. package/server/functions.ts +171 -0
  92. package/server/layout.ts +83 -0
  93. package/server/openclaw-adapter.ts +242 -0
  94. package/server/openclaw-gateway.ts +255 -0
  95. package/server/openclaw-session.ts +485 -0
  96. package/server/openclaw-strip.ts +134 -0
  97. package/server/openclaw.ts +206 -0
  98. package/server/registry.ts +150 -0
  99. package/server/skills-template.ts +21 -0
  100. package/server/state.ts +87 -0
  101. package/server/theme.ts +55 -0
  102. package/server/web.ts +321 -0
  103. package/server/widgets.ts +254 -0
  104. package/tsconfig.json +21 -0
  105. package/workspace/.claude/skills/widgets/DESIGN.md +630 -0
  106. package/workspace/.claude/skills/widgets/SKILL.md +176 -0
@@ -0,0 +1,282 @@
1
+ import { useEffect, useRef, useState } from 'react'
2
+
3
+ import { AnimatePresence, motion } from 'motion/react'
4
+
5
+ import { IconLayoutDashboard, IconPalette } from '@tabler/icons-react'
6
+ import { useQueryClient } from '@tanstack/react-query'
7
+
8
+ import { useWorkspaceSessions, useWorkspaceWidgets, workspaceKeys } from '@/client/api/workspaces'
9
+ import { ChatPanel } from '@/client/components/ChatPanel'
10
+ import { ChatPopup } from '@/client/components/ChatPopup'
11
+ import { type WidgetMode, Widgets } from '@/client/components/Widgets'
12
+ import { PanelHeader, SidebarLayout, SidebarToggle } from '@/client/components/layout/SidebarLayout'
13
+ import { LedLogo } from '@/client/components/playground/LedLogo'
14
+ import { Button } from '@/client/components/ui/button'
15
+ import { useChat } from '@/client/hooks/useChat'
16
+ import { useFitsSidebar } from '@/client/hooks/useFitsSidebar'
17
+ import { useGridReconcile } from '@/client/hooks/useGridReconcile'
18
+ import { useMeiEvent } from '@/client/hooks/useMeiEvents'
19
+ import { useWorkspaceTheme } from '@/client/hooks/useWorkspaceTheme'
20
+ import { Workspace } from '@/client/lib/WorkspaceContext'
21
+ import { WorkspaceLayoutProvider, useWorkspaceLayoutCtx } from '@/client/lib/WorkspaceLayoutContext'
22
+ import { cn } from '@/client/lib/cn'
23
+ import { ChatStoreProvider, useChatStoreApi } from '@/client/store/chat'
24
+ import type { SessionInfo, WidgetInfo } from '@/lib/types'
25
+
26
+ type WorkspaceRouteProps = {
27
+ id: string
28
+ }
29
+
30
+ // Route component for `/workspace/:id` — provides workspace id + layout context,
31
+ // then loads. Layout and widgets are React Query resources; chat (sessions,
32
+ // events, websocket) still runs on the Zustand stores, seeded from the sessions
33
+ // query below.
34
+ export function WorkspaceRoute({ id }: WorkspaceRouteProps) {
35
+ return (
36
+ <Workspace id={id}>
37
+ <WorkspaceLayoutProvider id={id}>
38
+ <WorkspaceLoader id={id} />
39
+ </WorkspaceLayoutProvider>
40
+ </Workspace>
41
+ )
42
+ }
43
+
44
+ type WorkspaceLoaderProps = {
45
+ id: string
46
+ }
47
+
48
+ function WorkspaceLoader({ id }: WorkspaceLoaderProps) {
49
+ const qc = useQueryClient()
50
+ const { layout, setLayout, cwd, isLoading: layoutLoading } = useWorkspaceLayoutCtx()
51
+ const widgets = useWorkspaceWidgets(id)
52
+ const sessions = useWorkspaceSessions(id)
53
+
54
+ // Keep the grid balanced as widgets come and go. (Theme is applied inside
55
+ // WorkspaceView, scoped to the panel — see useWorkspaceTheme there.)
56
+ useGridReconcile(id, widgets.data, layout, setLayout)
57
+
58
+ // Server-pushed changes invalidate the matching query so the next render
59
+ // revalidates (theme re-applies; the grid reconcile places any new widget).
60
+ useMeiEvent(e => {
61
+ if (e.type === 'theme:updated') {
62
+ qc.invalidateQueries({ queryKey: workspaceKeys.layout(id) })
63
+ } else if (e.type === 'widget-layout:updated') {
64
+ qc.invalidateQueries({ queryKey: workspaceKeys.widgets(id) })
65
+ }
66
+ })
67
+
68
+ // Fresh visit (nothing cached) → centered MOI logo in the panel. Switch-back
69
+ // shows cached data immediately while it revalidates, so no loader then.
70
+ const fresh = layoutLoading || widgets.isLoading
71
+
72
+ // One chat store per workspace mount: switching workspaces unmounts this and
73
+ // discards its chat state cleanly. cwd flows in so turn metadata can show it.
74
+ return (
75
+ <ChatStoreProvider cwd={cwd}>
76
+ <SeedActiveSession sessions={sessions.data} />
77
+ <SidebarLayout>
78
+ {fresh ? (
79
+ <div className="flex h-full items-center justify-center">
80
+ <LedLogo sprite="moi" effect="chaos" />
81
+ </div>
82
+ ) : (
83
+ <WorkspaceView widgets={widgets.data ?? []} />
84
+ )}
85
+ </SidebarLayout>
86
+ </ChatStoreProvider>
87
+ )
88
+ }
89
+
90
+ type SeedActiveSessionProps = {
91
+ sessions: SessionInfo[] | undefined
92
+ }
93
+
94
+ // Picks an active thread once the sessions query resolves. A freshly-mounted
95
+ // workspace store starts with `activeSessionId: null`, so this selects the most
96
+ // recent thread; it also re-selects if the current one vanished from the list.
97
+ function SeedActiveSession({ sessions }: SeedActiveSessionProps) {
98
+ const store = useChatStoreApi()
99
+ useEffect(() => {
100
+ if (!sessions) return
101
+ const active = store.getState().activeSessionId
102
+ const stillValid = active && sessions.some(s => s.sessionId === active)
103
+ if (!stillValid) store.getState().setActiveSession(sessions[0]?.sessionId ?? null)
104
+ }, [sessions, store])
105
+ return null
106
+ }
107
+
108
+ const ACTION_VARIANTS = {
109
+ from: { opacity: 0, scale: 0.8, filter: 'blur(4px)' },
110
+ to: { opacity: 1, scale: 1, filter: 'blur(0px)' }
111
+ }
112
+
113
+ type WidgetActionsProps = {
114
+ mode: WidgetMode
115
+ onMode: (mode: WidgetMode) => void
116
+ }
117
+
118
+ // Widget controls — live in the page header (right side), always visible.
119
+ function WidgetActions({ mode, onMode }: WidgetActionsProps) {
120
+ return (
121
+ <AnimatePresence mode="popLayout" initial={false}>
122
+ {mode !== 'idle' ? (
123
+ <motion.div
124
+ key="done"
125
+ variants={ACTION_VARIANTS}
126
+ initial="from"
127
+ animate="to"
128
+ exit="from"
129
+ transition={{ type: 'spring', duration: 0.3, bounce: 0 }}
130
+ >
131
+ <Button onClick={() => onMode('idle')}>Done</Button>
132
+ </motion.div>
133
+ ) : (
134
+ <motion.div
135
+ key="actions"
136
+ className="flex items-center gap-1"
137
+ variants={ACTION_VARIANTS}
138
+ initial="from"
139
+ animate="to"
140
+ exit="from"
141
+ transition={{ type: 'spring', duration: 0.3, bounce: 0 }}
142
+ >
143
+ <Button
144
+ variant="ghost"
145
+ className="text-muted-foreground [&_svg]:size-[18px]"
146
+ onClick={() => onMode('customizing')}
147
+ >
148
+ <IconPalette stroke={1.75} />
149
+ Customize
150
+ </Button>
151
+ <Button
152
+ variant="ghost"
153
+ className="text-muted-foreground [&_svg]:size-[18px]"
154
+ onClick={() => onMode('editing')}
155
+ >
156
+ <IconLayoutDashboard stroke={1.75} />
157
+ Edit widgets
158
+ </Button>
159
+ </motion.div>
160
+ )}
161
+ </AnimatePresence>
162
+ )
163
+ }
164
+
165
+ type WorkspaceViewProps = {
166
+ widgets: WidgetInfo[]
167
+ }
168
+
169
+ function WorkspaceView({ widgets }: WorkspaceViewProps) {
170
+ const { view, input, setInput, processing, error, send, stop, switchThread, dismissError } =
171
+ useChat()
172
+ const { layout, setLayout, name } = useWorkspaceLayoutCtx()
173
+ const { ref: rowRef, fits: canFitSidebar } = useFitsSidebar<HTMLDivElement>()
174
+ const [widgetMode, setWidgetMode] = useState<WidgetMode>('idle')
175
+
176
+ // Theme is scoped to this wrapper, not :root — the sidebar keeps the default
177
+ // tokens. The floating chat portals into the same element so it inherits them.
178
+ const themeRef = useRef<HTMLDivElement>(null)
179
+ useWorkspaceTheme(layout.theme, themeRef)
180
+
181
+ const hasWidgets = widgets.length > 0
182
+ // The chat always lives in the panel; "floating" only applies when there are
183
+ // widgets to clear room for. With no widgets it fills the panel (LHS hidden).
184
+ const chatMode: 'sidebar' | 'floating' =
185
+ hasWidgets && (layout.chatMode === 'floating' || !canFitSidebar) ? 'floating' : 'sidebar'
186
+
187
+ const handleModeChange = canFitSidebar
188
+ ? (mode: 'sidebar' | 'floating') => setLayout({ chatMode: mode })
189
+ : undefined
190
+
191
+ const chatPanel = (
192
+ <ChatPanel
193
+ view={view}
194
+ input={input}
195
+ setInput={setInput}
196
+ processing={processing}
197
+ error={error}
198
+ onDismissError={dismissError}
199
+ send={send}
200
+ stop={stop}
201
+ chatMode={chatMode}
202
+ onSwitchThread={switchThread}
203
+ onModeChange={handleModeChange}
204
+ onCollapse={() => setLayout({ chatMode: 'floating' })}
205
+ // With no widgets there's no LHS header beside the chat, so host the
206
+ // sidebar toggle in the chat header instead.
207
+ leading={hasWidgets ? undefined : <SidebarToggle />}
208
+ />
209
+ )
210
+
211
+ return (
212
+ // Themed wrapper: scoped CSS vars (bg/fg/font) live here so the panel — and
213
+ // the portaled floating chat — pick up the workspace theme, while the
214
+ // sidebar outside stays default.
215
+ <div
216
+ ref={themeRef}
217
+ className="bg-background text-foreground flex h-full min-h-0 flex-col font-sans"
218
+ >
219
+ {/* Two-pane panel split. LHS = workspace header + scrollable widgets;
220
+ RHS = the chat (its own header included). With no widgets the LHS is
221
+ dropped and the chat fills the whole panel. */}
222
+ <div ref={rowRef} className="flex h-full min-h-0">
223
+ {hasWidgets && (
224
+ <div className="border-border flex min-h-0 min-w-[var(--column-w)] flex-1 flex-col border-r">
225
+ <PanelHeader>
226
+ <SidebarToggle />
227
+ {name && <span className="text-foreground truncate text-sm font-medium">{name}</span>}
228
+ <div className="flex-1" />
229
+ <WidgetActions mode={widgetMode} onMode={setWidgetMode} />
230
+ </PanelHeader>
231
+ <Widgets mode={widgetMode} widgets={widgets} />
232
+ </div>
233
+ )}
234
+
235
+ {chatMode === 'sidebar' && (
236
+ <div
237
+ className={cn(
238
+ 'flex min-h-0 flex-col overflow-hidden px-3 pb-4 pt-2',
239
+ // Docked chat: caps at --chat-max on big screens (grow 0), shrinks
240
+ // down to --chat-min before the fit check flips it to floating.
241
+ hasWidgets ? 'min-w-[var(--chat-min)] flex-[0_1_var(--chat-max)]' : 'flex-1'
242
+ )}
243
+ >
244
+ {/* No widgets → the chat fills the panel, so cap and center it. */}
245
+ <div
246
+ className={cn(
247
+ 'flex min-h-0 w-full flex-1 flex-col',
248
+ !hasWidgets && 'mx-auto max-w-[var(--column-w)]'
249
+ )}
250
+ >
251
+ {chatPanel}
252
+ </div>
253
+ </div>
254
+ )}
255
+ </div>
256
+
257
+ {chatMode === 'floating' && (
258
+ <ChatPopup
259
+ defaultOpen={layout.chatMode === 'floating' && canFitSidebar}
260
+ container={themeRef}
261
+ >
262
+ {onClose => (
263
+ <ChatPanel
264
+ view={view}
265
+ input={input}
266
+ setInput={setInput}
267
+ processing={processing}
268
+ error={error}
269
+ onDismissError={dismissError}
270
+ send={send}
271
+ stop={stop}
272
+ chatMode={chatMode}
273
+ onSwitchThread={switchThread}
274
+ onModeChange={handleModeChange}
275
+ onClose={onClose}
276
+ />
277
+ )}
278
+ </ChatPopup>
279
+ )}
280
+ </div>
281
+ )
282
+ }
@@ -0,0 +1,48 @@
1
+ import { Button as ButtonPrimitive } from '@base-ui/react/button'
2
+ import { type VariantProps, cva } from 'class-variance-authority'
3
+
4
+ import { cn } from '@/client/lib/cn'
5
+
6
+ const buttonVariants = cva(
7
+ 'focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-3 inline-flex shrink-0 cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-sm text-sm font-medium outline-none transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0',
8
+ {
9
+ variants: {
10
+ variant: {
11
+ default:
12
+ 'bg-primary text-primary-foreground hover:bg-primary/90 disabled:bg-muted disabled:text-muted-foreground disabled:opacity-100',
13
+ secondary: 'bg-muted text-foreground hover:bg-muted/80',
14
+ outline: 'bg-background hover:bg-muted hover:text-foreground shadow-sm',
15
+ ghost: 'hover:bg-muted'
16
+ },
17
+ size: {
18
+ sm: 'rounded-xs h-6 gap-1 px-2 text-xs has-[>svg]:px-1.5 [&_svg]:size-4',
19
+ default: 'h-8 px-3 has-[>svg]:px-2.5 [&_svg]:size-5',
20
+ lg: 'h-10 rounded-lg px-4 has-[>svg]:px-3 [&_svg]:size-5',
21
+ 'icon-sm': 'rounded-xs size-6 [&_svg]:size-4',
22
+ icon: 'size-8 [&_svg]:size-5',
23
+ 'icon-lg': 'size-10 rounded-lg [&_svg]:size-5'
24
+ }
25
+ },
26
+ defaultVariants: {
27
+ variant: 'default',
28
+ size: 'default'
29
+ }
30
+ }
31
+ )
32
+
33
+ function Button({
34
+ className,
35
+ variant = 'default',
36
+ size = 'default',
37
+ ...props
38
+ }: ButtonPrimitive.Props & VariantProps<typeof buttonVariants>) {
39
+ return (
40
+ <ButtonPrimitive
41
+ data-slot="button"
42
+ className={cn(buttonVariants({ variant, size, className }))}
43
+ {...props}
44
+ />
45
+ )
46
+ }
47
+
48
+ export { Button, buttonVariants }
@@ -0,0 +1,257 @@
1
+ import type { ComponentProps } from 'react'
2
+
3
+ import { Menu as MenuPrimitive } from '@base-ui/react/menu'
4
+ import { IconCheck, IconChevronRight } from '@tabler/icons-react'
5
+
6
+ import { cn } from '@/client/lib/cn'
7
+
8
+ function DropdownMenu({ ...props }: MenuPrimitive.Root.Props) {
9
+ return <MenuPrimitive.Root data-slot="dropdown-menu" {...props} />
10
+ }
11
+
12
+ function DropdownMenuPortal({ ...props }: MenuPrimitive.Portal.Props) {
13
+ return <MenuPrimitive.Portal data-slot="dropdown-menu-portal" {...props} />
14
+ }
15
+
16
+ function DropdownMenuTrigger({ ...props }: MenuPrimitive.Trigger.Props) {
17
+ return <MenuPrimitive.Trigger data-slot="dropdown-menu-trigger" {...props} />
18
+ }
19
+
20
+ function DropdownMenuContent({
21
+ align = 'start',
22
+ alignOffset = 0,
23
+ side = 'bottom',
24
+ sideOffset = 4,
25
+ className,
26
+ ...props
27
+ }: MenuPrimitive.Popup.Props &
28
+ Pick<MenuPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'>) {
29
+ return (
30
+ <MenuPrimitive.Portal>
31
+ <MenuPrimitive.Positioner
32
+ className="isolate z-50 outline-none"
33
+ align={align}
34
+ alignOffset={alignOffset}
35
+ side={side}
36
+ sideOffset={sideOffset}
37
+ >
38
+ <MenuPrimitive.Popup
39
+ data-slot="dropdown-menu-content"
40
+ className={cn(
41
+ 'max-h-(--available-height) w-(--anchor-width) origin-(--transform-origin) bg-popover text-popover-foreground ring-foreground/10 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95 z-50 min-w-32 overflow-y-auto overflow-x-hidden rounded-md p-1 shadow-md outline-none ring-1 duration-100',
42
+ className
43
+ )}
44
+ {...props}
45
+ />
46
+ </MenuPrimitive.Positioner>
47
+ </MenuPrimitive.Portal>
48
+ )
49
+ }
50
+
51
+ function DropdownMenuGroup({ ...props }: MenuPrimitive.Group.Props) {
52
+ return <MenuPrimitive.Group data-slot="dropdown-menu-group" {...props} />
53
+ }
54
+
55
+ function DropdownMenuLabel({
56
+ className,
57
+ inset,
58
+ ...props
59
+ }: MenuPrimitive.GroupLabel.Props & {
60
+ inset?: boolean
61
+ }) {
62
+ return (
63
+ <MenuPrimitive.GroupLabel
64
+ data-slot="dropdown-menu-label"
65
+ data-inset={inset}
66
+ className={cn(
67
+ 'text-muted-foreground data-inset:pl-7 px-1.5 py-1 text-xs font-medium',
68
+ className
69
+ )}
70
+ {...props}
71
+ />
72
+ )
73
+ }
74
+
75
+ function DropdownMenuItem({
76
+ className,
77
+ inset,
78
+ variant = 'default',
79
+ ...props
80
+ }: MenuPrimitive.Item.Props & {
81
+ inset?: boolean
82
+ variant?: 'default' | 'destructive'
83
+ }) {
84
+ return (
85
+ <MenuPrimitive.Item
86
+ data-slot="dropdown-menu-item"
87
+ data-inset={inset}
88
+ data-variant={variant}
89
+ className={cn(
90
+ "group/dropdown-menu-item outline-hidden focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 data-[variant=destructive]:*:[svg]:text-destructive rounded-xs relative flex cursor-default select-none items-center gap-2 px-1.5 py-1 text-sm [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
91
+ className
92
+ )}
93
+ {...props}
94
+ />
95
+ )
96
+ }
97
+
98
+ function DropdownMenuSub({ ...props }: MenuPrimitive.SubmenuRoot.Props) {
99
+ return <MenuPrimitive.SubmenuRoot data-slot="dropdown-menu-sub" {...props} />
100
+ }
101
+
102
+ function DropdownMenuSubTrigger({
103
+ className,
104
+ inset,
105
+ children,
106
+ ...props
107
+ }: MenuPrimitive.SubmenuTrigger.Props & {
108
+ inset?: boolean
109
+ }) {
110
+ return (
111
+ <MenuPrimitive.SubmenuTrigger
112
+ data-slot="dropdown-menu-sub-trigger"
113
+ data-inset={inset}
114
+ className={cn(
115
+ "outline-hidden focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-popup-open:bg-accent data-popup-open:text-accent-foreground data-open:bg-accent data-open:text-accent-foreground rounded-xs flex cursor-default select-none items-center gap-2 px-1.5 py-1 text-sm [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
116
+ className
117
+ )}
118
+ {...props}
119
+ >
120
+ {children}
121
+ <IconChevronRight className="cn-rtl-flip ml-auto" stroke={1.5} />
122
+ </MenuPrimitive.SubmenuTrigger>
123
+ )
124
+ }
125
+
126
+ function DropdownMenuSubContent({
127
+ align = 'start',
128
+ alignOffset = -3,
129
+ side = 'right',
130
+ sideOffset = 0,
131
+ className,
132
+ ...props
133
+ }: ComponentProps<typeof DropdownMenuContent>) {
134
+ return (
135
+ <DropdownMenuContent
136
+ data-slot="dropdown-menu-sub-content"
137
+ className={cn(
138
+ 'bg-popover text-popover-foreground ring-foreground/10 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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 w-auto min-w-[96px] rounded-md p-1 shadow-lg ring-1 duration-100',
139
+ className
140
+ )}
141
+ align={align}
142
+ alignOffset={alignOffset}
143
+ side={side}
144
+ sideOffset={sideOffset}
145
+ {...props}
146
+ />
147
+ )
148
+ }
149
+
150
+ function DropdownMenuCheckboxItem({
151
+ className,
152
+ children,
153
+ checked,
154
+ inset,
155
+ ...props
156
+ }: MenuPrimitive.CheckboxItem.Props & {
157
+ inset?: boolean
158
+ }) {
159
+ return (
160
+ <MenuPrimitive.CheckboxItem
161
+ data-slot="dropdown-menu-checkbox-item"
162
+ data-inset={inset}
163
+ className={cn(
164
+ "outline-hidden focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 rounded-xs relative flex cursor-default select-none items-center gap-2 py-1 pl-2 pr-8 text-sm [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
165
+ className
166
+ )}
167
+ checked={checked}
168
+ {...props}
169
+ >
170
+ <span
171
+ className="pointer-events-none absolute right-2 flex items-center justify-center"
172
+ data-slot="dropdown-menu-checkbox-item-indicator"
173
+ >
174
+ <MenuPrimitive.CheckboxItemIndicator>
175
+ <IconCheck stroke={1.5} />
176
+ </MenuPrimitive.CheckboxItemIndicator>
177
+ </span>
178
+ {children}
179
+ </MenuPrimitive.CheckboxItem>
180
+ )
181
+ }
182
+
183
+ function DropdownMenuRadioGroup({ ...props }: MenuPrimitive.RadioGroup.Props) {
184
+ return <MenuPrimitive.RadioGroup data-slot="dropdown-menu-radio-group" {...props} />
185
+ }
186
+
187
+ function DropdownMenuRadioItem({
188
+ className,
189
+ children,
190
+ inset,
191
+ ...props
192
+ }: MenuPrimitive.RadioItem.Props & {
193
+ inset?: boolean
194
+ }) {
195
+ return (
196
+ <MenuPrimitive.RadioItem
197
+ data-slot="dropdown-menu-radio-item"
198
+ data-inset={inset}
199
+ className={cn(
200
+ "outline-hidden focus:bg-accent focus:text-accent-foreground focus:**:text-accent-foreground data-inset:pl-7 data-disabled:pointer-events-none data-disabled:opacity-50 rounded-xs relative flex cursor-default select-none items-center gap-2 py-1 pl-2 pr-8 text-sm [&_svg:not([class*='size-'])]:size-4 [&_svg]:pointer-events-none [&_svg]:shrink-0",
201
+ className
202
+ )}
203
+ {...props}
204
+ >
205
+ <span
206
+ className="pointer-events-none absolute right-2 flex items-center justify-center"
207
+ data-slot="dropdown-menu-radio-item-indicator"
208
+ >
209
+ <MenuPrimitive.RadioItemIndicator>
210
+ <IconCheck stroke={1.5} />
211
+ </MenuPrimitive.RadioItemIndicator>
212
+ </span>
213
+ {children}
214
+ </MenuPrimitive.RadioItem>
215
+ )
216
+ }
217
+
218
+ function DropdownMenuSeparator({ className, ...props }: MenuPrimitive.Separator.Props) {
219
+ return (
220
+ <MenuPrimitive.Separator
221
+ data-slot="dropdown-menu-separator"
222
+ className={cn('bg-border -mx-1 my-1 h-px', className)}
223
+ {...props}
224
+ />
225
+ )
226
+ }
227
+
228
+ function DropdownMenuShortcut({ className, ...props }: ComponentProps<'span'>) {
229
+ return (
230
+ <span
231
+ data-slot="dropdown-menu-shortcut"
232
+ className={cn(
233
+ 'text-muted-foreground group-focus/dropdown-menu-item:text-accent-foreground ml-auto text-xs tracking-widest',
234
+ className
235
+ )}
236
+ {...props}
237
+ />
238
+ )
239
+ }
240
+
241
+ export {
242
+ DropdownMenu,
243
+ DropdownMenuPortal,
244
+ DropdownMenuTrigger,
245
+ DropdownMenuContent,
246
+ DropdownMenuGroup,
247
+ DropdownMenuLabel,
248
+ DropdownMenuItem,
249
+ DropdownMenuCheckboxItem,
250
+ DropdownMenuRadioGroup,
251
+ DropdownMenuRadioItem,
252
+ DropdownMenuSeparator,
253
+ DropdownMenuShortcut,
254
+ DropdownMenuSub,
255
+ DropdownMenuSubTrigger,
256
+ DropdownMenuSubContent
257
+ }
@@ -0,0 +1,21 @@
1
+ import type { ComponentProps } from 'react'
2
+
3
+ import { Input as InputPrimitive } from '@base-ui/react/input'
4
+
5
+ import { cn } from '@/client/lib/cn'
6
+
7
+ function Input({ className, type, ...props }: ComponentProps<'input'>) {
8
+ return (
9
+ <InputPrimitive
10
+ type={type}
11
+ data-slot="input"
12
+ className={cn(
13
+ 'h-8 w-full min-w-0 rounded-md border border-input bg-transparent px-2.5 py-1 text-sm transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',
14
+ className
15
+ )}
16
+ {...props}
17
+ />
18
+ )
19
+ }
20
+
21
+ export { Input }
@@ -0,0 +1,79 @@
1
+ import type { ComponentProps } from 'react'
2
+
3
+ import { Popover as PopoverPrimitive } from '@base-ui/react/popover'
4
+
5
+ import { cn } from '@/client/lib/cn'
6
+
7
+ function Popover({ ...props }: PopoverPrimitive.Root.Props) {
8
+ return <PopoverPrimitive.Root data-slot="popover" {...props} />
9
+ }
10
+
11
+ function PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {
12
+ return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
13
+ }
14
+
15
+ function PopoverContent({
16
+ className,
17
+ align = 'center',
18
+ alignOffset = 0,
19
+ side = 'bottom',
20
+ sideOffset = 4,
21
+ keepMounted = false,
22
+ container,
23
+ ...props
24
+ }: PopoverPrimitive.Popup.Props &
25
+ Pick<PopoverPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'> &
26
+ Pick<PopoverPrimitive.Portal.Props, 'keepMounted' | 'container'>) {
27
+ return (
28
+ <PopoverPrimitive.Portal keepMounted={keepMounted} container={container}>
29
+ <PopoverPrimitive.Positioner
30
+ align={align}
31
+ alignOffset={alignOffset}
32
+ side={side}
33
+ sideOffset={sideOffset}
34
+ className="isolate z-50"
35
+ >
36
+ <PopoverPrimitive.Popup
37
+ data-slot="popover-content"
38
+ className={cn(
39
+ 'origin-(--transform-origin) bg-popover text-popover-foreground ring-foreground/5 outline-hidden data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95 z-50 flex w-72 flex-col gap-2.5 rounded-md p-2.5 text-sm shadow-md ring-1 duration-100',
40
+ className
41
+ )}
42
+ {...props}
43
+ />
44
+ </PopoverPrimitive.Positioner>
45
+ </PopoverPrimitive.Portal>
46
+ )
47
+ }
48
+
49
+ function PopoverHeader({ className, ...props }: ComponentProps<'div'>) {
50
+ return (
51
+ <div
52
+ data-slot="popover-header"
53
+ className={cn('flex flex-col gap-0.5 text-sm', className)}
54
+ {...props}
55
+ />
56
+ )
57
+ }
58
+
59
+ function PopoverTitle({ className, ...props }: PopoverPrimitive.Title.Props) {
60
+ return (
61
+ <PopoverPrimitive.Title
62
+ data-slot="popover-title"
63
+ className={cn('font-medium', className)}
64
+ {...props}
65
+ />
66
+ )
67
+ }
68
+
69
+ function PopoverDescription({ className, ...props }: PopoverPrimitive.Description.Props) {
70
+ return (
71
+ <PopoverPrimitive.Description
72
+ data-slot="popover-description"
73
+ className={cn('text-muted-foreground', className)}
74
+ {...props}
75
+ />
76
+ )
77
+ }
78
+
79
+ export { Popover, PopoverContent, PopoverDescription, PopoverHeader, PopoverTitle, PopoverTrigger }