@rh-support/components 2.1.0 → 2.1.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/PhoneInput/PhoneInput.tsx"],"names":[],"mappings":";AAAA,OAAO,mBAAmB,CAAC;AAS3B,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACtE,mBAAmB,CAAC,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,OAAO,KAAA,KAAK,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eAoOvC"}
1
+ {"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/PhoneInput/PhoneInput.tsx"],"names":[],"mappings":";AAAA,OAAO,mBAAmB,CAAC;AAS3B,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACtE,mBAAmB,CAAC,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,OAAO,KAAA,KAAK,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eAwOvC"}
@@ -69,7 +69,7 @@ function PhoneInput(props) {
69
69
  return countryItem;
70
70
  });
71
71
  const setLocalFormat = (phoneNumber) => {
72
- let localPhone = phoneNumber.replace(PREFIX, '');
72
+ let localPhone = phoneNumber.replace(PREFIX, '').trim();
73
73
  let localFormat;
74
74
  // Guessing countries according to user input
75
75
  const possibleCountries = initializedCountries.filter((country) => localPhone === null || localPhone === void 0 ? void 0 : localPhone.startsWith(country.dialCode.toString()));
@@ -95,7 +95,7 @@ function PhoneInput(props) {
95
95
  return localFormat;
96
96
  };
97
97
  const onPhoneChange = (phone) => {
98
- if (lodash_1.isEmpty(phone.replace(PREFIX, ''))) {
98
+ if (lodash_1.isEmpty(phone.trim()) || lodash_1.isEmpty(phone.replace(PREFIX, '').trim())) {
99
99
  setFormattedNumber('');
100
100
  onPhoneValueChange('');
101
101
  }
@@ -105,10 +105,10 @@ function PhoneInput(props) {
105
105
  const localFormat = setLocalFormat(phone);
106
106
  const _formattedNumber = formatNumber(phone, localFormat);
107
107
  setFormattedNumber(_formattedNumber);
108
- if (!phoneValue.startsWith(PREFIX) && regex.test(phone) && !lodash_1.isEqual(phone, '-')) {
109
- onPhoneValueChange(phone.startsWith(PREFIX) ? phone : PREFIX + phone);
108
+ if (!phone.trim().startsWith(PREFIX) && regex.test(phone) && !lodash_1.isEqual(phone, '-')) {
109
+ onPhoneValueChange(PREFIX + phone.trim());
110
110
  }
111
- else if (phone.length <= _formattedNumber.length) {
111
+ else if (phone.length <= localFormat.length) {
112
112
  onPhoneValueChange(phone);
113
113
  }
114
114
  };
@@ -193,6 +193,10 @@ function PhoneInput(props) {
193
193
  setInvalid && setInvalid(false);
194
194
  setFormattedNumber('');
195
195
  }
196
+ if (lodash_1.isEqual(phoneValue.trim(), PREFIX) && lodash_1.isEmpty(iso2)) {
197
+ onPhoneValueChange('');
198
+ setFormattedNumber('');
199
+ }
196
200
  // eslint-disable-next-line react-hooks/exhaustive-deps
197
201
  }, [phoneValue]);
198
202
  return (react_1.default.createElement(react_core_1.InputGroup, { className: "phone-number-input" },
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/PhoneInput/PhoneInput.tsx"],"names":[],"mappings":";AAAA,OAAO,mBAAmB,CAAC;AAS3B,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACtE,mBAAmB,CAAC,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,OAAO,KAAA,KAAK,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eAoOvC"}
1
+ {"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/PhoneInput/PhoneInput.tsx"],"names":[],"mappings":";AAAA,OAAO,mBAAmB,CAAC;AAS3B,UAAU,MAAM;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACrC,WAAW,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAAC;IACtE,mBAAmB,CAAC,EAAE,CAAC,MAAM,KAAA,KAAK,IAAI,CAAC;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,CAAC,OAAO,KAAA,KAAK,IAAI,CAAC;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,eAwOvC"}
@@ -44,7 +44,7 @@ export function PhoneInput(props) {
44
44
  return countryItem;
45
45
  });
46
46
  const setLocalFormat = (phoneNumber) => {
47
- let localPhone = phoneNumber.replace(PREFIX, '');
47
+ let localPhone = phoneNumber.replace(PREFIX, '').trim();
48
48
  let localFormat;
49
49
  // Guessing countries according to user input
50
50
  const possibleCountries = initializedCountries.filter((country) => localPhone === null || localPhone === void 0 ? void 0 : localPhone.startsWith(country.dialCode.toString()));
@@ -70,7 +70,7 @@ export function PhoneInput(props) {
70
70
  return localFormat;
71
71
  };
72
72
  const onPhoneChange = (phone) => {
73
- if (isEmpty(phone.replace(PREFIX, ''))) {
73
+ if (isEmpty(phone.trim()) || isEmpty(phone.replace(PREFIX, '').trim())) {
74
74
  setFormattedNumber('');
75
75
  onPhoneValueChange('');
76
76
  }
@@ -80,10 +80,10 @@ export function PhoneInput(props) {
80
80
  const localFormat = setLocalFormat(phone);
81
81
  const _formattedNumber = formatNumber(phone, localFormat);
82
82
  setFormattedNumber(_formattedNumber);
83
- if (!phoneValue.startsWith(PREFIX) && regex.test(phone) && !isEqual(phone, '-')) {
84
- onPhoneValueChange(phone.startsWith(PREFIX) ? phone : PREFIX + phone);
83
+ if (!phone.trim().startsWith(PREFIX) && regex.test(phone) && !isEqual(phone, '-')) {
84
+ onPhoneValueChange(PREFIX + phone.trim());
85
85
  }
86
- else if (phone.length <= _formattedNumber.length) {
86
+ else if (phone.length <= localFormat.length) {
87
87
  onPhoneValueChange(phone);
88
88
  }
89
89
  };
@@ -168,6 +168,10 @@ export function PhoneInput(props) {
168
168
  setInvalid && setInvalid(false);
169
169
  setFormattedNumber('');
170
170
  }
171
+ if (isEqual(phoneValue.trim(), PREFIX) && isEmpty(iso2)) {
172
+ onPhoneValueChange('');
173
+ setFormattedNumber('');
174
+ }
171
175
  // eslint-disable-next-line react-hooks/exhaustive-deps
172
176
  }, [phoneValue]);
173
177
  return (React.createElement(InputGroup, { className: "phone-number-input" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rh-support/components",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Contains all reusabel components for support app",
5
5
  "author": "Vikas Rathee <vrathee@redhat.com>",
6
6
  "license": "ISC",
@@ -80,7 +80,7 @@
80
80
  "@patternfly/react-core": "4.264.0",
81
81
  "@patternfly/react-table": "4.111.33",
82
82
  "@rh-support/types": "2.0.2",
83
- "@rh-support/user-permissions": "2.1.0",
83
+ "@rh-support/user-permissions": "2.1.1",
84
84
  "@rh-support/utils": "2.1.0",
85
85
  "dompurify": "^2.2.6",
86
86
  "downshift": "^6.0.5",
@@ -117,5 +117,5 @@
117
117
  "defaults and supports es6-module",
118
118
  "maintained node versions"
119
119
  ],
120
- "gitHead": "44f98fdf017d720df673a15bd27a2ac3e3309a88"
120
+ "gitHead": "edc82728887d89d9975d36c7a08b2ab6d7b73085"
121
121
  }