@hsu-react/ui 2.4.7 → 2.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -51,6 +51,16 @@ export interface ChatInputProps {
|
|
|
51
51
|
onFileInterceptClick?: (e: React.MouseEvent<HTMLSpanElement>) => void;
|
|
52
52
|
buttonGroup?: ButtonProps[];
|
|
53
53
|
uploadEnabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Disable sending. The send button turns disabled and Enter no longer submits;
|
|
56
|
+
* the textarea stays editable so a half-typed message is never lost.
|
|
57
|
+
*
|
|
58
|
+
* The component already disables the send button during its own uploads
|
|
59
|
+
* (`isUpload`), but consumers that run their own upload flow
|
|
60
|
+
* (`uploadEnabled={false}`) had no way in: they could only intercept `onSend`
|
|
61
|
+
* and pop a warning, leaving the button looking perfectly clickable.
|
|
62
|
+
*/
|
|
63
|
+
disabled?: boolean;
|
|
54
64
|
}
|
|
55
65
|
declare const ChatInput: React.FC<ChatInputProps>;
|
|
56
66
|
export default ChatInput;
|
|
@@ -43,7 +43,9 @@ var ChatInput = function ChatInput(props) {
|
|
|
43
43
|
onFileInterceptClick = props.onFileInterceptClick,
|
|
44
44
|
buttonGroup = props.buttonGroup,
|
|
45
45
|
_props$uploadEnabled = props.uploadEnabled,
|
|
46
|
-
uploadEnabled = _props$uploadEnabled === void 0 ? true : _props$uploadEnabled
|
|
46
|
+
uploadEnabled = _props$uploadEnabled === void 0 ? true : _props$uploadEnabled,
|
|
47
|
+
_props$disabled = props.disabled,
|
|
48
|
+
disabled = _props$disabled === void 0 ? false : _props$disabled;
|
|
47
49
|
var _useState = useState(""),
|
|
48
50
|
_useState2 = _slicedToArray(_useState, 2),
|
|
49
51
|
value = _useState2[0],
|
|
@@ -145,6 +147,9 @@ var ChatInput = function ChatInput(props) {
|
|
|
145
147
|
|
|
146
148
|
// Handle sending
|
|
147
149
|
var handleSend = function handleSend() {
|
|
150
|
+
if (disabled) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
148
153
|
if (value.trim() !== "") {
|
|
149
154
|
setValue("");
|
|
150
155
|
onSend === null || onSend === void 0 || onSend(value);
|
|
@@ -239,7 +244,7 @@ var ChatInput = function ChatInput(props) {
|
|
|
239
244
|
value: value,
|
|
240
245
|
onSend: handleSend,
|
|
241
246
|
sendIcon: sendIcon,
|
|
242
|
-
disabled: isUpload
|
|
247
|
+
disabled: isUpload || disabled
|
|
243
248
|
})
|
|
244
249
|
})]
|
|
245
250
|
})]
|
|
@@ -51,6 +51,16 @@ export interface ChatInputProps {
|
|
|
51
51
|
onFileInterceptClick?: (e: React.MouseEvent<HTMLSpanElement>) => void;
|
|
52
52
|
buttonGroup?: ButtonProps[];
|
|
53
53
|
uploadEnabled?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Disable sending. The send button turns disabled and Enter no longer submits;
|
|
56
|
+
* the textarea stays editable so a half-typed message is never lost.
|
|
57
|
+
*
|
|
58
|
+
* The component already disables the send button during its own uploads
|
|
59
|
+
* (`isUpload`), but consumers that run their own upload flow
|
|
60
|
+
* (`uploadEnabled={false}`) had no way in: they could only intercept `onSend`
|
|
61
|
+
* and pop a warning, leaving the button looking perfectly clickable.
|
|
62
|
+
*/
|
|
63
|
+
disabled?: boolean;
|
|
54
64
|
}
|
|
55
65
|
declare const ChatInput: React.FC<ChatInputProps>;
|
|
56
66
|
export default ChatInput;
|
|
@@ -34,7 +34,8 @@ const ChatInput = props => {
|
|
|
34
34
|
wrapperClassName,
|
|
35
35
|
onFileInterceptClick,
|
|
36
36
|
buttonGroup,
|
|
37
|
-
uploadEnabled = true
|
|
37
|
+
uploadEnabled = true,
|
|
38
|
+
disabled = false
|
|
38
39
|
} = props;
|
|
39
40
|
const [value, setValue] = (0, _react.useState)("");
|
|
40
41
|
const [isUpload, setIsUpload] = (0, _react.useState)(false);
|
|
@@ -111,6 +112,9 @@ const ChatInput = props => {
|
|
|
111
112
|
|
|
112
113
|
// Handle sending
|
|
113
114
|
const handleSend = () => {
|
|
115
|
+
if (disabled) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
114
118
|
if (value.trim() !== "") {
|
|
115
119
|
setValue("");
|
|
116
120
|
onSend?.(value);
|
|
@@ -198,7 +202,7 @@ const ChatInput = props => {
|
|
|
198
202
|
value: value,
|
|
199
203
|
onSend: handleSend,
|
|
200
204
|
sendIcon: sendIcon,
|
|
201
|
-
disabled: isUpload
|
|
205
|
+
disabled: isUpload || disabled
|
|
202
206
|
})
|
|
203
207
|
})]
|
|
204
208
|
})]
|
package/package.json
CHANGED
|
@@ -67,6 +67,16 @@ export interface ChatInputProps {
|
|
|
67
67
|
onFileInterceptClick?: (e: React.MouseEvent<HTMLSpanElement>) => void;
|
|
68
68
|
buttonGroup?: ButtonProps[];
|
|
69
69
|
uploadEnabled?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* Disable sending. The send button turns disabled and Enter no longer submits;
|
|
72
|
+
* the textarea stays editable so a half-typed message is never lost.
|
|
73
|
+
*
|
|
74
|
+
* The component already disables the send button during its own uploads
|
|
75
|
+
* (`isUpload`), but consumers that run their own upload flow
|
|
76
|
+
* (`uploadEnabled={false}`) had no way in: they could only intercept `onSend`
|
|
77
|
+
* and pop a warning, leaving the button looking perfectly clickable.
|
|
78
|
+
*/
|
|
79
|
+
disabled?: boolean;
|
|
70
80
|
}
|
|
71
81
|
|
|
72
82
|
const ChatInput: React.FC<ChatInputProps> = (props) => {
|
|
@@ -88,6 +98,7 @@ const ChatInput: React.FC<ChatInputProps> = (props) => {
|
|
|
88
98
|
onFileInterceptClick,
|
|
89
99
|
buttonGroup,
|
|
90
100
|
uploadEnabled = true,
|
|
101
|
+
disabled = false,
|
|
91
102
|
} = props;
|
|
92
103
|
|
|
93
104
|
const [value, setValue] = useState<string>("");
|
|
@@ -178,6 +189,9 @@ const ChatInput: React.FC<ChatInputProps> = (props) => {
|
|
|
178
189
|
|
|
179
190
|
// Handle sending
|
|
180
191
|
const handleSend = () => {
|
|
192
|
+
if (disabled) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
181
195
|
if (value.trim() !== "") {
|
|
182
196
|
setValue("");
|
|
183
197
|
onSend?.(value);
|
|
@@ -275,7 +289,7 @@ const ChatInput: React.FC<ChatInputProps> = (props) => {
|
|
|
275
289
|
value={value}
|
|
276
290
|
onSend={handleSend}
|
|
277
291
|
sendIcon={sendIcon}
|
|
278
|
-
disabled={isUpload}
|
|
292
|
+
disabled={isUpload || disabled}
|
|
279
293
|
/>
|
|
280
294
|
)}
|
|
281
295
|
</>
|