@xaypay/tui 0.1.2 → 0.1.3

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.
Files changed (3) hide show
  1. package/dist/index.es.js +347 -178
  2. package/dist/index.js +347 -178
  3. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -2952,6 +2952,287 @@ Modal.defaultProps = {
2952
2952
  type: 'content'
2953
2953
  };
2954
2954
 
2955
+ const handleCheckTypeTel = (val, prevVal) => {
2956
+ const phoneNumberRegex = /^\d{0,8}$/;
2957
+ if (!phoneNumberRegex.test(val)) {
2958
+ val = prevVal;
2959
+ }
2960
+ return val;
2961
+ };
2962
+ const handleCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumSize, withoutDot, innerMinNumSize) => {
2963
+ if (maxLength && maxLength > 0) {
2964
+ if (val.length > maxLength) {
2965
+ val = val.substr(0, maxLength);
2966
+ }
2967
+ } else {
2968
+ const regNum = floatToFix && floatToFix >= 0 ? /^\d+(\.)?(\d+)?$/ : /^\d+$/;
2969
+ if (val.length > 16 && !val.includes('.')) {
2970
+ val = val.substr(0, 16);
2971
+ }
2972
+ if (val < Number.MIN_SAFE_INTEGER || val > Number.MAX_SAFE_INTEGER || innerMinNumSize && val < innerMinNumSize || maxNumSize && val > maxNumSize) {
2973
+ val = prevVal;
2974
+ }
2975
+ const floatNumParts = typeof val === 'string' ? val.split('.') : val;
2976
+ const int = floatNumParts[0];
2977
+ const float = floatNumParts[1];
2978
+ if (floatToFix > 0) {
2979
+ if (float && float.length > 0) {
2980
+ let floatResult = '';
2981
+ [...float].map((item, index) => {
2982
+ if (index + 1 <= floatToFix) {
2983
+ floatResult += item;
2984
+ }
2985
+ });
2986
+ floatResult !== '' ? val = `${int}.${floatResult}` : val = `${int}`;
2987
+ }
2988
+ } else {
2989
+ if (floatNumParts && floatNumParts.length > 0 && floatToFix === 0) {
2990
+ val = `${int}`;
2991
+ }
2992
+ }
2993
+ if (!regNum.test(val)) {
2994
+ const newStr = val.replace(/[^0-9.]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
2995
+ return b + c.replace(/\./g, '');
2996
+ });
2997
+ val = newStr;
2998
+ }
2999
+ }
3000
+ if (withoutDot && !/^\d+$/.test(val)) {
3001
+ const newStr = val.replace(/[^0-9]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
3002
+ return b + c.replace(/\./g, '');
3003
+ });
3004
+ val = newStr;
3005
+ }
3006
+ return val;
3007
+ };
3008
+
3009
+ const TelInput = ({
3010
+ type,
3011
+ value,
3012
+ radius,
3013
+ inputChange,
3014
+ isHover,
3015
+ disabled,
3016
+ inpStyles,
3017
+ errorColor,
3018
+ phoneDisplay,
3019
+ inpAttributes,
3020
+ phoneAlignItems,
3021
+ innerErrorMessage,
3022
+ telBorderRightWidth,
3023
+ telBorderRightColor,
3024
+ telBorderRightStyle,
3025
+ phoneJustifyContent,
3026
+ telBorderRightColorHover
3027
+ }) => {
3028
+ const [innerValue, setInnerValue] = useState('');
3029
+ const handleChange = event => {
3030
+ let prevValue = innerValue;
3031
+ let currentValue = event.target.value;
3032
+ currentValue = handleCheckTypeTel(currentValue, prevValue);
3033
+ setInnerValue(() => currentValue);
3034
+ if (inputChange && currentValue !== prevValue) {
3035
+ inputChange(currentValue);
3036
+ }
3037
+ };
3038
+ useEffect(() => {
3039
+ let newValue = '';
3040
+ if (value !== undefined && value !== null) {
3041
+ newValue = handleCheckTypeTel(value, newValue);
3042
+ }
3043
+ setInnerValue(() => newValue);
3044
+ }, [value]);
3045
+ return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("div", {
3046
+ style: {
3047
+ ...inpStyles,
3048
+ width: 'auto',
3049
+ display: phoneDisplay,
3050
+ alignItems: phoneAlignItems,
3051
+ borderTopLeftRadius: radius,
3052
+ borderBottomLeftRadius: radius,
3053
+ justifyContent: phoneJustifyContent,
3054
+ pointerEvents: disabled ? 'none' : 'auto',
3055
+ borderRight: `${telBorderRightWidth} ${telBorderRightStyle}`,
3056
+ borderColor: innerErrorMessage ? errorColor : isHover ? telBorderRightColorHover : telBorderRightColor
3057
+ }
3058
+ }, "+374"), /*#__PURE__*/React__default.createElement("input", {
3059
+ type: type,
3060
+ value: innerValue,
3061
+ disabled: disabled,
3062
+ onInput: handleChange,
3063
+ name: inpAttributes?.iName,
3064
+ placeholder: inpAttributes?.placeholder,
3065
+ autoComplete: inpAttributes?.autoComplete,
3066
+ style: {
3067
+ ...inpStyles,
3068
+ border: 'none',
3069
+ outline: 'none',
3070
+ borderRadius: radius
3071
+ }
3072
+ }));
3073
+ };
3074
+
3075
+ const TextInput = ({
3076
+ value,
3077
+ radius,
3078
+ inputChange,
3079
+ maxLength,
3080
+ inpStyles,
3081
+ inpAttributes
3082
+ }) => {
3083
+ const [innerValue, setInnerValue] = useState('');
3084
+ const handleChange = event => {
3085
+ let prevValue = innerValue;
3086
+ let currentValue = event.target.value;
3087
+ if (maxLength && currentValue.length > maxLength) {
3088
+ currentValue = currentValue.substr(0, maxLength);
3089
+ }
3090
+ setInnerValue(() => currentValue);
3091
+ if (inputChange && currentValue !== prevValue) {
3092
+ inputChange(currentValue);
3093
+ }
3094
+ };
3095
+ useEffect(() => {
3096
+ let newValue = value;
3097
+ if (value !== undefined && value !== null) {
3098
+ newValue = value;
3099
+ if (maxLength && value.length > maxLength) {
3100
+ newValue = value.substr(0, maxLength);
3101
+ }
3102
+ }
3103
+ setInnerValue(() => newValue);
3104
+ }, [value]);
3105
+ return /*#__PURE__*/React__default.createElement("input", {
3106
+ type: "text",
3107
+ value: innerValue,
3108
+ onInput: handleChange,
3109
+ name: inpAttributes?.iName,
3110
+ placeholder: inpAttributes?.placeholder,
3111
+ autoComplete: inpAttributes?.autoComplete,
3112
+ style: {
3113
+ ...inpStyles,
3114
+ border: 'none',
3115
+ outline: 'none',
3116
+ borderRadius: radius
3117
+ }
3118
+ });
3119
+ };
3120
+
3121
+ const PassInput = ({
3122
+ show,
3123
+ value,
3124
+ radius,
3125
+ inputChange,
3126
+ maxLength,
3127
+ inpAttributes,
3128
+ inpStyles
3129
+ }) => {
3130
+ const [innerShow, setInnerShow] = useState('');
3131
+ const [innerValue, setInnerValue] = useState('');
3132
+ const handleChange = event => {
3133
+ let prevValue = innerValue;
3134
+ let currentValue = event.target.value;
3135
+ if (maxLength && currentValue.length > maxLength) {
3136
+ currentValue = currentValue.substr(0, maxLength);
3137
+ }
3138
+ setInnerValue(() => currentValue);
3139
+ if (inputChange && currentValue !== prevValue) {
3140
+ inputChange(currentValue);
3141
+ }
3142
+ };
3143
+ useEffect(() => {
3144
+ let newValue = '';
3145
+ if (value !== undefined && value !== null) {
3146
+ newValue = value;
3147
+ if (maxLength && value.length > maxLength) {
3148
+ newValue = value.substr(0, maxLength);
3149
+ }
3150
+ }
3151
+ setInnerValue(() => newValue);
3152
+ }, [value]);
3153
+ useEffect(() => {
3154
+ setInnerShow(show);
3155
+ }, [show]);
3156
+ return /*#__PURE__*/React__default.createElement("input", {
3157
+ type: innerShow ? 'text' : 'password',
3158
+ value: innerValue,
3159
+ onInput: handleChange,
3160
+ name: inpAttributes?.iName,
3161
+ placeholder: inpAttributes?.placeholder,
3162
+ autoComplete: inpAttributes?.autoComplete,
3163
+ style: {
3164
+ ...inpStyles,
3165
+ border: 'none',
3166
+ outline: 'none',
3167
+ borderRadius: radius
3168
+ }
3169
+ });
3170
+ };
3171
+
3172
+ const NumberInput = ({
3173
+ dots,
3174
+ value,
3175
+ float,
3176
+ radius,
3177
+ inputChange,
3178
+ maxLength,
3179
+ inpStyles,
3180
+ inpAttributes,
3181
+ minNumSize,
3182
+ maxNumSize
3183
+ }) => {
3184
+ const [innerValue, setInnerValue] = useState('');
3185
+ const [innerMinNumSize, setInnerMinNumSize] = useState(0);
3186
+ const handleChange = event => {
3187
+ let prevValue = innerValue;
3188
+ let currentValue = event.target.value;
3189
+ const max = maxLength ? maxLength : null;
3190
+ currentValue = handleCheckTypeNumber(currentValue, prevValue, max, float, maxNumSize, dots, innerMinNumSize);
3191
+ setInnerValue(() => currentValue);
3192
+ if (inputChange && currentValue !== prevValue) {
3193
+ inputChange(currentValue);
3194
+ }
3195
+ };
3196
+ useEffect(() => {
3197
+ if (minNumSize && minNumSize < 0) {
3198
+ setInnerMinNumSize(0);
3199
+ alert("minNumSize prop can't be less then 0");
3200
+ } else if (minNumSize && minNumSize >= 0) {
3201
+ setInnerMinNumSize(minNumSize);
3202
+ }
3203
+ if ((maxNumSize || maxNumSize === 0 || minNumSize || minNumSize === 0) && (maxLength || maxLength === 0)) {
3204
+ alert("You can't use maxNumSize or minNumSize and maxLength props together when Input type is number");
3205
+ }
3206
+ if (maxNumSize < minNumSize) {
3207
+ alert("maxNumSize prop can't be less then minNumSize");
3208
+ }
3209
+ }, [maxLength, minNumSize, maxNumSize]);
3210
+ useEffect(() => {
3211
+ let newValue = '';
3212
+ if (value !== undefined && value !== null) {
3213
+ const max = maxLength ? maxLength : null;
3214
+ newValue = handleCheckTypeNumber(value, newValue, max, float, maxNumSize, dots, innerMinNumSize);
3215
+ }
3216
+ setInnerValue(() => newValue);
3217
+ }, [dots, value, float, maxNumSize, minNumSize]);
3218
+ return /*#__PURE__*/React__default.createElement("input", {
3219
+ type: "text",
3220
+ value: innerValue,
3221
+ name: inpAttributes?.iName,
3222
+ placeholder: inpAttributes?.placeholder,
3223
+ autoComplete: inpAttributes?.autoComplete,
3224
+ style: {
3225
+ ...inpStyles,
3226
+ border: 'none',
3227
+ outline: 'none',
3228
+ borderRadius: radius
3229
+ },
3230
+ min: minNumSize,
3231
+ max: maxNumSize,
3232
+ onInput: handleChange
3233
+ });
3234
+ };
3235
+
2955
3236
  var css_248z$9 = ".input-module_input-wrap__NunrE{position:relative;width:100%}.input-module_input-content__kP7lZ{appearance:none!important;-webkit-appearance:none!important;display:flex;width:100%}input:-webkit-autofill,input:-webkit-autofill:active,input:-webkit-autofill:focus,input:-webkit-autofill:hover{background-color:inherit!important}input::-ms-clear,input::-ms-reveal{display:none}.input-module_error-message-show__OrVSo{animation-fill-mode:forwards;animation-name:input-module_error-show__9MP6k}.input-module_inp-num__vH7HL::-webkit-inner-spin-button,.input-module_inp-num__vH7HL::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.input-module_inp-num__vH7HL[type=number]{-moz-appearance:textfield}@keyframes input-module_error-show__9MP6k{to{bottom:-20px;transform:scaleX(1);-webkit-transform:scaleX(1);-moz-transform:scaleX(1);-ms-transform:scaleX(1);-o-transform:scaleX(1)}}";
2956
3237
  var styles$7 = {"input-wrap":"input-module_input-wrap__NunrE","input-content":"input-module_input-content__kP7lZ","error-message-show":"input-module_error-message-show__OrVSo","error-show":"input-module_error-show__9MP6k","inp-num":"input-module_inp-num__vH7HL"};
2957
3238
  styleInject(css_248z$9);
@@ -3029,15 +3310,29 @@ const Input = ({
3029
3310
  telBorderRightColor,
3030
3311
  backgroundDisableColor,
3031
3312
  errorAnimationDuration,
3032
- telBorderRightColorHover,
3033
- ...props
3313
+ telBorderRightColorHover
3034
3314
  }) => {
3035
- const phoneNumberRegex = /^\d+$/;
3036
3315
  const [show, setShow] = useState(false);
3037
3316
  const [isHover, setIsHover] = useState(false);
3038
- const [innerValue, setInnerValue] = useState('');
3039
- const [innerMinNumSize, setInnerMinNumSize] = useState(0);
3040
3317
  const [innerErrorMessage, setInnerErrorMessage] = useState('');
3318
+ const inpStyles = {
3319
+ width: width ?? merge.INPUT.width,
3320
+ cursor: disabled ? 'not-allowed' : 'auto',
3321
+ height: height ?? merge.INPUT.height,
3322
+ padding: padding ?? merge.INPUT.padding,
3323
+ fontSize: size ?? merge.INPUT.font.size,
3324
+ fontStyle: style ?? merge.INPUT.font.style,
3325
+ fontWeight: weight ?? merge.INPUT.font.weight,
3326
+ fontFamily: family ?? merge.INPUT.font.family,
3327
+ boxSizing: boxSizing ?? merge.INPUT.box.sizing,
3328
+ color: innerErrorMessage && errorColor ? errorColor : color ? color : merge.INPUT.color,
3329
+ backgroundColor: disabled ? backgroundDisableColor ? backgroundDisableColor : merge.INPUT.colors.backgroundDisable : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3330
+ };
3331
+ const inpAttributes = {
3332
+ placeholder: placeholder ?? '',
3333
+ iName: name ? name : `tui_${random}_tui`,
3334
+ autoComplete: autoComplete ?? merge.INPUT.autoComplete
3335
+ };
3041
3336
  const random = Math.floor(Math.random() * 1000 + 1);
3042
3337
  const classProps = classnames(className ?? merge.INPUT.className, type === 'number' ? styles$7['inp-num'] : '', styles$7['input-wrap']);
3043
3338
  const errorShow = keyframes`
@@ -3053,100 +3348,6 @@ const Input = ({
3053
3348
  const animation = () => css`
3054
3349
  ${errorShow} ${errorAnimationDuration ? errorAnimationDuration : merge.INPUT.error.animationDuration} forwards
3055
3350
  `;
3056
- const handleCheckTypeTel = (val, prevVal) => {
3057
- if (type === 'tel') {
3058
- if (!phoneNumberRegex.test(val)) {
3059
- if (val !== '') {
3060
- val = prevVal;
3061
- }
3062
- } else {
3063
- if (val.length > 8) {
3064
- val = val.substr(0, 8);
3065
- }
3066
- }
3067
- }
3068
- return val;
3069
- };
3070
- const handleCheckTypeNumber = (val, prevVal) => {
3071
- if (type === 'number') {
3072
- if (maxLength && maxLength > 0) {
3073
- if (val.length > maxLength) {
3074
- val = val.substr(0, maxLength);
3075
- }
3076
- } else {
3077
- const regNum = floatToFix && floatToFix >= 0 ? /^\d+(\.)?(\d+)?$/ : /^\d+$/;
3078
- if (val.length > 16 && !val.includes('.')) {
3079
- val = val.substr(0, 16);
3080
- }
3081
- if (val > Number.MAX_SAFE_INTEGER) {
3082
- val = prevVal;
3083
- }
3084
- if (val < Number.MIN_SAFE_INTEGER) {
3085
- val = prevVal;
3086
- }
3087
- if (innerMinNumSize && val < innerMinNumSize) {
3088
- val = prevVal;
3089
- }
3090
- if (maxNumSize && val > maxNumSize) {
3091
- val = prevVal;
3092
- }
3093
- if (floatToFix > 0) {
3094
- const floatNumParts = typeof val === 'string' ? val.split('.') : val;
3095
- const int = floatNumParts[0];
3096
- const float = floatNumParts[1];
3097
- if (float && float.length > 0) {
3098
- let floatResult = '';
3099
- [...float].map((item, index) => {
3100
- if (index + 1 <= floatToFix) {
3101
- floatResult += item;
3102
- }
3103
- });
3104
- if (floatResult !== '') {
3105
- val = `${int}.${floatResult}`;
3106
- } else {
3107
- val = `${int}`;
3108
- }
3109
- }
3110
- } else {
3111
- const floatNumParts = typeof val === 'string' ? val.split('.') : val;
3112
- const int = floatNumParts[0];
3113
- if (floatNumParts && floatNumParts.length > 0 && floatToFix === 0) {
3114
- val = `${int}`;
3115
- }
3116
- }
3117
- if (!regNum.test(val)) {
3118
- const newStr = val.replace(/[^0-9.]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
3119
- return b + c.replace(/\./g, '');
3120
- });
3121
- val = newStr;
3122
- }
3123
- }
3124
- if (withoutDot && !/^\d+$/.test(val)) {
3125
- const newStr = val.replace(/[^0-9]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
3126
- return b + c.replace(/\./g, '');
3127
- });
3128
- val = newStr;
3129
- }
3130
- }
3131
- return val;
3132
- };
3133
- const handleChange = event => {
3134
- let prevValue = innerValue;
3135
- let currentValue = event.target.value;
3136
- const max = type === 'number' ? maxLength ? maxLength : null : maxLength ? maxLength : merge.INPUT.maxLength;
3137
- currentValue = handleCheckTypeTel(currentValue, prevValue);
3138
- currentValue = handleCheckTypeNumber(currentValue, prevValue);
3139
- if (max && currentValue.length > max && type !== 'tel' && type !== 'number') {
3140
- currentValue = currentValue.substr(0, max);
3141
- }
3142
- if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3143
- !regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3144
- }
3145
- setInnerValue(() => currentValue);
3146
- if (change && currentValue !== prevValue) {
3147
- change(currentValue);
3148
- }
3149
- };
3150
3351
  const handleMouseEnter = () => {
3151
3352
  setIsHover(true);
3152
3353
  };
@@ -3157,41 +3358,15 @@ const Input = ({
3157
3358
  setShow(!show);
3158
3359
  };
3159
3360
  useEffect(() => {
3160
- let newValue = value;
3161
3361
  if (errorMessage) {
3162
3362
  setInnerErrorMessage(errorMessage);
3163
3363
  } else {
3164
3364
  setInnerErrorMessage('');
3165
3365
  }
3166
- if (minNumSize && minNumSize < 0) {
3167
- setInnerMinNumSize(0);
3168
- alert("minNumSize prop can't be less then 0");
3169
- } else if (minNumSize && minNumSize >= 0) {
3170
- setInnerMinNumSize(minNumSize);
3171
- }
3172
- if (type === 'number' && (maxNumSize || maxNumSize === 0 || minNumSize || minNumSize === 0) && (maxLength || maxLength === 0)) {
3173
- alert("You can't use maxNumSize or minNumSize and maxLength props together when Input type is number");
3174
- }
3175
- if (type === 'number' && maxNumSize < minNumSize) {
3176
- alert("maxNumSize prop can't be less then minNumSize");
3177
- }
3178
- if (value !== undefined) {
3179
- if (value === null) {
3180
- newValue = '';
3181
- } else {
3182
- const max = type === 'number' ? maxLength ? maxLength : null : maxLength ? maxLength : merge.INPUT.maxLength;
3183
- newValue = handleCheckTypeTel(value, newValue);
3184
- newValue = handleCheckTypeNumber(value, newValue);
3185
- if (max && value.length > max && type !== 'tel' && type !== 'number') {
3186
- newValue = value.substr(0, max);
3187
- }
3188
- if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3189
- !regexp.test(value) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3190
- }
3191
- }
3366
+ if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3367
+ !regexp.test(value) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3192
3368
  }
3193
- setInnerValue(() => newValue);
3194
- }, [type, value, regexp, maxLength, maxNumSize, minNumSize, errorMessage, regexpErrorMessage]);
3369
+ }, [type, regexp, errorMessage, regexpErrorMessage]);
3195
3370
  return /*#__PURE__*/React__default.createElement("div", {
3196
3371
  className: classProps
3197
3372
  }, label ? /*#__PURE__*/React__default.createElement("label", {
@@ -3229,56 +3404,50 @@ const Input = ({
3229
3404
  borderBottomLeftRadius: radius ?? merge.INPUT.radius,
3230
3405
  backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3231
3406
  }
3232
- }, type === 'password' ? show ? leftIcon[1] : leftIcon[0] : leftIcon[0]) : '', type === 'tel' ? /*#__PURE__*/React__default.createElement("div", {
3233
- style: {
3234
- // border: 'none',
3235
- pointerEvents: disabled ? 'none' : 'auto',
3236
- fontSize: size ?? merge.INPUT.font.size,
3237
- fontStyle: style ?? merge.INPUT.font.style,
3238
- fontWeight: weight ?? merge.INPUT.font.weight,
3239
- fontFamily: family ?? merge.INPUT.font.family,
3240
- height: height ?? merge.INPUT.height,
3241
- padding: padding ?? merge.INPUT.padding,
3242
- boxSizing: boxSizing ?? merge.INPUT.box.sizing,
3243
- borderTopLeftRadius: radius ?? merge.INPUT.radius,
3244
- borderBottomLeftRadius: radius ?? merge.INPUT.radius,
3245
- display: phoneDisplay ?? merge.INPUT.tel.display,
3246
- borderRight: `
3247
- ${telBorderRightWidth ?? merge.INPUT.tel.borderRight.width}
3248
- ${telBorderRightStyle ?? merge.INPUT.tel.borderRight.style}`,
3249
- alignItems: phoneAlignItems ?? merge.INPUT.tel.alignItems,
3250
- borderColor: innerErrorMessage ? errorColor ? errorColor : merge.INPUT.error.color : isHover ? telBorderRightColorHover ? telBorderRightColorHover : merge.INPUT.tel.borderRight.colors.hover : telBorderRightColor ? telBorderRightColor : merge.INPUT.tel.borderRight.color,
3251
- color: innerErrorMessage && errorColor ? errorColor : color ? color : merge.INPUT.color,
3252
- justifyContent: phoneJustifyContent ?? merge.INPUT.tel.justifyContent,
3253
- backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3254
- }
3255
- }, "+374") : '', /*#__PURE__*/React__default.createElement("input", _extends({}, props, {
3256
- value: innerValue,
3257
- onInput: handleChange,
3258
- disabled: disabled ? disabled : '',
3259
- name: name ? name : `tui_${random}_tui`,
3260
- placeholder: placeholder ? placeholder : '',
3261
- type: show || type === 'number' ? 'text' : type,
3262
- min: type === 'number' && minNumSize ? minNumSize : '',
3263
- max: type === 'number' && maxNumSize ? maxNumSize : '',
3264
- autoComplete: autoComplete ? autoComplete : merge.INPUT.autoComplete,
3265
- style: {
3266
- border: 'none',
3267
- outline: 'none',
3268
- cursor: disabled ? 'not-allowed' : 'auto',
3269
- width: width ?? merge.INPUT.width,
3270
- fontSize: size ?? merge.INPUT.font.size,
3271
- fontStyle: style ?? merge.INPUT.font.style,
3272
- fontWeight: weight ?? merge.INPUT.font.weight,
3273
- fontFamily: family ?? merge.INPUT.font.family,
3274
- height: height ?? merge.INPUT.height,
3275
- padding: padding ?? merge.INPUT.padding,
3276
- borderRadius: radius ?? merge.INPUT.radius,
3277
- boxSizing: boxSizing ?? merge.INPUT.box.sizing,
3278
- color: innerErrorMessage && errorColor ? errorColor : color ? color : merge.INPUT.color,
3279
- backgroundColor: disabled ? backgroundDisableColor ? backgroundDisableColor : merge.INPUT.colors.backgroundDisable : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3280
- }
3281
- })), rightIcon && rightIcon.length > 0 ? /*#__PURE__*/React__default.createElement("div", {
3407
+ }, type === 'password' ? show ? leftIcon[1] : leftIcon[0] : leftIcon[0]) : '', type === 'tel' ? /*#__PURE__*/React__default.createElement(TelInput, {
3408
+ type: type,
3409
+ value: value,
3410
+ inputChange: change,
3411
+ isHover: isHover,
3412
+ disabled: disabled,
3413
+ inpStyles: inpStyles,
3414
+ inpAttributes: inpAttributes,
3415
+ radius: radius ?? merge.INPUT.radius,
3416
+ phoneDisplay: phoneDisplay ?? merge.INPUT.tel.display,
3417
+ phoneAlignItems: phoneAlignItems ?? merge.INPUT.tel.alignItems,
3418
+ phoneJustifyContent: phoneJustifyContent ?? merge.INPUT.tel.justifyContent,
3419
+ telBorderRightWidth: telBorderRightWidth ?? merge.INPUT.tel.borderRight.width,
3420
+ telBorderRightStyle: telBorderRightStyle ?? merge.INPUT.tel.borderRight.style,
3421
+ telBorderRightColor: telBorderRightColor ?? merge.INPUT.tel.borderRight.color,
3422
+ telBorderRightColorHover: telBorderRightColorHover ?? merge.INPUT.tel.borderRight.colors.hover
3423
+ }) : type === 'number' ? /*#__PURE__*/React__default.createElement(NumberInput, {
3424
+ value: value,
3425
+ inputChange: change,
3426
+ dots: withoutDot,
3427
+ float: floatToFix,
3428
+ maxLength: maxLength,
3429
+ inpStyles: inpStyles,
3430
+ inpAttributes: inpAttributes,
3431
+ minNumSize: minNumSize ? minNumSize : '',
3432
+ maxNumSize: maxNumSize ? maxNumSize : '',
3433
+ radius: radius ?? merge.INPUT.radius
3434
+ }) : type === 'password' ? /*#__PURE__*/React__default.createElement(PassInput, {
3435
+ show: show,
3436
+ type: type,
3437
+ value: value,
3438
+ inputChange: change,
3439
+ isHover: isHover,
3440
+ disabled: disabled,
3441
+ inpStyles: inpStyles,
3442
+ inpAttributes: inpAttributes,
3443
+ radius: radius ?? merge.INPUT.radius
3444
+ }) : /*#__PURE__*/React__default.createElement(TextInput, {
3445
+ value: value,
3446
+ inputChange: change,
3447
+ inpStyles: inpStyles,
3448
+ inpAttributes: inpAttributes,
3449
+ radius: radius ?? merge.INPUT.radius
3450
+ }), rightIcon && rightIcon.length > 0 ? /*#__PURE__*/React__default.createElement("div", {
3282
3451
  onClick: type === 'password' ? handleShowPass : _ => _,
3283
3452
  style: {
3284
3453
  display: 'flex',
package/dist/index.js CHANGED
@@ -2982,6 +2982,287 @@ Modal.defaultProps = {
2982
2982
  type: 'content'
2983
2983
  };
2984
2984
 
2985
+ const handleCheckTypeTel = (val, prevVal) => {
2986
+ const phoneNumberRegex = /^\d{0,8}$/;
2987
+ if (!phoneNumberRegex.test(val)) {
2988
+ val = prevVal;
2989
+ }
2990
+ return val;
2991
+ };
2992
+ const handleCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumSize, withoutDot, innerMinNumSize) => {
2993
+ if (maxLength && maxLength > 0) {
2994
+ if (val.length > maxLength) {
2995
+ val = val.substr(0, maxLength);
2996
+ }
2997
+ } else {
2998
+ const regNum = floatToFix && floatToFix >= 0 ? /^\d+(\.)?(\d+)?$/ : /^\d+$/;
2999
+ if (val.length > 16 && !val.includes('.')) {
3000
+ val = val.substr(0, 16);
3001
+ }
3002
+ if (val < Number.MIN_SAFE_INTEGER || val > Number.MAX_SAFE_INTEGER || innerMinNumSize && val < innerMinNumSize || maxNumSize && val > maxNumSize) {
3003
+ val = prevVal;
3004
+ }
3005
+ const floatNumParts = typeof val === 'string' ? val.split('.') : val;
3006
+ const int = floatNumParts[0];
3007
+ const float = floatNumParts[1];
3008
+ if (floatToFix > 0) {
3009
+ if (float && float.length > 0) {
3010
+ let floatResult = '';
3011
+ [...float].map((item, index) => {
3012
+ if (index + 1 <= floatToFix) {
3013
+ floatResult += item;
3014
+ }
3015
+ });
3016
+ floatResult !== '' ? val = `${int}.${floatResult}` : val = `${int}`;
3017
+ }
3018
+ } else {
3019
+ if (floatNumParts && floatNumParts.length > 0 && floatToFix === 0) {
3020
+ val = `${int}`;
3021
+ }
3022
+ }
3023
+ if (!regNum.test(val)) {
3024
+ const newStr = val.replace(/[^0-9.]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
3025
+ return b + c.replace(/\./g, '');
3026
+ });
3027
+ val = newStr;
3028
+ }
3029
+ }
3030
+ if (withoutDot && !/^\d+$/.test(val)) {
3031
+ const newStr = val.replace(/[^0-9]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
3032
+ return b + c.replace(/\./g, '');
3033
+ });
3034
+ val = newStr;
3035
+ }
3036
+ return val;
3037
+ };
3038
+
3039
+ const TelInput = ({
3040
+ type,
3041
+ value,
3042
+ radius,
3043
+ inputChange,
3044
+ isHover,
3045
+ disabled,
3046
+ inpStyles,
3047
+ errorColor,
3048
+ phoneDisplay,
3049
+ inpAttributes,
3050
+ phoneAlignItems,
3051
+ innerErrorMessage,
3052
+ telBorderRightWidth,
3053
+ telBorderRightColor,
3054
+ telBorderRightStyle,
3055
+ phoneJustifyContent,
3056
+ telBorderRightColorHover
3057
+ }) => {
3058
+ const [innerValue, setInnerValue] = React.useState('');
3059
+ const handleChange = event => {
3060
+ let prevValue = innerValue;
3061
+ let currentValue = event.target.value;
3062
+ currentValue = handleCheckTypeTel(currentValue, prevValue);
3063
+ setInnerValue(() => currentValue);
3064
+ if (inputChange && currentValue !== prevValue) {
3065
+ inputChange(currentValue);
3066
+ }
3067
+ };
3068
+ React.useEffect(() => {
3069
+ let newValue = '';
3070
+ if (value !== undefined && value !== null) {
3071
+ newValue = handleCheckTypeTel(value, newValue);
3072
+ }
3073
+ setInnerValue(() => newValue);
3074
+ }, [value]);
3075
+ return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
3076
+ style: {
3077
+ ...inpStyles,
3078
+ width: 'auto',
3079
+ display: phoneDisplay,
3080
+ alignItems: phoneAlignItems,
3081
+ borderTopLeftRadius: radius,
3082
+ borderBottomLeftRadius: radius,
3083
+ justifyContent: phoneJustifyContent,
3084
+ pointerEvents: disabled ? 'none' : 'auto',
3085
+ borderRight: `${telBorderRightWidth} ${telBorderRightStyle}`,
3086
+ borderColor: innerErrorMessage ? errorColor : isHover ? telBorderRightColorHover : telBorderRightColor
3087
+ }
3088
+ }, "+374"), /*#__PURE__*/React__default["default"].createElement("input", {
3089
+ type: type,
3090
+ value: innerValue,
3091
+ disabled: disabled,
3092
+ onInput: handleChange,
3093
+ name: inpAttributes?.iName,
3094
+ placeholder: inpAttributes?.placeholder,
3095
+ autoComplete: inpAttributes?.autoComplete,
3096
+ style: {
3097
+ ...inpStyles,
3098
+ border: 'none',
3099
+ outline: 'none',
3100
+ borderRadius: radius
3101
+ }
3102
+ }));
3103
+ };
3104
+
3105
+ const TextInput = ({
3106
+ value,
3107
+ radius,
3108
+ inputChange,
3109
+ maxLength,
3110
+ inpStyles,
3111
+ inpAttributes
3112
+ }) => {
3113
+ const [innerValue, setInnerValue] = React.useState('');
3114
+ const handleChange = event => {
3115
+ let prevValue = innerValue;
3116
+ let currentValue = event.target.value;
3117
+ if (maxLength && currentValue.length > maxLength) {
3118
+ currentValue = currentValue.substr(0, maxLength);
3119
+ }
3120
+ setInnerValue(() => currentValue);
3121
+ if (inputChange && currentValue !== prevValue) {
3122
+ inputChange(currentValue);
3123
+ }
3124
+ };
3125
+ React.useEffect(() => {
3126
+ let newValue = value;
3127
+ if (value !== undefined && value !== null) {
3128
+ newValue = value;
3129
+ if (maxLength && value.length > maxLength) {
3130
+ newValue = value.substr(0, maxLength);
3131
+ }
3132
+ }
3133
+ setInnerValue(() => newValue);
3134
+ }, [value]);
3135
+ return /*#__PURE__*/React__default["default"].createElement("input", {
3136
+ type: "text",
3137
+ value: innerValue,
3138
+ onInput: handleChange,
3139
+ name: inpAttributes?.iName,
3140
+ placeholder: inpAttributes?.placeholder,
3141
+ autoComplete: inpAttributes?.autoComplete,
3142
+ style: {
3143
+ ...inpStyles,
3144
+ border: 'none',
3145
+ outline: 'none',
3146
+ borderRadius: radius
3147
+ }
3148
+ });
3149
+ };
3150
+
3151
+ const PassInput = ({
3152
+ show,
3153
+ value,
3154
+ radius,
3155
+ inputChange,
3156
+ maxLength,
3157
+ inpAttributes,
3158
+ inpStyles
3159
+ }) => {
3160
+ const [innerShow, setInnerShow] = React.useState('');
3161
+ const [innerValue, setInnerValue] = React.useState('');
3162
+ const handleChange = event => {
3163
+ let prevValue = innerValue;
3164
+ let currentValue = event.target.value;
3165
+ if (maxLength && currentValue.length > maxLength) {
3166
+ currentValue = currentValue.substr(0, maxLength);
3167
+ }
3168
+ setInnerValue(() => currentValue);
3169
+ if (inputChange && currentValue !== prevValue) {
3170
+ inputChange(currentValue);
3171
+ }
3172
+ };
3173
+ React.useEffect(() => {
3174
+ let newValue = '';
3175
+ if (value !== undefined && value !== null) {
3176
+ newValue = value;
3177
+ if (maxLength && value.length > maxLength) {
3178
+ newValue = value.substr(0, maxLength);
3179
+ }
3180
+ }
3181
+ setInnerValue(() => newValue);
3182
+ }, [value]);
3183
+ React.useEffect(() => {
3184
+ setInnerShow(show);
3185
+ }, [show]);
3186
+ return /*#__PURE__*/React__default["default"].createElement("input", {
3187
+ type: innerShow ? 'text' : 'password',
3188
+ value: innerValue,
3189
+ onInput: handleChange,
3190
+ name: inpAttributes?.iName,
3191
+ placeholder: inpAttributes?.placeholder,
3192
+ autoComplete: inpAttributes?.autoComplete,
3193
+ style: {
3194
+ ...inpStyles,
3195
+ border: 'none',
3196
+ outline: 'none',
3197
+ borderRadius: radius
3198
+ }
3199
+ });
3200
+ };
3201
+
3202
+ const NumberInput = ({
3203
+ dots,
3204
+ value,
3205
+ float,
3206
+ radius,
3207
+ inputChange,
3208
+ maxLength,
3209
+ inpStyles,
3210
+ inpAttributes,
3211
+ minNumSize,
3212
+ maxNumSize
3213
+ }) => {
3214
+ const [innerValue, setInnerValue] = React.useState('');
3215
+ const [innerMinNumSize, setInnerMinNumSize] = React.useState(0);
3216
+ const handleChange = event => {
3217
+ let prevValue = innerValue;
3218
+ let currentValue = event.target.value;
3219
+ const max = maxLength ? maxLength : null;
3220
+ currentValue = handleCheckTypeNumber(currentValue, prevValue, max, float, maxNumSize, dots, innerMinNumSize);
3221
+ setInnerValue(() => currentValue);
3222
+ if (inputChange && currentValue !== prevValue) {
3223
+ inputChange(currentValue);
3224
+ }
3225
+ };
3226
+ React.useEffect(() => {
3227
+ if (minNumSize && minNumSize < 0) {
3228
+ setInnerMinNumSize(0);
3229
+ alert("minNumSize prop can't be less then 0");
3230
+ } else if (minNumSize && minNumSize >= 0) {
3231
+ setInnerMinNumSize(minNumSize);
3232
+ }
3233
+ if ((maxNumSize || maxNumSize === 0 || minNumSize || minNumSize === 0) && (maxLength || maxLength === 0)) {
3234
+ alert("You can't use maxNumSize or minNumSize and maxLength props together when Input type is number");
3235
+ }
3236
+ if (maxNumSize < minNumSize) {
3237
+ alert("maxNumSize prop can't be less then minNumSize");
3238
+ }
3239
+ }, [maxLength, minNumSize, maxNumSize]);
3240
+ React.useEffect(() => {
3241
+ let newValue = '';
3242
+ if (value !== undefined && value !== null) {
3243
+ const max = maxLength ? maxLength : null;
3244
+ newValue = handleCheckTypeNumber(value, newValue, max, float, maxNumSize, dots, innerMinNumSize);
3245
+ }
3246
+ setInnerValue(() => newValue);
3247
+ }, [dots, value, float, maxNumSize, minNumSize]);
3248
+ return /*#__PURE__*/React__default["default"].createElement("input", {
3249
+ type: "text",
3250
+ value: innerValue,
3251
+ name: inpAttributes?.iName,
3252
+ placeholder: inpAttributes?.placeholder,
3253
+ autoComplete: inpAttributes?.autoComplete,
3254
+ style: {
3255
+ ...inpStyles,
3256
+ border: 'none',
3257
+ outline: 'none',
3258
+ borderRadius: radius
3259
+ },
3260
+ min: minNumSize,
3261
+ max: maxNumSize,
3262
+ onInput: handleChange
3263
+ });
3264
+ };
3265
+
2985
3266
  var css_248z$9 = ".input-module_input-wrap__NunrE{position:relative;width:100%}.input-module_input-content__kP7lZ{appearance:none!important;-webkit-appearance:none!important;display:flex;width:100%}input:-webkit-autofill,input:-webkit-autofill:active,input:-webkit-autofill:focus,input:-webkit-autofill:hover{background-color:inherit!important}input::-ms-clear,input::-ms-reveal{display:none}.input-module_error-message-show__OrVSo{animation-fill-mode:forwards;animation-name:input-module_error-show__9MP6k}.input-module_inp-num__vH7HL::-webkit-inner-spin-button,.input-module_inp-num__vH7HL::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.input-module_inp-num__vH7HL[type=number]{-moz-appearance:textfield}@keyframes input-module_error-show__9MP6k{to{bottom:-20px;transform:scaleX(1);-webkit-transform:scaleX(1);-moz-transform:scaleX(1);-ms-transform:scaleX(1);-o-transform:scaleX(1)}}";
2986
3267
  var styles$7 = {"input-wrap":"input-module_input-wrap__NunrE","input-content":"input-module_input-content__kP7lZ","error-message-show":"input-module_error-message-show__OrVSo","error-show":"input-module_error-show__9MP6k","inp-num":"input-module_inp-num__vH7HL"};
2987
3268
  styleInject(css_248z$9);
@@ -3059,15 +3340,29 @@ const Input = ({
3059
3340
  telBorderRightColor,
3060
3341
  backgroundDisableColor,
3061
3342
  errorAnimationDuration,
3062
- telBorderRightColorHover,
3063
- ...props
3343
+ telBorderRightColorHover
3064
3344
  }) => {
3065
- const phoneNumberRegex = /^\d+$/;
3066
3345
  const [show, setShow] = React.useState(false);
3067
3346
  const [isHover, setIsHover] = React.useState(false);
3068
- const [innerValue, setInnerValue] = React.useState('');
3069
- const [innerMinNumSize, setInnerMinNumSize] = React.useState(0);
3070
3347
  const [innerErrorMessage, setInnerErrorMessage] = React.useState('');
3348
+ const inpStyles = {
3349
+ width: width ?? merge.INPUT.width,
3350
+ cursor: disabled ? 'not-allowed' : 'auto',
3351
+ height: height ?? merge.INPUT.height,
3352
+ padding: padding ?? merge.INPUT.padding,
3353
+ fontSize: size ?? merge.INPUT.font.size,
3354
+ fontStyle: style ?? merge.INPUT.font.style,
3355
+ fontWeight: weight ?? merge.INPUT.font.weight,
3356
+ fontFamily: family ?? merge.INPUT.font.family,
3357
+ boxSizing: boxSizing ?? merge.INPUT.box.sizing,
3358
+ color: innerErrorMessage && errorColor ? errorColor : color ? color : merge.INPUT.color,
3359
+ backgroundColor: disabled ? backgroundDisableColor ? backgroundDisableColor : merge.INPUT.colors.backgroundDisable : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3360
+ };
3361
+ const inpAttributes = {
3362
+ placeholder: placeholder ?? '',
3363
+ iName: name ? name : `tui_${random}_tui`,
3364
+ autoComplete: autoComplete ?? merge.INPUT.autoComplete
3365
+ };
3071
3366
  const random = Math.floor(Math.random() * 1000 + 1);
3072
3367
  const classProps = classnames__default["default"](className ?? merge.INPUT.className, type === 'number' ? styles$7['inp-num'] : '', styles$7['input-wrap']);
3073
3368
  const errorShow = styled.keyframes`
@@ -3083,100 +3378,6 @@ const Input = ({
3083
3378
  const animation = () => styled.css`
3084
3379
  ${errorShow} ${errorAnimationDuration ? errorAnimationDuration : merge.INPUT.error.animationDuration} forwards
3085
3380
  `;
3086
- const handleCheckTypeTel = (val, prevVal) => {
3087
- if (type === 'tel') {
3088
- if (!phoneNumberRegex.test(val)) {
3089
- if (val !== '') {
3090
- val = prevVal;
3091
- }
3092
- } else {
3093
- if (val.length > 8) {
3094
- val = val.substr(0, 8);
3095
- }
3096
- }
3097
- }
3098
- return val;
3099
- };
3100
- const handleCheckTypeNumber = (val, prevVal) => {
3101
- if (type === 'number') {
3102
- if (maxLength && maxLength > 0) {
3103
- if (val.length > maxLength) {
3104
- val = val.substr(0, maxLength);
3105
- }
3106
- } else {
3107
- const regNum = floatToFix && floatToFix >= 0 ? /^\d+(\.)?(\d+)?$/ : /^\d+$/;
3108
- if (val.length > 16 && !val.includes('.')) {
3109
- val = val.substr(0, 16);
3110
- }
3111
- if (val > Number.MAX_SAFE_INTEGER) {
3112
- val = prevVal;
3113
- }
3114
- if (val < Number.MIN_SAFE_INTEGER) {
3115
- val = prevVal;
3116
- }
3117
- if (innerMinNumSize && val < innerMinNumSize) {
3118
- val = prevVal;
3119
- }
3120
- if (maxNumSize && val > maxNumSize) {
3121
- val = prevVal;
3122
- }
3123
- if (floatToFix > 0) {
3124
- const floatNumParts = typeof val === 'string' ? val.split('.') : val;
3125
- const int = floatNumParts[0];
3126
- const float = floatNumParts[1];
3127
- if (float && float.length > 0) {
3128
- let floatResult = '';
3129
- [...float].map((item, index) => {
3130
- if (index + 1 <= floatToFix) {
3131
- floatResult += item;
3132
- }
3133
- });
3134
- if (floatResult !== '') {
3135
- val = `${int}.${floatResult}`;
3136
- } else {
3137
- val = `${int}`;
3138
- }
3139
- }
3140
- } else {
3141
- const floatNumParts = typeof val === 'string' ? val.split('.') : val;
3142
- const int = floatNumParts[0];
3143
- if (floatNumParts && floatNumParts.length > 0 && floatToFix === 0) {
3144
- val = `${int}`;
3145
- }
3146
- }
3147
- if (!regNum.test(val)) {
3148
- const newStr = val.replace(/[^0-9.]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
3149
- return b + c.replace(/\./g, '');
3150
- });
3151
- val = newStr;
3152
- }
3153
- }
3154
- if (withoutDot && !/^\d+$/.test(val)) {
3155
- const newStr = val.replace(/[^0-9]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
3156
- return b + c.replace(/\./g, '');
3157
- });
3158
- val = newStr;
3159
- }
3160
- }
3161
- return val;
3162
- };
3163
- const handleChange = event => {
3164
- let prevValue = innerValue;
3165
- let currentValue = event.target.value;
3166
- const max = type === 'number' ? maxLength ? maxLength : null : maxLength ? maxLength : merge.INPUT.maxLength;
3167
- currentValue = handleCheckTypeTel(currentValue, prevValue);
3168
- currentValue = handleCheckTypeNumber(currentValue, prevValue);
3169
- if (max && currentValue.length > max && type !== 'tel' && type !== 'number') {
3170
- currentValue = currentValue.substr(0, max);
3171
- }
3172
- if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3173
- !regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3174
- }
3175
- setInnerValue(() => currentValue);
3176
- if (change && currentValue !== prevValue) {
3177
- change(currentValue);
3178
- }
3179
- };
3180
3381
  const handleMouseEnter = () => {
3181
3382
  setIsHover(true);
3182
3383
  };
@@ -3187,41 +3388,15 @@ const Input = ({
3187
3388
  setShow(!show);
3188
3389
  };
3189
3390
  React.useEffect(() => {
3190
- let newValue = value;
3191
3391
  if (errorMessage) {
3192
3392
  setInnerErrorMessage(errorMessage);
3193
3393
  } else {
3194
3394
  setInnerErrorMessage('');
3195
3395
  }
3196
- if (minNumSize && minNumSize < 0) {
3197
- setInnerMinNumSize(0);
3198
- alert("minNumSize prop can't be less then 0");
3199
- } else if (minNumSize && minNumSize >= 0) {
3200
- setInnerMinNumSize(minNumSize);
3201
- }
3202
- if (type === 'number' && (maxNumSize || maxNumSize === 0 || minNumSize || minNumSize === 0) && (maxLength || maxLength === 0)) {
3203
- alert("You can't use maxNumSize or minNumSize and maxLength props together when Input type is number");
3204
- }
3205
- if (type === 'number' && maxNumSize < minNumSize) {
3206
- alert("maxNumSize prop can't be less then minNumSize");
3207
- }
3208
- if (value !== undefined) {
3209
- if (value === null) {
3210
- newValue = '';
3211
- } else {
3212
- const max = type === 'number' ? maxLength ? maxLength : null : maxLength ? maxLength : merge.INPUT.maxLength;
3213
- newValue = handleCheckTypeTel(value, newValue);
3214
- newValue = handleCheckTypeNumber(value, newValue);
3215
- if (max && value.length > max && type !== 'tel' && type !== 'number') {
3216
- newValue = value.substr(0, max);
3217
- }
3218
- if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3219
- !regexp.test(value) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3220
- }
3221
- }
3396
+ if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3397
+ !regexp.test(value) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3222
3398
  }
3223
- setInnerValue(() => newValue);
3224
- }, [type, value, regexp, maxLength, maxNumSize, minNumSize, errorMessage, regexpErrorMessage]);
3399
+ }, [type, regexp, errorMessage, regexpErrorMessage]);
3225
3400
  return /*#__PURE__*/React__default["default"].createElement("div", {
3226
3401
  className: classProps
3227
3402
  }, label ? /*#__PURE__*/React__default["default"].createElement("label", {
@@ -3259,56 +3434,50 @@ const Input = ({
3259
3434
  borderBottomLeftRadius: radius ?? merge.INPUT.radius,
3260
3435
  backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3261
3436
  }
3262
- }, type === 'password' ? show ? leftIcon[1] : leftIcon[0] : leftIcon[0]) : '', type === 'tel' ? /*#__PURE__*/React__default["default"].createElement("div", {
3263
- style: {
3264
- // border: 'none',
3265
- pointerEvents: disabled ? 'none' : 'auto',
3266
- fontSize: size ?? merge.INPUT.font.size,
3267
- fontStyle: style ?? merge.INPUT.font.style,
3268
- fontWeight: weight ?? merge.INPUT.font.weight,
3269
- fontFamily: family ?? merge.INPUT.font.family,
3270
- height: height ?? merge.INPUT.height,
3271
- padding: padding ?? merge.INPUT.padding,
3272
- boxSizing: boxSizing ?? merge.INPUT.box.sizing,
3273
- borderTopLeftRadius: radius ?? merge.INPUT.radius,
3274
- borderBottomLeftRadius: radius ?? merge.INPUT.radius,
3275
- display: phoneDisplay ?? merge.INPUT.tel.display,
3276
- borderRight: `
3277
- ${telBorderRightWidth ?? merge.INPUT.tel.borderRight.width}
3278
- ${telBorderRightStyle ?? merge.INPUT.tel.borderRight.style}`,
3279
- alignItems: phoneAlignItems ?? merge.INPUT.tel.alignItems,
3280
- borderColor: innerErrorMessage ? errorColor ? errorColor : merge.INPUT.error.color : isHover ? telBorderRightColorHover ? telBorderRightColorHover : merge.INPUT.tel.borderRight.colors.hover : telBorderRightColor ? telBorderRightColor : merge.INPUT.tel.borderRight.color,
3281
- color: innerErrorMessage && errorColor ? errorColor : color ? color : merge.INPUT.color,
3282
- justifyContent: phoneJustifyContent ?? merge.INPUT.tel.justifyContent,
3283
- backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3284
- }
3285
- }, "+374") : '', /*#__PURE__*/React__default["default"].createElement("input", _extends({}, props, {
3286
- value: innerValue,
3287
- onInput: handleChange,
3288
- disabled: disabled ? disabled : '',
3289
- name: name ? name : `tui_${random}_tui`,
3290
- placeholder: placeholder ? placeholder : '',
3291
- type: show || type === 'number' ? 'text' : type,
3292
- min: type === 'number' && minNumSize ? minNumSize : '',
3293
- max: type === 'number' && maxNumSize ? maxNumSize : '',
3294
- autoComplete: autoComplete ? autoComplete : merge.INPUT.autoComplete,
3295
- style: {
3296
- border: 'none',
3297
- outline: 'none',
3298
- cursor: disabled ? 'not-allowed' : 'auto',
3299
- width: width ?? merge.INPUT.width,
3300
- fontSize: size ?? merge.INPUT.font.size,
3301
- fontStyle: style ?? merge.INPUT.font.style,
3302
- fontWeight: weight ?? merge.INPUT.font.weight,
3303
- fontFamily: family ?? merge.INPUT.font.family,
3304
- height: height ?? merge.INPUT.height,
3305
- padding: padding ?? merge.INPUT.padding,
3306
- borderRadius: radius ?? merge.INPUT.radius,
3307
- boxSizing: boxSizing ?? merge.INPUT.box.sizing,
3308
- color: innerErrorMessage && errorColor ? errorColor : color ? color : merge.INPUT.color,
3309
- backgroundColor: disabled ? backgroundDisableColor ? backgroundDisableColor : merge.INPUT.colors.backgroundDisable : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3310
- }
3311
- })), rightIcon && rightIcon.length > 0 ? /*#__PURE__*/React__default["default"].createElement("div", {
3437
+ }, type === 'password' ? show ? leftIcon[1] : leftIcon[0] : leftIcon[0]) : '', type === 'tel' ? /*#__PURE__*/React__default["default"].createElement(TelInput, {
3438
+ type: type,
3439
+ value: value,
3440
+ inputChange: change,
3441
+ isHover: isHover,
3442
+ disabled: disabled,
3443
+ inpStyles: inpStyles,
3444
+ inpAttributes: inpAttributes,
3445
+ radius: radius ?? merge.INPUT.radius,
3446
+ phoneDisplay: phoneDisplay ?? merge.INPUT.tel.display,
3447
+ phoneAlignItems: phoneAlignItems ?? merge.INPUT.tel.alignItems,
3448
+ phoneJustifyContent: phoneJustifyContent ?? merge.INPUT.tel.justifyContent,
3449
+ telBorderRightWidth: telBorderRightWidth ?? merge.INPUT.tel.borderRight.width,
3450
+ telBorderRightStyle: telBorderRightStyle ?? merge.INPUT.tel.borderRight.style,
3451
+ telBorderRightColor: telBorderRightColor ?? merge.INPUT.tel.borderRight.color,
3452
+ telBorderRightColorHover: telBorderRightColorHover ?? merge.INPUT.tel.borderRight.colors.hover
3453
+ }) : type === 'number' ? /*#__PURE__*/React__default["default"].createElement(NumberInput, {
3454
+ value: value,
3455
+ inputChange: change,
3456
+ dots: withoutDot,
3457
+ float: floatToFix,
3458
+ maxLength: maxLength,
3459
+ inpStyles: inpStyles,
3460
+ inpAttributes: inpAttributes,
3461
+ minNumSize: minNumSize ? minNumSize : '',
3462
+ maxNumSize: maxNumSize ? maxNumSize : '',
3463
+ radius: radius ?? merge.INPUT.radius
3464
+ }) : type === 'password' ? /*#__PURE__*/React__default["default"].createElement(PassInput, {
3465
+ show: show,
3466
+ type: type,
3467
+ value: value,
3468
+ inputChange: change,
3469
+ isHover: isHover,
3470
+ disabled: disabled,
3471
+ inpStyles: inpStyles,
3472
+ inpAttributes: inpAttributes,
3473
+ radius: radius ?? merge.INPUT.radius
3474
+ }) : /*#__PURE__*/React__default["default"].createElement(TextInput, {
3475
+ value: value,
3476
+ inputChange: change,
3477
+ inpStyles: inpStyles,
3478
+ inpAttributes: inpAttributes,
3479
+ radius: radius ?? merge.INPUT.radius
3480
+ }), rightIcon && rightIcon.length > 0 ? /*#__PURE__*/React__default["default"].createElement("div", {
3312
3481
  onClick: type === 'password' ? handleShowPass : _ => _,
3313
3482
  style: {
3314
3483
  display: 'flex',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaypay/tui",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",