@lobehub/ui 1.30.0 → 1.31.1
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/CodeEditor/index.d.ts +36 -0
- package/es/CodeEditor/index.js +50 -0
- package/es/CodeEditor/style.d.ts +8 -0
- package/es/CodeEditor/style.js +17 -0
- package/es/Highlighter/theme.js +2 -2
- package/es/Markdown/index.js +11 -4
- package/es/MessageInput/index.d.ts +6 -6
- package/es/MessageInput/index.js +23 -16
- package/es/MessageModal/index.js +2 -2
- package/es/MessageModal/style.js +1 -1
- package/es/Swatches/style.js +1 -1
- package/es/components/ControlInput.js +7 -9
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/package.json +3 -2
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { InputRef } from 'antd';
|
|
2
|
+
import { type CSSProperties, type FocusEventHandler, type KeyboardEventHandler, type MouseEventHandler, type Ref } from 'react';
|
|
3
|
+
import { SyntaxHighlighterProps } from "../Highlighter/SyntaxHighlighter";
|
|
4
|
+
export interface CodeEditorProps {
|
|
5
|
+
autoFocus?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
form?: string;
|
|
9
|
+
ignoreTabKey?: boolean;
|
|
10
|
+
insertSpaces?: boolean;
|
|
11
|
+
language: SyntaxHighlighterProps['language'];
|
|
12
|
+
maxLength?: number;
|
|
13
|
+
minLength?: number;
|
|
14
|
+
name?: string;
|
|
15
|
+
onBlur?: FocusEventHandler<HTMLTextAreaElement>;
|
|
16
|
+
onClick?: MouseEventHandler<HTMLTextAreaElement>;
|
|
17
|
+
onFocus?: FocusEventHandler<HTMLTextAreaElement>;
|
|
18
|
+
onKeyDown?: KeyboardEventHandler<HTMLTextAreaElement>;
|
|
19
|
+
onKeyUp?: KeyboardEventHandler<HTMLTextAreaElement>;
|
|
20
|
+
onValueChange: (value: string) => void;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
preClassName?: string;
|
|
23
|
+
readOnly?: boolean;
|
|
24
|
+
ref?: Ref<InputRef>;
|
|
25
|
+
required?: boolean;
|
|
26
|
+
resize?: boolean;
|
|
27
|
+
style?: CSSProperties;
|
|
28
|
+
tabSize?: number;
|
|
29
|
+
textareaClassName?: string;
|
|
30
|
+
textareaId?: string;
|
|
31
|
+
theme?: SyntaxHighlighterProps['theme'];
|
|
32
|
+
type?: 'ghost' | 'block' | 'pure';
|
|
33
|
+
value: string;
|
|
34
|
+
}
|
|
35
|
+
declare const CodeEditor: import("react").NamedExoticComponent<CodeEditorProps>;
|
|
36
|
+
export default CodeEditor;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["style", "language", "theme", "value", "onValueChange", "resize", "className", "textareaClassName", "type"];
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
|
+
import { forwardRef, memo } from 'react';
|
|
7
|
+
import Editor from 'react-simple-code-editor';
|
|
8
|
+
import SyntaxHighlighter from "../Highlighter/SyntaxHighlighter";
|
|
9
|
+
import { useStyles } from "./style";
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
var CodeEditor = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, reference) {
|
|
12
|
+
var style = _ref.style,
|
|
13
|
+
language = _ref.language,
|
|
14
|
+
theme = _ref.theme,
|
|
15
|
+
value = _ref.value,
|
|
16
|
+
onValueChange = _ref.onValueChange,
|
|
17
|
+
_ref$resize = _ref.resize,
|
|
18
|
+
resize = _ref$resize === void 0 ? true : _ref$resize,
|
|
19
|
+
className = _ref.className,
|
|
20
|
+
textareaClassName = _ref.textareaClassName,
|
|
21
|
+
_ref$type = _ref.type,
|
|
22
|
+
type = _ref$type === void 0 ? 'ghost' : _ref$type,
|
|
23
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
24
|
+
var _useStyles = useStyles({
|
|
25
|
+
resize: resize,
|
|
26
|
+
type: type
|
|
27
|
+
}),
|
|
28
|
+
styles = _useStyles.styles,
|
|
29
|
+
cx = _useStyles.cx;
|
|
30
|
+
return /*#__PURE__*/_jsx("div", {
|
|
31
|
+
className: cx(styles.container, className),
|
|
32
|
+
style: style,
|
|
33
|
+
children: /*#__PURE__*/_jsx(Editor, _objectSpread({
|
|
34
|
+
className: styles.editor,
|
|
35
|
+
highlight: function highlight(code) {
|
|
36
|
+
return /*#__PURE__*/_jsx(SyntaxHighlighter, {
|
|
37
|
+
language: language,
|
|
38
|
+
theme: theme,
|
|
39
|
+
children: code
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
onValueChange: onValueChange,
|
|
43
|
+
padding: 0,
|
|
44
|
+
ref: reference,
|
|
45
|
+
textareaClassName: cx(styles.textarea, textareaClassName),
|
|
46
|
+
value: value
|
|
47
|
+
}, props))
|
|
48
|
+
});
|
|
49
|
+
}));
|
|
50
|
+
export default CodeEditor;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const useStyles: (props?: {
|
|
2
|
+
resize: boolean;
|
|
3
|
+
type: 'ghost' | 'block' | 'pure';
|
|
4
|
+
} | undefined) => import("antd-style").ReturnStyles<{
|
|
5
|
+
container: string;
|
|
6
|
+
editor: import("antd-style").SerializedStyles;
|
|
7
|
+
textarea: import("antd-style").SerializedStyles;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4;
|
|
3
|
+
import { createStyles } from 'antd-style';
|
|
4
|
+
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
5
|
+
var cx = _ref.cx,
|
|
6
|
+
css = _ref.css,
|
|
7
|
+
token = _ref.token,
|
|
8
|
+
isDarkMode = _ref.isDarkMode;
|
|
9
|
+
var type = _ref2.type,
|
|
10
|
+
resize = _ref2.resize;
|
|
11
|
+
var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 8px 12px;\n\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n\n transition: background-color 100ms ", ",\n border-color 200ms ", ";\n\n &:hover {\n background-color: ", ";\n border-color: ", ";\n }\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorderSecondary, token.borderRadius, token.motionEaseOut, token.motionEaseOut, type === 'block' ? token.colorFillSecondary : token.colorFillQuaternary, token.colorBorder);
|
|
12
|
+
return {
|
|
13
|
+
container: cx(type !== 'pure' && typeStylish, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n overflow-x: hidden;\n overflow-y: auto;\n height: fit-content;\n "])))),
|
|
14
|
+
editor: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n resize: ", ";\n height: fit-content;\n font-family: ", " !important;\n\n pre {\n word-wrap: break-word;\n white-space: pre-wrap;\n\n &.shiki {\n margin: 0;\n }\n }\n "])), resize ? 'vertical' : 'none', token.fontFamilyCode),
|
|
15
|
+
textarea: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n overflow-x: hidden;\n overflow-y: auto;\n height: 100% !important;\n\n &::placeholder {\n color: ", ";\n }\n\n &::selection {\n color: #000;\n background: ", ";\n }\n\n &:focus {\n border: none !important;\n outline: none !important;\n box-shadow: none !important;\n }\n "])), token.colorTextQuaternary, isDarkMode ? token.yellow3A : token.yellow6A)
|
|
16
|
+
};
|
|
17
|
+
});
|
package/es/Highlighter/theme.js
CHANGED
|
@@ -2,8 +2,8 @@ import { colorScales } from "../styles/colors";
|
|
|
2
2
|
export var themeConfig = function themeConfig(isDarkMode) {
|
|
3
3
|
var type = isDarkMode ? 'dark' : 'light';
|
|
4
4
|
var colorText = colorScales.gray[type][11];
|
|
5
|
-
var colorTextSecondary =
|
|
6
|
-
var colorTextTertiary =
|
|
5
|
+
var colorTextSecondary = colorScales.gray[type][10];
|
|
6
|
+
var colorTextTertiary = colorScales.gray[type][7];
|
|
7
7
|
var colorRed = isDarkMode ? colorScales.red[type][9] : colorScales.volcano[type][9];
|
|
8
8
|
var colorOrange = isDarkMode ? colorScales.gold[type][9] : colorScales.orange[type][9];
|
|
9
9
|
var colorGreen = isDarkMode ? colorScales.lime[type][9] : colorScales.green[type][9];
|
package/es/Markdown/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["children", "className"];
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
1
6
|
import { Collapse, Divider, Typography } from 'antd';
|
|
2
7
|
import pangu from 'pangu';
|
|
3
8
|
import { memo } from 'react';
|
|
@@ -9,7 +14,8 @@ import { useStyles } from "./style";
|
|
|
9
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
15
|
var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
11
16
|
var children = _ref.children,
|
|
12
|
-
className = _ref.className
|
|
17
|
+
className = _ref.className,
|
|
18
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
13
19
|
var _useStyles = useStyles(),
|
|
14
20
|
styles = _useStyles.styles,
|
|
15
21
|
cx = _useStyles.cx;
|
|
@@ -21,12 +27,13 @@ var Markdown = /*#__PURE__*/memo(function (_ref) {
|
|
|
21
27
|
pre: CodeBlock
|
|
22
28
|
};
|
|
23
29
|
return /*#__PURE__*/_jsx(Typography, {
|
|
24
|
-
children: /*#__PURE__*/_jsx(ReactMarkdown, {
|
|
30
|
+
children: /*#__PURE__*/_jsx(ReactMarkdown, _objectSpread(_objectSpread({
|
|
25
31
|
className: cx(styles.markdown, className),
|
|
26
32
|
components: components,
|
|
27
|
-
remarkPlugins: [remarkGfm]
|
|
33
|
+
remarkPlugins: [remarkGfm]
|
|
34
|
+
}, props), {}, {
|
|
28
35
|
children: pangu.spacing(children)
|
|
29
|
-
})
|
|
36
|
+
}))
|
|
30
37
|
});
|
|
31
38
|
});
|
|
32
39
|
export default Markdown;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { ButtonProps } from 'antd';
|
|
2
|
+
import { type CSSProperties } from 'react';
|
|
3
3
|
import { type TextAreaProps } from "../Input";
|
|
4
|
-
|
|
4
|
+
import { DivProps } from "../types";
|
|
5
|
+
export interface MessageInputProps extends DivProps {
|
|
5
6
|
/**
|
|
6
7
|
* @description Additional className to apply to the component.
|
|
7
8
|
*/
|
|
@@ -10,10 +11,7 @@ export interface MessageInputProps {
|
|
|
10
11
|
* @description The default value of the input box.
|
|
11
12
|
*/
|
|
12
13
|
defaultValue?: string;
|
|
13
|
-
|
|
14
|
-
* @description The height of the input box.
|
|
15
|
-
*/
|
|
16
|
-
height?: number;
|
|
14
|
+
height?: number | string;
|
|
17
15
|
/**
|
|
18
16
|
* @description Callback function triggered when user clicks on the cancel button.
|
|
19
17
|
*/
|
|
@@ -28,6 +26,8 @@ export interface MessageInputProps {
|
|
|
28
26
|
* @param text - The text input by the user.
|
|
29
27
|
*/
|
|
30
28
|
renderButtons?: (text: string) => ButtonProps[];
|
|
29
|
+
textareaClassname?: string;
|
|
30
|
+
textareaStyle?: CSSProperties;
|
|
31
31
|
/**
|
|
32
32
|
* @description The type of the input box.
|
|
33
33
|
*/
|
package/es/MessageInput/index.js
CHANGED
|
@@ -1,38 +1,46 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "height"];
|
|
3
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
5
7
|
import { Button } from 'antd';
|
|
6
|
-
import { cx } from 'antd-style';
|
|
7
8
|
import { memo, useState } from 'react';
|
|
8
9
|
import { Flexbox } from 'react-layout-kit';
|
|
9
|
-
import
|
|
10
|
+
import CodeEditor from "../CodeEditor";
|
|
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";
|
|
13
14
|
var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
14
|
-
var type = _ref.type,
|
|
15
|
+
var _ref$type = _ref.type,
|
|
16
|
+
type = _ref$type === void 0 ? 'ghost' : _ref$type,
|
|
15
17
|
onCancel = _ref.onCancel,
|
|
16
18
|
defaultValue = _ref.defaultValue,
|
|
17
19
|
onConfirm = _ref.onConfirm,
|
|
18
20
|
renderButtons = _ref.renderButtons,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
textareaStyle = _ref.textareaStyle,
|
|
22
|
+
textareaClassname = _ref.textareaClassname,
|
|
23
|
+
_ref$height = _ref.height,
|
|
24
|
+
height = _ref$height === void 0 ? 'fit-content' : _ref$height,
|
|
25
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
21
26
|
var _useState = useState(defaultValue || ''),
|
|
22
27
|
_useState2 = _slicedToArray(_useState, 2),
|
|
23
28
|
temporarySystemRole = _useState2[0],
|
|
24
29
|
setRole = _useState2[1];
|
|
25
|
-
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
26
|
-
gap: 8
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
|
|
31
|
+
gap: 8
|
|
32
|
+
}, props), {}, {
|
|
33
|
+
children: [/*#__PURE__*/_jsx(CodeEditor, {
|
|
34
|
+
className: textareaClassname,
|
|
35
|
+
language: "md",
|
|
36
|
+
onValueChange: function onValueChange(value) {
|
|
37
|
+
setRole(value);
|
|
31
38
|
},
|
|
32
39
|
placeholder: '例如:你是一名擅长翻译的翻译官,请将用户所输入的英文都翻译为中文。',
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
resize: false,
|
|
41
|
+
style: _objectSpread({
|
|
42
|
+
height: height
|
|
43
|
+
}, textareaStyle),
|
|
36
44
|
type: type,
|
|
37
45
|
value: temporarySystemRole
|
|
38
46
|
}), /*#__PURE__*/_jsx(Flexbox, {
|
|
@@ -49,11 +57,10 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
49
57
|
children: "Confirm"
|
|
50
58
|
}), /*#__PURE__*/_jsx(Button, {
|
|
51
59
|
onClick: onCancel,
|
|
52
|
-
type: "text",
|
|
53
60
|
children: "Cancel"
|
|
54
61
|
})]
|
|
55
62
|
})
|
|
56
63
|
})]
|
|
57
|
-
});
|
|
64
|
+
}));
|
|
58
65
|
});
|
|
59
66
|
export default MessageInput;
|
package/es/MessageModal/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var MessageModal = /*#__PURE__*/memo(function (_ref) {
|
|
|
38
38
|
closeIcon: /*#__PURE__*/_jsx(Icon, {
|
|
39
39
|
icon: X
|
|
40
40
|
}),
|
|
41
|
-
footer: isEdit ?
|
|
41
|
+
footer: isEdit ? null : undefined,
|
|
42
42
|
okText: 'Edit',
|
|
43
43
|
onCancel: function onCancel() {
|
|
44
44
|
return setExpand(false);
|
|
@@ -56,7 +56,7 @@ var MessageModal = /*#__PURE__*/memo(function (_ref) {
|
|
|
56
56
|
width: 800,
|
|
57
57
|
children: isEdit ? /*#__PURE__*/_jsx(MessageInput, {
|
|
58
58
|
defaultValue: value,
|
|
59
|
-
height:
|
|
59
|
+
height: "70vh",
|
|
60
60
|
onCancel: function onCancel() {
|
|
61
61
|
return setTyping(false);
|
|
62
62
|
},
|
package/es/MessageModal/style.js
CHANGED
|
@@ -6,6 +6,6 @@ export var useStyles = createStyles(function (_ref) {
|
|
|
6
6
|
prefixCls = _ref.prefixCls;
|
|
7
7
|
return {
|
|
8
8
|
body: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n overflow-x: hidden;\n overflow-y: auto;\n max-height: 70vh;\n "]))),
|
|
9
|
-
modal: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n
|
|
9
|
+
modal: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n .", "-modal-header {\n margin-bottom: 24px;\n }\n "])), prefixCls)
|
|
10
10
|
};
|
|
11
11
|
});
|
package/es/Swatches/style.js
CHANGED
|
@@ -5,7 +5,7 @@ export var useStyles = createStyles(function (_ref, size) {
|
|
|
5
5
|
var css = _ref.css,
|
|
6
6
|
token = _ref.token;
|
|
7
7
|
return {
|
|
8
|
-
active: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n box-shadow: inset 0 0 0 2px ", ";\n "])), token.
|
|
8
|
+
active: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n box-shadow: inset 0 0 0 2px ", ";\n "])), token.colorText),
|
|
9
9
|
container: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n cursor: pointer;\n\n width: ", "px;\n height: ", "px;\n\n background: ", ";\n border-radius: 50%;\n box-shadow: inset 0 0 0 1px ", ";\n\n transition: scale 400ms ", ";\n\n &:active {\n scale: 0.8;\n }\n "])), size, size, token.colorBgContainer, token.colorFill, token.motionEaseOut)
|
|
10
10
|
};
|
|
11
11
|
});
|
|
@@ -6,22 +6,21 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
6
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
7
|
import { ConfigProvider, Space } from 'antd';
|
|
8
8
|
import { RotateCcw, Save } from 'lucide-react';
|
|
9
|
-
import { memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
9
|
+
import { forwardRef, memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
10
10
|
import ActionIcon from "../ActionIcon";
|
|
11
11
|
import { Input } from "../Input";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
-
export var ControlInput = /*#__PURE__*/memo(function (_ref) {
|
|
14
|
+
export var ControlInput = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, reference) {
|
|
15
15
|
var value = _ref.value,
|
|
16
16
|
onChange = _ref.onChange,
|
|
17
17
|
onValueChanging = _ref.onValueChanging,
|
|
18
18
|
onChangeEnd = _ref.onChangeEnd,
|
|
19
|
-
|
|
19
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
20
20
|
var _useState = useState(value || ''),
|
|
21
21
|
_useState2 = _slicedToArray(_useState, 2),
|
|
22
22
|
input = _useState2[0],
|
|
23
23
|
setInput = _useState2[1];
|
|
24
|
-
var inputReference = useRef();
|
|
25
24
|
var isChineseInput = useRef(false);
|
|
26
25
|
var isFocusing = useRef(false);
|
|
27
26
|
var updateValue = useCallback(function () {
|
|
@@ -30,9 +29,7 @@ export var ControlInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
30
29
|
useEffect(function () {
|
|
31
30
|
if (value !== undefined) setInput(value);
|
|
32
31
|
}, [value]);
|
|
33
|
-
return /*#__PURE__*/_jsx(Input, _objectSpread(
|
|
34
|
-
ref: inputReference
|
|
35
|
-
}, properties), {}, {
|
|
32
|
+
return /*#__PURE__*/_jsx(Input, _objectSpread({
|
|
36
33
|
onBlur: function onBlur() {
|
|
37
34
|
isFocusing.current = false;
|
|
38
35
|
onChangeEnd === null || onChangeEnd === void 0 ? void 0 : onChangeEnd(input);
|
|
@@ -58,6 +55,7 @@ export var ControlInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
58
55
|
onChangeEnd === null || onChangeEnd === void 0 ? void 0 : onChangeEnd(input);
|
|
59
56
|
}
|
|
60
57
|
},
|
|
58
|
+
ref: reference,
|
|
61
59
|
suffix: value === input ? /*#__PURE__*/_jsx("span", {}) : /*#__PURE__*/_jsx(ConfigProvider, {
|
|
62
60
|
theme: {
|
|
63
61
|
token: {
|
|
@@ -82,5 +80,5 @@ export var ControlInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
82
80
|
})
|
|
83
81
|
}),
|
|
84
82
|
value: input
|
|
85
|
-
}));
|
|
86
|
-
});
|
|
83
|
+
}, props));
|
|
84
|
+
}));
|
package/es/index.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export type { ChatMessage, MessageRoleType } from './Chat';
|
|
|
6
6
|
export { default as ChatInputArea, type ChatInputAreaProps } from './ChatInputArea';
|
|
7
7
|
export { default as ChatItem, type ChatItemProps } from './ChatItem';
|
|
8
8
|
export { default as ChatList, type ChatListProps } from './ChatList';
|
|
9
|
+
export { default as CodeEditor, type CodeEditorProps } from './CodeEditor';
|
|
9
10
|
export { default as ColorScales, type ColorScalesProps } from './ColorScales';
|
|
10
11
|
export { default as ContextMenu, type ContextMenuProps } from './ContextMenu';
|
|
11
12
|
export { default as CopyButton, type CopyButtonProps } from './CopyButton';
|
package/es/index.js
CHANGED
|
@@ -5,6 +5,7 @@ export { default as Burger } from "./Burger";
|
|
|
5
5
|
export { default as ChatInputArea } from "./ChatInputArea";
|
|
6
6
|
export { default as ChatItem } from "./ChatItem";
|
|
7
7
|
export { default as ChatList } from "./ChatList";
|
|
8
|
+
export { default as CodeEditor } from "./CodeEditor";
|
|
8
9
|
export { default as ColorScales } from "./ColorScales";
|
|
9
10
|
export { default as ContextMenu } from "./ContextMenu";
|
|
10
11
|
export { default as CopyButton } from "./CopyButton";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.1",
|
|
4
4
|
"description": "Lobe UI is an open-source UI component library for building chatbot web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -95,9 +95,10 @@
|
|
|
95
95
|
"react-layout-kit": "^1",
|
|
96
96
|
"react-markdown": "^8",
|
|
97
97
|
"react-rnd": "^10",
|
|
98
|
+
"react-simple-code-editor": "^0",
|
|
98
99
|
"remark-gfm": "^3",
|
|
99
100
|
"shiki-es": "^0",
|
|
100
|
-
"styled-components": "
|
|
101
|
+
"styled-components": "^6",
|
|
101
102
|
"ts-md5": "^1",
|
|
102
103
|
"use-merge-value": "^1",
|
|
103
104
|
"zustand": "^4",
|