@lobehub/ui 1.50.0 → 1.50.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.
@@ -0,0 +1,11 @@
1
+ import { ReactNode } from 'react';
2
+ export interface ActionProps {
3
+ /**
4
+ * @description Actions to be displayed in the input area
5
+ */
6
+ actions?: ReactNode;
7
+ expand?: boolean;
8
+ onExpandChange?: (expand: boolean) => void;
9
+ }
10
+ declare const Action: import("react").NamedExoticComponent<ActionProps>;
11
+ export default Action;
@@ -0,0 +1,40 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3;
3
+ import { createStyles } from 'antd-style';
4
+ import { Maximize2, Minimize2 } from 'lucide-react';
5
+ import { memo, useCallback } from 'react';
6
+ import ActionIcon from "../ActionIcon";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ var useStyles = createStyles(function (_ref) {
10
+ var css = _ref.css;
11
+ return {
12
+ actionLeft: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n flex: 1;\n gap: 4px;\n align-items: center;\n justify-content: flex-start;\n "]))),
13
+ 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 "]))),
14
+ actionsRight: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex: 0;\n gap: 4px;\n align-items: center;\n justify-content: flex-end;\n "])))
15
+ };
16
+ });
17
+ var Action = /*#__PURE__*/memo(function (_ref2) {
18
+ var actions = _ref2.actions,
19
+ expand = _ref2.expand,
20
+ onExpandChange = _ref2.onExpandChange;
21
+ var _useStyles = useStyles(),
22
+ styles = _useStyles.styles;
23
+ var handleExpandClick = useCallback(function () {
24
+ if (onExpandChange) onExpandChange(!expand);
25
+ }, [expand]);
26
+ return /*#__PURE__*/_jsxs("div", {
27
+ className: styles.actionsBar,
28
+ children: [/*#__PURE__*/_jsx("div", {
29
+ className: styles.actionLeft,
30
+ children: actions
31
+ }), /*#__PURE__*/_jsx("div", {
32
+ className: styles.actionsRight,
33
+ children: /*#__PURE__*/_jsx(ActionIcon, {
34
+ icon: expand ? Minimize2 : Maximize2,
35
+ onClick: handleExpandClick
36
+ })
37
+ })]
38
+ });
39
+ });
40
+ export default Action;
@@ -1,11 +1,8 @@
1
1
  import { type InputRef } from 'antd';
2
2
  import { CSSProperties, ReactNode } from 'react';
3
3
  import { type TextAreaProps } from "../Input";
4
- export interface ChatInputAreaProps extends TextAreaProps {
5
- /**
6
- * @description Actions to be displayed in the input area
7
- */
8
- actions?: ReactNode;
4
+ import { ActionProps } from './Action';
5
+ export interface ChatInputAreaProps extends ActionProps, TextAreaProps {
9
6
  /**
10
7
  * @description Additional class name for the component
11
8
  */
@@ -19,11 +16,6 @@ export interface ChatInputAreaProps extends TextAreaProps {
19
16
  * @default false
20
17
  */
21
18
  disabled?: boolean;
22
- /**
23
- * @description Whether the input area is expanded
24
- * @default false
25
- */
26
- expand?: boolean;
27
19
  /**
28
20
  * @description Footer content to be displayed below the input area
29
21
  */
@@ -38,11 +30,6 @@ export interface ChatInputAreaProps extends TextAreaProps {
38
30
  * @default 200
39
31
  */
40
32
  minHeight?: number;
41
- /**
42
- * @description Callback function when the expand state changes
43
- * @param expand - Whether the input area is expanded
44
- */
45
- onExpandChange?: (expand: boolean) => void;
46
33
  /**
47
34
  * @description Callback function when the input value changes
48
35
  * @param value - The current value of the input area
@@ -5,10 +5,9 @@ var _excluded = ["text", "textareaClassName", "style", "textareaStyle", "minHeig
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 { Maximize2, Minimize2 } from 'lucide-react';
9
8
  import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
10
- import ActionIcon from "../ActionIcon";
11
9
  import { TextArea } from "../Input";
10
+ import Action from "./Action";
12
11
  import InputHighlight from "./InputHighlight";
13
12
  import { useStyles } from "./style";
14
13
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -41,17 +40,14 @@ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
41
40
  _ref$textareaId = _ref.textareaId,
42
41
  textareaId = _ref$textareaId === void 0 ? 'lobe-chat-input-area' : _ref$textareaId,
43
42
  props = _objectWithoutProperties(_ref, _excluded);
43
+ var _useStyles = useStyles(),
44
+ cx = _useStyles.cx,
45
+ styles = _useStyles.styles;
44
46
  var isChineseInput = useRef(false);
45
47
  var _useState = useState(defaultValue),
46
48
  _useState2 = _slicedToArray(_useState, 2),
47
49
  value = _useState2[0],
48
50
  setValue = _useState2[1];
49
- var _useStyles = useStyles(),
50
- cx = _useStyles.cx,
51
- styles = _useStyles.styles;
52
- var handleExpandClick = useCallback(function () {
53
- if (onExpandChange) onExpandChange(!expand);
54
- }, [expand]);
55
51
  var handleSend = useCallback(function () {
56
52
  if (disabled) return;
57
53
  if (onSend) onSend(value);
@@ -65,18 +61,10 @@ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
65
61
  style: _objectSpread({
66
62
  minHeight: minHeight
67
63
  }, style),
68
- children: [/*#__PURE__*/_jsxs("div", {
69
- className: styles.actionsBar,
70
- children: [/*#__PURE__*/_jsx("div", {
71
- className: styles.actionLeft,
72
- children: actions
73
- }), /*#__PURE__*/_jsx("div", {
74
- className: styles.actionsRight,
75
- children: /*#__PURE__*/_jsx(ActionIcon, {
76
- icon: expand ? Minimize2 : Maximize2,
77
- onClick: handleExpandClick
78
- })
79
- })]
64
+ children: [/*#__PURE__*/_jsx(Action, {
65
+ actions: actions,
66
+ expand: expand,
67
+ onExpandChange: onExpandChange
80
68
  }), /*#__PURE__*/_jsxs("div", {
81
69
  className: styles.textareaContainer,
82
70
  children: [/*#__PURE__*/_jsx(InputHighlight, {
@@ -50,16 +50,7 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
50
50
  placeholder: placeholder,
51
51
  style: styles === null || styles === void 0 ? void 0 : styles.input
52
52
  }) : /*#__PURE__*/_jsxs(_Fragment, {
53
- children: [/*#__PURE__*/_jsx(MessageModal, {
54
- editing: isEdit,
55
- onChange: function onChange(text) {
56
- _onChange === null || _onChange === void 0 ? void 0 : _onChange(text);
57
- },
58
- onEditingChange: setTyping,
59
- onOpenChange: setExpand,
60
- open: expand,
61
- value: value
62
- }), !expand && isEdit ? /*#__PURE__*/_jsx(MessageInput, {
53
+ children: [!expand && isEdit ? /*#__PURE__*/_jsx(MessageInput, {
63
54
  className: classNames === null || classNames === void 0 ? void 0 : classNames.input,
64
55
  defaultValue: value,
65
56
  editButtonSize: editButtonSize,
@@ -76,6 +67,15 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
76
67
  className: classNames === null || classNames === void 0 ? void 0 : classNames.markdown,
77
68
  style: styles === null || styles === void 0 ? void 0 : styles.markdown,
78
69
  children: value
70
+ }), /*#__PURE__*/_jsx(MessageModal, {
71
+ editing: isEdit,
72
+ onChange: function onChange(text) {
73
+ _onChange === null || _onChange === void 0 ? void 0 : _onChange(text);
74
+ },
75
+ onEditingChange: setTyping,
76
+ onOpenChange: setExpand,
77
+ open: expand,
78
+ value: value
79
79
  })]
80
80
  });
81
81
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.50.0",
3
+ "version": "1.50.1",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",