@lobehub/ui 1.35.0 → 1.36.0

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.
@@ -1,30 +1,34 @@
1
- import { ReactNode } from 'react';
2
- import type { DivProps } from "../types";
3
- export interface ChatInputAreaProps extends DivProps {
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import { type TextAreaProps } from "../Input";
3
+ export interface ChatInputAreaProps extends TextAreaProps {
4
4
  /**
5
- * @description Actions to be displayed in the left of actions bar
5
+ * @description Actions to be displayed in the input area
6
6
  */
7
7
  actions?: ReactNode;
8
8
  /**
9
- * @description Default value of the input
9
+ * @description Additional class name for the component
10
+ */
11
+ className?: string;
12
+ /**
13
+ * @description Default value for the input area
10
14
  */
11
15
  defaultValue?: string;
12
16
  /**
13
- * @description Whether the input is disabled or not
17
+ * @description Whether the input area is disabled
14
18
  * @default false
15
19
  */
16
20
  disabled?: boolean;
17
21
  /**
18
- * @description Whether the input is expanded or not
22
+ * @description Whether the input area is expanded
19
23
  * @default false
20
24
  */
21
25
  expand?: boolean;
22
26
  /**
23
- * @description Footer to be displayed below input area
27
+ * @description Footer content to be displayed below the input area
24
28
  */
25
29
  footer?: ReactNode;
26
30
  /**
27
- * @description Whether the input is in loading state or not
31
+ * @description Whether the input area is in loading state
28
32
  * @default false
29
33
  */
30
34
  loading?: boolean;
@@ -35,24 +39,36 @@ export interface ChatInputAreaProps extends DivProps {
35
39
  minHeight?: number;
36
40
  /**
37
41
  * @description Callback function when the expand state changes
38
- * @param expand - Whether the input is expanded or not
42
+ * @param expand - Whether the input area is expanded
39
43
  */
40
44
  onExpandChange?: (expand: boolean) => void;
41
45
  /**
42
46
  * @description Callback function when the input value changes
43
- * @param value - The current value of the input
47
+ * @param value - The current value of the input area
44
48
  */
45
49
  onInputChange?: (value: string) => void;
46
50
  /**
47
51
  * @description Callback function when the send button is clicked
48
- * @param value - The current value of the input
52
+ * @param value - The current value of the input area
49
53
  */
50
54
  onSend?: (value: string) => void;
51
55
  /**
52
- * @description Placeholder text of the input
56
+ * @description Placeholder text for the input area
53
57
  * @default 'Type something to chat...'
54
58
  */
55
59
  placeholder?: string;
60
+ /**
61
+ * @description CSS styles for the component
62
+ */
63
+ style?: CSSProperties;
64
+ /**
65
+ * @description Additional class name for the textarea element
66
+ */
67
+ textareaClassName?: string;
68
+ /**
69
+ * @description CSS styles for the textarea element
70
+ */
71
+ textareaStyle?: CSSProperties;
56
72
  }
57
73
  declare const ChatInputArea: import("react").NamedExoticComponent<ChatInputAreaProps>;
58
74
  export default ChatInputArea;
@@ -1,19 +1,22 @@
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 = ["minHeight", "className", "actions", "footer", "expand", "placeholder", "onExpandChange", "onSend", "defaultValue", "loading", "style", "disabled", "onInputChange"];
4
+ var _excluded = ["textareaClassName", "style", "textareaStyle", "minHeight", "className", "actions", "footer", "expand", "placeholder", "onExpandChange", "onSend", "defaultValue", "loading", "disabled", "onInputChange", "onPressEnter", "onCompositionStart", "onCompositionEnd", "onBlur", "onChange"];
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 { Maximize2, Minimize2 } 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 { TextArea } from "../Input";
12
12
  import { useStyles } from "./style";
13
13
  import { jsx as _jsx } from "react/jsx-runtime";
14
14
  import { jsxs as _jsxs } from "react/jsx-runtime";
15
- var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
16
- var _ref$minHeight = _ref.minHeight,
15
+ var ChatInputArea = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, reference) {
16
+ var textareaClassName = _ref.textareaClassName,
17
+ style = _ref.style,
18
+ textareaStyle = _ref.textareaStyle,
19
+ _ref$minHeight = _ref.minHeight,
17
20
  minHeight = _ref$minHeight === void 0 ? 200 : _ref$minHeight,
18
21
  className = _ref.className,
19
22
  actions = _ref.actions,
@@ -26,9 +29,13 @@ var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
26
29
  _ref$defaultValue = _ref.defaultValue,
27
30
  defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
28
31
  loading = _ref.loading,
29
- style = _ref.style,
30
32
  disabled = _ref.disabled,
31
33
  onInputChange = _ref.onInputChange,
34
+ _onPressEnter = _ref.onPressEnter,
35
+ _onCompositionStart = _ref.onCompositionStart,
36
+ _onCompositionEnd = _ref.onCompositionEnd,
37
+ _onBlur = _ref.onBlur,
38
+ _onChange = _ref.onChange,
32
39
  props = _objectWithoutProperties(_ref, _excluded);
33
40
  var isChineseInput = useRef(false);
34
41
  var _useState = useState(defaultValue),
@@ -49,12 +56,11 @@ var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
49
56
  useEffect(function () {
50
57
  if (onInputChange) onInputChange(value);
51
58
  }, [value]);
52
- return /*#__PURE__*/_jsxs("section", _objectSpread(_objectSpread({
59
+ return /*#__PURE__*/_jsxs("section", {
53
60
  className: cx(styles.container, className),
54
61
  style: _objectSpread({
55
62
  minHeight: minHeight
56
- }, style)
57
- }, props), {}, {
63
+ }, style),
58
64
  children: [/*#__PURE__*/_jsxs("div", {
59
65
  className: styles.actionsBar,
60
66
  children: [/*#__PURE__*/_jsx("div", {
@@ -67,22 +73,30 @@ var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
67
73
  onClick: handleExpandClick
68
74
  })
69
75
  })]
70
- }), /*#__PURE__*/_jsx(TextArea, {
71
- className: styles.textarea,
76
+ }), /*#__PURE__*/_jsx(TextArea, _objectSpread(_objectSpread({
77
+ className: cx(styles.textarea, textareaClassName),
72
78
  defaultValue: defaultValue,
79
+ ref: reference,
80
+ style: textareaStyle
81
+ }, props), {}, {
73
82
  onBlur: function onBlur(e) {
74
- return setValue(e.target.value);
83
+ if (_onBlur) _onBlur(e);
84
+ setValue(e.target.value);
75
85
  },
76
86
  onChange: function onChange(e) {
77
- return setValue(e.target.value);
87
+ if (_onChange) _onChange(e);
88
+ setValue(e.target.value);
78
89
  },
79
- onCompositionEnd: function onCompositionEnd() {
90
+ onCompositionEnd: function onCompositionEnd(e) {
91
+ if (_onCompositionEnd) _onCompositionEnd(e);
80
92
  isChineseInput.current = false;
81
93
  },
82
- onCompositionStart: function onCompositionStart() {
94
+ onCompositionStart: function onCompositionStart(e) {
95
+ if (_onCompositionStart) _onCompositionStart(e);
83
96
  isChineseInput.current = true;
84
97
  },
85
98
  onPressEnter: function onPressEnter(e) {
99
+ if (_onPressEnter) _onPressEnter(e);
86
100
  if (!loading && !e.shiftKey && !isChineseInput.current) {
87
101
  e.preventDefault();
88
102
  handleSend();
@@ -92,7 +106,7 @@ var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
92
106
  resize: false,
93
107
  type: "pure",
94
108
  value: value
95
- }), /*#__PURE__*/_jsxs("div", {
109
+ })), /*#__PURE__*/_jsxs("div", {
96
110
  className: styles.footerBar,
97
111
  children: [footer, /*#__PURE__*/_jsx(Button, {
98
112
  disabled: disabled,
@@ -102,6 +116,6 @@ var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
102
116
  children: "Send"
103
117
  })]
104
118
  })]
105
- }));
106
- });
119
+ });
120
+ }));
107
121
  export default ChatInputArea;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.35.0",
3
+ "version": "1.36.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",