@40rty/ams-ui 0.3.0 → 0.3.2
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/agent.js +8 -6
- package/dist/chunk-BFZ3YCUY.js +163 -0
- package/dist/{chunk-54QPRWEG.js → chunk-OKP7MC72.js} +89 -281
- package/dist/chunk-QXCHHCPU.js +58 -0
- package/dist/chunk-TEPH476O.js +218 -0
- package/dist/css/shell/spacefront-island.css +30 -13
- package/dist/css/shell/spacefront-presence.css +222 -0
- package/dist/css/shell/spacefront-thread-panel.css +255 -0
- package/dist/index.js +6 -4
- package/dist/island.js +13 -3
- package/dist/presence.js +134 -0
- package/dist/shell.js +305 -451
- package/dist/thread-panel.js +238 -0
- package/dist/types/presence/index.d.ts +1 -0
- package/dist/types/shell/PresenceActivity.d.ts +22 -0
- package/dist/types/shell/SideDock.d.ts +3 -2
- package/dist/types/shell/SpacefrontIsland.d.ts +5 -1
- package/dist/types/shell/SpacefrontPresence.d.ts +25 -0
- package/dist/types/shell/SpacefrontThreadPanel.d.ts +45 -0
- package/dist/types/shell/ThreadPanelConversation.d.ts +14 -0
- package/dist/types/shell/host-shell-store.d.ts +35 -0
- package/dist/types/thread-panel/index.d.ts +1 -0
- package/package.json +12 -2
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import {
|
|
3
|
+
SideDock,
|
|
4
|
+
useDockState
|
|
5
|
+
} from "./chunk-BFZ3YCUY.js";
|
|
6
|
+
import {
|
|
7
|
+
stopHostKeys,
|
|
8
|
+
useHostShell,
|
|
9
|
+
usePanelSlot
|
|
10
|
+
} from "./chunk-QXCHHCPU.js";
|
|
11
|
+
|
|
12
|
+
// src/shell/SpacefrontThreadPanel.tsx
|
|
13
|
+
import * as React2 from "react";
|
|
14
|
+
import { DockPersistenceProvider, useFormFactor } from "@40rty/ams-sdk";
|
|
15
|
+
|
|
16
|
+
// src/shell/ThreadPanelConversation.tsx
|
|
17
|
+
import * as React from "react";
|
|
18
|
+
import { renderInline, useComposerChipSelect, useComposerDraft, useFourtySession, useThreadRows } from "@40rty/ams-sdk";
|
|
19
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
20
|
+
var FOLLOW_SLACK = 80;
|
|
21
|
+
function ThreadPanelConversation({ fieldRef, placeholder, emptyText, workingText }) {
|
|
22
|
+
const session = useFourtySession();
|
|
23
|
+
const [draft, setDraft] = useComposerDraft();
|
|
24
|
+
const { rows, isEmpty } = useThreadRows();
|
|
25
|
+
const selectChip = useComposerChipSelect();
|
|
26
|
+
const chips = session.suggestions === null ? [] : session.suggestions.actions.filter((chip) => chip.label.trim() !== "");
|
|
27
|
+
const working = session.isRunning || session.isSubmitting;
|
|
28
|
+
const latest = rows.length > 0 ? rows[rows.length - 1] : void 0;
|
|
29
|
+
const latestProse = latest === void 0 ? "" : latest.prose;
|
|
30
|
+
const listRef = React.useRef(null);
|
|
31
|
+
const following = React.useRef(true);
|
|
32
|
+
React.useEffect(() => {
|
|
33
|
+
const list = listRef.current;
|
|
34
|
+
if (list !== null && following.current) list.scrollTop = list.scrollHeight;
|
|
35
|
+
}, [rows.length, latestProse, working]);
|
|
36
|
+
const send = () => {
|
|
37
|
+
if (draft.trim() === "" || working) return;
|
|
38
|
+
following.current = true;
|
|
39
|
+
session.sendMessage(draft);
|
|
40
|
+
setDraft("");
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43
|
+
/* @__PURE__ */ jsxs(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
ref: listRef,
|
|
47
|
+
className: "fourty-tp__thread",
|
|
48
|
+
"aria-live": "polite",
|
|
49
|
+
"aria-busy": working,
|
|
50
|
+
onScroll: (event) => {
|
|
51
|
+
const list = event.currentTarget;
|
|
52
|
+
following.current = list.scrollHeight - list.scrollTop - list.clientHeight < FOLLOW_SLACK;
|
|
53
|
+
},
|
|
54
|
+
children: [
|
|
55
|
+
isEmpty && rows.length === 0 && /* @__PURE__ */ jsx("p", { className: "fourty-tp__muted", children: emptyText }),
|
|
56
|
+
rows.map((row) => /* @__PURE__ */ jsxs("div", { className: "fourty-tp__turn", children: [
|
|
57
|
+
row.visitorText !== "" && /* @__PURE__ */ jsx("p", { className: "fourty-tp__asked", children: row.visitorText }),
|
|
58
|
+
row.prose !== "" ? /* @__PURE__ */ jsx("p", { className: "fourty-tp__answer", children: renderInline(row.prose, row.key) }) : working && row === latest && /* @__PURE__ */ jsx("p", { className: "fourty-tp__working", children: workingText })
|
|
59
|
+
] }, row.key)),
|
|
60
|
+
working && latest === void 0 && /* @__PURE__ */ jsx("p", { className: "fourty-tp__working", children: workingText }),
|
|
61
|
+
session.error !== null && /* @__PURE__ */ jsx("p", { className: "fourty-tp__error", role: "alert", children: session.error })
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
chips.length > 0 && /* @__PURE__ */ jsx("div", { className: "fourty-tp__chips", role: "group", "aria-label": "Suggestions", children: chips.map((chip) => /* @__PURE__ */ jsx("button", { type: "button", className: "fourty-tp__chip", onClick: () => selectChip(chip), children: chip.label }, chip.id)) }),
|
|
66
|
+
/* @__PURE__ */ jsxs(
|
|
67
|
+
"form",
|
|
68
|
+
{
|
|
69
|
+
className: "fourty-tp__face",
|
|
70
|
+
onSubmit: (event) => {
|
|
71
|
+
event.preventDefault();
|
|
72
|
+
send();
|
|
73
|
+
},
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ jsx(
|
|
76
|
+
"input",
|
|
77
|
+
{
|
|
78
|
+
ref: fieldRef,
|
|
79
|
+
type: "text",
|
|
80
|
+
className: "fourty-tp__field",
|
|
81
|
+
"aria-label": placeholder,
|
|
82
|
+
placeholder,
|
|
83
|
+
enterKeyHint: "send",
|
|
84
|
+
autoComplete: "off",
|
|
85
|
+
value: draft,
|
|
86
|
+
onChange: (event) => setDraft(event.target.value)
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
/* @__PURE__ */ jsx("button", { type: "submit", className: "fourty-tp__stamp", "aria-label": "Send", disabled: working || draft.trim() === "", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ jsx("path", { d: "M8 13V3M3.5 7.5 8 3l4.5 4.5", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) })
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
)
|
|
93
|
+
] });
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// src/shell/SpacefrontThreadPanel.tsx
|
|
97
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
98
|
+
var THREAD_PANEL_INSET_PROPERTY = "--fourty-thread-panel-inset";
|
|
99
|
+
function readStored(storageKey) {
|
|
100
|
+
if (storageKey === null) return null;
|
|
101
|
+
try {
|
|
102
|
+
const stored = window.localStorage.getItem(storageKey);
|
|
103
|
+
return stored === "open" || stored === "closed" || stored === "collapsed" ? stored : null;
|
|
104
|
+
} catch (err) {
|
|
105
|
+
console.warn("[fourty] thread panel: could not read its stored open state", err);
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function useStoredDock(storageKey) {
|
|
110
|
+
const [stored] = React2.useState(() => readStored(storageKey));
|
|
111
|
+
const [collapsed, setCollapsedState] = React2.useState(stored === "collapsed");
|
|
112
|
+
const collapsedRef = React2.useRef(collapsed);
|
|
113
|
+
const setCollapsed = React2.useCallback((next) => {
|
|
114
|
+
collapsedRef.current = next;
|
|
115
|
+
setCollapsedState(next);
|
|
116
|
+
}, []);
|
|
117
|
+
const onOpenChange = React2.useCallback((open) => {
|
|
118
|
+
if (storageKey === null) return;
|
|
119
|
+
let next = "closed";
|
|
120
|
+
if (open) next = "open";
|
|
121
|
+
else if (collapsedRef.current) next = "collapsed";
|
|
122
|
+
try {
|
|
123
|
+
window.localStorage.setItem(storageKey, next);
|
|
124
|
+
} catch (err) {
|
|
125
|
+
console.warn("[fourty] thread panel: could not store its open state", err);
|
|
126
|
+
}
|
|
127
|
+
}, [storageKey]);
|
|
128
|
+
const initialOpen = stored === null ? null : stored === "open";
|
|
129
|
+
const persistence = React2.useMemo(() => ({ initialOpen, onOpenChange }), [initialOpen, onOpenChange]);
|
|
130
|
+
return { persistence, collapsed, setCollapsed };
|
|
131
|
+
}
|
|
132
|
+
function SpacefrontThreadPanel({ storageKey = "fourty-thread-panel", ...props }) {
|
|
133
|
+
const { persistence, collapsed, setCollapsed } = useStoredDock(storageKey);
|
|
134
|
+
return /* @__PURE__ */ jsx2(DockPersistenceProvider, { value: persistence, children: /* @__PURE__ */ jsx2(ThreadPanel, { ...props, collapsed, setCollapsed }) });
|
|
135
|
+
}
|
|
136
|
+
function ThreadPanel({
|
|
137
|
+
title = "Assistant",
|
|
138
|
+
placeholder = "Ask anything\u2026",
|
|
139
|
+
emptyText = "Tell us what you\u2019re looking for.",
|
|
140
|
+
workingText = "Pulling that together\u2026",
|
|
141
|
+
tabLabel = "Ask",
|
|
142
|
+
width = 400,
|
|
143
|
+
autoOpen = true,
|
|
144
|
+
stopKeyPropagation = true,
|
|
145
|
+
collapsed,
|
|
146
|
+
setCollapsed
|
|
147
|
+
}) {
|
|
148
|
+
const { isMobile } = useFormFactor();
|
|
149
|
+
const { islands } = useHostShell();
|
|
150
|
+
const dock = useDockState(autoOpen && !collapsed, autoOpen);
|
|
151
|
+
const handsOff = isMobile && islands > 0;
|
|
152
|
+
const shown = dock.open && !handsOff;
|
|
153
|
+
const [slot, setSlot] = React2.useState(null);
|
|
154
|
+
usePanelSlot(slot, shown);
|
|
155
|
+
const inset = shown && !isMobile ? width : 0;
|
|
156
|
+
React2.useEffect(() => {
|
|
157
|
+
document.documentElement.style.setProperty(THREAD_PANEL_INSET_PROPERTY, `${inset}px`);
|
|
158
|
+
}, [inset]);
|
|
159
|
+
React2.useEffect(() => () => {
|
|
160
|
+
document.documentElement.style.removeProperty(THREAD_PANEL_INSET_PROPERTY);
|
|
161
|
+
}, []);
|
|
162
|
+
const fieldRef = React2.useRef(null);
|
|
163
|
+
const tabRef = React2.useRef(null);
|
|
164
|
+
const focusAfterToggle = React2.useRef(false);
|
|
165
|
+
const toggle = () => {
|
|
166
|
+
setCollapsed(dock.open);
|
|
167
|
+
focusAfterToggle.current = true;
|
|
168
|
+
dock.toggle();
|
|
169
|
+
};
|
|
170
|
+
React2.useEffect(() => {
|
|
171
|
+
if (!focusAfterToggle.current) return;
|
|
172
|
+
focusAfterToggle.current = false;
|
|
173
|
+
const target = dock.open ? fieldRef.current : tabRef.current;
|
|
174
|
+
if (target !== null) target.focus({ preventScroll: true });
|
|
175
|
+
}, [dock.open]);
|
|
176
|
+
const panelId = React2.useId();
|
|
177
|
+
if (handsOff) return null;
|
|
178
|
+
return /* @__PURE__ */ jsxs2(
|
|
179
|
+
"div",
|
|
180
|
+
{
|
|
181
|
+
className: "fourty-tp",
|
|
182
|
+
"data-open": shown,
|
|
183
|
+
style: { width: isMobile ? "100%" : width },
|
|
184
|
+
onKeyDown: (event) => {
|
|
185
|
+
if (stopKeyPropagation) stopHostKeys(event);
|
|
186
|
+
if (event.key === "Escape" && dock.open) toggle();
|
|
187
|
+
},
|
|
188
|
+
onKeyUp: (event) => {
|
|
189
|
+
if (stopKeyPropagation) stopHostKeys(event);
|
|
190
|
+
},
|
|
191
|
+
children: [
|
|
192
|
+
!dock.open && /* @__PURE__ */ jsx2(
|
|
193
|
+
"button",
|
|
194
|
+
{
|
|
195
|
+
ref: tabRef,
|
|
196
|
+
type: "button",
|
|
197
|
+
className: "fourty-tp__tab",
|
|
198
|
+
"aria-expanded": false,
|
|
199
|
+
"aria-controls": panelId,
|
|
200
|
+
onClick: toggle,
|
|
201
|
+
children: tabLabel
|
|
202
|
+
}
|
|
203
|
+
),
|
|
204
|
+
/* @__PURE__ */ jsx2(SideDock, { open: dock.open, width: "100%", top: 0, zIndex: 1, children: /* @__PURE__ */ jsxs2("section", { id: panelId, className: "fourty-tp__panel", "aria-label": title, children: [
|
|
205
|
+
/* @__PURE__ */ jsxs2("header", { className: "fourty-tp__head", children: [
|
|
206
|
+
/* @__PURE__ */ jsx2("h2", { className: "fourty-tp__title", children: title }),
|
|
207
|
+
/* @__PURE__ */ jsx2(
|
|
208
|
+
"button",
|
|
209
|
+
{
|
|
210
|
+
type: "button",
|
|
211
|
+
className: "fourty-tp__close",
|
|
212
|
+
"aria-label": "Close the conversation",
|
|
213
|
+
"aria-expanded": dock.open,
|
|
214
|
+
"aria-controls": panelId,
|
|
215
|
+
onClick: toggle,
|
|
216
|
+
children: /* @__PURE__ */ jsx2("svg", { viewBox: "0 0 16 16", "aria-hidden": "true", children: /* @__PURE__ */ jsx2("path", { d: "M6 3.5 10.5 8 6 12.5", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) })
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
] }),
|
|
220
|
+
/* @__PURE__ */ jsx2("div", { ref: setSlot, className: "fourty-tp__presence" }),
|
|
221
|
+
/* @__PURE__ */ jsx2(
|
|
222
|
+
ThreadPanelConversation,
|
|
223
|
+
{
|
|
224
|
+
fieldRef,
|
|
225
|
+
placeholder,
|
|
226
|
+
emptyText,
|
|
227
|
+
workingText
|
|
228
|
+
}
|
|
229
|
+
)
|
|
230
|
+
] }) })
|
|
231
|
+
]
|
|
232
|
+
}
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
export {
|
|
236
|
+
SpacefrontThreadPanel,
|
|
237
|
+
THREAD_PANEL_INSET_PROPERTY
|
|
238
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SpacefrontPresence, type SpacefrontPresenceProps } from '../shell/SpacefrontPresence';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { PresenceSourceElement, ScanningState, ScanThumb } from '@40rty/ams-sdk';
|
|
3
|
+
export interface PresenceThumbs {
|
|
4
|
+
thumbs: ScanThumb[];
|
|
5
|
+
/** How many records the lookups accounted for (≥ thumbs drawn). */
|
|
6
|
+
count: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The records the agent is reading right now: the element stream's sources
|
|
10
|
+
* (each lookup's reported total, its imaged refs), else the live scan.
|
|
11
|
+
*/
|
|
12
|
+
export declare function presenceThumbs(sources: PresenceSourceElement[], scanning: ScanningState | null): PresenceThumbs;
|
|
13
|
+
interface PresenceActivityProps {
|
|
14
|
+
working: boolean;
|
|
15
|
+
thumbs: PresenceThumbs;
|
|
16
|
+
voice: string;
|
|
17
|
+
queryHint: string | undefined;
|
|
18
|
+
thinkingText: string;
|
|
19
|
+
}
|
|
20
|
+
/** What the agent is doing now: reading (thumbs + count), thinking, or its line. */
|
|
21
|
+
export declare function PresenceActivity({ working, thumbs, voice, queryHint, thinkingText }: PresenceActivityProps): React.ReactElement;
|
|
22
|
+
export {};
|
|
@@ -13,8 +13,9 @@ export interface SideDockProps {
|
|
|
13
13
|
* it slides off-screen and becomes inert. Keeping the subtree mounted
|
|
14
14
|
* means opening costs zero React work on the click's critical path. */
|
|
15
15
|
open: boolean;
|
|
16
|
-
/** Dock column width
|
|
17
|
-
|
|
16
|
+
/** Dock column width — px, or any CSS length (`'100%'` fills a sized
|
|
17
|
+
* ancestor). Resizing (`onWidthChange`) needs a px number. */
|
|
18
|
+
width: number | string;
|
|
18
19
|
/** Distance from the top of the positioned ancestor (the brand shell's
|
|
19
20
|
* relative container) — reserves room for brand chrome above the dock. */
|
|
20
21
|
top: number;
|
|
@@ -28,5 +28,9 @@ export interface SpacefrontIslandProps {
|
|
|
28
28
|
* `--fourty-island-*` custom properties in `@40rty/ams-ui/island.css` (which
|
|
29
29
|
* the host imports — this module has no CSS side effect). Reads only the
|
|
30
30
|
* public sdk hooks, so it works inside any `<Spacefront>`.
|
|
31
|
+
*
|
|
32
|
+
* Beside a `<SpacefrontThreadPanel>` it yields while the panel is open on
|
|
33
|
+
* screen — one composer at a time — and `<SpacefrontPresence>` attaches above
|
|
34
|
+
* its slab (`host-shell-store.ts`).
|
|
31
35
|
*/
|
|
32
|
-
export declare function SpacefrontIsland({ placeholder, emptyText, workingText, pillLabel, container, stopKeyPropagation, }: SpacefrontIslandProps): React.ReactElement;
|
|
36
|
+
export declare function SpacefrontIsland({ placeholder, emptyText, workingText, pillLabel, container, stopKeyPropagation, }: SpacefrontIslandProps): React.ReactElement | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface SpacefrontPresenceProps {
|
|
3
|
+
/** The working line while the agent thinks and has nothing to show yet. */
|
|
4
|
+
thinkingText?: string;
|
|
5
|
+
/** The heading over what the agent understood about the visitor. */
|
|
6
|
+
factsLabel?: string;
|
|
7
|
+
/** The confirm button of a standing question that offers no replies. */
|
|
8
|
+
confirmLabel?: string;
|
|
9
|
+
/**
|
|
10
|
+
* `'auto'` (default): attaches at the top of an open `<SpacefrontThreadPanel>`,
|
|
11
|
+
* else above a `<SpacefrontIsland>` (hidden while it is folded to its pill),
|
|
12
|
+
* else renders where it is mounted. `'inline'`: always where it is mounted.
|
|
13
|
+
*/
|
|
14
|
+
placement?: 'auto' | 'inline';
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The agent presence band for a host-owned page: what the agent is doing now
|
|
18
|
+
* (scanning, with the records it is reading; thinking; its one-line voice),
|
|
19
|
+
* what it understood about the visitor (facts the visitor can forget), and the
|
|
20
|
+
* question it stands on (confirm / dismiss). Fold mechanics are the platform
|
|
21
|
+
* notch's (`usePresenceNotch`: expanded while working, hovered or asking, a
|
|
22
|
+
* settle dwell after); the facts are the band's own projection (`useBandFacts`).
|
|
23
|
+
* Silent when there is nothing to say. Styles: `@40rty/ams-ui/presence.css`.
|
|
24
|
+
*/
|
|
25
|
+
export declare function SpacefrontPresence({ thinkingText, factsLabel, confirmLabel, placement, }: SpacefrontPresenceProps): React.ReactElement | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
export interface SpacefrontThreadPanelProps {
|
|
3
|
+
/** The panel's heading — also its landmark name. */
|
|
4
|
+
title?: string;
|
|
5
|
+
/** The field's placeholder — also its accessible name. */
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
/** What the thread says before the visitor has asked anything. */
|
|
8
|
+
emptyText?: string;
|
|
9
|
+
/** The answer's line while a turn is in flight, before its prose streams. */
|
|
10
|
+
workingText?: string;
|
|
11
|
+
/** The collapsed tab's text. */
|
|
12
|
+
tabLabel?: string;
|
|
13
|
+
/** Desktop width in px. On a phone the panel takes the full width. */
|
|
14
|
+
width?: number;
|
|
15
|
+
/**
|
|
16
|
+
* `true` (default): the panel opens once the visitor engages and again on
|
|
17
|
+
* each new message they send — until they collapse it themselves, after
|
|
18
|
+
* which (remembered under `storageKey`) only the tab opens it. `false`:
|
|
19
|
+
* only the tab ever opens it.
|
|
20
|
+
*/
|
|
21
|
+
autoOpen?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* `localStorage` key the open state is remembered under across reloads;
|
|
24
|
+
* `null` remembers nothing.
|
|
25
|
+
*/
|
|
26
|
+
storageKey?: string | null;
|
|
27
|
+
/** Keep keystrokes in the panel from the host's own key handlers. Default true. */
|
|
28
|
+
stopKeyPropagation?: boolean;
|
|
29
|
+
}
|
|
30
|
+
/** Set on `<html>` while the panel is docked open on desktop: its width in px,
|
|
31
|
+
* else `0px` — the host's canvas pads by it to cede the column. */
|
|
32
|
+
export declare const THREAD_PANEL_INSET_PROPERTY = "--fourty-thread-panel-inset";
|
|
33
|
+
/**
|
|
34
|
+
* The chat side panel for a host-owned page: the whole conversation (the
|
|
35
|
+
* visitor's asks, the agent's prose), suggestion chips and a composer, docked
|
|
36
|
+
* to the right on desktop and collapsible to a tab. Its open state is the
|
|
37
|
+
* platform shell's (`useDockState` — opens on engagement, stays shut while an
|
|
38
|
+
* agent drives the page, the visitor's own toggle wins) and its reveal is
|
|
39
|
+
* `SideDock`'s; the look is the host's, through `@40rty/ams-ui/thread-panel.css`.
|
|
40
|
+
*
|
|
41
|
+
* Beside a `<SpacefrontIsland>` it shares one composer: on desktop the island
|
|
42
|
+
* yields while the panel is open; on a phone the panel stands down entirely and
|
|
43
|
+
* the island is the thread. Alone, it works on both.
|
|
44
|
+
*/
|
|
45
|
+
export declare function SpacefrontThreadPanel({ storageKey, ...props }: SpacefrontThreadPanelProps): React.ReactElement;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
interface ThreadPanelConversationProps {
|
|
3
|
+
fieldRef: React.RefObject<HTMLInputElement | null>;
|
|
4
|
+
placeholder: string;
|
|
5
|
+
emptyText: string;
|
|
6
|
+
workingText: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The panel's body: the full thread (each turn's ask and the agent's prose),
|
|
10
|
+
* the working / error line, suggestion chips and the composer. Public sdk hooks
|
|
11
|
+
* only — the same ones the island reads, so both show one conversation.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ThreadPanelConversation({ fieldRef, placeholder, emptyText, workingText }: ThreadPanelConversationProps): React.ReactElement;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Where the host-page shell components meet: `<SpacefrontIsland>`,
|
|
4
|
+
* `<SpacefrontThreadPanel>` and `<SpacefrontPresence>` are mounted independently
|
|
5
|
+
* by the host (each from its own entry), so there is no ShellScaffold above them
|
|
6
|
+
* to provide a dock context. This module-scope store is that context instead —
|
|
7
|
+
* one copy per page, because the published entries share it as a split chunk.
|
|
8
|
+
*
|
|
9
|
+
* - `islands` — how many islands are mounted. The panel stands down on a
|
|
10
|
+
* phone when one is (the island IS the mobile thread).
|
|
11
|
+
* - `islandSlot` — the element above the island's slab presence portals into
|
|
12
|
+
* (null while the island is folded to its pill).
|
|
13
|
+
* - `panelSlot` — the element at the top of the panel, set only while the
|
|
14
|
+
* panel is open and on screen. Its presence means the panel
|
|
15
|
+
* owns the composer: the island yields while it is set.
|
|
16
|
+
*/
|
|
17
|
+
export interface HostShellState {
|
|
18
|
+
islands: number;
|
|
19
|
+
islandSlot: HTMLElement | null;
|
|
20
|
+
panelSlot: HTMLElement | null;
|
|
21
|
+
}
|
|
22
|
+
export declare function useHostShell(): HostShellState;
|
|
23
|
+
/** Counts this island as mounted for as long as the calling component is. */
|
|
24
|
+
export declare function useRegisterIsland(): void;
|
|
25
|
+
/** Publishes `el` as the island's presence slot while it is mounted. */
|
|
26
|
+
export declare function useIslandSlot(el: HTMLElement | null): void;
|
|
27
|
+
/** Publishes `el` as the panel's presence slot while `active`. */
|
|
28
|
+
export declare function usePanelSlot(el: HTMLElement | null, active: boolean): void;
|
|
29
|
+
/**
|
|
30
|
+
* Keeps a keystroke inside a shell component from reaching the host's own key
|
|
31
|
+
* handlers (single-key shortcuts, Escape-closes-drawer). React stops the native
|
|
32
|
+
* event at its root; the immediate stop also covers a host whose root IS the
|
|
33
|
+
* document (Hydrogen) with listeners added after React's.
|
|
34
|
+
*/
|
|
35
|
+
export declare function stopHostKeys(event: React.KeyboardEvent): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SpacefrontThreadPanel, THREAD_PANEL_INSET_PROPERTY, type SpacefrontThreadPanelProps, } from '../shell/SpacefrontThreadPanel';
|
package/package.json
CHANGED
|
@@ -42,8 +42,18 @@
|
|
|
42
42
|
"types": "./dist/types/island/index.d.ts",
|
|
43
43
|
"default": "./dist/island.js"
|
|
44
44
|
},
|
|
45
|
+
"./thread-panel": {
|
|
46
|
+
"types": "./dist/types/thread-panel/index.d.ts",
|
|
47
|
+
"default": "./dist/thread-panel.js"
|
|
48
|
+
},
|
|
49
|
+
"./presence": {
|
|
50
|
+
"types": "./dist/types/presence/index.d.ts",
|
|
51
|
+
"default": "./dist/presence.js"
|
|
52
|
+
},
|
|
45
53
|
"./motion.css": "./dist/css/preset/motion.css",
|
|
46
54
|
"./island.css": "./dist/css/shell/spacefront-island.css",
|
|
55
|
+
"./thread-panel.css": "./dist/css/shell/spacefront-thread-panel.css",
|
|
56
|
+
"./presence.css": "./dist/css/shell/spacefront-presence.css",
|
|
47
57
|
"./preset/tailwind-theme.css": "./dist/css/preset/tailwind-theme.css"
|
|
48
58
|
},
|
|
49
59
|
"sideEffects": [
|
|
@@ -62,12 +72,12 @@
|
|
|
62
72
|
"zod": "^3.23.0"
|
|
63
73
|
},
|
|
64
74
|
"peerDependencies": {
|
|
65
|
-
"@40rty/ams-sdk": "0.3.
|
|
75
|
+
"@40rty/ams-sdk": "0.3.2",
|
|
66
76
|
"lucide-react": ">=0.400.0",
|
|
67
77
|
"react": ">=18.0.0",
|
|
68
78
|
"react-dom": ">=18.0.0"
|
|
69
79
|
},
|
|
70
|
-
"version": "0.3.
|
|
80
|
+
"version": "0.3.2",
|
|
71
81
|
"homepage": "https://docs.40rty.ai",
|
|
72
82
|
"license": "UNLICENSED",
|
|
73
83
|
"engines": {
|