one-design-next 0.0.11 → 0.0.12
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/_genui-types.d.ts +9 -0
- package/dist/attachments/index.js +17 -10
- package/dist/attachments/style/index.css +23 -0
- package/dist/collapse/primitive.d.ts +1 -1
- package/dist/composer/editor.d.ts +6 -0
- package/dist/composer/editor.js +5 -1
- package/dist/composer/index.d.ts +58 -1
- package/dist/composer/index.js +156 -80
- package/dist/composer/style/index.css +9 -0
- package/dist/icon/svg-data.d.ts +4 -0
- package/dist/icon/svg-data.js +1 -1
- package/dist/icon/types.d.ts +1 -1
- package/dist/preview-panel/index.d.ts +5 -1
- package/dist/preview-panel/index.js +27 -2
- package/package.json +1 -2
package/dist/_genui-types.d.ts
CHANGED
|
@@ -105,6 +105,10 @@ export interface MessageSnapshot {
|
|
|
105
105
|
message: string;
|
|
106
106
|
retryable?: boolean;
|
|
107
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* 用户对该版本回答的反馈状态。点踩/点赞按版本独立维护——切到不同版本应回显该版本自身的态度。
|
|
110
|
+
*/
|
|
111
|
+
feedback?: 'positive' | 'negative' | null;
|
|
108
112
|
}
|
|
109
113
|
export interface ChatMessage {
|
|
110
114
|
id: string;
|
|
@@ -126,4 +130,9 @@ export interface ChatMessage {
|
|
|
126
130
|
* 助手消息可选的快捷回复(如意图澄清)。由上层在正文下渲染为可点选项,点击语义等同用户发送该句。
|
|
127
131
|
*/
|
|
128
132
|
suggestionChips?: string[];
|
|
133
|
+
/**
|
|
134
|
+
* 用户对**最新版本**回答的反馈状态。历史版本的反馈各自存在 `regenerations[i].feedback`,
|
|
135
|
+
* 切到不同版本时按版本独立回显——同一问题的不同回答用户态度可以不同。
|
|
136
|
+
*/
|
|
137
|
+
feedback?: 'positive' | 'negative' | null;
|
|
129
138
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
1
2
|
import HoverFill from "../hover-fill";
|
|
2
3
|
import Icon from "../icon";
|
|
3
4
|
import "./style";
|
|
@@ -253,12 +254,7 @@ export function Attachments(_ref) {
|
|
|
253
254
|
}
|
|
254
255
|
var meta = getFileMeta(a.type);
|
|
255
256
|
var isImage = a.type.startsWith('image/') && a.url;
|
|
256
|
-
var
|
|
257
|
-
"data-odn-attachments-img-wrapper": true
|
|
258
|
-
}, /*#__PURE__*/React.createElement("img", {
|
|
259
|
-
src: a.url,
|
|
260
|
-
alt: a.name
|
|
261
|
-
})) : /*#__PURE__*/React.createElement("div", {
|
|
257
|
+
var fileCardInner = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
262
258
|
"data-odn-attachments-file-icon": true,
|
|
263
259
|
style: {
|
|
264
260
|
backgroundColor: meta.bg
|
|
@@ -276,19 +272,30 @@ export function Attachments(_ref) {
|
|
|
276
272
|
}, a.name), /*#__PURE__*/React.createElement("div", {
|
|
277
273
|
"data-odn-attachments-meta": true
|
|
278
274
|
}, formatType(a.type, a.name), a.size ? " \xB7 ".concat(formatSize(a.size)) : '')));
|
|
275
|
+
var imageCardInner = /*#__PURE__*/React.createElement("div", {
|
|
276
|
+
"data-odn-attachments-img-wrapper": true
|
|
277
|
+
}, /*#__PURE__*/React.createElement("img", {
|
|
278
|
+
src: a.url,
|
|
279
|
+
alt: a.name
|
|
280
|
+
}));
|
|
279
281
|
return /*#__PURE__*/React.createElement("div", {
|
|
280
282
|
key: i,
|
|
281
283
|
"data-odn-attachments-item": true
|
|
282
|
-
}, onFileClick ? /*#__PURE__*/React.createElement("button", {
|
|
284
|
+
}, onFileClick ? /*#__PURE__*/React.createElement("button", _extends({
|
|
283
285
|
type: "button",
|
|
284
286
|
onClick: function onClick() {
|
|
285
287
|
return onFileClick(a);
|
|
286
288
|
},
|
|
287
|
-
"data-odn-attachments-card": true
|
|
289
|
+
"data-odn-attachments-card": true
|
|
290
|
+
}, isImage ? {
|
|
291
|
+
'data-odn-attachments-image-card': ''
|
|
292
|
+
} : {}, {
|
|
288
293
|
"data-odn-attachments-clickable": ""
|
|
289
|
-
},
|
|
294
|
+
}), isImage ? imageCardInner : fileCardInner) : /*#__PURE__*/React.createElement("div", _extends({
|
|
290
295
|
"data-odn-attachments-card": true
|
|
291
|
-
},
|
|
296
|
+
}, isImage ? {
|
|
297
|
+
'data-odn-attachments-image-card': ''
|
|
298
|
+
} : {}), isImage ? imageCardInner : fileCardInner), onRemove && /*#__PURE__*/React.createElement("button", {
|
|
292
299
|
onClick: function onClick() {
|
|
293
300
|
return onRemove(i);
|
|
294
301
|
},
|
|
@@ -98,6 +98,29 @@
|
|
|
98
98
|
object-fit: cover;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
/** 图片附件卡:仅内嵌预览(非「文件卡」双列),须写在通用 img-wrapper 规则之后以覆盖 grid 方形缩略策略 */
|
|
102
|
+
[data-odn-attachments-card][data-odn-attachments-image-card] {
|
|
103
|
+
display: block;
|
|
104
|
+
padding: 4px;
|
|
105
|
+
max-width: min(100%, 280px);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
[data-odn-attachments-card][data-odn-attachments-image-card] [data-odn-attachments-img-wrapper] {
|
|
109
|
+
height: auto;
|
|
110
|
+
min-height: 0;
|
|
111
|
+
aspect-ratio: auto;
|
|
112
|
+
max-height: 220px;
|
|
113
|
+
border-radius: 4px;
|
|
114
|
+
align-self: stretch;
|
|
115
|
+
}
|
|
116
|
+
[data-odn-attachments-card][data-odn-attachments-image-card] [data-odn-attachments-img-wrapper] img {
|
|
117
|
+
width: 100%;
|
|
118
|
+
height: auto;
|
|
119
|
+
max-height: 220px;
|
|
120
|
+
object-fit: contain;
|
|
121
|
+
vertical-align: middle;
|
|
122
|
+
}
|
|
123
|
+
|
|
101
124
|
[data-odn-attachments-file-icon] {
|
|
102
125
|
display: flex;
|
|
103
126
|
align-items: center;
|
|
@@ -25,7 +25,7 @@ type CollapsibleContentProps = Omit<HTMLMotionProps<'div'>, 'children' | 'ref' |
|
|
|
25
25
|
children?: React.ReactNode;
|
|
26
26
|
transition?: Transition;
|
|
27
27
|
};
|
|
28
|
-
declare const CollapsibleContent: React.ForwardRefExoticComponent<Omit<HTMLMotionProps<"div">, "
|
|
28
|
+
declare const CollapsibleContent: React.ForwardRefExoticComponent<Omit<HTMLMotionProps<"div">, "children" | "transition" | "ref"> & {
|
|
29
29
|
children?: React.ReactNode;
|
|
30
30
|
transition?: Transition | undefined;
|
|
31
31
|
} & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -86,6 +86,12 @@ export interface ComposerEditorProps {
|
|
|
86
86
|
* 若提供且 `files.length > 0`,编辑器会 `preventDefault` 且不再插入纯文本。
|
|
87
87
|
*/
|
|
88
88
|
onPasteFiles?: (files: File[]) => void;
|
|
89
|
+
/**
|
|
90
|
+
* 禁用:contenteditable 关闭,editor 不接受输入 / 聚焦 / 粘贴。
|
|
91
|
+
* 已有的文本与 chip 仍渲染(仅冻结,不清空),便于"等接通后继续编辑"。
|
|
92
|
+
* @default false
|
|
93
|
+
*/
|
|
94
|
+
disabled?: boolean;
|
|
89
95
|
className?: string;
|
|
90
96
|
style?: React.CSSProperties;
|
|
91
97
|
}
|
package/dist/composer/editor.js
CHANGED
|
@@ -99,6 +99,8 @@ export var ComposerEditor = /*#__PURE__*/forwardRef(function ComposerEditor(_ref
|
|
|
99
99
|
onTriggerKeyDown = _ref.onTriggerKeyDown,
|
|
100
100
|
onHeightChange = _ref.onHeightChange,
|
|
101
101
|
onPasteFiles = _ref.onPasteFiles,
|
|
102
|
+
_ref$disabled = _ref.disabled,
|
|
103
|
+
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
102
104
|
className = _ref.className,
|
|
103
105
|
style = _ref.style;
|
|
104
106
|
var editorRef = useRef(null);
|
|
@@ -538,11 +540,13 @@ export var ComposerEditor = /*#__PURE__*/forwardRef(function ComposerEditor(_ref
|
|
|
538
540
|
}, style)
|
|
539
541
|
}, /*#__PURE__*/React.createElement("div", {
|
|
540
542
|
ref: editorRef,
|
|
541
|
-
contentEditable:
|
|
543
|
+
contentEditable: !disabled,
|
|
542
544
|
suppressContentEditableWarning: true,
|
|
543
545
|
role: "textbox",
|
|
544
546
|
"aria-multiline": "true",
|
|
547
|
+
"aria-disabled": disabled || undefined,
|
|
545
548
|
"data-odn-composer-editor": true,
|
|
549
|
+
"data-odn-composer-editor-disabled": disabled || undefined,
|
|
546
550
|
"data-empty": empty || undefined,
|
|
547
551
|
"data-placeholder": placeholder,
|
|
548
552
|
className: className,
|
package/dist/composer/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { SkillItem, SendMeta } from '../_genui-types';
|
|
2
|
+
import type { Attachment, SkillItem, SendMeta } from '../_genui-types';
|
|
3
3
|
import './style';
|
|
4
4
|
export type ComposerTool = 'attachment' | 'webSearch' | 'skill';
|
|
5
5
|
export type ComposerVariant = 'full' | 'lite';
|
|
@@ -36,6 +36,18 @@ export interface ComposerProps {
|
|
|
36
36
|
onSend: (text: string, meta?: SendMeta) => void;
|
|
37
37
|
onStop?: () => void;
|
|
38
38
|
isGenerating?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* 整体禁用:输入框不可输入、工具按钮置灰、发送按钮显示但不可点击。
|
|
41
|
+
*
|
|
42
|
+
* 状态优先级(高 → 低):`disabled` > `isGenerating` > `canSend`。
|
|
43
|
+
* - `disabled=true` 时,无论是否在生成中,都强制呈现"发送态"按钮(仅置灰),
|
|
44
|
+
* 不会切换到中止按钮——因为禁用本身意味着"现在什么都不能做"。
|
|
45
|
+
*
|
|
46
|
+
* 典型场景:人工客服尚未接入、会话被风控冻结、配额耗尽等"暂时不可发起新交互"的状态。
|
|
47
|
+
* 此时业务方常配合修改 placeholder(如"等待客服接入…")告知用户。
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
disabled?: boolean;
|
|
39
51
|
placeholder?: string;
|
|
40
52
|
/** 根节点外边距:drawer = 左右下各 24px(与原先外层 px-6 pb-6 一致),不再包一层 div */
|
|
41
53
|
spacing?: 'default' | 'drawer';
|
|
@@ -76,6 +88,51 @@ export interface ComposerProps {
|
|
|
76
88
|
* 类型同步调整为 `HTMLDivElement`,旧业务代码若仅读 `e.shiftKey` 等通用属性无影响。
|
|
77
89
|
*/
|
|
78
90
|
onEnter?: (e: React.KeyboardEvent<HTMLDivElement>) => void | false;
|
|
91
|
+
/**
|
|
92
|
+
* 受控附件列表。
|
|
93
|
+
* - 传则受控,由业务方决定数组内容;典型搭配 `onAttachFiles` + `onAttachmentsChange` 使用,
|
|
94
|
+
* 把"原生 File → 云端 Attachment"的转换交给业务方(如先上传到企点 / OSS 拿 url)。
|
|
95
|
+
* - 不传则非受控,组件内部自管,沿用 `URL.createObjectURL(f)` 生成 blob url 的旧行为(向后兼容)。
|
|
96
|
+
*/
|
|
97
|
+
attachments?: Attachment[];
|
|
98
|
+
/**
|
|
99
|
+
* 附件数组变化时触发(新增、删除、外部回写都会调)。
|
|
100
|
+
* 受控模式下与 `attachments` 配合形成 React 标准受控形态。
|
|
101
|
+
*/
|
|
102
|
+
onAttachmentsChange?: (attachments: Attachment[]) => void;
|
|
103
|
+
/**
|
|
104
|
+
* 文件经选择 / 拖入 / 粘贴入口被选中并通过内置校验(数量上限、单文件体积、重名)后触发。
|
|
105
|
+
* - **传入此回调即接管"原生 File → Attachment"全过程**:组件不再做 `URL.createObjectURL`,
|
|
106
|
+
* 也不会自动入栈。业务方负责上传(如调企点接口拿 `qidian_uuid`)后,
|
|
107
|
+
* 通过 `onAttachmentsChange` 把云端结果回写到 `attachments`。
|
|
108
|
+
* - 不传则回落到默认行为:内部生成 blob url 入栈(仅本地预览,无服务端语义)。
|
|
109
|
+
*
|
|
110
|
+
* 强约定:传 `onAttachFiles` 时通常应同时把 `attachments` 受控(否则业务方无路径回写)。
|
|
111
|
+
*/
|
|
112
|
+
onAttachFiles?: (files: File[]) => void;
|
|
113
|
+
/**
|
|
114
|
+
* 单条附件被删除时触发,提供下标与被删条目。
|
|
115
|
+
* - 与 `onAttachmentsChange` 同时调(顺序:先 `onAttachmentRemove` 再 `onAttachmentsChange`)。
|
|
116
|
+
* - 适合在此处调"服务端删文件"等需要拿到具体被删条目的接口,
|
|
117
|
+
* 避免业务方从前后两次 `attachments` 数组里 diff 出被删项。
|
|
118
|
+
*/
|
|
119
|
+
onAttachmentRemove?: (index: number, attachment: Attachment) => void;
|
|
120
|
+
/**
|
|
121
|
+
* 关闭新附件入口:附件工具按钮置灰、拖入不再高亮、粘贴入文件被忽略。
|
|
122
|
+
* 已存在的附件仍可由用户点击 × 删除。
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
125
|
+
attachmentsDisabled?: boolean;
|
|
126
|
+
/**
|
|
127
|
+
* 单次最多附件数量。
|
|
128
|
+
* @default 5
|
|
129
|
+
*/
|
|
130
|
+
maxFileCount?: number;
|
|
131
|
+
/**
|
|
132
|
+
* 单个文件最大体积(字节)。
|
|
133
|
+
* @default 20 * 1024 * 1024(20MB)
|
|
134
|
+
*/
|
|
135
|
+
maxFileSize?: number;
|
|
79
136
|
className?: string;
|
|
80
137
|
style?: React.CSSProperties;
|
|
81
138
|
}
|