@lobehub/ui 1.25.5 → 1.26.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,17 @@
1
+ import { ReactNode } from 'react';
2
+ import type { DivProps } from "../types";
3
+ export interface ChatInputAreaProps extends DivProps {
4
+ actions?: ReactNode;
5
+ defaultValue?: string;
6
+ disabled?: boolean;
7
+ expand?: boolean;
8
+ footer?: ReactNode;
9
+ loading?: boolean;
10
+ minHeight?: number;
11
+ onExpandChange?: (expand: boolean) => void;
12
+ onInputChange?: (value: string) => void;
13
+ onSend?: (value: string) => void;
14
+ placeholder?: string;
15
+ }
16
+ declare const ChatInputArea: import("react").NamedExoticComponent<ChatInputAreaProps>;
17
+ export default ChatInputArea;
@@ -0,0 +1,106 @@
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 = ["minHeight", "className", "actions", "footer", "expand", "placeholder", "onExpandChange", "onSend", "defaultValue", "loading", "style", "disabled", "onInputChange"];
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 { Maximize2, Minimize2 } from 'lucide-react';
9
+ import { memo, useCallback, useEffect, useRef, useState } from 'react';
10
+ import { ActionIcon, TextArea } from "./..";
11
+ import { useStyles } from "./style";
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { jsxs as _jsxs } from "react/jsx-runtime";
14
+ var ChatInputArea = /*#__PURE__*/memo(function (_ref) {
15
+ var _ref$minHeight = _ref.minHeight,
16
+ minHeight = _ref$minHeight === void 0 ? 200 : _ref$minHeight,
17
+ className = _ref.className,
18
+ actions = _ref.actions,
19
+ footer = _ref.footer,
20
+ expand = _ref.expand,
21
+ _ref$placeholder = _ref.placeholder,
22
+ placeholder = _ref$placeholder === void 0 ? 'Type something to chat...' : _ref$placeholder,
23
+ onExpandChange = _ref.onExpandChange,
24
+ onSend = _ref.onSend,
25
+ _ref$defaultValue = _ref.defaultValue,
26
+ defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue,
27
+ loading = _ref.loading,
28
+ style = _ref.style,
29
+ disabled = _ref.disabled,
30
+ onInputChange = _ref.onInputChange,
31
+ props = _objectWithoutProperties(_ref, _excluded);
32
+ var isChineseInput = useRef(false);
33
+ var _useState = useState(defaultValue),
34
+ _useState2 = _slicedToArray(_useState, 2),
35
+ value = _useState2[0],
36
+ setValue = _useState2[1];
37
+ var _useStyles = useStyles(),
38
+ cx = _useStyles.cx,
39
+ styles = _useStyles.styles;
40
+ var handleExpandClick = useCallback(function () {
41
+ if (onExpandChange) onExpandChange(!expand);
42
+ }, [expand]);
43
+ var handleSend = useCallback(function () {
44
+ if (disabled) return;
45
+ if (onSend) onSend(value);
46
+ setValue('');
47
+ }, [disabled, value]);
48
+ useEffect(function () {
49
+ if (onInputChange) onInputChange(value);
50
+ }, [value]);
51
+ return /*#__PURE__*/_jsxs("section", _objectSpread(_objectSpread({
52
+ className: cx(styles.container, className),
53
+ style: _objectSpread({
54
+ minHeight: minHeight
55
+ }, style)
56
+ }, props), {}, {
57
+ children: [/*#__PURE__*/_jsxs("div", {
58
+ className: styles.actionsBar,
59
+ children: [/*#__PURE__*/_jsx("div", {
60
+ className: styles.actionLeft,
61
+ children: actions
62
+ }), /*#__PURE__*/_jsx("div", {
63
+ className: styles.actionsRight,
64
+ children: /*#__PURE__*/_jsx(ActionIcon, {
65
+ icon: expand ? Minimize2 : Maximize2,
66
+ onClick: handleExpandClick
67
+ })
68
+ })]
69
+ }), /*#__PURE__*/_jsx(TextArea, {
70
+ className: styles.textarea,
71
+ defaultValue: defaultValue,
72
+ onBlur: function onBlur(e) {
73
+ return setValue(e.target.value);
74
+ },
75
+ onChange: function onChange(e) {
76
+ return setValue(e.target.value);
77
+ },
78
+ onCompositionEnd: function onCompositionEnd() {
79
+ isChineseInput.current = false;
80
+ },
81
+ onCompositionStart: function onCompositionStart() {
82
+ isChineseInput.current = true;
83
+ },
84
+ onPressEnter: function onPressEnter(e) {
85
+ if (!loading && !e.shiftKey && !isChineseInput.current) {
86
+ e.preventDefault();
87
+ handleSend();
88
+ }
89
+ },
90
+ placeholder: placeholder,
91
+ resize: false,
92
+ type: "pure",
93
+ value: value
94
+ }), /*#__PURE__*/_jsxs("div", {
95
+ className: styles.footerBar,
96
+ children: [footer, /*#__PURE__*/_jsx(Button, {
97
+ disabled: disabled,
98
+ loading: loading,
99
+ onClick: handleSend,
100
+ type: "primary",
101
+ children: "Send"
102
+ })]
103
+ })]
104
+ }));
105
+ });
106
+ export default ChatInputArea;
@@ -0,0 +1,8 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ container: import("antd-style").SerializedStyles;
3
+ actionsBar: import("antd-style").SerializedStyles;
4
+ actionLeft: import("antd-style").SerializedStyles;
5
+ actionsRight: import("antd-style").SerializedStyles;
6
+ textarea: import("antd-style").SerializedStyles;
7
+ footerBar: import("antd-style").SerializedStyles;
8
+ }>;
@@ -0,0 +1,14 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref) {
5
+ var css = _ref.css;
6
+ return {
7
+ 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 "]))),
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
+ actionLeft: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n flex: 1;\n gap: 4px;\n align-items: center;\n justify-content: flex-start;\n "]))),
10
+ actionsRight: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n flex: 0;\n gap: 4px;\n align-items: center;\n justify-content: flex-end;\n "]))),
11
+ textarea: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n flex: 1;\n padding: 0 24px;\n "]))),
12
+ footerBar: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: flex;\n flex: none;\n gap: 8px;\n align-items: center;\n justify-content: flex-end;\n\n padding: 0 24px;\n "])))
13
+ };
14
+ });
@@ -6,7 +6,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
  import { Alert } from 'antd';
7
7
  import { Loader2 } from 'lucide-react';
8
8
  import { memo } from 'react';
9
- import { Avatar, Icon, Markdown } from "./..";
9
+ import Avatar from "../Avatar";
10
+ import Icon from "../Icon";
11
+ import Markdown from "../Markdown";
10
12
  import { formatTime } from "../utils/formatTime";
11
13
  import { useStyles } from "./style";
12
14
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -34,11 +34,13 @@ export interface DraggablePanelProps extends DivProps {
34
34
  * @default true
35
35
  */
36
36
  expandable?: boolean;
37
+ fullscreen?: boolean;
37
38
  /**
38
39
  * @description The style of the panel handler
39
40
  * @type CSSProperties
40
41
  */
41
42
  hanlderStyle?: React.CSSProperties;
43
+ maxHeight?: number;
42
44
  maxWidth?: number;
43
45
  /**
44
46
  * @description The minimum height of the panel
@@ -15,7 +15,9 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
15
15
  var DEFAULT_HEIGHT = 180;
16
16
  var DEFAULT_WIDTH = 280;
17
17
  var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
18
- var _ref$pin = _ref.pin,
18
+ var fullscreen = _ref.fullscreen,
19
+ maxHeight = _ref.maxHeight,
20
+ _ref$pin = _ref.pin,
19
21
  pin = _ref$pin === void 0 ? 'true' : _ref$pin,
20
22
  _ref$mode = _ref.mode,
21
23
  mode = _ref$mode === void 0 ? 'fixed' : _ref$mode,
@@ -46,7 +48,7 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
46
48
  var ref = useRef(null);
47
49
  var isHovering = useHover(ref);
48
50
  var isVertical = placement === 'top' || placement === 'bottom';
49
- var _useStyles = useStyles('draggable-panel'),
51
+ var _useStyles = useStyles(),
50
52
  styles = _useStyles.styles,
51
53
  cx = _useStyles.cx;
52
54
  var _useControlledState = useControlledState(defaultExpand, {
@@ -94,9 +96,10 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
94
96
  }, customizeDefaultSize);
95
97
  }, [isVertical]);
96
98
  var sizeProps = isExpand ? {
97
- minWidth: typeof minWidth === 'number' ? Math.max(minWidth, 0) : 280,
98
- minHeight: typeof minHeight === 'number' ? Math.max(minHeight, 0) : undefined,
99
- maxWidth: typeof maxWidth === 'number' ? Math.max(maxWidth, 0) : undefined,
99
+ minWidth: typeof minWidth === 'number' ? Math.max(minWidth, 0) : minWidth,
100
+ minHeight: typeof minHeight === 'number' ? Math.max(minHeight, 0) : minHeight,
101
+ maxWidth: typeof maxWidth === 'number' ? Math.max(maxWidth, 0) : maxWidth,
102
+ maxHeight: typeof maxHeight === 'number' ? Math.max(maxHeight, 0) : maxHeight,
100
103
  defaultSize: defaultSize,
101
104
  size: size
102
105
  } : isVertical ? {
@@ -186,6 +189,10 @@ var DraggablePanel = /*#__PURE__*/memo(function (_ref) {
186
189
  style: style,
187
190
  children: children
188
191
  }));
192
+ if (fullscreen) return /*#__PURE__*/_jsx("div", {
193
+ className: cx(styles.fullscreen, className),
194
+ children: children
195
+ });
189
196
  return /*#__PURE__*/_jsxs("aside", {
190
197
  className: cx(styles.container,
191
198
  // @ts-ignore
@@ -1,4 +1,4 @@
1
- export declare const useStyles: (props?: string | undefined) => import("antd-style").ReturnStyles<{
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
2
  container: string;
3
3
  fixed: import("antd-style").SerializedStyles;
4
4
  leftFloat: string;
@@ -15,4 +15,5 @@ export declare const useStyles: (props?: string | undefined) => import("antd-sty
15
15
  rightHandle: string;
16
16
  topHandle: string;
17
17
  bottomHandle: string;
18
+ fullscreen: import("antd-style").SerializedStyles;
18
19
  }>;
@@ -1,10 +1,11 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19;
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16, _templateObject17, _templateObject18, _templateObject19, _templateObject20;
3
3
  import { createStyles, css, cx } from 'antd-style';
4
4
  var offset = 16;
5
5
  var toggleLength = 40;
6
6
  var toggleShort = 16;
7
- export var useStyles = createStyles(function (_ref, prefix) {
7
+ var prefix = 'draggable-panel';
8
+ export var useStyles = createStyles(function (_ref) {
8
9
  var token = _ref.token;
9
10
  var commonHandle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n\n &::before {\n content: '';\n position: absolute;\n z-index: 50;\n transition: all 0.2s ", ";\n }\n\n &:hover,\n &:active {\n &::before {\n background: ", " !important;\n }\n }\n "])), token.motionEaseOut, token.colorPrimary);
10
11
  var commonToggle = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 101;\n opacity: 0;\n transition: all 0.2s ", ";\n\n &:hover {\n opacity: 1 !important;\n }\n\n &:active {\n opacity: 1 !important;\n }\n\n > div {\n cursor: pointer;\n\n position: absolute;\n\n color: ", ";\n\n background: ", ";\n border-color: ", ";\n border-style: solid;\n border-width: 1px;\n border-radius: 4px;\n\n transition: all 0.2s ", ";\n\n &:hover {\n color: ", ";\n background: ", ";\n }\n\n &:active {\n color: ", ";\n background: ", ";\n }\n }\n "])), token.motionEaseOut, token.colorTextTertiary, token.colorFillTertiary, token.colorBorderSecondary, token.motionEaseOut, token.colorTextSecondary, token.colorFillSecondary, token.colorText, token.colorFill);
@@ -25,6 +26,7 @@ export var useStyles = createStyles(function (_ref, prefix) {
25
26
  leftHandle: cx(css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n ", ";\n\n &::before {\n left: 50%;\n width: 2px;\n height: 100%;\n }\n "])), commonHandle), "".concat(prefix, "-left-handle")),
26
27
  rightHandle: cx(css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n ", ";\n &::before {\n right: 50%;\n width: 2px;\n height: 100%;\n }\n "])), commonHandle), "".concat(prefix, "-right-handle")),
27
28
  topHandle: cx("".concat(prefix, "-top-handle"), css(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n ", ";\n\n &::before {\n top: 50%;\n width: 100%;\n height: 2px;\n }\n "])), commonHandle)),
28
- bottomHandle: cx("".concat(prefix, "-bottom-handle"), css(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n ", ";\n\n &::before {\n bottom: 50%;\n width: 100%;\n height: 2px;\n }\n "])), commonHandle))
29
+ bottomHandle: cx("".concat(prefix, "-bottom-handle"), css(_templateObject19 || (_templateObject19 = _taggedTemplateLiteral(["\n ", ";\n\n &::before {\n bottom: 50%;\n width: 100%;\n height: 2px;\n }\n "])), commonHandle)),
30
+ fullscreen: css(_templateObject20 || (_templateObject20 = _taggedTemplateLiteral(["\n position: absolute;\n inset: 0;\n width: 100%;\n height: 100%;\n "])))
29
31
  };
30
32
  });
@@ -3,11 +3,12 @@ import { InputProps as AntdInputProps } from 'antd';
3
3
  import { TextAreaProps as AntdTextAreaProps } from 'antd/es/input/TextArea';
4
4
  export interface InputProps extends AntdInputProps {
5
5
  ref?: any;
6
- type?: 'ghost' | 'block';
6
+ type?: 'ghost' | 'block' | 'pure';
7
7
  }
8
8
  export declare const Input: import("react").NamedExoticComponent<InputProps>;
9
9
  export interface TextAreaProps extends AntdTextAreaProps {
10
10
  ref?: any;
11
- type?: 'ghost' | 'block';
11
+ resize?: boolean;
12
+ type?: 'ghost' | 'block' | 'pure';
12
13
  }
13
14
  export declare const TextArea: import("react").NamedExoticComponent<TextAreaProps>;
package/es/Input/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
3
  var _excluded = ["className", "type"],
4
- _excluded2 = ["className", "type"];
4
+ _excluded2 = ["className", "type", "resize", "style"];
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 { Input as AntInput } from 'antd';
@@ -19,6 +19,7 @@ export var Input = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref, re
19
19
  styles = _useStyles.styles,
20
20
  cx = _useStyles.cx;
21
21
  return /*#__PURE__*/_jsx(AntInput, _objectSpread({
22
+ bordered: type !== 'pure',
22
23
  className: cx(styles.input, className),
23
24
  ref: ref
24
25
  }, props));
@@ -27,6 +28,9 @@ export var TextArea = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref2
27
28
  var className = _ref2.className,
28
29
  _ref2$type = _ref2.type,
29
30
  type = _ref2$type === void 0 ? 'ghost' : _ref2$type,
31
+ _ref2$resize = _ref2.resize,
32
+ resize = _ref2$resize === void 0 ? true : _ref2$resize,
33
+ style = _ref2.style,
30
34
  props = _objectWithoutProperties(_ref2, _excluded2);
31
35
  var _useStyles2 = useStyles({
32
36
  type: type
@@ -34,7 +38,11 @@ export var TextArea = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function (_ref2
34
38
  styles = _useStyles2.styles,
35
39
  cx = _useStyles2.cx;
36
40
  return /*#__PURE__*/_jsx(AntInput.TextArea, _objectSpread({
41
+ bordered: type !== 'pure',
37
42
  className: cx(styles.textarea, className),
38
- ref: ref
43
+ ref: ref,
44
+ style: resize ? style : _objectSpread({
45
+ resize: 'none'
46
+ }, style)
39
47
  }, props));
40
48
  }));
@@ -1,5 +1,5 @@
1
1
  export declare const useStyles: (props?: {
2
- type: 'ghost' | 'block';
2
+ type: 'ghost' | 'block' | 'pure';
3
3
  } | undefined) => import("antd-style").ReturnStyles<{
4
4
  input: string;
5
5
  textarea: string;
package/es/Input/style.js CHANGED
@@ -6,9 +6,9 @@ export var useStyles = createStyles(function (_ref, _ref2) {
6
6
  css = _ref.css,
7
7
  token = _ref.token;
8
8
  var type = _ref2.type;
9
- var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorder);
9
+ var typeStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n border: 1px solid ", ";\n transition: background-color 100ms ", ",\n border-color 200ms ", ";\n\n &:hover {\n background-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n }\n\n &.ant-input-affix-wrapper-focused {\n border-color: ", ";\n }\n "])), type === 'block' ? token.colorFillTertiary : 'transparent', type === 'block' ? 'transparent' : token.colorBorder, token.motionEaseOut, token.motionEaseOut, token.colorFillTertiary, token.colorTextQuaternary, token.colorTextQuaternary);
10
10
  return {
11
- input: cx(typeStylish, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n\n max-width: 100%;\n height: 36px;\n padding: 0 12px;\n\n transition: background-color 100ms ", ",\n border-color 200ms ", ";\n\n input {\n background: transparent;\n }\n\n &:hover {\n background-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n }\n\n &.ant-input-affix-wrapper-focused {\n border-color: ", ";\n }\n "])), token.motionEaseOut, token.motionEaseOut, token.colorFillTertiary, token.colorTextQuaternary, token.colorTextQuaternary)),
12
- textarea: cx(typeStylish, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n max-width: 100%;\n padding: 8px 12px;\n transition: background-color 100ms ", ";\n\n textarea {\n background: transparent;\n }\n\n &:hover {\n background-color: ", ";\n border-color: ", ";\n }\n\n &:focus {\n border-color: ", ";\n }\n "])), token.motionEaseOut, token.colorFillTertiary, token.colorBorder, token.colorTextQuaternary))
11
+ input: cx(type !== 'pure' && typeStylish, css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n max-width: 100%;\n height: ", ";\n padding: ", ";\n\n input {\n background: transparent;\n }\n "])), type === 'pure' ? 'unset' : '36px', type === 'pure' ? '0' : '0 12px')),
12
+ textarea: cx(type !== 'pure' && typeStylish, css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: relative;\n max-width: 100%;\n padding: ", ";\n\n textarea {\n background: transparent;\n }\n "])), type === 'pure' ? '0' : '8px 12px'))
13
13
  };
14
14
  });
@@ -0,0 +1,8 @@
1
+ /// <reference types="react" />
2
+ import { DivProps } from "../types";
3
+ export interface TokenTagProps extends DivProps {
4
+ maxValue: number;
5
+ value: number;
6
+ }
7
+ declare const TokenTag: import("react").NamedExoticComponent<TokenTagProps>;
8
+ export default TokenTag;
@@ -0,0 +1,41 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["className", "maxValue", "value"];
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
+ 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
+ import { memo } from 'react';
7
+ import { useStyles } from "./style";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ import { jsxs as _jsxs } from "react/jsx-runtime";
10
+ var TokenTag = /*#__PURE__*/memo(function (_ref) {
11
+ var className = _ref.className,
12
+ maxValue = _ref.maxValue,
13
+ value = _ref.value,
14
+ props = _objectWithoutProperties(_ref, _excluded);
15
+ var valueLeft = maxValue - value;
16
+ var percent = valueLeft / maxValue;
17
+ var type;
18
+ var emoji;
19
+ if (percent > 0.3) {
20
+ type = 'normal';
21
+ emoji = '😀';
22
+ } else if (percent > 0) {
23
+ type = 'low';
24
+ emoji = '😅';
25
+ } else {
26
+ type = 'overload';
27
+ emoji = '🤯';
28
+ }
29
+ var _useStyles = useStyles(type),
30
+ styles = _useStyles.styles,
31
+ cx = _useStyles.cx;
32
+ return /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
33
+ className: cx(styles.container, className)
34
+ }, props), {}, {
35
+ children: [/*#__PURE__*/_jsx("span", {
36
+ className: styles.emoji,
37
+ children: emoji
38
+ }), valueLeft > 0 ? "Tokens ".concat(valueLeft) : "Overload"]
39
+ }));
40
+ });
41
+ export default TokenTag;
@@ -0,0 +1,4 @@
1
+ export declare const useStyles: (props?: "normal" | "low" | "overload" | undefined) => import("antd-style").ReturnStyles<{
2
+ container: string;
3
+ emoji: import("antd-style").SerializedStyles;
4
+ }>;
@@ -0,0 +1,27 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
3
+ import { createStyles } from 'antd-style';
4
+ var HEIGHT = 28;
5
+ var ICON_SIZE = 20;
6
+ export var useStyles = createStyles(function (_ref, type) {
7
+ var cx = _ref.cx,
8
+ css = _ref.css,
9
+ token = _ref.token;
10
+ var percentStyle;
11
+ switch (type) {
12
+ case 'normal':
13
+ percentStyle = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorSuccessText);
14
+ break;
15
+ case 'low':
16
+ percentStyle = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorWarningText);
17
+ break;
18
+ case 'overload':
19
+ default:
20
+ percentStyle = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorErrorText);
21
+ break;
22
+ }
23
+ return {
24
+ container: cx(percentStyle, css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n overflow: hidden;\n display: flex;\n gap: 4px;\n align-items: center;\n\n height: ", "px;\n padding: 0 ", "px 0 ", "px;\n\n background: ", ";\n border-radius: ", "px;\n "])), HEIGHT, HEIGHT - ICON_SIZE, (HEIGHT - ICON_SIZE) / 2, token.colorFillSecondary, HEIGHT / 2)),
25
+ emoji: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: ", "px;\n "])), ICON_SIZE)
26
+ };
27
+ });
package/es/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export { default as ActionIcon, type ActionIconProps, type ActionIconSize } from
2
2
  export { default as ActionIconGroup, type ActionIconGroupProps } from './ActionIconGroup';
3
3
  export { default as Avatar, type AvatarProps } from './Avatar';
4
4
  export type { ChatMessage, MessageRoleType } from './Chat';
5
+ export { default as ChatInputArea, type ChatInputAreaProps } from './ChatInputArea';
5
6
  export { default as ChatItem, type ChatItemProps } from './ChatItem';
6
7
  export { default as ChatList, type ChatListProps } from './ChatList';
7
8
  export { default as ColorScales, type ColorScalesProps } from './ColorScales';
@@ -37,6 +38,7 @@ export { default as TabsNav, type TabsNavProps } from './TabsNav';
37
38
  export { default as ThemeProvider } from './ThemeProvider';
38
39
  export { default as ThemeSwitch, type ThemeSwitchProps } from './ThemeSwitch';
39
40
  export { default as Toc, type TocProps } from './Toc';
41
+ export { default as TokenTag, type TokenTagProps } from './TokenTag';
40
42
  export { default as Tooltip, type TooltipProps } from './Tooltip';
41
43
  export { type LobeCustomStylish } from './types/customStylish';
42
44
  export { type LobeCustomToken } from './types/customToken';
package/es/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { default as ActionIcon } from "./ActionIcon";
2
2
  export { default as ActionIconGroup } from "./ActionIconGroup";
3
3
  export { default as Avatar } from "./Avatar";
4
+ export { default as ChatInputArea } from "./ChatInputArea";
4
5
  export { default as ChatItem } from "./ChatItem";
5
6
  export { default as ChatList } from "./ChatList";
6
7
  export { default as ColorScales } from "./ColorScales";
@@ -36,4 +37,5 @@ export { default as TabsNav } from "./TabsNav";
36
37
  export { default as ThemeProvider } from "./ThemeProvider";
37
38
  export { default as ThemeSwitch } from "./ThemeSwitch";
38
39
  export { default as Toc } from "./Toc";
40
+ export { default as TokenTag } from "./TokenTag";
39
41
  export { default as Tooltip } from "./Tooltip";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.25.5",
3
+ "version": "1.26.1",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",
@@ -78,7 +78,6 @@
78
78
  "@react-spring/web": "^9",
79
79
  "ahooks": "^3",
80
80
  "antd": "^5",
81
- "antd-style": "^3",
82
81
  "chroma-js": "^2",
83
82
  "copy-to-clipboard": "^3",
84
83
  "dayjs": "^1",
@@ -114,6 +113,7 @@
114
113
  "@types/react": "^18",
115
114
  "@types/react-dom": "^18",
116
115
  "@vitest/coverage-v8": "latest",
116
+ "antd-style": "^3",
117
117
  "commitlint": "^17",
118
118
  "concurrently": "^8",
119
119
  "cross-env": "^7",