@lobehub/ui 1.120.7 → 1.120.8

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 (36) hide show
  1. package/es/ActionIcon/calcSize.d.ts +2 -2
  2. package/es/ActionIcon/index.d.ts +2 -2
  3. package/es/BackBottom/index.js +1 -8
  4. package/es/BackBottom/style.js +4 -2
  5. package/es/ChatInputArea/ChatInputActionBar.d.ts +9 -0
  6. package/es/ChatInputArea/ChatInputActionBar.js +52 -0
  7. package/es/ChatInputArea/ChatInputAreaInner.d.ts +12 -0
  8. package/es/ChatInputArea/ChatInputAreaInner.js +52 -0
  9. package/es/ChatInputArea/desktop/ChatInputArea.d.ts +19 -0
  10. package/es/ChatInputArea/desktop/ChatInputArea.js +81 -0
  11. package/es/ChatInputArea/desktop/SendButton.d.ts +17 -0
  12. package/es/ChatInputArea/desktop/SendButton.js +76 -0
  13. package/es/ChatInputArea/index.d.ts +6 -18
  14. package/es/ChatInputArea/index.js +6 -17
  15. package/es/ChatInputArea/mobile/ChatInputArea.d.ts +14 -0
  16. package/es/ChatInputArea/mobile/ChatInputArea.js +146 -0
  17. package/es/ChatInputArea/mobile/SendButton.d.ts +8 -0
  18. package/es/ChatInputArea/mobile/SendButton.js +33 -0
  19. package/es/Icon/index.d.ts +1 -1
  20. package/es/Input/index.js +4 -4
  21. package/es/MessageModal/index.js +9 -2
  22. package/es/index.d.ts +1 -1
  23. package/es/index.js +1 -1
  24. package/package.json +1 -1
  25. package/es/ChatInputArea/Action.d.ts +0 -12
  26. package/es/ChatInputArea/Action.js +0 -43
  27. package/es/ChatInputArea/Desktop.d.ts +0 -17
  28. package/es/ChatInputArea/Desktop.js +0 -131
  29. package/es/ChatInputArea/Mobile.d.ts +0 -19
  30. package/es/ChatInputArea/Mobile.js +0 -136
  31. package/es/ChatInputArea/style.d.ts +0 -9
  32. package/es/ChatInputArea/style.js +0 -15
  33. package/es/ChatInputArea/style.mobile.d.ts +0 -5
  34. package/es/ChatInputArea/style.mobile.js +0 -13
  35. package/es/ChatInputArea/type.d.ts +0 -33
  36. package/es/ChatInputArea/type.js +0 -1
@@ -1,5 +1,5 @@
1
1
  import { ActionIconSize } from "./index";
2
2
  export declare const calcSize: (size?: ActionIconSize) => {
3
- blockSize: number;
4
- borderRadius: number;
3
+ blockSize: string | number;
4
+ borderRadius: string | number;
5
5
  };
@@ -2,8 +2,8 @@
2
2
  import { type IconProps, type IconSizeConfig, type IconSizeType } from "../Icon";
3
3
  import { type TooltipProps } from "../Tooltip";
4
4
  interface ActionIconSizeConfig extends IconSizeConfig {
5
- blockSize?: number;
6
- borderRadius?: number;
5
+ blockSize?: number | string;
6
+ borderRadius?: number | string;
7
7
  }
8
8
  type ActionIconSizeType = 'site' | IconSizeType;
9
9
  export type ActionIconSize = ActionIconSizeType | ActionIconSizeConfig;
@@ -1,7 +1,4 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
2
  import { useScroll } from 'ahooks';
6
3
  import { Button } from 'antd';
7
4
  import { ListEnd } from 'lucide-react';
@@ -51,11 +48,7 @@ var BackBottom = /*#__PURE__*/memo(function (_ref) {
51
48
  onClick: scrollToBottom,
52
49
  ref: ref,
53
50
  size: 'small',
54
- style: _objectSpread({
55
- bottom: 16,
56
- position: 'absolute',
57
- right: 16
58
- }, style),
51
+ style: style,
59
52
  children: text || 'Back to bottom'
60
53
  });
61
54
  });
@@ -1,10 +1,12 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
2
  var _templateObject;
3
3
  import { createStyles } from 'antd-style';
4
+ import { rgba } from 'polished';
4
5
  export var useStyles = createStyles(function (_ref, visible) {
5
6
  var token = _ref.token,
6
7
  css = _ref.css,
7
8
  stylish = _ref.stylish,
8
- cx = _ref.cx;
9
- return cx(stylish.blur, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n pointer-events: ", ";\n\n transform: translateY(", ");\n\n padding-inline: 12px !important;\n\n opacity: ", ";\n background: ", ";\n border-color: ", " !important;\n border-radius: 16px !important;\n "])), visible ? 'all' : 'none', visible ? 0 : '16px', visible ? 1 : 0, token.colorFillSecondary, token.colorFillTertiary));
9
+ cx = _ref.cx,
10
+ responsive = _ref.responsive;
11
+ return cx(stylish.blur, css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n pointer-events: ", ";\n\n position: absolute;\n right: 16px;\n bottom: 16px;\n transform: translateY(", ");\n\n padding-inline: 12px !important;\n\n opacity: ", ";\n background: ", ";\n border-color: ", " !important;\n border-radius: 16px !important;\n\n ", " {\n right: 0;\n border-right: none;\n border-top-right-radius: 0 !important;\n border-bottom-right-radius: 0 !important;\n }\n "])), visible ? 'all' : 'none', visible ? 0 : '16px', visible ? 1 : 0, rgba(token.colorBgContainer, 0.5), token.colorFillTertiary, responsive.mobile));
10
12
  });
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from 'react';
2
+ export interface ChatInputActionBarProps {
3
+ leftAddons?: ReactNode;
4
+ mobile?: boolean;
5
+ padding?: number | string;
6
+ rightAddons?: ReactNode;
7
+ }
8
+ declare const ChatInputActionBar: import("react").NamedExoticComponent<ChatInputActionBarProps>;
9
+ export default ChatInputActionBar;
@@ -0,0 +1,52 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3;
3
+ import { createStyles, useResponsive } from 'antd-style';
4
+ import { memo } from 'react';
5
+ import { Flexbox } from 'react-layout-kit';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ var useStyles = createStyles(function (_ref) {
9
+ var css = _ref.css,
10
+ cx = _ref.cx,
11
+ stylish = _ref.stylish;
12
+ return {
13
+ container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n width: 100%;\n "]))),
14
+ left: cx(stylish.noScrollbar, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n overflow: auto hidden;\n "])))),
15
+ right: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([""])))
16
+ };
17
+ });
18
+ var ChatInputActionBar = /*#__PURE__*/memo(function (_ref2) {
19
+ var _ref2$padding = _ref2.padding,
20
+ padding = _ref2$padding === void 0 ? '0 16px' : _ref2$padding,
21
+ leftAddons = _ref2.leftAddons,
22
+ rightAddons = _ref2.rightAddons;
23
+ var _useResponsive = useResponsive(),
24
+ mobile = _useResponsive.mobile;
25
+ var _useStyles = useStyles(),
26
+ styles = _useStyles.styles;
27
+ return /*#__PURE__*/_jsxs(Flexbox, {
28
+ align: 'center',
29
+ className: styles.container,
30
+ flex: 'none',
31
+ horizontal: true,
32
+ justify: 'space-between',
33
+ padding: padding,
34
+ children: [/*#__PURE__*/_jsx(Flexbox, {
35
+ align: 'center',
36
+ className: styles.left,
37
+ flex: 1,
38
+ gap: mobile ? 0 : 4,
39
+ horizontal: true,
40
+ children: leftAddons
41
+ }), /*#__PURE__*/_jsx(Flexbox, {
42
+ align: 'center',
43
+ className: styles.right,
44
+ flex: 0,
45
+ gap: mobile ? 0 : 4,
46
+ horizontal: true,
47
+ justify: 'flex-end',
48
+ children: rightAddons
49
+ })]
50
+ });
51
+ });
52
+ export default ChatInputActionBar;
@@ -0,0 +1,12 @@
1
+ import { TextAreaRef } from 'antd/es/input/TextArea';
2
+ import { CSSProperties } from 'react';
3
+ import { TextAreaProps } from "../Input";
4
+ export interface ChatInputAreaInnerProps extends Omit<TextAreaProps, 'onInput'> {
5
+ className?: string;
6
+ loading?: boolean;
7
+ onInput?: (value: string) => void;
8
+ onSend?: () => void;
9
+ style?: CSSProperties;
10
+ }
11
+ declare const ChatInputAreaInner: import("react").ForwardRefExoticComponent<ChatInputAreaInnerProps & import("react").RefAttributes<TextAreaRef>>;
12
+ export default ChatInputAreaInner;
@@ -0,0 +1,52 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["resize", "onCompositionEnd", "onPressEnter", "onCompositionStart", "className", "onInput", "loading", "onSend", "onBlur", "onChange"];
4
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
5
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
6
+ import { forwardRef, useRef } from 'react';
7
+ import { TextArea } from "../Input";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ var ChatInputAreaInner = /*#__PURE__*/forwardRef(function (_ref, ref) {
10
+ var _ref$resize = _ref.resize,
11
+ resize = _ref$resize === void 0 ? false : _ref$resize,
12
+ _onCompositionEnd = _ref.onCompositionEnd,
13
+ _onPressEnter = _ref.onPressEnter,
14
+ _onCompositionStart = _ref.onCompositionStart,
15
+ className = _ref.className,
16
+ onInput = _ref.onInput,
17
+ loading = _ref.loading,
18
+ onSend = _ref.onSend,
19
+ _onBlur = _ref.onBlur,
20
+ _onChange = _ref.onChange,
21
+ rest = _objectWithoutProperties(_ref, _excluded);
22
+ var isChineseInput = useRef(false);
23
+ return /*#__PURE__*/_jsx(TextArea, _objectSpread({
24
+ className: className,
25
+ onBlur: function onBlur(e) {
26
+ onInput === null || onInput === void 0 || onInput(e.target.value);
27
+ _onBlur === null || _onBlur === void 0 || _onBlur(e);
28
+ },
29
+ onChange: function onChange(e) {
30
+ onInput === null || onInput === void 0 || onInput(e.target.value);
31
+ _onChange === null || _onChange === void 0 || _onChange(e);
32
+ },
33
+ onCompositionEnd: function onCompositionEnd(e) {
34
+ isChineseInput.current = false;
35
+ _onCompositionEnd === null || _onCompositionEnd === void 0 || _onCompositionEnd(e);
36
+ },
37
+ onCompositionStart: function onCompositionStart(e) {
38
+ isChineseInput.current = true;
39
+ _onCompositionStart === null || _onCompositionStart === void 0 || _onCompositionStart(e);
40
+ },
41
+ onPressEnter: function onPressEnter(e) {
42
+ _onPressEnter === null || _onPressEnter === void 0 || _onPressEnter(e);
43
+ if (!loading && !e.shiftKey && !isChineseInput.current) {
44
+ e.preventDefault();
45
+ onSend === null || onSend === void 0 || onSend();
46
+ }
47
+ },
48
+ ref: ref,
49
+ resize: resize
50
+ }, rest));
51
+ });
52
+ export default ChatInputAreaInner;
@@ -0,0 +1,19 @@
1
+ import { TextAreaRef } from 'antd/es/input/TextArea';
2
+ import { ReactNode } from 'react';
3
+ import { type DraggablePanelProps } from "../../DraggablePanel";
4
+ import { type ChatInputAreaInnerProps } from '../ChatInputAreaInner';
5
+ export interface ChatInputAreaProps extends Omit<ChatInputAreaInnerProps, 'classNames'> {
6
+ bottomAddons?: ReactNode;
7
+ classNames?: DraggablePanelProps['classNames'];
8
+ expand?: boolean;
9
+ heights?: {
10
+ headerHeight?: number;
11
+ inputHeight?: number;
12
+ minHeight?: number;
13
+ };
14
+ onSizeChange?: DraggablePanelProps['onSizeChange'];
15
+ setExpand?: (expand: boolean) => void;
16
+ topAddons?: ReactNode;
17
+ }
18
+ declare const ChatInputArea: import("react").ForwardRefExoticComponent<ChatInputAreaProps & import("react").RefAttributes<TextAreaRef>>;
19
+ export default ChatInputArea;
@@ -0,0 +1,81 @@
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
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
5
+ var _excluded = ["className", "style", "classNames", "expand", "setExpand", "bottomAddons", "topAddons", "onSizeChange", "heights", "onSend"];
6
+ var _templateObject, _templateObject2, _templateObject3;
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ import { createStyles } from 'antd-style';
10
+ import { forwardRef } from 'react';
11
+ import useMergeState from 'use-merge-value';
12
+ import DraggablePanel from "../../DraggablePanel";
13
+ import ChatInputAreaInner from "../ChatInputAreaInner";
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ import { jsxs as _jsxs } from "react/jsx-runtime";
16
+ var useStyles = createStyles(function (_ref) {
17
+ var css = _ref.css;
18
+ return {
19
+ container: css(_templateObject || (_templateObject = _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 "]))),
20
+ textarea: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: 100% !important;\n padding: 0 24px;\n line-height: 1.5;\n "]))),
21
+ textareaContainer: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n flex: 1;\n "])))
22
+ };
23
+ });
24
+ var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref2, ref) {
25
+ var className = _ref2.className,
26
+ style = _ref2.style,
27
+ classNames = _ref2.classNames,
28
+ _ref2$expand = _ref2.expand,
29
+ expand = _ref2$expand === void 0 ? false : _ref2$expand,
30
+ setExpand = _ref2.setExpand,
31
+ bottomAddons = _ref2.bottomAddons,
32
+ topAddons = _ref2.topAddons,
33
+ onSizeChange = _ref2.onSizeChange,
34
+ heights = _ref2.heights,
35
+ _onSend = _ref2.onSend,
36
+ rest = _objectWithoutProperties(_ref2, _excluded);
37
+ var _useMergeState = useMergeState(expand, {
38
+ defaultValue: expand,
39
+ onChange: setExpand
40
+ }),
41
+ _useMergeState2 = _slicedToArray(_useMergeState, 2),
42
+ fullscreen = _useMergeState2[0],
43
+ setFullscreen = _useMergeState2[1];
44
+ var _useStyles = useStyles(),
45
+ styles = _useStyles.styles;
46
+ return /*#__PURE__*/_jsx(DraggablePanel, {
47
+ className: className,
48
+ classNames: classNames,
49
+ fullscreen: fullscreen,
50
+ headerHeight: heights === null || heights === void 0 ? void 0 : heights.headerHeight,
51
+ minHeight: heights === null || heights === void 0 ? void 0 : heights.minHeight,
52
+ onSizeChange: onSizeChange,
53
+ placement: "bottom",
54
+ size: {
55
+ height: heights === null || heights === void 0 ? void 0 : heights.inputHeight,
56
+ width: '100%'
57
+ },
58
+ style: _objectSpread({
59
+ zIndex: 10
60
+ }, style),
61
+ children: /*#__PURE__*/_jsxs("section", {
62
+ className: styles.container,
63
+ style: {
64
+ minHeight: heights === null || heights === void 0 ? void 0 : heights.minHeight
65
+ },
66
+ children: [topAddons, /*#__PURE__*/_jsx("div", {
67
+ className: styles.textareaContainer,
68
+ children: /*#__PURE__*/_jsx(ChatInputAreaInner, _objectSpread({
69
+ className: styles.textarea,
70
+ onSend: function onSend() {
71
+ _onSend === null || _onSend === void 0 || _onSend();
72
+ setFullscreen(false);
73
+ },
74
+ ref: ref,
75
+ type: 'pure'
76
+ }, rest))
77
+ }), bottomAddons]
78
+ })
79
+ });
80
+ });
81
+ export default ChatInputArea;
@@ -0,0 +1,17 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ export interface ChatSendButtonProps {
3
+ className?: string;
4
+ leftAddons?: ReactNode;
5
+ loading?: boolean;
6
+ onSend?: () => void;
7
+ onStop?: () => void;
8
+ rightAddons?: ReactNode;
9
+ style?: CSSProperties;
10
+ texts?: {
11
+ send?: string;
12
+ stop?: string;
13
+ warp?: string;
14
+ };
15
+ }
16
+ declare const ChatSendButton: import("react").NamedExoticComponent<ChatSendButtonProps>;
17
+ export default ChatSendButton;
@@ -0,0 +1,76 @@
1
+ import { Button } from 'antd';
2
+ import { useTheme } from 'antd-style';
3
+ import { ArrowBigUp, CornerDownLeft, Loader2 } from 'lucide-react';
4
+ import { memo } from 'react';
5
+ import { Flexbox } from 'react-layout-kit';
6
+ import Icon from "../../Icon";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ var ChatSendButton = /*#__PURE__*/memo(function (_ref) {
10
+ var className = _ref.className,
11
+ style = _ref.style,
12
+ leftAddons = _ref.leftAddons,
13
+ rightAddons = _ref.rightAddons,
14
+ texts = _ref.texts,
15
+ onSend = _ref.onSend,
16
+ loading = _ref.loading,
17
+ onStop = _ref.onStop;
18
+ var theme = useTheme();
19
+ return /*#__PURE__*/_jsxs(Flexbox, {
20
+ align: 'end',
21
+ className: className,
22
+ distribution: 'space-between',
23
+ flex: 'none',
24
+ gap: 8,
25
+ horizontal: true,
26
+ padding: '0 24px',
27
+ style: style,
28
+ children: [/*#__PURE__*/_jsx(Flexbox, {
29
+ align: 'center',
30
+ gap: 8,
31
+ horizontal: true,
32
+ children: leftAddons
33
+ }), /*#__PURE__*/_jsxs(Flexbox, {
34
+ align: 'center',
35
+ gap: 8,
36
+ horizontal: true,
37
+ children: [/*#__PURE__*/_jsxs(Flexbox, {
38
+ gap: 4,
39
+ horizontal: true,
40
+ style: {
41
+ color: theme.colorTextDescription,
42
+ fontSize: 12,
43
+ marginRight: 12
44
+ },
45
+ children: [/*#__PURE__*/_jsx(Icon, {
46
+ icon: CornerDownLeft
47
+ }), /*#__PURE__*/_jsx("span", {
48
+ children: (texts === null || texts === void 0 ? void 0 : texts.warp) || 'Warp'
49
+ }), /*#__PURE__*/_jsx("span", {
50
+ children: "/"
51
+ }), /*#__PURE__*/_jsxs(Flexbox, {
52
+ horizontal: true,
53
+ children: [/*#__PURE__*/_jsx(Icon, {
54
+ icon: ArrowBigUp
55
+ }), /*#__PURE__*/_jsx(Icon, {
56
+ icon: CornerDownLeft
57
+ })]
58
+ }), /*#__PURE__*/_jsx("span", {
59
+ children: (texts === null || texts === void 0 ? void 0 : texts.send) || 'Send'
60
+ })]
61
+ }), rightAddons, loading ? /*#__PURE__*/_jsx(Button, {
62
+ icon: loading && /*#__PURE__*/_jsx(Icon, {
63
+ icon: Loader2,
64
+ spin: true
65
+ }),
66
+ onClick: onStop,
67
+ children: (texts === null || texts === void 0 ? void 0 : texts.stop) || 'Stop'
68
+ }) : /*#__PURE__*/_jsx(Button, {
69
+ onClick: onSend,
70
+ type: 'primary',
71
+ children: (texts === null || texts === void 0 ? void 0 : texts.send) || 'Send'
72
+ })]
73
+ })]
74
+ });
75
+ });
76
+ export default ChatSendButton;
@@ -1,18 +1,6 @@
1
- /// <reference types="react" />
2
- import { type InputRef } from 'antd';
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
- safeArea?: boolean | undefined;
17
- } & import("react").RefAttributes<InputRef>>;
18
- export default ChatInputArea;
1
+ export { default as ChatInputActionBar, type ChatInputActionBarProps } from './ChatInputActionBar';
2
+ export { default as ChatInputAreaInner, type ChatInputAreaInnerProps } from './ChatInputAreaInner';
3
+ export { default as ChatInputArea, type ChatInputAreaProps } from './desktop/ChatInputArea';
4
+ export { default as ChatSendButton, type ChatSendButtonProps } from './desktop/SendButton';
5
+ export { default as MobileChatInputArea, type MobileChatInputAreaProps, } from './mobile/ChatInputArea';
6
+ export { default as MobileChatSendButton, type MobileChatSendButtonProps, } from './mobile/SendButton';
@@ -1,17 +1,6 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
- import { useResponsive } from 'antd-style';
5
- import { forwardRef } from 'react';
6
- import Desktop from "./Desktop";
7
- import Mobile from "./Mobile";
8
- import { jsx as _jsx } from "react/jsx-runtime";
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));
16
- });
17
- export default ChatInputArea;
1
+ export { default as ChatInputActionBar } from "./ChatInputActionBar";
2
+ export { default as ChatInputAreaInner } from "./ChatInputAreaInner";
3
+ export { default as ChatInputArea } from "./desktop/ChatInputArea";
4
+ export { default as ChatSendButton } from "./desktop/SendButton";
5
+ export { default as MobileChatInputArea } from "./mobile/ChatInputArea";
6
+ export { default as MobileChatSendButton } from "./mobile/SendButton";
@@ -0,0 +1,14 @@
1
+ import { TextAreaRef } from 'antd/es/input/TextArea';
2
+ import { CSSProperties, ReactNode } from 'react';
3
+ import { type ChatInputAreaInnerProps } from '../ChatInputAreaInner';
4
+ export interface MobileChatInputAreaProps extends ChatInputAreaInnerProps {
5
+ bottomAddons?: ReactNode;
6
+ expand?: boolean;
7
+ setExpand?: (expand: boolean) => void;
8
+ style?: CSSProperties;
9
+ textAreaLeftAddons?: ReactNode;
10
+ textAreaRightAddons?: ReactNode;
11
+ topAddons?: ReactNode;
12
+ }
13
+ declare const MobileChatInputArea: import("react").ForwardRefExoticComponent<MobileChatInputAreaProps & import("react").RefAttributes<TextAreaRef>>;
14
+ export default MobileChatInputArea;
@@ -0,0 +1,146 @@
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
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
5
+ var _excluded = ["className", "style", "topAddons", "textAreaLeftAddons", "textAreaRightAddons", "bottomAddons", "expand", "setExpand"];
6
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
7
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
8
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
9
+ import { useSize } from 'ahooks';
10
+ import { createStyles } from 'antd-style';
11
+ import { ChevronDown, ChevronUp } from 'lucide-react';
12
+ import { rgba } from 'polished';
13
+ import { forwardRef, useCallback, useEffect, useRef, useState } from 'react';
14
+ import { Flexbox } from 'react-layout-kit';
15
+ import useMergeState from 'use-merge-value';
16
+ import ActionIcon from "../../ActionIcon";
17
+ import ChatInputAreaInner from "../ChatInputAreaInner";
18
+ import { jsx as _jsx } from "react/jsx-runtime";
19
+ import { jsxs as _jsxs } from "react/jsx-runtime";
20
+ var useStyles = createStyles(function (_ref) {
21
+ var css = _ref.css,
22
+ token = _ref.token;
23
+ return {
24
+ container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 12px 0;\n background: ", ";\n border-top: 1px solid ", ";\n "])), token.colorBgLayout, rgba(token.colorBorder, 0.25)),
25
+ fullscreen: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n height: 100%;\n "]))),
26
+ fullscreenButton: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n right: 14px;\n "]))),
27
+ fullscreenTextArea: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n flex: 1;\n "]))),
28
+ inner: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n height: inherit;\n padding: 0 8px;\n "])))
29
+ };
30
+ });
31
+ var MobileChatInputArea = /*#__PURE__*/forwardRef(function (_ref2, ref) {
32
+ var className = _ref2.className,
33
+ style = _ref2.style,
34
+ topAddons = _ref2.topAddons,
35
+ textAreaLeftAddons = _ref2.textAreaLeftAddons,
36
+ textAreaRightAddons = _ref2.textAreaRightAddons,
37
+ bottomAddons = _ref2.bottomAddons,
38
+ _ref2$expand = _ref2.expand,
39
+ expand = _ref2$expand === void 0 ? false : _ref2$expand,
40
+ setExpand = _ref2.setExpand,
41
+ rest = _objectWithoutProperties(_ref2, _excluded);
42
+ var containerRef = useRef(null);
43
+ var _useStyles = useStyles(),
44
+ cx = _useStyles.cx,
45
+ styles = _useStyles.styles;
46
+ var size = useSize(containerRef);
47
+ var _useState = useState(false),
48
+ _useState2 = _slicedToArray(_useState, 2),
49
+ showFullscreen = _useState2[0],
50
+ setShowFullscreen = _useState2[1];
51
+ var _useState3 = useState(false),
52
+ _useState4 = _slicedToArray(_useState3, 2),
53
+ isFocused = _useState4[0],
54
+ setIsFocused = _useState4[1];
55
+ var _useMergeState = useMergeState(expand, {
56
+ defaultValue: expand,
57
+ onChange: setExpand
58
+ }),
59
+ _useMergeState2 = _slicedToArray(_useMergeState, 2),
60
+ fullscreen = _useMergeState2[0],
61
+ setFullscreen = _useMergeState2[1];
62
+ useEffect(function () {
63
+ if (!(size !== null && size !== void 0 && size.height)) return;
64
+ setShowFullscreen(size.height > 72);
65
+ }, [size]);
66
+ var InnerContainer = useCallback(function (_ref3) {
67
+ var children = _ref3.children;
68
+ return fullscreen ? /*#__PURE__*/_jsxs(Flexbox, {
69
+ className: styles.inner,
70
+ gap: 8,
71
+ style: {
72
+ paddingTop: 36
73
+ },
74
+ children: [children, /*#__PURE__*/_jsxs(Flexbox, {
75
+ horizontal: true,
76
+ justify: 'space-between',
77
+ children: [textAreaLeftAddons || /*#__PURE__*/_jsx("div", {}), textAreaRightAddons || /*#__PURE__*/_jsx("div", {})]
78
+ })]
79
+ }) : /*#__PURE__*/_jsxs(Flexbox, {
80
+ align: 'flex-end',
81
+ className: styles.inner,
82
+ gap: 8,
83
+ horizontal: true,
84
+ children: [textAreaLeftAddons, children, textAreaRightAddons]
85
+ });
86
+ }, [fullscreen]);
87
+ var showAddons = !fullscreen && !isFocused;
88
+ return /*#__PURE__*/_jsxs(Flexbox, {
89
+ className: cx(styles.container, fullscreen && styles.fullscreen, className),
90
+ gap: 12,
91
+ style: style,
92
+ children: [topAddons && /*#__PURE__*/_jsx(Flexbox, {
93
+ style: showAddons ? {} : {
94
+ height: 0,
95
+ overflow: 'hidden'
96
+ },
97
+ children: topAddons
98
+ }), /*#__PURE__*/_jsxs(Flexbox, {
99
+ className: cx(fullscreen && styles.fullscreen),
100
+ ref: containerRef,
101
+ style: {
102
+ position: 'relative'
103
+ },
104
+ children: [showFullscreen && /*#__PURE__*/_jsx(ActionIcon, {
105
+ active: true,
106
+ className: styles.fullscreenButton,
107
+ icon: fullscreen ? ChevronDown : ChevronUp,
108
+ onClick: function onClick() {
109
+ return setFullscreen(!fullscreen);
110
+ },
111
+ size: {
112
+ blockSize: 24,
113
+ borderRadius: '50%',
114
+ fontSize: 14
115
+ }
116
+ }), /*#__PURE__*/_jsx(InnerContainer, {
117
+ children: /*#__PURE__*/_jsx(ChatInputAreaInner, _objectSpread({
118
+ autoSize: fullscreen ? false : {
119
+ maxRows: 6,
120
+ minRows: 0
121
+ },
122
+ className: cx(fullscreen && styles.fullscreenTextArea),
123
+ onBlur: function onBlur() {
124
+ return setIsFocused(false);
125
+ },
126
+ onFocus: function onFocus() {
127
+ return setIsFocused(true);
128
+ },
129
+ ref: ref,
130
+ style: {
131
+ height: 36,
132
+ paddingBlock: 6
133
+ },
134
+ type: fullscreen ? 'pure' : 'block'
135
+ }, rest))
136
+ })]
137
+ }), bottomAddons && /*#__PURE__*/_jsx(Flexbox, {
138
+ style: showAddons ? {} : {
139
+ height: 0,
140
+ overflow: 'hidden'
141
+ },
142
+ children: bottomAddons
143
+ })]
144
+ });
145
+ });
146
+ export default MobileChatInputArea;
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ export interface MobileChatSendButtonProps {
3
+ loading?: boolean;
4
+ onSend?: () => void;
5
+ onStop?: () => void;
6
+ }
7
+ declare const MobileChatSendButton: import("react").NamedExoticComponent<MobileChatSendButtonProps>;
8
+ export default MobileChatSendButton;
@@ -0,0 +1,33 @@
1
+ import { useTheme } from 'antd-style';
2
+ import { Loader2, SendHorizonal } from 'lucide-react';
3
+ import { readableColor } from 'polished';
4
+ import { memo } from 'react';
5
+ import ActionIcon from "../../ActionIcon";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ var MobileChatSendButton = /*#__PURE__*/memo(function (_ref) {
8
+ var loading = _ref.loading,
9
+ onStop = _ref.onStop,
10
+ onSend = _ref.onSend;
11
+ var theme = useTheme();
12
+ var size = {
13
+ blockSize: 36,
14
+ fontSize: 16
15
+ };
16
+ return loading ? /*#__PURE__*/_jsx(ActionIcon, {
17
+ active: true,
18
+ icon: Loader2,
19
+ onClick: onStop,
20
+ size: size,
21
+ spin: true
22
+ }) : /*#__PURE__*/_jsx(ActionIcon, {
23
+ icon: SendHorizonal,
24
+ onClick: onSend,
25
+ size: size,
26
+ style: {
27
+ background: theme.colorPrimary,
28
+ color: readableColor(theme.colorPrimary),
29
+ flex: 'none'
30
+ }
31
+ });
32
+ });
33
+ export default MobileChatSendButton;
@@ -2,7 +2,7 @@
2
2
  import { LucideIcon, LucideProps } from 'lucide-react';
3
3
  import { DivProps } from "../types";
4
4
  export interface IconSizeConfig extends Pick<LucideProps, 'strokeWidth' | 'absoluteStrokeWidth'> {
5
- fontSize?: number;
5
+ fontSize?: number | string;
6
6
  }
7
7
  export type IconSizeType = 'large' | 'normal' | 'small';
8
8
  export type IconSize = IconSizeType | IconSizeConfig;
package/es/Input/index.js CHANGED
@@ -8,7 +8,7 @@ import { Input as AntInput } from 'antd';
8
8
  import { forwardRef } from 'react';
9
9
  import { useStyles } from "./style";
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
- export var Input = /*#__PURE__*/forwardRef(function (_ref, reference) {
11
+ export var Input = /*#__PURE__*/forwardRef(function (_ref, ref) {
12
12
  var className = _ref.className,
13
13
  _ref$type = _ref.type,
14
14
  type = _ref$type === void 0 ? 'ghost' : _ref$type,
@@ -21,10 +21,10 @@ export var Input = /*#__PURE__*/forwardRef(function (_ref, reference) {
21
21
  return /*#__PURE__*/_jsx(AntInput, _objectSpread({
22
22
  bordered: type !== 'pure',
23
23
  className: cx(styles.input, className),
24
- ref: reference
24
+ ref: ref
25
25
  }, rest));
26
26
  });
27
- export var TextArea = /*#__PURE__*/forwardRef(function (_ref2, reference) {
27
+ export var TextArea = /*#__PURE__*/forwardRef(function (_ref2, ref) {
28
28
  var className = _ref2.className,
29
29
  _ref2$type = _ref2.type,
30
30
  type = _ref2$type === void 0 ? 'ghost' : _ref2$type,
@@ -40,7 +40,7 @@ export var TextArea = /*#__PURE__*/forwardRef(function (_ref2, reference) {
40
40
  return /*#__PURE__*/_jsx(AntInput.TextArea, _objectSpread({
41
41
  bordered: type !== 'pure',
42
42
  className: cx(styles.textarea, className),
43
- ref: reference,
43
+ ref: ref,
44
44
  style: resize ? style : _objectSpread({
45
45
  resize: 'none'
46
46
  }, style)
@@ -70,7 +70,7 @@ var MessageModal = /*#__PURE__*/memo(function (_ref2) {
70
70
  padding: 16
71
71
  }
72
72
  } : {},
73
- title: (text === null || text === void 0 ? void 0 : text.title) || 'Prompt',
73
+ title: text === null || text === void 0 ? void 0 : text.title,
74
74
  children: isEdit ? /*#__PURE__*/_jsx(MessageInput, {
75
75
  defaultValue: value,
76
76
  height: height,
@@ -82,11 +82,18 @@ var MessageModal = /*#__PURE__*/memo(function (_ref2) {
82
82
  onChange === null || onChange === void 0 || onChange(text);
83
83
  },
84
84
  placeholder: placeholder,
85
+ style: mobile ? {
86
+ height: '100%'
87
+ } : {},
85
88
  text: {
86
89
  cancel: text === null || text === void 0 ? void 0 : text.cancel,
87
90
  confirm: text === null || text === void 0 ? void 0 : text.confirm
88
91
  },
89
- type: 'block'
92
+ textareaStyle: mobile ? {
93
+ flex: 1,
94
+ minHeight: 'unset'
95
+ } : {},
96
+ type: mobile ? 'pure' : 'block'
90
97
  }) : /*#__PURE__*/_jsxs(_Fragment, {
91
98
  children: [extra, /*#__PURE__*/_jsx(Markdown, {
92
99
  className: styles.markdown,
package/es/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { default as BackBottom, type BackBottomProps } from './BackBottom';
6
6
  export { default as Burger, type BurgerProps } from './Burger';
7
7
  export { default as ChatHeader, type ChatHeaderProps } from './ChatHeader';
8
8
  export { default as ChatHeaderTitle, type ChatHeaderTitleProps, } from './ChatHeader/ChatHeaderTitle';
9
- export { default as ChatInputArea, type ChatInputAreaProps } from './ChatInputArea';
9
+ export * from './ChatInputArea';
10
10
  export { default as ChatItem, type ChatItemProps } from './ChatItem';
11
11
  export type { ChatListProps, OnActionsClick, OnAvatatsClick, OnMessageChange, RenderAction, RenderErrorMessage, RenderItem, RenderMessage, RenderMessageExtra, } from './ChatList';
12
12
  export { default as ChatList } from './ChatList';
package/es/index.js CHANGED
@@ -6,7 +6,7 @@ export { default as BackBottom } from "./BackBottom";
6
6
  export { default as Burger } from "./Burger";
7
7
  export { default as ChatHeader } from "./ChatHeader";
8
8
  export { default as ChatHeaderTitle } from "./ChatHeader/ChatHeaderTitle";
9
- export { default as ChatInputArea } from "./ChatInputArea";
9
+ export * from "./ChatInputArea";
10
10
  export { default as ChatItem } from "./ChatItem";
11
11
  export { default as ChatList } from "./ChatList";
12
12
  export { default as ActionsBar } from "./ChatList/ActionsBar";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.120.7",
3
+ "version": "1.120.8",
4
4
  "description": "Lobe UI is an open-source UI component library for building AIGC web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -1,12 +0,0 @@
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
- actionsRight?: ReactNode;
8
- expand?: boolean;
9
- onExpandChange?: (expand: boolean) => void;
10
- }
11
- declare const Action: import("react").NamedExoticComponent<ActionProps>;
12
- export default Action;
@@ -1,43 +0,0 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3;
3
- import { createStyles, useResponsive } 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
- actionsRight = _ref2.actionsRight,
20
- expand = _ref2.expand,
21
- onExpandChange = _ref2.onExpandChange;
22
- var _useStyles = useStyles(),
23
- styles = _useStyles.styles;
24
- var _useResponsive = useResponsive(),
25
- mobile = _useResponsive.mobile;
26
- var handleExpandClick = useCallback(function () {
27
- if (onExpandChange) onExpandChange(!expand);
28
- }, [expand]);
29
- return /*#__PURE__*/_jsxs("div", {
30
- className: styles.actionsBar,
31
- children: [/*#__PURE__*/_jsx("div", {
32
- className: styles.actionLeft,
33
- children: actions
34
- }), /*#__PURE__*/_jsxs("div", {
35
- className: styles.actionsRight,
36
- children: [actionsRight, !mobile && /*#__PURE__*/_jsx(ActionIcon, {
37
- icon: expand ? Minimize2 : Maximize2,
38
- onClick: handleExpandClick
39
- })]
40
- })]
41
- });
42
- });
43
- export default Action;
@@ -1,17 +0,0 @@
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;
@@ -1,131 +0,0 @@
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(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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
- rest = _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
- }, rest), {}, {
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;
@@ -1,19 +0,0 @@
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
- safeArea?: boolean;
11
- };
12
- declare const ChatInputArea: import("react").ForwardRefExoticComponent<ChatInputBase & InputProps & {
13
- inputClassName?: string | undefined;
14
- inputId?: string | undefined;
15
- inputStyle?: CSSProperties | undefined;
16
- minHeight?: number | undefined;
17
- safeArea?: boolean | undefined;
18
- } & import("react").RefAttributes<InputRef>>;
19
- export default ChatInputArea;
@@ -1,136 +0,0 @@
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", "safeArea", "expand", "placeholder", "onExpandChange", "onSend", "defaultValue", "loading", "disabled", "onInputChange", "onPressEnter", "onCompositionStart", "onCompositionEnd", "onBlur", "onChange", "inputId", "actionsRight", "onStop", "value"];
5
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
6
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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 MobileSafeArea from "../MobileSafeArea";
15
- import Action from "./Action";
16
- import { useStyles } from "./style.mobile";
17
- import { jsx as _jsx } from "react/jsx-runtime";
18
- import { jsxs as _jsxs } from "react/jsx-runtime";
19
- var ChatInputArea = /*#__PURE__*/forwardRef(function (_ref, ref) {
20
- var inputClassName = _ref.inputClassName,
21
- style = _ref.style,
22
- inputStyle = _ref.inputStyle,
23
- _ref$minHeight = _ref.minHeight,
24
- minHeight = _ref$minHeight === void 0 ? 200 : _ref$minHeight,
25
- className = _ref.className,
26
- actions = _ref.actions,
27
- safeArea = _ref.safeArea,
28
- expand = _ref.expand,
29
- _ref$placeholder = _ref.placeholder,
30
- placeholder = _ref$placeholder === void 0 ? 'Type something to chat...' : _ref$placeholder,
31
- onExpandChange = _ref.onExpandChange,
32
- onSend = _ref.onSend,
33
- _ref$defaultValue = _ref.defaultValue,
34
- defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
35
- loading = _ref.loading,
36
- disabled = _ref.disabled,
37
- onInputChange = _ref.onInputChange,
38
- _onPressEnter = _ref.onPressEnter,
39
- _onCompositionStart = _ref.onCompositionStart,
40
- _onCompositionEnd = _ref.onCompositionEnd,
41
- _onBlur = _ref.onBlur,
42
- _onChange = _ref.onChange,
43
- _ref$inputId = _ref.inputId,
44
- inputId = _ref$inputId === void 0 ? 'lobe-chat-input-area' : _ref$inputId,
45
- actionsRight = _ref.actionsRight,
46
- onStop = _ref.onStop,
47
- value = _ref.value,
48
- rest = _objectWithoutProperties(_ref, _excluded);
49
- var _useControlledState = useControlledState(defaultValue, {
50
- defaultValue: defaultValue,
51
- onChange: onInputChange,
52
- value: value
53
- }),
54
- _useControlledState2 = _slicedToArray(_useControlledState, 2),
55
- currentValue = _useControlledState2[0],
56
- setCurrentValue = _useControlledState2[1];
57
- var _useStyles = useStyles(),
58
- cx = _useStyles.cx,
59
- styles = _useStyles.styles;
60
- var isChineseInput = useRef(false);
61
- var handleSend = useCallback(function () {
62
- if (loading && disabled) return;
63
- if (onSend) onSend(currentValue);
64
- setCurrentValue('');
65
- }, [disabled, currentValue]);
66
- return /*#__PURE__*/_jsxs(Flexbox, {
67
- className: cx(styles.container, className),
68
- gap: 12,
69
- style: _objectSpread({
70
- minHeight: minHeight
71
- }, style),
72
- children: [/*#__PURE__*/_jsx(Action, {
73
- actions: actions,
74
- actionsRight: actionsRight,
75
- expand: expand,
76
- onExpandChange: onExpandChange
77
- }), /*#__PURE__*/_jsxs(Flexbox, {
78
- className: styles.inner,
79
- gap: 8,
80
- horizontal: true,
81
- children: [/*#__PURE__*/_jsx(Input, _objectSpread(_objectSpread({
82
- className: cx(styles.input, inputClassName),
83
- defaultValue: defaultValue,
84
- id: inputId,
85
- ref: ref,
86
- style: inputStyle
87
- }, rest), {}, {
88
- onBlur: function onBlur(e) {
89
- if (_onBlur) _onBlur(e);
90
- setCurrentValue(e.target.value);
91
- },
92
- onChange: function onChange(e) {
93
- if (_onChange) _onChange(e);
94
- setCurrentValue(e.target.value);
95
- },
96
- onCompositionEnd: function onCompositionEnd(e) {
97
- if (_onCompositionEnd) _onCompositionEnd(e);
98
- isChineseInput.current = false;
99
- },
100
- onCompositionStart: function onCompositionStart(e) {
101
- if (_onCompositionStart) _onCompositionStart(e);
102
- isChineseInput.current = true;
103
- },
104
- onPressEnter: function onPressEnter(e) {
105
- if (_onPressEnter) _onPressEnter(e);
106
- if (!loading && !e.shiftKey && !isChineseInput.current) {
107
- e.preventDefault();
108
- handleSend();
109
- }
110
- },
111
- placeholder: placeholder,
112
- type: 'block',
113
- value: currentValue
114
- })), /*#__PURE__*/_jsx("div", {
115
- children: loading ? /*#__PURE__*/_jsx(Button, {
116
- disabled: disabled,
117
- icon: loading && /*#__PURE__*/_jsx(Icon, {
118
- icon: Loader2,
119
- spin: true
120
- }),
121
- onClick: onStop
122
- }) : /*#__PURE__*/_jsx(Button, {
123
- disabled: disabled,
124
- icon: /*#__PURE__*/_jsx(Icon, {
125
- icon: SendHorizonal
126
- }),
127
- onClick: handleSend,
128
- type: 'primary'
129
- })
130
- })]
131
- }), safeArea && /*#__PURE__*/_jsx(MobileSafeArea, {
132
- position: 'bottom'
133
- })]
134
- });
135
- });
136
- export default ChatInputArea;
@@ -1,9 +0,0 @@
1
- export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
- actionLeft: import("antd-style").SerializedStyles;
3
- actionsBar: import("antd-style").SerializedStyles;
4
- actionsRight: import("antd-style").SerializedStyles;
5
- container: import("antd-style").SerializedStyles;
6
- footerBar: import("antd-style").SerializedStyles;
7
- textarea: import("antd-style").SerializedStyles;
8
- textareaContainer: import("antd-style").SerializedStyles;
9
- }>;
@@ -1,15 +0,0 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
3
- import { createStyles } from 'antd-style';
4
- export var useStyles = createStyles(function (_ref) {
5
- var css = _ref.css;
6
- return {
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 "]))),
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 "]))),
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 "]))),
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 "]))),
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 "]))),
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 "])))
14
- };
15
- });
@@ -1,5 +0,0 @@
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
- }>;
@@ -1,13 +0,0 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3;
3
- import { createStyles } from 'antd-style';
4
- import { rgba } from 'polished';
5
- export var useStyles = createStyles(function (_ref) {
6
- var css = _ref.css,
7
- token = _ref.token;
8
- return {
9
- container: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding: 12px 0;\n background: ", ";\n border-top: 1px solid ", ";\n "])), token.colorBgLayout, rgba(token.colorBorder, 0.25)),
10
- inner: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding: 0 16px;\n "]))),
11
- input: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n background: ", " !important;\n border: none !important;\n "])), token.colorFillSecondary)
12
- };
13
- });
@@ -1,33 +0,0 @@
1
- import { ReactNode } from 'react';
2
- import { ActionProps } from "./Action";
3
- export interface ChatInputBase extends ActionProps {
4
- /**
5
- * @description Default value for the input area
6
- */
7
- defaultValue?: string;
8
- /**
9
- * @description Footer content to be displayed below the input area
10
- */
11
- footer?: ReactNode;
12
- /**
13
- * @description Whether the input area is in loading state
14
- * @default false
15
- */
16
- loading?: boolean;
17
- /**
18
- * @description Callback function when the input value changes
19
- * @param value - The current value of the input area
20
- */
21
- onInputChange?: (value: string) => void;
22
- /**
23
- * @description Callback function when the send button is clicked
24
- * @param value - The current value of the input area
25
- */
26
- onSend?: (value: string) => void;
27
- onStop?: () => void;
28
- text?: {
29
- send?: string;
30
- stop?: string;
31
- };
32
- value?: string;
33
- }
@@ -1 +0,0 @@
1
- export {};