@lemoncat7/dsh-partner 1.6.0 → 1.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,8 @@
1
+ import type { CompanionView } from '../client-api.js';
2
+ /** Local, themed listbox: no platform select popup or second CSS arrow. */
3
+ export declare function CompanionPicker({ companions, selectedId, onChange }: {
4
+ companions: Pick<CompanionView, 'id' | 'name' | 'role'>[];
5
+ selectedId: string | undefined;
6
+ onChange(id: string): void;
7
+ }): JSX.Element;
8
+ //# sourceMappingURL=companion-picker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"companion-picker.d.ts","sourceRoot":"","sources":["../../src/ui/companion-picker.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAGrD,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,EAAE;IACpE,UAAU,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzD,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;CAC3B,GAAG,GAAG,CAAC,OAAO,CA+Dd"}
@@ -0,0 +1,70 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useId, useRef, useState } from 'react';
3
+ import { IconCheckOutline14, IconChevronDownOutline14 } from '@deepseek-ai/dsh-client-ui-primitives';
4
+ import { Avatar } from './partner-components.js';
5
+ /** Local, themed listbox: no platform select popup or second CSS arrow. */
6
+ export function CompanionPicker({ companions, selectedId, onChange }) {
7
+ const [open, setOpen] = useState(false);
8
+ const root = useRef(null);
9
+ const trigger = useRef(null);
10
+ const list = useRef(null);
11
+ const listId = useId();
12
+ const current = companions.find(item => item.id === selectedId) ?? companions[0];
13
+ useEffect(() => {
14
+ if (!open)
15
+ return;
16
+ const options = list.current?.querySelectorAll('[role="option"]');
17
+ const selected = Math.max(0, companions.findIndex(item => item.id === selectedId));
18
+ options?.[selected]?.focus({ preventScroll: true });
19
+ options?.[selected]?.scrollIntoView({ block: 'nearest' });
20
+ const outside = (event) => {
21
+ if (!root.current?.contains(event.target))
22
+ setOpen(false);
23
+ };
24
+ const close = () => setOpen(false);
25
+ const desktop = window.matchMedia('(min-width: 761px)');
26
+ document.addEventListener('pointerdown', outside);
27
+ window.addEventListener('blur', close);
28
+ desktop.addEventListener('change', close);
29
+ return () => {
30
+ document.removeEventListener('pointerdown', outside);
31
+ window.removeEventListener('blur', close);
32
+ desktop.removeEventListener('change', close);
33
+ };
34
+ }, [open, companions, selectedId]);
35
+ const dismiss = () => { setOpen(false); trigger.current?.focus({ preventScroll: true }); };
36
+ const navigate = (event) => {
37
+ if (event.key === 'Escape') {
38
+ event.preventDefault();
39
+ event.stopPropagation();
40
+ dismiss();
41
+ return;
42
+ }
43
+ const options = Array.from(list.current?.querySelectorAll('[role="option"]') ?? []);
44
+ const index = options.indexOf(document.activeElement);
45
+ let next;
46
+ if (event.key === 'ArrowDown')
47
+ next = (index + 1) % options.length;
48
+ else if (event.key === 'ArrowUp')
49
+ next = (index - 1 + options.length) % options.length;
50
+ else if (event.key === 'Home')
51
+ next = 0;
52
+ else if (event.key === 'End')
53
+ next = options.length - 1;
54
+ else
55
+ return;
56
+ event.preventDefault();
57
+ options[next]?.focus({ preventScroll: true });
58
+ options[next]?.scrollIntoView({ block: 'nearest' });
59
+ };
60
+ return _jsxs("div", { className: "dsh-partner-companion-picker", ref: root, onBlur: event => {
61
+ if (!event.currentTarget.contains(event.relatedTarget))
62
+ setOpen(false);
63
+ }, children: [_jsxs("button", { ref: trigger, type: "button", className: "dsh-partner-companion-trigger", "aria-label": `切换当前伙伴${current ? `:${current.name}` : ''}`, "aria-haspopup": "listbox", "aria-expanded": open, "aria-controls": open ? listId : undefined, disabled: !current, onClick: () => setOpen(value => !value), onKeyDown: event => {
64
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
65
+ event.preventDefault();
66
+ setOpen(true);
67
+ }
68
+ }, children: [current && _jsx(Avatar, { name: current.name, small: true }), _jsxs("span", { className: "dsh-partner-companion-copy", children: [_jsx("strong", { children: current?.name ?? '还没有伙伴' }), _jsx("small", { children: current?.role || '选择伙伴' })] }), _jsx("span", { className: "dsh-partner-companion-chevron", "aria-hidden": "true", children: _jsx(IconChevronDownOutline14, { size: 14 }) })] }), open && _jsx("div", { ref: list, id: listId, role: "listbox", "aria-label": "\u9009\u62E9\u4F19\u4F34", className: "dsh-partner-companion-options", onKeyDown: navigate, children: companions.map(item => _jsxs("button", { type: "button", role: "option", "aria-selected": item.id === current?.id, tabIndex: item.id === current?.id ? 0 : -1, onClick: () => { dismiss(); onChange(item.id); }, children: [_jsx(Avatar, { name: item.name, small: true }), _jsxs("span", { className: "dsh-partner-companion-copy", children: [_jsx("strong", { children: item.name }), _jsx("small", { children: item.role })] }), _jsx("span", { className: "dsh-partner-companion-check", "aria-hidden": "true", children: item.id === current?.id && _jsx(IconCheckOutline14, { size: 14 }) })] }, item.id)) })] });
69
+ }
70
+ //# sourceMappingURL=companion-picker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"companion-picker.js","sourceRoot":"","sources":["../../src/ui/companion-picker.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAsB,MAAM,OAAO,CAAA;AAC9E,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,uCAAuC,CAAA;AAEpG,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAEhD,2EAA2E;AAC3E,MAAM,UAAU,eAAe,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAIjE;IACC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAA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AAI,GAAS,IAAO,EAC1G,eAAM,SAAS,EAAC,6BAA6B,iBAAa,MAAM,YAAE,IAAI,CAAC,EAAE,KAAK,OAAO,EAAE,EAAE,IAAI,KAAC,kBAAkB,IAAC,IAAI,EAAE,EAAE,GAAI,GAAQ,KAHc,IAAI,CAAC,EAAE,CAInJ,CAAC,GACN,IACF,CAAA;AACR,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lemoncat7/dsh-partner",
3
- "version": "1.6.0",
3
+ "version": "1.6.1",
4
4
  "description": "Long-lived AI companions with WeChat channel routing for DeepSeek Harness",
5
5
  "keywords": [
6
6
  "deepseek-harness",