@lobehub/ui 1.91.0 → 1.93.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.
Files changed (43) hide show
  1. package/es/ActionIcon/index.js +1 -0
  2. package/es/ActionIcon/style.d.ts +1 -0
  3. package/es/ActionIcon/style.js +3 -2
  4. package/es/Avatar/index.js +4 -2
  5. package/es/ChatInputArea/Action.js +4 -2
  6. package/es/ChatInputArea/Desktop.d.ts +17 -0
  7. package/es/ChatInputArea/Desktop.js +131 -0
  8. package/es/ChatInputArea/Mobile.d.ts +17 -0
  9. package/es/ChatInputArea/Mobile.js +132 -0
  10. package/es/ChatInputArea/index.d.ts +15 -67
  11. package/es/ChatInputArea/index.js +11 -125
  12. package/es/ChatInputArea/style.mobile.d.ts +5 -0
  13. package/es/ChatInputArea/style.mobile.js +12 -0
  14. package/es/ChatInputArea/type.d.ts +33 -0
  15. package/es/ChatInputArea/type.js +1 -0
  16. package/es/ChatItem/components/Actions.d.ts +1 -0
  17. package/es/ChatItem/components/Actions.js +3 -1
  18. package/es/ChatItem/components/BorderSpacing.d.ts +1 -2
  19. package/es/ChatItem/components/MessageContent.js +2 -1
  20. package/es/ChatItem/components/Title.js +4 -1
  21. package/es/ChatItem/index.js +20 -10
  22. package/es/ChatItem/style.d.ts +4 -3
  23. package/es/ChatItem/style.js +18 -15
  24. package/es/ChatItem/type.d.ts +0 -4
  25. package/es/EmptyCard/index.d.ts +15 -0
  26. package/es/EmptyCard/index.js +67 -0
  27. package/es/EmptyCard/style.d.ts +7 -0
  28. package/es/EmptyCard/style.js +15 -0
  29. package/es/FluentEmoji/index.js +1 -4
  30. package/es/SearchBar/index.d.ts +3 -0
  31. package/es/SearchBar/index.js +13 -8
  32. package/es/SelectWithImg/index.d.ts +27 -0
  33. package/es/SelectWithImg/index.js +78 -0
  34. package/es/SelectWithImg/styles.d.ts +7 -0
  35. package/es/SelectWithImg/styles.js +17 -0
  36. package/es/SpotlightCard/SpotlightCardItem.js +1 -1
  37. package/es/SpotlightCard/index.d.ts +2 -1
  38. package/es/SpotlightCard/index.js +13 -4
  39. package/es/SpotlightCard/style.js +1 -1
  40. package/es/TokenTag/index.js +4 -1
  41. package/es/index.d.ts +2 -0
  42. package/es/index.js +2 -0
  43. package/package.json +1 -1
@@ -86,6 +86,7 @@ var ActionIcon = /*#__PURE__*/forwardRef(function (_ref, ref) {
86
86
  borderRadius = _useMemo.borderRadius;
87
87
  var content = /*#__PURE__*/_jsxs(_Fragment, {
88
88
  children: [icon && /*#__PURE__*/_jsx(Icon, {
89
+ className: styles.icon,
89
90
  color: color,
90
91
  fill: fill,
91
92
  icon: icon,
@@ -3,4 +3,5 @@ export declare const useStyles: (props?: {
3
3
  glass: boolean;
4
4
  } | undefined) => import("antd-style").ReturnStyles<{
5
5
  block: string;
6
+ icon: import("antd-style").SerializedStyles;
6
7
  }>;
@@ -1,5 +1,5 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
- var _templateObject;
2
+ var _templateObject, _templateObject2;
3
3
  import { createStyles } from 'antd-style';
4
4
  export var useStyles = createStyles(function (_ref, _ref2) {
5
5
  var css = _ref.css,
@@ -9,6 +9,7 @@ export var useStyles = createStyles(function (_ref, _ref2) {
9
9
  var active = _ref2.active,
10
10
  glass = _ref2.glass;
11
11
  return {
12
- block: cx(glass && stylish.blur, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n\n position: relative;\n\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n color: ", ";\n\n background: ", ";\n\n transition:\n color 600ms ", ",\n scale 400ms ", ",\n background-color 100ms ", ";\n\n &:hover {\n color: ", ";\n background-color: ", ";\n }\n\n &:active {\n scale: 0.8;\n color: ", ";\n background-color: ", ";\n }\n "])), active ? token.colorText : token.colorTextTertiary, active ? token.colorFillTertiary : 'transparent', token.motionEaseOut, token.motionEaseOut, token.motionEaseOut, token.colorText, token.colorFillSecondary, token.colorText, token.colorFill))
12
+ block: cx(glass && stylish.blur, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n cursor: pointer;\n\n position: relative;\n\n display: flex;\n flex: none;\n align-items: center;\n justify-content: center;\n\n color: ", ";\n\n background: ", ";\n\n transition:\n color 600ms ", ",\n scale 400ms ", ",\n background-color 100ms ", ";\n\n &:hover {\n color: ", ";\n background-color: ", ";\n }\n\n &:active {\n color: ", ";\n background-color: ", ";\n }\n "])), active ? token.colorText : token.colorTextTertiary, active ? token.colorFillTertiary : 'transparent', token.motionEaseOut, token.motionEaseOut, token.motionEaseOut, token.colorText, token.colorFillSecondary, token.colorText, token.colorFill)),
13
+ icon: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n transition: scale 400ms ", ";\n\n &:active {\n scale: 0.8;\n }\n "])), token.motionEaseOut)
13
14
  };
14
15
  });
@@ -4,7 +4,7 @@ var _excluded = ["className", "avatar", "title", "animation", "size", "shape", "
4
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
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
6
  import { Avatar as AntAvatar } from 'antd';
7
- import { memo } from 'react';
7
+ import { memo, useMemo } from 'react';
8
8
  import FluentEmoji from "../FluentEmoji";
9
9
  import { getEmoji } from "../utils/getEmojiByCharacter";
10
10
  import { useStyles } from "./style";
@@ -24,7 +24,9 @@ var Avatar = /*#__PURE__*/memo(function (_ref) {
24
24
  var isImage = Boolean(avatar && ['/', 'http', 'data:'].some(function (index) {
25
25
  return avatar.startsWith(index);
26
26
  }));
27
- var emoji = avatar && !isImage && getEmoji(avatar);
27
+ var emoji = useMemo(function () {
28
+ return avatar && !isImage && getEmoji(avatar);
29
+ }, [avatar]);
28
30
  var _useStyles = useStyles({
29
31
  background: background,
30
32
  isEmoji: Boolean(emoji),
@@ -1,6 +1,6 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
2
  var _templateObject, _templateObject2, _templateObject3;
3
- import { createStyles } from 'antd-style';
3
+ import { createStyles, useResponsive } from 'antd-style';
4
4
  import { Maximize2, Minimize2 } from 'lucide-react';
5
5
  import { memo, useCallback } from 'react';
6
6
  import ActionIcon from "../ActionIcon";
@@ -21,6 +21,8 @@ var Action = /*#__PURE__*/memo(function (_ref2) {
21
21
  onExpandChange = _ref2.onExpandChange;
22
22
  var _useStyles = useStyles(),
23
23
  styles = _useStyles.styles;
24
+ var _useResponsive = useResponsive(),
25
+ mobile = _useResponsive.mobile;
24
26
  var handleExpandClick = useCallback(function () {
25
27
  if (onExpandChange) onExpandChange(!expand);
26
28
  }, [expand]);
@@ -31,7 +33,7 @@ var Action = /*#__PURE__*/memo(function (_ref2) {
31
33
  children: actions
32
34
  }), /*#__PURE__*/_jsxs("div", {
33
35
  className: styles.actionsRight,
34
- children: [actionsRight, /*#__PURE__*/_jsx(ActionIcon, {
36
+ children: [actionsRight, !mobile && /*#__PURE__*/_jsx(ActionIcon, {
35
37
  icon: expand ? Minimize2 : Maximize2,
36
38
  onClick: handleExpandClick
37
39
  })]
@@ -0,0 +1,17 @@
1
+ import { type InputRef } from 'antd';
2
+ import { CSSProperties } from 'react';
3
+ import { type TextAreaProps } from "../Input";
4
+ import type { ChatInputBase } from './type';
5
+ export type ChatInputAreaDesktop = ChatInputBase & TextAreaProps & {
6
+ minHeight?: number;
7
+ textareaClassName?: string;
8
+ textareaId?: string;
9
+ textareaStyle?: CSSProperties;
10
+ };
11
+ declare const ChatInputArea: import("react").ForwardRefExoticComponent<ChatInputBase & TextAreaProps & {
12
+ minHeight?: number | undefined;
13
+ textareaClassName?: string | undefined;
14
+ textareaId?: string | undefined;
15
+ textareaStyle?: CSSProperties | undefined;
16
+ } & import("react").RefAttributes<InputRef>>;
17
+ export default ChatInputArea;
@@ -0,0 +1,131 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
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", "onStop", "value"];
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
+ 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
+ import { Button } from 'antd';
8
+ import { Loader2 } from 'lucide-react';
9
+ import { forwardRef, useCallback, useRef } from 'react';
10
+ import useControlledState from 'use-merge-value';
11
+ import Icon from "../Icon";
12
+ import { TextArea } from "../Input";
13
+ import Action from "./Action";
14
+ import { useStyles } from "./style";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ import { jsxs as _jsxs } from "react/jsx-runtime";
17
+ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
18
+ var text = _ref.text,
19
+ textareaClassName = _ref.textareaClassName,
20
+ style = _ref.style,
21
+ textareaStyle = _ref.textareaStyle,
22
+ _ref$minHeight = _ref.minHeight,
23
+ minHeight = _ref$minHeight === void 0 ? 200 : _ref$minHeight,
24
+ className = _ref.className,
25
+ actions = _ref.actions,
26
+ footer = _ref.footer,
27
+ expand = _ref.expand,
28
+ _ref$placeholder = _ref.placeholder,
29
+ placeholder = _ref$placeholder === void 0 ? 'Type something to chat...' : _ref$placeholder,
30
+ onExpandChange = _ref.onExpandChange,
31
+ onSend = _ref.onSend,
32
+ _ref$defaultValue = _ref.defaultValue,
33
+ defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
34
+ loading = _ref.loading,
35
+ disabled = _ref.disabled,
36
+ onInputChange = _ref.onInputChange,
37
+ _onPressEnter = _ref.onPressEnter,
38
+ _onCompositionStart = _ref.onCompositionStart,
39
+ _onCompositionEnd = _ref.onCompositionEnd,
40
+ _onBlur = _ref.onBlur,
41
+ _onChange = _ref.onChange,
42
+ _ref$textareaId = _ref.textareaId,
43
+ textareaId = _ref$textareaId === void 0 ? 'lobe-chat-input-area' : _ref$textareaId,
44
+ actionsRight = _ref.actionsRight,
45
+ onStop = _ref.onStop,
46
+ value = _ref.value,
47
+ props = _objectWithoutProperties(_ref, _excluded);
48
+ var _useControlledState = useControlledState(defaultValue, {
49
+ defaultValue: defaultValue,
50
+ onChange: onInputChange,
51
+ value: value
52
+ }),
53
+ _useControlledState2 = _slicedToArray(_useControlledState, 2),
54
+ currentValue = _useControlledState2[0],
55
+ setCurrentValue = _useControlledState2[1];
56
+ var _useStyles = useStyles(),
57
+ cx = _useStyles.cx,
58
+ styles = _useStyles.styles;
59
+ var isChineseInput = useRef(false);
60
+ var handleSend = useCallback(function () {
61
+ if (loading && disabled) return;
62
+ if (onSend) onSend(currentValue);
63
+ setCurrentValue('');
64
+ }, [disabled, currentValue]);
65
+ return /*#__PURE__*/_jsxs("section", {
66
+ className: cx(styles.container, className),
67
+ style: _objectSpread({
68
+ minHeight: minHeight
69
+ }, style),
70
+ children: [/*#__PURE__*/_jsx(Action, {
71
+ actions: actions,
72
+ actionsRight: actionsRight,
73
+ expand: expand,
74
+ onExpandChange: onExpandChange
75
+ }), /*#__PURE__*/_jsx("div", {
76
+ className: styles.textareaContainer,
77
+ children: /*#__PURE__*/_jsx(TextArea, _objectSpread(_objectSpread({
78
+ className: cx(styles.textarea, textareaClassName),
79
+ defaultValue: defaultValue,
80
+ id: textareaId,
81
+ ref: ref,
82
+ style: textareaStyle
83
+ }, props), {}, {
84
+ onBlur: function onBlur(e) {
85
+ if (_onBlur) _onBlur(e);
86
+ setCurrentValue(e.target.value);
87
+ },
88
+ onChange: function onChange(e) {
89
+ if (_onChange) _onChange(e);
90
+ setCurrentValue(e.target.value);
91
+ },
92
+ onCompositionEnd: function onCompositionEnd(e) {
93
+ if (_onCompositionEnd) _onCompositionEnd(e);
94
+ isChineseInput.current = false;
95
+ },
96
+ onCompositionStart: function onCompositionStart(e) {
97
+ if (_onCompositionStart) _onCompositionStart(e);
98
+ isChineseInput.current = true;
99
+ },
100
+ onPressEnter: function onPressEnter(e) {
101
+ if (_onPressEnter) _onPressEnter(e);
102
+ if (!loading && !e.shiftKey && !isChineseInput.current) {
103
+ e.preventDefault();
104
+ handleSend();
105
+ }
106
+ },
107
+ placeholder: placeholder,
108
+ resize: false,
109
+ type: "pure",
110
+ value: currentValue
111
+ }))
112
+ }), /*#__PURE__*/_jsxs("div", {
113
+ className: styles.footerBar,
114
+ children: [footer, loading ? /*#__PURE__*/_jsx(Button, {
115
+ disabled: disabled,
116
+ icon: loading && /*#__PURE__*/_jsx(Icon, {
117
+ icon: Loader2,
118
+ spin: true
119
+ }),
120
+ onClick: onStop,
121
+ children: (text === null || text === void 0 ? void 0 : text.stop) || 'Stop'
122
+ }) : /*#__PURE__*/_jsx(Button, {
123
+ disabled: disabled,
124
+ onClick: handleSend,
125
+ type: 'primary',
126
+ children: (text === null || text === void 0 ? void 0 : text.send) || 'Send'
127
+ })]
128
+ })]
129
+ });
130
+ });
131
+ export default ChatInputArea;
@@ -0,0 +1,17 @@
1
+ import { type InputRef } from 'antd';
2
+ import { CSSProperties } from 'react';
3
+ import { type InputProps } from "../Input";
4
+ import type { ChatInputBase } from './type';
5
+ export type ChatInputAreaMobile = ChatInputBase & InputProps & {
6
+ inputClassName?: string;
7
+ inputId?: string;
8
+ inputStyle?: CSSProperties;
9
+ minHeight?: number;
10
+ };
11
+ declare const ChatInputArea: import("react").ForwardRefExoticComponent<ChatInputBase & InputProps & {
12
+ inputClassName?: string | undefined;
13
+ inputId?: string | undefined;
14
+ inputStyle?: CSSProperties | undefined;
15
+ minHeight?: number | undefined;
16
+ } & import("react").RefAttributes<InputRef>>;
17
+ export default ChatInputArea;
@@ -0,0 +1,132 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
+ var _excluded = ["inputClassName", "style", "inputStyle", "minHeight", "className", "actions", "expand", "placeholder", "onExpandChange", "onSend", "defaultValue", "loading", "disabled", "onInputChange", "onPressEnter", "onCompositionStart", "onCompositionEnd", "onBlur", "onChange", "inputId", "actionsRight", "onStop", "value"];
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
+ 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
+ import { Button } from 'antd';
8
+ import { Loader2, SendHorizonal } from 'lucide-react';
9
+ import { forwardRef, useCallback, useRef } from 'react';
10
+ import { Flexbox } from 'react-layout-kit';
11
+ import useControlledState from 'use-merge-value';
12
+ import Icon from "../Icon";
13
+ import { Input } from "../Input";
14
+ import Action from "./Action";
15
+ import { useStyles } from "./style.mobile";
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { jsxs as _jsxs } from "react/jsx-runtime";
18
+ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
19
+ var inputClassName = _ref.inputClassName,
20
+ style = _ref.style,
21
+ inputStyle = _ref.inputStyle,
22
+ _ref$minHeight = _ref.minHeight,
23
+ minHeight = _ref$minHeight === void 0 ? 200 : _ref$minHeight,
24
+ className = _ref.className,
25
+ actions = _ref.actions,
26
+ expand = _ref.expand,
27
+ _ref$placeholder = _ref.placeholder,
28
+ placeholder = _ref$placeholder === void 0 ? 'Type something to chat...' : _ref$placeholder,
29
+ onExpandChange = _ref.onExpandChange,
30
+ onSend = _ref.onSend,
31
+ _ref$defaultValue = _ref.defaultValue,
32
+ defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
33
+ loading = _ref.loading,
34
+ disabled = _ref.disabled,
35
+ onInputChange = _ref.onInputChange,
36
+ _onPressEnter = _ref.onPressEnter,
37
+ _onCompositionStart = _ref.onCompositionStart,
38
+ _onCompositionEnd = _ref.onCompositionEnd,
39
+ _onBlur = _ref.onBlur,
40
+ _onChange = _ref.onChange,
41
+ _ref$inputId = _ref.inputId,
42
+ inputId = _ref$inputId === void 0 ? 'lobe-chat-input-area' : _ref$inputId,
43
+ actionsRight = _ref.actionsRight,
44
+ onStop = _ref.onStop,
45
+ value = _ref.value,
46
+ props = _objectWithoutProperties(_ref, _excluded);
47
+ var _useControlledState = useControlledState(defaultValue, {
48
+ defaultValue: defaultValue,
49
+ onChange: onInputChange,
50
+ value: value
51
+ }),
52
+ _useControlledState2 = _slicedToArray(_useControlledState, 2),
53
+ currentValue = _useControlledState2[0],
54
+ setCurrentValue = _useControlledState2[1];
55
+ var _useStyles = useStyles(),
56
+ cx = _useStyles.cx,
57
+ styles = _useStyles.styles;
58
+ var isChineseInput = useRef(false);
59
+ var handleSend = useCallback(function () {
60
+ if (loading && disabled) return;
61
+ if (onSend) onSend(currentValue);
62
+ setCurrentValue('');
63
+ }, [disabled, currentValue]);
64
+ return /*#__PURE__*/_jsxs(Flexbox, {
65
+ className: cx(styles.container, className),
66
+ gap: 12,
67
+ style: _objectSpread({
68
+ minHeight: minHeight
69
+ }, style),
70
+ children: [/*#__PURE__*/_jsx(Action, {
71
+ actions: actions,
72
+ actionsRight: actionsRight,
73
+ expand: expand,
74
+ onExpandChange: onExpandChange
75
+ }), /*#__PURE__*/_jsxs(Flexbox, {
76
+ className: styles.inner,
77
+ gap: 8,
78
+ horizontal: true,
79
+ children: [/*#__PURE__*/_jsx(Input, _objectSpread(_objectSpread({
80
+ className: cx(styles.input, inputClassName),
81
+ defaultValue: defaultValue,
82
+ id: inputId,
83
+ ref: ref,
84
+ style: inputStyle
85
+ }, props), {}, {
86
+ onBlur: function onBlur(e) {
87
+ if (_onBlur) _onBlur(e);
88
+ setCurrentValue(e.target.value);
89
+ },
90
+ onChange: function onChange(e) {
91
+ if (_onChange) _onChange(e);
92
+ setCurrentValue(e.target.value);
93
+ },
94
+ onCompositionEnd: function onCompositionEnd(e) {
95
+ if (_onCompositionEnd) _onCompositionEnd(e);
96
+ isChineseInput.current = false;
97
+ },
98
+ onCompositionStart: function onCompositionStart(e) {
99
+ if (_onCompositionStart) _onCompositionStart(e);
100
+ isChineseInput.current = true;
101
+ },
102
+ onPressEnter: function onPressEnter(e) {
103
+ if (_onPressEnter) _onPressEnter(e);
104
+ if (!loading && !e.shiftKey && !isChineseInput.current) {
105
+ e.preventDefault();
106
+ handleSend();
107
+ }
108
+ },
109
+ placeholder: placeholder,
110
+ type: 'block',
111
+ value: currentValue
112
+ })), /*#__PURE__*/_jsx("div", {
113
+ children: loading ? /*#__PURE__*/_jsx(Button, {
114
+ disabled: disabled,
115
+ icon: loading && /*#__PURE__*/_jsx(Icon, {
116
+ icon: Loader2,
117
+ spin: true
118
+ }),
119
+ onClick: onStop
120
+ }) : /*#__PURE__*/_jsx(Button, {
121
+ disabled: disabled,
122
+ icon: /*#__PURE__*/_jsx(Icon, {
123
+ icon: SendHorizonal
124
+ }),
125
+ onClick: handleSend,
126
+ type: 'primary'
127
+ })
128
+ })]
129
+ })]
130
+ });
131
+ });
132
+ export default ChatInputArea;
@@ -1,69 +1,17 @@
1
+ /// <reference types="react" />
1
2
  import { type InputRef } from 'antd';
2
- import { CSSProperties, ReactNode } from 'react';
3
- import { type TextAreaProps } from "../Input";
4
- import { ActionProps } from './Action';
5
- export interface ChatInputAreaProps extends ActionProps, TextAreaProps {
6
- /**
7
- * @description Additional class name for the component
8
- */
9
- className?: string;
10
- /**
11
- * @description Default value for the input area
12
- */
13
- defaultValue?: string;
14
- /**
15
- * @description Whether the input area is disabled
16
- * @default false
17
- */
18
- disabled?: boolean;
19
- /**
20
- * @description Footer content to be displayed below the input area
21
- */
22
- footer?: ReactNode;
23
- /**
24
- * @description Whether the input area is in loading state
25
- * @default false
26
- */
27
- loading?: boolean;
28
- /**
29
- * @description Minimum height of the input area
30
- * @default 200
31
- */
32
- minHeight?: number;
33
- /**
34
- * @description Callback function when the input value changes
35
- * @param value - The current value of the input area
36
- */
37
- onInputChange?: (value: string) => void;
38
- /**
39
- * @description Callback function when the send button is clicked
40
- * @param value - The current value of the input area
41
- */
42
- onSend?: (value: string) => void;
43
- onStop?: () => void;
44
- /**
45
- * @description Placeholder text for the input area
46
- * @default 'Type something to chat...'
47
- */
48
- placeholder?: string;
49
- /**
50
- * @description CSS styles for the component
51
- */
52
- style?: CSSProperties;
53
- text?: {
54
- send?: string;
55
- stop?: string;
56
- };
57
- /**
58
- * @description Additional class name for the textarea element
59
- */
60
- textareaClassName?: string;
61
- textareaId?: string;
62
- /**
63
- * @description CSS styles for the textarea element
64
- */
65
- textareaStyle?: CSSProperties;
66
- value?: string;
67
- }
68
- declare const ChatInputArea: import("react").ForwardRefExoticComponent<ChatInputAreaProps & import("react").RefAttributes<InputRef>>;
3
+ import { ChatInputAreaDesktop } from './Desktop';
4
+ import { ChatInputAreaMobile } from './Mobile';
5
+ export type ChatInputAreaProps = ChatInputAreaDesktop & ChatInputAreaMobile;
6
+ declare const ChatInputArea: import("react").ForwardRefExoticComponent<import("./type").ChatInputBase & import("..").TextAreaProps & {
7
+ minHeight?: number | undefined;
8
+ textareaClassName?: string | undefined;
9
+ textareaId?: string | undefined;
10
+ textareaStyle?: import("react").CSSProperties | undefined;
11
+ } & import("..").InputProps & {
12
+ inputClassName?: string | undefined;
13
+ inputId?: string | undefined;
14
+ inputStyle?: import("react").CSSProperties | undefined;
15
+ minHeight?: number | undefined;
16
+ } & import("react").RefAttributes<InputRef>>;
69
17
  export default ChatInputArea;
@@ -1,131 +1,17 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
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", "onStop", "value"];
5
2
  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
3
  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
- import { Button } from 'antd';
8
- import { Loader2 } from 'lucide-react';
9
- import { forwardRef, useCallback, useRef } from 'react';
10
- import useControlledState from 'use-merge-value';
11
- import Icon from "../Icon";
12
- import { TextArea } from "../Input";
13
- import Action from "./Action";
14
- import { useStyles } from "./style";
4
+ import { useResponsive } from 'antd-style';
5
+ import { forwardRef } from 'react';
6
+ import Desktop from "./Desktop";
7
+ import Mobile from "./Mobile";
15
8
  import { jsx as _jsx } from "react/jsx-runtime";
16
- import { jsxs as _jsxs } from "react/jsx-runtime";
17
- var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
18
- var text = _ref.text,
19
- textareaClassName = _ref.textareaClassName,
20
- style = _ref.style,
21
- textareaStyle = _ref.textareaStyle,
22
- _ref$minHeight = _ref.minHeight,
23
- minHeight = _ref$minHeight === void 0 ? 200 : _ref$minHeight,
24
- className = _ref.className,
25
- actions = _ref.actions,
26
- footer = _ref.footer,
27
- expand = _ref.expand,
28
- _ref$placeholder = _ref.placeholder,
29
- placeholder = _ref$placeholder === void 0 ? 'Type something to chat...' : _ref$placeholder,
30
- onExpandChange = _ref.onExpandChange,
31
- onSend = _ref.onSend,
32
- _ref$defaultValue = _ref.defaultValue,
33
- defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
34
- loading = _ref.loading,
35
- disabled = _ref.disabled,
36
- onInputChange = _ref.onInputChange,
37
- _onPressEnter = _ref.onPressEnter,
38
- _onCompositionStart = _ref.onCompositionStart,
39
- _onCompositionEnd = _ref.onCompositionEnd,
40
- _onBlur = _ref.onBlur,
41
- _onChange = _ref.onChange,
42
- _ref$textareaId = _ref.textareaId,
43
- textareaId = _ref$textareaId === void 0 ? 'lobe-chat-input-area' : _ref$textareaId,
44
- actionsRight = _ref.actionsRight,
45
- onStop = _ref.onStop,
46
- value = _ref.value,
47
- props = _objectWithoutProperties(_ref, _excluded);
48
- var _useControlledState = useControlledState(defaultValue, {
49
- defaultValue: defaultValue,
50
- onChange: onInputChange,
51
- value: value
52
- }),
53
- _useControlledState2 = _slicedToArray(_useControlledState, 2),
54
- currentValue = _useControlledState2[0],
55
- setCurrentValue = _useControlledState2[1];
56
- var _useStyles = useStyles(),
57
- cx = _useStyles.cx,
58
- styles = _useStyles.styles;
59
- var isChineseInput = useRef(false);
60
- var handleSend = useCallback(function () {
61
- if (loading && disabled) return;
62
- if (onSend) onSend(currentValue);
63
- setCurrentValue('');
64
- }, [disabled, currentValue]);
65
- return /*#__PURE__*/_jsxs("section", {
66
- className: cx(styles.container, className),
67
- style: _objectSpread({
68
- minHeight: minHeight
69
- }, style),
70
- children: [/*#__PURE__*/_jsx(Action, {
71
- actions: actions,
72
- actionsRight: actionsRight,
73
- expand: expand,
74
- onExpandChange: onExpandChange
75
- }), /*#__PURE__*/_jsx("div", {
76
- className: styles.textareaContainer,
77
- children: /*#__PURE__*/_jsx(TextArea, _objectSpread(_objectSpread({
78
- className: cx(styles.textarea, textareaClassName),
79
- defaultValue: defaultValue,
80
- id: textareaId,
81
- ref: ref,
82
- style: textareaStyle
83
- }, props), {}, {
84
- onBlur: function onBlur(e) {
85
- if (_onBlur) _onBlur(e);
86
- setCurrentValue(e.target.value);
87
- },
88
- onChange: function onChange(e) {
89
- if (_onChange) _onChange(e);
90
- setCurrentValue(e.target.value);
91
- },
92
- onCompositionEnd: function onCompositionEnd(e) {
93
- if (_onCompositionEnd) _onCompositionEnd(e);
94
- isChineseInput.current = false;
95
- },
96
- onCompositionStart: function onCompositionStart(e) {
97
- if (_onCompositionStart) _onCompositionStart(e);
98
- isChineseInput.current = true;
99
- },
100
- onPressEnter: function onPressEnter(e) {
101
- if (_onPressEnter) _onPressEnter(e);
102
- if (!loading && !e.shiftKey && !isChineseInput.current) {
103
- e.preventDefault();
104
- handleSend();
105
- }
106
- },
107
- placeholder: placeholder,
108
- resize: false,
109
- type: "pure",
110
- value: currentValue
111
- }))
112
- }), /*#__PURE__*/_jsxs("div", {
113
- className: styles.footerBar,
114
- children: [footer, loading ? /*#__PURE__*/_jsx(Button, {
115
- disabled: disabled,
116
- icon: loading && /*#__PURE__*/_jsx(Icon, {
117
- icon: Loader2,
118
- spin: true
119
- }),
120
- onClick: onStop,
121
- children: (text === null || text === void 0 ? void 0 : text.stop) || 'Stop'
122
- }) : /*#__PURE__*/_jsx(Button, {
123
- disabled: disabled,
124
- onClick: handleSend,
125
- type: 'primary',
126
- children: (text === null || text === void 0 ? void 0 : text.send) || 'Send'
127
- })]
128
- })]
129
- });
9
+ var ChatInputArea = /*#__PURE__*/forwardRef(function (props, ref) {
10
+ var _useResponsive = useResponsive(),
11
+ mobile = _useResponsive.mobile;
12
+ var Render = mobile ? Mobile : Desktop;
13
+ return /*#__PURE__*/_jsx(Render, _objectSpread({
14
+ ref: ref
15
+ }, props));
130
16
  });
131
17
  export default ChatInputArea;
@@ -0,0 +1,5 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ container: import("antd-style").SerializedStyles;
3
+ inner: import("antd-style").SerializedStyles;
4
+ input: import("antd-style").SerializedStyles;
5
+ }>;
@@ -0,0 +1,12 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref) {
5
+ var css = _ref.css,
6
+ token = _ref.token;
7
+ return {
8
+ container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 12px 0;\n "]))),
9
+ inner: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: 0 16px;\n "]))),
10
+ input: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background: ", " !important;\n border: none !important;\n "])), token.colorFillSecondary)
11
+ };
12
+ });