@lobehub/ui 1.72.5 → 1.72.6
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/ChatInputArea/index.d.ts +2 -0
- package/es/ChatInputArea/index.js +20 -13
- package/es/ChatInputArea/style.d.ts +0 -1
- package/es/ChatInputArea/style.js +4 -6
- package/es/EditableMessage/index.d.ts +3 -1
- package/es/EditableMessage/index.js +15 -18
- package/es/Input/style.js +1 -1
- package/es/MessageInput/index.d.ts +1 -1
- package/es/MessageInput/index.js +28 -29
- package/es/MessageInput/style.js +1 -1
- package/package.json +1 -1
- package/es/ChatInputArea/InputHighlight.d.ts +0 -7
- package/es/ChatInputArea/InputHighlight.js +0 -39
|
@@ -40,6 +40,7 @@ export interface ChatInputAreaProps extends ActionProps, TextAreaProps {
|
|
|
40
40
|
* @param value - The current value of the input area
|
|
41
41
|
*/
|
|
42
42
|
onSend?: (value: string) => void;
|
|
43
|
+
onStop?: () => void;
|
|
43
44
|
/**
|
|
44
45
|
* @description Placeholder text for the input area
|
|
45
46
|
* @default 'Type something to chat...'
|
|
@@ -51,6 +52,7 @@ export interface ChatInputAreaProps extends ActionProps, TextAreaProps {
|
|
|
51
52
|
style?: CSSProperties;
|
|
52
53
|
text?: {
|
|
53
54
|
send?: string;
|
|
55
|
+
stop?: string;
|
|
54
56
|
};
|
|
55
57
|
/**
|
|
56
58
|
* @description Additional class name for the textarea element
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["text", "textareaClassName", "style", "textareaStyle", "minHeight", "className", "actions", "footer", "expand", "placeholder", "onExpandChange", "onSend", "defaultValue", "loading", "disabled", "onInputChange", "onPressEnter", "onCompositionStart", "onCompositionEnd", "onBlur", "onChange", "textareaId", "actionsRight"];
|
|
4
|
+
var _excluded = ["text", "textareaClassName", "style", "textareaStyle", "minHeight", "className", "actions", "footer", "expand", "placeholder", "onExpandChange", "onSend", "defaultValue", "loading", "disabled", "onInputChange", "onPressEnter", "onCompositionStart", "onCompositionEnd", "onBlur", "onChange", "textareaId", "actionsRight", "onStop"];
|
|
5
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; }
|
|
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 { Button } from 'antd';
|
|
8
|
+
import { Loader2 } from 'lucide-react';
|
|
8
9
|
import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
|
|
10
|
+
import Icon from "../Icon";
|
|
9
11
|
import { TextArea } from "../Input";
|
|
10
12
|
import Action from "./Action";
|
|
11
|
-
import InputHighlight from "./InputHighlight";
|
|
12
13
|
import { useStyles } from "./style";
|
|
13
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -29,7 +30,8 @@ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
29
30
|
onSend = _ref.onSend,
|
|
30
31
|
_ref$defaultValue = _ref.defaultValue,
|
|
31
32
|
defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
|
|
32
|
-
loading = _ref.loading,
|
|
33
|
+
_ref$loading = _ref.loading,
|
|
34
|
+
loading = _ref$loading === void 0 ? true : _ref$loading,
|
|
33
35
|
disabled = _ref.disabled,
|
|
34
36
|
onInputChange = _ref.onInputChange,
|
|
35
37
|
_onPressEnter = _ref.onPressEnter,
|
|
@@ -40,6 +42,7 @@ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
40
42
|
_ref$textareaId = _ref.textareaId,
|
|
41
43
|
textareaId = _ref$textareaId === void 0 ? 'lobe-chat-input-area' : _ref$textareaId,
|
|
42
44
|
actionsRight = _ref.actionsRight,
|
|
45
|
+
onStop = _ref.onStop,
|
|
43
46
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
44
47
|
var _useStyles = useStyles(),
|
|
45
48
|
cx = _useStyles.cx,
|
|
@@ -50,7 +53,7 @@ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
50
53
|
value = _useState2[0],
|
|
51
54
|
setValue = _useState2[1];
|
|
52
55
|
var handleSend = useCallback(function () {
|
|
53
|
-
if (disabled) return;
|
|
56
|
+
if (loading && disabled) return;
|
|
54
57
|
if (onSend) onSend(value);
|
|
55
58
|
setValue('');
|
|
56
59
|
}, [disabled, value]);
|
|
@@ -67,12 +70,9 @@ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
67
70
|
actionsRight: actionsRight,
|
|
68
71
|
expand: expand,
|
|
69
72
|
onExpandChange: onExpandChange
|
|
70
|
-
}), /*#__PURE__*/
|
|
73
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
71
74
|
className: styles.textareaContainer,
|
|
72
|
-
children:
|
|
73
|
-
target: textareaId,
|
|
74
|
-
value: value
|
|
75
|
-
}), /*#__PURE__*/_jsx(TextArea, _objectSpread(_objectSpread({
|
|
75
|
+
children: /*#__PURE__*/_jsx(TextArea, _objectSpread(_objectSpread({
|
|
76
76
|
className: cx(styles.textarea, textareaClassName),
|
|
77
77
|
defaultValue: defaultValue,
|
|
78
78
|
id: textareaId,
|
|
@@ -106,14 +106,21 @@ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
106
106
|
resize: false,
|
|
107
107
|
type: "pure",
|
|
108
108
|
value: value
|
|
109
|
-
}))
|
|
109
|
+
}))
|
|
110
110
|
}), /*#__PURE__*/_jsxs("div", {
|
|
111
111
|
className: styles.footerBar,
|
|
112
|
-
children: [footer, /*#__PURE__*/_jsx(Button, {
|
|
112
|
+
children: [footer, loading ? /*#__PURE__*/_jsx(Button, {
|
|
113
|
+
disabled: disabled,
|
|
114
|
+
icon: loading && /*#__PURE__*/_jsx(Icon, {
|
|
115
|
+
icon: Loader2,
|
|
116
|
+
spin: true
|
|
117
|
+
}),
|
|
118
|
+
onClick: onStop,
|
|
119
|
+
children: (text === null || text === void 0 ? void 0 : text.stop) || 'Stop'
|
|
120
|
+
}) : /*#__PURE__*/_jsx(Button, {
|
|
113
121
|
disabled: disabled,
|
|
114
|
-
loading: loading,
|
|
115
122
|
onClick: handleSend,
|
|
116
|
-
type:
|
|
123
|
+
type: 'primary',
|
|
117
124
|
children: (text === null || text === void 0 ? void 0 : text.send) || 'Send'
|
|
118
125
|
})]
|
|
119
126
|
})]
|
|
@@ -4,7 +4,6 @@ export declare const useStyles: (props?: unknown) => import("antd-style").Return
|
|
|
4
4
|
actionsRight: import("antd-style").SerializedStyles;
|
|
5
5
|
container: import("antd-style").SerializedStyles;
|
|
6
6
|
footerBar: import("antd-style").SerializedStyles;
|
|
7
|
-
highlight: import("antd-style").SerializedStyles;
|
|
8
7
|
textarea: import("antd-style").SerializedStyles;
|
|
9
8
|
textareaContainer: import("antd-style").SerializedStyles;
|
|
10
9
|
}>;
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
|
|
2
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7
|
|
2
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
export var useStyles = createStyles(function (_ref) {
|
|
5
|
-
var css = _ref.css
|
|
6
|
-
token = _ref.token;
|
|
5
|
+
var css = _ref.css;
|
|
7
6
|
return {
|
|
8
7
|
actionLeft: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex: 1;\n gap: 4px;\n align-items: center;\n justify-content: flex-start;\n "]))),
|
|
9
8
|
actionsBar: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: flex;\n flex: none;\n align-items: center;\n justify-content: space-between;\n\n padding: 0 16px;\n "]))),
|
|
10
9
|
actionsRight: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex: 0;\n gap: 4px;\n align-items: center;\n justify-content: flex-end;\n "]))),
|
|
11
10
|
container: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n position: relative;\n\n display: flex;\n flex-direction: column;\n gap: 8px;\n\n height: 100%;\n padding: 12px 0 16px;\n "]))),
|
|
12
11
|
footerBar: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n display: flex;\n flex: none;\n gap: 8px;\n align-items: center;\n justify-content: flex-end;\n\n padding: 0 24px;\n "]))),
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
textareaContainer: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n position: relative;\n flex: 1;\n "])))
|
|
12
|
+
textarea: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n height: 100% !important;\n padding: 0 24px;\n line-height: 1.5;\n "]))),
|
|
13
|
+
textareaContainer: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n position: relative;\n flex: 1;\n "])))
|
|
16
14
|
};
|
|
17
15
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
|
+
import { type MessageInputProps } from "../MessageInput";
|
|
2
3
|
import { type MessageModalProps } from "../MessageModal";
|
|
3
4
|
export interface EditableMessageProps {
|
|
4
5
|
/**
|
|
@@ -14,12 +15,13 @@ export interface EditableMessageProps {
|
|
|
14
15
|
*/
|
|
15
16
|
markdown?: string;
|
|
16
17
|
};
|
|
17
|
-
editButtonSize?: '
|
|
18
|
+
editButtonSize?: MessageInputProps['editButtonSize'];
|
|
18
19
|
/**
|
|
19
20
|
* @title Whether the component is in edit mode or not
|
|
20
21
|
* @default false
|
|
21
22
|
*/
|
|
22
23
|
editing?: boolean;
|
|
24
|
+
height?: number;
|
|
23
25
|
/**
|
|
24
26
|
* @title Callback function when the value changes
|
|
25
27
|
* @param value - The new value
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
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
|
+
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; }
|
|
2
5
|
import { memo } from 'react';
|
|
3
6
|
import useControlledState from 'use-merge-value';
|
|
4
7
|
import Markdown from "../Markdown";
|
|
@@ -21,6 +24,7 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
21
24
|
_ref$showEditWhenEmpt = _ref.showEditWhenEmpty,
|
|
22
25
|
showEditWhenEmpty = _ref$showEditWhenEmpt === void 0 ? false : _ref$showEditWhenEmpt,
|
|
23
26
|
styles = _ref.styles,
|
|
27
|
+
height = _ref.height,
|
|
24
28
|
editButtonSize = _ref.editButtonSize,
|
|
25
29
|
text = _ref.text;
|
|
26
30
|
var _useControlledState = useControlledState(false, {
|
|
@@ -37,10 +41,11 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
37
41
|
_useControlledState4 = _slicedToArray(_useControlledState3, 2),
|
|
38
42
|
expand = _useControlledState4[0],
|
|
39
43
|
setExpand = _useControlledState4[1];
|
|
40
|
-
|
|
44
|
+
var input = /*#__PURE__*/_jsx(MessageInput, {
|
|
41
45
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.input,
|
|
42
46
|
defaultValue: value,
|
|
43
47
|
editButtonSize: editButtonSize,
|
|
48
|
+
height: height,
|
|
44
49
|
onCancel: function onCancel() {
|
|
45
50
|
return setTyping(false);
|
|
46
51
|
},
|
|
@@ -51,24 +56,16 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
|
|
|
51
56
|
placeholder: placeholder,
|
|
52
57
|
style: styles === null || styles === void 0 ? void 0 : styles.input,
|
|
53
58
|
text: text
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
editButtonSize: editButtonSize,
|
|
59
|
-
onCancel: function onCancel() {
|
|
60
|
-
return setTyping(false);
|
|
61
|
-
},
|
|
62
|
-
onConfirm: function onConfirm(text) {
|
|
63
|
-
_onChange === null || _onChange === void 0 ? void 0 : _onChange(text);
|
|
64
|
-
setTyping(false);
|
|
65
|
-
},
|
|
66
|
-
placeholder: placeholder,
|
|
67
|
-
style: styles === null || styles === void 0 ? void 0 : styles.input,
|
|
68
|
-
text: text
|
|
69
|
-
}) : /*#__PURE__*/_jsx(Markdown, {
|
|
59
|
+
});
|
|
60
|
+
if (!value && showEditWhenEmpty) return input;
|
|
61
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
62
|
+
children: [!expand && isEdit ? input : /*#__PURE__*/_jsx(Markdown, {
|
|
70
63
|
className: classNames === null || classNames === void 0 ? void 0 : classNames.markdown,
|
|
71
|
-
style:
|
|
64
|
+
style: _objectSpread({
|
|
65
|
+
height: height,
|
|
66
|
+
overflowX: 'hidden',
|
|
67
|
+
overflowY: 'auto'
|
|
68
|
+
}, styles === null || styles === void 0 ? void 0 : styles.markdown),
|
|
72
69
|
children: value || placeholder
|
|
73
70
|
}), /*#__PURE__*/_jsx(MessageModal, {
|
|
74
71
|
editing: isEdit,
|
package/es/Input/style.js
CHANGED
|
@@ -9,6 +9,6 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
9
9
|
var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n transition:\n background-color 100ms ", ",\n border-color 200ms ", ";\n\n &:hover {\n background-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n }\n\n &.ant-input-affix-wrapper-focused {\n border-color: ", ";\n }\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorder, token.motionEaseOut, token.motionEaseOut, token.colorFillTertiary, token.colorTextQuaternary, token.colorTextQuaternary);
|
|
10
10
|
return {
|
|
11
11
|
input: cx(type !== 'pure' && typeStylish, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n max-width: 100%;\n height: ", ";\n padding: ", ";\n\n input {\n background: transparent;\n }\n "])), type === 'pure' ? 'unset' : '36px', type === 'pure' ? '0' : '0 12px')),
|
|
12
|
-
textarea: cx(type !== 'pure' && typeStylish, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n max-width: 100%;\n padding: ", ";\n\n textarea {\n background: transparent;\n }\n "])), type === 'pure' ? '0' : '8px 12px'))
|
|
12
|
+
textarea: cx(type !== 'pure' && typeStylish, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n max-width: 100%;\n padding: ", ";\n border-radius: ", ";\n\n textarea {\n background: transparent;\n }\n "])), type === 'pure' ? '0' : '8px 12px', type === 'pure' ? '0' : "".concat(token.borderRadius, "px")))
|
|
13
13
|
};
|
|
14
14
|
});
|
|
@@ -11,7 +11,7 @@ export interface MessageInputProps extends DivProps {
|
|
|
11
11
|
* @description The default value of the input box.
|
|
12
12
|
*/
|
|
13
13
|
defaultValue?: string;
|
|
14
|
-
editButtonSize?: '
|
|
14
|
+
editButtonSize?: ButtonProps['size'];
|
|
15
15
|
height?: number | string;
|
|
16
16
|
/**
|
|
17
17
|
* @description Callback function triggered when user clicks on the cancel button.
|
package/es/MessageInput/index.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["text", "type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height", "editButtonSize"];
|
|
4
|
+
var _excluded = ["text", "type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height", "style", "editButtonSize"];
|
|
5
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; }
|
|
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 { Button } from 'antd';
|
|
8
8
|
import { memo, useState } from 'react';
|
|
9
9
|
import { Flexbox } from 'react-layout-kit';
|
|
10
|
-
import
|
|
10
|
+
import { TextArea } from "../Input";
|
|
11
11
|
import { useStyles } from "./style";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -26,6 +26,7 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
26
26
|
placeholder = _ref$placeholder === void 0 ? 'Type something...' : _ref$placeholder,
|
|
27
27
|
_ref$height = _ref.height,
|
|
28
28
|
height = _ref$height === void 0 ? 'fit-content' : _ref$height,
|
|
29
|
+
style = _ref.style,
|
|
29
30
|
_ref$editButtonSize = _ref.editButtonSize,
|
|
30
31
|
editButtonSize = _ref$editButtonSize === void 0 ? 'middle' : _ref$editButtonSize,
|
|
31
32
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
@@ -36,32 +37,30 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
36
37
|
var _useStyles = useStyles(),
|
|
37
38
|
cx = _useStyles.cx,
|
|
38
39
|
styles = _useStyles.styles;
|
|
39
|
-
return /*#__PURE__*/_jsxs(Flexbox, {
|
|
40
|
-
gap:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
})
|
|
64
|
-
})), /*#__PURE__*/_jsx(Flexbox, {
|
|
40
|
+
return /*#__PURE__*/_jsxs(Flexbox, _objectSpread(_objectSpread({
|
|
41
|
+
gap: 16,
|
|
42
|
+
style: _objectSpread({
|
|
43
|
+
flex: 1,
|
|
44
|
+
width: '100%'
|
|
45
|
+
}, style)
|
|
46
|
+
}, props), {}, {
|
|
47
|
+
children: [/*#__PURE__*/_jsx(TextArea, {
|
|
48
|
+
className: cx(styles, textareaClassname),
|
|
49
|
+
onBlur: function onBlur(e) {
|
|
50
|
+
return setRole(e.target.value);
|
|
51
|
+
},
|
|
52
|
+
onChange: function onChange(e) {
|
|
53
|
+
return setRole(e.target.value);
|
|
54
|
+
},
|
|
55
|
+
placeholder: placeholder,
|
|
56
|
+
resize: false,
|
|
57
|
+
style: _objectSpread({
|
|
58
|
+
height: height,
|
|
59
|
+
minHeight: '100%'
|
|
60
|
+
}, textareaStyle),
|
|
61
|
+
type: type,
|
|
62
|
+
value: temporarySystemRole
|
|
63
|
+
}), /*#__PURE__*/_jsx(Flexbox, {
|
|
65
64
|
direction: 'horizontal-reverse',
|
|
66
65
|
gap: 8,
|
|
67
66
|
children: renderButtons ? renderButtons(temporarySystemRole).map(function (buttonProps, index) {
|
|
@@ -83,6 +82,6 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
83
82
|
})]
|
|
84
83
|
})
|
|
85
84
|
})]
|
|
86
|
-
});
|
|
85
|
+
}));
|
|
87
86
|
});
|
|
88
87
|
export default MessageInput;
|
package/es/MessageInput/style.js
CHANGED
|
@@ -3,5 +3,5 @@ var _templateObject;
|
|
|
3
3
|
import { createStyles } from 'antd-style';
|
|
4
4
|
export var useStyles = createStyles(function (_ref) {
|
|
5
5
|
var css = _ref.css;
|
|
6
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n font-size: 14px;\n line-height: 1.8;\n "])));
|
|
6
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n height: 100%;\n font-size: 14px;\n line-height: 1.8;\n "])));
|
|
7
7
|
});
|
package/package.json
CHANGED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
|
-
import { useScroll, useSize } from 'ahooks';
|
|
3
|
-
import { memo, useEffect, useRef, useState } from 'react';
|
|
4
|
-
import { SyntaxHighlighter } from "../Highlighter";
|
|
5
|
-
import { useStyles } from "./style";
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
var InputHighlight = /*#__PURE__*/memo(function (_ref) {
|
|
8
|
-
var value = _ref.value,
|
|
9
|
-
target = _ref.target;
|
|
10
|
-
var ref = useRef(null);
|
|
11
|
-
var _useState = useState(),
|
|
12
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
13
|
-
nativeTextarea = _useState2[0],
|
|
14
|
-
setNativeTextarea = _useState2[1];
|
|
15
|
-
var _useStyles = useStyles(),
|
|
16
|
-
styles = _useStyles.styles;
|
|
17
|
-
useEffect(function () {
|
|
18
|
-
if (!nativeTextarea) setNativeTextarea(document.querySelector("#".concat(target)));
|
|
19
|
-
}, []);
|
|
20
|
-
var size = useSize(nativeTextarea);
|
|
21
|
-
var scroll = useScroll(nativeTextarea);
|
|
22
|
-
useEffect(function () {
|
|
23
|
-
ref.current.scroll(0, (scroll === null || scroll === void 0 ? void 0 : scroll.top) || 0);
|
|
24
|
-
}, [scroll === null || scroll === void 0 ? void 0 : scroll.top]);
|
|
25
|
-
return /*#__PURE__*/_jsx("div", {
|
|
26
|
-
className: styles.highlight,
|
|
27
|
-
"data-code-type": "highlighter",
|
|
28
|
-
ref: ref,
|
|
29
|
-
style: {
|
|
30
|
-
height: size === null || size === void 0 ? void 0 : size.height,
|
|
31
|
-
width: size === null || size === void 0 ? void 0 : size.width
|
|
32
|
-
},
|
|
33
|
-
children: /*#__PURE__*/_jsx(SyntaxHighlighter, {
|
|
34
|
-
language: "markdown",
|
|
35
|
-
children: value.trim()
|
|
36
|
-
})
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
export default InputHighlight;
|