@lobehub/ui 1.54.0 → 1.55.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.
@@ -1,4 +1,5 @@
1
1
  import { CSSProperties } from 'react';
2
+ import { type MessageModalProps } from "../MessageModal";
2
3
  export interface EditableMessageProps {
3
4
  /**
4
5
  * @title The class name for the Markdown and MessageInput component
@@ -55,6 +56,7 @@ export interface EditableMessageProps {
55
56
  */
56
57
  markdown?: CSSProperties;
57
58
  };
59
+ text?: MessageModalProps['text'];
58
60
  /**
59
61
  * @title The current text value
60
62
  */
@@ -21,7 +21,8 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
21
21
  _ref$showEditWhenEmpt = _ref.showEditWhenEmpty,
22
22
  showEditWhenEmpty = _ref$showEditWhenEmpt === void 0 ? false : _ref$showEditWhenEmpt,
23
23
  styles = _ref.styles,
24
- editButtonSize = _ref.editButtonSize;
24
+ editButtonSize = _ref.editButtonSize,
25
+ text = _ref.text;
25
26
  var _useControlledState = useControlledState(false, {
26
27
  onChange: onEditingChange,
27
28
  value: editing
@@ -66,15 +67,20 @@ var EditableMessage = /*#__PURE__*/memo(function (_ref) {
66
67
  }) : /*#__PURE__*/_jsx(Markdown, {
67
68
  className: classNames === null || classNames === void 0 ? void 0 : classNames.markdown,
68
69
  style: styles === null || styles === void 0 ? void 0 : styles.markdown,
69
- children: value
70
+ children: value || placeholder
70
71
  }), /*#__PURE__*/_jsx(MessageModal, {
71
72
  editing: isEdit,
72
73
  onChange: function onChange(text) {
73
- _onChange === null || _onChange === void 0 ? void 0 : _onChange(text);
74
+ return _onChange === null || _onChange === void 0 ? void 0 : _onChange(text);
74
75
  },
75
76
  onEditingChange: setTyping,
76
- onOpenChange: setExpand,
77
+ onOpenChange: function onOpenChange(e) {
78
+ setExpand(e);
79
+ setTyping(false);
80
+ },
77
81
  open: expand,
82
+ placeholder: placeholder,
83
+ text: text,
78
84
  value: value
79
85
  })]
80
86
  });
@@ -22,6 +22,13 @@ export interface MessageModalProps {
22
22
  * @default false
23
23
  */
24
24
  open?: boolean;
25
+ placeholder?: string;
26
+ text?: {
27
+ cancel?: string;
28
+ confirm?: string;
29
+ edit?: string;
30
+ title?: string;
31
+ };
25
32
  /**
26
33
  * @description The value of the message content
27
34
  */
@@ -14,8 +14,10 @@ var MessageModal = /*#__PURE__*/memo(function (_ref) {
14
14
  open = _ref.open,
15
15
  onOpenChange = _ref.onOpenChange,
16
16
  onEditingChange = _ref.onEditingChange,
17
+ placeholder = _ref.placeholder,
17
18
  value = _ref.value,
18
- onChange = _ref.onChange;
19
+ onChange = _ref.onChange,
20
+ text = _ref.text;
19
21
  var _useStyles = useStyles(),
20
22
  styles = _useStyles.styles;
21
23
  var _useControlledState = useControlledState(false, {
@@ -33,13 +35,13 @@ var MessageModal = /*#__PURE__*/memo(function (_ref) {
33
35
  expand = _useControlledState4[0],
34
36
  setExpand = _useControlledState4[1];
35
37
  return /*#__PURE__*/_jsx(Modal, {
36
- cancelText: 'Cancel',
38
+ cancelText: (text === null || text === void 0 ? void 0 : text.cancel) || 'Cancel',
37
39
  className: styles.modal,
38
40
  closeIcon: /*#__PURE__*/_jsx(Icon, {
39
41
  icon: X
40
42
  }),
41
43
  footer: isEdit ? null : undefined,
42
- okText: 'Edit',
44
+ okText: (text === null || text === void 0 ? void 0 : text.edit) || 'Edit',
43
45
  onCancel: function onCancel() {
44
46
  return setExpand(false);
45
47
  },
@@ -51,7 +53,7 @@ var MessageModal = /*#__PURE__*/memo(function (_ref) {
51
53
  align: 'center',
52
54
  gap: 4,
53
55
  horizontal: true,
54
- children: "Prompt"
56
+ children: (text === null || text === void 0 ? void 0 : text.title) || 'Prompt'
55
57
  }),
56
58
  width: 800,
57
59
  children: isEdit ? /*#__PURE__*/_jsx(MessageInput, {
@@ -63,10 +65,18 @@ var MessageModal = /*#__PURE__*/memo(function (_ref) {
63
65
  onConfirm: function onConfirm(text) {
64
66
  setTyping(false);
65
67
  onChange === null || onChange === void 0 ? void 0 : onChange(text);
68
+ },
69
+ placeholder: placeholder,
70
+ text: {
71
+ cancel: text === null || text === void 0 ? void 0 : text.cancel,
72
+ confirm: text === null || text === void 0 ? void 0 : text.confirm
66
73
  }
67
74
  }) : /*#__PURE__*/_jsx(Markdown, {
68
75
  className: styles.body,
69
- children: value
76
+ style: value ? {} : {
77
+ opacity: 0.5
78
+ },
79
+ children: String(value || placeholder)
70
80
  })
71
81
  });
72
82
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobehub/ui",
3
- "version": "1.54.0",
3
+ "version": "1.55.0",
4
4
  "description": "Lobe UI is an open-source UI component library for building chatbot web apps",
5
5
  "keywords": [
6
6
  "lobehub",