@yuntijs/ui 1.0.0-beta.93 → 1.0.0-beta.95
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/es/ChatMarkdown/MarkdownElements/AntThinking/Component.d.ts +7 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/Component.js +57 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/index.d.ts +7 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/index.js +8 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/rehypePlugin.d.ts +3 -0
- package/es/ChatMarkdown/MarkdownElements/AntThinking/rehypePlugin.js +32 -0
- package/es/ChatMarkdown/MarkdownElements/index.d.ts +6 -0
- package/es/ChatMarkdown/MarkdownElements/index.js +2 -0
- package/es/ChatMarkdown/index.d.ts +10 -0
- package/es/ChatMarkdown/index.js +36 -0
- package/es/EditableMessage/index.d.ts +3 -2
- package/es/EditableMessage/index.js +3 -2
- package/es/JsonViewer/index.js +1 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/package.json +3 -1
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
4
|
+
import { Icon } from '@lobehub/ui';
|
|
5
|
+
import { createStyles } from 'antd-style';
|
|
6
|
+
import { ChevronDown, ChevronRight, Sparkles } from 'lucide-react';
|
|
7
|
+
import { memo, useState } from 'react';
|
|
8
|
+
import { Flexbox } from 'react-layout-kit';
|
|
9
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
+
var useStyles = createStyles(function (_ref) {
|
|
12
|
+
var css = _ref.css,
|
|
13
|
+
token = _ref.token,
|
|
14
|
+
isDarkMode = _ref.isDarkMode;
|
|
15
|
+
return {
|
|
16
|
+
container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n padding-block: 12px;\n padding-block-end: 6px;\n color: ", ";\n "])), token.colorTextTertiary),
|
|
17
|
+
titlebox: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: 8px;\n color: ", ";\n background: ", ";\n border-radius: 8px;\n\n &:hover {\n background: ", ";\n }\n "])), token.colorTextSecondary, token.colorFillTertiary, isDarkMode ? '' : token.colorFillSecondary),
|
|
18
|
+
title: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow: hidden;\n display: box;\n -webkit-box-orient: vertical;\n\n font-size: 12px;\n text-overflow: ellipsis;\n\n -webkit-line-clamp: 1;\n "])))
|
|
19
|
+
};
|
|
20
|
+
});
|
|
21
|
+
var Render = /*#__PURE__*/memo(function (_ref2) {
|
|
22
|
+
var children = _ref2.children,
|
|
23
|
+
second = _ref2.second,
|
|
24
|
+
done = _ref2.done;
|
|
25
|
+
var _useStyles = useStyles(),
|
|
26
|
+
styles = _useStyles.styles,
|
|
27
|
+
theme = _useStyles.theme;
|
|
28
|
+
var _useState = useState(true),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
showDetail = _useState2[0],
|
|
31
|
+
setShowDetail = _useState2[1];
|
|
32
|
+
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
33
|
+
className: styles.container,
|
|
34
|
+
gap: 16,
|
|
35
|
+
onClick: function onClick() {
|
|
36
|
+
setShowDetail(!showDetail);
|
|
37
|
+
},
|
|
38
|
+
width: '100%',
|
|
39
|
+
children: [/*#__PURE__*/_jsxs(Flexbox, {
|
|
40
|
+
className: styles.titlebox,
|
|
41
|
+
distribution: 'space-between',
|
|
42
|
+
flex: 1,
|
|
43
|
+
horizontal: true,
|
|
44
|
+
children: [/*#__PURE__*/_jsxs(Flexbox, {
|
|
45
|
+
gap: 8,
|
|
46
|
+
horizontal: true,
|
|
47
|
+
children: [/*#__PURE__*/_jsx(Icon, {
|
|
48
|
+
color: theme.purple,
|
|
49
|
+
icon: Sparkles
|
|
50
|
+
}), done ? "\u5DF2\u6DF1\u5EA6\u601D\u8003\uFF08\u7528\u65F6 ".concat(second || 0, " \u79D2\uFF09") : '思考中...']
|
|
51
|
+
}), /*#__PURE__*/_jsx(Icon, {
|
|
52
|
+
icon: showDetail ? ChevronDown : ChevronRight
|
|
53
|
+
})]
|
|
54
|
+
}), showDetail && children]
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
export default Render;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const AntThinkingElement: {
|
|
3
|
+
Component: import("react").NamedExoticComponent<import("react").PropsWithChildren<import("./Component").ThinkProps>>;
|
|
4
|
+
rehypePlugin: () => (tree: import("unist").Node) => void;
|
|
5
|
+
tag: string;
|
|
6
|
+
};
|
|
7
|
+
export default AntThinkingElement;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { visit } from 'unist-util-visit';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line unicorn/consistent-function-scoping
|
|
4
|
+
var rehypePlugin = function rehypePlugin() {
|
|
5
|
+
return function (tree) {
|
|
6
|
+
visit(tree, 'element', function (node, index, parent) {
|
|
7
|
+
if (node.type === 'element' && node.tagName === 'p') {
|
|
8
|
+
var children = node.children || [];
|
|
9
|
+
var openTagIndex = children.findIndex(function (child) {
|
|
10
|
+
return child.type === 'raw' && child.value === '<think>';
|
|
11
|
+
});
|
|
12
|
+
var closeTagIndex = children.findIndex(function (child) {
|
|
13
|
+
return child.type === 'raw' && child.value === '</think>';
|
|
14
|
+
});
|
|
15
|
+
if (openTagIndex !== -1 && closeTagIndex !== -1 && closeTagIndex > openTagIndex) {
|
|
16
|
+
var content = children.slice(openTagIndex + 1, closeTagIndex);
|
|
17
|
+
var thinkNode = {
|
|
18
|
+
children: content,
|
|
19
|
+
properties: {},
|
|
20
|
+
tagName: 'think',
|
|
21
|
+
type: 'element'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Replace the entire paragraph with our new thinkNode node
|
|
25
|
+
parent.children.splice(index, 1, thinkNode);
|
|
26
|
+
return index; // Skip processing the newly inserted node
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export default rehypePlugin;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const markdownElements: {
|
|
3
|
+
Component: import("react").NamedExoticComponent<import("react").PropsWithChildren<import("./AntThinking/Component").ThinkProps>>;
|
|
4
|
+
rehypePlugin: () => (tree: import("unist").Node) => void;
|
|
5
|
+
tag: string;
|
|
6
|
+
}[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MarkdownProps } from '@lobehub/ui';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ThinkProps } from './MarkdownElements/AntThinking/Component';
|
|
4
|
+
export interface ChatMarkdownProps extends MarkdownProps {
|
|
5
|
+
customComponentProps?: {
|
|
6
|
+
think?: Partial<ThinkProps>;
|
|
7
|
+
[k: string]: any;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export declare const ChatMarkdown: React.FC<ChatMarkdownProps>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
2
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["components", "rehypePlugins", "customComponentProps"];
|
|
5
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
+
import { Markdown } from '@lobehub/ui';
|
|
8
|
+
import React, { useMemo } from 'react';
|
|
9
|
+
import { markdownElements } from "./MarkdownElements";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
var defaultRehypePlugins = markdownElements.map(function (element) {
|
|
12
|
+
return element.rehypePlugin;
|
|
13
|
+
});
|
|
14
|
+
export var ChatMarkdown = function ChatMarkdown(_ref) {
|
|
15
|
+
var _ref$components = _ref.components,
|
|
16
|
+
components = _ref$components === void 0 ? {} : _ref$components,
|
|
17
|
+
_ref$rehypePlugins = _ref.rehypePlugins,
|
|
18
|
+
rehypePlugins = _ref$rehypePlugins === void 0 ? [] : _ref$rehypePlugins,
|
|
19
|
+
customComponentProps = _ref.customComponentProps,
|
|
20
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
+
var allComponents = useMemo(function () {
|
|
22
|
+
var defaultComponents = Object.fromEntries(markdownElements.map(function (element) {
|
|
23
|
+
return [element.tag, function (aprops) {
|
|
24
|
+
return /*#__PURE__*/_jsx(element.Component, _objectSpread(_objectSpread({}, aprops), customComponentProps === null || customComponentProps === void 0 ? void 0 : customComponentProps[element.tag]));
|
|
25
|
+
}];
|
|
26
|
+
}));
|
|
27
|
+
return _objectSpread(_objectSpread({}, defaultComponents), components);
|
|
28
|
+
}, [components, customComponentProps]);
|
|
29
|
+
var allRehypePlugins = useMemo(function () {
|
|
30
|
+
return [].concat(_toConsumableArray(defaultRehypePlugins), _toConsumableArray(rehypePlugins));
|
|
31
|
+
}, [rehypePlugins]);
|
|
32
|
+
return /*#__PURE__*/_jsx(Markdown, _objectSpread({
|
|
33
|
+
components: allComponents,
|
|
34
|
+
rehypePlugins: allRehypePlugins
|
|
35
|
+
}, props));
|
|
36
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type MessageInputProps, type MessageModalProps } from '@lobehub/ui';
|
|
2
2
|
import { CSSProperties } from 'react';
|
|
3
|
+
import { ChatMarkdownProps } from "../ChatMarkdown";
|
|
3
4
|
export interface EditableMessageProps {
|
|
4
5
|
/**
|
|
5
6
|
* @title The class name for the Markdown and MessageInput component
|
|
@@ -70,6 +71,6 @@ export interface EditableMessageProps {
|
|
|
70
71
|
* @title The current text value
|
|
71
72
|
*/
|
|
72
73
|
value: string;
|
|
73
|
-
markdownProps?: Omit<
|
|
74
|
+
markdownProps?: Omit<ChatMarkdownProps, 'children'>;
|
|
74
75
|
}
|
|
75
76
|
export declare const EditableMessage: import("react").NamedExoticComponent<EditableMessageProps>;
|
|
@@ -4,9 +4,10 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
|
4
4
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
|
-
import {
|
|
7
|
+
import { MessageInput, MessageModal } from '@lobehub/ui';
|
|
8
8
|
import { memo } from 'react';
|
|
9
9
|
import useControlledState from 'use-merge-value';
|
|
10
|
+
import { ChatMarkdown } from "../ChatMarkdown";
|
|
10
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
12
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -69,7 +70,7 @@ export var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
69
70
|
});
|
|
70
71
|
if (!value && showEditWhenEmpty) return input;
|
|
71
72
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
72
|
-
children: [!expand && isEdit ? input : /*#__PURE__*/_jsx(
|
|
73
|
+
children: [!expand && isEdit ? input : /*#__PURE__*/_jsx(ChatMarkdown, _objectSpread(_objectSpread({
|
|
73
74
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.markdown,
|
|
74
75
|
fontSize: fontSize,
|
|
75
76
|
fullFeaturedCodeBlock: fullFeaturedCodeBlock,
|
package/es/JsonViewer/index.js
CHANGED
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuntijs/ui",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.95",
|
|
4
4
|
"description": "☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yuntijs",
|
|
@@ -113,6 +113,7 @@
|
|
|
113
113
|
"@types/query-string": "^6",
|
|
114
114
|
"@types/react": "18.2.40",
|
|
115
115
|
"@types/react-dom": "^18",
|
|
116
|
+
"@types/unist": "^3.0.3",
|
|
116
117
|
"@vitest/coverage-v8": "latest",
|
|
117
118
|
"@yuntijs/lint": "^1.7.0",
|
|
118
119
|
"antd": "^5.23.0",
|
|
@@ -137,6 +138,7 @@
|
|
|
137
138
|
"semantic-release": "^21",
|
|
138
139
|
"stylelint": "^15",
|
|
139
140
|
"typescript": "^5",
|
|
141
|
+
"unist-util-visit": "^5.0.0",
|
|
140
142
|
"vitest": "latest"
|
|
141
143
|
},
|
|
142
144
|
"peerDependencies": {
|