@xaypay/tui 0.1.1 → 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 +392 -199
  2. package/dist/index.js +392 -199
  3. package/package.json +1 -1
package/dist/index.es.js CHANGED
@@ -1596,14 +1596,15 @@ const TD = ({
1596
1596
  optionIndex
1597
1597
  });
1598
1598
  };
1599
- const handleContentList = (e, item, index, innerIndex, listContentId, listContent, listContentIndex) => {
1599
+ const handleContentList = (e, item, index, innerIndex, listContentId, listContent, listContentIndex, contentListInnerItem) => {
1600
1600
  handleContentListClick(e, {
1601
1601
  item,
1602
1602
  index,
1603
1603
  innerIndex,
1604
1604
  listContentId,
1605
1605
  listContent,
1606
- listContentIndex
1606
+ listContentIndex,
1607
+ contentListInnerItem
1607
1608
  });
1608
1609
  };
1609
1610
  return /*#__PURE__*/React__default.createElement("td", {
@@ -1763,20 +1764,46 @@ const TD = ({
1763
1764
  height: item.status === 'close' ? '0px' : 'auto'
1764
1765
  }
1765
1766
  }, item.contentList.map((innerItem, innerItemIndex) => {
1766
- return /*#__PURE__*/React__default.createElement("p", {
1767
- key: `${innerItem}_${innerItemIndex}`,
1768
- className: styles$9['list-text'],
1769
- style: {
1770
- maxWidth: '100%',
1771
- color: openListColor,
1772
- textAlign: tBodyTextAlign,
1773
- fontSize: openListFontSize,
1774
- fontStyle: openListFontStyle,
1775
- fontWeight: openListFontWeight,
1776
- fontFamily: openListFontFamily
1777
- },
1778
- onClick: e => handleContentList(e, item, index, innerIndex, innerItem.id, innerItem.content, innerItemIndex)
1779
- }, innerItem.content === 0 ? innerItem.content.toString() : innerItem.content ? innerItem.content : '');
1767
+ if (Array.isArray(innerItem.content)) {
1768
+ return /*#__PURE__*/React__default.createElement("div", {
1769
+ key: `__${innerItemIndex}__`,
1770
+ style: {
1771
+ display: 'flex',
1772
+ justifyContent: 'center'
1773
+ }
1774
+ }, innerItem.content.map((contInnerItem, contInnerIndex) => {
1775
+ return /*#__PURE__*/React__default.createElement("p", {
1776
+ key: `${contInnerItem}_${contInnerIndex}`,
1777
+ className: styles$9['list-text'],
1778
+ style: {
1779
+ maxWidth: '100%',
1780
+ color: openListColor,
1781
+ textAlign: tBodyTextAlign,
1782
+ fontSize: openListFontSize,
1783
+ fontStyle: openListFontStyle,
1784
+ fontWeight: openListFontWeight,
1785
+ fontFamily: openListFontFamily,
1786
+ marginRight: contInnerIndex === innerItem.content.length - 1 ? '0px' : '10px'
1787
+ },
1788
+ onClick: e => handleContentList(e, item, index, innerIndex, innerItem.id, innerItem.content, innerItemIndex, contInnerItem)
1789
+ }, contInnerItem.content === 0 ? contInnerItem.content.toString() : contInnerItem.content ? contInnerItem.content : '');
1790
+ }));
1791
+ } else {
1792
+ return /*#__PURE__*/React__default.createElement("p", {
1793
+ key: `${innerItem}_${innerItemIndex}`,
1794
+ className: styles$9['list-text'],
1795
+ style: {
1796
+ maxWidth: '100%',
1797
+ color: openListColor,
1798
+ textAlign: tBodyTextAlign,
1799
+ fontSize: openListFontSize,
1800
+ fontStyle: openListFontStyle,
1801
+ fontWeight: openListFontWeight,
1802
+ fontFamily: openListFontFamily
1803
+ },
1804
+ onClick: e => handleContentList(e, item, index, innerIndex, innerItem.id, innerItem.content, innerItemIndex)
1805
+ }, innerItem.content === 0 ? innerItem.content.toString() : innerItem.content ? innerItem.content : '');
1806
+ }
1780
1807
  }))), !hasOwnerProperty(item, 'hideArrow') && item.hideArrow !== false && hasOwnerProperty(item, 'rightArrow') && item.rightArrow === true ? hasOwnerProperty(item, 'contentList') && (hasOwnerProperty(item, 'closeArrow') || hasOwnerProperty(item, 'openArrow')) && /*#__PURE__*/React__default.createElement("div", {
1781
1808
  id: item.id,
1782
1809
  style: {
@@ -2256,7 +2283,8 @@ const Table = ({
2256
2283
  listItemId: data.listContentId,
2257
2284
  listItemContent: data.listContent,
2258
2285
  itemIndex: removeItemIndex !== undefined && removeItemIndex < data.innerIndex ? data.innerIndex - 1 : data.innerIndex,
2259
- listItemInnerIndex: data.listContentIndex
2286
+ listItemInnerIndex: data.listContentIndex,
2287
+ contentListInnerItem: data.contentListInnerItem
2260
2288
  };
2261
2289
  getData(listData);
2262
2290
  };
@@ -2924,6 +2952,287 @@ Modal.defaultProps = {
2924
2952
  type: 'content'
2925
2953
  };
2926
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
+
2927
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)}}";
2928
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"};
2929
3238
  styleInject(css_248z$9);
@@ -3001,15 +3310,29 @@ const Input = ({
3001
3310
  telBorderRightColor,
3002
3311
  backgroundDisableColor,
3003
3312
  errorAnimationDuration,
3004
- telBorderRightColorHover,
3005
- ...props
3313
+ telBorderRightColorHover
3006
3314
  }) => {
3007
- const phoneNumberRegex = /^\d+$/;
3008
3315
  const [show, setShow] = useState(false);
3009
3316
  const [isHover, setIsHover] = useState(false);
3010
- const [innerValue, setInnerValue] = useState('');
3011
- const [innerMinNumSize, setInnerMinNumSize] = useState(0);
3012
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
+ };
3013
3336
  const random = Math.floor(Math.random() * 1000 + 1);
3014
3337
  const classProps = classnames(className ?? merge.INPUT.className, type === 'number' ? styles$7['inp-num'] : '', styles$7['input-wrap']);
3015
3338
  const errorShow = keyframes`
@@ -3025,104 +3348,6 @@ const Input = ({
3025
3348
  const animation = () => css`
3026
3349
  ${errorShow} ${errorAnimationDuration ? errorAnimationDuration : merge.INPUT.error.animationDuration} forwards
3027
3350
  `;
3028
- const handleCheckTypeTel = (val, prevVal) => {
3029
- if (type === 'tel') {
3030
- if (!phoneNumberRegex.test(val)) {
3031
- if (errorMessage) {
3032
- setInnerErrorMessage(errorMessage);
3033
- }
3034
- if (val !== '') {
3035
- val = prevVal;
3036
- }
3037
- } else {
3038
- setInnerErrorMessage('');
3039
- if (val.length > 8) {
3040
- val = val.substr(0, 8);
3041
- }
3042
- }
3043
- }
3044
- return val;
3045
- };
3046
- const handleCheckTypeNumber = (val, prevVal) => {
3047
- if (type === 'number') {
3048
- if (maxLength && maxLength > 0) {
3049
- if (val.length > maxLength) {
3050
- val = val.substr(0, maxLength);
3051
- }
3052
- } else {
3053
- const regNum = floatToFix && floatToFix >= 0 ? /^\d+(\.)?(\d+)?$/ : /^\d+$/;
3054
- if (val.length > 16 && !val.includes('.')) {
3055
- val = val.substr(0, 16);
3056
- }
3057
- if (val > Number.MAX_SAFE_INTEGER) {
3058
- val = prevVal;
3059
- }
3060
- if (val < Number.MIN_SAFE_INTEGER) {
3061
- val = prevVal;
3062
- }
3063
- if (innerMinNumSize && val < innerMinNumSize) {
3064
- val = prevVal;
3065
- }
3066
- if (maxNumSize && val > maxNumSize) {
3067
- val = prevVal;
3068
- }
3069
- if (floatToFix > 0) {
3070
- const floatNumParts = typeof val === 'string' ? val.split('.') : val;
3071
- const int = floatNumParts[0];
3072
- const float = floatNumParts[1];
3073
- if (float && float.length > 0) {
3074
- let floatResult = '';
3075
- [...float].map((item, index) => {
3076
- if (index + 1 <= floatToFix) {
3077
- floatResult += item;
3078
- }
3079
- });
3080
- if (floatResult !== '') {
3081
- val = `${int}.${floatResult}`;
3082
- } else {
3083
- val = `${int}`;
3084
- }
3085
- }
3086
- } else {
3087
- const floatNumParts = typeof val === 'string' ? val.split('.') : val;
3088
- const int = floatNumParts[0];
3089
- if (floatNumParts && floatNumParts.length > 0 && floatToFix === 0) {
3090
- val = `${int}`;
3091
- }
3092
- }
3093
- if (!regNum.test(val)) {
3094
- const newStr = val.replace(/[^0-9.]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
3095
- return b + c.replace(/\./g, '');
3096
- });
3097
- val = newStr;
3098
- }
3099
- }
3100
- if (withoutDot && !/^\d+$/.test(val)) {
3101
- const newStr = val.replace(/[^0-9]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
3102
- return b + c.replace(/\./g, '');
3103
- });
3104
- val = newStr;
3105
- }
3106
- }
3107
- return val;
3108
- };
3109
- const handleChange = event => {
3110
- let prevValue = innerValue;
3111
- let currentValue = event.target.value;
3112
- const max = type === 'number' ? maxLength ? maxLength : null : maxLength ? maxLength : merge.INPUT.maxLength;
3113
- currentValue = handleCheckTypeTel(currentValue, prevValue);
3114
- currentValue = handleCheckTypeNumber(currentValue, prevValue);
3115
- if (max && currentValue.length > max && type !== 'tel' && type !== 'number') {
3116
- currentValue = currentValue.substr(0, max);
3117
- }
3118
- if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3119
- !regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3120
- }
3121
- setInnerValue(() => currentValue);
3122
- if (change && currentValue !== prevValue) {
3123
- change(currentValue);
3124
- }
3125
- };
3126
3351
  const handleMouseEnter = () => {
3127
3352
  setIsHover(true);
3128
3353
  };
@@ -3133,41 +3358,15 @@ const Input = ({
3133
3358
  setShow(!show);
3134
3359
  };
3135
3360
  useEffect(() => {
3136
- let newValue = value;
3137
3361
  if (errorMessage) {
3138
3362
  setInnerErrorMessage(errorMessage);
3139
3363
  } else {
3140
3364
  setInnerErrorMessage('');
3141
3365
  }
3142
- if (minNumSize && minNumSize < 0) {
3143
- setInnerMinNumSize(0);
3144
- alert("minNumSize prop can't be less then 0");
3145
- } else if (minNumSize && minNumSize >= 0) {
3146
- setInnerMinNumSize(minNumSize);
3147
- }
3148
- if (type === 'number' && (maxNumSize || maxNumSize === 0 || minNumSize || minNumSize === 0) && (maxLength || maxLength === 0)) {
3149
- alert("You can't use maxNumSize or minNumSize and maxLength props together when Input type is number");
3150
- }
3151
- if (type === 'number' && maxNumSize < minNumSize) {
3152
- alert("maxNumSize prop can't be less then minNumSize");
3153
- }
3154
- if (value !== undefined) {
3155
- if (value === null) {
3156
- newValue = '';
3157
- } else {
3158
- const max = type === 'number' ? maxLength ? maxLength : null : maxLength ? maxLength : merge.INPUT.maxLength;
3159
- newValue = handleCheckTypeTel(value, newValue);
3160
- newValue = handleCheckTypeNumber(value, newValue);
3161
- if (max && value.length > max && type !== 'tel' && type !== 'number') {
3162
- newValue = value.substr(0, max);
3163
- }
3164
- if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3165
- !regexp.test(value) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3166
- }
3167
- }
3366
+ if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3367
+ !regexp.test(value) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3168
3368
  }
3169
- setInnerValue(() => newValue);
3170
- }, [type, value, regexp, maxLength, maxNumSize, minNumSize, errorMessage, regexpErrorMessage]);
3369
+ }, [type, regexp, errorMessage, regexpErrorMessage]);
3171
3370
  return /*#__PURE__*/React__default.createElement("div", {
3172
3371
  className: classProps
3173
3372
  }, label ? /*#__PURE__*/React__default.createElement("label", {
@@ -3205,56 +3404,50 @@ const Input = ({
3205
3404
  borderBottomLeftRadius: radius ?? merge.INPUT.radius,
3206
3405
  backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3207
3406
  }
3208
- }, type === 'password' ? show ? leftIcon[1] : leftIcon[0] : leftIcon[0]) : '', type === 'tel' ? /*#__PURE__*/React__default.createElement("div", {
3209
- style: {
3210
- // border: 'none',
3211
- pointerEvents: disabled ? 'none' : 'auto',
3212
- fontSize: size ?? merge.INPUT.font.size,
3213
- fontStyle: style ?? merge.INPUT.font.style,
3214
- fontWeight: weight ?? merge.INPUT.font.weight,
3215
- fontFamily: family ?? merge.INPUT.font.family,
3216
- height: height ?? merge.INPUT.height,
3217
- padding: padding ?? merge.INPUT.padding,
3218
- boxSizing: boxSizing ?? merge.INPUT.box.sizing,
3219
- borderTopLeftRadius: radius ?? merge.INPUT.radius,
3220
- borderBottomLeftRadius: radius ?? merge.INPUT.radius,
3221
- display: phoneDisplay ?? merge.INPUT.tel.display,
3222
- borderRight: `
3223
- ${telBorderRightWidth ?? merge.INPUT.tel.borderRight.width}
3224
- ${telBorderRightStyle ?? merge.INPUT.tel.borderRight.style}`,
3225
- alignItems: phoneAlignItems ?? merge.INPUT.tel.alignItems,
3226
- borderColor: innerErrorMessage ? errorColor ? errorColor : merge.INPUT.error.color : isHover ? telBorderRightColorHover ? telBorderRightColorHover : merge.INPUT.tel.borderRight.colors.hover : telBorderRightColor ? telBorderRightColor : merge.INPUT.tel.borderRight.color,
3227
- color: innerErrorMessage && errorColor ? errorColor : color ? color : merge.INPUT.color,
3228
- justifyContent: phoneJustifyContent ?? merge.INPUT.tel.justifyContent,
3229
- backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3230
- }
3231
- }, "+374") : '', /*#__PURE__*/React__default.createElement("input", _extends({}, props, {
3232
- value: innerValue,
3233
- onInput: handleChange,
3234
- disabled: disabled ? disabled : '',
3235
- name: name ? name : `tui_${random}_tui`,
3236
- placeholder: placeholder ? placeholder : '',
3237
- type: show || type === 'number' ? 'text' : type,
3238
- min: type === 'number' && minNumSize ? minNumSize : '',
3239
- max: type === 'number' && maxNumSize ? maxNumSize : '',
3240
- autoComplete: autoComplete ? autoComplete : merge.INPUT.autoComplete,
3241
- style: {
3242
- border: 'none',
3243
- outline: 'none',
3244
- cursor: disabled ? 'not-allowed' : 'auto',
3245
- width: width ?? merge.INPUT.width,
3246
- fontSize: size ?? merge.INPUT.font.size,
3247
- fontStyle: style ?? merge.INPUT.font.style,
3248
- fontWeight: weight ?? merge.INPUT.font.weight,
3249
- fontFamily: family ?? merge.INPUT.font.family,
3250
- height: height ?? merge.INPUT.height,
3251
- padding: padding ?? merge.INPUT.padding,
3252
- borderRadius: radius ?? merge.INPUT.radius,
3253
- boxSizing: boxSizing ?? merge.INPUT.box.sizing,
3254
- color: innerErrorMessage && errorColor ? errorColor : color ? color : merge.INPUT.color,
3255
- backgroundColor: disabled ? backgroundDisableColor ? backgroundDisableColor : merge.INPUT.colors.backgroundDisable : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3256
- }
3257
- })), 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", {
3258
3451
  onClick: type === 'password' ? handleShowPass : _ => _,
3259
3452
  style: {
3260
3453
  display: 'flex',
package/dist/index.js CHANGED
@@ -1626,14 +1626,15 @@ const TD = ({
1626
1626
  optionIndex
1627
1627
  });
1628
1628
  };
1629
- const handleContentList = (e, item, index, innerIndex, listContentId, listContent, listContentIndex) => {
1629
+ const handleContentList = (e, item, index, innerIndex, listContentId, listContent, listContentIndex, contentListInnerItem) => {
1630
1630
  handleContentListClick(e, {
1631
1631
  item,
1632
1632
  index,
1633
1633
  innerIndex,
1634
1634
  listContentId,
1635
1635
  listContent,
1636
- listContentIndex
1636
+ listContentIndex,
1637
+ contentListInnerItem
1637
1638
  });
1638
1639
  };
1639
1640
  return /*#__PURE__*/React__default["default"].createElement("td", {
@@ -1793,20 +1794,46 @@ const TD = ({
1793
1794
  height: item.status === 'close' ? '0px' : 'auto'
1794
1795
  }
1795
1796
  }, item.contentList.map((innerItem, innerItemIndex) => {
1796
- return /*#__PURE__*/React__default["default"].createElement("p", {
1797
- key: `${innerItem}_${innerItemIndex}`,
1798
- className: styles$9['list-text'],
1799
- style: {
1800
- maxWidth: '100%',
1801
- color: openListColor,
1802
- textAlign: tBodyTextAlign,
1803
- fontSize: openListFontSize,
1804
- fontStyle: openListFontStyle,
1805
- fontWeight: openListFontWeight,
1806
- fontFamily: openListFontFamily
1807
- },
1808
- onClick: e => handleContentList(e, item, index, innerIndex, innerItem.id, innerItem.content, innerItemIndex)
1809
- }, innerItem.content === 0 ? innerItem.content.toString() : innerItem.content ? innerItem.content : '');
1797
+ if (Array.isArray(innerItem.content)) {
1798
+ return /*#__PURE__*/React__default["default"].createElement("div", {
1799
+ key: `__${innerItemIndex}__`,
1800
+ style: {
1801
+ display: 'flex',
1802
+ justifyContent: 'center'
1803
+ }
1804
+ }, innerItem.content.map((contInnerItem, contInnerIndex) => {
1805
+ return /*#__PURE__*/React__default["default"].createElement("p", {
1806
+ key: `${contInnerItem}_${contInnerIndex}`,
1807
+ className: styles$9['list-text'],
1808
+ style: {
1809
+ maxWidth: '100%',
1810
+ color: openListColor,
1811
+ textAlign: tBodyTextAlign,
1812
+ fontSize: openListFontSize,
1813
+ fontStyle: openListFontStyle,
1814
+ fontWeight: openListFontWeight,
1815
+ fontFamily: openListFontFamily,
1816
+ marginRight: contInnerIndex === innerItem.content.length - 1 ? '0px' : '10px'
1817
+ },
1818
+ onClick: e => handleContentList(e, item, index, innerIndex, innerItem.id, innerItem.content, innerItemIndex, contInnerItem)
1819
+ }, contInnerItem.content === 0 ? contInnerItem.content.toString() : contInnerItem.content ? contInnerItem.content : '');
1820
+ }));
1821
+ } else {
1822
+ return /*#__PURE__*/React__default["default"].createElement("p", {
1823
+ key: `${innerItem}_${innerItemIndex}`,
1824
+ className: styles$9['list-text'],
1825
+ style: {
1826
+ maxWidth: '100%',
1827
+ color: openListColor,
1828
+ textAlign: tBodyTextAlign,
1829
+ fontSize: openListFontSize,
1830
+ fontStyle: openListFontStyle,
1831
+ fontWeight: openListFontWeight,
1832
+ fontFamily: openListFontFamily
1833
+ },
1834
+ onClick: e => handleContentList(e, item, index, innerIndex, innerItem.id, innerItem.content, innerItemIndex)
1835
+ }, innerItem.content === 0 ? innerItem.content.toString() : innerItem.content ? innerItem.content : '');
1836
+ }
1810
1837
  }))), !hasOwnerProperty(item, 'hideArrow') && item.hideArrow !== false && hasOwnerProperty(item, 'rightArrow') && item.rightArrow === true ? hasOwnerProperty(item, 'contentList') && (hasOwnerProperty(item, 'closeArrow') || hasOwnerProperty(item, 'openArrow')) && /*#__PURE__*/React__default["default"].createElement("div", {
1811
1838
  id: item.id,
1812
1839
  style: {
@@ -2286,7 +2313,8 @@ const Table = ({
2286
2313
  listItemId: data.listContentId,
2287
2314
  listItemContent: data.listContent,
2288
2315
  itemIndex: removeItemIndex !== undefined && removeItemIndex < data.innerIndex ? data.innerIndex - 1 : data.innerIndex,
2289
- listItemInnerIndex: data.listContentIndex
2316
+ listItemInnerIndex: data.listContentIndex,
2317
+ contentListInnerItem: data.contentListInnerItem
2290
2318
  };
2291
2319
  getData(listData);
2292
2320
  };
@@ -2954,6 +2982,287 @@ Modal.defaultProps = {
2954
2982
  type: 'content'
2955
2983
  };
2956
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
+
2957
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)}}";
2958
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"};
2959
3268
  styleInject(css_248z$9);
@@ -3031,15 +3340,29 @@ const Input = ({
3031
3340
  telBorderRightColor,
3032
3341
  backgroundDisableColor,
3033
3342
  errorAnimationDuration,
3034
- telBorderRightColorHover,
3035
- ...props
3343
+ telBorderRightColorHover
3036
3344
  }) => {
3037
- const phoneNumberRegex = /^\d+$/;
3038
3345
  const [show, setShow] = React.useState(false);
3039
3346
  const [isHover, setIsHover] = React.useState(false);
3040
- const [innerValue, setInnerValue] = React.useState('');
3041
- const [innerMinNumSize, setInnerMinNumSize] = React.useState(0);
3042
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
+ };
3043
3366
  const random = Math.floor(Math.random() * 1000 + 1);
3044
3367
  const classProps = classnames__default["default"](className ?? merge.INPUT.className, type === 'number' ? styles$7['inp-num'] : '', styles$7['input-wrap']);
3045
3368
  const errorShow = styled.keyframes`
@@ -3055,104 +3378,6 @@ const Input = ({
3055
3378
  const animation = () => styled.css`
3056
3379
  ${errorShow} ${errorAnimationDuration ? errorAnimationDuration : merge.INPUT.error.animationDuration} forwards
3057
3380
  `;
3058
- const handleCheckTypeTel = (val, prevVal) => {
3059
- if (type === 'tel') {
3060
- if (!phoneNumberRegex.test(val)) {
3061
- if (errorMessage) {
3062
- setInnerErrorMessage(errorMessage);
3063
- }
3064
- if (val !== '') {
3065
- val = prevVal;
3066
- }
3067
- } else {
3068
- setInnerErrorMessage('');
3069
- if (val.length > 8) {
3070
- val = val.substr(0, 8);
3071
- }
3072
- }
3073
- }
3074
- return val;
3075
- };
3076
- const handleCheckTypeNumber = (val, prevVal) => {
3077
- if (type === 'number') {
3078
- if (maxLength && maxLength > 0) {
3079
- if (val.length > maxLength) {
3080
- val = val.substr(0, maxLength);
3081
- }
3082
- } else {
3083
- const regNum = floatToFix && floatToFix >= 0 ? /^\d+(\.)?(\d+)?$/ : /^\d+$/;
3084
- if (val.length > 16 && !val.includes('.')) {
3085
- val = val.substr(0, 16);
3086
- }
3087
- if (val > Number.MAX_SAFE_INTEGER) {
3088
- val = prevVal;
3089
- }
3090
- if (val < Number.MIN_SAFE_INTEGER) {
3091
- val = prevVal;
3092
- }
3093
- if (innerMinNumSize && val < innerMinNumSize) {
3094
- val = prevVal;
3095
- }
3096
- if (maxNumSize && val > maxNumSize) {
3097
- val = prevVal;
3098
- }
3099
- if (floatToFix > 0) {
3100
- const floatNumParts = typeof val === 'string' ? val.split('.') : val;
3101
- const int = floatNumParts[0];
3102
- const float = floatNumParts[1];
3103
- if (float && float.length > 0) {
3104
- let floatResult = '';
3105
- [...float].map((item, index) => {
3106
- if (index + 1 <= floatToFix) {
3107
- floatResult += item;
3108
- }
3109
- });
3110
- if (floatResult !== '') {
3111
- val = `${int}.${floatResult}`;
3112
- } else {
3113
- val = `${int}`;
3114
- }
3115
- }
3116
- } else {
3117
- const floatNumParts = typeof val === 'string' ? val.split('.') : val;
3118
- const int = floatNumParts[0];
3119
- if (floatNumParts && floatNumParts.length > 0 && floatToFix === 0) {
3120
- val = `${int}`;
3121
- }
3122
- }
3123
- if (!regNum.test(val)) {
3124
- const newStr = val.replace(/[^0-9.]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
3125
- return b + c.replace(/\./g, '');
3126
- });
3127
- val = newStr;
3128
- }
3129
- }
3130
- if (withoutDot && !/^\d+$/.test(val)) {
3131
- const newStr = val.replace(/[^0-9]/g, '').replace(/^([^.]*\.)(.*)$/, function (_, b, c) {
3132
- return b + c.replace(/\./g, '');
3133
- });
3134
- val = newStr;
3135
- }
3136
- }
3137
- return val;
3138
- };
3139
- const handleChange = event => {
3140
- let prevValue = innerValue;
3141
- let currentValue = event.target.value;
3142
- const max = type === 'number' ? maxLength ? maxLength : null : maxLength ? maxLength : merge.INPUT.maxLength;
3143
- currentValue = handleCheckTypeTel(currentValue, prevValue);
3144
- currentValue = handleCheckTypeNumber(currentValue, prevValue);
3145
- if (max && currentValue.length > max && type !== 'tel' && type !== 'number') {
3146
- currentValue = currentValue.substr(0, max);
3147
- }
3148
- if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3149
- !regexp.test(currentValue) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3150
- }
3151
- setInnerValue(() => currentValue);
3152
- if (change && currentValue !== prevValue) {
3153
- change(currentValue);
3154
- }
3155
- };
3156
3381
  const handleMouseEnter = () => {
3157
3382
  setIsHover(true);
3158
3383
  };
@@ -3163,41 +3388,15 @@ const Input = ({
3163
3388
  setShow(!show);
3164
3389
  };
3165
3390
  React.useEffect(() => {
3166
- let newValue = value;
3167
3391
  if (errorMessage) {
3168
3392
  setInnerErrorMessage(errorMessage);
3169
3393
  } else {
3170
3394
  setInnerErrorMessage('');
3171
3395
  }
3172
- if (minNumSize && minNumSize < 0) {
3173
- setInnerMinNumSize(0);
3174
- alert("minNumSize prop can't be less then 0");
3175
- } else if (minNumSize && minNumSize >= 0) {
3176
- setInnerMinNumSize(minNumSize);
3177
- }
3178
- if (type === 'number' && (maxNumSize || maxNumSize === 0 || minNumSize || minNumSize === 0) && (maxLength || maxLength === 0)) {
3179
- alert("You can't use maxNumSize or minNumSize and maxLength props together when Input type is number");
3180
- }
3181
- if (type === 'number' && maxNumSize < minNumSize) {
3182
- alert("maxNumSize prop can't be less then minNumSize");
3183
- }
3184
- if (value !== undefined) {
3185
- if (value === null) {
3186
- newValue = '';
3187
- } else {
3188
- const max = type === 'number' ? maxLength ? maxLength : null : maxLength ? maxLength : merge.INPUT.maxLength;
3189
- newValue = handleCheckTypeTel(value, newValue);
3190
- newValue = handleCheckTypeNumber(value, newValue);
3191
- if (max && value.length > max && type !== 'tel' && type !== 'number') {
3192
- newValue = value.substr(0, max);
3193
- }
3194
- if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3195
- !regexp.test(value) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3196
- }
3197
- }
3396
+ if (regexp && regexpErrorMessage && !maxLength && type !== 'tel') {
3397
+ !regexp.test(value) ? setInnerErrorMessage(regexpErrorMessage) : setInnerErrorMessage('');
3198
3398
  }
3199
- setInnerValue(() => newValue);
3200
- }, [type, value, regexp, maxLength, maxNumSize, minNumSize, errorMessage, regexpErrorMessage]);
3399
+ }, [type, regexp, errorMessage, regexpErrorMessage]);
3201
3400
  return /*#__PURE__*/React__default["default"].createElement("div", {
3202
3401
  className: classProps
3203
3402
  }, label ? /*#__PURE__*/React__default["default"].createElement("label", {
@@ -3235,56 +3434,50 @@ const Input = ({
3235
3434
  borderBottomLeftRadius: radius ?? merge.INPUT.radius,
3236
3435
  backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3237
3436
  }
3238
- }, type === 'password' ? show ? leftIcon[1] : leftIcon[0] : leftIcon[0]) : '', type === 'tel' ? /*#__PURE__*/React__default["default"].createElement("div", {
3239
- style: {
3240
- // border: 'none',
3241
- pointerEvents: disabled ? 'none' : 'auto',
3242
- fontSize: size ?? merge.INPUT.font.size,
3243
- fontStyle: style ?? merge.INPUT.font.style,
3244
- fontWeight: weight ?? merge.INPUT.font.weight,
3245
- fontFamily: family ?? merge.INPUT.font.family,
3246
- height: height ?? merge.INPUT.height,
3247
- padding: padding ?? merge.INPUT.padding,
3248
- boxSizing: boxSizing ?? merge.INPUT.box.sizing,
3249
- borderTopLeftRadius: radius ?? merge.INPUT.radius,
3250
- borderBottomLeftRadius: radius ?? merge.INPUT.radius,
3251
- display: phoneDisplay ?? merge.INPUT.tel.display,
3252
- borderRight: `
3253
- ${telBorderRightWidth ?? merge.INPUT.tel.borderRight.width}
3254
- ${telBorderRightStyle ?? merge.INPUT.tel.borderRight.style}`,
3255
- alignItems: phoneAlignItems ?? merge.INPUT.tel.alignItems,
3256
- borderColor: innerErrorMessage ? errorColor ? errorColor : merge.INPUT.error.color : isHover ? telBorderRightColorHover ? telBorderRightColorHover : merge.INPUT.tel.borderRight.colors.hover : telBorderRightColor ? telBorderRightColor : merge.INPUT.tel.borderRight.color,
3257
- color: innerErrorMessage && errorColor ? errorColor : color ? color : merge.INPUT.color,
3258
- justifyContent: phoneJustifyContent ?? merge.INPUT.tel.justifyContent,
3259
- backgroundColor: disabled ? '#FBFBFB' : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3260
- }
3261
- }, "+374") : '', /*#__PURE__*/React__default["default"].createElement("input", _extends({}, props, {
3262
- value: innerValue,
3263
- onInput: handleChange,
3264
- disabled: disabled ? disabled : '',
3265
- name: name ? name : `tui_${random}_tui`,
3266
- placeholder: placeholder ? placeholder : '',
3267
- type: show || type === 'number' ? 'text' : type,
3268
- min: type === 'number' && minNumSize ? minNumSize : '',
3269
- max: type === 'number' && maxNumSize ? maxNumSize : '',
3270
- autoComplete: autoComplete ? autoComplete : merge.INPUT.autoComplete,
3271
- style: {
3272
- border: 'none',
3273
- outline: 'none',
3274
- cursor: disabled ? 'not-allowed' : 'auto',
3275
- width: width ?? merge.INPUT.width,
3276
- fontSize: size ?? merge.INPUT.font.size,
3277
- fontStyle: style ?? merge.INPUT.font.style,
3278
- fontWeight: weight ?? merge.INPUT.font.weight,
3279
- fontFamily: family ?? merge.INPUT.font.family,
3280
- height: height ?? merge.INPUT.height,
3281
- padding: padding ?? merge.INPUT.padding,
3282
- borderRadius: radius ?? merge.INPUT.radius,
3283
- boxSizing: boxSizing ?? merge.INPUT.box.sizing,
3284
- color: innerErrorMessage && errorColor ? errorColor : color ? color : merge.INPUT.color,
3285
- backgroundColor: disabled ? backgroundDisableColor ? backgroundDisableColor : merge.INPUT.colors.backgroundDisable : backgroundColor ? backgroundColor : merge.INPUT.colors.background
3286
- }
3287
- })), 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", {
3288
3481
  onClick: type === 'password' ? handleShowPass : _ => _,
3289
3482
  style: {
3290
3483
  display: 'flex',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaypay/tui",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",