@schemavaults/ui 0.117.1 → 0.119.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/dist/components/ui/agent-sessions/agent-sessions-context.d.ts +72 -0
- package/dist/components/ui/agent-sessions/agent-sessions-context.js +41 -0
- package/dist/components/ui/agent-sessions/agent-sessions-context.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog-context.d.ts +10 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog-context.js +16 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog-context.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog.d.ts +61 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog.js +113 -0
- package/dist/components/ui/agent-sessions/agent-sessions-dialog.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-draft-store.d.ts +20 -0
- package/dist/components/ui/agent-sessions/agent-sessions-draft-store.js +38 -0
- package/dist/components/ui/agent-sessions/agent-sessions-draft-store.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-list.d.ts +126 -0
- package/dist/components/ui/agent-sessions/agent-sessions-list.js +191 -0
- package/dist/components/ui/agent-sessions/agent-sessions-list.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-main.d.ts +93 -0
- package/dist/components/ui/agent-sessions/agent-sessions-main.js +67 -0
- package/dist/components/ui/agent-sessions/agent-sessions-main.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-model.d.ts +103 -0
- package/dist/components/ui/agent-sessions/agent-sessions-model.js +176 -0
- package/dist/components/ui/agent-sessions/agent-sessions-model.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-prompt-input.d.ts +37 -0
- package/dist/components/ui/agent-sessions/agent-sessions-prompt-input.js +49 -0
- package/dist/components/ui/agent-sessions/agent-sessions-prompt-input.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-sidebar.d.ts +84 -0
- package/dist/components/ui/agent-sessions/agent-sessions-sidebar.js +148 -0
- package/dist/components/ui/agent-sessions/agent-sessions-sidebar.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions-start.d.ts +63 -0
- package/dist/components/ui/agent-sessions/agent-sessions-start.js +49 -0
- package/dist/components/ui/agent-sessions/agent-sessions-start.js.map +1 -0
- package/dist/components/ui/agent-sessions/agent-sessions.d.ts +71 -0
- package/dist/components/ui/agent-sessions/agent-sessions.js +201 -0
- package/dist/components/ui/agent-sessions/agent-sessions.js.map +1 -0
- package/dist/components/ui/agent-sessions/index.d.ts +20 -0
- package/dist/components/ui/agent-sessions/index.js +11 -0
- package/dist/components/ui/agent-sessions/index.js.map +1 -0
- package/dist/components/ui/agent-sessions/local-day.d.ts +8 -0
- package/dist/components/ui/agent-sessions/local-day.js +17 -0
- package/dist/components/ui/agent-sessions/local-day.js.map +1 -0
- package/dist/components/ui/agent-sessions/merge-refs.d.ts +6 -0
- package/dist/components/ui/agent-sessions/merge-refs.js +17 -0
- package/dist/components/ui/agent-sessions/merge-refs.js.map +1 -0
- package/dist/components/ui/aspect-ratio/aspect-ratio.d.ts +1 -1
- package/dist/components/ui/chip/chip.d.ts +1 -1
- package/dist/components/ui/countdown/countdown.d.ts +3 -3
- package/dist/components/ui/index.d.ts +4 -0
- package/dist/components/ui/index.js +2 -0
- package/dist/components/ui/index.js.map +1 -1
- package/dist/components/ui/mark/mark.d.ts +1 -1
- package/dist/components/ui/pagination/pagination.d.ts +1 -1
- package/dist/components/ui/relative-time/format-relative-time.d.ts +57 -0
- package/dist/components/ui/relative-time/format-relative-time.js +126 -0
- package/dist/components/ui/relative-time/format-relative-time.js.map +1 -0
- package/dist/components/ui/relative-time/index.d.ts +5 -0
- package/dist/components/ui/relative-time/index.js +4 -0
- package/dist/components/ui/relative-time/index.js.map +1 -0
- package/dist/components/ui/relative-time/relative-time.d.ts +73 -0
- package/dist/components/ui/relative-time/relative-time.js +171 -0
- package/dist/components/ui/relative-time/relative-time.js.map +1 -0
- package/dist/components/ui/ribbon/ribbon.d.ts +1 -1
- package/dist/components/ui/segmented-bar/segmented-bar.d.ts +1 -1
- package/dist/components/ui/uptime-bar/uptime-bar.d.ts +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type MutableRefObject, type ReactNode, type RefObject } from "react";
|
|
2
|
+
import type { AgentSession } from "./agent-sessions-model";
|
|
3
|
+
import type { AgentSessionDraftKey, AgentSessionsDraftStore } from "./agent-sessions-draft-store";
|
|
4
|
+
export declare const agentSessionsSidebarModeIds: readonly ["auto", "inline", "overlay"];
|
|
5
|
+
/**
|
|
6
|
+
* How the session list sits next to the conversation:
|
|
7
|
+
*
|
|
8
|
+
* - `inline` — a column beside it that the toggle collapses and expands.
|
|
9
|
+
* - `overlay` — a drawer that slides over it, behind a scrim.
|
|
10
|
+
* - `auto` — `overlay` while the `<AgentSessions>` element itself is
|
|
11
|
+
* narrower than `overlayBelowPx`, `inline` otherwise. It measures the
|
|
12
|
+
* component rather than the viewport, so it also does the right thing
|
|
13
|
+
* inside a dialog on a wide screen.
|
|
14
|
+
*/
|
|
15
|
+
export type AgentSessionsSidebarModeId = (typeof agentSessionsSidebarModeIds)[number];
|
|
16
|
+
export type AgentSessionsResolvedSidebarMode = Exclude<AgentSessionsSidebarModeId, "auto">;
|
|
17
|
+
/**
|
|
18
|
+
* `new` while no session is active (the new-session screen shows), and
|
|
19
|
+
* `session` while one is (its conversation shows).
|
|
20
|
+
*/
|
|
21
|
+
export type AgentSessionsView = "new" | "session";
|
|
22
|
+
export interface AgentSessionsContextValue<TSession extends AgentSession = AgentSession> {
|
|
23
|
+
sessions: readonly TSession[];
|
|
24
|
+
/** The active session's id, or `null` on the new-session screen. */
|
|
25
|
+
activeSessionId: string | null;
|
|
26
|
+
/**
|
|
27
|
+
* The active session's summary. `undefined` on the new-session screen —
|
|
28
|
+
* and also while `activeSessionId` names a session not yet in `sessions`
|
|
29
|
+
* (e.g. one you just created and have not added to the list yet).
|
|
30
|
+
*/
|
|
31
|
+
activeSession: TSession | undefined;
|
|
32
|
+
view: AgentSessionsView;
|
|
33
|
+
/** Resume a session. Closes the overlay sidebar (see `closeSidebarOnSelect`). */
|
|
34
|
+
selectSession: (sessionId: string) => void;
|
|
35
|
+
/** Show the new-session screen. Closes the overlay sidebar too. */
|
|
36
|
+
startNewSession: () => void;
|
|
37
|
+
sidebarMode: AgentSessionsResolvedSidebarMode;
|
|
38
|
+
sidebarOpen: boolean;
|
|
39
|
+
setSidebarOpen: (open: boolean) => void;
|
|
40
|
+
toggleSidebar: () => void;
|
|
41
|
+
/** `id` of the sidebar element, for `aria-controls`. */
|
|
42
|
+
sidebarId: string;
|
|
43
|
+
searchQuery: string;
|
|
44
|
+
setSearchQuery: (query: string) => void;
|
|
45
|
+
/** Header title on the new-session screen. */
|
|
46
|
+
newSessionTitle: ReactNode;
|
|
47
|
+
/** Per-session draft prompts. Prefer `useAgentSessionDraft()`. */
|
|
48
|
+
draftStore: AgentSessionsDraftStore;
|
|
49
|
+
/** Focus the prompt of the current view, with the caret at the end. */
|
|
50
|
+
focusComposer: () => void;
|
|
51
|
+
/** @internal The textarea `focusComposer()` focuses. */
|
|
52
|
+
composerTextareaRef: MutableRefObject<RefObject<HTMLTextAreaElement | null> | null>;
|
|
53
|
+
/** @internal `false` until the component's width has been measured. */
|
|
54
|
+
isMeasured: boolean;
|
|
55
|
+
}
|
|
56
|
+
export declare const AgentSessionsContext: import("react").Context<AgentSessionsContextValue<AgentSession> | null>;
|
|
57
|
+
export declare function useAgentSessionsContext<TSession extends AgentSession = AgentSession>(component: string): AgentSessionsContextValue<TSession>;
|
|
58
|
+
/**
|
|
59
|
+
* Read and drive the surrounding `<AgentSessions>`: the active session, the
|
|
60
|
+
* sidebar, the search query. Use it to build custom buttons, inputs and
|
|
61
|
+
* menus that act on the sessions. Pass your session type to get it back:
|
|
62
|
+
* `useAgentSessions<MySession>()`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function useAgentSessions<TSession extends AgentSession = AgentSession>(): AgentSessionsContextValue<TSession>;
|
|
65
|
+
/**
|
|
66
|
+
* The draft prompt kept for a session, as a `[value, setValue]` pair — for
|
|
67
|
+
* wiring your own textarea or input to the per-session drafts that
|
|
68
|
+
* `<AgentSessionsPromptInput>` uses. With no argument it follows the active
|
|
69
|
+
* session (or the new-session screen); pass a session id, or `null` for the
|
|
70
|
+
* new-session screen, to pin one.
|
|
71
|
+
*/
|
|
72
|
+
export declare function useAgentSessionDraft(key?: AgentSessionDraftKey): [string, (value: string) => void];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useCallback, useContext, useSyncExternalStore, } from "react";
|
|
3
|
+
export const agentSessionsSidebarModeIds = [
|
|
4
|
+
"auto",
|
|
5
|
+
"inline",
|
|
6
|
+
"overlay",
|
|
7
|
+
];
|
|
8
|
+
export const AgentSessionsContext = createContext(null);
|
|
9
|
+
export function useAgentSessionsContext(component) {
|
|
10
|
+
const ctx = useContext(AgentSessionsContext);
|
|
11
|
+
if (ctx === null) {
|
|
12
|
+
throw new Error(`<${component}> must be rendered inside an <AgentSessions> parent.`);
|
|
13
|
+
}
|
|
14
|
+
return ctx;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Read and drive the surrounding `<AgentSessions>`: the active session, the
|
|
18
|
+
* sidebar, the search query. Use it to build custom buttons, inputs and
|
|
19
|
+
* menus that act on the sessions. Pass your session type to get it back:
|
|
20
|
+
* `useAgentSessions<MySession>()`.
|
|
21
|
+
*/
|
|
22
|
+
export function useAgentSessions() {
|
|
23
|
+
return useAgentSessionsContext("useAgentSessions");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The draft prompt kept for a session, as a `[value, setValue]` pair — for
|
|
27
|
+
* wiring your own textarea or input to the per-session drafts that
|
|
28
|
+
* `<AgentSessionsPromptInput>` uses. With no argument it follows the active
|
|
29
|
+
* session (or the new-session screen); pass a session id, or `null` for the
|
|
30
|
+
* new-session screen, to pin one.
|
|
31
|
+
*/
|
|
32
|
+
export function useAgentSessionDraft(key) {
|
|
33
|
+
const ctx = useAgentSessionsContext("useAgentSessionDraft");
|
|
34
|
+
const draftKey = key === undefined ? ctx.activeSessionId : key;
|
|
35
|
+
const { draftStore } = ctx;
|
|
36
|
+
const getSnapshot = useCallback(() => draftStore.get(draftKey), [draftStore, draftKey]);
|
|
37
|
+
const value = useSyncExternalStore(draftStore.subscribe, getSnapshot, getSnapshot);
|
|
38
|
+
const setValue = useCallback((next) => draftStore.set(draftKey, next), [draftStore, draftKey]);
|
|
39
|
+
return [value, setValue];
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=agent-sessions-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-sessions-context.js","sourceRoot":"","sources":["../../../../src/components/ui/agent-sessions/agent-sessions-context.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EACL,aAAa,EACb,WAAW,EACX,UAAU,EACV,oBAAoB,GAIrB,MAAM,OAAO,CAAC;AAQf,MAAM,CAAC,MAAM,2BAA2B,GAAG;IACzC,MAAM;IACN,QAAQ;IACR,SAAS;CAC2B,CAAC;AAoEvC,MAAM,CAAC,MAAM,oBAAoB,GAC/B,aAAa,CAAmC,IAAI,CAAC,CAAC;AAExD,MAAM,UAAU,uBAAuB,CAErC,SAAiB;IACjB,MAAM,GAAG,GAAG,UAAU,CAAC,oBAAoB,CAAC,CAAC;IAC7C,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACb,IAAI,SAAS,sDAAsD,CACpE,CAAC;IACJ,CAAC;IACD,OAAO,GAAqD,CAAC;AAC/D,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB;IAG9B,OAAO,uBAAuB,CAAW,kBAAkB,CAAC,CAAC;AAC/D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,oBAAoB,CAClC,GAA0B;IAE1B,MAAM,GAAG,GAAG,uBAAuB,CAAC,sBAAsB,CAAC,CAAC;IAC5D,MAAM,QAAQ,GACZ,GAAG,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,CAAC;IAChD,MAAM,EAAE,UAAU,EAAE,GAAG,GAAG,CAAC;IAE3B,MAAM,WAAW,GAAG,WAAW,CAC7B,GAAW,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,EACtC,CAAC,UAAU,EAAE,QAAQ,CAAC,CACvB,CAAC;IACF,MAAM,KAAK,GAAW,oBAAoB,CACxC,UAAU,CAAC,SAAS,EACpB,WAAW,EACX,WAAW,CACZ,CAAC;IACF,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,IAAY,EAAQ,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,CAAC,EACtD,CAAC,UAAU,EAAE,QAAQ,CAAC,CACvB,CAAC;IACF,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AAC3B,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface AgentSessionsDialogContextValue {
|
|
2
|
+
/**
|
|
3
|
+
* Register a handler the dialog runs on Escape before closing. A handler
|
|
4
|
+
* that returns `true` has used the key, and the dialog stays open.
|
|
5
|
+
*/
|
|
6
|
+
registerEscapeHandler: (handler: () => boolean) => () => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const AgentSessionsDialogContext: import("react").Context<AgentSessionsDialogContextValue | null>;
|
|
9
|
+
/** The surrounding `<AgentSessionsDialogContent>`, if any. */
|
|
10
|
+
export declare function useAgentSessionsDialogContext(): AgentSessionsDialogContextValue | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
/**
|
|
3
|
+
* Internal: how `<AgentSessionsDialogContent>` and the `<AgentSessions>`
|
|
4
|
+
* inside it talk to each other. Not re-exported from the package index.
|
|
5
|
+
*
|
|
6
|
+
* Radix handles Escape for a dialog on the document, before the keydown
|
|
7
|
+
* reaches anything inside it — so without this, Escape with the overlay
|
|
8
|
+
* sidebar open would close the whole dialog instead of just the sidebar.
|
|
9
|
+
*/
|
|
10
|
+
import { createContext, useContext } from "react";
|
|
11
|
+
export const AgentSessionsDialogContext = createContext(null);
|
|
12
|
+
/** The surrounding `<AgentSessionsDialogContent>`, if any. */
|
|
13
|
+
export function useAgentSessionsDialogContext() {
|
|
14
|
+
return useContext(AgentSessionsDialogContext);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=agent-sessions-dialog-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-sessions-dialog-context.js","sourceRoot":"","sources":["../../../../src/components/ui/agent-sessions/agent-sessions-dialog-context.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb;;;;;;;GAOG;AAEH,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAUlD,MAAM,CAAC,MAAM,0BAA0B,GACrC,aAAa,CAAyC,IAAI,CAAC,CAAC;AAE9D,8DAA8D;AAC9D,MAAM,UAAU,6BAA6B;IAC3C,OAAO,UAAU,CAAC,0BAA0B,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { type ComponentProps, type ComponentPropsWithoutRef, type ReactElement, type ReactNode, type Ref } from "react";
|
|
2
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
3
|
+
import { type ButtonProps } from "../button/button";
|
|
4
|
+
export declare const agentSessionsDialogPlacementIds: readonly ["center", "bottom-right", "bottom-left", "fullscreen"];
|
|
5
|
+
/**
|
|
6
|
+
* Where the dialog opens. `center` is a large modal; `bottom-right` and
|
|
7
|
+
* `bottom-left` are a chat-widget panel that opens just above a
|
|
8
|
+
* `FloatingActionButton` in that corner; `fullscreen` covers the viewport.
|
|
9
|
+
* Every placement goes full-screen below the `sm` breakpoint.
|
|
10
|
+
*/
|
|
11
|
+
export type AgentSessionsDialogPlacementId = (typeof agentSessionsDialogPlacementIds)[number];
|
|
12
|
+
export type AgentSessionsDialogProps = ComponentProps<typeof DialogPrimitive.Root>;
|
|
13
|
+
/** The dialog's root: holds `open` / `onOpenChange` (controlled or not). */
|
|
14
|
+
declare function AgentSessionsDialog(props: AgentSessionsDialogProps): ReactElement;
|
|
15
|
+
declare namespace AgentSessionsDialog {
|
|
16
|
+
var displayName: string;
|
|
17
|
+
}
|
|
18
|
+
export type AgentSessionsDialogTriggerProps = ComponentProps<typeof DialogPrimitive.Trigger>;
|
|
19
|
+
/**
|
|
20
|
+
* Opens the dialog. Use `asChild` to make a `FloatingActionButton` (or any
|
|
21
|
+
* button) the trigger.
|
|
22
|
+
*/
|
|
23
|
+
declare function AgentSessionsDialogTrigger(props: AgentSessionsDialogTriggerProps): ReactElement;
|
|
24
|
+
declare namespace AgentSessionsDialogTrigger {
|
|
25
|
+
var displayName: string;
|
|
26
|
+
}
|
|
27
|
+
export interface AgentSessionsDialogContentProps extends Omit<ComponentPropsWithoutRef<typeof DialogPrimitive.Content>, "title"> {
|
|
28
|
+
/** The dialog's accessible name (visually hidden). Default: "Agent sessions". */
|
|
29
|
+
title?: ReactNode;
|
|
30
|
+
/** The dialog's accessible description (visually hidden). */
|
|
31
|
+
description?: ReactNode;
|
|
32
|
+
/** Where the dialog opens. Default: `center`. */
|
|
33
|
+
placement?: AgentSessionsDialogPlacementId;
|
|
34
|
+
/** Class for the backdrop. */
|
|
35
|
+
overlayClassName?: string;
|
|
36
|
+
ref?: Ref<HTMLDivElement>;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The dialog surface to put an `<AgentSessions>` in. Sized for it, with a
|
|
40
|
+
* visually hidden title and no built-in close button — an
|
|
41
|
+
* `<AgentSessionsHeader>` inside it adds an `<AgentSessionsDialogClose>`
|
|
42
|
+
* itself. On open it focuses the prompt textarea, and Escape first closes
|
|
43
|
+
* the overlay sidebar, if open, before it closes the dialog.
|
|
44
|
+
*/
|
|
45
|
+
declare function AgentSessionsDialogContent({ title, description, placement, className, overlayClassName, children, onEscapeKeyDown, onOpenAutoFocus, ref, ...props }: AgentSessionsDialogContentProps): ReactElement;
|
|
46
|
+
declare namespace AgentSessionsDialogContent {
|
|
47
|
+
var displayName: string;
|
|
48
|
+
}
|
|
49
|
+
export interface AgentSessionsDialogCloseProps extends ButtonProps {
|
|
50
|
+
/** Default: "Close". */
|
|
51
|
+
"aria-label"?: string;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* An icon button that closes the dialog. `<AgentSessionsHeader>` renders
|
|
55
|
+
* one at its end by default; place your own anywhere else in the dialog.
|
|
56
|
+
*/
|
|
57
|
+
declare function AgentSessionsDialogClose({ className, children, variant, size, "aria-label": ariaLabel, ...props }: AgentSessionsDialogCloseProps): ReactElement;
|
|
58
|
+
declare namespace AgentSessionsDialogClose {
|
|
59
|
+
var displayName: string;
|
|
60
|
+
}
|
|
61
|
+
export { AgentSessionsDialog, AgentSessionsDialogTrigger, AgentSessionsDialogContent, AgentSessionsDialogClose, };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useMemo, useRef, } from "react";
|
|
4
|
+
import * as DialogPrimitive from "@radix-ui/react-dialog";
|
|
5
|
+
import { cva } from "class-variance-authority";
|
|
6
|
+
import { X } from "lucide-react";
|
|
7
|
+
import { cn } from "../../../lib/utils";
|
|
8
|
+
import { Button } from "../button/button";
|
|
9
|
+
import { AgentSessionsDialogContext, } from "./agent-sessions-dialog-context";
|
|
10
|
+
import { mergeRefs } from "./merge-refs";
|
|
11
|
+
export const agentSessionsDialogPlacementIds = [
|
|
12
|
+
"center",
|
|
13
|
+
"bottom-right",
|
|
14
|
+
"bottom-left",
|
|
15
|
+
"fullscreen",
|
|
16
|
+
];
|
|
17
|
+
const agentSessionsDialogContentVariants = cva("fixed z-50 flex overflow-hidden border bg-background text-foreground shadow-2xl outline-none duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 motion-reduce:animate-none max-sm:inset-0 max-sm:h-auto max-sm:w-auto max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-none max-sm:border-0", {
|
|
18
|
+
variants: {
|
|
19
|
+
placement: {
|
|
20
|
+
center: "left-1/2 top-1/2 h-[min(46rem,calc(100dvh_-_2rem))] w-[min(64rem,calc(100vw_-_2rem))] -translate-x-1/2 -translate-y-1/2 rounded-xl data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 sm:data-[state=closed]:slide-out-to-left-1/2 sm:data-[state=closed]:slide-out-to-top-[48%] sm:data-[state=open]:slide-in-from-left-1/2 sm:data-[state=open]:slide-in-from-top-[48%]",
|
|
21
|
+
"bottom-right": "bottom-24 right-6 h-[min(40rem,calc(100dvh_-_8rem))] w-[min(28rem,calc(100vw_-_3rem))] origin-bottom-right rounded-xl data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-bottom-4 data-[state=open]:slide-in-from-bottom-4",
|
|
22
|
+
"bottom-left": "bottom-24 left-6 h-[min(40rem,calc(100dvh_-_8rem))] w-[min(28rem,calc(100vw_-_3rem))] origin-bottom-left rounded-xl data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-bottom-4 data-[state=open]:slide-in-from-bottom-4",
|
|
23
|
+
fullscreen: "inset-0 rounded-none border-0",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
defaultVariants: {
|
|
27
|
+
placement: "center",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
const agentSessionsDialogOverlayVariants = cva("fixed inset-0 z-50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 motion-reduce:animate-none", {
|
|
31
|
+
variants: {
|
|
32
|
+
placement: {
|
|
33
|
+
center: "bg-black/60",
|
|
34
|
+
"bottom-right": "bg-black/20",
|
|
35
|
+
"bottom-left": "bg-black/20",
|
|
36
|
+
fullscreen: "bg-black/60",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
defaultVariants: {
|
|
40
|
+
placement: "center",
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
/** The dialog's root: holds `open` / `onOpenChange` (controlled or not). */
|
|
44
|
+
function AgentSessionsDialog(props) {
|
|
45
|
+
return _jsx(DialogPrimitive.Root, { ...props });
|
|
46
|
+
}
|
|
47
|
+
AgentSessionsDialog.displayName = "AgentSessionsDialog";
|
|
48
|
+
/**
|
|
49
|
+
* Opens the dialog. Use `asChild` to make a `FloatingActionButton` (or any
|
|
50
|
+
* button) the trigger.
|
|
51
|
+
*/
|
|
52
|
+
function AgentSessionsDialogTrigger(props) {
|
|
53
|
+
return (_jsx(DialogPrimitive.Trigger, { "data-slot": "agent-sessions-dialog-trigger", ...props }));
|
|
54
|
+
}
|
|
55
|
+
AgentSessionsDialogTrigger.displayName = "AgentSessionsDialogTrigger";
|
|
56
|
+
/**
|
|
57
|
+
* The dialog surface to put an `<AgentSessions>` in. Sized for it, with a
|
|
58
|
+
* visually hidden title and no built-in close button — an
|
|
59
|
+
* `<AgentSessionsHeader>` inside it adds an `<AgentSessionsDialogClose>`
|
|
60
|
+
* itself. On open it focuses the prompt textarea, and Escape first closes
|
|
61
|
+
* the overlay sidebar, if open, before it closes the dialog.
|
|
62
|
+
*/
|
|
63
|
+
function AgentSessionsDialogContent({ title = "Agent sessions", description, placement = "center", className, overlayClassName, children, onEscapeKeyDown, onOpenAutoFocus, ref, ...props }) {
|
|
64
|
+
const contentRef = useRef(null);
|
|
65
|
+
const mergedRef = useMemo(() => mergeRefs(contentRef, ref), [ref]);
|
|
66
|
+
const escapeHandlersRef = useRef(new Set());
|
|
67
|
+
const dialogContext = useMemo(() => ({
|
|
68
|
+
registerEscapeHandler: (handler) => {
|
|
69
|
+
escapeHandlersRef.current.add(handler);
|
|
70
|
+
return () => {
|
|
71
|
+
escapeHandlersRef.current.delete(handler);
|
|
72
|
+
};
|
|
73
|
+
},
|
|
74
|
+
}), []);
|
|
75
|
+
const handleEscapeKeyDown = useCallback((event) => {
|
|
76
|
+
onEscapeKeyDown?.(event);
|
|
77
|
+
if (event.defaultPrevented)
|
|
78
|
+
return;
|
|
79
|
+
for (const handler of escapeHandlersRef.current) {
|
|
80
|
+
if (handler()) {
|
|
81
|
+
event.preventDefault();
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}, [onEscapeKeyDown]);
|
|
86
|
+
// Land in the prompt, which is what someone opening an assistant wants;
|
|
87
|
+
// Radix would otherwise focus the first button (the sidebar toggle).
|
|
88
|
+
const handleOpenAutoFocus = useCallback((event) => {
|
|
89
|
+
onOpenAutoFocus?.(event);
|
|
90
|
+
if (event.defaultPrevented)
|
|
91
|
+
return;
|
|
92
|
+
const textarea = contentRef.current?.querySelector('textarea[data-slot="prompt-input-textarea"]:not(:disabled)');
|
|
93
|
+
if (textarea) {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
textarea.focus({ preventScroll: true });
|
|
96
|
+
}
|
|
97
|
+
}, [onOpenAutoFocus]);
|
|
98
|
+
// Radix warns about a dialog with no description unless
|
|
99
|
+
// `aria-describedby` is explicitly undefined.
|
|
100
|
+
const describedBy = description === undefined ? { "aria-describedby": undefined } : {};
|
|
101
|
+
return (_jsxs(DialogPrimitive.Portal, { children: [_jsx(DialogPrimitive.Overlay, { "data-slot": "agent-sessions-dialog-overlay", className: cn(agentSessionsDialogOverlayVariants({ placement }), overlayClassName) }), _jsxs(DialogPrimitive.Content, { ref: mergedRef, "data-slot": "agent-sessions-dialog-content", "data-placement": placement, ...describedBy, onEscapeKeyDown: handleEscapeKeyDown, onOpenAutoFocus: handleOpenAutoFocus, className: cn(agentSessionsDialogContentVariants({ placement }), className), ...props, children: [_jsx(DialogPrimitive.Title, { className: "sr-only", children: title }), description !== undefined ? (_jsx(DialogPrimitive.Description, { className: "sr-only", children: description })) : null, _jsx(AgentSessionsDialogContext.Provider, { value: dialogContext, children: children })] })] }));
|
|
102
|
+
}
|
|
103
|
+
AgentSessionsDialogContent.displayName = "AgentSessionsDialogContent";
|
|
104
|
+
/**
|
|
105
|
+
* An icon button that closes the dialog. `<AgentSessionsHeader>` renders
|
|
106
|
+
* one at its end by default; place your own anywhere else in the dialog.
|
|
107
|
+
*/
|
|
108
|
+
function AgentSessionsDialogClose({ className, children, variant = "ghost", size = "icon", "aria-label": ariaLabel = "Close", ...props }) {
|
|
109
|
+
return (_jsx(DialogPrimitive.Close, { asChild: true, children: _jsx(Button, { type: "button", variant: variant, size: size, "data-slot": "agent-sessions-dialog-close", "aria-label": ariaLabel, className: cn(size === "icon" && "h-8 w-8 shrink-0", className), ...props, children: children ?? _jsx(X, { "aria-hidden": "true", className: "size-4" }) }) }));
|
|
110
|
+
}
|
|
111
|
+
AgentSessionsDialogClose.displayName = "AgentSessionsDialogClose";
|
|
112
|
+
export { AgentSessionsDialog, AgentSessionsDialogTrigger, AgentSessionsDialogContent, AgentSessionsDialogClose, };
|
|
113
|
+
//# sourceMappingURL=agent-sessions-dialog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-sessions-dialog.js","sourceRoot":"","sources":["../../../../src/components/ui/agent-sessions/agent-sessions-dialog.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EACL,WAAW,EACX,OAAO,EACP,MAAM,GAMP,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAC/C,OAAO,EAAE,CAAC,EAAE,MAAM,cAAc,CAAC;AAEjC,OAAO,E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AC;AACD,0BAA0B,CAAC,WAAW,GAAG,4BAA4B,CAAC;AAWtE;;;GAGG;AACH,SAAS,wBAAwB,CAAC,EAChC,SAAS,EACT,QAAQ,EACR,OAAO,GAAG,OAAO,EACjB,IAAI,GAAG,MAAM,EACb,YAAY,EAAE,SAAS,GAAG,OAAO,EACjC,GAAG,KAAK,EACsB;IAC9B,OAAO,CACL,KAAC,eAAe,CAAC,KAAK,IAAC,OAAO,kBAC5B,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,eACA,6BAA6B,gBAC3B,SAAS,EACrB,SAAS,EAAE,EAAE,CAAC,IAAI,KAAK,MAAM,IAAI,kBAAkB,EAAE,SAAS,CAAC,KAC3D,KAAK,YAER,QAAQ,IAAI,KAAC,CAAC,mBAAa,MAAM,EAAC,SAAS,EAAC,QAAQ,GAAG,GACjD,GACa,CACzB,CAAC;AACJ,CAAC;AACD,wBAAwB,CAAC,WAAW,GAAG,0BAA0B,CAAC;AAElE,OAAO,EACL,mBAAmB,EACnB,0BAA0B,EAC1B,0BAA0B,EAC1B,wBAAwB,GACzB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-session draft prompts `<AgentSessions>` keeps while the user
|
|
3
|
+
* switches between sessions. React-free: `<AgentSessionsPromptInput>` and
|
|
4
|
+
* `useAgentSessionDraft()` read it through `useSyncExternalStore`, so typing
|
|
5
|
+
* re-renders only the prompt, never the transcript or the session list.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Which draft to read or write: a session id, or `null` for the prompt on
|
|
9
|
+
* the new-session screen.
|
|
10
|
+
*/
|
|
11
|
+
export type AgentSessionDraftKey = string | null;
|
|
12
|
+
export interface AgentSessionsDraftStore {
|
|
13
|
+
/** The draft kept under `key`, or `""`. */
|
|
14
|
+
get(key: AgentSessionDraftKey): string;
|
|
15
|
+
/** Replace the draft under `key`. An empty string removes it. */
|
|
16
|
+
set(key: AgentSessionDraftKey, value: string): void;
|
|
17
|
+
/** Called after any draft changes. Returns the unsubscribe function. */
|
|
18
|
+
subscribe(listener: () => void): () => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function createAgentSessionsDraftStore(initial?: Iterable<readonly [AgentSessionDraftKey, string]>): AgentSessionsDraftStore;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-session draft prompts `<AgentSessions>` keeps while the user
|
|
3
|
+
* switches between sessions. React-free: `<AgentSessionsPromptInput>` and
|
|
4
|
+
* `useAgentSessionDraft()` read it through `useSyncExternalStore`, so typing
|
|
5
|
+
* re-renders only the prompt, never the transcript or the session list.
|
|
6
|
+
*/
|
|
7
|
+
export function createAgentSessionsDraftStore(initial) {
|
|
8
|
+
const drafts = new Map();
|
|
9
|
+
for (const [key, value] of initial ?? []) {
|
|
10
|
+
if (value.length > 0)
|
|
11
|
+
drafts.set(key, value);
|
|
12
|
+
}
|
|
13
|
+
const listeners = new Set();
|
|
14
|
+
return {
|
|
15
|
+
get(key) {
|
|
16
|
+
return drafts.get(key) ?? "";
|
|
17
|
+
},
|
|
18
|
+
set(key, value) {
|
|
19
|
+
if ((drafts.get(key) ?? "") === value)
|
|
20
|
+
return;
|
|
21
|
+
if (value.length === 0) {
|
|
22
|
+
drafts.delete(key);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
drafts.set(key, value);
|
|
26
|
+
}
|
|
27
|
+
for (const listener of [...listeners])
|
|
28
|
+
listener();
|
|
29
|
+
},
|
|
30
|
+
subscribe(listener) {
|
|
31
|
+
listeners.add(listener);
|
|
32
|
+
return () => {
|
|
33
|
+
listeners.delete(listener);
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=agent-sessions-draft-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent-sessions-draft-store.js","sourceRoot":"","sources":["../../../../src/components/ui/agent-sessions/agent-sessions-draft-store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAiBH,MAAM,UAAU,6BAA6B,CAC3C,OAA2D;IAE3D,MAAM,MAAM,GAAG,IAAI,GAAG,EAAgC,CAAC;IACvD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,IAAI,EAAE,EAAE,CAAC;QACzC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IAExC,OAAO;QACL,GAAG,CAAC,GAAyB;YAC3B,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QACD,GAAG,CAAC,GAAyB,EAAE,KAAa;YAC1C,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,KAAK;gBAAE,OAAO;YAC9C,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACrB,CAAC;iBAAM,CAAC;gBACN,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YACzB,CAAC;YACD,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,SAAS,CAAC;gBAAE,QAAQ,EAAE,CAAC;QACpD,CAAC;QACD,SAAS,CAAC,QAAoB;YAC5B,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YACxB,OAAO,GAAS,EAAE;gBAChB,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { type ButtonHTMLAttributes, type HTMLAttributes, type LiHTMLAttributes, type MouseEvent, type ReactElement, type ReactNode, type Ref } from "react";
|
|
2
|
+
import { type RelativeTimeProps } from "../relative-time/relative-time";
|
|
3
|
+
import { type AgentSession, type AgentSessionGroupBy, type AgentSessionMatcher, type AgentSessionRecencyGroupId, type AgentSessionStatusId } from "./agent-sessions-model";
|
|
4
|
+
export interface AgentSessionStatusIndicatorProps extends HTMLAttributes<HTMLSpanElement> {
|
|
5
|
+
status: AgentSessionStatusId;
|
|
6
|
+
/** Screen-reader text. Default: the status's entry in `agentSessionStatusLabels`. */
|
|
7
|
+
label?: string;
|
|
8
|
+
/** Render a dot for `idle` too (it shows nothing by default). */
|
|
9
|
+
showIdle?: boolean;
|
|
10
|
+
ref?: Ref<HTMLSpanElement>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A small coloured dot for a session's status; `running` pulses (unless
|
|
14
|
+
* the viewer prefers reduced motion). Renders nothing for `idle` unless
|
|
15
|
+
* `showIdle` is set.
|
|
16
|
+
*/
|
|
17
|
+
declare function AgentSessionStatusIndicator({ status, label, showIdle, className, ref, ...props }: AgentSessionStatusIndicatorProps): ReactElement | null;
|
|
18
|
+
declare namespace AgentSessionStatusIndicator {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
21
|
+
export interface AgentSessionsListItemProps extends Omit<LiHTMLAttributes<HTMLLIElement>, "children" | "onSelect" | "title"> {
|
|
22
|
+
session: AgentSession;
|
|
23
|
+
/** Replaces the title. Default: `session.title`. */
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
/** Replaces the preview line. Default: `session.preview`; `false` hides it. */
|
|
26
|
+
description?: ReactNode | false;
|
|
27
|
+
/**
|
|
28
|
+
* Leading slot. Default: the status dot (an empty, aligned slot when the
|
|
29
|
+
* session is idle). Pass `null` to drop the slot entirely.
|
|
30
|
+
*/
|
|
31
|
+
icon?: ReactNode | null;
|
|
32
|
+
/**
|
|
33
|
+
* Trailing timestamp. Default: a live `<RelativeTime>` of
|
|
34
|
+
* `session.updatedAt` ("5m ago"); `false` hides it.
|
|
35
|
+
*/
|
|
36
|
+
timestamp?: ReactNode | false;
|
|
37
|
+
/** Props for the default `<RelativeTime>` timestamp. */
|
|
38
|
+
timestampProps?: Partial<RelativeTimeProps>;
|
|
39
|
+
/**
|
|
40
|
+
* Buttons or a menu for the session — rename, pin, delete… On devices
|
|
41
|
+
* with hover they appear over the timestamp on hover and focus; on touch
|
|
42
|
+
* devices they are always shown.
|
|
43
|
+
*/
|
|
44
|
+
actions?: ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Called on click before the session is resumed; call
|
|
47
|
+
* `event.preventDefault()` to stop it from being resumed.
|
|
48
|
+
*/
|
|
49
|
+
onSelect?: (event: MouseEvent<HTMLButtonElement>) => void;
|
|
50
|
+
/** Props for the item's main button. */
|
|
51
|
+
buttonProps?: Omit<ButtonHTMLAttributes<HTMLButtonElement>, "onClick">;
|
|
52
|
+
ref?: Ref<HTMLLIElement>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* One session in the list. Clicking it resumes the session. The active
|
|
56
|
+
* session is marked `aria-current` and highlighted.
|
|
57
|
+
*/
|
|
58
|
+
declare function AgentSessionsListItem({ session, children, description, icon, timestamp, timestampProps, actions, onSelect, buttonProps, className, ref, ...props }: AgentSessionsListItemProps): ReactElement;
|
|
59
|
+
declare namespace AgentSessionsListItem {
|
|
60
|
+
var displayName: string;
|
|
61
|
+
}
|
|
62
|
+
export interface AgentSessionsListGroupProps extends Omit<LiHTMLAttributes<HTMLLIElement>, "children"> {
|
|
63
|
+
/** The group's heading, e.g. "Today" or a project name. */
|
|
64
|
+
label: ReactNode;
|
|
65
|
+
/** `<AgentSessionsListItem>`s. */
|
|
66
|
+
children?: ReactNode;
|
|
67
|
+
ref?: Ref<HTMLLIElement>;
|
|
68
|
+
}
|
|
69
|
+
/** A labelled group of sessions inside `<AgentSessionsList>`. */
|
|
70
|
+
declare function AgentSessionsListGroup({ label, children, className, ref, ...props }: AgentSessionsListGroupProps): ReactElement;
|
|
71
|
+
declare namespace AgentSessionsListGroup {
|
|
72
|
+
var displayName: string;
|
|
73
|
+
}
|
|
74
|
+
export interface AgentSessionsListItemRenderState {
|
|
75
|
+
/** Whether this is the active session. */
|
|
76
|
+
active: boolean;
|
|
77
|
+
/** Resume this session. */
|
|
78
|
+
select: () => void;
|
|
79
|
+
}
|
|
80
|
+
export interface AgentSessionsListProps<TSession extends AgentSession = AgentSession> extends Omit<HTMLAttributes<HTMLUListElement>, "children"> {
|
|
81
|
+
/**
|
|
82
|
+
* Hand-written items (`<AgentSessionsListItem>`, `<AgentSessionsListGroup>`).
|
|
83
|
+
* When given, the list renders them as-is instead of `sessions`.
|
|
84
|
+
*/
|
|
85
|
+
children?: ReactNode;
|
|
86
|
+
/**
|
|
87
|
+
* Order of the sessions: `recent` (by `updatedAt`, newest first — the
|
|
88
|
+
* default), `none` (as passed in), or your own comparator.
|
|
89
|
+
*/
|
|
90
|
+
sort?: "recent" | "none" | ((a: TSession, b: TSession) => number);
|
|
91
|
+
/**
|
|
92
|
+
* Grouping: `recency` (Pinned, Today, Yesterday, Previous 7 days… — the
|
|
93
|
+
* default), `none`, or a function returning each session's group.
|
|
94
|
+
*/
|
|
95
|
+
groupBy?: "recency" | "none" | AgentSessionGroupBy<TSession>;
|
|
96
|
+
/** Rename the recency groups (e.g. to translate them). */
|
|
97
|
+
groupLabels?: Partial<Record<AgentSessionRecencyGroupId, string>>;
|
|
98
|
+
/**
|
|
99
|
+
* How the search query filters sessions. Default: every term must appear
|
|
100
|
+
* in the title or preview. `false` turns client-side filtering off (e.g.
|
|
101
|
+
* when you search on the server).
|
|
102
|
+
*/
|
|
103
|
+
filter?: AgentSessionMatcher<TSession> | false;
|
|
104
|
+
/** Render each session yourself — return an `<AgentSessionsListItem>`. */
|
|
105
|
+
renderItem?: (session: TSession, state: AgentSessionsListItemRenderState) => ReactNode;
|
|
106
|
+
/** Per-session actions for the default items (see `AgentSessionsListItem`). */
|
|
107
|
+
itemActions?: (session: TSession) => ReactNode;
|
|
108
|
+
/** Shown when there are no sessions at all. */
|
|
109
|
+
empty?: ReactNode;
|
|
110
|
+
/** Shown when the search matches nothing. */
|
|
111
|
+
noResults?: ReactNode | ((query: string) => ReactNode);
|
|
112
|
+
/** Class for the empty and no-results messages. */
|
|
113
|
+
emptyClassName?: string;
|
|
114
|
+
ref?: Ref<HTMLUListElement>;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The sessions from `<AgentSessions>`, filtered by the search query, newest
|
|
118
|
+
* first, grouped by recency and each stamped with a live relative time.
|
|
119
|
+
* Every step can be replaced: `sort`, `groupBy`, `filter`, `renderItem`,
|
|
120
|
+
* `itemActions` — or pass `children` to lay the list out by hand.
|
|
121
|
+
*/
|
|
122
|
+
declare function AgentSessionsList<TSession extends AgentSession = AgentSession>({ children, sort, groupBy, groupLabels, filter, renderItem, itemActions, empty, noResults, emptyClassName, className, "aria-label": ariaLabel, ref, ...props }: AgentSessionsListProps<TSession>): ReactElement;
|
|
123
|
+
declare namespace AgentSessionsList {
|
|
124
|
+
var displayName: string;
|
|
125
|
+
}
|
|
126
|
+
export { AgentSessionsList, AgentSessionsListGroup, AgentSessionsListItem, AgentSessionStatusIndicator, };
|