@woosmap/ui 4.107.3 → 4.109.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.
package/package.json
CHANGED
|
@@ -80,7 +80,7 @@ export default class W3WDemo extends Component {
|
|
|
80
80
|
const { input } = this.state;
|
|
81
81
|
axios
|
|
82
82
|
.get(`${this.baseRequestUrl}autosuggest`, {
|
|
83
|
-
params: this.getRequestparams({ input }),
|
|
83
|
+
params: this.getRequestparams({ input, 'clip-to-country': 'GB,FR' }),
|
|
84
84
|
})
|
|
85
85
|
.then((response) => {
|
|
86
86
|
if (this.mounted) {
|
|
@@ -52,8 +52,8 @@ it('add a tag by clicking the OK btn', () => {
|
|
|
52
52
|
|
|
53
53
|
it('cant add the same value twice', () => {
|
|
54
54
|
const ref = React.createRef();
|
|
55
|
-
render(<DynamicTag ref={ref} placeholder="tags" />);
|
|
56
|
-
const input = screen.
|
|
55
|
+
render(<DynamicTag ref={ref} placeholder="tags" testId="dt" />);
|
|
56
|
+
const input = screen.getByTestId('dt-input');
|
|
57
57
|
expect(input).toBeTruthy();
|
|
58
58
|
|
|
59
59
|
fireEvent.change(input, { target: { value: 'mytag' } });
|
|
@@ -61,13 +61,16 @@ it('cant add the same value twice', () => {
|
|
|
61
61
|
expect(input).toHaveValue('mytag');
|
|
62
62
|
|
|
63
63
|
expect(ref.current.getTags()).toEqual([]);
|
|
64
|
-
const ok = screen.
|
|
64
|
+
const ok = screen.getByTestId('dt-button');
|
|
65
65
|
act(() => {
|
|
66
66
|
fireEvent.click(ok);
|
|
67
67
|
});
|
|
68
68
|
expect(ref.current.getTags()).toEqual(['mytag']);
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
act(() => {
|
|
71
|
+
fireEvent.change(input, { target: { value: 'mytag' } });
|
|
72
|
+
});
|
|
73
|
+
|
|
71
74
|
expect(input).toHaveValue('mytag');
|
|
72
75
|
|
|
73
76
|
act(() => {
|
|
@@ -9,7 +9,7 @@ export default class Input extends Component {
|
|
|
9
9
|
super(props);
|
|
10
10
|
this.inputId = uniqueId();
|
|
11
11
|
this.inputRef = React.createRef();
|
|
12
|
-
this.state = { showPassword: false };
|
|
12
|
+
this.state = { showPassword: false, value: null };
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
componentDidMount() {
|
|
@@ -27,6 +27,30 @@ export default class Input extends Component {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
increment = () => {
|
|
31
|
+
const { onChange, value: oldValue, name, step, max } = this.props;
|
|
32
|
+
const { value: stateValue } = this.state;
|
|
33
|
+
const theValue = oldValue || stateValue;
|
|
34
|
+
const newValue = !isNaN(theValue) ? theValue + step : step;
|
|
35
|
+
if (onChange) {
|
|
36
|
+
onChange({ target: { name, value: max ? Math.min(max, newValue) : newValue } });
|
|
37
|
+
} else {
|
|
38
|
+
this.setState({ value: newValue });
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
decrement = () => {
|
|
43
|
+
const { onChange, value: oldValue, name, step, min } = this.props;
|
|
44
|
+
const { value: stateValue } = this.state;
|
|
45
|
+
const theValue = oldValue || stateValue;
|
|
46
|
+
const newValue = !isNaN(theValue) ? theValue - step : 0;
|
|
47
|
+
if (onChange) {
|
|
48
|
+
onChange({ target: { name, value: min ? Math.max(min, newValue) : newValue } });
|
|
49
|
+
} else {
|
|
50
|
+
this.setState({ value: newValue });
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
30
54
|
renderInput = () => {
|
|
31
55
|
const {
|
|
32
56
|
type,
|
|
@@ -45,9 +69,10 @@ export default class Input extends Component {
|
|
|
45
69
|
icon,
|
|
46
70
|
isInputIconFill,
|
|
47
71
|
enableTogglePassword,
|
|
72
|
+
testId,
|
|
48
73
|
} = this.props;
|
|
49
74
|
|
|
50
|
-
const { showPassword } = this.state;
|
|
75
|
+
const { showPassword, value: stateValue } = this.state;
|
|
51
76
|
|
|
52
77
|
let iconSize = size;
|
|
53
78
|
|
|
@@ -73,7 +98,7 @@ export default class Input extends Component {
|
|
|
73
98
|
}),
|
|
74
99
|
id: this.inputId,
|
|
75
100
|
ref: this.inputRef,
|
|
76
|
-
'data-testid':
|
|
101
|
+
'data-testid': testId,
|
|
77
102
|
name,
|
|
78
103
|
checked,
|
|
79
104
|
autoComplete: autocomplete ? '' : 'off',
|
|
@@ -82,11 +107,21 @@ export default class Input extends Component {
|
|
|
82
107
|
onFocus,
|
|
83
108
|
onKeyDown: this.onKeyDown,
|
|
84
109
|
type: type === 'password' && showPassword ? 'text' : type,
|
|
85
|
-
value,
|
|
110
|
+
value: value !== undefined ? value : stateValue,
|
|
86
111
|
size: length,
|
|
87
112
|
disabled,
|
|
88
113
|
onChange,
|
|
89
114
|
})}
|
|
115
|
+
{type === 'number' && (
|
|
116
|
+
<div>
|
|
117
|
+
<button onClick={this.increment} type="button" disabled={disabled}>
|
|
118
|
+
+
|
|
119
|
+
</button>
|
|
120
|
+
<button onClick={this.decrement} type="button" disabled={disabled}>
|
|
121
|
+
-
|
|
122
|
+
</button>
|
|
123
|
+
</div>
|
|
124
|
+
)}
|
|
90
125
|
{type === 'password' && enableTogglePassword && (
|
|
91
126
|
<span
|
|
92
127
|
onKeyDown={() => ({})}
|
|
@@ -182,6 +217,10 @@ Input.propTypes = {
|
|
|
182
217
|
onPressEnter: PropTypes.func,
|
|
183
218
|
enableTogglePassword: PropTypes.bool,
|
|
184
219
|
isInputIconFill: PropTypes.bool,
|
|
220
|
+
step: PropTypes.number,
|
|
221
|
+
testId: PropTypes.string,
|
|
222
|
+
min: PropTypes.number,
|
|
223
|
+
max: PropTypes.number,
|
|
185
224
|
};
|
|
186
225
|
|
|
187
226
|
Input.defaultProps = {
|
|
@@ -208,4 +247,8 @@ Input.defaultProps = {
|
|
|
208
247
|
onFocus: null,
|
|
209
248
|
enableTogglePassword: false,
|
|
210
249
|
isInputIconFill: false,
|
|
250
|
+
step: 1,
|
|
251
|
+
testId: 'input',
|
|
252
|
+
min: null,
|
|
253
|
+
max: null,
|
|
211
254
|
};
|