moi-computer 0.5.2-next.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/AGENTS.md +9 -0
- package/client/api/app-ui-keys.ts +4 -0
- package/client/api/workspace-keys.ts +2 -2
- package/client/app/routes/WorkspaceRoute.tsx +8 -28
- package/client/app/shell/SidebarLayout.tsx +1 -1
- package/client/components/shared/Composer.tsx +15 -9
- package/client/components/shared/IconGhost.tsx +130 -0
- package/client/components/ui/dropdown-menu.tsx +2 -5
- package/client/components/ui/popover.tsx +11 -4
- package/client/components/ui/slider.tsx +70 -0
- package/client/components/ui/spinner.tsx +18 -0
- package/client/components/ui/toast.tsx +220 -0
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/features/chat/ChatComposer.tsx +11 -14
- package/client/features/chat/ChatPanel.tsx +15 -14
- package/client/features/chat/ChatPopup.tsx +10 -4
- package/client/features/chat/ChatSelector.tsx +263 -48
- package/client/features/chat/ModelPicker.tsx +295 -121
- package/client/features/chat/TurnView.tsx +1 -1
- package/client/features/chat/api.ts +36 -9
- package/client/features/chat/chat-frames.ts +35 -6
- package/client/features/chat/chat-send.ts +40 -6
- package/client/features/chat/chat-store.ts +52 -40
- package/client/features/chat/model-order.ts +50 -28
- package/client/features/chat/useChat.ts +71 -60
- package/client/features/chat/useSelectedSession.ts +151 -0
- package/client/features/chat/useStickToBottom.ts +3 -3
- package/client/features/home/api.ts +0 -2
- package/client/features/scratchpad/ScratchpadControls.tsx +2 -2
- package/client/features/settings/IconPicker.tsx +2 -2
- package/client/features/settings/WorkspaceSettings.tsx +6 -6
- package/client/features/views/ViewBuilderTab.tsx +3 -4
- package/client/features/views/api.ts +1 -0
- package/client/features/views/useViewBuilderActions.ts +7 -3
- package/client/features/workspace/WorkspaceScreen.tsx +40 -19
- package/client/features/workspace/WorkspaceSkillUpdateBanner.tsx +2 -2
- package/client/features/workspace/WorkspaceTabs.tsx +10 -1
- package/client/index.css +5 -3
- package/client/main.tsx +2 -0
- package/client/runtime/useWorkspaceEvents.ts +1 -0
- package/client/store/ui.ts +13 -3
- package/dist/{chunk-m9qja0nx.js → chunk-0pcdwjkp.js} +1 -1
- package/dist/chunk-55sh4dty.js +2 -0
- package/dist/{chunk-h3evrtyp.js → chunk-9y2zbzqz.js} +1 -1
- package/dist/{chunk-7bzpmtxp.js → chunk-afgbg75t.js} +1 -1
- package/dist/chunk-agtetn7n.css +1 -0
- package/dist/chunk-bv6vrvqf.js +27 -0
- package/dist/chunk-dfs36zgc.js +1 -0
- package/dist/chunk-exj6hr30.js +9 -0
- package/dist/{chunk-v797g6ap.js → chunk-m11ckkxd.js} +1 -1
- package/dist/chunk-n6t40enm.js +1 -0
- package/dist/{chunk-jg6ezptn.js → chunk-rxvx4ta9.js} +3 -3
- package/dist/index.html +1 -1
- package/lib/attachment-note.ts +18 -0
- package/lib/chat-title.ts +6 -0
- package/lib/types.ts +33 -10
- package/package.json +1 -1
- package/server/api.ts +100 -10
- package/server/app-settings.ts +1 -1
- package/server/data-dir.ts +1 -1
- package/server/harness/README.md +6 -0
- package/server/harness/claude-code/adapter.ts +2 -2
- package/server/harness/claude-code/index.ts +7 -1
- package/server/harness/claude-code/models.ts +25 -2
- package/server/harness/claude-code/session-title.ts +106 -0
- package/server/harness/claude-code/session.ts +114 -17
- package/server/harness/claude-code/sessions.ts +35 -4
- package/server/harness/codex/adapter.ts +27 -2
- package/server/harness/codex/client.ts +56 -9
- package/server/harness/codex/index.ts +2 -0
- package/server/harness/codex/session-title.ts +149 -0
- package/server/harness/codex/session.ts +96 -14
- package/server/harness/openclaw/adapter.ts +4 -2
- package/server/harness/openclaw/discovery.ts +2 -0
- package/server/harness/openclaw/session.ts +15 -7
- package/server/harness/session-title.ts +96 -0
- package/server/harness/types.ts +5 -2
- package/server/selected-session.ts +132 -0
- package/server/session-config.ts +146 -0
- package/server/web.ts +15 -1
- package/workspace/.claude/skills/moi-workspace/DESIGN.md +54 -68
- package/workspace/.claude/skills/moi-workspace/SKILL.md +8 -2
- package/dist/chunk-5vaevt8z.js +0 -2
- package/dist/chunk-fhhv99bd.js +0 -1
- package/dist/chunk-h0hk61pm.js +0 -9
- package/dist/chunk-k5sjx9s5.js +0 -1
- package/dist/chunk-rs9nb0fr.js +0 -27
- package/dist/chunk-s7za1qsv.css +0 -1
- package/server/thread-config.ts +0 -124
package/client/AGENTS.md
CHANGED
|
@@ -15,6 +15,15 @@ Before editing host-app UI, read `../DESIGN.md` and the relevant rules in `../.a
|
|
|
15
15
|
- UI components in `components/ui/` are shadcn built on Base UI React.
|
|
16
16
|
- `lib/cn.ts` is `clsx` + `tailwind-merge`.
|
|
17
17
|
|
|
18
|
+
## Vendored React
|
|
19
|
+
|
|
20
|
+
React is not bundled into the app. It ships as locally-vendored ESM in `vendor/react/` (development and production builds, generated by `scripts/build-vendor.ts`) and is served at `/vendor/react/*`, so moi runs fully offline — no CDN fetch.
|
|
21
|
+
|
|
22
|
+
- An importmap in `index.html` maps `react`, `react-dom`, and the jsx runtimes to the `/vendor/react/*` URLs. A preload script in the same file imports them, stores the modules on `globalThis.__esm`, and only then calls `__init` to mount the app — this load order is load-bearing.
|
|
23
|
+
- `externalize-react.ts` is a Bun bundler plugin that replaces those specifiers in bundled code with reads from `globalThis.__esm`. The point is ONE shared React instance across the host app and every applet/widget bundle (which resolve the same importmap); bundling React in would give each its own copy and break hooks.
|
|
24
|
+
- `structured-clone-shim.ts` must be the first import in `index.tsx`, before any tldraw module loads.
|
|
25
|
+
- HMR works across the bundle/vendor boundary; the `import.meta.hot.accept()` in `externalize-react.ts` is what stops every edit from escalating to a full page reload. See the comment in `index.tsx` before touching any of this.
|
|
26
|
+
|
|
18
27
|
## Frontend boundaries
|
|
19
28
|
|
|
20
29
|
- `app/` owns routes and the app shell. Route files load data and compose features; keep feature UI out of them.
|
|
@@ -9,8 +9,8 @@ export const workspaceKeys = {
|
|
|
9
9
|
viewBuilders: (id: string) => ['workspaces', 'view-builders', id] as const,
|
|
10
10
|
sessions: (id: string) => ['workspaces', 'sessions', id] as const,
|
|
11
11
|
events: (id: string, sessionId: string) => ['workspaces', 'events', id, sessionId] as const,
|
|
12
|
-
|
|
13
|
-
['workspaces', '
|
|
12
|
+
sessionConfig: (id: string, sessionId: string) =>
|
|
13
|
+
['workspaces', 'sessionConfig', id, sessionId] as const,
|
|
14
14
|
mcp: (id: string) => ['workspaces', 'mcp', id] as const,
|
|
15
15
|
models: (id: string) => ['workspaces', 'models', id] as const,
|
|
16
16
|
availability: (id: string) => ['workspaces', 'availability', id] as const,
|
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
import { useEffect } from 'react'
|
|
2
|
-
|
|
3
1
|
import { useQueryClient } from '@tanstack/react-query'
|
|
4
2
|
|
|
5
3
|
import { workspaceKeys } from '@/client/api/workspace-keys'
|
|
6
4
|
import { LedLogo } from '@/client/components/shared/LedLogo'
|
|
7
5
|
import { SidebarLayout } from '@/client/app/shell/SidebarLayout'
|
|
8
|
-
import {
|
|
9
|
-
import { useWorkspaceSessions } from '@/client/features/chat/api'
|
|
6
|
+
import { useSelectedSession } from '@/client/features/chat/useSelectedSession'
|
|
10
7
|
import { useAppletCacheInvalidation } from '@/client/features/applets/useApplet'
|
|
11
8
|
import { Workspace } from '@/client/features/workspace/WorkspaceContext'
|
|
12
9
|
import {
|
|
@@ -18,7 +15,6 @@ import { useWorkspaceViews, useWorkspaceWidgets } from '@/client/features/worksp
|
|
|
18
15
|
import { useViewBuilders } from '@/client/features/views/api'
|
|
19
16
|
import { useGridReconcile } from '@/client/features/widgets/useGridReconcile'
|
|
20
17
|
import { useWorkspaceEvent } from '@/client/runtime/useWorkspaceEvents'
|
|
21
|
-
import type { SessionInfo } from '@/lib/types'
|
|
22
18
|
|
|
23
19
|
type WorkspaceRouteProps = {
|
|
24
20
|
id: string
|
|
@@ -38,12 +34,11 @@ export function WorkspaceRoute({ id }: WorkspaceRouteProps) {
|
|
|
38
34
|
|
|
39
35
|
function WorkspaceLoader({ id }: WorkspaceRouteProps) {
|
|
40
36
|
const queryClient = useQueryClient()
|
|
37
|
+
const [selectedSessionId] = useSelectedSession()
|
|
41
38
|
const { layout, setLayout, isLoading: layoutLoading } = useWorkspaceLayoutCtx()
|
|
42
39
|
const widgets = useWorkspaceWidgets(id)
|
|
43
40
|
const views = useWorkspaceViews(id)
|
|
44
41
|
const builders = useViewBuilders(id)
|
|
45
|
-
const sessions = useWorkspaceSessions(id)
|
|
46
|
-
|
|
47
42
|
useGridReconcile(id, widgets.data, layout, setLayout)
|
|
48
43
|
useAppletCacheInvalidation()
|
|
49
44
|
|
|
@@ -59,11 +54,15 @@ function WorkspaceLoader({ id }: WorkspaceRouteProps) {
|
|
|
59
54
|
}
|
|
60
55
|
})
|
|
61
56
|
|
|
62
|
-
const fresh =
|
|
57
|
+
const fresh =
|
|
58
|
+
layoutLoading ||
|
|
59
|
+
selectedSessionId === undefined ||
|
|
60
|
+
widgets.isLoading ||
|
|
61
|
+
views.isLoading ||
|
|
62
|
+
builders.isLoading
|
|
63
63
|
|
|
64
64
|
return (
|
|
65
65
|
<>
|
|
66
|
-
<SeedActiveSession workspaceId={id} sessions={sessions.data} />
|
|
67
66
|
<SidebarLayout>
|
|
68
67
|
{fresh ? (
|
|
69
68
|
<div className="flex h-full items-center justify-center">
|
|
@@ -80,22 +79,3 @@ function WorkspaceLoader({ id }: WorkspaceRouteProps) {
|
|
|
80
79
|
</>
|
|
81
80
|
)
|
|
82
81
|
}
|
|
83
|
-
|
|
84
|
-
type SeedActiveSessionProps = {
|
|
85
|
-
workspaceId: string
|
|
86
|
-
sessions: SessionInfo[] | undefined
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
function SeedActiveSession({ workspaceId, sessions }: SeedActiveSessionProps) {
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (!sessions) return
|
|
92
|
-
const activeByWorkspace = liveStore.getState().activeByWorkspace
|
|
93
|
-
const hasActiveSelection = Object.prototype.hasOwnProperty.call(activeByWorkspace, workspaceId)
|
|
94
|
-
const activeSessionId = activeByWorkspace[workspaceId]
|
|
95
|
-
const activeStillValid =
|
|
96
|
-
activeSessionId === null || sessions.some(session => session.sessionId === activeSessionId)
|
|
97
|
-
if (hasActiveSelection && activeStillValid) return
|
|
98
|
-
liveStore.getState().setActive(workspaceId, sessions[0]?.sessionId ?? null)
|
|
99
|
-
}, [workspaceId, sessions])
|
|
100
|
-
return null
|
|
101
|
-
}
|
|
@@ -77,7 +77,7 @@ function Sidebar({ workspaces }: SidebarProps) {
|
|
|
77
77
|
const reorder = useReorderWorkspaces()
|
|
78
78
|
|
|
79
79
|
return (
|
|
80
|
-
<aside className="flex h-full shrink-0 flex-col items-center gap-4 px-2 py-5">
|
|
80
|
+
<aside className="flex h-full shrink-0 flex-col items-center gap-4 px-2 py-5 [font-family:var(--default-sans)]">
|
|
81
81
|
<Link href="/" aria-label="Home" title="Home" className={sidebarNavButtonClass}>
|
|
82
82
|
<IconSmartHome stroke={1.5} />
|
|
83
83
|
</Link>
|
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import type { ComponentProps, RefObject } from 'react'
|
|
2
2
|
|
|
3
|
-
import { IconArrowUp
|
|
3
|
+
import { IconArrowUp } from '@tabler/icons-react'
|
|
4
4
|
|
|
5
5
|
import { Button } from '@/client/components/ui/button'
|
|
6
6
|
import { Tooltip, TooltipContent, TooltipTrigger } from '@/client/components/ui/tooltip'
|
|
7
7
|
import { cn } from '@/client/lib/cn'
|
|
8
|
+
import { Spinner } from '../ui/spinner'
|
|
8
9
|
|
|
9
10
|
type ComposerProps = Omit<ComponentProps<'form'>, 'ref'> & {
|
|
10
11
|
composerRef: RefObject<HTMLTextAreaElement | null>
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
type ComposerFocusTarget = Pick<HTMLTextAreaElement, 'focus' | 'setSelectionRange' | 'value'>
|
|
15
|
+
|
|
16
|
+
export function focusComposer(composer: ComposerFocusTarget | null) {
|
|
17
|
+
if (!composer) return
|
|
18
|
+
composer.focus()
|
|
19
|
+
const end = composer.value.length
|
|
20
|
+
composer.setSelectionRange(end, end)
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
export function Composer({
|
|
14
24
|
composerRef,
|
|
15
25
|
className,
|
|
@@ -28,10 +38,10 @@ export function Composer({
|
|
|
28
38
|
event.target.closest('button, input, textarea, select, a, [contenteditable="true"]')
|
|
29
39
|
)
|
|
30
40
|
return
|
|
31
|
-
composerRef.current
|
|
41
|
+
focusComposer(composerRef.current)
|
|
32
42
|
}}
|
|
33
43
|
className={cn(
|
|
34
|
-
'flex w-full cursor-text flex-col gap-1 rounded-xl bg-card p-2 text-card-foreground shadow-xs transition-[color,box-shadow] outline-none focus-within:shadow-sm',
|
|
44
|
+
'group/composer flex w-full cursor-text flex-col gap-1 rounded-xl bg-card p-2 text-card-foreground shadow-xs transition-[color,box-shadow] outline-none focus-within:shadow-sm',
|
|
35
45
|
className
|
|
36
46
|
)}
|
|
37
47
|
>
|
|
@@ -61,7 +71,7 @@ type ComposerFooterProps = ComponentProps<'div'>
|
|
|
61
71
|
|
|
62
72
|
export function ComposerFooter({ className, children, ...props }: ComposerFooterProps) {
|
|
63
73
|
return (
|
|
64
|
-
<div {...props} className={cn('flex items-center justify-end gap-
|
|
74
|
+
<div {...props} className={cn('flex items-center justify-end gap-3', className)}>
|
|
65
75
|
{children}
|
|
66
76
|
</div>
|
|
67
77
|
)
|
|
@@ -93,11 +103,7 @@ export function ComposerSubmitButton({
|
|
|
93
103
|
const canSubmit = canSubmitComposerAction(hasContent, busy || loading, unavailableReason)
|
|
94
104
|
const button = (
|
|
95
105
|
<Button type="submit" size="icon" disabled={!canSubmit} aria-label={label}>
|
|
96
|
-
{loading ?
|
|
97
|
-
<IconLoader2 stroke={1.5} className="animate-spin" />
|
|
98
|
-
) : (
|
|
99
|
-
<IconArrowUp stroke={1.5} />
|
|
100
|
-
)}
|
|
106
|
+
{loading ? <Spinner /> : <IconArrowUp stroke={1.5} />}
|
|
101
107
|
</Button>
|
|
102
108
|
)
|
|
103
109
|
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { forwardRef } from 'react'
|
|
2
|
+
|
|
3
|
+
import { motion, useReducedMotion } from 'motion/react'
|
|
4
|
+
|
|
5
|
+
import { IconGhost as TablerIconGhost, type IconProps } from '@tabler/icons-react'
|
|
6
|
+
|
|
7
|
+
import { cn } from '@/client/lib/cn'
|
|
8
|
+
|
|
9
|
+
type IconGhostProps = IconProps & {
|
|
10
|
+
animated?: boolean
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type Point = {
|
|
14
|
+
x: number
|
|
15
|
+
y: number
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const bodyPath =
|
|
19
|
+
'M5 11a7 7 0 0 1 14 0v7a1.78 1.78 0 0 1 -3.1 1.4a1.65 1.65 0 0 0 -2.6 0a1.65 1.65 0 0 1 -2.6 0a1.65 1.65 0 0 0 -2.6 0a1.78 1.78 0 0 1 -3.1 -1.4v-7'
|
|
20
|
+
|
|
21
|
+
const animatedEdgeY = 18.85
|
|
22
|
+
|
|
23
|
+
function formatPoint(value: number): string {
|
|
24
|
+
return value.toFixed(3)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function smoothPath(points: Point[]): string {
|
|
28
|
+
let path = ''
|
|
29
|
+
|
|
30
|
+
for (let index = 0; index < points.length - 1; index += 1) {
|
|
31
|
+
const previous = points[index - 1] ?? points[index]
|
|
32
|
+
const current = points[index]
|
|
33
|
+
const next = points[index + 1]
|
|
34
|
+
const afterNext = points[index + 2] ?? next
|
|
35
|
+
const firstControl =
|
|
36
|
+
index === 0
|
|
37
|
+
? { x: current.x, y: current.y + 0.4 }
|
|
38
|
+
: {
|
|
39
|
+
x: current.x + (next.x - previous.x) / 6,
|
|
40
|
+
y: current.y + (next.y - previous.y) / 6
|
|
41
|
+
}
|
|
42
|
+
const secondControl =
|
|
43
|
+
index === points.length - 2
|
|
44
|
+
? { x: next.x, y: next.y + 0.4 }
|
|
45
|
+
: {
|
|
46
|
+
x: next.x - (afterNext.x - current.x) / 6,
|
|
47
|
+
y: next.y - (afterNext.y - current.y) / 6
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
path += `C${formatPoint(firstControl.x)} ${formatPoint(firstControl.y)} ${formatPoint(secondControl.x)} ${formatPoint(secondControl.y)} ${formatPoint(next.x)} ${formatPoint(next.y)}`
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return path
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function bodyPathAt(progress: number): string {
|
|
57
|
+
const phase = progress * Math.PI * 2
|
|
58
|
+
const verticalProgress = 1 - Math.abs(progress * 2 - 1)
|
|
59
|
+
const verticalOffset = verticalProgress * 1.55
|
|
60
|
+
const edgeY = animatedEdgeY + verticalOffset
|
|
61
|
+
const points = Array.from({ length: 13 }, (_, index): Point => {
|
|
62
|
+
const horizontalProgress = index / 12
|
|
63
|
+
const envelope = Math.sin(Math.PI * horizontalProgress) ** 0.35
|
|
64
|
+
const baseline = edgeY + 0.3 * envelope
|
|
65
|
+
const wave = 0.55 * envelope * Math.sin(5 * Math.PI * horizontalProgress - phase)
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
x: 5 + 14 * horizontalProgress,
|
|
69
|
+
y: baseline + wave
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
const sideLength = edgeY - 11
|
|
73
|
+
|
|
74
|
+
return `M5 11a7 7 0 0 1 14 0v${formatPoint(sideLength)}${smoothPath(points.reverse())}v-${formatPoint(sideLength)}`
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const animatedBodyPaths = Array.from({ length: 17 }, (_, index) => bodyPathAt(index / 16))
|
|
78
|
+
|
|
79
|
+
const IconGhost = forwardRef<SVGSVGElement, IconGhostProps>(function IconGhost(
|
|
80
|
+
{
|
|
81
|
+
animated = false,
|
|
82
|
+
color = 'currentColor',
|
|
83
|
+
size = 24,
|
|
84
|
+
stroke = 2,
|
|
85
|
+
title,
|
|
86
|
+
className,
|
|
87
|
+
children,
|
|
88
|
+
...props
|
|
89
|
+
},
|
|
90
|
+
ref
|
|
91
|
+
) {
|
|
92
|
+
const prefersReducedMotion = useReducedMotion()
|
|
93
|
+
const shouldAnimate = animated && !prefersReducedMotion
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
<svg
|
|
97
|
+
ref={ref}
|
|
98
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
99
|
+
width={size}
|
|
100
|
+
height={size}
|
|
101
|
+
viewBox="0 0 24 24"
|
|
102
|
+
fill="none"
|
|
103
|
+
stroke={color}
|
|
104
|
+
strokeWidth={stroke}
|
|
105
|
+
strokeLinecap="round"
|
|
106
|
+
strokeLinejoin="round"
|
|
107
|
+
className={cn('tabler-icon tabler-icon-ghost', className)}
|
|
108
|
+
{...props}
|
|
109
|
+
>
|
|
110
|
+
{title && <title>{title}</title>}
|
|
111
|
+
{shouldAnimate ? (
|
|
112
|
+
<motion.path
|
|
113
|
+
d={animatedBodyPaths[0]}
|
|
114
|
+
animate={{ d: animatedBodyPaths }}
|
|
115
|
+
transition={{ duration: 2, ease: 'linear', repeat: Infinity }}
|
|
116
|
+
/>
|
|
117
|
+
) : (
|
|
118
|
+
<path d={bodyPath} />
|
|
119
|
+
)}
|
|
120
|
+
<path d="M10 10l.01 0" />
|
|
121
|
+
<path d="M14 10l.01 0" />
|
|
122
|
+
<path d="M10 14a3.5 3.5 0 0 0 4 0" />
|
|
123
|
+
{children}
|
|
124
|
+
</svg>
|
|
125
|
+
)
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
IconGhost.displayName = TablerIconGhost.displayName
|
|
129
|
+
|
|
130
|
+
export { IconGhost }
|
|
@@ -63,10 +63,7 @@ function DropdownMenuLabel({
|
|
|
63
63
|
<MenuPrimitive.GroupLabel
|
|
64
64
|
data-slot="dropdown-menu-label"
|
|
65
65
|
data-inset={inset}
|
|
66
|
-
className={cn(
|
|
67
|
-
'px-2 py-1 text-xs font-medium text-muted-foreground data-inset:pl-7',
|
|
68
|
-
className
|
|
69
|
-
)}
|
|
66
|
+
className={cn('px-2 pt-1.5 pb-0.5 text-xs text-muted-foreground data-inset:pl-7', className)}
|
|
70
67
|
{...props}
|
|
71
68
|
/>
|
|
72
69
|
)
|
|
@@ -219,7 +216,7 @@ function DropdownMenuSeparator({ className, ...props }: MenuPrimitive.Separator.
|
|
|
219
216
|
return (
|
|
220
217
|
<MenuPrimitive.Separator
|
|
221
218
|
data-slot="dropdown-menu-separator"
|
|
222
|
-
className={cn('
|
|
219
|
+
className={cn('mx-2 my-1 h-px bg-border', className)}
|
|
223
220
|
{...props}
|
|
224
221
|
/>
|
|
225
222
|
)
|
|
@@ -12,23 +12,30 @@ function PopoverTrigger({ ...props }: PopoverPrimitive.Trigger.Props) {
|
|
|
12
12
|
return <PopoverPrimitive.Trigger data-slot="popover-trigger" {...props} />
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
type PopoverContentProps = PopoverPrimitive.Popup.Props &
|
|
16
|
+
Pick<
|
|
17
|
+
PopoverPrimitive.Positioner.Props,
|
|
18
|
+
'align' | 'alignOffset' | 'disableAnchorTracking' | 'side' | 'sideOffset'
|
|
19
|
+
> &
|
|
20
|
+
Pick<PopoverPrimitive.Portal.Props, 'keepMounted' | 'container'>
|
|
21
|
+
|
|
15
22
|
function PopoverContent({
|
|
16
23
|
className,
|
|
17
24
|
align = 'center',
|
|
18
25
|
alignOffset = 0,
|
|
26
|
+
disableAnchorTracking = false,
|
|
19
27
|
side = 'bottom',
|
|
20
28
|
sideOffset = 4,
|
|
21
29
|
keepMounted = false,
|
|
22
30
|
container,
|
|
23
31
|
...props
|
|
24
|
-
}:
|
|
25
|
-
Pick<PopoverPrimitive.Positioner.Props, 'align' | 'alignOffset' | 'side' | 'sideOffset'> &
|
|
26
|
-
Pick<PopoverPrimitive.Portal.Props, 'keepMounted' | 'container'>) {
|
|
32
|
+
}: PopoverContentProps) {
|
|
27
33
|
return (
|
|
28
34
|
<PopoverPrimitive.Portal keepMounted={keepMounted} container={container}>
|
|
29
35
|
<PopoverPrimitive.Positioner
|
|
30
36
|
align={align}
|
|
31
37
|
alignOffset={alignOffset}
|
|
38
|
+
disableAnchorTracking={disableAnchorTracking}
|
|
32
39
|
side={side}
|
|
33
40
|
sideOffset={sideOffset}
|
|
34
41
|
className="isolate z-50"
|
|
@@ -36,7 +43,7 @@ function PopoverContent({
|
|
|
36
43
|
<PopoverPrimitive.Popup
|
|
37
44
|
data-slot="popover-content"
|
|
38
45
|
className={cn(
|
|
39
|
-
'z-50 flex w-72 origin-(--transform-origin) flex-col gap-
|
|
46
|
+
'z-50 flex w-72 origin-(--transform-origin) flex-col gap-3 rounded-lg bg-popover p-3 text-sm text-popover-foreground shadow-md ring-1 ring-border outline-hidden duration-100 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',
|
|
40
47
|
className
|
|
41
48
|
)}
|
|
42
49
|
{...props}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { useEffect, useState } from 'react'
|
|
2
|
+
|
|
3
|
+
import { Slider as SliderPrimitive } from '@base-ui/react/slider'
|
|
4
|
+
|
|
5
|
+
import { cn } from '@/client/lib/cn'
|
|
6
|
+
|
|
7
|
+
function Slider({
|
|
8
|
+
children,
|
|
9
|
+
className,
|
|
10
|
+
defaultValue,
|
|
11
|
+
value,
|
|
12
|
+
min = 0,
|
|
13
|
+
max = 100,
|
|
14
|
+
...props
|
|
15
|
+
}: SliderPrimitive.Root.Props) {
|
|
16
|
+
const [animationReady, setAnimationReady] = useState(false)
|
|
17
|
+
const _values = Array.isArray(value)
|
|
18
|
+
? value
|
|
19
|
+
: Array.isArray(defaultValue)
|
|
20
|
+
? defaultValue
|
|
21
|
+
: [min, max]
|
|
22
|
+
|
|
23
|
+
// Let Base UI measure the initial positions before transitions are enabled.
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const frame = requestAnimationFrame(() => setAnimationReady(true))
|
|
26
|
+
return () => cancelAnimationFrame(frame)
|
|
27
|
+
}, [])
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<SliderPrimitive.Root
|
|
31
|
+
className={cn('data-horizontal:w-full data-vertical:h-full', className)}
|
|
32
|
+
data-slot="slider"
|
|
33
|
+
defaultValue={defaultValue}
|
|
34
|
+
value={value}
|
|
35
|
+
min={min}
|
|
36
|
+
max={max}
|
|
37
|
+
thumbAlignment="edge"
|
|
38
|
+
{...props}
|
|
39
|
+
>
|
|
40
|
+
<SliderPrimitive.Control className="relative flex w-full touch-none items-center select-none data-disabled:opacity-50 data-vertical:h-full data-vertical:min-h-40 data-vertical:w-auto data-vertical:flex-col">
|
|
41
|
+
<SliderPrimitive.Track
|
|
42
|
+
data-slot="slider-track"
|
|
43
|
+
className="relative grow overflow-hidden rounded-full bg-muted select-none data-horizontal:h-1 data-horizontal:w-full data-vertical:h-full data-vertical:w-1"
|
|
44
|
+
>
|
|
45
|
+
<SliderPrimitive.Indicator
|
|
46
|
+
data-slot="slider-range"
|
|
47
|
+
className={cn(
|
|
48
|
+
'bg-primary select-none data-horizontal:h-full data-vertical:w-full',
|
|
49
|
+
animationReady && 'transition-[width] duration-150 ease-in-out'
|
|
50
|
+
)}
|
|
51
|
+
/>
|
|
52
|
+
</SliderPrimitive.Track>
|
|
53
|
+
{children}
|
|
54
|
+
{Array.from({ length: _values.length }, (_, index) => (
|
|
55
|
+
<SliderPrimitive.Thumb
|
|
56
|
+
data-slot="slider-thumb"
|
|
57
|
+
key={index}
|
|
58
|
+
className={cn(
|
|
59
|
+
'relative block size-3 shrink-0 cursor-ew-resize rounded-full border border-ring bg-white ring-ring/50 select-none after:absolute after:-inset-2 hover:ring-3 focus-visible:ring-3 focus-visible:outline-hidden active:ring-3 disabled:pointer-events-none disabled:opacity-50',
|
|
60
|
+
animationReady &&
|
|
61
|
+
'transition-[inset-inline-start,color,box-shadow] duration-150 ease-in-out'
|
|
62
|
+
)}
|
|
63
|
+
/>
|
|
64
|
+
))}
|
|
65
|
+
</SliderPrimitive.Control>
|
|
66
|
+
</SliderPrimitive.Root>
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export { Slider }
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { IconLoader2 } from '@tabler/icons-react'
|
|
2
|
+
|
|
3
|
+
import { cn } from '@/client/lib/cn'
|
|
4
|
+
|
|
5
|
+
function Spinner({ className, ...props }: React.ComponentProps<typeof IconLoader2>) {
|
|
6
|
+
return (
|
|
7
|
+
<IconLoader2
|
|
8
|
+
data-slot="spinner"
|
|
9
|
+
role="status"
|
|
10
|
+
aria-label="Loading"
|
|
11
|
+
className={cn('size-4 animate-spin', className)}
|
|
12
|
+
stroke={1.75}
|
|
13
|
+
{...props}
|
|
14
|
+
/>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { Spinner }
|