@xaypay/tui 0.2.9 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -2291,9 +2291,6 @@ const handleUtilsCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumS
2291
2291
  if (val.length > 16 && !val.includes('.')) {
2292
2292
  val = val.substr(0, 16);
2293
2293
  }
2294
- if (val < Number.MIN_SAFE_INTEGER || val > Number.MAX_SAFE_INTEGER || innerMinNumSize && val < innerMinNumSize || maxNumSize && val > maxNumSize) {
2295
- val = prevVal;
2296
- }
2297
2294
  const floatNumParts = typeof val === 'string' ? val.split(/\.|\․|\.|\,/) : val;
2298
2295
  const int = floatNumParts[0];
2299
2296
  const float = floatNumParts[1];
@@ -4056,23 +4053,31 @@ const NumberInput = ({
4056
4053
  float,
4057
4054
  radius,
4058
4055
  disabled,
4059
- maxLength,
4060
4056
  inpStyles,
4061
4057
  minNumSize,
4062
4058
  maxNumSize,
4063
4059
  inputChange,
4064
- inpAttributes
4060
+ inpAttributes,
4061
+ setInnerErrorMessage
4065
4062
  }) => {
4066
4063
  const [innerValue, setInnerValue] = useState('');
4067
4064
  const [innerMinNumSize, setInnerMinNumSize] = useState(0);
4068
4065
  const handleChange = event => {
4069
4066
  let prevValue = innerValue;
4070
4067
  let currentValue = event.target.value;
4071
- const max = maxLength ? maxLength : null;
4072
- currentValue = handleUtilsCheckTypeNumber(currentValue, prevValue, max, float, maxNumSize, dots, innerMinNumSize);
4068
+ currentValue = handleUtilsCheckTypeNumber(currentValue, prevValue, null, float, maxNumSize, dots);
4073
4069
  setInnerValue(() => currentValue);
4074
4070
  if (inputChange && currentValue !== prevValue) {
4075
- inputChange(currentValue);
4071
+ if (currentValue < Number.MIN_SAFE_INTEGER || currentValue > Number.MAX_SAFE_INTEGER || innerMinNumSize && currentValue < innerMinNumSize || maxNumSize && currentValue > maxNumSize) {
4072
+ if (currentValue === '') {
4073
+ setInnerErrorMessage(() => '');
4074
+ } else {
4075
+ setInnerErrorMessage(() => `Լրացված դաշտի արժեքը պետք է լինի ${innerMinNumSize} - ${maxNumSize} միջակայքում`);
4076
+ }
4077
+ } else if (currentValue >= Number.MIN_SAFE_INTEGER || currentValue <= Number.MAX_SAFE_INTEGER || innerMinNumSize && currentValue >= innerMinNumSize || maxNumSize && currentValue <= maxNumSize) {
4078
+ inputChange(currentValue);
4079
+ setInnerErrorMessage(() => '');
4080
+ }
4076
4081
  }
4077
4082
  };
4078
4083
  useEffect(() => {
@@ -4082,18 +4087,14 @@ const NumberInput = ({
4082
4087
  } else if (minNumSize && minNumSize >= 0) {
4083
4088
  setInnerMinNumSize(minNumSize);
4084
4089
  }
4085
- if ((maxNumSize || maxNumSize === 0 || minNumSize || minNumSize === 0) && (maxLength || maxLength === 0)) {
4086
- alert("You can't use maxNumSize or minNumSize and maxLength props together when Input type is number");
4087
- }
4088
- if (maxNumSize < minNumSize) {
4090
+ if (maxNumSize && maxNumSize < minNumSize) {
4089
4091
  alert("maxNumSize prop can't be less then minNumSize");
4090
4092
  }
4091
- }, [maxLength, minNumSize, maxNumSize]);
4093
+ }, [minNumSize, maxNumSize]);
4092
4094
  useEffect(() => {
4093
4095
  let newValue = '';
4094
4096
  if (value !== undefined && value !== null) {
4095
- const max = maxLength ? maxLength : null;
4096
- newValue = handleUtilsCheckTypeNumber(value, newValue, max, float, maxNumSize, dots, innerMinNumSize);
4097
+ newValue = handleUtilsCheckTypeNumber(value, newValue, null, float, maxNumSize, dots);
4097
4098
  }
4098
4099
  setInnerValue(() => newValue);
4099
4100
  }, [dots, value, float, maxNumSize, minNumSize]);
@@ -4327,11 +4328,11 @@ const Input = ({
4327
4328
  float: floatToFix,
4328
4329
  disabled: disabled,
4329
4330
  inputChange: change,
4330
- maxLength: maxLength,
4331
4331
  inpStyles: inpStyles,
4332
4332
  inpAttributes: inpAttributes,
4333
4333
  minNumSize: minNumSize ? minNumSize : '',
4334
4334
  maxNumSize: maxNumSize ? maxNumSize : '',
4335
+ setInnerErrorMessage: setInnerErrorMessage,
4335
4336
  radius: radius ?? configStyles.INPUT.radius
4336
4337
  }) : type === 'password' ? /*#__PURE__*/React__default.createElement(PassInput, {
4337
4338
  show: show,
@@ -4339,18 +4340,18 @@ const Input = ({
4339
4340
  value: innerValue,
4340
4341
  disabled: disabled,
4341
4342
  inputChange: change,
4342
- maxLength: maxLength,
4343
4343
  inpStyles: inpStyles,
4344
4344
  inpAttributes: inpAttributes,
4345
- radius: radius ?? configStyles.INPUT.radius
4345
+ radius: radius ?? configStyles.INPUT.radius,
4346
+ maxLength: maxLength ?? configStyles.INPUT.maxLength
4346
4347
  }) : /*#__PURE__*/React__default.createElement(TextInput, {
4347
4348
  value: innerValue,
4348
4349
  disabled: disabled,
4349
4350
  inputChange: change,
4350
4351
  inpStyles: inpStyles,
4351
- maxLength: maxLength,
4352
4352
  inpAttributes: inpAttributes,
4353
- radius: radius ?? configStyles.INPUT.radius
4353
+ radius: radius ?? configStyles.INPUT.radius,
4354
+ maxLength: maxLength ?? configStyles.INPUT.maxLength
4354
4355
  }), rightIcon && rightIcon.length > 0 ? /*#__PURE__*/React__default.createElement("div", {
4355
4356
  onClick: type === 'password' ? handleShowPass : _ => _,
4356
4357
  style: {
@@ -4829,9 +4830,9 @@ const Select = ({
4829
4830
  }
4830
4831
  }
4831
4832
  if (!multiple) {
4832
- options && options.length > 0 && setExistOptions(options);
4833
+ options && setExistOptions(options);
4833
4834
  } else {
4834
- const modifiedOptions = options && options.length > 0 && options.map(item => {
4835
+ const modifiedOptions = options && options.map(item => {
4835
4836
  item.checked = false;
4836
4837
  if (selected && selected.length > 0) {
4837
4838
  selected.map(innerItem => {
package/dist/index.js CHANGED
@@ -2322,9 +2322,6 @@ const handleUtilsCheckTypeNumber = (val, prevVal, maxLength, floatToFix, maxNumS
2322
2322
  if (val.length > 16 && !val.includes('.')) {
2323
2323
  val = val.substr(0, 16);
2324
2324
  }
2325
- if (val < Number.MIN_SAFE_INTEGER || val > Number.MAX_SAFE_INTEGER || innerMinNumSize && val < innerMinNumSize || maxNumSize && val > maxNumSize) {
2326
- val = prevVal;
2327
- }
2328
2325
  const floatNumParts = typeof val === 'string' ? val.split(/\.|\․|\.|\,/) : val;
2329
2326
  const int = floatNumParts[0];
2330
2327
  const float = floatNumParts[1];
@@ -4087,23 +4084,31 @@ const NumberInput = ({
4087
4084
  float,
4088
4085
  radius,
4089
4086
  disabled,
4090
- maxLength,
4091
4087
  inpStyles,
4092
4088
  minNumSize,
4093
4089
  maxNumSize,
4094
4090
  inputChange,
4095
- inpAttributes
4091
+ inpAttributes,
4092
+ setInnerErrorMessage
4096
4093
  }) => {
4097
4094
  const [innerValue, setInnerValue] = React.useState('');
4098
4095
  const [innerMinNumSize, setInnerMinNumSize] = React.useState(0);
4099
4096
  const handleChange = event => {
4100
4097
  let prevValue = innerValue;
4101
4098
  let currentValue = event.target.value;
4102
- const max = maxLength ? maxLength : null;
4103
- currentValue = handleUtilsCheckTypeNumber(currentValue, prevValue, max, float, maxNumSize, dots, innerMinNumSize);
4099
+ currentValue = handleUtilsCheckTypeNumber(currentValue, prevValue, null, float, maxNumSize, dots);
4104
4100
  setInnerValue(() => currentValue);
4105
4101
  if (inputChange && currentValue !== prevValue) {
4106
- inputChange(currentValue);
4102
+ if (currentValue < Number.MIN_SAFE_INTEGER || currentValue > Number.MAX_SAFE_INTEGER || innerMinNumSize && currentValue < innerMinNumSize || maxNumSize && currentValue > maxNumSize) {
4103
+ if (currentValue === '') {
4104
+ setInnerErrorMessage(() => '');
4105
+ } else {
4106
+ setInnerErrorMessage(() => `Լրացված դաշտի արժեքը պետք է լինի ${innerMinNumSize} - ${maxNumSize} միջակայքում`);
4107
+ }
4108
+ } else if (currentValue >= Number.MIN_SAFE_INTEGER || currentValue <= Number.MAX_SAFE_INTEGER || innerMinNumSize && currentValue >= innerMinNumSize || maxNumSize && currentValue <= maxNumSize) {
4109
+ inputChange(currentValue);
4110
+ setInnerErrorMessage(() => '');
4111
+ }
4107
4112
  }
4108
4113
  };
4109
4114
  React.useEffect(() => {
@@ -4113,18 +4118,14 @@ const NumberInput = ({
4113
4118
  } else if (minNumSize && minNumSize >= 0) {
4114
4119
  setInnerMinNumSize(minNumSize);
4115
4120
  }
4116
- if ((maxNumSize || maxNumSize === 0 || minNumSize || minNumSize === 0) && (maxLength || maxLength === 0)) {
4117
- alert("You can't use maxNumSize or minNumSize and maxLength props together when Input type is number");
4118
- }
4119
- if (maxNumSize < minNumSize) {
4121
+ if (maxNumSize && maxNumSize < minNumSize) {
4120
4122
  alert("maxNumSize prop can't be less then minNumSize");
4121
4123
  }
4122
- }, [maxLength, minNumSize, maxNumSize]);
4124
+ }, [minNumSize, maxNumSize]);
4123
4125
  React.useEffect(() => {
4124
4126
  let newValue = '';
4125
4127
  if (value !== undefined && value !== null) {
4126
- const max = maxLength ? maxLength : null;
4127
- newValue = handleUtilsCheckTypeNumber(value, newValue, max, float, maxNumSize, dots, innerMinNumSize);
4128
+ newValue = handleUtilsCheckTypeNumber(value, newValue, null, float, maxNumSize, dots);
4128
4129
  }
4129
4130
  setInnerValue(() => newValue);
4130
4131
  }, [dots, value, float, maxNumSize, minNumSize]);
@@ -4358,11 +4359,11 @@ const Input = ({
4358
4359
  float: floatToFix,
4359
4360
  disabled: disabled,
4360
4361
  inputChange: change,
4361
- maxLength: maxLength,
4362
4362
  inpStyles: inpStyles,
4363
4363
  inpAttributes: inpAttributes,
4364
4364
  minNumSize: minNumSize ? minNumSize : '',
4365
4365
  maxNumSize: maxNumSize ? maxNumSize : '',
4366
+ setInnerErrorMessage: setInnerErrorMessage,
4366
4367
  radius: radius ?? configStyles.INPUT.radius
4367
4368
  }) : type === 'password' ? /*#__PURE__*/React__default["default"].createElement(PassInput, {
4368
4369
  show: show,
@@ -4370,18 +4371,18 @@ const Input = ({
4370
4371
  value: innerValue,
4371
4372
  disabled: disabled,
4372
4373
  inputChange: change,
4373
- maxLength: maxLength,
4374
4374
  inpStyles: inpStyles,
4375
4375
  inpAttributes: inpAttributes,
4376
- radius: radius ?? configStyles.INPUT.radius
4376
+ radius: radius ?? configStyles.INPUT.radius,
4377
+ maxLength: maxLength ?? configStyles.INPUT.maxLength
4377
4378
  }) : /*#__PURE__*/React__default["default"].createElement(TextInput, {
4378
4379
  value: innerValue,
4379
4380
  disabled: disabled,
4380
4381
  inputChange: change,
4381
4382
  inpStyles: inpStyles,
4382
- maxLength: maxLength,
4383
4383
  inpAttributes: inpAttributes,
4384
- radius: radius ?? configStyles.INPUT.radius
4384
+ radius: radius ?? configStyles.INPUT.radius,
4385
+ maxLength: maxLength ?? configStyles.INPUT.maxLength
4385
4386
  }), rightIcon && rightIcon.length > 0 ? /*#__PURE__*/React__default["default"].createElement("div", {
4386
4387
  onClick: type === 'password' ? handleShowPass : _ => _,
4387
4388
  style: {
@@ -4860,9 +4861,9 @@ const Select = ({
4860
4861
  }
4861
4862
  }
4862
4863
  if (!multiple) {
4863
- options && options.length > 0 && setExistOptions(options);
4864
+ options && setExistOptions(options);
4864
4865
  } else {
4865
- const modifiedOptions = options && options.length > 0 && options.map(item => {
4866
+ const modifiedOptions = options && options.map(item => {
4866
4867
  item.checked = false;
4867
4868
  if (selected && selected.length > 0) {
4868
4869
  selected.map(innerItem => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xaypay/tui",
3
- "version": "0.2.9",
3
+ "version": "0.2.10",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.es.js",