@lobehub/ui 1.8.2 → 1.10.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 (49) hide show
  1. package/es/ActionIcon/index.js +2 -2
  2. package/es/EditableMessageList/index.js +6 -6
  3. package/es/EditableText/index.js +11 -10
  4. package/es/Icon/index.d.ts +1 -0
  5. package/es/Icon/index.js +5 -2
  6. package/es/Input/index.d.ts +13 -0
  7. package/es/Input/index.js +36 -0
  8. package/es/Input/style.d.ts +6 -0
  9. package/es/Input/style.js +13 -0
  10. package/es/MessageInput/index.d.ts +2 -0
  11. package/es/MessageInput/index.js +10 -8
  12. package/es/SearchBar/index.d.ts +6 -3
  13. package/es/SearchBar/index.js +74 -17
  14. package/es/SearchBar/style.d.ts +6 -0
  15. package/es/SearchBar/style.js +13 -0
  16. package/es/StroyBook/style.js +1 -1
  17. package/es/ThemeProvider/index.js +0 -2
  18. package/es/Tooltip/index.js +5 -2
  19. package/es/components/ControlInput.d.ts +1 -1
  20. package/es/components/ControlInput.js +20 -23
  21. package/es/index.d.ts +1 -0
  22. package/es/index.js +1 -0
  23. package/es/styles/theme/base.js +4 -4
  24. package/es/types/index.d.ts +15 -4
  25. package/lib/ActionIcon/index.js +2 -2
  26. package/lib/EditableMessageList/index.js +6 -6
  27. package/lib/EditableText/index.js +10 -6
  28. package/lib/Icon/index.d.ts +1 -0
  29. package/lib/Icon/index.js +5 -2
  30. package/lib/Input/index.d.ts +13 -0
  31. package/lib/Input/index.js +41 -0
  32. package/lib/Input/style.d.ts +6 -0
  33. package/lib/Input/style.js +71 -0
  34. package/lib/MessageInput/index.d.ts +2 -0
  35. package/lib/MessageInput/index.js +6 -5
  36. package/lib/SearchBar/index.d.ts +6 -3
  37. package/lib/SearchBar/index.js +46 -12
  38. package/lib/SearchBar/style.d.ts +6 -0
  39. package/lib/SearchBar/style.js +49 -0
  40. package/lib/StroyBook/style.js +6 -0
  41. package/lib/ThemeProvider/index.js +0 -1
  42. package/lib/Tooltip/index.js +2 -2
  43. package/lib/components/ControlInput.d.ts +1 -1
  44. package/lib/components/ControlInput.js +9 -19
  45. package/lib/index.d.ts +1 -0
  46. package/lib/index.js +5 -0
  47. package/lib/styles/theme/base.js +4 -4
  48. package/lib/types/index.d.ts +15 -4
  49. package/package.json +1 -1
@@ -36,7 +36,7 @@ var ActionIcon = /*#__PURE__*/memo(function (_ref) {
36
36
  borderRadius = 5;
37
37
  break;
38
38
  case 'small':
39
- blockSize = 28;
39
+ blockSize = 24;
40
40
  borderRadius = 5;
41
41
  break;
42
42
  case 'site':
@@ -57,7 +57,7 @@ var ActionIcon = /*#__PURE__*/memo(function (_ref) {
57
57
  }, style)
58
58
  }, props), {}, {
59
59
  children: /*#__PURE__*/_jsx(Icon, {
60
- size: size === 'site' ? 'small' : size,
60
+ size: size === 'site' ? 'normal' : size,
61
61
  icon: icon
62
62
  })
63
63
  }));
@@ -1,13 +1,13 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import IconAction from "../ActionIcon";
3
+ import { messagesReducer } from "../Chat";
4
+ import { ControlInput } from "../components/ControlInput";
2
5
  import { PlusOutlined } from '@ant-design/icons';
3
6
  import { Button, Select } from 'antd';
4
7
  import isEqual from 'fast-deep-equal';
8
+ import { TrashIcon } from 'lucide-react';
5
9
  import { memo, useEffect, useReducer } from 'react';
6
10
  import { Flexbox } from 'react-layout-kit';
7
- import IconAction from "../ActionIcon";
8
- import { messagesReducer } from "../Chat";
9
- import { ControlInput } from "../components/ControlInput";
10
- import { TrashIcon } from 'lucide-react';
11
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
12
  import { jsxs as _jsxs } from "react/jsx-runtime";
13
13
  export var EditableMessageList = /*#__PURE__*/memo(function (_ref) {
@@ -70,8 +70,8 @@ export var EditableMessageList = /*#__PURE__*/memo(function (_ref) {
70
70
  placeholder: item.role === 'user' ? '请填入输入的样例内容' : '请填入输出的样例'
71
71
  }), /*#__PURE__*/_jsx(IconAction, {
72
72
  icon: TrashIcon,
73
- title: '删除',
74
- size: 'small',
73
+ placement: "right",
74
+ title: "Delete",
75
75
  onClick: function onClick() {
76
76
  dispatch({
77
77
  type: 'deleteMessage',
@@ -1,9 +1,9 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
- import { EditOutlined } from '@ant-design/icons';
3
- import { Tooltip } from 'antd';
2
+ import { ControlInput } from "../components/ControlInput";
3
+ import { ActionIcon } from "./..";
4
+ import { Edit3 } from 'lucide-react';
4
5
  import { memo, useState } from 'react';
5
6
  import { Flexbox } from 'react-layout-kit';
6
- import { ControlInput } from "../components/ControlInput";
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  import { jsxs as _jsxs } from "react/jsx-runtime";
9
9
  var EditableText = /*#__PURE__*/memo(function (_ref) {
@@ -22,13 +22,14 @@ var EditableText = /*#__PURE__*/memo(function (_ref) {
22
22
  }) : /*#__PURE__*/_jsxs(Flexbox, {
23
23
  horizontal: true,
24
24
  gap: 8,
25
- children: [value, /*#__PURE__*/_jsx(Tooltip, {
26
- title: '编辑',
27
- children: /*#__PURE__*/_jsx(EditOutlined, {
28
- onClick: function onClick() {
29
- setEdited(!edited);
30
- }
31
- })
25
+ children: [value, /*#__PURE__*/_jsx(ActionIcon, {
26
+ title: 'Edit',
27
+ placement: "right",
28
+ icon: Edit3,
29
+ size: "small",
30
+ onClick: function onClick() {
31
+ setEdited(!edited);
32
+ }
32
33
  })]
33
34
  });
34
35
  });
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { SvgProps } from "../types";
2
3
  import { LucideIcon } from 'lucide-react';
3
4
  export declare type IconSize = 'large' | 'normal' | 'small' | {
4
5
  fontSize?: number;
package/es/Icon/index.js CHANGED
@@ -13,12 +13,15 @@ var Icon = function Icon(_ref) {
13
13
  var SvgIcon = icon;
14
14
  switch (size) {
15
15
  case 'large':
16
- case 'normal':
17
16
  fontSize = 24;
18
17
  strokeWidth = 2;
19
18
  break;
20
- case 'small':
19
+ case 'normal':
21
20
  fontSize = 20;
21
+ strokeWidth = 2;
22
+ break;
23
+ case 'small':
24
+ fontSize = 14;
22
25
  strokeWidth = 1.5;
23
26
  break;
24
27
  default:
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { InputProps as AntdInputProps } from 'antd';
3
+ import { TextAreaProps as AntdTextAreaProps } from 'antd/es/input/TextArea';
4
+ export interface InputProps extends AntdInputProps {
5
+ ref?: any;
6
+ type?: 'ghost' | 'block';
7
+ }
8
+ export declare const Input: import("react").NamedExoticComponent<InputProps>;
9
+ export interface TextAreaProps extends AntdTextAreaProps {
10
+ ref?: any;
11
+ type?: 'ghost' | 'block';
12
+ }
13
+ export declare const TextArea: import("react").NamedExoticComponent<TextAreaProps>;
@@ -0,0 +1,36 @@
1
+ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
+ var _excluded = ["className", "type"],
4
+ _excluded2 = ["className", "type"];
5
+ import { Input as AntInput } from 'antd';
6
+ import { memo } from 'react';
7
+ import { useStyles } from "./style";
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ export var Input = /*#__PURE__*/memo(function (_ref) {
10
+ var className = _ref.className,
11
+ _ref$type = _ref.type,
12
+ type = _ref$type === void 0 ? 'ghost' : _ref$type,
13
+ props = _objectWithoutProperties(_ref, _excluded);
14
+ var _useStyles = useStyles({
15
+ type: type
16
+ }),
17
+ styles = _useStyles.styles,
18
+ cx = _useStyles.cx;
19
+ return /*#__PURE__*/_jsx(AntInput, _objectSpread({
20
+ className: cx(styles.input, className)
21
+ }, props));
22
+ });
23
+ export var TextArea = /*#__PURE__*/memo(function (_ref2) {
24
+ var className = _ref2.className,
25
+ _ref2$type = _ref2.type,
26
+ type = _ref2$type === void 0 ? 'ghost' : _ref2$type,
27
+ props = _objectWithoutProperties(_ref2, _excluded2);
28
+ var _useStyles2 = useStyles({
29
+ type: type
30
+ }),
31
+ styles = _useStyles2.styles,
32
+ cx = _useStyles2.cx;
33
+ return /*#__PURE__*/_jsx(AntInput.TextArea, _objectSpread({
34
+ className: cx(styles.textarea, className)
35
+ }, props));
36
+ });
@@ -0,0 +1,6 @@
1
+ export declare const useStyles: (props?: {
2
+ type: 'ghost' | 'block';
3
+ } | undefined) => import("antd-style").ReturnStyles<{
4
+ input: import("antd-style").SerializedStyles;
5
+ textarea: import("antd-style").SerializedStyles;
6
+ }>;
@@ -0,0 +1,13 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2;
3
+ import { createStyles } from 'antd-style';
4
+ import { rgba } from 'polished';
5
+ export var useStyles = createStyles(function (_ref, _ref2) {
6
+ var css = _ref.css,
7
+ token = _ref.token;
8
+ var type = _ref2.type;
9
+ return {
10
+ input: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n\n max-width: 100%;\n height: 36px;\n padding: 0 12px;\n\n background-color: ", ";\n border: 1px solid ", ";\n\n transition: background-color 100ms ", ";\n\n input {\n background: transparent;\n }\n\n &:hover {\n background-color: ", ";\n }\n "])), type === 'block' ? rgba(token.colorBgElevated, 0.6) : 'transparent', type === 'block' ? 'transparent' : token.colorBorder, token.motionEaseOut, token.colorFillTertiary),
11
+ textarea: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n\n max-width: 100%;\n padding: 8px 12px;\n\n background-color: ", ";\n border: 1px solid ", ";\n\n transition: background-color 100ms ", ";\n\n textarea {\n background: transparent;\n }\n\n &:hover {\n background-color: ", ";\n }\n "])), type === 'block' ? rgba(token.colorBgElevated, 0.6) : 'transparent', type === 'block' ? 'transparent' : token.colorBorder, token.motionEaseOut, token.colorFillTertiary)
12
+ };
13
+ });
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { type TextAreaProps } from "../index";
2
3
  import { ButtonProps } from 'antd';
3
4
  /**
4
5
  * @title MessageInputProps
@@ -30,6 +31,7 @@ export interface MessageInputProps {
30
31
  renderButtons?: (text: string) => ButtonProps[];
31
32
  height?: number;
32
33
  className?: string;
34
+ type?: TextAreaProps['type'];
33
35
  }
34
36
  declare const MessageInput: import("react").NamedExoticComponent<MessageInputProps>;
35
37
  export default MessageInput;
@@ -1,6 +1,7 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
- import { Button, Input } from 'antd';
3
+ import { TextArea } from "./..";
4
+ import { Button } from 'antd';
4
5
  import { cx } from 'antd-style';
5
6
  import { memo, useState } from 'react';
6
7
  import { Flexbox } from 'react-layout-kit';
@@ -14,7 +15,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
14
15
  import { Fragment as _Fragment } from "react/jsx-runtime";
15
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
16
17
  var MessageInput = /*#__PURE__*/memo(function (_ref) {
17
- var onCancel = _ref.onCancel,
18
+ var type = _ref.type,
19
+ onCancel = _ref.onCancel,
18
20
  defaultValue = _ref.defaultValue,
19
21
  onConfirm = _ref.onConfirm,
20
22
  renderButtons = _ref.renderButtons,
@@ -26,9 +28,9 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
26
28
  setRole = _useState2[1];
27
29
  return /*#__PURE__*/_jsxs(Flexbox, {
28
30
  gap: 8,
29
- children: [/*#__PURE__*/_jsx(Input.TextArea, {
31
+ children: [/*#__PURE__*/_jsx(TextArea, {
32
+ type: type,
30
33
  value: tempSystemRole,
31
- allowClear: true,
32
34
  placeholder: '例如:你是一名擅长翻译的翻译官,请将用户所输入的英文都翻译为中文。',
33
35
  style: {
34
36
  height: height !== null && height !== void 0 ? height : 200
@@ -44,15 +46,15 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
44
46
  return /*#__PURE__*/_jsx(Button, _objectSpread({}, buttonProps), index);
45
47
  }) : /*#__PURE__*/_jsxs(_Fragment, {
46
48
  children: [/*#__PURE__*/_jsx(Button, {
47
- type: 'primary',
49
+ type: "primary",
48
50
  onClick: function onClick() {
49
51
  onConfirm === null || onConfirm === void 0 ? void 0 : onConfirm(tempSystemRole);
50
52
  },
51
- children: "\u8BBE\u5B9A"
53
+ children: "Confirm"
52
54
  }), /*#__PURE__*/_jsx(Button, {
53
- type: 'text',
55
+ type: "text",
54
56
  onClick: onCancel,
55
- children: "\u53D6\u6D88"
57
+ children: "Cancel"
56
58
  })]
57
59
  })
58
60
  })]
@@ -1,5 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { InputProps } from 'antd';
3
- export declare type SearchBarProps = InputProps;
4
- declare const SearchBar: import("react").MemoExoticComponent<({ value, onChange, style, placeholder, ...props }: SearchBarProps) => import("react/jsx-runtime").JSX.Element>;
2
+ import { InputProps } from "../index";
3
+ export interface SearchBarProps extends InputProps {
4
+ shortKey?: string;
5
+ enableShortKey?: boolean;
6
+ }
7
+ declare const SearchBar: import("react").NamedExoticComponent<SearchBarProps>;
5
8
  export default SearchBar;
@@ -1,25 +1,82 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["value", "onChange", "style", "placeholder"];
4
- import { SearchOutlined } from '@ant-design/icons';
5
- import { Input } from 'antd';
6
- import { memo } from 'react';
4
+ var _excluded = ["className", "value", "onChange", "placeholder", "enableShortKey", "shortKey"];
5
+ var _navigator;
6
+ import { Icon, Input } from "./..";
7
+ import { Tag } from 'antd';
8
+ import { Search } from 'lucide-react';
9
+ import { memo, useEffect, useRef, useState } from 'react';
10
+ import { useStyles } from "./style";
7
11
  import { jsx as _jsx } from "react/jsx-runtime";
12
+ import { jsxs as _jsxs } from "react/jsx-runtime";
13
+ var isAppleDevice = /(mac|iphone|ipod|ipad)/i.test(typeof navigator !== 'undefined' ? (_navigator = navigator) === null || _navigator === void 0 ? void 0 : _navigator.platform : '');
14
+ var symbol = isAppleDevice ? '⌘' : 'Ctrl';
8
15
  var SearchBar = /*#__PURE__*/memo(function (_ref) {
9
- var value = _ref.value,
10
- onChange = _ref.onChange,
11
- style = _ref.style,
16
+ var className = _ref.className,
17
+ value = _ref.value,
18
+ _onChange = _ref.onChange,
12
19
  placeholder = _ref.placeholder,
20
+ enableShortKey = _ref.enableShortKey,
21
+ _ref$shortKey = _ref.shortKey,
22
+ shortKey = _ref$shortKey === void 0 ? 'f' : _ref$shortKey,
13
23
  props = _objectWithoutProperties(_ref, _excluded);
14
- return /*#__PURE__*/_jsx(Input, _objectSpread({
15
- prefix: /*#__PURE__*/_jsx(SearchOutlined, {}),
16
- allowClear: true,
17
- value: value,
18
- placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : 'Search',
19
- style: _objectSpread(_objectSpread({}, style), {}, {
20
- borderColor: 'transparent'
21
- }),
22
- onChange: onChange
23
- }, props));
24
+ var _useState = useState(true),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ showTag = _useState2[0],
27
+ setShowTag = _useState2[1];
28
+ var _useState3 = useState(value),
29
+ _useState4 = _slicedToArray(_useState3, 2),
30
+ inputValue = _useState4[0],
31
+ setInputValue = _useState4[1];
32
+ var _useStyles = useStyles(),
33
+ styles = _useStyles.styles,
34
+ cx = _useStyles.cx;
35
+ var inputRef = useRef(null);
36
+ useEffect(function () {
37
+ if (!enableShortKey) return;
38
+ var handler = function handler(ev) {
39
+ if ((isAppleDevice ? ev.metaKey : ev.ctrlKey) && ev.key === shortKey) {
40
+ ev.preventDefault();
41
+ inputRef.current.focus();
42
+ }
43
+ };
44
+ document.addEventListener('keydown', handler);
45
+ return function () {
46
+ return document.removeEventListener('keydown', handler);
47
+ };
48
+ }, []);
49
+ return /*#__PURE__*/_jsxs("div", {
50
+ className: styles.search,
51
+ children: [/*#__PURE__*/_jsx(Input, _objectSpread({
52
+ ref: inputRef,
53
+ className: cx(styles.input, className),
54
+ prefix: /*#__PURE__*/_jsx(Icon, {
55
+ className: styles.icon,
56
+ icon: Search,
57
+ size: "small",
58
+ style: {
59
+ marginRight: 4
60
+ }
61
+ }),
62
+ allowClear: true,
63
+ value: value,
64
+ placeholder: placeholder !== null && placeholder !== void 0 ? placeholder : 'Type keywords...',
65
+ onChange: function onChange(e) {
66
+ setInputValue(e.target.value);
67
+ setShowTag(e.target.value ? false : true);
68
+ if (_onChange) _onChange(e);
69
+ },
70
+ onFocus: function onFocus() {
71
+ return setShowTag(false);
72
+ },
73
+ onBlur: function onBlur() {
74
+ return setShowTag(true);
75
+ }
76
+ }, props)), enableShortKey && showTag && !inputValue && /*#__PURE__*/_jsxs(Tag, {
77
+ className: styles.tag,
78
+ children: [symbol, " ", shortKey.toUpperCase()]
79
+ })]
80
+ });
24
81
  });
25
82
  export default SearchBar;
@@ -0,0 +1,6 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ search: import("antd-style").SerializedStyles;
3
+ input: import("antd-style").SerializedStyles;
4
+ tag: import("antd-style").SerializedStyles;
5
+ icon: import("antd-style").SerializedStyles;
6
+ }>;
@@ -0,0 +1,13 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
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
+ search: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n max-width: 100%;\n "]))),
9
+ input: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: relative;\n padding: 0 8px 0 12px;\n "]))),
10
+ tag: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n position: absolute;\n z-index: 5;\n top: 50%;\n right: 0;\n transform: translateY(-50%);\n "]))),
11
+ icon: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorTextPlaceholder)
12
+ };
13
+ });
@@ -9,6 +9,6 @@ export var useStyles = createStyles(function (_ref, _ref2) {
9
9
  return {
10
10
  editor: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n align-items: stretch;\n justify-content: stretch;\n\n width: inherit;\n min-height: inherit;\n ", "\n "])), mobile && css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n flex-direction: column;\n "])))),
11
11
  left: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n overflow: auto;\n display: flex;\n flex: 1;\n align-items: center;\n justify-content: center;\n\n ", "\n "])), !noPadding && css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n padding: 40px 24px;\n "])))),
12
- right: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n --leva-sizes-controlWidth: 66%;\n --leva-colors-elevation1: ", ";\n --leva-colors-elevation2: transparent;\n --leva-colors-elevation3: ", ";\n --leva-colors-accent1: ", ";\n --leva-colors-accent2: ", ";\n --leva-colors-accent3: ", ";\n --leva-colors-highlight1: ", ";\n --leva-colors-highlight2: ", ";\n --leva-colors-highlight3: ", ";\n --leva-colors-vivid1: ", ";\n --leva-shadows-level1: unset;\n --leva-shadows-level2: unset;\n\n padding: 6px 0;\n background: ", ";\n > div {\n background: transparent;\n > div {\n background: transparent;\n }\n }\n input:checked + label > svg {\n stroke: ", ";\n }\n "])), token.colorFillSecondary, token.colorFillSecondary, token.colorPrimary, token.colorPrimaryHover, token.colorPrimaryActive, token.colorTextTertiary, token.colorTextSecondary, token.colorText, token.colorWarning, token.colorBgLayout, token.colorBorder)
12
+ right: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n --leva-sizes-controlWidth: 66%;\n --leva-colors-elevation1: ", ";\n --leva-colors-elevation2: transparent;\n --leva-colors-elevation3: ", ";\n --leva-colors-accent1: ", ";\n --leva-colors-accent2: ", ";\n --leva-colors-accent3: ", ";\n --leva-colors-highlight1: ", ";\n --leva-colors-highlight2: ", ";\n --leva-colors-highlight3: ", ";\n --leva-colors-vivid1: ", ";\n --leva-shadows-level1: unset;\n --leva-shadows-level2: unset;\n --leva-fonts-mono: ", ";\n\n padding: 6px 0;\n background: ", ";\n > div {\n background: transparent;\n > div {\n background: transparent;\n }\n }\n\n input:checked + label > svg {\n stroke: ", ";\n }\n\n button {\n --leva-colors-accent2: ", ";\n }\n "])), token.colorFillSecondary, token.colorFillSecondary, token.colorPrimary, token.colorPrimaryHover, token.colorPrimaryActive, token.colorTextTertiary, token.colorTextSecondary, token.colorText, token.colorWarning, token.fontFamilyCode, token.colorBgLayout, token.colorBorder, token.colorFillSecondary)
13
13
  };
14
14
  });
@@ -32,8 +32,6 @@ var ThemeProvider = function ThemeProvider(_ref) {
32
32
  customStylish: getCustomStylish,
33
33
  customToken: getCustomToken,
34
34
  children: [/*#__PURE__*/_jsx(ReactFontLoader, {
35
- url: "https://raw.githubusercontent.com/divspace/hack/master/css/hack.css"
36
- }), /*#__PURE__*/_jsx(ReactFontLoader, {
37
35
  url: "https://raw.githubusercontent.com/IKKI2000/harmonyos-fonts/main/css/harmonyos_sans.css"
38
36
  }), /*#__PURE__*/_jsx(ReactFontLoader, {
39
37
  url: "https://raw.githubusercontent.com/IKKI2000/harmonyos-fonts/main/css/harmonyos_sans_sc.css"
@@ -1,18 +1,21 @@
1
1
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
3
- var _excluded = ["className"];
3
+ var _excluded = ["className", "arrow"];
4
4
  import { Tooltip as AntdTooltip } from 'antd';
5
5
  import { memo } from 'react';
6
6
  import { useStyles } from "./style";
7
7
  import { jsx as _jsx } from "react/jsx-runtime";
8
8
  var Tooltip = /*#__PURE__*/memo(function (_ref) {
9
9
  var className = _ref.className,
10
+ _ref$arrow = _ref.arrow,
11
+ arrow = _ref$arrow === void 0 ? false : _ref$arrow,
10
12
  props = _objectWithoutProperties(_ref, _excluded);
11
13
  var _useStyles = useStyles(),
12
14
  styles = _useStyles.styles,
13
15
  cx = _useStyles.cx;
14
16
  return /*#__PURE__*/_jsx(AntdTooltip, _objectSpread({
15
- overlayClassName: cx(styles.tooltip, className)
17
+ overlayClassName: cx(styles.tooltip, className),
18
+ arrow: arrow
16
19
  }, props));
17
20
  });
18
21
  export default Tooltip;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { InputProps } from 'antd';
2
+ import { InputProps } from "../index";
3
3
  export interface ControlInputProps extends Omit<InputProps, 'onChange' | 'value' | 'onAbort'> {
4
4
  onChange?: (value: string) => void;
5
5
  onValueChanging?: (value: string) => void;
@@ -2,7 +2,9 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
2
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
4
  var _excluded = ["value", "onChange", "onValueChanging", "onChangeEnd"];
5
- import { Button, ConfigProvider, Input } from 'antd';
5
+ import { ActionIcon, Input } from "./..";
6
+ import { ConfigProvider, Space } from 'antd';
7
+ import { RotateCcw, Save } from 'lucide-react';
6
8
  import { memo, useCallback, useEffect, useRef, useState } from 'react';
7
9
  import { jsx as _jsx } from "react/jsx-runtime";
8
10
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -54,33 +56,28 @@ export var ControlInput = /*#__PURE__*/memo(function (_ref) {
54
56
  onChangeEnd === null || onChangeEnd === void 0 ? void 0 : onChangeEnd(input);
55
57
  }
56
58
  },
57
- suffix: value === input ? /*#__PURE__*/_jsx("span", {}) : /*#__PURE__*/_jsxs(ConfigProvider, {
59
+ suffix: value === input ? /*#__PURE__*/_jsx("span", {}) : /*#__PURE__*/_jsx(ConfigProvider, {
58
60
  theme: {
59
61
  token: {
60
62
  fontSize: 14
61
63
  }
62
64
  },
63
- children: [/*#__PURE__*/_jsx(Button, {
64
- type: 'link',
65
- size: 'small',
66
- onClick: function onClick() {
67
- setInput(value);
68
- },
69
- style: {
70
- padding: 0
71
- },
72
- children: "\u91CD\u7F6E"
73
- }), /*#__PURE__*/_jsx(Button, {
74
- type: 'link',
75
- size: 'small',
76
- style: {
77
- padding: 0
78
- },
79
- onClick: function onClick() {
80
- updateValue();
81
- },
82
- children: "\u4FDD\u5B58 \u21B5"
83
- })]
65
+ children: /*#__PURE__*/_jsxs(Space, {
66
+ size: 2,
67
+ children: [/*#__PURE__*/_jsx(ActionIcon, {
68
+ title: "Reset",
69
+ icon: RotateCcw,
70
+ size: "small",
71
+ onClick: function onClick() {
72
+ setInput(value);
73
+ }
74
+ }), /*#__PURE__*/_jsx(ActionIcon, {
75
+ title: "\u2705 Save",
76
+ icon: Save,
77
+ size: "small",
78
+ onClick: updateValue
79
+ })]
80
+ })
84
81
  })
85
82
  }));
86
83
  });
package/es/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export { default as EditableMessageList, type EditableMessageListProps, } from '
10
10
  export { default as EditableText, type EditableTextProps } from './EditableText';
11
11
  export { default as Highlighter, SyntaxHighlighter, type HighlighterProps, type SyntaxHighlighterProps, } from './Highlighter';
12
12
  export { default as Icon, type IconProps, type IconSize } from './Icon';
13
+ export { Input, TextArea, type InputProps, type TextAreaProps } from './Input';
13
14
  export { default as List } from './List';
14
15
  export { default as Logo, type LogoProps } from './Logo';
15
16
  export { default as Markdown, type MarkdownProps } from './Markdown';
package/es/index.js CHANGED
@@ -9,6 +9,7 @@ export { default as EditableMessageList } from "./EditableMessageList";
9
9
  export { default as EditableText } from "./EditableText";
10
10
  export { default as Highlighter, SyntaxHighlighter } from "./Highlighter";
11
11
  export { default as Icon } from "./Icon";
12
+ export { Input, TextArea } from "./Input";
12
13
  export { default as List } from "./List";
13
14
  export { default as Logo } from "./Logo";
14
15
  export { default as Markdown } from "./Markdown";
@@ -1,7 +1,7 @@
1
- var FONT_EMOJI = "\"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Apple Color Emoji\", \"Twemoji Mozilla\", \"Noto Color Emoji\", \"Android Emoji\"";
2
- var FONT_EN = "\"HarmonyOS Sans\", \"Segoe UI\", \"SF Pro Display\",-apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, \"Open Sans\", \"Helvetica Neue\", sans-serif";
3
- var FONT_CN = "\"HarmonyOS Sans SC\", \"PingFang SC\", \"Hiragino Sans GB\", \"Microsoft Yahei UI\", \"Microsoft Yahei\", \"Source Han Sans CN\", sans-serif";
4
- var FONT_CODE = "Hack, \"SFMono Regular\", Consolas, \"Liberation Mono\", Menlo, Courier, monospace";
1
+ var FONT_EMOJI = "\"Segoe UI Emoji\",\"Segoe UI Symbol\",\"Apple Color Emoji\",\"Twemoji Mozilla\",\"Noto Color Emoji\",\"Android Emoji\"";
2
+ var FONT_EN = "\"HarmonyOS Sans\",\"Segoe UI\",\"SF Pro Display\",-apple-system,BlinkMacSystemFont,Roboto,Oxygen,Ubuntu,Cantarell,\"Open Sans\",\"Helvetica Neue\",sans-serif";
3
+ var FONT_CN = "\"HarmonyOS Sans SC\",\"PingFang SC\",\"Hiragino Sans GB\",\"Microsoft Yahei UI\",\"Microsoft Yahei\",\"Source Han Sans CN\",sans-serif";
4
+ var FONT_CODE = "ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace";
5
5
  export var baseTheme = {
6
6
  token: {
7
7
  colorInfo: '#0070f3',
@@ -11,8 +11,19 @@ export type DivProps = React.DetailedHTMLProps<
11
11
  HTMLDivElement
12
12
  >;
13
13
 
14
- declare global {
15
- type SvgProps = React.DetailedHTMLProps<React.HTMLAttributes<SVGSVGElement>, SVGSVGElement>;
14
+ export type SvgProps = React.DetailedHTMLProps<React.HTMLAttributes<SVGSVGElement>, SVGSVGElement>;
16
15
 
17
- type ImgProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLImageElement>, HTMLImageElement>;
18
- }
16
+ export type ImgProps = React.DetailedHTMLProps<
17
+ React.HTMLAttributes<HTMLImageElement>,
18
+ HTMLImageElement
19
+ >;
20
+
21
+ export type InputProps = React.DetailedHTMLProps<
22
+ React.HTMLAttributes<HTMLInputElement>,
23
+ HTMLInputElement
24
+ >;
25
+
26
+ export type TextAreaProps = React.DetailedHTMLProps<
27
+ React.HTMLAttributes<HTMLTextAreaElement>,
28
+ HTMLTextAreaElement
29
+ >;
@@ -51,7 +51,7 @@ var ActionIcon = (0, import_react.memo)(
51
51
  borderRadius = 5;
52
52
  break;
53
53
  case "small":
54
- blockSize = 28;
54
+ blockSize = 24;
55
55
  borderRadius = 5;
56
56
  break;
57
57
  case "site":
@@ -70,7 +70,7 @@ var ActionIcon = (0, import_react.memo)(
70
70
  style: { width: blockSize, height: blockSize, borderRadius, ...style },
71
71
  ...props
72
72
  },
73
- /* @__PURE__ */ React.createElement(import__.Icon, { size: size === "site" ? "small" : size, icon })
73
+ /* @__PURE__ */ React.createElement(import__.Icon, { size: size === "site" ? "normal" : size, icon })
74
74
  );
75
75
  if (!title)
76
76
  return actionIconBlock;
@@ -33,15 +33,15 @@ __export(EditableMessageList_exports, {
33
33
  default: () => EditableMessageList_default
34
34
  });
35
35
  module.exports = __toCommonJS(EditableMessageList_exports);
36
+ var import_ActionIcon = __toESM(require("../ActionIcon"));
37
+ var import_Chat = require("../Chat");
38
+ var import_ControlInput = require("../components/ControlInput");
36
39
  var import_icons = require("@ant-design/icons");
37
40
  var import_antd = require("antd");
38
41
  var import_fast_deep_equal = __toESM(require("fast-deep-equal"));
42
+ var import_lucide_react = require("lucide-react");
39
43
  var import_react = require("react");
40
44
  var import_react_layout_kit = require("react-layout-kit");
41
- var import_ActionIcon = __toESM(require("../ActionIcon"));
42
- var import_Chat = require("../Chat");
43
- var import_ControlInput = require("../components/ControlInput");
44
- var import_lucide_react = require("lucide-react");
45
45
  var EditableMessageList = (0, import_react.memo)(
46
46
  ({ disabled, dataSources, onChange }) => {
47
47
  const [chatMessages, dispatch] = (0, import_react.useReducer)(import_Chat.messagesReducer, dataSources);
@@ -91,8 +91,8 @@ var EditableMessageList = (0, import_react.memo)(
91
91
  import_ActionIcon.default,
92
92
  {
93
93
  icon: import_lucide_react.TrashIcon,
94
- title: "删除",
95
- size: "small",
94
+ placement: "right",
95
+ title: "Delete",
96
96
  onClick: () => {
97
97
  dispatch({ type: "deleteMessage", index });
98
98
  }
@@ -22,11 +22,11 @@ __export(EditableText_exports, {
22
22
  default: () => EditableText_default
23
23
  });
24
24
  module.exports = __toCommonJS(EditableText_exports);
25
- var import_icons = require("@ant-design/icons");
26
- var import_antd = require("antd");
25
+ var import_ControlInput = require("../components/ControlInput");
26
+ var import__ = require("../index");
27
+ var import_lucide_react = require("lucide-react");
27
28
  var import_react = require("react");
28
29
  var import_react_layout_kit = require("react-layout-kit");
29
- var import_ControlInput = require("../components/ControlInput");
30
30
  var EditableText = (0, import_react.memo)(({ value, onChange }) => {
31
31
  const [edited, setEdited] = (0, import_react.useState)(false);
32
32
  return edited ? /* @__PURE__ */ React.createElement(
@@ -38,14 +38,18 @@ var EditableText = (0, import_react.memo)(({ value, onChange }) => {
38
38
  },
39
39
  onChange
40
40
  }
41
- ) : /* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, { horizontal: true, gap: 8 }, value, /* @__PURE__ */ React.createElement(import_antd.Tooltip, { title: "编辑" }, /* @__PURE__ */ React.createElement(
42
- import_icons.EditOutlined,
41
+ ) : /* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, { horizontal: true, gap: 8 }, value, /* @__PURE__ */ React.createElement(
42
+ import__.ActionIcon,
43
43
  {
44
+ title: "Edit",
45
+ placement: "right",
46
+ icon: import_lucide_react.Edit3,
47
+ size: "small",
44
48
  onClick: () => {
45
49
  setEdited(!edited);
46
50
  }
47
51
  }
48
- )));
52
+ ));
49
53
  });
50
54
  var EditableText_default = EditableText;
51
55
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { SvgProps } from "../types";
2
3
  import { LucideIcon } from 'lucide-react';
3
4
  export declare type IconSize = 'large' | 'normal' | 'small' | {
4
5
  fontSize?: number;
package/lib/Icon/index.js CHANGED
@@ -29,12 +29,15 @@ var Icon = ({ icon, size = "normal", ...props }) => {
29
29
  const SvgIcon = icon;
30
30
  switch (size) {
31
31
  case "large":
32
- case "normal":
33
32
  fontSize = 24;
34
33
  strokeWidth = 2;
35
34
  break;
36
- case "small":
35
+ case "normal":
37
36
  fontSize = 20;
37
+ strokeWidth = 2;
38
+ break;
39
+ case "small":
40
+ fontSize = 14;
38
41
  strokeWidth = 1.5;
39
42
  break;
40
43
  default:
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ import { InputProps as AntdInputProps } from 'antd';
3
+ import { TextAreaProps as AntdTextAreaProps } from 'antd/es/input/TextArea';
4
+ export interface InputProps extends AntdInputProps {
5
+ ref?: any;
6
+ type?: 'ghost' | 'block';
7
+ }
8
+ export declare const Input: import("react").NamedExoticComponent<InputProps>;
9
+ export interface TextAreaProps extends AntdTextAreaProps {
10
+ ref?: any;
11
+ type?: 'ghost' | 'block';
12
+ }
13
+ export declare const TextArea: import("react").NamedExoticComponent<TextAreaProps>;
@@ -0,0 +1,41 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/Input/index.tsx
20
+ var Input_exports = {};
21
+ __export(Input_exports, {
22
+ Input: () => Input,
23
+ TextArea: () => TextArea
24
+ });
25
+ module.exports = __toCommonJS(Input_exports);
26
+ var import_antd = require("antd");
27
+ var import_react = require("react");
28
+ var import_style = require("./style");
29
+ var Input = (0, import_react.memo)(({ className, type = "ghost", ...props }) => {
30
+ const { styles, cx } = (0, import_style.useStyles)({ type });
31
+ return /* @__PURE__ */ React.createElement(import_antd.Input, { className: cx(styles.input, className), ...props });
32
+ });
33
+ var TextArea = (0, import_react.memo)(({ className, type = "ghost", ...props }) => {
34
+ const { styles, cx } = (0, import_style.useStyles)({ type });
35
+ return /* @__PURE__ */ React.createElement(import_antd.Input.TextArea, { className: cx(styles.textarea, className), ...props });
36
+ });
37
+ // Annotate the CommonJS export names for ESM import in node:
38
+ 0 && (module.exports = {
39
+ Input,
40
+ TextArea
41
+ });
@@ -0,0 +1,6 @@
1
+ export declare const useStyles: (props?: {
2
+ type: 'ghost' | 'block';
3
+ } | undefined) => import("antd-style").ReturnStyles<{
4
+ input: import("antd-style").SerializedStyles;
5
+ textarea: import("antd-style").SerializedStyles;
6
+ }>;
@@ -0,0 +1,71 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/Input/style.ts
20
+ var style_exports = {};
21
+ __export(style_exports, {
22
+ useStyles: () => useStyles
23
+ });
24
+ module.exports = __toCommonJS(style_exports);
25
+ var import_antd_style = require("antd-style");
26
+ var import_polished = require("polished");
27
+ var useStyles = (0, import_antd_style.createStyles)(({ css, token }, { type }) => ({
28
+ input: css`
29
+ position: relative;
30
+
31
+ max-width: 100%;
32
+ height: 36px;
33
+ padding: 0 12px;
34
+
35
+ background-color: ${type === "block" ? (0, import_polished.rgba)(token.colorBgElevated, 0.6) : "transparent"};
36
+ border: 1px solid ${type === "block" ? "transparent" : token.colorBorder};
37
+
38
+ transition: background-color 100ms ${token.motionEaseOut};
39
+
40
+ input {
41
+ background: transparent;
42
+ }
43
+
44
+ &:hover {
45
+ background-color: ${token.colorFillTertiary};
46
+ }
47
+ `,
48
+ textarea: css`
49
+ position: relative;
50
+
51
+ max-width: 100%;
52
+ padding: 8px 12px;
53
+
54
+ background-color: ${type === "block" ? (0, import_polished.rgba)(token.colorBgElevated, 0.6) : "transparent"};
55
+ border: 1px solid ${type === "block" ? "transparent" : token.colorBorder};
56
+
57
+ transition: background-color 100ms ${token.motionEaseOut};
58
+
59
+ textarea {
60
+ background: transparent;
61
+ }
62
+
63
+ &:hover {
64
+ background-color: ${token.colorFillTertiary};
65
+ }
66
+ `
67
+ }));
68
+ // Annotate the CommonJS export names for ESM import in node:
69
+ 0 && (module.exports = {
70
+ useStyles
71
+ });
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import { type TextAreaProps } from "../index";
2
3
  import { ButtonProps } from 'antd';
3
4
  /**
4
5
  * @title MessageInputProps
@@ -30,6 +31,7 @@ export interface MessageInputProps {
30
31
  renderButtons?: (text: string) => ButtonProps[];
31
32
  height?: number;
32
33
  className?: string;
34
+ type?: TextAreaProps['type'];
33
35
  }
34
36
  declare const MessageInput: import("react").NamedExoticComponent<MessageInputProps>;
35
37
  export default MessageInput;
@@ -22,18 +22,19 @@ __export(MessageInput_exports, {
22
22
  default: () => MessageInput_default
23
23
  });
24
24
  module.exports = __toCommonJS(MessageInput_exports);
25
+ var import__ = require("../index");
25
26
  var import_antd = require("antd");
26
27
  var import_antd_style = require("antd-style");
27
28
  var import_react = require("react");
28
29
  var import_react_layout_kit = require("react-layout-kit");
29
30
  var MessageInput = (0, import_react.memo)(
30
- ({ onCancel, defaultValue, onConfirm, renderButtons, height, className }) => {
31
+ ({ type, onCancel, defaultValue, onConfirm, renderButtons, height, className }) => {
31
32
  const [tempSystemRole, setRole] = (0, import_react.useState)(defaultValue || "");
32
33
  return /* @__PURE__ */ React.createElement(import_react_layout_kit.Flexbox, { gap: 8 }, /* @__PURE__ */ React.createElement(
33
- import_antd.Input.TextArea,
34
+ import__.TextArea,
34
35
  {
36
+ type,
35
37
  value: tempSystemRole,
36
- allowClear: true,
37
38
  placeholder: "例如:你是一名擅长翻译的翻译官,请将用户所输入的英文都翻译为中文。",
38
39
  style: { height: height ?? 200 },
39
40
  onChange: (e) => {
@@ -49,8 +50,8 @@ var MessageInput = (0, import_react.memo)(
49
50
  onConfirm == null ? void 0 : onConfirm(tempSystemRole);
50
51
  }
51
52
  },
52
- "设定"
53
- ), /* @__PURE__ */ React.createElement(import_antd.Button, { type: "text", onClick: onCancel }, "取消"))));
53
+ "Confirm"
54
+ ), /* @__PURE__ */ React.createElement(import_antd.Button, { type: "text", onClick: onCancel }, "Cancel"))));
54
55
  }
55
56
  );
56
57
  var MessageInput_default = MessageInput;
@@ -1,5 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { InputProps } from 'antd';
3
- export declare type SearchBarProps = InputProps;
4
- declare const SearchBar: import("react").MemoExoticComponent<({ value, onChange, style, placeholder, ...props }: SearchBarProps) => import("react/jsx-runtime").JSX.Element>;
2
+ import { InputProps } from "../index";
3
+ export interface SearchBarProps extends InputProps {
4
+ shortKey?: string;
5
+ enableShortKey?: boolean;
6
+ }
7
+ declare const SearchBar: import("react").NamedExoticComponent<SearchBarProps>;
5
8
  export default SearchBar;
@@ -22,21 +22,55 @@ __export(SearchBar_exports, {
22
22
  default: () => SearchBar_default
23
23
  });
24
24
  module.exports = __toCommonJS(SearchBar_exports);
25
- var import_icons = require("@ant-design/icons");
25
+ var import__ = require("../index");
26
26
  var import_antd = require("antd");
27
+ var import_lucide_react = require("lucide-react");
27
28
  var import_react = require("react");
28
- var SearchBar = (0, import_react.memo)(({ value, onChange, style, placeholder, ...props }) => /* @__PURE__ */ React.createElement(
29
- import_antd.Input,
30
- {
31
- prefix: /* @__PURE__ */ React.createElement(import_icons.SearchOutlined, null),
32
- allowClear: true,
33
- value,
34
- placeholder: placeholder ?? "Search",
35
- style: { ...style, borderColor: "transparent" },
36
- onChange,
37
- ...props
29
+ var import_style = require("./style");
30
+ var isAppleDevice = /(mac|iphone|ipod|ipad)/i.test(
31
+ typeof navigator !== "undefined" ? navigator == null ? void 0 : navigator.platform : ""
32
+ );
33
+ var symbol = isAppleDevice ? "⌘" : "Ctrl";
34
+ var SearchBar = (0, import_react.memo)(
35
+ ({ className, value, onChange, placeholder, enableShortKey, shortKey = "f", ...props }) => {
36
+ const [showTag, setShowTag] = (0, import_react.useState)(true);
37
+ const [inputValue, setInputValue] = (0, import_react.useState)(value);
38
+ const { styles, cx } = (0, import_style.useStyles)();
39
+ const inputRef = (0, import_react.useRef)(null);
40
+ (0, import_react.useEffect)(() => {
41
+ if (!enableShortKey)
42
+ return;
43
+ const handler = (ev) => {
44
+ if ((isAppleDevice ? ev.metaKey : ev.ctrlKey) && ev.key === shortKey) {
45
+ ev.preventDefault();
46
+ inputRef.current.focus();
47
+ }
48
+ };
49
+ document.addEventListener("keydown", handler);
50
+ return () => document.removeEventListener("keydown", handler);
51
+ }, []);
52
+ return /* @__PURE__ */ React.createElement("div", { className: styles.search }, /* @__PURE__ */ React.createElement(
53
+ import__.Input,
54
+ {
55
+ ref: inputRef,
56
+ className: cx(styles.input, className),
57
+ prefix: /* @__PURE__ */ React.createElement(import__.Icon, { className: styles.icon, icon: import_lucide_react.Search, size: "small", style: { marginRight: 4 } }),
58
+ allowClear: true,
59
+ value,
60
+ placeholder: placeholder ?? "Type keywords...",
61
+ onChange: (e) => {
62
+ setInputValue(e.target.value);
63
+ setShowTag(e.target.value ? false : true);
64
+ if (onChange)
65
+ onChange(e);
66
+ },
67
+ onFocus: () => setShowTag(false),
68
+ onBlur: () => setShowTag(true),
69
+ ...props
70
+ }
71
+ ), enableShortKey && showTag && !inputValue && /* @__PURE__ */ React.createElement(import_antd.Tag, { className: styles.tag }, symbol, " ", shortKey.toUpperCase()));
38
72
  }
39
- ));
73
+ );
40
74
  var SearchBar_default = SearchBar;
41
75
  // Annotate the CommonJS export names for ESM import in node:
42
76
  0 && (module.exports = {});
@@ -0,0 +1,6 @@
1
+ export declare const useStyles: (props?: unknown) => import("antd-style").ReturnStyles<{
2
+ search: import("antd-style").SerializedStyles;
3
+ input: import("antd-style").SerializedStyles;
4
+ tag: import("antd-style").SerializedStyles;
5
+ icon: import("antd-style").SerializedStyles;
6
+ }>;
@@ -0,0 +1,49 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/SearchBar/style.ts
20
+ var style_exports = {};
21
+ __export(style_exports, {
22
+ useStyles: () => useStyles
23
+ });
24
+ module.exports = __toCommonJS(style_exports);
25
+ var import_antd_style = require("antd-style");
26
+ var useStyles = (0, import_antd_style.createStyles)(({ css, token }) => ({
27
+ search: css`
28
+ position: relative;
29
+ max-width: 100%;
30
+ `,
31
+ input: css`
32
+ position: relative;
33
+ padding: 0 8px 0 12px;
34
+ `,
35
+ tag: css`
36
+ position: absolute;
37
+ z-index: 5;
38
+ top: 50%;
39
+ right: 0;
40
+ transform: translateY(-50%);
41
+ `,
42
+ icon: css`
43
+ color: ${token.colorTextPlaceholder};
44
+ `
45
+ }));
46
+ // Annotate the CommonJS export names for ESM import in node:
47
+ 0 && (module.exports = {
48
+ useStyles
49
+ });
@@ -62,6 +62,7 @@ var useStyles = (0, import_antd_style.createStyles)(
62
62
  --leva-colors-vivid1: ${token.colorWarning};
63
63
  --leva-shadows-level1: unset;
64
64
  --leva-shadows-level2: unset;
65
+ --leva-fonts-mono: ${token.fontFamilyCode};
65
66
 
66
67
  padding: 6px 0;
67
68
  background: ${token.colorBgLayout};
@@ -71,9 +72,14 @@ var useStyles = (0, import_antd_style.createStyles)(
71
72
  background: transparent;
72
73
  }
73
74
  }
75
+
74
76
  input:checked + label > svg {
75
77
  stroke: ${token.colorBorder};
76
78
  }
79
+
80
+ button {
81
+ --leva-colors-accent2: ${token.colorFillSecondary};
82
+ }
77
83
  `
78
84
  };
79
85
  }
@@ -60,7 +60,6 @@ var ThemeProvider = ({ token, children, themeMode }) => {
60
60
  customStylish: import_styles.getCustomStylish,
61
61
  customToken: getCustomToken
62
62
  },
63
- /* @__PURE__ */ import_react.default.createElement(import_react_font_loader.default, { url: "https://raw.githubusercontent.com/divspace/hack/master/css/hack.css" }),
64
63
  /* @__PURE__ */ import_react.default.createElement(import_react_font_loader.default, { url: "https://raw.githubusercontent.com/IKKI2000/harmonyos-fonts/main/css/harmonyos_sans.css" }),
65
64
  /* @__PURE__ */ import_react.default.createElement(import_react_font_loader.default, { url: "https://raw.githubusercontent.com/IKKI2000/harmonyos-fonts/main/css/harmonyos_sans_sc.css" }),
66
65
  /* @__PURE__ */ import_react.default.createElement(import_GlobalStyle.default, null),
@@ -25,9 +25,9 @@ module.exports = __toCommonJS(Tooltip_exports);
25
25
  var import_antd = require("antd");
26
26
  var import_react = require("react");
27
27
  var import_style = require("./style");
28
- var Tooltip = (0, import_react.memo)(({ className, ...props }) => {
28
+ var Tooltip = (0, import_react.memo)(({ className, arrow = false, ...props }) => {
29
29
  const { styles, cx } = (0, import_style.useStyles)();
30
- return /* @__PURE__ */ React.createElement(import_antd.Tooltip, { overlayClassName: cx(styles.tooltip, className), ...props });
30
+ return /* @__PURE__ */ React.createElement(import_antd.Tooltip, { overlayClassName: cx(styles.tooltip, className), arrow, ...props });
31
31
  });
32
32
  var Tooltip_default = Tooltip;
33
33
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { InputProps } from 'antd';
2
+ import { InputProps } from "../index";
3
3
  export interface ControlInputProps extends Omit<InputProps, 'onChange' | 'value' | 'onAbort'> {
4
4
  onChange?: (value: string) => void;
5
5
  onValueChanging?: (value: string) => void;
@@ -22,7 +22,9 @@ __export(ControlInput_exports, {
22
22
  ControlInput: () => ControlInput
23
23
  });
24
24
  module.exports = __toCommonJS(ControlInput_exports);
25
+ var import__ = require("../index");
25
26
  var import_antd = require("antd");
27
+ var import_lucide_react = require("lucide-react");
26
28
  var import_react = require("react");
27
29
  var ControlInput = (0, import_react.memo)(
28
30
  ({ value, onChange, onValueChanging, onChangeEnd, ...props }) => {
@@ -38,7 +40,7 @@ var ControlInput = (0, import_react.memo)(
38
40
  setInput(value);
39
41
  }, [value]);
40
42
  return /* @__PURE__ */ React.createElement(
41
- import_antd.Input,
43
+ import__.Input,
42
44
  {
43
45
  ref: inputRef,
44
46
  ...props,
@@ -68,29 +70,17 @@ var ControlInput = (0, import_react.memo)(
68
70
  onChangeEnd == null ? void 0 : onChangeEnd(input);
69
71
  }
70
72
  },
71
- suffix: value === input ? /* @__PURE__ */ React.createElement("span", null) : /* @__PURE__ */ React.createElement(import_antd.ConfigProvider, { theme: { token: { fontSize: 14 } } }, /* @__PURE__ */ React.createElement(
72
- import_antd.Button,
73
+ suffix: value === input ? /* @__PURE__ */ React.createElement("span", null) : /* @__PURE__ */ React.createElement(import_antd.ConfigProvider, { theme: { token: { fontSize: 14 } } }, /* @__PURE__ */ React.createElement(import_antd.Space, { size: 2 }, /* @__PURE__ */ React.createElement(
74
+ import__.ActionIcon,
73
75
  {
74
- type: "link",
76
+ title: "Reset",
77
+ icon: import_lucide_react.RotateCcw,
75
78
  size: "small",
76
79
  onClick: () => {
77
80
  setInput(value);
78
- },
79
- style: { padding: 0 }
80
- },
81
- "重置"
82
- ), /* @__PURE__ */ React.createElement(
83
- import_antd.Button,
84
- {
85
- type: "link",
86
- size: "small",
87
- style: { padding: 0 },
88
- onClick: () => {
89
- updateValue();
90
81
  }
91
- },
92
- "保存 "
93
- ))
82
+ }
83
+ ), /* @__PURE__ */ React.createElement(import__.ActionIcon, { title: " Save", icon: import_lucide_react.Save, size: "small", onClick: updateValue })))
94
84
  }
95
85
  );
96
86
  }
package/lib/index.d.ts CHANGED
@@ -10,6 +10,7 @@ export { default as EditableMessageList, type EditableMessageListProps, } from '
10
10
  export { default as EditableText, type EditableTextProps } from './EditableText';
11
11
  export { default as Highlighter, SyntaxHighlighter, type HighlighterProps, type SyntaxHighlighterProps, } from './Highlighter';
12
12
  export { default as Icon, type IconProps, type IconSize } from './Icon';
13
+ export { Input, TextArea, type InputProps, type TextAreaProps } from './Input';
13
14
  export { default as List } from './List';
14
15
  export { default as Logo, type LogoProps } from './Logo';
15
16
  export { default as Markdown, type MarkdownProps } from './Markdown';
package/lib/index.js CHANGED
@@ -40,6 +40,7 @@ __export(src_exports, {
40
40
  EditableText: () => import_EditableText.default,
41
41
  Highlighter: () => import_Highlighter.default,
42
42
  Icon: () => import_Icon.default,
43
+ Input: () => import_Input.Input,
43
44
  List: () => import_List.default,
44
45
  Logo: () => import_Logo.default,
45
46
  Markdown: () => import_Markdown.default,
@@ -52,6 +53,7 @@ __export(src_exports, {
52
53
  Swatches: () => import_Swatches.default,
53
54
  SyntaxHighlighter: () => import_Highlighter.SyntaxHighlighter,
54
55
  TabsNav: () => import_TabsNav.default,
56
+ TextArea: () => import_Input.TextArea,
55
57
  ThemeProvider: () => import_ThemeProvider.default,
56
58
  ThemeSwitch: () => import_ThemeSwitch.default,
57
59
  Tooltip: () => import_Tooltip.default,
@@ -70,6 +72,7 @@ var import_EditableMessageList = __toESM(require("./EditableMessageList"));
70
72
  var import_EditableText = __toESM(require("./EditableText"));
71
73
  var import_Highlighter = __toESM(require("./Highlighter"));
72
74
  var import_Icon = __toESM(require("./Icon"));
75
+ var import_Input = require("./Input");
73
76
  var import_List = __toESM(require("./List"));
74
77
  var import_Logo = __toESM(require("./Logo"));
75
78
  var import_Markdown = __toESM(require("./Markdown"));
@@ -97,6 +100,7 @@ var import_Tooltip = __toESM(require("./Tooltip"));
97
100
  EditableText,
98
101
  Highlighter,
99
102
  Icon,
103
+ Input,
100
104
  List,
101
105
  Logo,
102
106
  Markdown,
@@ -109,6 +113,7 @@ var import_Tooltip = __toESM(require("./Tooltip"));
109
113
  Swatches,
110
114
  SyntaxHighlighter,
111
115
  TabsNav,
116
+ TextArea,
112
117
  ThemeProvider,
113
118
  ThemeSwitch,
114
119
  Tooltip,
@@ -22,10 +22,10 @@ __export(base_exports, {
22
22
  baseTheme: () => baseTheme
23
23
  });
24
24
  module.exports = __toCommonJS(base_exports);
25
- var FONT_EMOJI = `"Segoe UI Emoji", "Segoe UI Symbol", "Apple Color Emoji", "Twemoji Mozilla", "Noto Color Emoji", "Android Emoji"`;
26
- var FONT_EN = `"HarmonyOS Sans", "Segoe UI", "SF Pro Display",-apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif`;
27
- var FONT_CN = `"HarmonyOS Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft Yahei UI", "Microsoft Yahei", "Source Han Sans CN", sans-serif`;
28
- var FONT_CODE = `Hack, "SFMono Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace`;
25
+ var FONT_EMOJI = `"Segoe UI Emoji","Segoe UI Symbol","Apple Color Emoji","Twemoji Mozilla","Noto Color Emoji","Android Emoji"`;
26
+ var FONT_EN = `"HarmonyOS Sans","Segoe UI","SF Pro Display",-apple-system,BlinkMacSystemFont,Roboto,Oxygen,Ubuntu,Cantarell,"Open Sans","Helvetica Neue",sans-serif`;
27
+ var FONT_CN = `"HarmonyOS Sans SC","PingFang SC","Hiragino Sans GB","Microsoft Yahei UI","Microsoft Yahei","Source Han Sans CN",sans-serif`;
28
+ var FONT_CODE = `ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace`;
29
29
  var baseTheme = {
30
30
  token: {
31
31
  colorInfo: "#0070f3",
@@ -11,8 +11,19 @@ export type DivProps = React.DetailedHTMLProps<
11
11
  HTMLDivElement
12
12
  >;
13
13
 
14
- declare global {
15
- type SvgProps = React.DetailedHTMLProps<React.HTMLAttributes<SVGSVGElement>, SVGSVGElement>;
14
+ export type SvgProps = React.DetailedHTMLProps<React.HTMLAttributes<SVGSVGElement>, SVGSVGElement>;
16
15
 
17
- type ImgProps = React.DetailedHTMLProps<React.HTMLAttributes<HTMLImageElement>, HTMLImageElement>;
18
- }
16
+ export type ImgProps = React.DetailedHTMLProps<
17
+ React.HTMLAttributes<HTMLImageElement>,
18
+ HTMLImageElement
19
+ >;
20
+
21
+ export type InputProps = React.DetailedHTMLProps<
22
+ React.HTMLAttributes<HTMLInputElement>,
23
+ HTMLInputElement
24
+ >;
25
+
26
+ export type TextAreaProps = React.DetailedHTMLProps<
27
+ React.HTMLAttributes<HTMLTextAreaElement>,
28
+ HTMLTextAreaElement
29
+ >;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.8.2",
3
+ "version": "1.10.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",