one-design-next 0.0.13 → 0.0.15

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.
Files changed (48) hide show
  1. package/dist/_genui-types.d.ts +72 -27
  2. package/dist/action-bar/style/index.css +2 -2
  3. package/dist/agent-step/style/index.css +1 -1
  4. package/dist/attachments/style/index.css +5 -5
  5. package/dist/chat-item/style/index.css +2 -2
  6. package/dist/composer/clipboard.d.ts +1 -1
  7. package/dist/composer/editor.d.ts +10 -2
  8. package/dist/composer/editor.js +199 -35
  9. package/dist/composer/hooks/useChipManager.d.ts +8 -3
  10. package/dist/composer/hooks/useChipManager.js +105 -10
  11. package/dist/composer/index.d.ts +17 -2
  12. package/dist/composer/index.js +136 -65
  13. package/dist/composer/inline-ref.d.ts +6 -2
  14. package/dist/composer/inline-ref.js +10 -3
  15. package/dist/composer/param-panel.d.ts +14 -0
  16. package/dist/composer/param-panel.js +1 -0
  17. package/dist/composer/segments.d.ts +29 -0
  18. package/dist/composer/segments.js +83 -0
  19. package/dist/composer/send-meta.d.ts +7 -4
  20. package/dist/composer/send-meta.js +12 -52
  21. package/dist/composer/style/index.css +27 -8
  22. package/dist/composer/utils.d.ts +35 -1
  23. package/dist/composer/utils.js +281 -36
  24. package/dist/fab/style/index.css +1 -1
  25. package/dist/index.d.ts +4 -2
  26. package/dist/index.js +4 -2
  27. package/dist/invocation/index.d.ts +7 -2
  28. package/dist/invocation/index.js +14 -8
  29. package/dist/invocation/param-popover.d.ts +21 -0
  30. package/dist/invocation/param-popover.js +113 -0
  31. package/dist/invocation/style/index.css +33 -9
  32. package/dist/mention/index.d.ts +1 -6
  33. package/dist/mention/index.js +11 -8
  34. package/dist/mention/style/index.css +30 -9
  35. package/dist/preview-panel/index.js +11 -1
  36. package/dist/preview-panel/style/index.css +11 -0
  37. package/dist/skill-slot/index.js +5 -5
  38. package/dist/skill-slot/style/index.css +51 -27
  39. package/dist/suggestions/index.js +1 -5
  40. package/dist/suggestions/style/index.css +6 -7
  41. package/dist/user-bubble/index.js +9 -4
  42. package/dist/user-bubble/render-segments.d.ts +9 -0
  43. package/dist/user-bubble/render-segments.js +42 -0
  44. package/dist/user-bubble/style/index.css +9 -0
  45. package/dist/welcome/style/index.css +1 -1
  46. package/package.json +4 -4
  47. package/dist/composer/chip.d.ts +0 -36
  48. package/dist/composer/chip.js +0 -49
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ import type { ComposerSegment } from '../_genui-types';
3
+ /** segments 是否含可见正文(文本非空或含内联引用)。 */
4
+ export declare function segmentsHaveVisibleContent(segments: ComposerSegment[]): boolean;
5
+ /**
6
+ * 将 `ComposerSegment[]` 渲染为 UserBubble 正文(只读 Invocation / Mention + 文本)。
7
+ * 顺序与 Composer 发送时一致。
8
+ */
9
+ export declare function renderSegmentsContent(segments: ComposerSegment[]): React.ReactNode;
@@ -0,0 +1,42 @@
1
+ import { Invocation } from "../invocation";
2
+ import { Mention } from "../mention";
3
+
4
+ /** segments 是否含可见正文(文本非空或含内联引用)。 */
5
+ export function segmentsHaveVisibleContent(segments) {
6
+ return segments.some(function (s) {
7
+ return s.type === 'invocation' || s.type === 'mention' || s.type === 'text' && s.data.text.trim().length > 0;
8
+ });
9
+ }
10
+
11
+ /**
12
+ * 将 `ComposerSegment[]` 渲染为 UserBubble 正文(只读 Invocation / Mention + 文本)。
13
+ * 顺序与 Composer 发送时一致。
14
+ */
15
+ export function renderSegmentsContent(segments) {
16
+ var nodes = [];
17
+ segments.forEach(function (seg, index) {
18
+ var key = "".concat(seg.type, "-").concat(index);
19
+ if (seg.type === 'text') {
20
+ if (seg.data.text.length > 0) nodes.push( /*#__PURE__*/React.createElement("span", {
21
+ key: key
22
+ }, seg.data.text));
23
+ return;
24
+ }
25
+ if (seg.type === 'invocation') {
26
+ nodes.push( /*#__PURE__*/React.createElement(Invocation, {
27
+ key: key,
28
+ data: seg.data
29
+ }));
30
+ return;
31
+ }
32
+ if (seg.type === 'mention') {
33
+ nodes.push( /*#__PURE__*/React.createElement(Mention, {
34
+ key: key,
35
+ data: seg.data
36
+ }));
37
+ }
38
+ });
39
+ if (nodes.length === 0) return null;
40
+ if (nodes.length === 1) return nodes[0];
41
+ return /*#__PURE__*/React.createElement(React.Fragment, null, nodes);
42
+ }
@@ -1,3 +1,4 @@
1
+ @charset "UTF-8";
1
2
  [data-odn-user-bubble] {
2
3
  display: flex;
3
4
  justify-content: flex-end;
@@ -25,6 +26,14 @@
25
26
  color: var(--odn-color-black-12);
26
27
  margin: 0;
27
28
  }
29
+ [data-odn-user-bubble-text] {
30
+ /* 气泡内 inline ref 跟随正文 inherit,避免与 Composer 默认 14/24 脱节 */
31
+ }
32
+ [data-odn-user-bubble-text] [data-odn-invocation],
33
+ [data-odn-user-bubble-text] [data-odn-mention] {
34
+ font-size: inherit;
35
+ line-height: inherit;
36
+ }
28
37
 
29
38
  [data-odn-user-bubble-images] {
30
39
  display: flex;
@@ -29,7 +29,7 @@
29
29
  align-items: center;
30
30
  justify-content: center;
31
31
  margin-bottom: 16px;
32
- color: var(--odn-color-cyan-5);
32
+ color: var(--odn-color-brand-6);
33
33
  }
34
34
 
35
35
  [data-odn-welcome-suggestions] {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one-design-next",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "One Design Next from TAD@tencent.com",
5
5
  "module": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -117,8 +117,8 @@
117
117
  "tweakpane": "latest"
118
118
  },
119
119
  "dependencies": {
120
- "@base-ui/react": "^1.4.1",
121
- "@daypicker/react": "^10.0.0",
120
+ "@base-ui/react": "^1.5.0",
121
+ "@daypicker/react": "^10.0.1",
122
122
  "@floating-ui/react": "^0.27.19",
123
123
  "@number-flow/react": "^0.6.0",
124
124
  "@paper-design/shaders-react": "^0.0.76",
@@ -126,7 +126,7 @@
126
126
  "clsx": "^2.1.1",
127
127
  "echarts-for-react": "^3.0.6",
128
128
  "ldrs": "^1.1.9",
129
- "motion": "^12.38.0",
129
+ "motion": "^12.39.0",
130
130
  "rc-cascader": "^3.34.0",
131
131
  "rc-select": "^14.16.8",
132
132
  "rc-slider": "^11.1.9",
@@ -1,36 +0,0 @@
1
- /**
2
- * Composer · 编辑器内的 chip 视觉
3
- *
4
- * 当前形态极简:[icon][label][×]
5
- * - hover 时 icon 变 ×(左槽位互斥),节省横向空间
6
- * - × 用 onMouseDown preventDefault 防止 contenteditable 把焦点吃过去
7
- *
8
- * 视觉是 inline-flex 的 atomic 元素;其 DOM 容器(host span)由 useChipManager
9
- * 创建并维护 contentEditable=false / data-mention-id;这里只渲染 host 内的内容。
10
- */
11
- /// <reference types="react" />
12
- /** chip 渲染所需的最小数据结构。 */
13
- export interface ChipData {
14
- /** chip 实例唯一 id(与 value marker 中的 id 对应) */
15
- id: string;
16
- /** 业务定义 id(如 skill id / mention 对象 id),业务方在 onSend 时反查源数据用 */
17
- skillId: string;
18
- /** chip 显示文本 */
19
- label: string;
20
- /** chip 显示 icon name */
21
- icon: string;
22
- /**
23
- * chip 语义来源标记,业务方自定义。Composer 内部不消费 kind,
24
- * 仅原样透传到 onSend(meta.chips),方便业务方按 kind 分类。
25
- * 约定:'invocation' = 工具栏按钮 / `/` 触发(SendMeta.invocations);
26
- * 'mention' = `@` 触发(SendMeta.mentions);
27
- * 'skill' 为兼容别名,等同 invocation。
28
- */
29
- kind?: 'invocation' | 'mention' | 'skill' | (string & {});
30
- }
31
- export interface ChipProps {
32
- data: ChipData;
33
- onRemove: () => void;
34
- }
35
- export declare function Chip({ data, onRemove }: ChipProps): import("react").JSX.Element;
36
- export default Chip;
@@ -1,49 +0,0 @@
1
- /**
2
- * Composer · 编辑器内的 chip 视觉
3
- *
4
- * 当前形态极简:[icon][label][×]
5
- * - hover 时 icon 变 ×(左槽位互斥),节省横向空间
6
- * - × 用 onMouseDown preventDefault 防止 contenteditable 把焦点吃过去
7
- *
8
- * 视觉是 inline-flex 的 atomic 元素;其 DOM 容器(host span)由 useChipManager
9
- * 创建并维护 contentEditable=false / data-mention-id;这里只渲染 host 内的内容。
10
- */
11
-
12
- import Icon from "../icon";
13
-
14
- /** chip 渲染所需的最小数据结构。 */
15
-
16
- export function Chip(_ref) {
17
- var data = _ref.data,
18
- onRemove = _ref.onRemove;
19
- return /*#__PURE__*/React.createElement("span", {
20
- "data-odn-composer-chip": true,
21
- "data-state": "valid"
22
- }, /*#__PURE__*/React.createElement("span", {
23
- "data-odn-composer-chip-icon": true,
24
- "aria-hidden": true
25
- }, /*#__PURE__*/React.createElement(Icon, {
26
- name: data.icon,
27
- size: 12
28
- })), /*#__PURE__*/React.createElement("button", {
29
- type: "button",
30
- "data-odn-composer-chip-remove": true,
31
- "aria-label": "\u79FB\u9664 ".concat(data.label),
32
- onMouseDown: function onMouseDown(e) {
33
- // 阻止 contenteditable 把焦点拽走 / 光标错位
34
- e.preventDefault();
35
- e.stopPropagation();
36
- },
37
- onClick: function onClick(e) {
38
- e.preventDefault();
39
- e.stopPropagation();
40
- onRemove();
41
- }
42
- }, /*#__PURE__*/React.createElement(Icon, {
43
- name: "x",
44
- size: 12
45
- })), /*#__PURE__*/React.createElement("span", {
46
- "data-odn-composer-chip-label": true
47
- }, data.label));
48
- }
49
- export default Chip;