@xaypay/tui 0.0.91 → 0.0.93
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/dist/index.es.js +182 -119
- package/dist/index.js +182 -119
- package/package.json +1 -1
- package/src/components/input/index.js +71 -10
- package/src/components/input/input.module.css +1 -0
- package/src/components/newAutocomplete/autocomplete.module.css +3 -0
- package/src/components/newAutocomplete/index.js +3 -0
- package/src/components/select/select.module.css +2 -0
- package/src/components/textarea/textarea.module.css +4 -0
package/package.json
CHANGED
|
@@ -45,6 +45,7 @@ export const Input = ({
|
|
|
45
45
|
errorSize,
|
|
46
46
|
labelSize,
|
|
47
47
|
maxLength,
|
|
48
|
+
floatToFix,
|
|
48
49
|
minNumSize,
|
|
49
50
|
maxNumSize,
|
|
50
51
|
labelColor,
|
|
@@ -135,18 +136,37 @@ export const Input = ({
|
|
|
135
136
|
}
|
|
136
137
|
|
|
137
138
|
if (type === 'number') {
|
|
139
|
+
const regNum = /^\d+(\.)?(\d+)?$/;
|
|
140
|
+
if (!regNum.test(currentValue)) {
|
|
141
|
+
setInnerValue(prevValue);
|
|
142
|
+
if (change) {
|
|
143
|
+
change(prevValue);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
138
146
|
if (minNumSize && currentValue < minNumSize) {
|
|
139
|
-
setInnerValue(minNumSize);
|
|
147
|
+
setInnerValue(`${minNumSize}`);
|
|
140
148
|
if (change) {
|
|
141
|
-
change(minNumSize);
|
|
149
|
+
change(`${minNumSize}`);
|
|
142
150
|
}
|
|
143
151
|
}
|
|
144
152
|
if (maxNumSize && currentValue > maxNumSize) {
|
|
145
|
-
setInnerValue(maxNumSize);
|
|
153
|
+
setInnerValue(`${maxNumSize}`);
|
|
146
154
|
if (change) {
|
|
147
|
-
change(maxNumSize);
|
|
155
|
+
change(`${maxNumSize}`);
|
|
148
156
|
}
|
|
149
157
|
}
|
|
158
|
+
if (floatToFix && floatToFix > 0 && !Number.isInteger(parseFloat(currentValue))) {
|
|
159
|
+
const floatNumParts = typeof currentValue === 'string' ? currentValue.split('.') : currentValue;
|
|
160
|
+
const int = floatNumParts[0];
|
|
161
|
+
const float = floatNumParts[1];
|
|
162
|
+
|
|
163
|
+
if (float && float.length > floatToFix) {
|
|
164
|
+
setInnerValue(`${int}.${float.substr(0, floatToFix)}`);
|
|
165
|
+
if (change) {
|
|
166
|
+
change(`${int}.${float.substr(0, floatToFix)}`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
150
170
|
if (currentValue === '') {
|
|
151
171
|
setInnerValue('');
|
|
152
172
|
if (change) {
|
|
@@ -155,14 +175,14 @@ export const Input = ({
|
|
|
155
175
|
}
|
|
156
176
|
}
|
|
157
177
|
|
|
158
|
-
if (maxLength && currentValue.length > maxLength && type !== 'tel'
|
|
178
|
+
if (maxLength && currentValue.length > maxLength && type !== 'tel') {
|
|
159
179
|
setInnerValue(currentValue.substr(0, maxLength));
|
|
160
180
|
if (change) {
|
|
161
181
|
change(currentValue.substr(0, maxLength));
|
|
162
182
|
}
|
|
163
183
|
}
|
|
164
184
|
|
|
165
|
-
if (regexp && regexpErrorMessage && !maxLength && type !== 'tel'
|
|
185
|
+
if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
|
|
166
186
|
!regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
|
|
167
187
|
if (change) {
|
|
168
188
|
change(currentValue);
|
|
@@ -210,6 +230,46 @@ export const Input = ({
|
|
|
210
230
|
}
|
|
211
231
|
}
|
|
212
232
|
|
|
233
|
+
if (type === 'number') {
|
|
234
|
+
const regNum = /^\d+(\.)?(\d+)?$/;
|
|
235
|
+
if (!regNum.test(value)) {
|
|
236
|
+
setInnerValue('');
|
|
237
|
+
if (change) {
|
|
238
|
+
change('');
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
if (minNumSize && value < minNumSize) {
|
|
242
|
+
setInnerValue(`${minNumSize}`);
|
|
243
|
+
if (change) {
|
|
244
|
+
change(`${minNumSize}`);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
if (maxNumSize && value > maxNumSize) {
|
|
248
|
+
setInnerValue(`${maxNumSize}`);
|
|
249
|
+
if (change) {
|
|
250
|
+
change(`${maxNumSize}`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
if (floatToFix && floatToFix > 0 && !Number.isInteger(parseFloat(value))) {
|
|
254
|
+
const floatNumParts = typeof value === 'string' ? value.split('.') : value;
|
|
255
|
+
const int = floatNumParts[0];
|
|
256
|
+
const float = floatNumParts[1];
|
|
257
|
+
|
|
258
|
+
if (float && float.length > floatToFix) {
|
|
259
|
+
setInnerValue(`${int}.${float.substr(0, floatToFix)}`);
|
|
260
|
+
if (change) {
|
|
261
|
+
change(`${int}.${float.substr(0, floatToFix)}`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
if (value === '') {
|
|
266
|
+
setInnerValue('');
|
|
267
|
+
if (change) {
|
|
268
|
+
change('');
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
|
213
273
|
if (maxLength && value.length > maxLength && type !== 'tel') {
|
|
214
274
|
setInnerValue(value.substr(0, maxLength));
|
|
215
275
|
}
|
|
@@ -220,7 +280,7 @@ export const Input = ({
|
|
|
220
280
|
}
|
|
221
281
|
}
|
|
222
282
|
}, [type, value, regexp, maxLength, errorMessage, regexpErrorMessage, telErrorMessage]);
|
|
223
|
-
|
|
283
|
+
|
|
224
284
|
return (
|
|
225
285
|
<div className={`${styles["input-wrap"]}`}>
|
|
226
286
|
{
|
|
@@ -304,14 +364,14 @@ export const Input = ({
|
|
|
304
364
|
{...props}
|
|
305
365
|
value={innerValue}
|
|
306
366
|
className={classProps}
|
|
307
|
-
|
|
308
|
-
type={show ? 'text' : type}
|
|
367
|
+
onInput={handleChange}
|
|
309
368
|
disabled={disabled ? disabled : ""}
|
|
310
369
|
name={name ? name : `tui_${random}_tui`}
|
|
311
370
|
placeholder={placeholder ? placeholder : ''}
|
|
312
|
-
|
|
371
|
+
type={show || type === 'number' ? 'text' : type}
|
|
313
372
|
min={type === 'number' && minNumSize ? minNumSize: ''}
|
|
314
373
|
max={type === 'number' && maxNumSize ? maxNumSize : ''}
|
|
374
|
+
autoComplete={autoComplete ? autoComplete : configStyles.INPUT.autoComplete}
|
|
315
375
|
style={{
|
|
316
376
|
border: 'none',
|
|
317
377
|
outline: 'none',
|
|
@@ -401,6 +461,7 @@ Input.propTypes = {
|
|
|
401
461
|
errorLeft: PropTypes.string,
|
|
402
462
|
labelSize: PropTypes.string,
|
|
403
463
|
maxLength: PropTypes.number,
|
|
464
|
+
floatToFix: PropTypes.number,
|
|
404
465
|
minNumSize: PropTypes.number,
|
|
405
466
|
maxNumSize: PropTypes.number,
|
|
406
467
|
errorColor: PropTypes.string,
|
|
@@ -4,6 +4,8 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import { keyframes, css } from 'styled-components';
|
|
5
5
|
|
|
6
6
|
import { compereConfigs } from './../../utils';
|
|
7
|
+
|
|
8
|
+
import styles from './autocomplete.module.css';
|
|
7
9
|
|
|
8
10
|
export const NewAutocomplete = ({
|
|
9
11
|
label,
|
|
@@ -320,6 +322,7 @@ export const NewAutocomplete = ({
|
|
|
320
322
|
onInput={handleChange}
|
|
321
323
|
onMouseEnter={handleMouseEnter}
|
|
322
324
|
onMouseLeave={handleMouseLeave}
|
|
325
|
+
className={styles['auto-complete']}
|
|
323
326
|
placeholder={placeHolder ? placeHolder : ''}
|
|
324
327
|
autoComplete={autoComplete ? autoComplete : configStyles.NEWAUTOCOMPLETE.autoComplete}
|
|
325
328
|
style={{
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
position: relative;
|
|
5
|
+
-webkit-appearance: none;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
.select-content-top {
|
|
@@ -10,6 +11,7 @@
|
|
|
10
11
|
flex-wrap: nowrap;
|
|
11
12
|
align-items: center;
|
|
12
13
|
justify-content: space-between;
|
|
14
|
+
-webkit-appearance: none;
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
.select-content-bottom {
|