react-gldn-kit 0.1.58 → 0.1.59

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.
@@ -79,9 +79,11 @@ var PhoneInput = function (props) {
79
79
  return value.length === countryPhoneSettings.length;
80
80
  }, [countryPhoneSettings]);
81
81
  var isValidPhone = (0, react_1.useMemo)(function () {
82
- var isValid = handleValidatePhoneNumber(phone.value);
82
+ var isValid = countryPhoneSettings.length
83
+ ? handleValidatePhoneNumber(phone.value)
84
+ : phone.value.length > 1 && !phone.errorText;
83
85
  return isValid;
84
- }, [phone, countryCodeDefault]);
86
+ }, [phone, countryPhoneSettings]);
85
87
  var toggleValue = function () {
86
88
  setOpenState(!isOpened);
87
89
  };
@@ -98,10 +100,21 @@ var PhoneInput = function (props) {
98
100
  var value = target.value;
99
101
  var _b = countryPhoneSettings.length, length = _b === void 0 ? 0 : _b, code = countryPhoneSettings.code;
100
102
  var fullLength = length + code.length;
101
- if (value.length > fullLength || !+value || code.length > value.length) {
103
+ if (!value) {
102
104
  return;
103
105
  }
104
- if (!countryPhoneSettings.length) {
106
+ if ((countryPhoneSettings === null || countryPhoneSettings === void 0 ? void 0 : countryPhoneSettings.length) &&
107
+ (value.length > fullLength || !+value || code.length > value.length)) {
108
+ return;
109
+ }
110
+ if ((countryPhoneSettings === null || countryPhoneSettings === void 0 ? void 0 : countryPhoneSettings.length) === undefined) {
111
+ return;
112
+ }
113
+ if (!length) {
114
+ setPhone({
115
+ value: "+".concat(value.replace('+', '')),
116
+ errorText: value.length > 12 && value.length < 16 ? '' : 'errors.phone',
117
+ });
105
118
  return;
106
119
  }
107
120
  setPhone({
@@ -123,8 +136,7 @@ var PhoneInput = function (props) {
123
136
  if (!countryInfo) {
124
137
  return;
125
138
  }
126
- var countryFullInfo = mock_1.COUNTRY_MOCK.find(function (c) { return c.id === 50; } //countryInfo.countryId
127
- );
139
+ var countryFullInfo = mock_1.COUNTRY_MOCK.find(function (c) { return c.id === countryInfo.countryId; });
128
140
  if (!countryFullInfo) {
129
141
  setCountryPhoneSettings(constants_1.DEFAULT_COUNTRY_INFO);
130
142
  return;
@@ -137,14 +149,6 @@ var PhoneInput = function (props) {
137
149
  }, [countryCodeDefault, countryInfo]);
138
150
  (0, react_1.useEffect)(function () {
139
151
  if (phone.value && !phone.errorText) {
140
- var errorText = (0, validation_1.composeValidations)([
141
- (0, validation_1.isRequired)({ value: phone.value, errorText: 'errors.required' }),
142
- (0, validation_1.isPhone)({ value: phone.value, errorText: 'errors.phone' }),
143
- ]);
144
- // TODO first render
145
- if (errorText) {
146
- return;
147
- }
148
152
  onChange(phone.value);
149
153
  return;
150
154
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-gldn-kit",
3
- "version": "0.1.58",
3
+ "version": "0.1.59",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "keywords": [],