@hsu-react/ui 2.4.6 → 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.
- package/es/components/Chat/ChatInput/index.d.ts +10 -0
- package/es/components/Chat/ChatInput/index.js +7 -2
- package/es/components/Input/index.module.scss +7 -3
- package/es/components/Select/TreeSelect/index.module.scss +4 -1
- package/es/components/Select/index.module.scss +28 -4
- package/lib/components/Chat/ChatInput/index.d.ts +10 -0
- package/lib/components/Chat/ChatInput/index.js +6 -2
- package/lib/components/Input/index.module.scss +7 -3
- package/lib/components/Select/TreeSelect/index.module.scss +4 -1
- package/lib/components/Select/index.module.scss +28 -4
- package/package.json +1 -1
- package/src/components/Chat/ChatInput/index.tsx +15 -1
- package/src/components/Input/index.module.scss +7 -3
- package/src/components/Select/TreeSelect/index.module.scss +4 -1
- package/src/components/Select/index.module.scss +28 -4
|
@@ -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
|
})]
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
.antdInput {
|
|
2
2
|
width: 100%;
|
|
3
|
-
height: 100
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// The control height is a floor, not `height: 100%` — see the long note in
|
|
4
|
+
// `Select/index.module.scss`. Same failure: under a flex item stretched by a taller
|
|
5
|
+
// sibling, `height: 100%` inflates the input to the item's whole content box.
|
|
6
|
+
//
|
|
7
|
+
// The inner `height: 100%` rules below stay: when this root *is* stretched (as a flex
|
|
8
|
+
// child, or because the app asked for it), they propagate that height inward. They
|
|
9
|
+
// resolve to `auto` otherwise and fall back to `min-height: inherit`.
|
|
6
10
|
min-height: var(--vita-control-height);
|
|
7
11
|
|
|
8
12
|
:global(.ant-input-clear-icon) {
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
--tree-switcher-gap: 0px;
|
|
5
5
|
|
|
6
6
|
width: 100%;
|
|
7
|
-
height: 100
|
|
7
|
+
// Control height as a floor, not `height: 100%` — same reason as `Select` (see the
|
|
8
|
+
// note there). TreeSelect had no `min-height` at all because `height: 100%` was doing
|
|
9
|
+
// that job by accident; dropping one without adding the other would collapse it.
|
|
10
|
+
min-height: var(--vita-control-height);
|
|
8
11
|
|
|
9
12
|
// CF style: outlined input control that follows appearance switching.
|
|
10
13
|
//
|
|
@@ -5,9 +5,24 @@
|
|
|
5
5
|
align-items: center;
|
|
6
6
|
|
|
7
7
|
width: 100%;
|
|
8
|
-
height: 100
|
|
9
|
-
//
|
|
10
|
-
//
|
|
8
|
+
// The control height is a floor, not `height: 100%`.
|
|
9
|
+
//
|
|
10
|
+
// `height: 100%` looks harmless because it resolves to `auto` under an auto-height
|
|
11
|
+
// parent — but the moment the parent has a *definite* height the control inflates to
|
|
12
|
+
// fill it, and the most common way a parent acquires one is by accident: a flex item
|
|
13
|
+
// stretched by a taller sibling. A card holding `<label> <Select> <hint>` where the
|
|
14
|
+
// hint wraps to two lines is enough — the Select swells to the card's whole content
|
|
15
|
+
// box (measured: 102px for a 32px control) and covers the label and the hint.
|
|
16
|
+
//
|
|
17
|
+
// This bit hsu-ui itself: `ChainGraph/SearchSelect` has to park the Select in a
|
|
18
|
+
// fixed 32px box, "preventing the Select root's height:100% from resolving against
|
|
19
|
+
// the graph and being stretched to the full graph height". Consumers hit it too and
|
|
20
|
+
// reach for the same wrapper, which is a workaround for a default that is wrong.
|
|
21
|
+
//
|
|
22
|
+
// Filling a deliberately sized parent still works without the declaration: as a flex
|
|
23
|
+
// child the default `align-self: stretch` fills the cross axis, and the inner
|
|
24
|
+
// `height: 100%` rules below then resolve against a genuinely definite height.
|
|
25
|
+
// A block parent that really wants a taller control can still say `height: 100%`.
|
|
11
26
|
min-height: var(--vita-control-height);
|
|
12
27
|
padding: 0px 11px;
|
|
13
28
|
|
|
@@ -118,7 +133,16 @@
|
|
|
118
133
|
align-items: center;
|
|
119
134
|
|
|
120
135
|
width: 100%;
|
|
121
|
-
height: 100
|
|
136
|
+
// 撑满外壳用 align-self,不用 height: 100%。
|
|
137
|
+
//
|
|
138
|
+
// 外壳 `.select` 的高度是 `min-height` 撑出来的、`height` 仍是 auto,
|
|
139
|
+
// 百分比高度对着 auto 解析不出东西 —— 这一层会缩回内容高(实测 22px,
|
|
140
|
+
// 而外壳是 32px),上下各多出 5px 点不动的死区:看着是个 32px 的下拉框,
|
|
141
|
+
// 边缘一圈却没有反应。
|
|
142
|
+
//
|
|
143
|
+
// 外壳是 flex 且 align-items: center,所以这里要显式 stretch;
|
|
144
|
+
// 前后缀图标不受影响,它们该保持居中
|
|
145
|
+
align-self: stretch;
|
|
122
146
|
margin: 0px !important;
|
|
123
147
|
|
|
124
148
|
border-radius: inherit;
|
|
@@ -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
|
})]
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
.antdInput {
|
|
2
2
|
width: 100%;
|
|
3
|
-
height: 100
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// The control height is a floor, not `height: 100%` — see the long note in
|
|
4
|
+
// `Select/index.module.scss`. Same failure: under a flex item stretched by a taller
|
|
5
|
+
// sibling, `height: 100%` inflates the input to the item's whole content box.
|
|
6
|
+
//
|
|
7
|
+
// The inner `height: 100%` rules below stay: when this root *is* stretched (as a flex
|
|
8
|
+
// child, or because the app asked for it), they propagate that height inward. They
|
|
9
|
+
// resolve to `auto` otherwise and fall back to `min-height: inherit`.
|
|
6
10
|
min-height: var(--vita-control-height);
|
|
7
11
|
|
|
8
12
|
:global(.ant-input-clear-icon) {
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
--tree-switcher-gap: 0px;
|
|
5
5
|
|
|
6
6
|
width: 100%;
|
|
7
|
-
height: 100
|
|
7
|
+
// Control height as a floor, not `height: 100%` — same reason as `Select` (see the
|
|
8
|
+
// note there). TreeSelect had no `min-height` at all because `height: 100%` was doing
|
|
9
|
+
// that job by accident; dropping one without adding the other would collapse it.
|
|
10
|
+
min-height: var(--vita-control-height);
|
|
8
11
|
|
|
9
12
|
// CF style: outlined input control that follows appearance switching.
|
|
10
13
|
//
|
|
@@ -5,9 +5,24 @@
|
|
|
5
5
|
align-items: center;
|
|
6
6
|
|
|
7
7
|
width: 100%;
|
|
8
|
-
height: 100
|
|
9
|
-
//
|
|
10
|
-
//
|
|
8
|
+
// The control height is a floor, not `height: 100%`.
|
|
9
|
+
//
|
|
10
|
+
// `height: 100%` looks harmless because it resolves to `auto` under an auto-height
|
|
11
|
+
// parent — but the moment the parent has a *definite* height the control inflates to
|
|
12
|
+
// fill it, and the most common way a parent acquires one is by accident: a flex item
|
|
13
|
+
// stretched by a taller sibling. A card holding `<label> <Select> <hint>` where the
|
|
14
|
+
// hint wraps to two lines is enough — the Select swells to the card's whole content
|
|
15
|
+
// box (measured: 102px for a 32px control) and covers the label and the hint.
|
|
16
|
+
//
|
|
17
|
+
// This bit hsu-ui itself: `ChainGraph/SearchSelect` has to park the Select in a
|
|
18
|
+
// fixed 32px box, "preventing the Select root's height:100% from resolving against
|
|
19
|
+
// the graph and being stretched to the full graph height". Consumers hit it too and
|
|
20
|
+
// reach for the same wrapper, which is a workaround for a default that is wrong.
|
|
21
|
+
//
|
|
22
|
+
// Filling a deliberately sized parent still works without the declaration: as a flex
|
|
23
|
+
// child the default `align-self: stretch` fills the cross axis, and the inner
|
|
24
|
+
// `height: 100%` rules below then resolve against a genuinely definite height.
|
|
25
|
+
// A block parent that really wants a taller control can still say `height: 100%`.
|
|
11
26
|
min-height: var(--vita-control-height);
|
|
12
27
|
padding: 0px 11px;
|
|
13
28
|
|
|
@@ -118,7 +133,16 @@
|
|
|
118
133
|
align-items: center;
|
|
119
134
|
|
|
120
135
|
width: 100%;
|
|
121
|
-
height: 100
|
|
136
|
+
// 撑满外壳用 align-self,不用 height: 100%。
|
|
137
|
+
//
|
|
138
|
+
// 外壳 `.select` 的高度是 `min-height` 撑出来的、`height` 仍是 auto,
|
|
139
|
+
// 百分比高度对着 auto 解析不出东西 —— 这一层会缩回内容高(实测 22px,
|
|
140
|
+
// 而外壳是 32px),上下各多出 5px 点不动的死区:看着是个 32px 的下拉框,
|
|
141
|
+
// 边缘一圈却没有反应。
|
|
142
|
+
//
|
|
143
|
+
// 外壳是 flex 且 align-items: center,所以这里要显式 stretch;
|
|
144
|
+
// 前后缀图标不受影响,它们该保持居中
|
|
145
|
+
align-self: stretch;
|
|
122
146
|
margin: 0px !important;
|
|
123
147
|
|
|
124
148
|
border-radius: inherit;
|
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
|
</>
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
.antdInput {
|
|
2
2
|
width: 100%;
|
|
3
|
-
height: 100
|
|
4
|
-
//
|
|
5
|
-
//
|
|
3
|
+
// The control height is a floor, not `height: 100%` — see the long note in
|
|
4
|
+
// `Select/index.module.scss`. Same failure: under a flex item stretched by a taller
|
|
5
|
+
// sibling, `height: 100%` inflates the input to the item's whole content box.
|
|
6
|
+
//
|
|
7
|
+
// The inner `height: 100%` rules below stay: when this root *is* stretched (as a flex
|
|
8
|
+
// child, or because the app asked for it), they propagate that height inward. They
|
|
9
|
+
// resolve to `auto` otherwise and fall back to `min-height: inherit`.
|
|
6
10
|
min-height: var(--vita-control-height);
|
|
7
11
|
|
|
8
12
|
:global(.ant-input-clear-icon) {
|
|
@@ -4,7 +4,10 @@
|
|
|
4
4
|
--tree-switcher-gap: 0px;
|
|
5
5
|
|
|
6
6
|
width: 100%;
|
|
7
|
-
height: 100
|
|
7
|
+
// Control height as a floor, not `height: 100%` — same reason as `Select` (see the
|
|
8
|
+
// note there). TreeSelect had no `min-height` at all because `height: 100%` was doing
|
|
9
|
+
// that job by accident; dropping one without adding the other would collapse it.
|
|
10
|
+
min-height: var(--vita-control-height);
|
|
8
11
|
|
|
9
12
|
// CF style: outlined input control that follows appearance switching.
|
|
10
13
|
//
|
|
@@ -5,9 +5,24 @@
|
|
|
5
5
|
align-items: center;
|
|
6
6
|
|
|
7
7
|
width: 100%;
|
|
8
|
-
height: 100
|
|
9
|
-
//
|
|
10
|
-
//
|
|
8
|
+
// The control height is a floor, not `height: 100%`.
|
|
9
|
+
//
|
|
10
|
+
// `height: 100%` looks harmless because it resolves to `auto` under an auto-height
|
|
11
|
+
// parent — but the moment the parent has a *definite* height the control inflates to
|
|
12
|
+
// fill it, and the most common way a parent acquires one is by accident: a flex item
|
|
13
|
+
// stretched by a taller sibling. A card holding `<label> <Select> <hint>` where the
|
|
14
|
+
// hint wraps to two lines is enough — the Select swells to the card's whole content
|
|
15
|
+
// box (measured: 102px for a 32px control) and covers the label and the hint.
|
|
16
|
+
//
|
|
17
|
+
// This bit hsu-ui itself: `ChainGraph/SearchSelect` has to park the Select in a
|
|
18
|
+
// fixed 32px box, "preventing the Select root's height:100% from resolving against
|
|
19
|
+
// the graph and being stretched to the full graph height". Consumers hit it too and
|
|
20
|
+
// reach for the same wrapper, which is a workaround for a default that is wrong.
|
|
21
|
+
//
|
|
22
|
+
// Filling a deliberately sized parent still works without the declaration: as a flex
|
|
23
|
+
// child the default `align-self: stretch` fills the cross axis, and the inner
|
|
24
|
+
// `height: 100%` rules below then resolve against a genuinely definite height.
|
|
25
|
+
// A block parent that really wants a taller control can still say `height: 100%`.
|
|
11
26
|
min-height: var(--vita-control-height);
|
|
12
27
|
padding: 0px 11px;
|
|
13
28
|
|
|
@@ -118,7 +133,16 @@
|
|
|
118
133
|
align-items: center;
|
|
119
134
|
|
|
120
135
|
width: 100%;
|
|
121
|
-
height: 100
|
|
136
|
+
// 撑满外壳用 align-self,不用 height: 100%。
|
|
137
|
+
//
|
|
138
|
+
// 外壳 `.select` 的高度是 `min-height` 撑出来的、`height` 仍是 auto,
|
|
139
|
+
// 百分比高度对着 auto 解析不出东西 —— 这一层会缩回内容高(实测 22px,
|
|
140
|
+
// 而外壳是 32px),上下各多出 5px 点不动的死区:看着是个 32px 的下拉框,
|
|
141
|
+
// 边缘一圈却没有反应。
|
|
142
|
+
//
|
|
143
|
+
// 外壳是 flex 且 align-items: center,所以这里要显式 stretch;
|
|
144
|
+
// 前后缀图标不受影响,它们该保持居中
|
|
145
|
+
align-self: stretch;
|
|
122
146
|
margin: 0px !important;
|
|
123
147
|
|
|
124
148
|
border-radius: inherit;
|