@lobehub/ui 1.125.2 → 1.125.3
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.
|
@@ -5,11 +5,11 @@ export interface MessageInputFooterProps {
|
|
|
5
5
|
onCancel?: () => void;
|
|
6
6
|
onConfirm?: (text: string) => void;
|
|
7
7
|
renderButtons?: (text: string) => ButtonProps[];
|
|
8
|
-
temporarySystemRole?: string;
|
|
9
8
|
text?: {
|
|
10
9
|
cancel?: string;
|
|
11
10
|
confirm?: string;
|
|
12
11
|
};
|
|
12
|
+
value?: string;
|
|
13
13
|
}
|
|
14
14
|
declare const MessageInputFooter: import("react").NamedExoticComponent<MessageInputFooterProps>;
|
|
15
15
|
export default MessageInputFooter;
|
|
@@ -11,20 +11,20 @@ var MessageInputFooter = /*#__PURE__*/memo(function (_ref) {
|
|
|
11
11
|
var text = _ref.text,
|
|
12
12
|
renderButtons = _ref.renderButtons,
|
|
13
13
|
onConfirm = _ref.onConfirm,
|
|
14
|
-
|
|
14
|
+
value = _ref.value,
|
|
15
15
|
editButtonSize = _ref.editButtonSize,
|
|
16
16
|
onCancel = _ref.onCancel;
|
|
17
17
|
return /*#__PURE__*/_jsx(Flexbox, {
|
|
18
18
|
direction: 'horizontal-reverse',
|
|
19
19
|
gap: 8,
|
|
20
|
-
children: renderButtons &&
|
|
20
|
+
children: renderButtons && value ? renderButtons(value).map(function (buttonProps, index) {
|
|
21
21
|
return /*#__PURE__*/_jsx(Button, _objectSpread({
|
|
22
22
|
size: "small"
|
|
23
23
|
}, buttonProps), index);
|
|
24
24
|
}) : /*#__PURE__*/_jsxs(_Fragment, {
|
|
25
25
|
children: [/*#__PURE__*/_jsx(Button, {
|
|
26
26
|
onClick: function onClick() {
|
|
27
|
-
onConfirm === null || onConfirm === void 0 || onConfirm(
|
|
27
|
+
onConfirm === null || onConfirm === void 0 || onConfirm(value || '');
|
|
28
28
|
},
|
|
29
29
|
size: editButtonSize,
|
|
30
30
|
type: "primary",
|
|
@@ -3,17 +3,18 @@ import { type CSSProperties } from 'react';
|
|
|
3
3
|
import { type TextAreaProps } from "../Input";
|
|
4
4
|
import { DivProps } from "../types";
|
|
5
5
|
import { type MessageInputFooterProps } from './MessageInputFooter';
|
|
6
|
-
export interface MessageInputProps extends MessageInputFooterProps, DivProps {
|
|
6
|
+
export interface MessageInputProps extends MessageInputFooterProps, Omit<DivProps, 'onChange'> {
|
|
7
7
|
className?: string;
|
|
8
8
|
classNames?: TextAreaProps['classNames'];
|
|
9
9
|
defaultValue?: string;
|
|
10
10
|
editButtonSize?: ButtonProps['size'];
|
|
11
11
|
height?: number | 'auto' | string;
|
|
12
|
-
|
|
12
|
+
onChange?: (value: string) => void;
|
|
13
13
|
showFooter?: boolean;
|
|
14
14
|
textareaClassname?: string;
|
|
15
15
|
textareaStyle?: CSSProperties;
|
|
16
16
|
type?: TextAreaProps['type'];
|
|
17
|
+
value?: string;
|
|
17
18
|
}
|
|
18
19
|
declare const MessageInput: import("react").NamedExoticComponent<MessageInputProps>;
|
|
19
20
|
export default MessageInput;
|
package/es/MessageInput/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["text", "type", "onCancel", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height", "style", "editButtonSize", "showFooter", "classNames", "
|
|
4
|
+
var _excluded = ["text", "type", "onCancel", "value", "defaultValue", "onConfirm", "renderButtons", "textareaStyle", "textareaClassname", "placeholder", "height", "style", "editButtonSize", "showFooter", "classNames", "onChange"];
|
|
5
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
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
7
|
import { memo } from 'react';
|
|
@@ -17,6 +17,7 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
17
17
|
_ref$type = _ref.type,
|
|
18
18
|
type = _ref$type === void 0 ? 'pure' : _ref$type,
|
|
19
19
|
onCancel = _ref.onCancel,
|
|
20
|
+
value = _ref.value,
|
|
20
21
|
defaultValue = _ref.defaultValue,
|
|
21
22
|
onConfirm = _ref.onConfirm,
|
|
22
23
|
renderButtons = _ref.renderButtons,
|
|
@@ -31,15 +32,16 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
31
32
|
_ref$showFooter = _ref.showFooter,
|
|
32
33
|
showFooter = _ref$showFooter === void 0 ? true : _ref$showFooter,
|
|
33
34
|
classNames = _ref.classNames,
|
|
34
|
-
|
|
35
|
+
onChange = _ref.onChange,
|
|
35
36
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
36
|
-
var _useMergeState = useMergeState(
|
|
37
|
+
var _useMergeState = useMergeState('', {
|
|
37
38
|
defaultValue: defaultValue,
|
|
38
|
-
onChange:
|
|
39
|
+
onChange: onChange,
|
|
40
|
+
value: value
|
|
39
41
|
}),
|
|
40
42
|
_useMergeState2 = _slicedToArray(_useMergeState, 2),
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
message = _useMergeState2[0],
|
|
44
|
+
setMessage = _useMergeState2[1];
|
|
43
45
|
var _useStyles = useStyles(),
|
|
44
46
|
cx = _useStyles.cx,
|
|
45
47
|
styles = _useStyles.styles;
|
|
@@ -56,10 +58,10 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
56
58
|
className: cx(styles, textareaClassname),
|
|
57
59
|
classNames: classNames,
|
|
58
60
|
onBlur: function onBlur(e) {
|
|
59
|
-
return
|
|
61
|
+
return setMessage(e.target.value);
|
|
60
62
|
},
|
|
61
63
|
onChange: function onChange(e) {
|
|
62
|
-
return
|
|
64
|
+
return setMessage(e.target.value);
|
|
63
65
|
},
|
|
64
66
|
placeholder: placeholder,
|
|
65
67
|
resize: false,
|
|
@@ -68,14 +70,14 @@ var MessageInput = /*#__PURE__*/memo(function (_ref) {
|
|
|
68
70
|
minHeight: '100%'
|
|
69
71
|
}, textareaStyle),
|
|
70
72
|
type: type,
|
|
71
|
-
value:
|
|
73
|
+
value: message
|
|
72
74
|
}), showFooter && /*#__PURE__*/_jsx(MessageInputFooter, {
|
|
73
75
|
editButtonSize: editButtonSize,
|
|
74
76
|
onCancel: onCancel,
|
|
75
77
|
onConfirm: onConfirm,
|
|
76
78
|
renderButtons: renderButtons,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
text: text,
|
|
80
|
+
value: message
|
|
79
81
|
})]
|
|
80
82
|
}));
|
|
81
83
|
});
|
|
@@ -2,6 +2,7 @@ import { ReactNode } from 'react';
|
|
|
2
2
|
import { type MessageInputProps } from "../MessageInput";
|
|
3
3
|
import { type ModalProps } from "../Modal";
|
|
4
4
|
export interface MessageModalProps extends Pick<ModalProps, 'open' | 'footer'> {
|
|
5
|
+
defaultValue?: string;
|
|
5
6
|
/**
|
|
6
7
|
* @description Whether the message is being edited or not
|
|
7
8
|
* @default false
|
package/es/MessageModal/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
|
3
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
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
5
|
import { createStyles, useResponsive } from 'antd-style';
|
|
6
|
-
import { memo
|
|
6
|
+
import { memo } from 'react';
|
|
7
7
|
import useControlledState from 'use-merge-value';
|
|
8
8
|
import Markdown from "../Markdown";
|
|
9
9
|
import MessageInput from "../MessageInput";
|
|
@@ -27,6 +27,7 @@ var MessageModal = /*#__PURE__*/memo(function (_ref2) {
|
|
|
27
27
|
onEditingChange = _ref2.onEditingChange,
|
|
28
28
|
placeholder = _ref2.placeholder,
|
|
29
29
|
value = _ref2.value,
|
|
30
|
+
defaultValue = _ref2.defaultValue,
|
|
30
31
|
onChange = _ref2.onChange,
|
|
31
32
|
text = _ref2.text,
|
|
32
33
|
footer = _ref2.footer,
|
|
@@ -35,24 +36,28 @@ var MessageModal = /*#__PURE__*/memo(function (_ref2) {
|
|
|
35
36
|
mobile = _useResponsive.mobile;
|
|
36
37
|
var _useStyles = useStyles(),
|
|
37
38
|
styles = _useStyles.styles;
|
|
38
|
-
var
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
var _useControlledState = useControlledState(false, {
|
|
43
|
-
onChange: onEditingChange,
|
|
44
|
-
value: editing
|
|
39
|
+
var _useControlledState = useControlledState('', {
|
|
40
|
+
defaultValue: defaultValue,
|
|
41
|
+
onChange: onChange,
|
|
42
|
+
value: value
|
|
45
43
|
}),
|
|
46
44
|
_useControlledState2 = _slicedToArray(_useControlledState, 2),
|
|
47
|
-
|
|
48
|
-
|
|
45
|
+
message = _useControlledState2[0],
|
|
46
|
+
setMessage = _useControlledState2[1];
|
|
49
47
|
var _useControlledState3 = useControlledState(false, {
|
|
48
|
+
onChange: onEditingChange,
|
|
49
|
+
value: editing
|
|
50
|
+
}),
|
|
51
|
+
_useControlledState4 = _slicedToArray(_useControlledState3, 2),
|
|
52
|
+
isEdit = _useControlledState4[0],
|
|
53
|
+
setTyping = _useControlledState4[1];
|
|
54
|
+
var _useControlledState5 = useControlledState(false, {
|
|
50
55
|
onChange: onOpenChange,
|
|
51
56
|
value: open
|
|
52
57
|
}),
|
|
53
|
-
|
|
54
|
-
expand =
|
|
55
|
-
setExpand =
|
|
58
|
+
_useControlledState6 = _slicedToArray(_useControlledState5, 2),
|
|
59
|
+
expand = _useControlledState6[0],
|
|
60
|
+
setExpand = _useControlledState6[1];
|
|
56
61
|
var isAutoSize = height === 'auto';
|
|
57
62
|
var markdownStyle = {
|
|
58
63
|
height: isAutoSize ? 'unset' : height,
|
|
@@ -70,11 +75,11 @@ var MessageModal = /*#__PURE__*/memo(function (_ref2) {
|
|
|
70
75
|
setTyping(false);
|
|
71
76
|
onChange === null || onChange === void 0 || onChange(text);
|
|
72
77
|
},
|
|
73
|
-
temporarySystemRole: role,
|
|
74
78
|
text: {
|
|
75
79
|
cancel: text === null || text === void 0 ? void 0 : text.cancel,
|
|
76
80
|
confirm: text === null || text === void 0 ? void 0 : text.confirm
|
|
77
|
-
}
|
|
81
|
+
},
|
|
82
|
+
value: message
|
|
78
83
|
}) : footer,
|
|
79
84
|
okText: (text === null || text === void 0 ? void 0 : text.edit) || 'Edit',
|
|
80
85
|
onCancel: function onCancel() {
|
|
@@ -86,10 +91,10 @@ var MessageModal = /*#__PURE__*/memo(function (_ref2) {
|
|
|
86
91
|
open: expand,
|
|
87
92
|
title: text === null || text === void 0 ? void 0 : text.title,
|
|
88
93
|
children: isEdit ? /*#__PURE__*/_jsx(MessageInput, {
|
|
89
|
-
defaultValue:
|
|
94
|
+
defaultValue: message,
|
|
90
95
|
height: height,
|
|
96
|
+
onChange: setMessage,
|
|
91
97
|
placeholder: placeholder,
|
|
92
|
-
setTemporarySystemRole: setRole,
|
|
93
98
|
showFooter: false,
|
|
94
99
|
style: mobile ? {
|
|
95
100
|
height: '100%'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lobehub/ui",
|
|
3
|
-
"version": "1.125.
|
|
3
|
+
"version": "1.125.3",
|
|
4
4
|
"description": "Lobe UI is an open-source UI component library for building AIGC web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lobehub",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "father build",
|
|
31
|
+
"build:watch": "father dev",
|
|
31
32
|
"ci": "npm run lint && npm run type-check",
|
|
32
33
|
"clean": "rm -r es lib dist coverage .dumi/tmp .eslintcache node_modules/.cache",
|
|
33
|
-
"dev": "father dev",
|
|
34
34
|
"docs:build": "dumi build",
|
|
35
35
|
"docs:build-analyze": "ANALYZE=1 dumi build",
|
|
36
36
|
"docs:dev": "dumi dev",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"@lobehub/emojilib": "latest",
|
|
81
81
|
"@react-spring/web": "^9",
|
|
82
82
|
"@splinetool/react-spline": "^2",
|
|
83
|
-
"@splinetool/runtime": "^
|
|
83
|
+
"@splinetool/runtime": "^0.9",
|
|
84
84
|
"ahooks": "^3",
|
|
85
85
|
"chroma-js": "^2",
|
|
86
86
|
"copy-to-clipboard": "^3",
|