@xaypay/tui 0.0.92 → 0.0.94

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 CHANGED
@@ -778,20 +778,27 @@ const Input = ({
778
778
  }
779
779
  }
780
780
  if (type === 'number') {
781
+ const regNum = /^\d+(\.)?(\d+)?$/;
782
+ if (!regNum.test(currentValue)) {
783
+ setInnerValue(prevValue);
784
+ if (change) {
785
+ change(prevValue);
786
+ }
787
+ }
781
788
  if (minNumSize && currentValue < minNumSize) {
782
- setInnerValue(minNumSize);
789
+ setInnerValue(`${minNumSize}`);
783
790
  if (change) {
784
- change(minNumSize);
791
+ change(`${minNumSize}`);
785
792
  }
786
793
  }
787
794
  if (maxNumSize && currentValue > maxNumSize) {
788
- setInnerValue(maxNumSize);
795
+ setInnerValue(`${maxNumSize}`);
789
796
  if (change) {
790
- change(maxNumSize);
797
+ change(`${maxNumSize}`);
791
798
  }
792
799
  }
793
800
  if (floatToFix && floatToFix > 0 && !Number.isInteger(parseFloat(currentValue))) {
794
- const floatNumParts = currentValue.split('.');
801
+ const floatNumParts = typeof currentValue === 'string' ? currentValue.split('.') : currentValue;
795
802
  const int = floatNumParts[0];
796
803
  const float = floatNumParts[1];
797
804
  if (float && float.length > floatToFix) {
@@ -808,13 +815,13 @@ const Input = ({
808
815
  }
809
816
  }
810
817
  }
811
- if (maxLength && currentValue.length > maxLength && type !== 'tel' && type !== 'number') {
818
+ if (maxLength && currentValue.length > maxLength && type !== 'tel') {
812
819
  setInnerValue(currentValue.substr(0, maxLength));
813
820
  if (change) {
814
821
  change(currentValue.substr(0, maxLength));
815
822
  }
816
823
  }
817
- if (regexp && regexpErrorMessage && !maxLength && type !== 'tel' && type !== 'number') {
824
+ if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
818
825
  !regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
819
826
  if (change) {
820
827
  change(currentValue);
@@ -856,6 +863,44 @@ const Input = ({
856
863
  }
857
864
  }
858
865
  }
866
+ if (type === 'number') {
867
+ const regNum = /^\d+(\.)?(\d+)?$/;
868
+ if (!regNum.test(value)) {
869
+ setInnerValue('');
870
+ if (change) {
871
+ change('');
872
+ }
873
+ }
874
+ if (minNumSize && value < minNumSize) {
875
+ setInnerValue(`${minNumSize}`);
876
+ if (change) {
877
+ change(`${minNumSize}`);
878
+ }
879
+ }
880
+ if (maxNumSize && value > maxNumSize) {
881
+ setInnerValue(`${maxNumSize}`);
882
+ if (change) {
883
+ change(`${maxNumSize}`);
884
+ }
885
+ }
886
+ if (floatToFix && floatToFix > 0 && !Number.isInteger(parseFloat(value))) {
887
+ const floatNumParts = typeof value === 'string' ? value.split('.') : value;
888
+ const int = floatNumParts[0];
889
+ const float = floatNumParts[1];
890
+ if (float && float.length > floatToFix) {
891
+ setInnerValue(`${int}.${float.substr(0, floatToFix)}`);
892
+ if (change) {
893
+ change(`${int}.${float.substr(0, floatToFix)}`);
894
+ }
895
+ }
896
+ }
897
+ if (value === '') {
898
+ setInnerValue('');
899
+ if (change) {
900
+ change('');
901
+ }
902
+ }
903
+ }
859
904
  if (maxLength && value.length > maxLength && type !== 'tel') {
860
905
  setInnerValue(value.substr(0, maxLength));
861
906
  }
@@ -925,11 +970,11 @@ const Input = ({
925
970
  }, "+374") : '', /*#__PURE__*/React__default.createElement("input", _extends({}, props, {
926
971
  value: innerValue,
927
972
  className: classProps,
928
- onChange: handleChange,
929
- type: show ? 'text' : type,
973
+ onInput: handleChange,
930
974
  disabled: disabled ? disabled : "",
931
975
  name: name ? name : `tui_${random}_tui`,
932
976
  placeholder: placeholder ? placeholder : '',
977
+ type: show || type === 'number' ? 'text' : type,
933
978
  min: type === 'number' && minNumSize ? minNumSize : '',
934
979
  max: type === 'number' && maxNumSize ? maxNumSize : '',
935
980
  autoComplete: autoComplete ? autoComplete : configStyles.INPUT.autoComplete,
@@ -2684,6 +2729,11 @@ const NewFile = ({
2684
2729
  const node = ReactDOM.findDOMNode(ref.current);
2685
2730
  const parent = node.parentNode;
2686
2731
  parent.removeChild(node);
2732
+ if (!multiple) {
2733
+ removeFile && removeFile(singleFile);
2734
+ } else {
2735
+ removeFile && removeFile(filesArray);
2736
+ }
2687
2737
  };
2688
2738
  const handleRemoveFile = () => {
2689
2739
  setImage(null);
package/dist/index.js CHANGED
@@ -808,20 +808,27 @@ const Input = ({
808
808
  }
809
809
  }
810
810
  if (type === 'number') {
811
+ const regNum = /^\d+(\.)?(\d+)?$/;
812
+ if (!regNum.test(currentValue)) {
813
+ setInnerValue(prevValue);
814
+ if (change) {
815
+ change(prevValue);
816
+ }
817
+ }
811
818
  if (minNumSize && currentValue < minNumSize) {
812
- setInnerValue(minNumSize);
819
+ setInnerValue(`${minNumSize}`);
813
820
  if (change) {
814
- change(minNumSize);
821
+ change(`${minNumSize}`);
815
822
  }
816
823
  }
817
824
  if (maxNumSize && currentValue > maxNumSize) {
818
- setInnerValue(maxNumSize);
825
+ setInnerValue(`${maxNumSize}`);
819
826
  if (change) {
820
- change(maxNumSize);
827
+ change(`${maxNumSize}`);
821
828
  }
822
829
  }
823
830
  if (floatToFix && floatToFix > 0 && !Number.isInteger(parseFloat(currentValue))) {
824
- const floatNumParts = currentValue.split('.');
831
+ const floatNumParts = typeof currentValue === 'string' ? currentValue.split('.') : currentValue;
825
832
  const int = floatNumParts[0];
826
833
  const float = floatNumParts[1];
827
834
  if (float && float.length > floatToFix) {
@@ -838,13 +845,13 @@ const Input = ({
838
845
  }
839
846
  }
840
847
  }
841
- if (maxLength && currentValue.length > maxLength && type !== 'tel' && type !== 'number') {
848
+ if (maxLength && currentValue.length > maxLength && type !== 'tel') {
842
849
  setInnerValue(currentValue.substr(0, maxLength));
843
850
  if (change) {
844
851
  change(currentValue.substr(0, maxLength));
845
852
  }
846
853
  }
847
- if (regexp && regexpErrorMessage && !maxLength && type !== 'tel' && type !== 'number') {
854
+ if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
848
855
  !regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
849
856
  if (change) {
850
857
  change(currentValue);
@@ -886,6 +893,44 @@ const Input = ({
886
893
  }
887
894
  }
888
895
  }
896
+ if (type === 'number') {
897
+ const regNum = /^\d+(\.)?(\d+)?$/;
898
+ if (!regNum.test(value)) {
899
+ setInnerValue('');
900
+ if (change) {
901
+ change('');
902
+ }
903
+ }
904
+ if (minNumSize && value < minNumSize) {
905
+ setInnerValue(`${minNumSize}`);
906
+ if (change) {
907
+ change(`${minNumSize}`);
908
+ }
909
+ }
910
+ if (maxNumSize && value > maxNumSize) {
911
+ setInnerValue(`${maxNumSize}`);
912
+ if (change) {
913
+ change(`${maxNumSize}`);
914
+ }
915
+ }
916
+ if (floatToFix && floatToFix > 0 && !Number.isInteger(parseFloat(value))) {
917
+ const floatNumParts = typeof value === 'string' ? value.split('.') : value;
918
+ const int = floatNumParts[0];
919
+ const float = floatNumParts[1];
920
+ if (float && float.length > floatToFix) {
921
+ setInnerValue(`${int}.${float.substr(0, floatToFix)}`);
922
+ if (change) {
923
+ change(`${int}.${float.substr(0, floatToFix)}`);
924
+ }
925
+ }
926
+ }
927
+ if (value === '') {
928
+ setInnerValue('');
929
+ if (change) {
930
+ change('');
931
+ }
932
+ }
933
+ }
889
934
  if (maxLength && value.length > maxLength && type !== 'tel') {
890
935
  setInnerValue(value.substr(0, maxLength));
891
936
  }
@@ -955,11 +1000,11 @@ const Input = ({
955
1000
  }, "+374") : '', /*#__PURE__*/React__default["default"].createElement("input", _extends({}, props, {
956
1001
  value: innerValue,
957
1002
  className: classProps,
958
- onChange: handleChange,
959
- type: show ? 'text' : type,
1003
+ onInput: handleChange,
960
1004
  disabled: disabled ? disabled : "",
961
1005
  name: name ? name : `tui_${random}_tui`,
962
1006
  placeholder: placeholder ? placeholder : '',
1007
+ type: show || type === 'number' ? 'text' : type,
963
1008
  min: type === 'number' && minNumSize ? minNumSize : '',
964
1009
  max: type === 'number' && maxNumSize ? maxNumSize : '',
965
1010
  autoComplete: autoComplete ? autoComplete : configStyles.INPUT.autoComplete,
@@ -2714,6 +2759,11 @@ const NewFile = ({
2714
2759
  const node = ReactDOM__default["default"].findDOMNode(ref.current);
2715
2760
  const parent = node.parentNode;
2716
2761
  parent.removeChild(node);
2762
+ if (!multiple) {
2763
+ removeFile && removeFile(singleFile);
2764
+ } else {
2765
+ removeFile && removeFile(filesArray);
2766
+ }
2717
2767
  };
2718
2768
  const handleRemoveFile = () => {
2719
2769
  setImage(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaypay/tui",
3
- "version": "0.0.92",
3
+ "version": "0.0.94",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",
@@ -136,20 +136,27 @@ export const Input = ({
136
136
  }
137
137
 
138
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
+ }
139
146
  if (minNumSize && currentValue < minNumSize) {
140
- setInnerValue(minNumSize);
147
+ setInnerValue(`${minNumSize}`);
141
148
  if (change) {
142
- change(minNumSize);
149
+ change(`${minNumSize}`);
143
150
  }
144
151
  }
145
152
  if (maxNumSize && currentValue > maxNumSize) {
146
- setInnerValue(maxNumSize);
153
+ setInnerValue(`${maxNumSize}`);
147
154
  if (change) {
148
- change(maxNumSize);
155
+ change(`${maxNumSize}`);
149
156
  }
150
157
  }
151
158
  if (floatToFix && floatToFix > 0 && !Number.isInteger(parseFloat(currentValue))) {
152
- const floatNumParts = currentValue.split('.');
159
+ const floatNumParts = typeof currentValue === 'string' ? currentValue.split('.') : currentValue;
153
160
  const int = floatNumParts[0];
154
161
  const float = floatNumParts[1];
155
162
 
@@ -168,14 +175,14 @@ export const Input = ({
168
175
  }
169
176
  }
170
177
 
171
- if (maxLength && currentValue.length > maxLength && type !== 'tel' && type !== 'number') {
178
+ if (maxLength && currentValue.length > maxLength && type !== 'tel') {
172
179
  setInnerValue(currentValue.substr(0, maxLength));
173
180
  if (change) {
174
181
  change(currentValue.substr(0, maxLength));
175
182
  }
176
183
  }
177
184
 
178
- if (regexp && regexpErrorMessage && !maxLength && type !== 'tel' && type !== 'number') {
185
+ if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
179
186
  !regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
180
187
  if (change) {
181
188
  change(currentValue);
@@ -223,6 +230,46 @@ export const Input = ({
223
230
  }
224
231
  }
225
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
+
226
273
  if (maxLength && value.length > maxLength && type !== 'tel') {
227
274
  setInnerValue(value.substr(0, maxLength));
228
275
  }
@@ -233,7 +280,7 @@ export const Input = ({
233
280
  }
234
281
  }
235
282
  }, [type, value, regexp, maxLength, errorMessage, regexpErrorMessage, telErrorMessage]);
236
-
283
+
237
284
  return (
238
285
  <div className={`${styles["input-wrap"]}`}>
239
286
  {
@@ -317,11 +364,11 @@ export const Input = ({
317
364
  {...props}
318
365
  value={innerValue}
319
366
  className={classProps}
320
- onChange={handleChange}
321
- type={show ? 'text' : type}
367
+ onInput={handleChange}
322
368
  disabled={disabled ? disabled : ""}
323
369
  name={name ? name : `tui_${random}_tui`}
324
370
  placeholder={placeholder ? placeholder : ''}
371
+ type={show || type === 'number' ? 'text' : type}
325
372
  min={type === 'number' && minNumSize ? minNumSize: ''}
326
373
  max={type === 'number' && maxNumSize ? maxNumSize : ''}
327
374
  autoComplete={autoComplete ? autoComplete : configStyles.INPUT.autoComplete}
@@ -81,6 +81,11 @@ export const NewFile = ({
81
81
  const node = ReactDOM.findDOMNode(ref.current);
82
82
  const parent = node.parentNode;
83
83
  parent.removeChild(node);
84
+ if (!multiple) {
85
+ removeFile && removeFile(singleFile);
86
+ } else {
87
+ removeFile && removeFile(filesArray);
88
+ }
84
89
  };
85
90
 
86
91
  const handleRemoveFile = () => {
@@ -41,4 +41,4 @@ Default.args = {
41
41
  },
42
42
  multiple: true,
43
43
  name: 'sss'
44
- };
44
+ };