@asteby/metacore-ai-chat 1.1.0 → 1.2.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/copilot-widget.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
import { type CopilotChatProps } from './copilot-chat';
|
|
1
2
|
import { type FabPosition } from './use-draggable-fab';
|
|
2
3
|
export interface CopilotWidgetProps {
|
|
3
4
|
/** Initial FAB spot (right-anchored); a position the user dragged wins. */
|
|
4
5
|
defaultPosition?: FabPosition;
|
|
5
6
|
defaultOpen?: boolean;
|
|
6
7
|
zIndex?: number;
|
|
8
|
+
/** Forwarded to `CopilotChat`: past sessions for the picker. */
|
|
9
|
+
sessions?: CopilotChatProps['sessions'];
|
|
10
|
+
/** Forwarded to `CopilotChat`: called when the user picks a session. */
|
|
11
|
+
onSelectSession?: CopilotChatProps['onSelectSession'];
|
|
12
|
+
/** Forwarded to `CopilotChat`: shows the demo badge (overrides the provider). */
|
|
13
|
+
demo?: CopilotChatProps['demo'];
|
|
7
14
|
}
|
|
8
15
|
/** Floating action button + anchored chat panel. Renders nothing without `canChat`. */
|
|
9
|
-
export declare function CopilotWidget({ defaultPosition, defaultOpen, zIndex }: CopilotWidgetProps): import("react").JSX.Element | null;
|
|
16
|
+
export declare function CopilotWidget({ defaultPosition, defaultOpen, zIndex, sessions, onSelectSession, demo }: CopilotWidgetProps): import("react").JSX.Element | null;
|
|
10
17
|
//# sourceMappingURL=copilot-widget.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-widget.d.ts","sourceRoot":"","sources":["../src/copilot-widget.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"copilot-widget.d.ts","sourceRoot":"","sources":["../src/copilot-widget.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAe,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAGnE,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAA;AAEvE,MAAM,WAAW,kBAAkB;IACjC,2EAA2E;IAC3E,eAAe,CAAC,EAAE,WAAW,CAAA;IAC7B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,gEAAgE;IAChE,QAAQ,CAAC,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAA;IACvC,wEAAwE;IACxE,eAAe,CAAC,EAAE,gBAAgB,CAAC,iBAAiB,CAAC,CAAA;IACrD,iFAAiF;IACjF,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAA;CAChC;AAED,uFAAuF;AACvF,wBAAgB,aAAa,CAAC,EAAE,eAAe,EAAE,WAAmB,EAAE,MAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAE,EAAE,kBAAkB,sCAiFvI"}
|
package/dist/copilot-widget.js
CHANGED
|
@@ -6,7 +6,7 @@ import { useCopilot } from './context';
|
|
|
6
6
|
import { AGENT_FOCUS, AGENT_PANEL } from './surfaces';
|
|
7
7
|
import { useDraggableFab } from './use-draggable-fab';
|
|
8
8
|
/** Floating action button + anchored chat panel. Renders nothing without `canChat`. */
|
|
9
|
-
export function CopilotWidget({ defaultPosition, defaultOpen = false, zIndex = 50 }) {
|
|
9
|
+
export function CopilotWidget({ defaultPosition, defaultOpen = false, zIndex = 50, sessions, onSelectSession, demo }) {
|
|
10
10
|
const { permissions, branding, labels } = useCopilot();
|
|
11
11
|
const [open, setOpen] = useState(defaultOpen);
|
|
12
12
|
const fab = useDraggableFab(defaultPosition);
|
|
@@ -26,6 +26,27 @@ export function CopilotWidget({ defaultPosition, defaultOpen = false, zIndex = 5
|
|
|
26
26
|
fabRef.current?.focus();
|
|
27
27
|
}
|
|
28
28
|
}, [open]);
|
|
29
|
+
// Escape closes the panel even when focus sits outside it (e.g. a toast).
|
|
30
|
+
// Yields to anything else that claims the key: handled events, IME
|
|
31
|
+
// composition, other modal dialogs and text fields outside the panel.
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!open)
|
|
34
|
+
return;
|
|
35
|
+
const onKey = (e) => {
|
|
36
|
+
if (e.key !== 'Escape' || e.defaultPrevented || e.isComposing)
|
|
37
|
+
return;
|
|
38
|
+
const t = e.target instanceof Element ? e.target : null;
|
|
39
|
+
if (t && !panelRef.current?.contains(t)) {
|
|
40
|
+
if (t.closest('[aria-modal="true"], dialog[open]'))
|
|
41
|
+
return;
|
|
42
|
+
if (t.closest('input, textarea, select, [contenteditable]:not([contenteditable="false"])'))
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
setOpen(false);
|
|
46
|
+
};
|
|
47
|
+
document.addEventListener('keydown', onKey);
|
|
48
|
+
return () => document.removeEventListener('keydown', onKey);
|
|
49
|
+
}, [open]);
|
|
29
50
|
if (!permissions.canChat)
|
|
30
51
|
return null;
|
|
31
52
|
const { panelLayout: p } = fab;
|
|
@@ -37,7 +58,7 @@ export function CopilotWidget({ defaultPosition, defaultOpen = false, zIndex = 5
|
|
|
37
58
|
width: p.width,
|
|
38
59
|
height: p.height,
|
|
39
60
|
overflow: 'hidden',
|
|
40
|
-
}, children: _jsx(CopilotChat, { onClose: () => setOpen(false) }) })), _jsx("button", { type: "button", "aria-label": open ? labels.close : labels.open, "aria-expanded": open, ref: fabRef, className: `fixed flex size-12 items-center justify-center rounded-full border bg-background shadow-lg ${AGENT_FOCUS}`, style: { ...fab.fabStyle, zIndex }, onPointerDown: fab.onFabPointerDown, onPointerMove: fab.onFabPointerMove, onPointerUp: fab.onFabPointerUp, onClick: () => {
|
|
61
|
+
}, children: _jsx(CopilotChat, { onClose: () => setOpen(false), sessions: sessions, onSelectSession: onSelectSession, demo: demo }) })), _jsx("button", { type: "button", "aria-label": open ? labels.close : labels.open, "aria-expanded": open, ref: fabRef, className: `fixed flex size-12 items-center justify-center rounded-full border bg-background shadow-lg ${AGENT_FOCUS}`, style: { ...fab.fabStyle, zIndex }, onPointerDown: fab.onFabPointerDown, onPointerMove: fab.onFabPointerMove, onPointerUp: fab.onFabPointerUp, onClick: () => {
|
|
41
62
|
if (!fab.shouldSkipFabClick())
|
|
42
63
|
setOpen((o) => !o);
|
|
43
64
|
}, children: branding.avatar ?? _jsx(Mascot, { skin: branding.mascotSkin, size: 36 }) })] }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot-widget.js","sourceRoot":"","sources":["../src/copilot-widget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AACvD,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"copilot-widget.js","sourceRoot":"","sources":["../src/copilot-widget.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAA;AACvD,OAAO,EAAE,WAAW,EAAyB,MAAM,gBAAgB,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AACtC,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EAAE,eAAe,EAAoB,MAAM,qBAAqB,CAAA;AAevE,uFAAuF;AACvF,MAAM,UAAU,aAAa,CAAC,EAAE,eAAe,EAAE,WAAW,GAAG,KAAK,EAAE,MAAM,GAAG,EAAE,EAAE,QAAQ,EAAE,eAAe,EAAE,IAAI,EAAsB;IACtI,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAAA;IACtD,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAA;IAC7C,MAAM,GAAG,GAAG,eAAe,CAAC,eAAe,CAAC,CAAA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AAE,MAAM,EAAE,EAClC,aAAa,EAAE,GAAG,CAAC,gBAAgB,EACnC,aAAa,EAAE,GAAG,CAAC,gBAAgB,EACnC,WAAW,EAAE,GAAG,CAAC,cAAc,EAC/B,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE;wBAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;gBACnD,CAAC,YAEA,QAAQ,CAAC,MAAM,IAAI,KAAC,MAAM,IAAC,IAAI,EAAE,QAAQ,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,GAAI,GAC5D,IACR,CACJ,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asteby/metacore-ai-chat",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Metacore copilot chat — floating widget, chat panel, draggable FAB and an injectable chat client (HTTP, permissions, branding, suggestions)",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|