Skip to content

Commit c6bda49

Browse files
authored
refactor: InputNumber semantic refactor (#726)
* refactor: simplify dom * test: fix test case * chore: fix ts def * chore: clean up * chore: use utoo * chore: clean up * chore: clean up * chore: rm useless deps * chore: fix input * test: clean up
1 parent 0d846a3 commit c6bda49

17 files changed

+619
-880
lines changed

assets/index.less

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
@inputNumberPrefixCls: rc-input-number;
22

33
.@{inputNumberPrefixCls} {
4-
display: inline-block;
4+
display: inline-flex;
5+
flex-wrap: nowrap;
56
height: 26px;
67
margin: 0;
78
padding: 0;
@@ -22,7 +23,7 @@
2223
}
2324
}
2425

25-
&-handler {
26+
&-action {
2627
display: block;
2728
height: 12px;
2829
overflow: hidden;
@@ -35,8 +36,8 @@
3536
}
3637
}
3738

38-
&-handler-up-inner,
39-
&-handler-down-inner {
39+
&-action-up-inner,
40+
&-action-down-inner {
4041
color: #666666;
4142
-webkit-user-select: none;
4243
user-select: none;
@@ -45,26 +46,21 @@
4546
&:hover {
4647
border-color: #1890ff;
4748

48-
.@{inputNumberPrefixCls}-handler-up,
49-
.@{inputNumberPrefixCls}-handler-wrap {
49+
.@{inputNumberPrefixCls}-action-up,
50+
.@{inputNumberPrefixCls}-actions {
5051
border-color: #1890ff;
5152
}
5253
}
5354

5455
&-disabled:hover {
5556
border-color: #d9d9d9;
5657

57-
.@{inputNumberPrefixCls}-handler-up,
58-
.@{inputNumberPrefixCls}-handler-wrap {
58+
.@{inputNumberPrefixCls}-action-up,
59+
.@{inputNumberPrefixCls}-actions {
5960
border-color: #d9d9d9;
6061
}
6162
}
6263

63-
&-input-wrap {
64-
height: 100%;
65-
overflow: hidden;
66-
}
67-
6864
&-input {
6965
width: 100%;
7066
height: 100%;
@@ -80,15 +76,14 @@
8076
-moz-appearance: textfield;
8177
}
8278

83-
&-handler-wrap {
84-
float: right;
79+
&-actions {
8580
width: 20px;
8681
height: 100%;
8782
border-left: 1px solid #d9d9d9;
8883
transition: all 0.3s;
8984
}
9085

91-
&-handler-up {
86+
&-action-up {
9287
padding-top: 1px;
9388
border-bottom: 1px solid #d9d9d9;
9489
transition: all 0.3s;
@@ -100,7 +95,7 @@
10095
}
10196
}
10297

103-
&-handler-down {
98+
&-action-down {
10499
transition: all 0.3s;
105100

106101
&-inner {
@@ -118,8 +113,8 @@
118113
}
119114
}
120115

121-
&-handler-down-disabled,
122-
&-handler-up-disabled {
116+
&-action-down-disabled,
117+
&-action-up-disabled {
123118
.handler-disabled();
124119
}
125120

@@ -129,7 +124,7 @@
129124
cursor: not-allowed;
130125
opacity: 0.72;
131126
}
132-
.@{inputNumberPrefixCls}-handler {
127+
.@{inputNumberPrefixCls}-action {
133128
.handler-disabled();
134129
}
135130
}
@@ -139,17 +134,17 @@
139134
align-items: center;
140135
}
141136

142-
&-mode-spinner &-handler {
137+
&-mode-spinner &-action {
143138
flex: 0 0 20px;
144-
line-height: 26px;
145139
height: 100%;
140+
line-height: 26px;
146141
}
147142

148-
&-mode-spinner &-handler-up {
143+
&-mode-spinner &-action-up {
149144
border-bottom: 0;
150145
border-left: 1px solid #d9d9d9;
151146
}
152-
&-mode-spinner &-handler-down {
147+
&-mode-spinner &-action-down {
153148
border-top: 0;
154149
border-right: 1px solid #d9d9d9;
155150
}

docs/demo/prefix-suffix.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/* eslint no-console:0 */
2+
import InputNumber from '@rc-component/input-number';
3+
import React from 'react';
4+
import '../../assets/index.less';
5+
6+
export default () => {
7+
const [value, setValue] = React.useState<string | number>(100);
8+
9+
const onChange = (val: number) => {
10+
console.log('onChange:', val, typeof val);
11+
setValue(val);
12+
};
13+
14+
return (
15+
<div style={{ margin: 10 }}>
16+
<InputNumber
17+
style={{ width: 200 }}
18+
value={value}
19+
onChange={onChange}
20+
prefix="¥"
21+
suffix="RMB"
22+
/>
23+
</div>
24+
);
25+
};

docs/example.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ nav:
99

1010
<code src="./demo/simple.tsx"></code>
1111

12+
## prefix-suffix
13+
14+
<code src="./demo/prefix-suffix.tsx"></code>
15+
1216
## combination-key-format
1317

1418
<code src="./demo/combination-key-format.tsx"></code>

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@
4545
]
4646
},
4747
"dependencies": {
48-
"@rc-component/input": "~1.1.0",
4948
"@rc-component/mini-decimal": "^1.0.1",
50-
"@rc-component/util": "^1.2.0",
49+
"@rc-component/util": "^1.4.0",
5150
"clsx": "^2.1.1"
5251
},
5352
"devDependencies": {

0 commit comments

Comments
 (0)