one-design-next 0.0.12 → 0.0.13
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 +36 -10
- package/dist/attachments/index.js +66 -16
- package/dist/attachments/style/index.css +86 -37
- package/dist/composer/chip.d.ts +4 -4
- package/dist/composer/clipboard.d.ts +12 -0
- package/dist/composer/clipboard.js +84 -0
- package/dist/composer/editor.d.ts +3 -1
- package/dist/composer/editor.js +65 -13
- package/dist/composer/hooks/useChipManager.d.ts +6 -1
- package/dist/composer/hooks/useChipManager.js +76 -27
- package/dist/composer/hooks/useChipSelectionMarker.d.ts +7 -0
- package/dist/composer/hooks/useChipSelectionMarker.js +66 -0
- package/dist/composer/index.js +73 -32
- package/dist/composer/inline-ref.d.ts +9 -0
- package/dist/composer/inline-ref.js +21 -0
- package/dist/composer/send-meta.d.ts +6 -0
- package/dist/composer/send-meta.js +67 -0
- package/dist/composer/style/index.css +39 -53
- package/dist/composer/utils.d.ts +9 -0
- package/dist/composer/utils.js +43 -2
- package/dist/fab/index.js +3 -16
- package/dist/fab/style/index.css +1 -3
- package/dist/image/index.d.ts +43 -0
- package/dist/image/index.js +51 -0
- package/dist/image/style/index.css +59 -0
- package/dist/image/style/index.d.ts +2 -0
- package/dist/image/style/index.js +2 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +4 -0
- package/dist/invocation/index.d.ts +17 -0
- package/dist/invocation/index.js +84 -0
- package/dist/invocation/style/index.css +58 -0
- package/dist/invocation/style/index.d.ts +2 -0
- package/dist/invocation/style/index.js +2 -0
- package/dist/mention/index.d.ts +17 -0
- package/dist/mention/index.js +90 -0
- package/dist/mention/style/index.css +58 -0
- package/dist/mention/style/index.d.ts +2 -0
- package/dist/mention/style/index.js +2 -0
- package/dist/message-image/index.d.ts +42 -0
- package/dist/message-image/index.js +46 -0
- package/dist/message-image/style/index.css +60 -0
- package/dist/message-image/style/index.d.ts +2 -0
- package/dist/message-image/style/index.js +2 -0
- package/dist/user-bubble/index.d.ts +11 -1
- package/dist/user-bubble/index.js +30 -5
- package/dist/user-bubble/style/index.css +6 -0
- package/package.json +2 -2
package/dist/composer/utils.js
CHANGED
|
@@ -29,6 +29,12 @@ var escapeRe = function escapeRe(s) {
|
|
|
29
29
|
};
|
|
30
30
|
var MARKER_RE = new RegExp("".concat(escapeRe(MARKER_OPEN), "([^").concat(SEP, "]+)").concat(escapeRe(MARKER_CLOSE)), 'g');
|
|
31
31
|
|
|
32
|
+
/** 从用户可见文本中剔除 ZWSP / SEP(粘贴残留、锚点字符)。 */
|
|
33
|
+
var INVISIBLE_RE = new RegExp("[".concat(ZWSP).concat(SEP, "]"), 'g');
|
|
34
|
+
export function stripInvisibleChars(s) {
|
|
35
|
+
return s.replace(INVISIBLE_RE, '');
|
|
36
|
+
}
|
|
37
|
+
|
|
32
38
|
/** 把 mention id 包成 marker token,插入 value 的 string 里。 */
|
|
33
39
|
export function createMarker(id) {
|
|
34
40
|
return "".concat(MARKER_OPEN).concat(id).concat(MARKER_CLOSE);
|
|
@@ -71,6 +77,41 @@ export function stripMarkers(raw) {
|
|
|
71
77
|
return raw.replace(MARKER_RE, '');
|
|
72
78
|
}
|
|
73
79
|
|
|
80
|
+
/** 按 marker 切分 raw string,用于粘贴还原 DOM。 */
|
|
81
|
+
export function forEachMarkerSegment(raw, visit) {
|
|
82
|
+
var lastIdx = 0;
|
|
83
|
+
var re = new RegExp(MARKER_RE.source, 'g');
|
|
84
|
+
var _iterator2 = _createForOfIteratorHelper(raw.matchAll(re)),
|
|
85
|
+
_step2;
|
|
86
|
+
try {
|
|
87
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
88
|
+
var m = _step2.value;
|
|
89
|
+
var index = m.index;
|
|
90
|
+
if (index > lastIdx) {
|
|
91
|
+
visit({
|
|
92
|
+
type: 'text',
|
|
93
|
+
text: raw.slice(lastIdx, index)
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
visit({
|
|
97
|
+
type: 'marker',
|
|
98
|
+
id: m[1]
|
|
99
|
+
});
|
|
100
|
+
lastIdx = index + m[0].length;
|
|
101
|
+
}
|
|
102
|
+
} catch (err) {
|
|
103
|
+
_iterator2.e(err);
|
|
104
|
+
} finally {
|
|
105
|
+
_iterator2.f();
|
|
106
|
+
}
|
|
107
|
+
if (lastIdx < raw.length) {
|
|
108
|
+
visit({
|
|
109
|
+
type: 'text',
|
|
110
|
+
text: raw.slice(lastIdx)
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
74
115
|
/* ────────────────────────────────────────────────────────────────────
|
|
75
116
|
* getPlainText · 从 DOM 提取 marker 化的字符串
|
|
76
117
|
* ──────────────────────────────────────────────────────────────────── */
|
|
@@ -101,7 +142,7 @@ export function getPlainText(editor) {
|
|
|
101
142
|
}
|
|
102
143
|
if (node.nodeType === Node.TEXT_NODE) {
|
|
103
144
|
var _node$textContent;
|
|
104
|
-
out += ((_node$textContent = node.textContent) !== null && _node$textContent !== void 0 ? _node$textContent : '')
|
|
145
|
+
out += stripInvisibleChars((_node$textContent = node.textContent) !== null && _node$textContent !== void 0 ? _node$textContent : '');
|
|
105
146
|
return;
|
|
106
147
|
}
|
|
107
148
|
if (node.nodeType === Node.ELEMENT_NODE) {
|
|
@@ -134,7 +175,7 @@ export function isEditorEmpty(editor) {
|
|
|
134
175
|
var _editor$textContent;
|
|
135
176
|
var chipIdAttr = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'mentionId';
|
|
136
177
|
if (editor.querySelector("[data-".concat(kebab(chipIdAttr), "]"))) return false;
|
|
137
|
-
var text = ((_editor$textContent = editor.textContent) !== null && _editor$textContent !== void 0 ? _editor$textContent : '')
|
|
178
|
+
var text = stripInvisibleChars((_editor$textContent = editor.textContent) !== null && _editor$textContent !== void 0 ? _editor$textContent : '');
|
|
138
179
|
// 仅过滤换行符(contenteditable 默认 <br> 单独存在时 textContent 是 '\n',视觉仍为空)
|
|
139
180
|
return text.replace(/\n/g, '') === '';
|
|
140
181
|
}
|
package/dist/fab/index.js
CHANGED
|
@@ -7,7 +7,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
7
7
|
import React, { useState, useEffect, useRef } from 'react';
|
|
8
8
|
import { MeshGradient } from '@paper-design/shaders-react';
|
|
9
9
|
import "./style";
|
|
10
|
-
var BRAND_ICON_PATHS = ['M37.4911 121.803C38.7808 118.657 42.6771 117.561 45.6776 119.159C46.4424 119.566 47.2191 119.953 48.0073 120.32C50.7196 121.583 52.1802 124.712 51.0454 127.48C49.9576 130.134 46.9172 131.395 44.2708 130.289L40.3265 128.642C37.6621 127.529 36.3957 124.474 37.4911 121.803Z', 'M99.5065 121.794C100.608 124.469 99.3411 127.532 96.6715 128.647L92.7363 130.29C90.0906 131.395 87.0509 130.136 85.9612 127.484C84.8231 124.714 86.2839 121.582 88.9978 120.316C89.7828 119.95 90.5564 119.563 91.3181 119.157C94.3174 117.558 98.2123 118.651 99.5065 121.794Z', 'M19.2739 104.82C22.2702 101.797 27.3851 102.607 30.001 105.964C32.1488 108.721 32.21 112.711 29.7514 115.194C27.2761 117.695 23.2367 117.697 20.7586 115.199L19.276 113.704C16.8365 111.245 16.8356 107.28 19.2739 104.82Z', 'M117.721 104.818C120.162 107.279 120.163 111.248 117.723 113.71L116.25 115.196C113.772 117.696 109.731 117.697 107.253 115.198C104.787 112.713 104.843 108.721 106.994 105.959C109.61 102.6 114.722 101.795 117.721 104.818Z', 'M11.3154 81.5483C15.3671 79.8562 19.9061 82.799 20.9247 87.07C21.7135 90.3776 20.191 93.8468 17.0542 95.1594L14.8843 96.0674C11.1043 97.6492 6.75913 95.8518 5.20113 92.0619C3.65613 88.3037 5.43683 84.0033 9.18643 82.4374L11.3154 81.5483Z', 'M127.821 82.4366C131.568 84.0034 133.347 88.3007 131.805 92.0578C130.249 95.8498 125.903 97.6501 122.122 96.0696L119.941 95.1583C116.802 93.8465 115.278 90.3755 116.07 87.0669C117.092 82.7945 121.637 79.8506 125.69 81.5455L127.821 82.4366Z', 'M129.602 58.2774C133.688 58.2774 137 61.5896 137 65.6753C137 69.761 133.688 73.0731 129.602 73.0731H123.403C120.02 73.0731 117.267 70.3183 116.689 66.9847C115.934 62.6302 119.041 58.2774 123.46 58.2774H129.602Z', 'M13.5398 58.2774C17.9593 58.2774 21.0663 62.6302 20.3112 66.9847C19.7332 70.3183 16.98 73.0731 13.5966 73.0731H7.39786C3.31213 73.0731 0 69.761 0 65.6753C0 61.5896 3.31214 58.2774 7.39786 58.2774H13.5398Z', 'M131.807 39.29C133.353 43.0529 131.569 47.3578 127.815 48.9247L118.711 52.7244C115.543 54.0469 111.92 52.5582 110.127 49.6298C107.845 45.9014 109.032 40.7313 113.066 39.0492L122.121 35.2743C125.904 33.6969 130.249 35.4982 131.807 39.29Z', 'M23.9305 39.0492C27.9628 40.7315 29.147 45.8984 26.8641 49.6237C25.0708 52.5502 21.4485 54.0379 18.281 52.716L9.19401 48.9239C5.44023 47.3575 3.65664 43.0531 5.20226 39.2907C6.76 35.4988 11.1054 33.6981 14.8887 35.2766L23.9305 39.0492Z', 'M39.5076 25.9808C42.4931 28.9902 41.719 34.045 38.3912 36.6709C35.6086 38.8665 31.5638 38.915 29.0675 36.3987L20.0223 27.2814C17.17 24.4063 17.17 19.769 20.0223 16.8939C22.9068 13.9863 27.6081 13.9863 30.4926 16.8939L39.5076 25.9808Z', 'M116.976 16.892C119.829 19.7677 119.828 24.4064 116.973 27.2807L107.92 36.3963C105.425 38.9092 101.384 38.8605 98.6025 36.6683C95.2734 34.0444 94.4989 28.99 97.4851 25.9814L106.508 16.8907C109.392 13.9847 114.092 13.9853 116.976 16.892Z', 'M58.9142 18.1863C60.4617 21.9498 58.0298 26.1793 54.1812 27.5009C50.6835 28.7019 46.7164 27.2251 45.3119 23.804L39.706 10.1492C38.1699 6.40742 39.9438 2.12743 43.6765 0.569414C47.4388 -1.00092 51.7606 0.788889 53.311 4.55942L58.9142 18.1863Z', 'M92.9927 0.57847C96.7231 2.13658 98.494 6.41548 96.9559 10.1541L91.3334 23.8209C89.9291 27.2342 85.9703 28.7077 82.4782 27.5127C78.6324 26.1967 76.2033 21.9728 77.7497 18.2137L83.3655 4.56307C84.9153 0.795926 89.2339 -0.991508 92.9927 0.57847Z', 'M62 128.222C62 124.632 64.9101 121.722 68.5 121.722C72.0899 121.722 75 124.632 75 128.222C75 131.812 72.0899 134.722 68.5 134.722C64.9101 134.722 62 131.812 62 128.222Z'];
|
|
11
10
|
var COLOR_TRANSITION_MS = 600;
|
|
12
11
|
var hexToRgb = function hexToRgb(hex) {
|
|
13
12
|
var m = hex.replace('#', '');
|
|
@@ -52,9 +51,9 @@ var Fab = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
52
51
|
className = _ref3.className,
|
|
53
52
|
style = _ref3.style,
|
|
54
53
|
_ref3$colors = _ref3.colors,
|
|
55
|
-
colors = _ref3$colors === void 0 ? ['#
|
|
54
|
+
colors = _ref3$colors === void 0 ? ['#3284FF', '#1894FF', '#2A6BEF'] : _ref3$colors,
|
|
56
55
|
_ref3$hoverColors = _ref3.hoverColors,
|
|
57
|
-
hoverColors = _ref3$hoverColors === void 0 ? ['#
|
|
56
|
+
hoverColors = _ref3$hoverColors === void 0 ? ['#2089FE', '#3276FF', '#47B4FF'] : _ref3$hoverColors,
|
|
58
57
|
_ref3$bgOpacity = _ref3.bgOpacity,
|
|
59
58
|
bgOpacity = _ref3$bgOpacity === void 0 ? 1 : _ref3$bgOpacity,
|
|
60
59
|
_ref3$hoverBgOpacity = _ref3.hoverBgOpacity,
|
|
@@ -140,19 +139,7 @@ var Fab = /*#__PURE__*/React.forwardRef(function (_ref3, ref) {
|
|
|
140
139
|
}), /*#__PURE__*/React.createElement("div", {
|
|
141
140
|
className: "odn-fab-glow",
|
|
142
141
|
"aria-hidden": "true"
|
|
143
|
-
}), icon
|
|
144
|
-
width: "22",
|
|
145
|
-
height: "22",
|
|
146
|
-
viewBox: "0 0 137 135",
|
|
147
|
-
fill: "none",
|
|
148
|
-
className: "odn-fab-icon"
|
|
149
|
-
}, BRAND_ICON_PATHS.map(function (d, i) {
|
|
150
|
-
return /*#__PURE__*/React.createElement("path", {
|
|
151
|
-
key: i,
|
|
152
|
-
d: d,
|
|
153
|
-
fill: "currentColor"
|
|
154
|
-
});
|
|
155
|
-
})), /*#__PURE__*/React.createElement("span", {
|
|
142
|
+
}), icon, /*#__PURE__*/React.createElement("span", {
|
|
156
143
|
className: "odn-fab-label"
|
|
157
144
|
}, label));
|
|
158
145
|
});
|
package/dist/fab/style/index.css
CHANGED
|
@@ -5,11 +5,9 @@
|
|
|
5
5
|
align-items: center;
|
|
6
6
|
justify-content: center;
|
|
7
7
|
gap: 8px;
|
|
8
|
-
width: 172px;
|
|
9
|
-
height: 64px;
|
|
10
8
|
padding: 16px;
|
|
11
9
|
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
12
|
-
border-radius:
|
|
10
|
+
border-radius: 16px;
|
|
13
11
|
cursor: pointer;
|
|
14
12
|
user-select: none;
|
|
15
13
|
background: none;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import './style';
|
|
3
|
+
export interface ImageProps {
|
|
4
|
+
/** 图片地址(必填) */
|
|
5
|
+
url: string;
|
|
6
|
+
/** 无障碍说明文本 */
|
|
7
|
+
alt?: string;
|
|
8
|
+
/**
|
|
9
|
+
* 整图点击回调。传此 prop 即把图片包一层 button,业务方按需对接
|
|
10
|
+
* `PreviewPanel` 等 lightbox 组件。
|
|
11
|
+
*/
|
|
12
|
+
onPreview?: () => void;
|
|
13
|
+
/**
|
|
14
|
+
* 删除按钮回调。传此 prop 即在 hover 时整图浮出 30% 黑色遮罩 + 中央
|
|
15
|
+
* trash icon,用于 Composer 待发送态等需要删除的场景。
|
|
16
|
+
*/
|
|
17
|
+
onRemove?: () => void;
|
|
18
|
+
/** 透传到容器(非 img 本体)的 className,用于上层套尺寸约束。 */
|
|
19
|
+
className?: string;
|
|
20
|
+
/** 透传到容器(非 img 本体)的 style,用于上层套尺寸约束。 */
|
|
21
|
+
style?: React.CSSProperties;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* 图片渲染 leaf 组件。
|
|
25
|
+
*
|
|
26
|
+
* 职责:
|
|
27
|
+
* - 画一张图(lazy load)
|
|
28
|
+
* - 整图作为 onPreview 触发区
|
|
29
|
+
* - 删除按钮的 hover 遮罩
|
|
30
|
+
*
|
|
31
|
+
* 不职责:
|
|
32
|
+
* - 不带尺寸 opinion(max-width / max-height / object-fit 全由上层套)
|
|
33
|
+
* - 不带消息态 / 输入态等业务语义
|
|
34
|
+
*
|
|
35
|
+
* 业务态包装在更上层的组件里实现:
|
|
36
|
+
* - 消息态:`<MessageImage>` 套一层 max 280×360 contain(单图)或 88×88 cover(多图)容器
|
|
37
|
+
* - Composer 待发送态:composer 内部直接套一层 72×72 cover 容器
|
|
38
|
+
*/
|
|
39
|
+
export declare function Image({ url, alt, onPreview, onRemove, className, style }: ImageProps): import("react").JSX.Element;
|
|
40
|
+
export declare namespace Image {
|
|
41
|
+
var displayName: string;
|
|
42
|
+
}
|
|
43
|
+
export default Image;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import Icon from "../icon";
|
|
2
|
+
import "./style";
|
|
3
|
+
/**
|
|
4
|
+
* 图片渲染 leaf 组件。
|
|
5
|
+
*
|
|
6
|
+
* 职责:
|
|
7
|
+
* - 画一张图(lazy load)
|
|
8
|
+
* - 整图作为 onPreview 触发区
|
|
9
|
+
* - 删除按钮的 hover 遮罩
|
|
10
|
+
*
|
|
11
|
+
* 不职责:
|
|
12
|
+
* - 不带尺寸 opinion(max-width / max-height / object-fit 全由上层套)
|
|
13
|
+
* - 不带消息态 / 输入态等业务语义
|
|
14
|
+
*
|
|
15
|
+
* 业务态包装在更上层的组件里实现:
|
|
16
|
+
* - 消息态:`<MessageImage>` 套一层 max 280×360 contain(单图)或 88×88 cover(多图)容器
|
|
17
|
+
* - Composer 待发送态:composer 内部直接套一层 72×72 cover 容器
|
|
18
|
+
*/
|
|
19
|
+
export function Image(_ref) {
|
|
20
|
+
var url = _ref.url,
|
|
21
|
+
alt = _ref.alt,
|
|
22
|
+
onPreview = _ref.onPreview,
|
|
23
|
+
onRemove = _ref.onRemove,
|
|
24
|
+
className = _ref.className,
|
|
25
|
+
style = _ref.style;
|
|
26
|
+
var imgEl = /*#__PURE__*/React.createElement("img", {
|
|
27
|
+
src: url,
|
|
28
|
+
alt: alt !== null && alt !== void 0 ? alt : '',
|
|
29
|
+
loading: "lazy"
|
|
30
|
+
});
|
|
31
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
"data-odn-image": true,
|
|
33
|
+
className: className,
|
|
34
|
+
style: style
|
|
35
|
+
}, onPreview ? /*#__PURE__*/React.createElement("button", {
|
|
36
|
+
type: "button",
|
|
37
|
+
onClick: onPreview,
|
|
38
|
+
"data-odn-image-trigger": true,
|
|
39
|
+
"aria-label": alt || '查看大图'
|
|
40
|
+
}, imgEl) : imgEl, onRemove && /*#__PURE__*/React.createElement("button", {
|
|
41
|
+
type: "button",
|
|
42
|
+
onClick: onRemove,
|
|
43
|
+
"data-odn-image-remove": true,
|
|
44
|
+
"aria-label": "\u5220\u9664\u56FE\u7247"
|
|
45
|
+
}, /*#__PURE__*/React.createElement(Icon, {
|
|
46
|
+
name: "trash-2",
|
|
47
|
+
size: 20
|
|
48
|
+
})));
|
|
49
|
+
}
|
|
50
|
+
Image.displayName = 'Image';
|
|
51
|
+
export default Image;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
[data-odn-image] {
|
|
3
|
+
position: relative;
|
|
4
|
+
display: inline-block;
|
|
5
|
+
}
|
|
6
|
+
[data-odn-image] img {
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** 整图作为 onPreview 触发区时的 button 包装;样式上完全融入容器(无边框、无 padding)。 */
|
|
11
|
+
[data-odn-image-trigger] {
|
|
12
|
+
display: block;
|
|
13
|
+
width: 100%;
|
|
14
|
+
height: 100%;
|
|
15
|
+
padding: 0;
|
|
16
|
+
border: none;
|
|
17
|
+
background: none;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
appearance: none;
|
|
20
|
+
font: inherit;
|
|
21
|
+
}
|
|
22
|
+
[data-odn-image-trigger]:focus-visible {
|
|
23
|
+
outline: 2px solid color-mix(in srgb, var(--odn-color-primary) 55%, transparent);
|
|
24
|
+
outline-offset: 2px;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* 删除按钮:hover 时整图浮出 30% 黑色遮罩 + 中央白色 trash icon。
|
|
28
|
+
* - 整张图作为点击热区,比右上角小角标好命中
|
|
29
|
+
* - 遮罩贴边(inset: 0 + border-radius: inherit),与上层容器圆角自然贴合
|
|
30
|
+
* - 与 onPreview 的 trigger button 是兄弟节点,z-index 保证其在上层
|
|
31
|
+
*
|
|
32
|
+
* 规则按 specificity 升序排列:base → :focus-visible → :hover 复合选择器,
|
|
33
|
+
* 避免 stylelint `no-descending-specificity` 报错。 */
|
|
34
|
+
[data-odn-image-remove] {
|
|
35
|
+
position: absolute;
|
|
36
|
+
inset: 0;
|
|
37
|
+
display: flex;
|
|
38
|
+
align-items: center;
|
|
39
|
+
justify-content: center;
|
|
40
|
+
background: rgba(0, 0, 0, 0.3);
|
|
41
|
+
border: none;
|
|
42
|
+
border-radius: inherit;
|
|
43
|
+
color: #fff;
|
|
44
|
+
cursor: pointer;
|
|
45
|
+
opacity: 0;
|
|
46
|
+
transition: opacity 0.15s;
|
|
47
|
+
padding: 0;
|
|
48
|
+
z-index: 2;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[data-odn-image-remove]:focus-visible {
|
|
52
|
+
opacity: 1;
|
|
53
|
+
outline: 2px solid color-mix(in srgb, var(--odn-color-primary) 55%, transparent);
|
|
54
|
+
outline-offset: -2px;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[data-odn-image]:hover [data-odn-image-remove] {
|
|
58
|
+
opacity: 1;
|
|
59
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export { default as Empty, type EmptyProps, type EmptyType, type EmptySize } fro
|
|
|
29
29
|
export { default as Form, type FormProps, type FormItemProps } from './form';
|
|
30
30
|
export { default as HoverFill, type HoverFillProps, type HoverFillState } from './hover-fill';
|
|
31
31
|
export { default as Icon, type IconProps } from './icon';
|
|
32
|
+
export { default as Image, type ImageProps } from './image';
|
|
32
33
|
export { default as Input, type InputProps, type InputRef } from './input';
|
|
33
34
|
export { default as InputNumber } from './input-number';
|
|
34
35
|
export { default as InputOtp, type InputOtpProps, type InputOtpRef } from './input-otp';
|
|
@@ -58,14 +59,17 @@ export { default as AgentThink, type AgentThinkProps } from './agent-think';
|
|
|
58
59
|
export { default as Attachments, type AttachmentsProps } from './attachments';
|
|
59
60
|
export { default as CodeBlock, type CodeBlockProps } from './code-block';
|
|
60
61
|
export { default as Composer, type ComposerProps, type ComposerRef } from './composer';
|
|
62
|
+
export { default as Invocation, type InvocationProps } from './invocation';
|
|
63
|
+
export { default as Mention, type MentionProps } from './mention';
|
|
61
64
|
export { default as ChatItem, type ChatItemProps } from './chat-item';
|
|
62
65
|
export { default as SkillSlot, type SkillSlotProps } from './skill-slot';
|
|
63
66
|
export { default as ErrorBlock, type ErrorBlockProps } from './error-block';
|
|
64
67
|
export { default as Fab, type FabProps } from './fab';
|
|
68
|
+
export { default as MessageImage, type MessageImageProps, type MessageImageItem } from './message-image';
|
|
65
69
|
export { default as PreviewPanel, type PreviewPanelProps } from './preview-panel';
|
|
66
70
|
export { default as Sources, type SourcesProps } from './sources';
|
|
67
71
|
export { default as StreamText, type StreamTextProps, type TypographyOverrides } from './stream-text';
|
|
68
72
|
export { default as Suggestions, type SuggestionsProps } from './suggestions';
|
|
69
73
|
export { default as UserBubble, type UserBubbleProps } from './user-bubble';
|
|
70
74
|
export { default as Welcome, type WelcomeProps } from './welcome';
|
|
71
|
-
export type { ToolCall, ToolStatus, Source, Attachment, PreviewTarget, PreviewTab, SendMeta, ComposerChipMeta, SkillItem, AgentEvent, Conversation, MessageSnapshot, ChatMessage } from './_genui-types';
|
|
75
|
+
export type { ToolCall, ToolStatus, Source, Attachment, PreviewTarget, PreviewTab, SendMeta, ComposerChipMeta, InvocationData, MentionData, SkillItem, AgentEvent, Conversation, MessageSnapshot, ChatMessage } from './_genui-types';
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export { default as Empty } from "./empty";
|
|
|
33
33
|
export { default as Form } from "./form";
|
|
34
34
|
export { default as HoverFill } from "./hover-fill";
|
|
35
35
|
export { default as Icon } from "./icon";
|
|
36
|
+
export { default as Image } from "./image";
|
|
36
37
|
export { default as Input } from "./input";
|
|
37
38
|
export { default as InputNumber } from "./input-number";
|
|
38
39
|
export { default as InputOtp } from "./input-otp";
|
|
@@ -64,10 +65,13 @@ export { default as AgentThink } from "./agent-think";
|
|
|
64
65
|
export { default as Attachments } from "./attachments";
|
|
65
66
|
export { default as CodeBlock } from "./code-block";
|
|
66
67
|
export { default as Composer } from "./composer";
|
|
68
|
+
export { default as Invocation } from "./invocation";
|
|
69
|
+
export { default as Mention } from "./mention";
|
|
67
70
|
export { default as ChatItem } from "./chat-item";
|
|
68
71
|
export { default as SkillSlot } from "./skill-slot";
|
|
69
72
|
export { default as ErrorBlock } from "./error-block";
|
|
70
73
|
export { default as Fab } from "./fab";
|
|
74
|
+
export { default as MessageImage } from "./message-image";
|
|
71
75
|
export { default as PreviewPanel } from "./preview-panel";
|
|
72
76
|
export { default as Sources } from "./sources";
|
|
73
77
|
export { default as StreamText } from "./stream-text";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { InvocationData } from '../_genui-types';
|
|
3
|
+
import './style';
|
|
4
|
+
export interface InvocationProps {
|
|
5
|
+
data: InvocationData;
|
|
6
|
+
/**
|
|
7
|
+
* true:Composer 编辑态(可点、无 hover 摘要弹层)。
|
|
8
|
+
* false:UserBubble 等只读态(可 hover 看摘要)。
|
|
9
|
+
*/
|
|
10
|
+
interactive?: boolean;
|
|
11
|
+
/** form popover 打开时的高亮态(L4 params 启用后使用) */
|
|
12
|
+
active?: boolean;
|
|
13
|
+
/** 交互态单击回调 */
|
|
14
|
+
onClick?: (anchor: HTMLElement) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function Invocation({ data, interactive, active, onClick, }: InvocationProps): import("react").JSX.Element;
|
|
17
|
+
export default Invocation;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import Popover from "../popover";
|
|
8
|
+
import "./style";
|
|
9
|
+
function formatParamsSummary(params) {
|
|
10
|
+
if (!params) return null;
|
|
11
|
+
var entries = Object.entries(params).filter(function (_ref) {
|
|
12
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
13
|
+
v = _ref2[1];
|
|
14
|
+
return v != null && v !== '';
|
|
15
|
+
});
|
|
16
|
+
if (entries.length === 0) return null;
|
|
17
|
+
return entries.map(function (_ref3) {
|
|
18
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
19
|
+
k = _ref4[0],
|
|
20
|
+
v = _ref4[1];
|
|
21
|
+
return "".concat(k, ": ").concat(String(v));
|
|
22
|
+
}).join(' · ');
|
|
23
|
+
}
|
|
24
|
+
export function Invocation(_ref5) {
|
|
25
|
+
var data = _ref5.data,
|
|
26
|
+
_ref5$interactive = _ref5.interactive,
|
|
27
|
+
interactive = _ref5$interactive === void 0 ? false : _ref5$interactive,
|
|
28
|
+
_ref5$active = _ref5.active,
|
|
29
|
+
active = _ref5$active === void 0 ? false : _ref5$active,
|
|
30
|
+
onClick = _ref5.onClick;
|
|
31
|
+
var clickable = interactive && !!onClick;
|
|
32
|
+
var state = active ? 'active' : 'complete';
|
|
33
|
+
var handleClick = clickable ? function (e) {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
onClick(e.currentTarget);
|
|
37
|
+
} : undefined;
|
|
38
|
+
var handleMouseDown = clickable ? function (e) {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
e.stopPropagation();
|
|
41
|
+
} : undefined;
|
|
42
|
+
var core = /*#__PURE__*/React.createElement("span", {
|
|
43
|
+
"data-odn-invocation": true,
|
|
44
|
+
"data-state": state,
|
|
45
|
+
"data-clickable": clickable || undefined,
|
|
46
|
+
onClick: handleClick,
|
|
47
|
+
onMouseDown: handleMouseDown
|
|
48
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
49
|
+
"data-odn-invocation-slash": true,
|
|
50
|
+
"aria-hidden": true
|
|
51
|
+
}, "/"), /*#__PURE__*/React.createElement("span", {
|
|
52
|
+
"data-odn-invocation-label": true
|
|
53
|
+
}, data.label));
|
|
54
|
+
if (interactive) return core;
|
|
55
|
+
var summary = formatParamsSummary(data.params);
|
|
56
|
+
if (!summary) return core;
|
|
57
|
+
return /*#__PURE__*/React.createElement(Popover, {
|
|
58
|
+
trigger: "hover",
|
|
59
|
+
placement: "top",
|
|
60
|
+
arrowed: false,
|
|
61
|
+
offset: 6,
|
|
62
|
+
mouseEnterDelay: 0.15,
|
|
63
|
+
mouseLeaveDelay: 0.1,
|
|
64
|
+
popup: /*#__PURE__*/React.createElement(InvocationHoverPopup, {
|
|
65
|
+
label: data.label,
|
|
66
|
+
summary: summary
|
|
67
|
+
})
|
|
68
|
+
}, core);
|
|
69
|
+
}
|
|
70
|
+
function InvocationHoverPopup(_ref6) {
|
|
71
|
+
var label = _ref6.label,
|
|
72
|
+
summary = _ref6.summary;
|
|
73
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
"data-odn-invocation-popover-inner": true
|
|
75
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
76
|
+
"data-odn-invocation-popover-title": true
|
|
77
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
78
|
+
"data-odn-invocation-popover-slash": true,
|
|
79
|
+
"aria-hidden": true
|
|
80
|
+
}, "/"), label), /*#__PURE__*/React.createElement("div", {
|
|
81
|
+
"data-odn-invocation-popover-summary": true
|
|
82
|
+
}, summary));
|
|
83
|
+
}
|
|
84
|
+
export default Invocation;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
[data-odn-invocation] {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
white-space: nowrap;
|
|
5
|
+
word-break: keep-all;
|
|
6
|
+
overflow-wrap: normal;
|
|
7
|
+
margin: 0;
|
|
8
|
+
padding: 0 4px;
|
|
9
|
+
border-radius: 6px;
|
|
10
|
+
background: transparent;
|
|
11
|
+
color: var(--odn-color-cyan-6, var(--odn-color-cyan-5));
|
|
12
|
+
font-weight: 500;
|
|
13
|
+
font-size: inherit;
|
|
14
|
+
line-height: inherit;
|
|
15
|
+
cursor: default;
|
|
16
|
+
user-select: none;
|
|
17
|
+
-webkit-user-select: none;
|
|
18
|
+
transition: background-color 0.15s;
|
|
19
|
+
}
|
|
20
|
+
[data-odn-invocation][data-state=active], [data-odn-invocation]:hover {
|
|
21
|
+
background: color-mix(in srgb, var(--odn-color-cyan-5) 12%, transparent);
|
|
22
|
+
}
|
|
23
|
+
[data-odn-invocation][data-clickable] {
|
|
24
|
+
cursor: pointer;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
[data-odn-invocation-slash] {
|
|
28
|
+
opacity: 0.7;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
[data-odn-invocation-popover-inner] {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
gap: 6px;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
[data-odn-invocation-popover-title] {
|
|
38
|
+
display: inline-flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
gap: 1px;
|
|
41
|
+
font-weight: 500;
|
|
42
|
+
color: var(--odn-color-cyan-6, var(--odn-color-cyan-5));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
[data-odn-invocation-popover-slash] {
|
|
46
|
+
opacity: 0.7;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
[data-odn-invocation-popover-summary] {
|
|
50
|
+
display: inline-block;
|
|
51
|
+
align-self: flex-start;
|
|
52
|
+
padding: 2px 6px;
|
|
53
|
+
border-radius: 4px;
|
|
54
|
+
background: color-mix(in srgb, var(--odn-color-cyan-5) 10%, transparent);
|
|
55
|
+
color: var(--odn-color-cyan-6, var(--odn-color-cyan-5));
|
|
56
|
+
font-size: 12px;
|
|
57
|
+
line-height: 1.4;
|
|
58
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { MentionData } from '../_genui-types';
|
|
3
|
+
import './style';
|
|
4
|
+
export interface MentionProps {
|
|
5
|
+
data: MentionData;
|
|
6
|
+
/**
|
|
7
|
+
* true:Composer 编辑态(可点、无 hover 摘要弹层)。
|
|
8
|
+
* false:UserBubble 等只读态(可 hover 看摘要)。
|
|
9
|
+
*/
|
|
10
|
+
interactive?: boolean;
|
|
11
|
+
/** form popover 打开时的高亮态(L4 params 启用后使用) */
|
|
12
|
+
active?: boolean;
|
|
13
|
+
/** 交互态单击回调 */
|
|
14
|
+
onClick?: (anchor: HTMLElement) => void;
|
|
15
|
+
}
|
|
16
|
+
export declare function Mention({ data, interactive, active, onClick, }: MentionProps): import("react").JSX.Element;
|
|
17
|
+
export default Mention;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import Popover from "../popover";
|
|
8
|
+
import "./style";
|
|
9
|
+
function formatParamsSummary(params) {
|
|
10
|
+
if (!params) return null;
|
|
11
|
+
var entries = Object.entries(params).filter(function (_ref) {
|
|
12
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
13
|
+
v = _ref2[1];
|
|
14
|
+
return v != null && v !== '';
|
|
15
|
+
});
|
|
16
|
+
if (entries.length === 0) return null;
|
|
17
|
+
return entries.map(function (_ref3) {
|
|
18
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
19
|
+
k = _ref4[0],
|
|
20
|
+
v = _ref4[1];
|
|
21
|
+
return "".concat(k, ": ").concat(String(v));
|
|
22
|
+
}).join(' · ');
|
|
23
|
+
}
|
|
24
|
+
export function Mention(_ref5) {
|
|
25
|
+
var data = _ref5.data,
|
|
26
|
+
_ref5$interactive = _ref5.interactive,
|
|
27
|
+
interactive = _ref5$interactive === void 0 ? false : _ref5$interactive,
|
|
28
|
+
_ref5$active = _ref5.active,
|
|
29
|
+
active = _ref5$active === void 0 ? false : _ref5$active,
|
|
30
|
+
onClick = _ref5.onClick;
|
|
31
|
+
var clickable = interactive && !!onClick;
|
|
32
|
+
var state = active ? 'active' : 'complete';
|
|
33
|
+
var handleClick = clickable ? function (e) {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
e.stopPropagation();
|
|
36
|
+
onClick(e.currentTarget);
|
|
37
|
+
} : undefined;
|
|
38
|
+
var handleMouseDown = clickable ? function (e) {
|
|
39
|
+
e.preventDefault();
|
|
40
|
+
e.stopPropagation();
|
|
41
|
+
} : undefined;
|
|
42
|
+
var core = /*#__PURE__*/React.createElement("span", {
|
|
43
|
+
"data-odn-mention": true,
|
|
44
|
+
"data-state": state,
|
|
45
|
+
"data-clickable": clickable || undefined,
|
|
46
|
+
onClick: handleClick,
|
|
47
|
+
onMouseDown: handleMouseDown
|
|
48
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
49
|
+
"data-odn-mention-at": true,
|
|
50
|
+
"aria-hidden": true
|
|
51
|
+
}, "@"), /*#__PURE__*/React.createElement("span", {
|
|
52
|
+
"data-odn-mention-label": true
|
|
53
|
+
}, data.label));
|
|
54
|
+
if (interactive) return core;
|
|
55
|
+
var summary = formatParamsSummary(data.params);
|
|
56
|
+
if (!summary) return core;
|
|
57
|
+
return /*#__PURE__*/React.createElement(Popover, {
|
|
58
|
+
trigger: "hover",
|
|
59
|
+
placement: "top",
|
|
60
|
+
arrowed: false,
|
|
61
|
+
offset: 6,
|
|
62
|
+
mouseEnterDelay: 0.15,
|
|
63
|
+
mouseLeaveDelay: 0.1,
|
|
64
|
+
popup: /*#__PURE__*/React.createElement(MentionHoverPopup, {
|
|
65
|
+
label: data.label,
|
|
66
|
+
summary: summary
|
|
67
|
+
})
|
|
68
|
+
}, core);
|
|
69
|
+
}
|
|
70
|
+
function MentionHoverPopup(_ref6) {
|
|
71
|
+
var label = _ref6.label,
|
|
72
|
+
summary = _ref6.summary;
|
|
73
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
74
|
+
"data-odn-mention-popover-inner": true
|
|
75
|
+
}, /*#__PURE__*/React.createElement(MentionPopoverTitle, {
|
|
76
|
+
label: label
|
|
77
|
+
}), /*#__PURE__*/React.createElement("div", {
|
|
78
|
+
"data-odn-mention-popover-summary": true
|
|
79
|
+
}, summary));
|
|
80
|
+
}
|
|
81
|
+
function MentionPopoverTitle(_ref7) {
|
|
82
|
+
var label = _ref7.label;
|
|
83
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
84
|
+
"data-odn-mention-popover-title": true
|
|
85
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
86
|
+
"data-odn-mention-popover-at": true,
|
|
87
|
+
"aria-hidden": true
|
|
88
|
+
}, "@"), label);
|
|
89
|
+
}
|
|
90
|
+
export default Mention;
|