one-design-next 0.0.71 → 0.0.73

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.
@@ -182,7 +182,7 @@ html {
182
182
  --odn-shadow-3:
183
183
  0 4px 10px 0 rgba(0, 0, 0, 7%), 0 12px 24px 0 rgba(0, 0, 0, 8%);
184
184
  --odn-shadow-4:
185
- 0 6px 15px 0 rgba(0, 0, 0, 7%), 0 10 36px 0 rgba(0, 0, 0, 16%);
185
+ 0 6px 15px 0 rgba(0, 0, 0, 7%), 0 10px 36px 0 rgba(0, 0, 0, 16%);
186
186
 
187
187
  /* 通用组件 */
188
188
  --odn-color-bg-elevated: #fff;
@@ -159,13 +159,29 @@ var TooltipGroup = function TooltipGroup(props) {
159
159
  }, /*#__PURE__*/React.createElement(Tag, _objectSpread({
160
160
  ref: tagRef
161
161
  }, otherProps), tooltipInfos.map(function (info, index) {
162
- if ( /*#__PURE__*/React.isValidElement(info.children)) {
163
- var _ref2 = info.children.props,
164
- _onMouseEnter = _ref2.onMouseEnter,
165
- _onMouseLeave = _ref2.onMouseLeave,
166
- rest = _objectWithoutProperties(_ref2, _excluded2);
167
- return /*#__PURE__*/React.cloneElement(info.children, _objectSpread(_objectSpread({
168
- key: index
162
+ if (! /*#__PURE__*/React.isValidElement(info.children)) {
163
+ return null;
164
+ }
165
+
166
+ /**
167
+ * Group 需要把 hover 绑到「能接到 DOM 事件」的触发器上。
168
+ * 若 children 是 Popover(含 popup prop),事件挂在 Popover 上无效:
169
+ * PopBase 的 onMouseEnter/Leave 只用于浮层,不会传到 reference。
170
+ * 因此遇到带 popup 的包装层时,递归绑到其 trigger children。
171
+ */
172
+ var bindHover = function bindHover(node, key) {
173
+ var nodeProps = node.props;
174
+ if (nodeProps.popup !== undefined && /*#__PURE__*/React.isValidElement(nodeProps.children) && nodeProps.children.type !== React.Fragment) {
175
+ return /*#__PURE__*/React.cloneElement(node, {
176
+ key: key,
177
+ children: bindHover(nodeProps.children, key)
178
+ });
179
+ }
180
+ var _onMouseEnter = nodeProps.onMouseEnter,
181
+ _onMouseLeave = nodeProps.onMouseLeave,
182
+ rest = _objectWithoutProperties(nodeProps, _excluded2);
183
+ return /*#__PURE__*/React.cloneElement(node, _objectSpread(_objectSpread({
184
+ key: key
169
185
  }, rest), {}, {
170
186
  onMouseEnter: function onMouseEnter(e) {
171
187
  handleMouseEnter(e, index);
@@ -176,8 +192,8 @@ var TooltipGroup = function TooltipGroup(props) {
176
192
  _onMouseLeave === null || _onMouseLeave === void 0 || _onMouseLeave(e);
177
193
  }
178
194
  }));
179
- }
180
- return null;
195
+ };
196
+ return bindHover(info.children, index);
181
197
  })));
182
198
  };
183
199
  Tooltip.Group = TooltipGroup;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
- import { type MessageImageItem } from '../message-image';
3
2
  import type { Attachment, ChatMessage } from '../_genui-types';
3
+ import { type MessageImageItem } from '../message-image';
4
4
  import './style';
5
5
  export interface UserBubbleProps {
6
6
  message: ChatMessage;
@@ -13,8 +13,10 @@ export interface UserBubbleProps {
13
13
  * @param images 当前消息内所有 image attachments(已转成 `MessageImageItem` 形态)
14
14
  */
15
15
  onImageClick?: (index: number, images: MessageImageItem[]) => void;
16
+ /** 搜索跳转:在用户气泡正文中精准高亮关键词 */
17
+ highlightQuery?: string;
16
18
  }
17
- export declare function UserBubble({ message, onFileClick, onImageClick }: UserBubbleProps): import("react").JSX.Element;
19
+ export declare function UserBubble({ message, onFileClick, onImageClick, highlightQuery, }: UserBubbleProps): import("react").JSX.Element;
18
20
  export declare namespace UserBubble {
19
21
  var displayName: string;
20
22
  }
@@ -1,15 +1,17 @@
1
1
  import { Attachments } from "../attachments";
2
2
  import MessageImage from "../message-image";
3
+ import { highlightQueryText } from "../stream-text/highlight-query-text";
3
4
  import { renderSegmentsContent, segmentsHaveVisibleContent } from "./render-segments";
4
5
  import "./style";
5
6
  export function UserBubble(_ref) {
6
- var _message$content, _message$attachments;
7
+ var _message$content, _message$content2, _message$attachments;
7
8
  var message = _ref.message,
8
9
  onFileClick = _ref.onFileClick,
9
- onImageClick = _ref.onImageClick;
10
+ onImageClick = _ref.onImageClick,
11
+ highlightQuery = _ref.highlightQuery;
10
12
  var segments = message.segments;
11
13
  var hasText = segments !== null && segments !== void 0 && segments.length ? segmentsHaveVisibleContent(segments) : !!((_message$content = message.content) !== null && _message$content !== void 0 && _message$content.trim());
12
- var textBody = segments !== null && segments !== void 0 && segments.length ? renderSegmentsContent(segments) : message.content;
14
+ var textBody = segments !== null && segments !== void 0 && segments.length ? renderSegmentsContent(segments, highlightQuery) : highlightQueryText((_message$content2 = message.content) !== null && _message$content2 !== void 0 ? _message$content2 : '', highlightQuery);
13
15
  var all = (_message$attachments = message.attachments) !== null && _message$attachments !== void 0 ? _message$attachments : [];
14
16
 
15
17
  /* 图片附件分流到 MessageImage,保持其数据驱动尺寸的渲染语义;
@@ -6,4 +6,4 @@ export declare function segmentsHaveVisibleContent(segments: ComposerSegment[]):
6
6
  * 将 `ComposerSegment[]` 渲染为 UserBubble 正文(只读 Invocation / Mention + 文本)。
7
7
  * 顺序与 Composer 发送时一致。
8
8
  */
9
- export declare function renderSegmentsContent(segments: ComposerSegment[]): React.ReactNode;
9
+ export declare function renderSegmentsContent(segments: ComposerSegment[], highlightQuery?: string): React.ReactNode;
@@ -1,5 +1,6 @@
1
1
  import { Invocation } from "../invocation";
2
2
  import { Mention } from "../mention";
3
+ import { highlightQueryText } from "../stream-text/highlight-query-text";
3
4
 
4
5
  /** segments 是否含可见正文(文本非空或含内联引用)。 */
5
6
  export function segmentsHaveVisibleContent(segments) {
@@ -12,14 +13,16 @@ export function segmentsHaveVisibleContent(segments) {
12
13
  * 将 `ComposerSegment[]` 渲染为 UserBubble 正文(只读 Invocation / Mention + 文本)。
13
14
  * 顺序与 Composer 发送时一致。
14
15
  */
15
- export function renderSegmentsContent(segments) {
16
+ export function renderSegmentsContent(segments, highlightQuery) {
16
17
  var nodes = [];
17
18
  segments.forEach(function (seg, index) {
18
19
  var key = "".concat(seg.type, "-").concat(index);
19
20
  if (seg.type === 'text') {
20
- if (seg.data.text.length > 0) nodes.push( /*#__PURE__*/React.createElement("span", {
21
- key: key
22
- }, seg.data.text));
21
+ if (seg.data.text.length > 0) {
22
+ nodes.push( /*#__PURE__*/React.createElement("span", {
23
+ key: key
24
+ }, highlightQueryText(seg.data.text, highlightQuery)));
25
+ }
23
26
  return;
24
27
  }
25
28
  if (seg.type === 'invocation') {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "one-design-next",
3
- "version": "0.0.71",
3
+ "version": "0.0.73",
4
4
  "description": "One Design Next from TAD@tencent.com",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -41,9 +41,10 @@
41
41
  "test": "vitest",
42
42
  "test:a11y": "echo 'axe-core smoke run(待 P5 接入)'",
43
43
  "test:changed": "vitest run --changed",
44
- "test:ci": "vitest run",
44
+ "test:ci": "vitest run --exclude '**/visual.test.tsx'",
45
+ "test:visual": "vitest run '**/visual.test.tsx'",
45
46
  "test:visual:docker": "bash scripts/visual-baseline-docker.sh",
46
- "test:visual:update": "UPDATE_VISUAL=1 vitest run",
47
+ "test:visual:update": "UPDATE_VISUAL=1 vitest run '**/visual.test.tsx'",
47
48
  "test:visual:update:docker": "bash scripts/visual-baseline-docker.sh update",
48
49
  "typecheck": "tsc -p tsconfig.ci.json"
49
50
  },